input_dump.c 883 B

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