input_dump.c 594 B

12345678910111213141516171819202122232425262728
  1. #include <furi.h>
  2. #include <stdio.h>
  3. #include <input/input.h>
  4. typedef union {
  5. unsigned int packed;
  6. InputType state;
  7. } InputDump;
  8. static void event_cb(const void* value, void* ctx) {
  9. const InputEvent* event = value;
  10. printf("event: %02x %s\r\n", event->key, event->type ? "pressed" : "released");
  11. }
  12. int32_t application_input_dump(void* p) {
  13. // open record
  14. PubSub* event_record = furi_record_open("input_events");
  15. subscribe_pubsub(event_record, event_cb, NULL);
  16. printf("Example app [input dump]\r\n");
  17. for(;;) {
  18. delay(100);
  19. }
  20. return 0;
  21. }