2020-10-26 12:26:15 +03:00
|
|
|
#include "flipper_v2.h"
|
2020-10-02 09:44:05 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2020-10-29 10:58:19 +03:00
|
|
|
typedef union {
|
|
|
|
unsigned int packed;
|
|
|
|
InputState state;
|
|
|
|
} InputDump;
|
|
|
|
|
2020-10-26 12:26:15 +03:00
|
|
|
static void state_cb(const void* value, void* ctx) {
|
2020-10-29 10:58:19 +03:00
|
|
|
InputDump dump = {.packed = 0};
|
|
|
|
dump.state = *(InputState*)value;
|
2020-10-02 09:44:05 +03:00
|
|
|
|
2020-10-29 10:58:19 +03:00
|
|
|
printf("state: %02x\n", dump.packed);
|
2020-10-02 09:44:05 +03:00
|
|
|
}
|
|
|
|
|
2020-10-26 12:26:15 +03:00
|
|
|
static void event_cb(const void* value, void* ctx) {
|
2020-10-02 09:44:05 +03:00
|
|
|
const InputEvent* event = value;
|
|
|
|
|
|
|
|
printf("event: %02x %s\n", event->input, event->state ? "pressed" : "released");
|
|
|
|
}
|
|
|
|
|
|
|
|
void application_input_dump(void* p) {
|
|
|
|
// open record
|
2020-10-26 12:26:15 +03:00
|
|
|
ValueManager* state_record = furi_open("input_state");
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_check(state_record);
|
2020-10-26 12:26:15 +03:00
|
|
|
subscribe_pubsub(&state_record->pubsub, state_cb, NULL);
|
|
|
|
|
|
|
|
PubSub* event_record = furi_open("input_events");
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_check(event_record);
|
2020-10-26 12:26:15 +03:00
|
|
|
subscribe_pubsub(event_record, event_cb, NULL);
|
2020-10-02 09:44:05 +03:00
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
delay(100);
|
|
|
|
}
|
|
|
|
}
|