|
21 | 21 | extern "C" {
|
22 | 22 | #endif
|
23 | 23 |
|
| 24 | +typedef struct { |
| 25 | + int x; // X position of the mouse |
| 26 | + int y; // Y position of the mouse |
| 27 | + int button; // Mouse button (0 = left, 1 = right, etc.) |
| 28 | + int shift; // 1 if Shift is pressed, 0 otherwise |
| 29 | + int ctrl; // 1 if Ctrl is pressed, 0 otherwise |
| 30 | + int alt; // 1 if Alt is pressed, 0 otherwise |
| 31 | +} fossil_io_mouse_event_t; |
| 32 | + |
| 33 | +typedef void (*fossil_io_mouse_callback_t)(fossil_io_mouse_event_t event); |
| 34 | + |
| 35 | +#define MAX_MOUSEBINDS 256 |
| 36 | + |
| 37 | +typedef struct { |
| 38 | + fossil_io_mouse_event_t event; |
| 39 | + fossil_io_mouse_callback_t callback; |
| 40 | +} fossil_io_mouse_binding_t; |
| 41 | + |
| 42 | +typedef struct { |
| 43 | + fossil_io_mouse_binding_t bindings[MAX_MOUSEBINDS]; |
| 44 | + size_t count; |
| 45 | +} fossil_io_mouse_manager_t; |
| 46 | + |
| 47 | +static fossil_io_mouse_manager_t mouse_manager = { .count = 0 }; |
| 48 | + |
| 49 | +typedef struct { |
| 50 | + int x; // X position of the touch |
| 51 | + int y; // Y position of the touch |
| 52 | + int touch_id; // Unique identifier for the touch (for multi-touch) |
| 53 | + int action; // Action: 0 = start, 1 = move, 2 = end |
| 54 | + int shift; // 1 if Shift is pressed, 0 otherwise |
| 55 | + int ctrl; // 1 if Ctrl is pressed, 0 otherwise |
| 56 | + int alt; // 1 if Alt is pressed, 0 otherwise |
| 57 | +} fossil_io_touch_event_t; |
| 58 | + |
| 59 | +typedef void (*fossil_io_touch_callback_t)(fossil_io_touch_event_t event); |
| 60 | + |
| 61 | +#define MAX_TOUCHBINDS 256 |
| 62 | + |
| 63 | +typedef struct { |
| 64 | + fossil_io_touch_event_t event; |
| 65 | + fossil_io_touch_callback_t callback; |
| 66 | +} fossil_io_touch_binding_t; |
| 67 | + |
| 68 | +typedef struct { |
| 69 | + fossil_io_touch_binding_t bindings[MAX_TOUCHBINDS]; |
| 70 | + size_t count; |
| 71 | +} fossil_io_touch_manager_t; |
| 72 | + |
| 73 | +static fossil_io_touch_manager_t touch_manager = { .count = 0 }; |
| 74 | + |
24 | 75 | // Define a keyboard event structure
|
25 | 76 | typedef struct {
|
26 | 77 | int shift; // 1 if Shift is pressed, 0 otherwise
|
@@ -70,6 +121,20 @@ void fossil_io_keyboard_unregister_binding(fossil_io_keyboard_event_t event);
|
70 | 121 | */
|
71 | 122 | void fossil_io_keyboard_poll_events(void);
|
72 | 123 |
|
| 124 | +// Functions for mouse handling |
| 125 | +void fossil_io_mouse_init(void); // Initialize the mouse event library |
| 126 | +void fossil_io_mouse_shutdown(void); // Shut down the mouse event library |
| 127 | +void fossil_io_mouse_register_binding(fossil_io_mouse_event_t event, fossil_io_mouse_callback_t callback); // Register a mouse binding |
| 128 | +void fossil_io_mouse_unregister_binding(fossil_io_mouse_event_t event); // Unregister a mouse binding |
| 129 | +void fossil_io_mouse_poll_events(void); |
| 130 | + |
| 131 | +// Functions for touch handling |
| 132 | +void fossil_io_touch_init(void); // Initialize the touch event library |
| 133 | +void fossil_io_touch_shutdown(void); // Shut down the touch event library |
| 134 | +void fossil_io_touch_register_binding(fossil_io_touch_event_t event, fossil_io_touch_callback_t callback); // Register a touch binding |
| 135 | +void fossil_io_touch_unregister_binding(fossil_io_touch_event_t event); // Unregister a touch binding |
| 136 | +void fossil_io_touch_poll_events(void); |
| 137 | + |
73 | 138 | #ifdef __cplusplus
|
74 | 139 | }
|
75 | 140 |
|
|
0 commit comments