Add timestamps to position and behavior events (#147)

* Add timestamps to position events and behaviors.

- Take original event timestamps into consideration so nested tap-holds have proper timing.
- Add position and timestamp to keycode state changed event so the one-shot behavior can properly identify other keypresses and timings.
- Add timestamp to position events received from peripheral

* reduce number of arguments to behaviors
This commit is contained in:
Okke Formsma
2020-10-10 23:32:53 +02:00
committed by GitHub
parent fc6c01fd69
commit d38740cebf
21 changed files with 248 additions and 122 deletions

View File

@@ -10,4 +10,10 @@ struct zmk_behavior_binding {
char *behavior_dev;
u32_t param1;
u32_t param2;
};
struct zmk_behavior_binding_event {
int layer;
u32_t position;
s64_t timestamp;
};

View File

@@ -24,6 +24,5 @@ inline struct keycode_state_changed *create_keycode_state_changed(u8_t usage_pag
ev->usage_page = usage_page;
ev->keycode = keycode;
ev->state = state;
return ev;
}

View File

@@ -13,6 +13,7 @@ struct position_state_changed {
struct zmk_event_header header;
u32_t position;
bool state;
s64_t timestamp;
};
ZMK_EVENT_DECLARE(position_state_changed);

View File

@@ -11,4 +11,4 @@ int zmk_keymap_layer_activate(u8_t layer);
int zmk_keymap_layer_deactivate(u8_t layer);
int zmk_keymap_layer_toggle(u8_t layer);
int zmk_keymap_position_state_changed(u32_t position, bool pressed);
int zmk_keymap_position_state_changed(u32_t position, bool pressed, s64_t timestamp);