From c23d752917774bc740c791e2f7eeef6f8f9e1033 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 19 Jun 2020 15:32:33 -0400 Subject: Some initial work on behavior bindings for keymaps --- app/include/zmk/keymap.h | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'app/include/zmk') diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h index 285b071..7866cd5 100644 --- a/app/include/zmk/keymap.h +++ b/app/include/zmk/keymap.h @@ -6,23 +6,9 @@ #include #include -#include - -#define ZMK_KEYMAP_NODE DT_CHOSEN(zmk_keymap) -#define ZMK_KEYMAP_LAYERS_LEN DT_PROP_LEN(ZMK_KEYMAP_NODE, layers) - -/* TODO: Need to actually be able to get a NODELABEL from a node id -#define _ZMK_KEYMAP_GENERATE_LAYER_CONST(node_id) \ - DT_NODELABEL_FOR_NODE(node_id)_layer, - -enum zmk_keymap_layer -{ - DT_FOREACH_CHILD(DT_INST(0, zmk_layers), _ZMK_KEYMAP_GENERATE_LAYER_CONST) -}; -*/ +// #include bool zmk_keymap_layer_activate(u8_t layer); bool zmk_keymap_layer_deactivate(u8_t layer); -zmk_key -zmk_keymap_keycode_from_position(u32_t row, u32_t column); +int zmk_keymap_position_state_changed(u32_t row, u32_t column, bool pressed); -- cgit v1.2.3 From d65629b9a0b79b6e294419fe9a4118fb09491c91 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sat, 20 Jun 2020 00:11:39 -0400 Subject: Lots more pieces toward HID working again. --- app/include/zmk/behavior.h | 8 ++++++++ app/include/zmk/events.h | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 app/include/zmk/behavior.h create mode 100644 app/include/zmk/events.h (limited to 'app/include/zmk') diff --git a/app/include/zmk/behavior.h b/app/include/zmk/behavior.h new file mode 100644 index 0000000..63edcc9 --- /dev/null +++ b/app/include/zmk/behavior.h @@ -0,0 +1,8 @@ + +#pragma once + +struct zmk_behavior_binding { + char *behavior_dev; + u32_t param1; + u32_t param2; +}; \ No newline at end of file diff --git a/app/include/zmk/events.h b/app/include/zmk/events.h new file mode 100644 index 0000000..9314b9d --- /dev/null +++ b/app/include/zmk/events.h @@ -0,0 +1,13 @@ +#pragma once + +int zmk_events_position_pressed(u32_t row, u32_t column); +int zmk_events_position_released(u32_t row, u32_t column); +int zmk_events_keycode_pressed(u32_t keycode); +int zmk_events_keycode_released(u32_t keycode); +int zmk_events_mod_pressed(u32_t modifier); +int zmk_events_mod_released(u32_t modifier); +int zmk_events_consumer_key_pressed(u32_t usage); +int zmk_events_consumer_key_released(u32_t usage); + +// TODO: Encoders? +// TODO: Sensors? \ No newline at end of file -- cgit v1.2.3 From 7e659851c80bf2819554d93ad9971f56aa5b225b Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sat, 20 Jun 2020 17:54:52 -0400 Subject: Refactor matrix transform, positions pervasively * Do mapping to positions right in kscan handler, and then surface positions throughout the API. --- app/include/zmk/events.h | 4 ++-- app/include/zmk/keymap.h | 2 +- app/include/zmk/matrix_transform.h | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 app/include/zmk/matrix_transform.h (limited to 'app/include/zmk') diff --git a/app/include/zmk/events.h b/app/include/zmk/events.h index 9314b9d..ac4815a 100644 --- a/app/include/zmk/events.h +++ b/app/include/zmk/events.h @@ -1,7 +1,7 @@ #pragma once -int zmk_events_position_pressed(u32_t row, u32_t column); -int zmk_events_position_released(u32_t row, u32_t column); +int zmk_events_position_pressed(u32_t position); +int zmk_events_position_released(u32_t position); int zmk_events_keycode_pressed(u32_t keycode); int zmk_events_keycode_released(u32_t keycode); int zmk_events_mod_pressed(u32_t modifier); diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h index 7866cd5..cf38904 100644 --- a/app/include/zmk/keymap.h +++ b/app/include/zmk/keymap.h @@ -11,4 +11,4 @@ bool zmk_keymap_layer_activate(u8_t layer); bool zmk_keymap_layer_deactivate(u8_t layer); -int zmk_keymap_position_state_changed(u32_t row, u32_t column, bool pressed); +int zmk_keymap_position_state_changed(u32_t position, bool pressed); diff --git a/app/include/zmk/matrix_transform.h b/app/include/zmk/matrix_transform.h new file mode 100644 index 0000000..e9e969a --- /dev/null +++ b/app/include/zmk/matrix_transform.h @@ -0,0 +1,3 @@ +#pragma once + +u32_t zmk_matrix_transform_row_column_to_position(u32_t row, u32_t column); \ No newline at end of file -- cgit v1.2.3 From 223edf05ad08938b066f9187668ebfae43c5e91a Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sun, 21 Jun 2020 21:43:44 -0400 Subject: Refactor global bindings, implement mod-tap. * Use extra comptible = "zmk,behavior-global" to add behaviors to global bindings for event notification. * Implement mod-tap, as a keymap binding and global one to skip tap if other keycode pressed while held. --- app/include/zmk/events.h | 6 ++++-- app/include/zmk/keymap.h | 8 -------- app/include/zmk/matrix.h | 2 ++ 3 files changed, 6 insertions(+), 10 deletions(-) (limited to 'app/include/zmk') diff --git a/app/include/zmk/events.h b/app/include/zmk/events.h index ac4815a..8d1ae6a 100644 --- a/app/include/zmk/events.h +++ b/app/include/zmk/events.h @@ -1,11 +1,13 @@ #pragma once +#include + int zmk_events_position_pressed(u32_t position); int zmk_events_position_released(u32_t position); int zmk_events_keycode_pressed(u32_t keycode); int zmk_events_keycode_released(u32_t keycode); -int zmk_events_mod_pressed(u32_t modifier); -int zmk_events_mod_released(u32_t modifier); +int zmk_events_modifiers_pressed(zmk_mod_flags modifiers); +int zmk_events_modifiers_released(zmk_mod_flags modifiers); int zmk_events_consumer_key_pressed(u32_t usage); int zmk_events_consumer_key_released(u32_t usage); diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h index cf38904..38c1249 100644 --- a/app/include/zmk/keymap.h +++ b/app/include/zmk/keymap.h @@ -1,13 +1,5 @@ #pragma once -#include -#include -#include -#include - -#include -// #include - bool zmk_keymap_layer_activate(u8_t layer); bool zmk_keymap_layer_deactivate(u8_t layer); diff --git a/app/include/zmk/matrix.h b/app/include/zmk/matrix.h index 783c98e..9cabb7e 100644 --- a/app/include/zmk/matrix.h +++ b/app/include/zmk/matrix.h @@ -1,5 +1,7 @@ #pragma once +#include + #define ZMK_MATRIX_NODE_ID DT_CHOSEN(zmk_kscan) #if DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID,row_gpios) -- cgit v1.2.3 From ec663310c1682f55578b1b6d886ebcae4965425c Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sun, 21 Jun 2020 22:46:27 -0400 Subject: Clean up after refactor, better HID constants. --- app/include/zmk/hid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/include/zmk') diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index 7e3560d..e14a51a 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -9,7 +9,7 @@ #define COLLECTION_REPORT 0x03 -#define ZMK_HID_MAX_KEYCODE KC_APP +#define ZMK_HID_MAX_KEYCODE GUI static const u8_t zmk_hid_report_desc[] = { /* USAGE_PAGE (Generic Desktop) */ -- cgit v1.2.3 From 55cf9db564e66e2804f2d3f2201c55c3c86a90d7 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Mon, 22 Jun 2020 11:06:01 -0400 Subject: Fix consumer keys w/ refactored behaviors. --- app/include/zmk/endpoints.h | 3 +-- app/include/zmk/events.h | 4 ++-- app/include/zmk/hid.h | 55 +++++++++++++-------------------------------- app/include/zmk/keymap.h | 4 ++-- 4 files changed, 21 insertions(+), 45 deletions(-) (limited to 'app/include/zmk') diff --git a/app/include/zmk/endpoints.h b/app/include/zmk/endpoints.h index 255ca54..624bb4e 100644 --- a/app/include/zmk/endpoints.h +++ b/app/include/zmk/endpoints.h @@ -4,5 +4,4 @@ #include int zmk_endpoints_init(); -int zmk_endpoints_send_report(enum zmk_hid_report_changes changes); -int zmk_endpoints_send_key_event(struct zmk_key_event key_event); +int zmk_endpoints_send_report(u8_t usage_report); diff --git a/app/include/zmk/events.h b/app/include/zmk/events.h index 8d1ae6a..5be2beb 100644 --- a/app/include/zmk/events.h +++ b/app/include/zmk/events.h @@ -4,8 +4,8 @@ int zmk_events_position_pressed(u32_t position); int zmk_events_position_released(u32_t position); -int zmk_events_keycode_pressed(u32_t keycode); -int zmk_events_keycode_released(u32_t keycode); +int zmk_events_keycode_pressed(u8_t usage_page, u32_t keycode); +int zmk_events_keycode_released(u8_t usage_page, u32_t keycode); int zmk_events_modifiers_pressed(zmk_mod_flags modifiers); int zmk_events_modifiers_released(zmk_mod_flags modifiers); int zmk_events_consumer_key_pressed(u32_t usage); diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index e14a51a..138606a 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -108,40 +108,21 @@ static const u8_t zmk_hid_report_desc[] = { 0x00, /* LOGICAL_MAXIMUM (1) */ HID_GI_LOGICAL_MAX(1), - 0x01, - /* USAGE (Scan Next Track) */ - HID_LI_USAGE, - 0xB5, - /* USAGE (Scan Previous Track) */ - HID_LI_USAGE, - 0xB6, - /* USAGE (Stop) */ - HID_LI_USAGE, - 0xB7, - /* USAGE (Eject) */ - HID_LI_USAGE, - 0xB8, - /* USAGE (Media Play/Pause) */ - HID_LI_USAGE, - 0xCD, - /* USAGE (Mute) */ - HID_LI_USAGE, - 0xE2, - /* USAGE (Volume Increment) */ - HID_LI_USAGE, - 0xE9, - /* USAGE (Volume Decrement) */ - HID_LI_USAGE, - 0xEA, + 0xFF, + HID_LI_USAGE_MIN(1), + 0x00, + /* USAGE_MAXIMUM (Keyboard Application) */ + HID_LI_USAGE_MAX(1), + 0xFF, /* INPUT (Data,Ary,Abs) */ - /* REPORT_SIZE (1) */ + /* REPORT_SIZE (8) */ HID_GI_REPORT_SIZE, - 0x01, + 0x08, /* REPORT_COUNT (8) */ HID_GI_REPORT_COUNT, - 0x08, + 0x06, HID_MI_INPUT, - 0x02, + 0x00, /* END COLLECTION */ HID_MI_COLLECTION_END, }; @@ -167,7 +148,7 @@ struct zmk_hid_keypad_report struct zmk_hid_consumer_report_body { - u8_t keys; + u8_t keys[6]; } __packed; struct zmk_hid_consumer_report @@ -176,19 +157,15 @@ struct zmk_hid_consumer_report struct zmk_hid_consumer_report_body body; } __packed; -enum zmk_hid_report_changes -{ - None = 0x00, - Keypad = (0x01 << 0x00), - Consumer = (0x01 << 0x01) -}; - int zmk_hid_register_mod(zmk_mod modifier); int zmk_hid_unregister_mod(zmk_mod modifier); int zmk_hid_register_mods(zmk_mod_flags modifiers); int zmk_hid_unregister_mods(zmk_mod_flags modifiers); -enum zmk_hid_report_changes zmk_hid_press_key(zmk_key key); -enum zmk_hid_report_changes zmk_hid_release_key(zmk_key key); +int zmk_hid_keypad_press(zmk_key key); +int zmk_hid_keypad_release(zmk_key key); + +int zmk_hid_consumer_press(zmk_key key); +int zmk_hid_consumer_release(zmk_key key); struct zmk_hid_keypad_report *zmk_hid_get_keypad_report(); struct zmk_hid_consumer_report *zmk_hid_get_consumer_report(); diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h index 38c1249..4a6bb37 100644 --- a/app/include/zmk/keymap.h +++ b/app/include/zmk/keymap.h @@ -1,6 +1,6 @@ #pragma once -bool zmk_keymap_layer_activate(u8_t layer); -bool zmk_keymap_layer_deactivate(u8_t layer); +int zmk_keymap_layer_activate(u8_t layer); +int zmk_keymap_layer_deactivate(u8_t layer); int zmk_keymap_position_state_changed(u32_t position, bool pressed); -- cgit v1.2.3