25 #include "microui_event_decoder.h" 31 #ifdef MICROUIEVENTDECODER_ENABLED 40 #define DESCRIBE_EVENT_GENERATOR(event) (LLUI_DEBUG_TRACE(" (event generator %u)", EVENT_GENERATOR_ID(event))) 41 #define DESCRIBE_EOL() (LLUI_DEBUG_TRACE("\n")) 46 #define EVENT_DATA(event) ((uint16_t)(event)) 47 #define EVENT_GENERATOR_ID(event) ((uint8_t)((event) >> 16)) 52 #define COMMAND_GET(event) EVENT_DATA(event) 57 #define BUTTON_ACTION_PRESSED 0 58 #define BUTTON_ACTION_RELEASED 1 59 #define BUTTON_ACTION_LONG 2 60 #define BUTTON_ACTION_REPEATED 3 61 #define BUTTON_ACTION_CLICK 4 62 #define BUTTON_ACTION_DOUBLECLICK 5 63 #define BUTTON_ACTION(event) ((uint8_t)((event) >> 8)) 64 #define BUTTON_ID(event) ((uint8_t)(event)) 69 #define POINTER_ACTION_MOVE 6 70 #define POINTER_ACTION_DRAG 7 71 #define POINTER_X(data) (((data) >> 16) & 0xfff) 72 #define POINTER_Y(data) ((data) & 0xfff) 73 #define POINTER_TYPE(data) (((data) >> 31) & 0x1) 78 #define USEREVENT_SIZE(event) EVENT_DATA(event) 84 static void decode_event_command(uint32_t event, uint32_t index, MICROUI_EVENT_DECODER_decode_event_data* fct_data_decoder) {
86 (void)fct_data_decoder;
88 LLUI_DEBUG_TRACE(
"Command ");
90 uint8_t command = (uint8_t)COMMAND_GET(event);
94 LLUI_DEBUG_TRACE(
"ESC");
97 LLUI_DEBUG_TRACE(
"BACK");
100 LLUI_DEBUG_TRACE(
"UP");
103 LLUI_DEBUG_TRACE(
"DOWN");
106 LLUI_DEBUG_TRACE(
"LEFT");
109 LLUI_DEBUG_TRACE(
"RIGHT");
112 LLUI_DEBUG_TRACE(
"SELECT");
115 LLUI_DEBUG_TRACE(
"CANCEL");
118 LLUI_DEBUG_TRACE(
"HELP");
121 LLUI_DEBUG_TRACE(
"MENU");
124 LLUI_DEBUG_TRACE(
"EXIT");
127 LLUI_DEBUG_TRACE(
"START");
130 LLUI_DEBUG_TRACE(
"STOP");
133 LLUI_DEBUG_TRACE(
"PAUSE");
136 LLUI_DEBUG_TRACE(
"RESUME");
139 LLUI_DEBUG_TRACE(
"COPY");
142 LLUI_DEBUG_TRACE(
"CUT");
145 LLUI_DEBUG_TRACE(
"PASTE");
148 LLUI_DEBUG_TRACE(
"CLOCKWISE");
151 LLUI_DEBUG_TRACE(
"ANTICLOCKWISE");
154 LLUI_DEBUG_TRACE(
"PREVIOUS");
157 LLUI_DEBUG_TRACE(
"NEXT");
160 LLUI_DEBUG_TRACE(
"0x%02x", command);
164 DESCRIBE_EVENT_GENERATOR(event);
168 static void decode_event_button(uint32_t event, uint32_t index, MICROUI_EVENT_DECODER_decode_event_data* fct_data_decoder) {
170 (void)fct_data_decoder;
172 LLUI_DEBUG_TRACE(
"Button %u ", BUTTON_ID(event));
173 uint8_t action = BUTTON_ACTION(event);
176 case BUTTON_ACTION_PRESSED:
177 LLUI_DEBUG_TRACE(
"pressed");
179 case BUTTON_ACTION_RELEASED:
180 LLUI_DEBUG_TRACE(
"released");
182 case BUTTON_ACTION_LONG:
183 LLUI_DEBUG_TRACE(
"long");
185 case BUTTON_ACTION_REPEATED:
186 LLUI_DEBUG_TRACE(
"repeated");
188 case BUTTON_ACTION_CLICK:
189 LLUI_DEBUG_TRACE(
"click");
191 case BUTTON_ACTION_DOUBLECLICK:
192 LLUI_DEBUG_TRACE(
"double-click");
195 LLUI_DEBUG_TRACE(
"unknown action: %u", action);
199 DESCRIBE_EVENT_GENERATOR(event);
203 #ifdef MICROUIEVENTDECODER_EVENTGEN_TOUCH 207 static void decode_event_pointer_data(uint32_t event, uint32_t data, uint32_t index) {
210 LLUI_DEBUG_TRACE(
"[%02u: 0x%08x] at %u,%u (", index, data, POINTER_X(data), POINTER_Y(data));
211 if (0 == POINTER_TYPE(data)) {
212 LLUI_DEBUG_TRACE(
"absolute)");
215 LLUI_DEBUG_TRACE(
"relative)");
220 #endif // MICROUIEVENTDECODER_EVENTGEN_TOUCH 222 static void decode_event_pointer(uint32_t event, uint32_t index, MICROUI_EVENT_DECODER_decode_event_data* fct_data_decoder) {
224 (void)fct_data_decoder;
226 LLUI_DEBUG_TRACE(
"Pointer ");
227 uint8_t action = BUTTON_ACTION(event);
230 case BUTTON_ACTION_PRESSED:
231 LLUI_DEBUG_TRACE(
"pressed");
233 case BUTTON_ACTION_RELEASED:
234 LLUI_DEBUG_TRACE(
"released");
236 case BUTTON_ACTION_LONG:
237 LLUI_DEBUG_TRACE(
"long");
239 case BUTTON_ACTION_REPEATED:
240 LLUI_DEBUG_TRACE(
"repeated");
242 case BUTTON_ACTION_CLICK:
243 LLUI_DEBUG_TRACE(
"click");
245 case BUTTON_ACTION_DOUBLECLICK:
246 LLUI_DEBUG_TRACE(
"double-click");
248 case POINTER_ACTION_MOVE:
249 LLUI_DEBUG_TRACE(
"moved");
251 case POINTER_ACTION_DRAG:
252 LLUI_DEBUG_TRACE(
"dragged");
255 LLUI_DEBUG_TRACE(
"unknown action: %u", action);
259 DESCRIBE_EVENT_GENERATOR(event);
263 static void decode_event_state(uint32_t event, uint32_t index, MICROUI_EVENT_DECODER_decode_event_data* fct_data_decoder) {
265 (void)fct_data_decoder;
267 LLUI_DEBUG_TRACE(
"TODO %s 0x%08x\n", __FUNCTION__, event);
277 static void decode_event_input(uint32_t event, uint32_t index, MICROUI_EVENT_DECODER_decode_event_data* fct_data_decoder) {
278 LLUI_DEBUG_TRACE(
"Input event: ");
280 uint8_t generator_id = EVENT_GENERATOR_ID(event);
282 switch(generator_id) {
284 #ifdef MICROUIEVENTDECODER_EVENTGEN_COMMAND 285 case MICROUI_EVENTGEN_COMMANDS:
286 decode_event_command(event, index, fct_data_decoder);
288 #endif // MICROUIEVENTDECODER_EVENTGEN_COMMAND 290 #ifdef MICROUIEVENTDECODER_EVENTGEN_BUTTONS 291 case MICROUIEVENTDECODER_EVENTGEN_BUTTONS:
292 decode_event_button(event, index, fct_data_decoder);
294 #endif // MICROUIEVENTDECODER_EVENTGEN_BUTTONS 296 #ifdef MICROUIEVENTDECODER_EVENTGEN_TOUCH 297 case MICROUIEVENTDECODER_EVENTGEN_TOUCH:
298 *fct_data_decoder = decode_event_pointer_data;
299 decode_event_pointer(event, index, fct_data_decoder);
301 #endif // MICROUIEVENTDECODER_EVENTGEN_TOUCH 304 LLUI_DEBUG_TRACE(
"unknown ");
305 DESCRIBE_EVENT_GENERATOR(event);
311 static void decode_event_user_data(uint32_t event, uint32_t data, uint32_t index) {
313 LLUI_DEBUG_TRACE(
" [%02u] 0x%08x\n", index, data);
316 static void decode_event_user(uint32_t event, uint32_t index, MICROUI_EVENT_DECODER_decode_event_data* fct_data_decoder) {
317 LLUI_DEBUG_TRACE(
"User input event");
319 uint8_t size = (uint8_t)USEREVENT_SIZE(event);
320 if (size > (uint32_t)1) {
321 LLUI_DEBUG_TRACE(
"s (size = %u)", size);
323 DESCRIBE_EVENT_GENERATOR(event);
324 LLUI_DEBUG_TRACE(
": ");
326 *fct_data_decoder = decode_event_user_data;
334 void MICROUI_EVENT_DECODER_describe_dump_start(
void) {
335 LLUI_DEBUG_TRACE(
"============================== MicroUI FIFO Dump ===============================\n");
338 void MICROUI_EVENT_DECODER_describe_dump_past(
void) {
339 LLUI_DEBUG_TRACE(
"---------------------------------- Old Events ----------------------------------\n");
342 void MICROUI_EVENT_DECODER_describe_dump_future(
void) {
343 LLUI_DEBUG_TRACE(
"---------------------------------- New Events ----------------------------------\n");
346 void MICROUI_EVENT_DECODER_describe_dump_events_objects(
void) {
347 LLUI_DEBUG_TRACE(
"--------------------------- New Events' Java objects ---------------------------\n");
350 void MICROUI_EVENT_DECODER_describe_dump_end(
void) {
351 LLUI_DEBUG_TRACE(
"================================================================================\n");
354 void MICROUI_EVENT_DECODER_drop_data(uint32_t data, uint32_t index) {
355 LLUI_DEBUG_TRACE(
"[%02u: 0x%08x] garbage\n", index, data);
358 void MICROUI_EVENT_DECODER_decode_event(uint32_t event, uint32_t index, MICROUI_EVENT_DECODER_decode_event_data* fct_data_decoder) {
359 LLUI_DEBUG_TRACE(
"[%02u: 0x%08x] ", index, event);
361 uint8_t event_type = (uint8_t)(event >> 24);
365 decode_event_command(event, index, fct_data_decoder);
368 decode_event_button(event, index, fct_data_decoder);
371 decode_event_pointer(event, index, fct_data_decoder);
374 decode_event_state(event, index, fct_data_decoder);
380 LLUI_DEBUG_TRACE(
"Call serially (Runnable index = %u)\n", EVENT_DATA(event));
383 LLUI_DEBUG_TRACE(
"MicroUI STOP\n");
386 decode_event_input(event, index, fct_data_decoder);
389 LLUI_DEBUG_TRACE(
"Display SHOW Displayable (Displayable index = %u)\n", EVENT_DATA(event));
392 LLUI_DEBUG_TRACE(
"Display HIDE Displayable (Displayable index = %u)\n", EVENT_DATA(event));
398 LLUI_DEBUG_TRACE(
"Display FLUSH\n");
401 LLUI_DEBUG_TRACE(
"Display FORCE FLUSH\n");
404 LLUI_DEBUG_TRACE(
"Display REPAINT Displayable (Displayable index = %u)\n", EVENT_DATA(event));
407 LLUI_DEBUG_TRACE(
"Display REPAINT Current Displayable\n");
410 LLUI_DEBUG_TRACE(
"Display KF SWITCH Display\n");
413 decode_event_user(event, index, fct_data_decoder);
418 #endif // MICROUIEVENTDECODER_ENABLED