project for a (works on my devices) demo

This commit is contained in:
beno
2026-03-13 16:48:03 +01:00
parent 0c0b42fbd0
commit 7ca7ec5d61
38 changed files with 4797 additions and 62 deletions

View File

@@ -0,0 +1,49 @@
#pragma once
#include <events.h> /* from mydevicehandler */
/* should include it in the input library instead... */
#include <linux/input.h>
#include "touch/touch_controller_L1_builder.h"
extern unsigned char buffered_keys[KEY_CNT];
/* DELTAS
yes, typedef can also be used like this
typedef unsigned char buffered_keys_transition[KEY_CNT];
*/
void dispatch_input_event();
static void dispatch_input_absolute_event( device_event event);
static void dispatch_input_key_event( device_event event);
static void dispatch_regular_absolute_event( device_event event);
/* subtype of input_absolute_event */
static void dispatch_multitouch_event( device_event event);
/* common keyboard codes from 0 up to KEY_MACRO, before KEY_MUTE */
static void dispatch_keyboard_keys( device_event event);
/* interesting keys from KEY_MIN_INTERESTING = KEY_MUTE up to BTN_DEAD, before BTN_GAMEPAD */
static void dispatch_interesting_keys_1( device_event event);
/* joypad keys, from BTN_GAMEPAD up to BTN_THUMBR, gap of one before BTN_DIGI */
static void dispatch_interesting_keys_2( device_event event);
/* interesting keys, from BTN_DIGI up to the MAX */
static void dispatch_interesting_keys_3( device_event event);
/* reserving the NULL character code for unsupported keys
maps from linux input.h key codes to ascii
*/
char get_ascii_code( unsigned short linux_code);
/* shitty hack waiting for the use of hashmaps */
unsigned short remap_joypad_to_keyboard( unsigned short linux_key);

View File

@@ -0,0 +1,20 @@
#pragma once
#include "touch_data.h"
/* yes int instead of uint */
void TC_L1_builder_set_tracking_id( int64_t tracking_id);
void TC_L1_builder_set_position_x( uint64_t x_coord);
void TC_L1_builder_set_position_y( uint64_t y_coord);
void TC_L1_builder_set_major_axis( uint64_t width);
void TC_L1_builder_set_approaching_major_axis( uint64_t width);
void TC_L1_builder_set_slot_number( uint64_t number);
void TC_L1_builder_copy_tracked_events( touch_event ***store, uint8_t *count);
void TC_L1_builder_destroy_copy( touch_event **store, uint8_t count);

View File

@@ -0,0 +1,9 @@
#include "touch_data.h"
touch_coordinates* TC_L2_getAABB( touch_event **events, uint8_t count);
float TC_L2_get_width( touch_event **events, uint8_t count);
float TC_L2_get_angle( touch_event **events, uint8_t count);
touch_coordinates* TC_L2_get_midpoint( touch_event **events, uint8_t count);

View File

@@ -0,0 +1,13 @@
#pragma once
#include "touch_controller_L2.h"
void TC_L3_get_position_deltas(
touch_event **previous, uint8_t previous_count,
touch_event **current, uint8_t current_count,
touch_coordinates **deltas, uint8_t *count
);
float TC_L3_get_angle_delta( float previous_angle, float current_angle);
touch_coordinates* TC_L3_get_midpoint_delta( touch_coordinates previous, touch_coordinates current);

View File

@@ -0,0 +1,22 @@
#pragma once
#include <stdint.h>
typedef struct {
uint8_t state; /* entered unchanged exited */
uint8_t old_index;
uint8_t new_index;
uint64_t tracking_id;
} tracked_delta;
/* could also resort to TRANSIENT / PERSISTENT */
static const uint8_t TRACKED_DELTA_ENTERED = 0;
static const uint8_t TRACKED_DELTA_UNCHANGED = 1;
static const uint8_t TRACKED_DELTA_EXITED = 2;
void touch_events_sorted_ids_deltas(
tracked_delta **endbuffer, uint16_t *endcount,
uint64_t *previous_ids, uint8_t previous_count,
uint64_t *current_ids, uint8_t current_count
);

View File

@@ -0,0 +1,30 @@
#pragma once
#include <stdint.h>
typedef struct {
int64_t x; /* touch horizontal center */
int64_t y; /* touch vertical center */
} touch_coordinates;
/* using ultrawide ints (narrowing later) */
typedef struct {
uint64_t slot_number;
uint64_t tracking_id; /* this increases with each new touch */
touch_coordinates position;
/* ignoring ABS_MT_TOUCH_MAJOR
and ABS_MT_WIDTH_MAJOR
*/
} touch_event;
touch_event* touch_event_new();
void touch_event_copy( touch_event *dst, touch_event *src);
touch_coordinates* new_touch_coordinates_buffer( uint8_t count);
void free_touch_coordinates_buffer( touch_coordinates* buffer);
void touch_events_array_copy( touch_event ***dst, touch_event **src, uint8_t count);
void free_touch_events_array( touch_event **buffer, uint8_t count);

View File

@@ -0,0 +1,21 @@
ABS_MT_TRACKING_ID [UNIQUE ID OF INITIATED CONTACT] 100
ABS_MT_POSITION_X [CENTER X TOUCH POSITION] 288
ABS_MT_POSITION_Y [CENTER Y TOUCH POSITION] 1028
ABS_MT_TOUCH_MAJOR [MAJOR AXIS OF TOUCH ELLIPSE] 40
ABS_MT_WIDTH_MAJOR [MINOR AXIS OF APPROACHING ELLIPSE] 40
ABS_MT_SLOT [MULTITOUCH SLOT MODIFIED] 1
ABS_MT_TRACKING_ID [UNIQUE ID OF INITIATED CONTACT] 101
ABS_MT_POSITION_X [CENTER X TOUCH POSITION] 866
ABS_MT_POSITION_Y [CENTER Y TOUCH POSITION] 660
ABS_MT_TOUCH_MAJOR [MAJOR AXIS OF TOUCH ELLIPSE] 49
ABS_MT_WIDTH_MAJOR [MINOR AXIS OF APPROACHING ELLIPSE] 49
TOUCH EVENT BEGIN
separator for 0 : 0
ABS_MT_SLOT [MULTITOUCH SLOT MODIFIED] 0
ABS_MT_TRACKING_ID [UNIQUE ID OF INITIATED CONTACT] -1
ABS_MT_SLOT [MULTITOUCH SLOT MODIFIED] 1
ABS_MT_TRACKING_ID [UNIQUE ID OF INITIATED CONTACT] -1
TOUCH EVENT END
separator for 0 : 0