2020-10-26 09:26:15 +00:00
|
|
|
#include "flipper_v2.h"
|
2020-10-02 06:44:05 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2020-10-29 07:58:19 +00:00
|
|
|
typedef union {
|
|
|
|
unsigned int packed;
|
|
|
|
InputState state;
|
|
|
|
} InputDump;
|
|
|
|
|
2020-10-26 09:26:15 +00:00
|
|
|
static void state_cb(const void* value, void* ctx) {
|
2020-10-29 07:58:19 +00:00
|
|
|
InputDump dump = {.packed = 0};
|
|
|
|
dump.state = *(InputState*)value;
|
2020-10-02 06:44:05 +00:00
|
|
|
|
2020-10-29 07:58:19 +00:00
|
|
|
printf("state: %02x\n", dump.packed);
|
2020-10-02 06:44:05 +00:00
|
|
|
}
|
|
|
|
|
2020-10-26 09:26:15 +00:00
|
|
|
static void event_cb(const void* value, void* ctx) {
|
2020-10-02 06:44:05 +00: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 09:26:15 +00:00
|
|
|
ValueManager* state_record = furi_open("input_state");
|
2020-10-29 06:27:17 +00:00
|
|
|
furi_check(state_record);
|
2020-10-26 09:26:15 +00:00
|
|
|
subscribe_pubsub(&state_record->pubsub, state_cb, NULL);
|
|
|
|
|
|
|
|
PubSub* event_record = furi_open("input_events");
|
2020-10-29 06:27:17 +00:00
|
|
|
furi_check(event_record);
|
2020-10-26 09:26:15 +00:00
|
|
|
subscribe_pubsub(event_record, event_cb, NULL);
|
2020-10-02 06:44:05 +00:00
|
|
|
|
2020-11-06 08:31:59 +00:00
|
|
|
printf("Example app [input dump]\n");
|
|
|
|
|
2020-10-02 06:44:05 +00:00
|
|
|
for(;;) {
|
|
|
|
delay(100);
|
|
|
|
}
|
|
|
|
}
|