summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2020-06-21 22:46:27 -0400
committerPete Johanson <peter@peterjohanson.com>2020-06-21 22:46:27 -0400
commitec663310c1682f55578b1b6d886ebcae4965425c (patch)
tree29d3d21dc9136884e9c04baa7ec84a4fc9778e2d
parentc6625169e5f6cfc8641fc08662f59935abf11588 (diff)
Clean up after refactor, better HID constants.
-rw-r--r--app/CMakeLists.txt1
-rw-r--r--app/boards/native_posix.overlay25
-rw-r--r--app/boards/shields/kyria/keymap/keymap.overlay (renamed from app/boards/shields/kyria/keymaps/default/keymap.overlay)13
-rw-r--r--app/boards/shields/kyria/keymaps/default/include/keymap.h5
-rw-r--r--app/boards/shields/kyria/keymaps/default/keymap.c34
-rw-r--r--app/boards/shields/petejohanson_proton_handwire/keymap/keymap.overlay28
-rw-r--r--app/dts/bindings/zmk,layers.yaml4
-rw-r--r--app/include/dt-bindings/zmk/keys.h233
-rw-r--r--app/include/zmk/hid.h2
-rw-r--r--app/src/ble.c4
-rw-r--r--app/src/handlers.c88
-rw-r--r--app/src/hid.c42
12 files changed, 155 insertions, 324 deletions
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 38bd075..4dcd2f6 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -46,5 +46,4 @@ target_sources_ifdef(CONFIG_ZMK_USB app PRIVATE src/usb_hid.c)
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/hog.c)
target_sources(app PRIVATE src/endpoints.c)
target_sources(app PRIVATE src/main.c)
-target_sources(app PRIVATE src/handlers.c)
diff --git a/app/boards/native_posix.overlay b/app/boards/native_posix.overlay
index 204032a..bf9ae2c 100644
--- a/app/boards/native_posix.overlay
+++ b/app/boards/native_posix.overlay
@@ -54,39 +54,26 @@
default: layer_0 {
label = "DEFAULT";
- keys =
- <
- KC_A MT(MOD_LSFT, KC_B) KC_C KC_D
- KC_E KC_F KC_G KC_H
- >;
bindings = <
- &kp 5 &mo 1 &kp 10 &kp 11
- &kp 1 &kp 2 &kp 4 &kp 89>;
+ &kp B &mo A &kp C &kp E
+ &kp D &kp G &kp F &kp Q>;
};
lower: layer_1 {
label = "LOWER";
- keys = <
- KC_A KC_B KC_C KC_D
- KC_E KC_F KC_G KC_H
- >;
bindings = <
- &kp 20 &trans &kp 18 &kp 19
- &kp 21 &kp 22 &kp 24 &kp 49>;
+ &kp N &trans &kp O &kp Q
+ &kp L &kp J &kp P &kp K>;
};
raise: layer_2 {
label = "RAISE";
- keys = <
- KC_E KC_F KC_G KC_H
- KC_A KC_B KC_C KC_D
- >;
bindings = <
- &kp 5 &kp 0 &kp 10 &kp 11
- &kp 1 &kp 2 &kp 4 &kp 89>;
+ &kp W &kp U &kp I &kp N
+ &kp X &kp M &kp C &kp B>;
};
};
};
diff --git a/app/boards/shields/kyria/keymaps/default/keymap.overlay b/app/boards/shields/kyria/keymap/keymap.overlay
index 66c1a23..f61bb6c 100644
--- a/app/boards/shields/kyria/keymaps/default/keymap.overlay
+++ b/app/boards/shields/kyria/keymap/keymap.overlay
@@ -1,7 +1,6 @@
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/matrix-transform.h>
-#include <keymap.h>
/ {
chosen {
@@ -24,12 +23,12 @@
// | <- | A | S | D | F | G | | H | J | K | L | ; | ' |
// | SHIFT | Z | X | C | V | B | L SHIFT | L SHIFT | | L SHIFT | L SHIFT | N | M | , | . | / | - |
// | GUI | DEL | RET | SPACE | ESC | | RET | SPACE | TAB | BSPC | R-ALT |
- keys = <
- KC_ESC KC_Q KC_W KC_E KC_R KC_T KC_Y KC_U KC_I KC_O KC_P KC_PIPE
- KC_BKSP KC_A KC_S KC_D KC_F KC_G KC_H KC_J KC_K KC_L KC_SCLN KC_QUOT
- KC_LSFT KC_Z KC_X KC_C KC_V KC_B KC_LSFT KC_LSFT KC_LSFT KC_LSFT KC_N KC_M KC_CMMA KC_DOT KC_BSLH KC_MIN
- KC_LGUI KC_DEL KC_RET KC_SPC KC_ESC KC_RET KC_SPC KC_TAB KC_BKSP KC_RALT
- >;
+ bindings = <
+ &kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp PIPE
+ &kp BKSP &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT
+ &kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp LSFT &kp LSFT &kp LSFT &kp LSFT &kp N &kp M &kp CMMA &kp DOT &kp BSLH &kp MINUS
+ &kp LGUI &kp DEL &kp RET &kp SPC &kp ESC &kp RET &kp SPC &kp TAB &kp BKSP &kp RALT
+ >;
};
};
};
diff --git a/app/boards/shields/kyria/keymaps/default/include/keymap.h b/app/boards/shields/kyria/keymaps/default/include/keymap.h
deleted file mode 100644
index 01cd9e5..0000000
--- a/app/boards/shields/kyria/keymaps/default/include/keymap.h
+++ /dev/null
@@ -1,5 +0,0 @@
-
-#include <dt-bindings/zmk/keys.h>
-
-#define CC_RAIS ZC_CSTM(1)
-#define CC_LOWR ZC_CSTM(2) \ No newline at end of file
diff --git a/app/boards/shields/kyria/keymaps/default/keymap.c b/app/boards/shields/kyria/keymaps/default/keymap.c
deleted file mode 100644
index 067cd08..0000000
--- a/app/boards/shields/kyria/keymaps/default/keymap.c
+++ /dev/null
@@ -1,34 +0,0 @@
-
-#include <zmk/keys.h>
-#include <zmk/keymap.h>
-#include <keymap.h>
-
-bool zmk_handle_key_user(struct zmk_key_event *key_event)
-{
- switch (key_event->key)
- {
- case CC_LOWR:
- if (key_event->pressed)
- {
- zmk_keymap_layer_activate(1);
- }
- else
- {
- zmk_keymap_layer_deactivate(1);
- }
-
- return false;
- case CC_RAIS:
- if (key_event->pressed)
- {
- zmk_keymap_layer_activate(2);
- }
- else
- {
- zmk_keymap_layer_deactivate(2);
- }
- return false;
- }
-
- return true;
-};
diff --git a/app/boards/shields/petejohanson_proton_handwire/keymap/keymap.overlay b/app/boards/shields/petejohanson_proton_handwire/keymap/keymap.overlay
index ad07e9f..7540022 100644
--- a/app/boards/shields/petejohanson_proton_handwire/keymap/keymap.overlay
+++ b/app/boards/shields/petejohanson_proton_handwire/keymap/keymap.overlay
@@ -17,36 +17,26 @@
default: layer_0 {
label = "DEFAULT";
- keys =
- <
- KC_A MT(MOD_LSFT, KC_B)
- CC_RAIS CC_LOWR
- >;
+
bindings = <
- &reset &kp 0
- &kp 1 &kp 2>;
+ &reset &kp A
+ &kp B &kp C>;
};
lower: layer_1 {
label = "LOWER";
- keys = <
- KC_MPLY KC_MNXT
- ZC_TRNS ZC_TRNS
- >;
+
bindings = <
- &reset &kp 0
- &kp 1 &kp 2>;
+ &reset &kp D
+ &kp F &kp E>;
};
raise: layer_2 {
label = "RAISE";
- keys = <
- KC_C KC_D
- ZC_TRNS ZC_TRNS
- >;
+
bindings = <
- &reset &kp 0
- &kp 1 &kp 2>;
+ &reset &kp I
+ &kp G &kp H>;
};
};
};
diff --git a/app/dts/bindings/zmk,layers.yaml b/app/dts/bindings/zmk,layers.yaml
index 2bbb023..34cbb95 100644
--- a/app/dts/bindings/zmk,layers.yaml
+++ b/app/dts/bindings/zmk,layers.yaml
@@ -9,7 +9,7 @@ child-binding:
properties:
label:
type: string
- keys:
- type: array
+ required: true
bindings:
type: phandle-array
+ required: true
diff --git a/app/include/dt-bindings/zmk/keys.h b/app/include/dt-bindings/zmk/keys.h
index c91d27b..476d110 100644
--- a/app/include/dt-bindings/zmk/keys.h
+++ b/app/include/dt-bindings/zmk/keys.h
@@ -1,122 +1,117 @@
#pragma once
-#define KC_A 0x04
-#define KC_B 0x05
-#define KC_C 0x06
-#define KC_D 0x07
-#define KC_E 0x08
-#define KC_F 0x09
-#define KC_G 0x0A
-#define KC_H 0x0B
-#define KC_I 0x0C
-#define KC_J 0x0D
-#define KC_K 0x0E
-#define KC_L 0x0F
-#define KC_M 0x10
-#define KC_N 0x11
-#define KC_O 0x12
-#define KC_P 0x13
-#define KC_Q 0x14
-#define KC_R 0x15
-#define KC_S 0x16
-#define KC_T 0x17
-#define KC_U 0x18
-#define KC_V 0x19
-#define KC_W 0x1A
-#define KC_X 0x1B
-#define KC_Y 0x1C
-#define KC_Z 0x1D
-#define KC_1 0x1E
-#define KC_2 0x1F
-#define KC_3 0x20
-#define KC_4 0x21
-#define KC_5 0x22
-#define KC_6 0x23
-#define KC_7 0x24
-#define KC_8 0x25
-#define KC_9 0x26
-#define KC_0 0x27
-#define KC_RET 0x28
-#define KC_ESC 0x29
-#define KC_DEL 0x2A
-#define KC_BKSP KC_DEL
-#define KC_TAB 0x2B
-#define KC_SPC 0x2C
-#define KC_MIN 0x2D
-#define KC_EQL 0x2E
-#define KC_LBKT 0x2F
-#define KC_RBKT 0x30
-#define KC_FSLH 0x31
-
-#define KC_SCLN 0x33
-#define KC_QUOT 0x34
-#define KC_GRAV 0x35
-#define KC_CMMA 0x36
-#define KC_DOT 0x37
-#define KC_BSLH 0x38
-#define KC_CLCK 0x39
-#define KC_F1 0x3A
-#define KC_F2 0x3B
-
-#define KC_RARW 0x4F
-#define KC_LARW 0x50
-#define KC_DARW 0x51
-#define KC_UARW 0x52
-
-#define KC_KDIV 0x54
-#define KC_KMLT 0x55
-#define KC_KMIN 0x56
-#define KC_KPLS 0x57
-
-#define KC_APP 0x65
-
-#define KC_CURU 0xB4
-
-#define KC_LPRN 0xB6
-#define KC_RPRN 0xB7
-#define KC_LCUR 0xB8
-#define KC_RCUR 0xB9
-
-#define KC_CRRT 0xC3
-#define KC_PRCT 0xC4
-#define KC_LABT 0xC5
-#define KC_RABT 0xC6
-#define KC_AMPS 0xC7
-#define KC_PIPE 0xC9
-#define KC_COLN 0xCB
-#define KC_HASH 0xCC
-#define KC_KSPC 0xCD
-#define KC_ATSN 0xCE
-#define KC_BANG 0xCF
-
-#define KC_LCTL 0xE0
-#define KC_LSFT 0xE1
-#define KC_LALT 0xE2
-#define KC_LGUI 0xE3
-#define KC_RCTL 0xE4
-#define KC_RSFT 0xE5
-#define KC_RALT 0xE6
-#define KC_RGUI 0xE7
-
-#define KC_VOLU 0x80
-#define KC_VOLD 0x81
+#define A 0x04
+#define B 0x05
+#define C 0x06
+#define D 0x07
+#define E 0x08
+#define F 0x09
+#define G 0x0A
+#define H 0x0B
+#define I 0x0C
+#define J 0x0D
+#define K 0x0E
+#define L 0x0F
+#define M 0x10
+#define N 0x11
+#define O 0x12
+#define P 0x13
+#define Q 0x14
+#define R 0x15
+#define S 0x16
+#define T 0x17
+#define U 0x18
+#define V 0x19
+#define W 0x1A
+#define X 0x1B
+#define Y 0x1C
+#define Z 0x1D
+#define NUM_1 0x1E
+#define NUM_2 0x1F
+#define NUM_3 0x20
+#define NUM_4 0x21
+#define NUM_5 0x22
+#define NUM_6 0x23
+#define NUM_7 0x24
+#define NUM_8 0x25
+#define NUM_9 0x26
+#define NUM_0 0x27
+#define RET 0x28
+#define ESC 0x29
+#define DEL 0x2A
+#define BKSP DEL
+#define TAB 0x2B
+#define SPC 0x2C
+#define MINUS 0x2D
+#define EQL 0x2E
+#define LBKT 0x2F
+#define RBKT 0x30
+#define FSLH 0x31
+
+#define SCLN 0x33
+#define QUOT 0x34
+#define GRAV 0x35
+#define CMMA 0x36
+#define DOT 0x37
+#define BSLH 0x38
+#define CLCK 0x39
+#define F1 0x3A
+#define F2 0x3B
+
+#define RARW 0x4F
+#define LARW 0x50
+#define DARW 0x51
+#define UARW 0x52
+
+#define KDIV 0x54
+#define KMLT 0x55
+#define KMIN 0x56
+#define KPLS 0x57
+
+#define GUI 0x65
+
+#define CURU 0xB4
+
+#define LPRN 0xB6
+#define RPRN 0xB7
+#define LCUR 0xB8
+#define RCUR 0xB9
+
+#define CRRT 0xC3
+#define PRCT 0xC4
+#define LABT 0xC5
+#define RABT 0xC6
+#define AMPS 0xC7
+#define PIPE 0xC9
+#define COLN 0xCB
+#define HASH 0xCC
+#define KSPC 0xCD
+#define ATSN 0xCE
+#define BANG 0xCF
+
+#define LCTL 0xE0
+#define LSFT 0xE1
+#define LALT 0xE2
+#define LGUI 0xE3
+#define RCTL 0xE4
+#define RSFT 0xE5
+#define RALT 0xE6
+#define RGUI 0xE7
+
+#define VOLU 0x80
+#define VOLD 0x81
/* The following are select consumer page usages */
-#define KC_MNXT 0x100
-#define KC_MPRV 0x101
-#define KC_MSTP 0x102
-#define KC_MJCT 0x103
-#define KC_MPLY 0x104
-#define KC_MMUT 0x105
-#define KC_MVLU 0x106
-#define KC_MVLD 0x107
-
-#define ZC_TRNS (0xFFFF)
-#define ZC_NO (0xFFFF - 1)
-
-#define ZC_CSTM(n) (0xFFF + n)
+#define MNXT 0x100
+#define MPRV 0x101
+#define MSTP 0x102
+#define MJCT 0x103
+#define MPLY 0x104
+#define MMUT 0x105
+#define MVLU 0x106
+#define MVLD 0x107
#define MOD_LCTL (1 << 0x00)
#define MOD_LSFT (1 << 0x01)
@@ -127,16 +122,4 @@
#define MOD_RALT (1 << 0x06)
#define MOD_RGUI (1 << 0x07)
-#define ZK_ACTION(k) (k >> 24)
-#define _ACTION(a) (a << 24)
-#define _ACTION_MODS(m) (m << 16)
-#define ZK_KEY(a) (a & 0xFFFF)
-#define ZK_MODS(a) ((a >> 16) & 0xFF)
-
#define ZK_IS_CONSUMER(k) (ZK_KEY(k) >= 0x100)
-
-#define ZMK_ACTION_KEY 0x01
-#define ZMK_ACTION_MOD_TAP 0x01
-#define ZMK_ACTION_ONE_SHOT 0x02
-
-#define MT(mods, kc) (_ACTION(ZMK_ACTION_MOD_TAP) + _ACTION_MODS(mods) + kc)
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) */
diff --git a/app/src/ble.c b/app/src/ble.c
index 51607c6..0e6c5f2 100644
--- a/app/src/ble.c
+++ b/app/src/ble.c
@@ -168,12 +168,12 @@ bool zmk_ble_handle_key_user(struct zmk_key_event *key_event)
return true;
}
- if (key < KC_1 || key > KC_0)
+ if (key < NUM_1 || key > NUM_0)
{
return true;
}
- u32_t val = (key == KC_0) ? 0 : (key - KC_1 + 1);
+ u32_t val = (key == NUM_0) ? 0 : (key - NUM_1 + 1);
passkey_entries[passkey_digit++] = val;
diff --git a/app/src/handlers.c b/app/src/handlers.c
deleted file mode 100644
index 464b1ab..0000000
--- a/app/src/handlers.c
+++ /dev/null
@@ -1,88 +0,0 @@
-
-#include <zmk/ble.h>
-#include <zmk/handlers.h>
-#include <zmk/endpoints.h>
-#include <zmk/hid.h>
-#include <zmk/matrix.h>
-
-#ifdef CONFIG_ZMK_ACTION_MOD_TAP
-u16_t action_effect_pending = 0;
-#endif
-
-__attribute__((weak)) bool zmk_handle_key_user(struct zmk_key_event *key_event)
-{
- return true;
-};
-
-bool zmk_handle_action(zmk_action action, struct zmk_key_event *key_event)
-{
- zmk_mod mods = ZK_MODS(key_event->key);
- u8_t flattened_index = (key_event->row * ZMK_MATRIX_COLS) + key_event->column;
- switch (action)
- {
-#ifdef CONFIG_ZMK_ACTION_MOD_TAP
- case ZMK_ACTION_MOD_TAP:
- if (key_event->pressed)
- {
- WRITE_BIT(action_effect_pending, flattened_index, true);
- zmk_hid_register_mods(mods);
- }
- else
- {
- zmk_hid_unregister_mods(mods);
- if (action_effect_pending & BIT(flattened_index))
- {
- struct zmk_key_event non_mod_event =
- {
- .row = key_event->row,
- .column = key_event->column,
- .key = ZK_KEY(key_event->key),
- .pressed = true};
-
- zmk_handle_key(non_mod_event);
- // A small sleep is needed to ensure device layer sends initial
- // key, before we send the release.
- k_msleep(10);
- non_mod_event.pressed = false;
- zmk_handle_key(non_mod_event);
- }
- else
- {
- // Since not sending a keycode, at least send the report w/ the mod removed
- zmk_endpoints_send_report(Keypad);
- }
- }
- break;
-#endif
- }
- return false;
-};
-
-void zmk_handle_key(struct zmk_key_event key_event)
-{
- zmk_action action = ZK_ACTION(key_event.key);
-
- if (!zmk_handle_key_user(&key_event))
- {
- return;
- }
-
- if (action && !zmk_handle_action(action, &key_event))
- {
- return;
- }
-
-#ifdef CONFIG_ZMK_ACTION_MOD_TAP
- action_effect_pending = 0;
-#endif
-
-#ifdef CONFIG_ZMK_BLE
- /* Used for intercepting key presses when doing passkey verification */
- if (!zmk_ble_handle_key_user(&key_event))
- {
- return;
- }
-#endif /* CONFIG_ZMK_BLE */
-
- zmk_endpoints_send_key_event(key_event);
-};
diff --git a/app/src/hid.c b/app/src/hid.c
index b3d47cf..2bcb621 100644
--- a/app/src/hid.c
+++ b/app/src/hid.c
@@ -66,19 +66,19 @@ int zmk_hid_unregister_mods(zmk_mod_flags modifiers)
enum zmk_hid_report_changes zmk_hid_press_key(zmk_key code)
{
- if (code >= KC_LCTL && code <= KC_RGUI)
+ if (code >= LCTL && code <= RGUI)
{
- return zmk_hid_register_mod(code - KC_LCTL);
+ return zmk_hid_register_mod(code - LCTL);
}
- if (ZK_IS_CONSUMER(code))
- {
- LOG_DBG("Toggling a consumer key!");
- TOGGLE_CONSUMER(code, true);
- return Consumer;
- }
- else
- {
+ // if (ZK_IS_CONSUMER(code))
+ // {
+ // LOG_DBG("Toggling a consumer key!");
+ // TOGGLE_CONSUMER(code, true);
+ // return Consumer;
+ // }
+ // else
+ // {
if (code > ZMK_HID_MAX_KEYCODE)
{
return -EINVAL;
@@ -89,23 +89,23 @@ enum zmk_hid_report_changes zmk_hid_press_key(zmk_key code)
TOGGLE_KEY(code, true);
return Keypad;
- }
+ // }
};
enum zmk_hid_report_changes zmk_hid_release_key(zmk_key code)
{
- if (code >= KC_LCTL && code <= KC_RGUI)
+ if (code >= LCTL && code <= RGUI)
{
- return zmk_hid_unregister_mod(code - KC_LCTL);
+ return zmk_hid_unregister_mod(code - LCTL);
}
- if (ZK_IS_CONSUMER(code))
- {
- TOGGLE_CONSUMER(code, false);
- return Consumer;
- }
- else
- {
+ // if (ZK_IS_CONSUMER(code))
+ // {
+ // TOGGLE_CONSUMER(code, false);
+ // return Consumer;
+ // }
+ // else
+ // {
if (code > ZMK_HID_MAX_KEYCODE)
{
return -EINVAL;
@@ -116,7 +116,7 @@ enum zmk_hid_report_changes zmk_hid_release_key(zmk_key code)
TOGGLE_KEY(code, false);
return Keypad;
- }
+ // }
};
struct zmk_hid_keypad_report *zmk_hid_get_keypad_report()