hollyhock
Loading...
Searching...
No Matches
input.h
Go to the documentation of this file.
9#pragma once
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include <stdint.h>
16#include <stdbool.h>
17
18#define __UCONCAT(a, b) #a b
19#define _UCONCAT(a, b) __UCONCAT(a, b)
20#define UCONCAT(b) _UCONCAT(__USER_LABEL_PREFIX__, b)
21
22enum Input_EventType {
23 EVENT_KEY = 0x0017,
24 EVENT_ACTBAR_RESIZE = 0x1003,
25 EVENT_ACTBAR_SWAP = 0x1004,
26 EVENT_ACTBAR_ROTATE = 0x1005,
27 EVENT_ACTBAR_ESC = 0x3009,
28 EVENT_ACTBAR_SETTINGS = 0x300A,
29 EVENT_TOUCH = 0x4000,
30 EVENT_TIMER = 0x0005
31};
32
33enum Input_KeyEventType {
34 KEY_PRESSED = 1,
35 KEY_HELD = 0x100,
36 KEY_RELEASED = 0x40
37};
38
39enum Input_Keycode {
40 KEYCODE_KEYBOARD = 0x00B3,
41 KEYCODE_SHIFT = 0x00A0,
42 KEYCODE_BACKSPACE = 0x0097,
43 KEYCODE_POWER_CLEAR = 0x0080,
44 KEYCODE_UP = 0x0090,
45 KEYCODE_DOWN = 0x0091,
46 KEYCODE_LEFT = 0x0092,
47 KEYCODE_RIGHT = 0x0093,
48 KEYCODE_EQUALS = 0x003D,
49 KEYCODE_X = 0xEDB8,
50 KEYCODE_Y = 0xEDB9,
51 KEYCODE_Z = 0xEDBA,
52 KEYCODE_POWER = 0x005E,
53 KEYCODE_DIVIDE = 0x002F,
54 KEYCODE_OPEN_PARENTHESIS = 0x0028,
55 KEYCODE_7 = 0x0037,
56 KEYCODE_8 = 0x0038,
57 KEYCODE_9 = 0x0039,
58 KEYCODE_TIMES = 0xEE10,
59 KEYCODE_CLOSE_PARENTHESIS = 0x0029,
60 KEYCODE_4 = 0x0034,
61 KEYCODE_5 = 0x0035,
62 KEYCODE_6 = 0x0036,
63 KEYCODE_MINUS = 0x002D,
64 KEYCODE_COMMA = 0x002C,
65 KEYCODE_1 = 0x0031,
66 KEYCODE_2 = 0x0032,
67 KEYCODE_3 = 0x0033,
68 KEYCODE_PLUS = 0x002B,
69 KEYCODE_NEGATIVE = 0x001F,
70 KEYCODE_0 = 0x0030,
71 KEYCODE_DOT = 0x002E,
72 KEYCODE_EXP = 0x001D,
73 KEYCODE_EXE = 0x0094
74};
75
76enum Input_TouchEventType {
77 TOUCH_DOWN = 1,
78 TOUCH_HOLD_DRAG = 2,
79 TOUCH_ACT_BAR = 0x100,
80 TOUCH_UP = 0x40
81};
82
83enum Input_Scancode {
84 ScancodeKeyboard = (7 << 8) | 5,
85 ScancodeShift = (7 << 8) | 1,
86 ScancodeBackspace = (7 << 8) | 2,
87 ScancodeClear = (1 << 8) | 0,
88 ScancodeUp = (7 << 8) | 4,
89 ScancodeDown = (6 << 8) | 4,
90 ScancodeLeft = (6 << 8) | 3,
91 ScancodeRight = (7 << 8) | 3,
92 ScancodeEquals = (7 << 8) | 6,
93 ScancodeX = (6 << 8) | 6,
94 ScancodeY = (6 << 8) | 5,
95 ScancodeZ = (5 << 8) | 3,
96 ScancodePower = (6 << 8) | 2,
97 ScancodeDivide = (6 << 8) | 1,
98 ScancodeOpenParenthesis = (5 << 8) | 6,
99 Scancode7 = (5 << 8) | 5,
100 Scancode8 = (5 << 8) | 4,
101 Scancode9 = (5 << 8) | 2,
102 ScancodeTimes = (5 << 8) | 1,
103 ScancodeCloseParenthesis = (4 << 8) | 6,
104 Scancode4 = (4 << 8) | 5,
105 Scancode5 = (4 << 8) | 4,
106 Scancode6 = (4 << 8) | 2,
107 ScancodeMinus = (4 << 8) | 1,
108 ScancodeComma = (3 << 8) | 6,
109 Scancode1 = (3 << 8) | 5,
110 Scancode2 = (3 << 8) | 4,
111 Scancode3 = (3 << 8) | 2,
112 ScancodePlus = (3 << 8) | 1,
113 ScancodeNegative = (2 << 8) | 6,
114 Scancode0 = (2 << 8) | 5,
115 ScancodeDot = (2 << 8) | 4,
116 ScancodeEXP = (2 << 8) | 2,
117 ScancodeEXE = (2 << 8) | 1
118};
119
124struct __attribute__((packed)) Input_Event {
130 enum Input_EventType type : 16;
131 uint16_t zero;
132
146 union {
147 struct {
152 enum Input_KeyEventType direction : 32;
153
157 enum Input_Keycode keyCode : 16;
158 } key;
159
160 struct {
165 enum Input_TouchEventType direction : 32;
166
171 int32_t p1_x;
172
177 int32_t p1_y;
178
179 uint16_t adc_x1;
180 uint16_t adc_y1;
181 uint16_t adc_z1;
182 uint16_t adc_z2;
183 uint16_t adc_x2;
184 uint16_t adc_y2;
185
186 uint16_t adc_gh;
187 uint16_t adc_dm;
188 } touch_single;
189
190 struct {
191 enum Input_TouchEventType direction : 32;
192
193 int32_t p1_x;
194 int32_t p1_y;
195 int32_t p1_z;
196
197 int32_t p2_x;
198 int32_t p2_y;
199 int32_t p2_z;
200
201 uint32_t distance;
202
203 uint16_t adc_x1;
204 uint16_t adc_y1;
205 uint16_t adc_z1;
206 uint16_t adc_z2;
207 uint16_t adc_x2;
208 uint16_t adc_y2;
209
210 uint16_t adc_gh;
211 uint16_t adc_dm;
212 } touch_multi;
213 } data;
214};
215
226extern int (*GetInput)(struct Input_Event *event, uint32_t unknown1, uint32_t unknown2)
227#ifndef __clang__
228__attribute__((access(write_only, 1)))
229#endif
230;
231
232extern bool (*Input_GetKeyStateU)(uint16_t *scancode) __asm__ (UCONCAT("Input_GetKeyState"))
233#ifndef __clang__
234__attribute__((access(read_only, 1)))
235#endif
236;
237
244static inline __attribute__((always_inline)) bool Input_GetKeyState(enum Input_Scancode scanCode) {
245 return Input_GetKeyStateU((uint16_t *)&scanCode);
246}
247
253extern bool (*Input_IsAnyKeyDown)();
254
255#undef __UCONCAT
256#undef _UCONCAT
257#undef UCONCAT
258
259#ifdef __cplusplus
260}
261#endif
int(* GetInput)(struct Input_Event *event, uint32_t unknown1, uint32_t unknown2) __attribute__((access(write_only
bool(* Input_IsAnyKeyDown)()