input_dump.c 750 B

1234567891011121314151617181920212223242526272829
  1. #include "flipper_v2.h"
  2. #include <stdio.h>
  3. static void state_cb(const void* value, void* ctx) {
  4. const InputState* state = value;
  5. printf("state: %02x\n", *state);
  6. }
  7. static void event_cb(const void* value, void* ctx) {
  8. const InputEvent* event = value;
  9. printf("event: %02x %s\n", event->input, event->state ? "pressed" : "released");
  10. }
  11. void application_input_dump(void* p) {
  12. // open record
  13. ValueManager* state_record = furi_open("input_state");
  14. assert(state_record != NULL);
  15. subscribe_pubsub(&state_record->pubsub, state_cb, NULL);
  16. PubSub* event_record = furi_open("input_events");
  17. assert(event_record != NULL);
  18. subscribe_pubsub(event_record, event_cb, NULL);
  19. for(;;) {
  20. delay(100);
  21. }
  22. }