Browse Source

Clean up and implement MT release w/o mod press.

xmkb
Pete Johanson 5 years ago
parent
commit
76a433fc39
  1. 5
      boards/native_posix.overlay
  2. 1
      include/dt-bindings/zmk/keys.h
  3. 3
      src/endpoints.c
  4. 12
      src/handlers.c

5
boards/native_posix.overlay

@ -13,7 +13,8 @@ @@ -13,7 +13,8 @@
rows = <2>;
columns = <2>;
events = <ZMK_MOCK_PRESS(0,0,800) ZMK_MOCK_RELEASE(0,0,800)>;
events = <ZMK_MOCK_PRESS(0,1,300) ZMK_MOCK_PRESS(0,0,300) ZMK_MOCK_RELEASE(0,0,300) ZMK_MOCK_RELEASE(0,1,300)>;
// events = <ZMK_MOCK_PRESS(0,0,800) ZMK_MOCK_RELEASE(0,0,800) ZMK_MOCK_PRESS(0,1,800) ZMK_MOCK_RELEASE(0,1,800)>;
};
keymap0: keymap {
@ -29,7 +30,7 @@ @@ -29,7 +30,7 @@
label = "DEFAULT";
keys =
<
KC_A KC_B
KC_A MT(MOD_LSFT, KC_B)
KC_C KC_D
>;
};

1
include/dt-bindings/zmk/keys.h

@ -86,6 +86,7 @@ @@ -86,6 +86,7 @@
#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 ZMK_ACTION_KEY 0x01

3
src/endpoints.c

@ -56,9 +56,6 @@ int zmk_endpoints_send_report() @@ -56,9 +56,6 @@ int zmk_endpoints_send_report()
int zmk_endpoints_send_key_event(struct zmk_key_event key_event)
{
struct zmk_hid_report *report;
int err;
LOG_DBG("key %d, state %d\n", key_event.key, key_event.pressed);
if (key_event.pressed)

12
src/handlers.c

@ -32,8 +32,16 @@ bool zmk_handle_action(zmk_action action, struct zmk_key_event *key_event) @@ -32,8 +32,16 @@ bool zmk_handle_action(zmk_action action, struct zmk_key_event *key_event)
zmk_hid_unregister_mods(mods);
if (action_effect_pending & BIT(flattened_index))
{
// Allow baseline keycode to flow to the endpoints!
return true;
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);
non_mod_event.pressed = false;
zmk_handle_key(non_mod_event);
}
else
{

Loading…
Cancel
Save