Input handling and debouncing (#148)
* Add input driver and definitions for target_f2 * Add input_dump example * Invert charge input * Fix back and left button configuration * remove input debug * input testing case * move header * lint code Co-authored-by: aanper <mail@s3f.ru>
This commit is contained in:
29
applications/examples/input_dump.c
Normal file
29
applications/examples/input_dump.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "flipper.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static void state_cb(const void* value, size_t size, void* ctx) {
|
||||
const InputState* state = value;
|
||||
|
||||
printf("state: %02x\n", *state);
|
||||
}
|
||||
|
||||
static void event_cb(const void* value, size_t size, void* ctx) {
|
||||
const InputEvent* event = value;
|
||||
|
||||
printf("event: %02x %s\n", event->input, event->state ? "pressed" : "released");
|
||||
}
|
||||
|
||||
void application_input_dump(void* p) {
|
||||
// TODO try open record and retry on timeout (needs FURI behaviour change)
|
||||
delay(1000);
|
||||
|
||||
// open record
|
||||
FuriRecordSubscriber* state_record =
|
||||
furi_open("input_state", false, false, state_cb, NULL, NULL);
|
||||
FuriRecordSubscriber* event_record =
|
||||
furi_open("input_events", false, false, event_cb, NULL, NULL);
|
||||
|
||||
for(;;) {
|
||||
delay(100);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user