input_dump.c 615 B

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