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

File diff suppressed because it is too large Load Diff

45
headers/glut.h Normal file
View File

@@ -0,0 +1,45 @@
#pragma once
/* creates a window with a bound GL context */
int glutCreateWindow(const char *title);
/* invoked after a glutPostRedisplay */
void glutDisplayFunc( void (*callback)(void));
void glutInit( char **devPaths, int count); /*initializes a */
void glutInitWindowPosition( int x, int y);
void glutInitWindowSize( int width, int height );
/* removed bc.
from the school projects see
/CGI/SHADING/packages/nupengl.core.0.1.0.1/build/native/include/GL
void glutInitContextVersion(4, 0);
void glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
void glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
*/
/* invokes CB after each keypress, passing keycode and mouse cords (buffered) */
void glutKeyboardFunc( void ( *callback) (unsigned char key, int x, int y));
/*starts any timer and then loops waiting for postRedisplay() */
void glutMainLoop();
/* passes to CB the xy coord relative to the screen */
void glutPassiveMotionFunc( void ( *callback) (int x, int y) );
/* issue a call to glutDisplayCB glutKeyboardFunc glutPassiveMotionFunc */
void glutPostRedisplay();
//glutSetCursor(GLUT_CURSOR_NONE);
void glutSwapBuffers();
/* waits TIME and then calls CB passing VAL as argument */
void glutTimerFunc( int time, void ( *callback)(int), int value);
/* forces mouse position to SCR_X SCR_Y */
void glutWarpPointer( int x, int y);

9
headers/glut_backend.h Normal file
View File

@@ -0,0 +1,9 @@
void init_implementation();
void init_window_size_implementation( int width, int height);
int create_window_implementation( const char *title);
void sleep_implementation();
void swap_buffers_implementation();

22
headers/glut_extensions.h Normal file
View File

@@ -0,0 +1,22 @@
#pragma once
#include <stdint.h>
#include "input/touch/touch_data.h"
typedef struct {
uint8_t ( *get_count) ( void);
void ( *get_tracked_events) ( touch_event ***store, uint8_t *count);
touch_coordinates* ( *getAABB) ( touch_event **events, uint8_t count);
float ( *get_width) ( touch_event **events, uint8_t count);
float ( *get_angle) ( touch_event **events, uint8_t count);
touch_coordinates* ( *get_midpoint) ( touch_event **events, uint8_t count);
void ( *get_position_deltas) (
touch_event **previous, uint8_t previous_count,
touch_event **current, uint8_t current_count,
touch_coordinates **deltas, uint8_t *count
);
float ( *get_angle_delta) ( float previous_angle, float current_angle);
touch_coordinates* ( *get_midpoint_delta) ( touch_coordinates previous, touch_coordinates current);
} touch_data_proxy;
touch_data_proxy glutGetTouchProxy();

5
headers/glut_graphics.h Normal file
View File

@@ -0,0 +1,5 @@
void assignRedrawCallback( void ( *callback) ( void));
void issueRedraw();
void consume_redraws();

15
headers/glut_input.h Normal file
View File

@@ -0,0 +1,15 @@
#pragma once
#include <my_device_handler.h>
void warp_pointer_implementation( int x, int y);
void assignKeyboardCallback( void ( *callback) (unsigned char key, int x, int y));
void assignMouseMotionCallback( void ( *callback) (int x, int y));
void process_inputs();
static void process_key_events();
static void process_cursor_events();

16
headers/glut_timers.h Normal file
View File

@@ -0,0 +1,16 @@
#pragma once
/* list of timers, no way to identify them, so no prunability outside of their exhaustion */
typedef struct timer_list_entry_t {
int remaining_ms;
void (*callback) (int);
struct timer_list_entry_t* next;
} timer_list_entry ;
void timers_add( timer_list_entry *toAdd);
void decrease_timers();
int timers_isEmpty();
int timers_isUpdating();

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