debug.c needs dylib.h.
[SquirrelJME.git] / nanocoat / include / lib / scritchinput / scritchinput.h
blob3b36991c8754f974661668750a0948c99bfbfe8a
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 /**
11 * Scritch Input Library.
13 * @since 2024/05/01
16 #ifndef SQUIRRELJME_SCRITCHINPUT_H
17 #define SQUIRRELJME_SCRITCHINPUT_H
19 #include "sjme/stdTypes.h"
21 /* Anti-C++. */
22 #ifdef __cplusplus
23 #ifndef SJME_CXX_IS_EXTERNED
24 #define SJME_CXX_IS_EXTERNED
25 #define SJME_CXX_SQUIRRELJME_SCRITCHINPUT_H
26 extern "C" {
27 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
28 #endif /* #ifdef __cplusplus */
30 /*--------------------------------------------------------------------------*/
32 /**
33 * The types of events that are possible.
35 * @since 2024/06/28
37 typedef enum sjme_scritchinput_type
39 /** Unknown event. */
40 SJME_SCRITCHINPUT_TYPE_UNKNOWN = 0,
42 /** Key event: Pressed. */
43 SJME_SCRITCHINPUT_TYPE_KEY_PRESSED = 1,
45 /** Key event: Released. */
46 SJME_SCRITCHINPUT_TYPE_KEY_RELEASED = 2,
48 /** Key event: Repeated. */
49 SJME_SCRITCHINPUT_TYPE_KEY_REPEATED = 4,
51 /** Mouse event: Button pressed. */
52 SJME_SCRITCHINPUT_TYPE_MOUSE_BUTTON_PRESSED = 8,
54 /** Mouse event: Button released. */
55 SJME_SCRITCHINPUT_TYPE_MOUSE_BUTTON_RELEASED = 16,
57 /** Mouse event: Motion. */
58 SJME_SCRITCHINPUT_TYPE_MOUSE_MOTION = 32,
60 /** Gamepad event: Button pressed. */
61 SJME_SCRITCHINPUT_TYPE_GAMEPAD_BUTTON_PRESSED = 64,
63 /** Gamepad event: Button released. */
64 SJME_SCRITCHINPUT_TYPE_GAMEPAD_BUTTON_RELEASED = 128,
66 /** Gamepad event: Motion on axis. */
67 SJME_SCRITCHINPUT_TYPE_GAMEPAD_AXIS_MOTION = 256,
69 /** Touch event: Finger pressed. */
70 SJME_SCRITCHINPUT_TYPE_TOUCH_FINGER_PRESSED = 512,
72 /** Touch event: Finger released. */
73 SJME_SCRITCHINPUT_TYPE_TOUCH_FINGER_RELEASED = 1024,
75 /** Touch event: Drag motion. */
76 SJME_SCRITCHINPUT_TYPE_TOUCH_DRAG_MOTION = 2048,
78 /** Stylus event: Pressed. */
79 SJME_SCRITCHINPUT_TYPE_STYLUS_PEN_PRESSED = 4096,
81 /** Stylus event: Released. */
82 SJME_SCRITCHINPUT_TYPE_STYLUS_PEN_RELEASED = 8192,
84 /** Stylus event: Dragging motion. */
85 SJME_SCRITCHINPUT_TYPE_STYLUS_DRAG_MOTION = 16384,
87 /** Stylus event: Hovering over display. */
88 SJME_SCRITCHINPUT_TYPE_STYLUS_HOVER_MOTION = 32768,
90 /** Gyroscope event: Axis motion. */
91 SJME_SCRITCHINPUT_TYPE_GYRO_AXIS_MOTION = 65536,
93 /** Device action (flip open/close, shaken, not stirred). */
94 SJME_SCRITCHINPUT_TYPE_DEVICE_ACTION = 131072,
96 /** A character key was pressed. */
97 SJME_SCRITCHINPUT_TYPE_KEY_CHAR_PRESSED = 262144,
98 } sjme_scritchinput_type;
100 typedef enum sjme_scritchinput_key
102 /** Backspace. */
103 SJME_SCRITCHINPUT_KEY_BACKSPACE = 8,
105 /** Tab. */
106 SJME_SCRITCHINPUT_KEY_TAB = 9,
108 /** Enter. */
109 SJME_SCRITCHINPUT_KEY_ENTER = 10,
111 /** Escape. */
112 SJME_SCRITCHINPUT_KEY_ESCAPE = 27,
114 /** Star key. */
115 SJME_SCRITCHINPUT_KEY_STAR = 42,
117 /** Space key. */
118 SJME_SCRITCHINPUT_KEY_SPACE = 32,
120 /** Pound key. */
121 SJME_SCRITCHINPUT_KEY_POUND = 35,
123 /** Delete key. */
124 SJME_SCRITCHINPUT_KEY_DELETE = 127,
126 /** Unknown, zero is the invalid index so always make it known. */
127 SJME_SCRITCHINPUT_KEY_UNKNOWN = 0,
129 /** The up arrow key. */
130 SJME_SCRITCHINPUT_KEY_UP = -1,
132 /** Down arrow key. */
133 SJME_SCRITCHINPUT_KEY_DOWN = -2,
135 /** Left arrow key. */
136 SJME_SCRITCHINPUT_KEY_LEFT = -3,
138 /** Right arrow key. */
139 SJME_SCRITCHINPUT_KEY_RIGHT = -4,
141 /** Game Up. */
142 SJME_SCRITCHINPUT_KEY_VGAME_UP = -9,
144 /** Game Down. */
145 SJME_SCRITCHINPUT_KEY_VGAME_DOWN = -10,
147 /** Game Left. */
148 SJME_SCRITCHINPUT_KEY_VGAME_LEFT = -11,
150 /** Game Right. */
151 SJME_SCRITCHINPUT_KEY_VGAME_RIGHT = -12,
153 /** Game fire. */
154 SJME_SCRITCHINPUT_KEY_VGAME_FIRE = -13,
156 /** Game A. */
157 SJME_SCRITCHINPUT_KEY_VGAME_A = -14,
159 /** Game B. */
160 SJME_SCRITCHINPUT_KEY_VGAME_B = -15,
162 /** Game C. */
163 SJME_SCRITCHINPUT_KEY_VGAME_C = -16,
165 /** Game D. */
166 SJME_SCRITCHINPUT_KEY_VGAME_D = -17,
168 /** Shift. */
169 SJME_SCRITCHINPUT_KEY_SHIFT = -18,
171 /** Control. */
172 SJME_SCRITCHINPUT_KEY_CONTROL = -19,
174 /** Alt. */
175 SJME_SCRITCHINPUT_KEY_ALT = -20,
177 /** Logo. */
178 SJME_SCRITCHINPUT_KEY_LOGO = -21,
180 /** Caps lock. */
181 SJME_SCRITCHINPUT_KEY_CAPSLOCK = -22,
183 /** Context menu. */
184 SJME_SCRITCHINPUT_KEY_CONTEXT_MENU = -23,
186 /** Home. */
187 SJME_SCRITCHINPUT_KEY_HOME = -24,
189 /** End. */
190 SJME_SCRITCHINPUT_KEY_END = -25,
192 /** Page Up. */
193 SJME_SCRITCHINPUT_KEY_PAGE_UP = -26,
195 /** Page Down. */
196 SJME_SCRITCHINPUT_KEY_PAGE_DOWN = -27,
198 /** Meta. */
199 SJME_SCRITCHINPUT_KEY_META = -28,
201 /** Numlock. */
202 SJME_SCRITCHINPUT_KEY_NUMLOCK = -29,
204 /** Pause. */
205 SJME_SCRITCHINPUT_KEY_PAUSE = -30,
207 /** Print Screen. */
208 SJME_SCRITCHINPUT_KEY_PRINTSCREEN = -31,
210 /** Scroll lock. */
211 SJME_SCRITCHINPUT_KEY_SCROLLLOCK = -32,
213 /** Insert. */
214 SJME_SCRITCHINPUT_KEY_INSERT = -33,
216 /** Game Virtual Left Command. */
217 SJME_SCRITCHINPUT_KEY_VGAME_COMMAND_LEFT = -34,
219 /** Game Virtual Right Command. */
220 SJME_SCRITCHINPUT_KEY_VGAME_COMMAND_RIGHT = -35,
222 /** Game virtual Center Command. */
223 SJME_SCRITCHINPUT_KEY_VGAME_COMMAND_CENTER = -36,
225 /** Game virtual open LCDUI inspector. */
226 SJME_SCRITCHINPUT_KEY_VGAME_LCDUI_INSPECTOR = -37,
228 /** Number pad divide. */
229 SJME_SCRITCHINPUT_KEY_NUMPAD_DIVIDE = -38,
231 /** Number pad multiply. */
232 SJME_SCRITCHINPUT_KEY_NUMPAD_MULTIPLY = -39,
234 /** Number pad minus. */
235 SJME_SCRITCHINPUT_KEY_NUMPAD_MINUS = -40,
237 /** Number pad plus. */
238 SJME_SCRITCHINPUT_KEY_NUMPAD_PLUS = -41,
240 /** Number pad decimal. */
241 SJME_SCRITCHINPUT_KEY_NUMPAD_DECIMAL = -42,
243 /** Number pad enter. */
244 SJME_SCRITCHINPUT_KEY_NUMPAD_ENTER = -43,
246 /** Number pad 0. */
247 SJME_SCRITCHINPUT_KEY_NUMPAD_0 = -50,
249 /** Number pad 1. */
250 SJME_SCRITCHINPUT_KEY_NUMPAD_1 = -51,
252 /** Number pad 2. */
253 SJME_SCRITCHINPUT_KEY_NUMPAD_2 = -52,
255 /** Number pad 3. */
256 SJME_SCRITCHINPUT_KEY_NUMPAD_3 = -53,
258 /** Number pad 4. */
259 SJME_SCRITCHINPUT_KEY_NUMPAD_4 = -54,
261 /** Number pad 5. */
262 SJME_SCRITCHINPUT_KEY_NUMPAD_5 = -55,
264 /** Number pad 6. */
265 SJME_SCRITCHINPUT_KEY_NUMPAD_6 = -56,
267 /** Number pad 7. */
268 SJME_SCRITCHINPUT_KEY_NUMPAD_7 = -57,
270 /** Number pad 8. */
271 SJME_SCRITCHINPUT_KEY_NUMPAD_8 = -58,
273 /** Number pad 9. */
274 SJME_SCRITCHINPUT_KEY_NUMPAD_9 = -59,
276 /** F24. */
277 SJME_SCRITCHINPUT_KEY_F24 = -64,
279 /** F23. */
280 SJME_SCRITCHINPUT_KEY_F23 = -65,
282 /** F22. */
283 SJME_SCRITCHINPUT_KEY_F22 = -66,
285 /** F21. */
286 SJME_SCRITCHINPUT_KEY_F21 = -67,
288 /** F20. */
289 SJME_SCRITCHINPUT_KEY_F20 = -68,
291 /** F19. */
292 SJME_SCRITCHINPUT_KEY_F19 = -69,
294 /** F18. */
295 SJME_SCRITCHINPUT_KEY_F18 = -70,
297 /** F17. */
298 SJME_SCRITCHINPUT_KEY_F17 = -71,
300 /** F16. */
301 SJME_SCRITCHINPUT_KEY_F16 = -72,
303 /** F15. */
304 SJME_SCRITCHINPUT_KEY_F15 = -73,
306 /** F14. */
307 SJME_SCRITCHINPUT_KEY_F14 = -74,
309 /** F13. */
310 SJME_SCRITCHINPUT_KEY_F13 = -75,
312 /** F12. */
313 SJME_SCRITCHINPUT_KEY_F12 = -76,
315 /** F11. */
316 SJME_SCRITCHINPUT_KEY_F11 = -77,
318 /** F10. */
319 SJME_SCRITCHINPUT_KEY_F10 = -78,
321 /** F9. */
322 SJME_SCRITCHINPUT_KEY_F9 = -79,
324 /** F8. */
325 SJME_SCRITCHINPUT_KEY_F8 = -80,
327 /** F7. */
328 SJME_SCRITCHINPUT_KEY_F7 = -81,
330 /** F6. */
331 SJME_SCRITCHINPUT_KEY_F6 = -82,
333 /** F5. */
334 SJME_SCRITCHINPUT_KEY_F5 = -83,
336 /** F4. */
337 SJME_SCRITCHINPUT_KEY_F4 = -84,
339 /** F3. */
340 SJME_SCRITCHINPUT_KEY_F3 = -85,
342 /** F2. */
343 SJME_SCRITCHINPUT_KEY_F2 = -86,
345 /** F1. */
346 SJME_SCRITCHINPUT_KEY_F1 = -87,
347 } sjme_scritchinput_key;
349 typedef enum sjme_scritchinput_modifier
351 /** Modifier status not supported. */
352 SJME_SCRITCHINPUT_MODIFIER_UNSUPPORTED = -1,
354 /** Alt key modifier. */
355 SJME_SCRITCHINPUT_MODIFIER_ALT = 65536,
357 /** Function (Fn/Chr) key modifier. */
358 SJME_SCRITCHINPUT_MODIFIER_CHR = 8388608,
360 /** Command key modifier. */
361 SJME_SCRITCHINPUT_MODIFIER_COMMAND = 4194304,
363 /** Ctrl key modifier. */
364 SJME_SCRITCHINPUT_MODIFIER_CTRL = 262144,
366 /** Shift key modifier. */
367 SJME_SCRITCHINPUT_MODIFIER_SHIFT = 131072,
369 /** Mask for all the modifier keys. */
370 SJME_SCRITCHINPUT_MODIFIER_MASK = 13041664,
371 } sjme_scritchinput_modifier;
373 typedef struct sjme_scritchinput_eventDataUnknown
375 /** Value 1. */
376 sjme_jint a;
378 /** Value 2. */
379 sjme_jint b;
381 /** Value 3. */
382 sjme_jint c;
384 /** Value 4. */
385 sjme_jint d;
387 /** Value 5. */
388 sjme_jint e;
390 /** Value 6. */
391 sjme_jint f;
393 /** Value 7. */
394 sjme_jint g;
396 /** Value 8. */
397 sjme_jint h;
399 /** Value 9. */
400 sjme_jint i;
402 /** Value 10. */
403 sjme_jint j;
405 /** Value 11. */
406 sjme_jint k;
408 /** Value 12. */
409 sjme_jint l;
410 } sjme_scritchinput_eventDataUnknown;
413 * Event data for key events.
415 * @since 2024/06/30
417 typedef struct sjme_scritchinput_eventDataKey
419 /** Unicode key core or @c sjme_scritchinput_key . */
420 sjme_jint code;
422 /** The modifiers held down, from @c sjme_scritchinput_modifier . */
423 sjme_jint modifiers;
424 } sjme_scritchinput_eventDataKey;
426 typedef struct sjme_scritchinput_eventDataMouseButton
428 /** The buttons being pressed. */
429 sjme_jint buttonMask;
431 /** The modifiers held down, from @c sjme_scritchinput_modifier . */
432 sjme_jint modifiers;
434 /** The X coordinate. */
435 sjme_jint x;
437 /** The Y coordinate. */
438 sjme_jint y;
440 /** The button being pressed. */
441 sjme_jint button;
442 } sjme_scritchinput_eventDataMouseButton;
444 typedef struct sjme_scritchinput_eventDataMouseMotion
446 /** The buttons being pressed. */
447 sjme_jint buttonMask;
449 /** The modifiers held down, from @c sjme_scritchinput_modifier . */
450 sjme_jint modifiers;
452 /** The X coordinate. */
453 sjme_jint x;
455 /** The Y coordinate. */
456 sjme_jint y;
457 } sjme_scritchinput_eventDataMouseMotion;
459 typedef struct sjme_scritchinput_eventDataGamePadButton
461 sjme_jint todo;
462 } sjme_scritchinput_eventDataGamePadButton;
464 typedef struct sjme_scritchinput_eventDataGamePadAxisMotion
466 sjme_jint todo;
467 } sjme_scritchinput_eventDataGamePadAxisMotion;
469 typedef struct sjme_scritchinput_eventDataTouchFinger
471 sjme_jint todo;
472 } sjme_scritchinput_eventDataTouchFinger;
474 typedef struct sjme_scritchinput_eventDataTouchDrag
476 sjme_jint todo;
477 } sjme_scritchinput_eventDataTouchDrag;
479 typedef struct sjme_scritchinput_eventDataStylusPen
481 sjme_jint todo;
482 } sjme_scritchinput_eventDataStylusPen;
484 typedef struct sjme_scritchinput_eventDataStylusMotion
486 sjme_jint todo;
487 } sjme_scritchinput_eventDataStylusMotion;
489 typedef struct sjme_scritchinput_eventDataDeviceAction
491 sjme_jint todo;
492 } sjme_scritchinput_eventDataDeviceAction;
495 * Structure which contains event data and otherwise.
497 * @since 2024/06/28
499 typedef struct sjme_scritchinput_event
501 /** The type of event that has occurred. */
502 sjme_scritchinput_type type;
504 /** The time the event occurred at. */
505 sjme_jlong time;
507 /** The event data. */
508 union
510 /** Unknown event. */
511 sjme_scritchinput_eventDataUnknown unknown;
513 /** Key events. */
514 sjme_scritchinput_eventDataKey key;
516 /** Mouse button events. */
517 sjme_scritchinput_eventDataMouseButton mouseButton;
519 /** Mouse motion events. */
520 sjme_scritchinput_eventDataMouseMotion mouseMotion;
522 /** Game pad button. */
523 sjme_scritchinput_eventDataGamePadButton gamePadButton;
525 /** Game pad axis motion. */
526 sjme_scritchinput_eventDataGamePadAxisMotion gamePadAxisMotion;
528 /** Touchscreen/Touchpad finger. */
529 sjme_scritchinput_eventDataTouchFinger touchFinger;
531 /** Touch drag. */
532 sjme_scritchinput_eventDataTouchDrag touchDrag;
534 /** Stylus pen. */
535 sjme_scritchinput_eventDataStylusPen stylusPen;
537 /** Stylus motion. */
538 sjme_scritchinput_eventDataStylusMotion stylusMotion;
540 /** Device action. */
541 sjme_scritchinput_eventDataDeviceAction deviceAction;
542 } data;
543 } sjme_scritchinput_event;
545 /*--------------------------------------------------------------------------*/
547 /* Anti-C++. */
548 #ifdef __cplusplus
549 #ifdef SJME_CXX_SQUIRRELJME_SCRITCHINPUT_H
551 #undef SJME_CXX_SQUIRRELJME_SCRITCHINPUT_H
552 #undef SJME_CXX_IS_EXTERNED
553 #endif /* #ifdef SJME_CXX_SQUIRRELJME_SCRITCHINPUT_H */
554 #endif /* #ifdef __cplusplus */
556 #endif /* SQUIRRELJME_SCRITCHINPUT_H */