forked from kofal.net/zmk
Initial work on keymap transforms for non-standard matrixes.
* Allows "gaps" for keyboards like Kyra. * Allows keyboards with matrixes that don't map the logical key locations to have normal looking keymaps when defined.
This commit is contained in:
7
app/boards/shields/kyria/Kconfig.defconfig
Normal file
7
app/boards/shields/kyria/Kconfig.defconfig
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
if SHIELD_KYRIA
|
||||
|
||||
config ZMK_KEYBOARD_NAME
|
||||
default "Kyria"
|
||||
|
||||
endif
|
||||
5
app/boards/shields/kyria/Kconfig.shield
Normal file
5
app/boards/shields/kyria/Kconfig.shield
Normal file
@@ -0,0 +1,5 @@
|
||||
# Copyright (c) 2020 Pete Johanson
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
config SHIELD_KYRIA
|
||||
def_bool $(shields_list_contains,kyria)
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
|
||||
#define CC_RAIS ZC_CSTM(1)
|
||||
#define CC_LOWR ZC_CSTM(2)
|
||||
34
app/boards/shields/kyria/keymaps/default/keymap.c
Normal file
34
app/boards/shields/kyria/keymaps/default/keymap.c
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
#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;
|
||||
};
|
||||
50
app/boards/shields/kyria/keymaps/default/keymap.overlay
Normal file
50
app/boards/shields/kyria/keymaps/default/keymap.overlay
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
#include <dt-bindings/zmk/keymap-transform.h>
|
||||
#include <keymap.h>
|
||||
|
||||
/ {
|
||||
chosen {
|
||||
zmk,keymap = &keymap0;
|
||||
};
|
||||
|
||||
keymap0: keymap {
|
||||
compatible = "zmk,keymap";
|
||||
label ="Default Kyria Keymap";
|
||||
layers = <&default>;
|
||||
transform = <&default_transform>;
|
||||
};
|
||||
|
||||
default_transform: keymap_transform_0 {
|
||||
compatible = "zmk,keymap-transform";
|
||||
map = <
|
||||
IDENTITY_ROW(0, 6) OFFSET_ROW(6, 0, 6)
|
||||
IDENTITY_ROW(1, 6) OFFSET_ROW(6, 1, 6)
|
||||
IDENTITY_ROW(2, 8) OFFSET_ROW(8, 2, 8)
|
||||
OFFSET_ROW(3, 3, 5) OFFSET_ROW(8, 3, 5)
|
||||
>;
|
||||
};
|
||||
|
||||
five_column_transform: keymap_transform_1 {
|
||||
compatible = "zmk,keymap-transform";
|
||||
map = <
|
||||
IDENTITY_ROW(0, 5) OFFSET_ROW(5, 0, 5)
|
||||
IDENTITY_ROW(1, 5) OFFSET_ROW(6, 1, 5)
|
||||
IDENTITY_ROW(2, 7) OFFSET_ROW(7, 2, 7)
|
||||
OFFSET_ROW(2, 3, 5) OFFSET_ROW(7, 3, 5)
|
||||
>;
|
||||
};
|
||||
|
||||
layers {
|
||||
compatible = "zmk,layers";
|
||||
|
||||
default: layer_0 {
|
||||
label = "DEFAULT";
|
||||
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
|
||||
>;
|
||||
};
|
||||
};
|
||||
};
|
||||
0
app/boards/shields/kyria/kyria.conf
Normal file
0
app/boards/shields/kyria/kyria.conf
Normal file
75
app/boards/shields/kyria/kyria.overlay
Normal file
75
app/boards/shields/kyria/kyria.overlay
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Pete Johanson
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/ {
|
||||
chosen {
|
||||
zmk,kscan = &kscan0;
|
||||
};
|
||||
|
||||
kscan0: kscan_comp {
|
||||
compatible = "zmk,kscan-composite";
|
||||
|
||||
label = "KSCAN_COMP";
|
||||
rows = <4>;
|
||||
columns = <16>;
|
||||
|
||||
left {
|
||||
kscan = <&kscan_left>;
|
||||
};
|
||||
|
||||
right {
|
||||
kscan = <&kscan_right>;
|
||||
// TODO: Actually put this in the kscan driver, so it can report
|
||||
// HID events directly to host if plugged in directly.
|
||||
column-offset = <8>;
|
||||
};
|
||||
};
|
||||
|
||||
kscan_left: kscan_left {
|
||||
compatible = "gpio-kscan";
|
||||
label = "KSCAN_LEFT";
|
||||
|
||||
diode-direction = "row2col";
|
||||
row-gpios = <&pro_micro_pins 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
|
||||
|
||||
col-gpios = <&pro_micro_pins 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 18 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 19 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 20 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 21 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
|
||||
};
|
||||
|
||||
kscan_right: kscan_right {
|
||||
compatible = "gpio-kscan";
|
||||
label = "KSCAN_RIGHT";
|
||||
|
||||
diode-direction = "row2col";
|
||||
row-gpios = <&pro_micro_pins 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
|
||||
|
||||
col-gpios = <&pro_micro_pins 21 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 20 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 19 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 18 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
|
||||
<&pro_micro_pins 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
|
||||
};
|
||||
|
||||
// TODO: Encoder node(s)
|
||||
// TODO: OLED node
|
||||
// TODO: RGB node(s)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user