From a12734fbb3473f75075502faf984d99defc2fff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Tu=C4=8Dek?= Date: Fri, 20 Sep 2024 21:18:14 +0200 Subject: [PATCH 1/5] Migrate to new keyid mappings. --- device/src/keyboard/key_scanner.c | 11 +- device/src/legacy/layouts/key_layout.c | 1 + device/src/legacy/layouts/key_layout.h | 1 + .../layouts/key_layout_60_to_universal.c | 1 + .../layouts/key_layout_60_to_universal.h | 1 + .../layouts/key_layout_80_to_universal.c | 1 + .../layouts/key_layout_80_to_universal.h | 1 + right/src/keymap.c | 46 ++--- .../src/layouts}/key_layout.c | 2 + .../src/layouts}/key_layout.h | 7 +- .../src/layouts/key_layout_60_to_universal.c | 99 +++++++++ .../src/layouts/key_layout_60_to_universal.h | 19 ++ .../src/layouts/key_layout_80_to_universal.c | 153 ++++++++++++++ .../src/layouts/key_layout_80_to_universal.h | 21 ++ right/src/ledmap.c | 47 ++--- right/src/macros/keyid_parser.c | 192 +++++++++--------- right/src/main.c | 15 +- right/src/slave_drivers/uhk_module_driver.c | 14 +- 18 files changed, 473 insertions(+), 159 deletions(-) create mode 120000 device/src/legacy/layouts/key_layout.c create mode 120000 device/src/legacy/layouts/key_layout.h create mode 120000 device/src/legacy/layouts/key_layout_60_to_universal.c create mode 120000 device/src/legacy/layouts/key_layout_60_to_universal.h create mode 120000 device/src/legacy/layouts/key_layout_80_to_universal.c create mode 120000 device/src/legacy/layouts/key_layout_80_to_universal.h rename {device/src/keyboard => right/src/layouts}/key_layout.c (99%) rename {device/src/keyboard => right/src/layouts}/key_layout.h (75%) create mode 100644 right/src/layouts/key_layout_60_to_universal.c create mode 100644 right/src/layouts/key_layout_60_to_universal.h create mode 100644 right/src/layouts/key_layout_80_to_universal.c create mode 100644 right/src/layouts/key_layout_80_to_universal.h diff --git a/device/src/keyboard/key_scanner.c b/device/src/keyboard/key_scanner.c index 0e3c014ad..d9c7d67ac 100644 --- a/device/src/keyboard/key_scanner.c +++ b/device/src/keyboard/key_scanner.c @@ -10,7 +10,6 @@ #include "oled/oled_buffer.h" #include "logger.h" #include "key_states.h" -#include "keyboard/key_layout.h" #include "bool_array_converter.h" #include "legacy/module.h" #include "logger.h" @@ -21,6 +20,8 @@ #include "legacy/config_manager.h" #include "legacy/macros/keyid_parser.h" #include "attributes.h" +#include "legacy/layouts/key_layout.h" +#include "legacy/layouts/key_layout_80_to_universal.h" // Thread definitions @@ -115,7 +116,13 @@ static void scanKeys() { for (uint8_t rowId=0; rowId= 8) { + targetKeyId = KeyLayout_Uhk80_to_Universal[slotId][sourceIndex]; + } else { + targetKeyId = KeyLayout_Uhk80_to_Uhk60[slotId][sourceIndex]; + } if (targetKeyId < MAX_KEY_COUNT_PER_MODULE) { if (currentBacklightingMode == BacklightingMode_LedTest) { diff --git a/device/src/legacy/layouts/key_layout.c b/device/src/legacy/layouts/key_layout.c new file mode 120000 index 000000000..cebed70f0 --- /dev/null +++ b/device/src/legacy/layouts/key_layout.c @@ -0,0 +1 @@ +../../../../right/src/layouts/key_layout.c \ No newline at end of file diff --git a/device/src/legacy/layouts/key_layout.h b/device/src/legacy/layouts/key_layout.h new file mode 120000 index 000000000..4a2a0807a --- /dev/null +++ b/device/src/legacy/layouts/key_layout.h @@ -0,0 +1 @@ +../../../../right/src/layouts/key_layout.h \ No newline at end of file diff --git a/device/src/legacy/layouts/key_layout_60_to_universal.c b/device/src/legacy/layouts/key_layout_60_to_universal.c new file mode 120000 index 000000000..28f4b7df9 --- /dev/null +++ b/device/src/legacy/layouts/key_layout_60_to_universal.c @@ -0,0 +1 @@ +../../../../right/src/layouts/key_layout_60_to_universal.c \ No newline at end of file diff --git a/device/src/legacy/layouts/key_layout_60_to_universal.h b/device/src/legacy/layouts/key_layout_60_to_universal.h new file mode 120000 index 000000000..78f0fa4c2 --- /dev/null +++ b/device/src/legacy/layouts/key_layout_60_to_universal.h @@ -0,0 +1 @@ +../../../../right/src/layouts/key_layout_60_to_universal.h \ No newline at end of file diff --git a/device/src/legacy/layouts/key_layout_80_to_universal.c b/device/src/legacy/layouts/key_layout_80_to_universal.c new file mode 120000 index 000000000..745f8a106 --- /dev/null +++ b/device/src/legacy/layouts/key_layout_80_to_universal.c @@ -0,0 +1 @@ +../../../../right/src/layouts/key_layout_80_to_universal.c \ No newline at end of file diff --git a/device/src/legacy/layouts/key_layout_80_to_universal.h b/device/src/legacy/layouts/key_layout_80_to_universal.h new file mode 120000 index 000000000..0046c71e6 --- /dev/null +++ b/device/src/legacy/layouts/key_layout_80_to_universal.h @@ -0,0 +1 @@ +../../../../right/src/layouts/key_layout_80_to_universal.h \ No newline at end of file diff --git a/right/src/keymap.c b/right/src/keymap.c index 9882bc8bc..d54e6b8e8 100644 --- a/right/src/keymap.c +++ b/right/src/keymap.c @@ -135,6 +135,7 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_BACKSPACE }}, // Row 2 + { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_Y }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_U }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_I }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_O }}, @@ -142,16 +143,15 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_OPENING_BRACKET_AND_OPENING_BRACE }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_CLOSING_BRACKET_AND_CLOSING_BRACE }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_BACKSLASH_AND_PIPE }}, - { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_Y }}, // Row 3 + { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_H }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_J }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_K }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_L }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SEMICOLON_AND_COLON }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_APOSTROPHE_AND_QUOTE }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_ENTER }}, - { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_H }}, // Row 4 { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_N }}, @@ -160,15 +160,15 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_DOT_AND_GREATER_THAN_SIGN }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SLASH_AND_QUESTION_MARK }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_SHIFT }}, - { .type = KeyActionType_None }, // Row 5 { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SPACE }}, - { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod, .mode = SwitchLayerMode_Hold }}, { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn , .mode = SwitchLayerMode_Hold }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_ALT }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_GUI }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_CONTROL }}, + { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod, .mode = SwitchLayerMode_Hold }}, + { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn2, .mode = SwitchLayerMode_HoldAndDoubleTapToggle }}, #if DEVICE_IS_UHK80 // Row 0 @@ -194,7 +194,6 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_ARROW}}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_DOWN_ARROW}}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_ARROW}}, - { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn2, .mode = SwitchLayerMode_HoldAndDoubleTapToggle }}, #endif }, @@ -216,7 +215,6 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_W }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_E }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_R }}, - { .type = KeyActionType_None }, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_T }}, // Row 3 @@ -225,7 +223,6 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_S }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_D }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_F }}, - { .type = KeyActionType_None }, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_G }}, // Row 4 @@ -242,8 +239,9 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_GUI }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_ALT }}, { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn, .mode = SwitchLayerMode_Hold }}, - { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SPACE }}, { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod, .mode = SwitchLayerMode_Hold }}, + { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SPACE }}, + { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn2, .mode = SwitchLayerMode_HoldAndDoubleTapToggle }}, #if DEVICE_IS_UHK80 // Row 0 @@ -254,7 +252,6 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_F4 }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_F5 }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_F6 }}, - { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn2, .mode = SwitchLayerMode_HoldAndDoubleTapToggle }}, #endif }, @@ -288,6 +285,7 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_DELETE }}, // Row 2 + { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_PAGE_UP }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_HOME }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_UP_ARROW }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_END }}, @@ -295,16 +293,15 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_PRINT_SCREEN }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SCROLL_LOCK }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_PAUSE }}, - { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_PAGE_UP }}, // Row 3 + { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_PAGE_DOWN }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_ARROW }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_DOWN_ARROW }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_ARROW }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_INSERT }}, { .type = KeyActionType_None }, { .type = KeyActionType_None }, - { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_PAGE_DOWN }}, // Row 4 { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_ESCAPE }}, @@ -313,15 +310,14 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_None }, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_APPLICATION }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_SHIFT }}, - { .type = KeyActionType_None }, // Row 5 { .type = KeyActionType_None }, - { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod, .mode = SwitchLayerMode_Hold }}, { .type = KeyActionType_None }, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_ALT }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_GUI }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_CONTROL }}, + { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod, .mode = SwitchLayerMode_Hold }}, }, // Left keyboard half @@ -342,7 +338,6 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_T, .modifiers = HID_KEYBOARD_MODIFIER_LEFTCTRL }}, // [+] tab new { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_PAGE_DOWN, .modifiers = HID_KEYBOARD_MODIFIER_LEFTCTRL }}, // [>] tab next { .type = KeyActionType_None }, - { .type = KeyActionType_None }, // Row 3 { .type = KeyActionType_None }, @@ -351,7 +346,6 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_TAB, .modifiers = HID_KEYBOARD_MODIFIER_LEFTALT }}, // window switch { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_ARROW, .modifiers = HID_KEYBOARD_MODIFIER_LEFTCTRL | HID_KEYBOARD_MODIFIER_LEFTALT }}, // workspace next { .type = KeyActionType_None }, - { .type = KeyActionType_None }, // Row 4 { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_SHIFT }}, @@ -367,9 +361,9 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_GUI }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_ALT }}, { .type = KeyActionType_None }, - { .type = KeyActionType_None }, { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod, .mode = SwitchLayerMode_Hold }}, { .type = KeyActionType_None }, + { .type = KeyActionType_None }, }, // Left module @@ -402,6 +396,7 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_None }, // Row 2 + { .type = KeyActionType_None }, { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_PLAY_PAUSE }}, { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_VOLUME_UP }}, { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_STOP }}, @@ -409,16 +404,15 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_None }, { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_System, .scancode = SYSTEM_SLEEP }}, { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_System, .scancode = SYSTEM_POWER_DOWN }}, - { .type = KeyActionType_None }, // Row 3 + { .type = KeyActionType_None }, { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_PREVIOUS }}, { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_VOLUME_DOWN }}, { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_NEXT }}, { .type = KeyActionType_None }, { .type = KeyActionType_None }, { .type = KeyActionType_None }, - { .type = KeyActionType_None }, // Row 4 { .type = KeyActionType_None }, @@ -427,15 +421,14 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_None }, { .type = KeyActionType_None }, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_SHIFT }}, - { .type = KeyActionType_None }, // Row 5 { .type = KeyActionType_None }, - { .type = KeyActionType_None }, { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn, .mode = SwitchLayerMode_Hold }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_ALT }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_GUI }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_CONTROL }}, + { .type = KeyActionType_None }, }, // Left keyboard half @@ -456,7 +449,6 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = CONSUMER_BROWSER_REFRESH }}, { .type = KeyActionType_None }, { .type = KeyActionType_None }, - { .type = KeyActionType_None }, // Row 3 { .type = KeyActionType_None }, @@ -465,7 +457,6 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = CONSUMER_EXPLORER }}, { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = CONSUMER_BROWSER_FORWARD }}, { .type = KeyActionType_None }, - { .type = KeyActionType_None }, // Row 4 { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_SHIFT }}, @@ -516,6 +507,7 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_None }, // Row 2 + { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_ScrollUp }, { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_Button_4 }, { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_MoveUp }, { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_Button_5 }, @@ -523,16 +515,15 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_None }, { .type = KeyActionType_None }, { .type = KeyActionType_None }, - { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_ScrollUp }, // Row 3 + { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_ScrollDown }, { .type = KeyActionType_Mouse, .mouseAction= SerializedMouseAction_MoveLeft }, { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_MoveDown }, { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_MoveRight }, { .type = KeyActionType_None }, { .type = KeyActionType_None }, { .type = KeyActionType_None }, - { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_ScrollDown }, // Row 4 { .type = KeyActionType_None }, @@ -541,15 +532,14 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_None }, { .type = KeyActionType_None }, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_SHIFT }}, - { .type = KeyActionType_None }, // Row 5 { .type = KeyActionType_None }, { .type = KeyActionType_None }, - { .type = KeyActionType_None }, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_ALT }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_GUI }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_CONTROL }}, + { .type = KeyActionType_None }, }, // Left keyboard half @@ -570,7 +560,6 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_None }, { .type = KeyActionType_None }, { .type = KeyActionType_None }, - { .type = KeyActionType_None }, // Row 3 { .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mouse, .mode = SwitchLayerMode_HoldAndDoubleTapToggle }}, @@ -579,7 +568,6 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_MiddleClick }, { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_LeftClick }, { .type = KeyActionType_None }, - { .type = KeyActionType_None }, // Row 4 { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_SHIFT }}, @@ -595,8 +583,8 @@ key_action_t CurrentKeymap[LayerId_Count][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_GUI }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_ALT }}, { .type = KeyActionType_None }, - { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_Decelerate }, { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_Accelerate }, + { .type = KeyActionType_Mouse, .mouseAction = SerializedMouseAction_Decelerate }, { .type = KeyActionType_None }, }, diff --git a/device/src/keyboard/key_layout.c b/right/src/layouts/key_layout.c similarity index 99% rename from device/src/keyboard/key_layout.c rename to right/src/layouts/key_layout.c index 9da4da243..18a7e436d 100644 --- a/device/src/keyboard/key_layout.c +++ b/right/src/layouts/key_layout.c @@ -1,5 +1,6 @@ #include "key_layout.h" +#ifdef __ZEPHYR__ const uint8_t KeyLayout_Uhk80_to_Uhk60[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { { // UHK60 keys @@ -159,3 +160,4 @@ const uint8_t KeyLayout_Uhk80_to_Uhk60[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { {}, {}, }; +#endif diff --git a/device/src/keyboard/key_layout.h b/right/src/layouts/key_layout.h similarity index 75% rename from device/src/keyboard/key_layout.h rename to right/src/layouts/key_layout.h index 435fbca0d..0d3730df7 100644 --- a/device/src/keyboard/key_layout.h +++ b/right/src/layouts/key_layout.h @@ -3,13 +3,14 @@ // Includes - #include "legacy/module.h" - #include "legacy/slot.h" + #include "module.h" + #include "slot.h" // Variables: - +#ifdef __ZEPHYR__ extern const uint8_t KeyLayout_Uhk80_to_Uhk60[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE]; +#endif // Functions: diff --git a/right/src/layouts/key_layout_60_to_universal.c b/right/src/layouts/key_layout_60_to_universal.c new file mode 100644 index 000000000..6f0ad6f33 --- /dev/null +++ b/right/src/layouts/key_layout_60_to_universal.c @@ -0,0 +1,99 @@ +#include "key_layout_60_to_universal.h" + +const uint8_t KeyLayout_Uhk60_to_Universal[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { + { + // UHK60 keys + [0] = 0, // 7 + [1] = 1, // 8 + [2] = 2, // 9 + [3] = 3, // 0 + [4] = 4, // - + [5] = 5, // = + [6] = 6, // backspace + + [14] = 7, // y + [7] = 8, // u + [8] = 9, // i + [9] = 10, // o + [10] = 11, // p + [11] = 12, // [ + [12] = 13, // ] + [13] = 14, // | + + [21] = 15, // h + [15] = 16, // j + [16] = 17, // k + [17] = 18, // l + [18] = 19, // ; + [19] = 20, // ' + [20] = 21, // enter + + [22] = 22, // n + [23] = 23, // m + [24] = 24, // , + [25] = 25, // . + [26] = 26, // / + [27] = 27, // shift + + [29] = 28, // space + [31] = 29, // fn + [32] = 30, // alt + [33] = 31, // super + [34] = 32, // ctrl + + [30] = 33, // inner case button + + // empty + [28] = 255, + }, + { + // UHK60 keys + + [0] = 0, // tilde + [1] = 1, // 1 + [2] = 2, // 2 + [3] = 3, // 3 + [4] = 4, // 4 + [5] = 5, // 5 + [6] = 6, // 6 + + + [7] = 7, // tab + [8] = 8, // q + [9] = 9, // w + [10] = 10, // e + [11] = 11, // r + [13] = 12, // t + + [14] = 13, // mouse + [15] = 14, // a + [16] = 15, // s + [17] = 16, // d + [18] = 17, // f + [20] = 18, // g + + [21] = 19, // shift + [22] = 20, // iso key + [23] = 21, // z + [24] = 22, // x + [25] = 23, // c + [26] = 24, // v + [27] = 25, // b + + [28] = 26, // ctrl + [29] = 27, // super + [30] = 28, // alt + [31] = 29, // fn + [33] = 30, // mod + + [32] = 31, // inner case button + + // unused + + [12] = 255, + [19] = 255, + [34] = 255, + }, + {}, + {}, +}; diff --git a/right/src/layouts/key_layout_60_to_universal.h b/right/src/layouts/key_layout_60_to_universal.h new file mode 100644 index 000000000..55d2921a2 --- /dev/null +++ b/right/src/layouts/key_layout_60_to_universal.h @@ -0,0 +1,19 @@ +#ifndef __KEY_LAYOUT_60_TO_UNIVERSAL_H__ +#define __KEY_LAYOUT_60_TO_UNIVERSAL_H__ + +// Includes + + #include "module.h" + #include "slot.h" + +// Variables: + + + extern const uint8_t KeyLayout_Uhk60_to_Universal[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE]; + +// Functions: + + + +#endif // __KEY_LAYOUT_H__ + diff --git a/right/src/layouts/key_layout_80_to_universal.c b/right/src/layouts/key_layout_80_to_universal.c new file mode 100644 index 000000000..450d124ae --- /dev/null +++ b/right/src/layouts/key_layout_80_to_universal.c @@ -0,0 +1,153 @@ +#include "key_layout_80_to_universal.h" + +#ifdef __ZEPHYR__ + +const uint8_t KeyLayout_Uhk80_to_Universal[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { + { + [0] = 35, // f7 + [1] = 36, // f8 + [2] = 37, // f9 + [3] = 38, // f10 + [4] = 39, // f11 + [5] = 40, // f12 + [6] = 41, // print + [8] = 42, // del + [9] = 43, // ins + + [10] = 0, // 7 + [11] = 1, // 8 + [12] = 2, // 9 + [13] = 3, // 0 + [14] = 4, // - + [15] = 5, // = + [16] = 6, // backspace + [18] = 44, // scrl lck + [19] = 45, // pause + + [30] = 7, // y + [20] = 8, // u + [21] = 9, // i + [22] = 10, // o + [23] = 11, // p + [24] = 12, // [ + [25] = 13, // ] + [26] = 14, // | + [28] = 46, // home + [29] = 47, // pg up + + [40] = 15, // h + [31] = 16, // j + [32] = 17, // k + [33] = 18, // l + [34] = 19, // ; + [35] = 20, // ' + [36] = 21, // enter + [38] = 48, // end + [39] = 49, // pg down + + [50] = 22, // n + [41] = 23, // m + [43] = 24, // , + [44] = 25, // . + [45] = 26, // / + [46] = 27, // shift + [47] = 50, // dbl arrow left + [48] = 51, // arrow up + [49] = 52, // dbl arrow right + + [51] = 28, // space + [42] = 29, // fn + [54] = 30, // alt + [55] = 31, // super + [56] = 32, // ctrl + [57] = 53, // arrow left + [58] = 54, // arrow down + [59] = 55, // arrow right + + [52] = 33, // inner case button + [53] = 34, // right case button + + // empty + [7] = 255, + [17] = 255, + [27] = 255, + [37] = 255, + }, + { + // UHK60 keys + + [0] = 33, // esc + [1] = 34, // f1 + [2] = 35, // f2 + [3] = 36, // f3 + [4] = 37, // f4 + [5] = 38, // f5 + [6] = 39, // f6 + + [7] = 0, // tilde + [8] = 1, // 1 + [9] = 2, // 2 + [10] = 3, // 3 + [11] = 4, // 4 + [12] = 5, // 5 + [13] = 6, // 6 + + + [14] = 7, // tab + [15] = 8, // q + [16] = 9, // w + [17] = 10, // e + [18] = 11, // r + [19] = 12, // t + + [21] = 13, // mouse + [22] = 14, // a + [23] = 15, // s + [24] = 16, // d + [25] = 17, // f + [26] = 18, // g + + [28] = 19, // shift + [29] = 20, // iso key + [30] = 21, // z + [31] = 22, // x + [32] = 23, // c + [33] = 24, // v + [34] = 25, // b + + [35] = 26, // ctrl + [36] = 27, // super + [37] = 28, // alt + [40] = 29, // fn + [41] = 30, // mod + + [39] = 31, // inner case button + [38] = 32, // left case button + + // unused + [20] = 255, + [27] = 255, + [42] = 255, + [43] = 255, + [44] = 255, + [45] = 255, + [46] = 255, + [47] = 255, + [48] = 255, + [49] = 255, + [50] = 255, + [51] = 255, + [52] = 255, + [53] = 255, + [54] = 255, + [55] = 255, + [56] = 255, + [57] = 255, + [58] = 255, + [59] = 255, + }, + {}, + {}, +}; + +#endif diff --git a/right/src/layouts/key_layout_80_to_universal.h b/right/src/layouts/key_layout_80_to_universal.h new file mode 100644 index 000000000..f35f952f8 --- /dev/null +++ b/right/src/layouts/key_layout_80_to_universal.h @@ -0,0 +1,21 @@ +#ifndef __KEY_LAYOUT_80_TO_UNIVERSAL_H__ +#define __KEY_LAYOUT_80_TO_UNIVERSAL_H__ + +// Includes + + #include "module.h" + #include "slot.h" + +// Variables: + + +#ifdef __ZEPHYR__ + extern const uint8_t KeyLayout_Uhk80_to_Universal[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE]; +#endif + +// Functions: + + + +#endif // __KEY_LAYOUT_H__ + diff --git a/right/src/ledmap.c b/right/src/ledmap.c index d3a5377a9..c61711c87 100644 --- a/right/src/ledmap.c +++ b/right/src/ledmap.c @@ -57,6 +57,7 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { MONO(6), // Backspace // Row 2 + MONO(32), // Y MONO(16), // U MONO(17), // I MONO(18), // O @@ -64,16 +65,15 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { MONO(20), // [ MONO(21), // ] MONO(22), // Backslash - MONO(32), // Y // Row 3 + MONO(48), // H MONO(33), // J MONO(34), // K MONO(35), // L MONO(36), // ; MONO(37), // ' MONO(38), // Enter - MONO(48), // H // Row 4 MONO(49), // N @@ -82,15 +82,16 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { MONO(52), // . MONO(53), // / MONO(54), // Right Shift - MONO(0), // Unused // Row 5 MONO(65), // Right Space - MONO(0), // Right Mod (no backlight) MONO(67), // Right Fn MONO(68), // Right Alt MONO(69), // Right Super MONO(70), // Right Control + + // Row 6 + MONO(0), // Right Mod (no backlight) }, // Left keyboard half @@ -114,7 +115,6 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { MONO(18), // W MONO(19), // E MONO(20), // R - MONO(0), // Unused MONO(22), // T // Row 3 @@ -123,7 +123,6 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { MONO(34), // S MONO(35), // D MONO(36), // F - MONO(0), // Unused MONO(38), // G // Row 4 @@ -140,9 +139,10 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { MONO(65), // Left Super MONO(66), // Left Alt MONO(67), // Left Fn - MONO(0), // Left Space (no backlight) MONO(69), // Left Mod - MONO(0), // Unused + + // Row 6 + MONO(0), // Left Space (no backlight) }, // Left module @@ -177,6 +177,7 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(0x95, 0xA5, 0x25), // = RGB(0x98, 0xA8, 0x28), // Backspace // Row 2 + RGB(0x9D, 0xAD, 0x2D), // Y RGB(0x99, 0xA9, 0x29), // U RGB(0x9A, 0xAA, 0x2A), // I RGB(0x9B, 0xAB, 0x2B), // O @@ -184,16 +185,15 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(0x60, 0x70, 0x80), // [ RGB(0x61, 0x71, 0x81), // ] RGB(0x62, 0x72, 0x82), // Backslash - RGB(0x9D, 0xAD, 0x2D), // Y // Row 3 + RGB(0x3D, 0x4D, 0x5D), // H RGB(0x30, 0x40, 0x50), // J RGB(0x31, 0x41, 0x51), // K RGB(0x32, 0x42, 0x52), // L RGB(0x33, 0x43, 0x53), // ; RGB(0x34, 0x44, 0x54), // ' RGB(0x35, 0x45, 0x55), // Enter - RGB(0x3D, 0x4D, 0x5D), // H // Row 4 RGB(0x39, 0x49, 0x59), // N @@ -202,15 +202,16 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(0x3C, 0x4C, 0x5C), // . RGB(0x38, 0x48, 0x58), // / RGB(0x63, 0x73, 0x83), // Right Shift - RGB(0x00, 0x00, 0x00), // Unused // Row 5 RGB(0x69, 0x79, 0x89), // Right Space - RGB(0x00, 0x00, 0x00), // Right Mod (no backlight) RGB(0x6A, 0x7A, 0x8A), // Right Fn RGB(0x68, 0x78, 0x88), // Right Alt RGB(0x64, 0x74, 0x84), // Right Super RGB(0x65, 0x75, 0x85), // Right Control + + // Row 6 + RGB(0x00, 0x00, 0x00), // Right Mod (no backlight) }, // Left keyboard half @@ -234,7 +235,6 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(0x04, 0x14, 0x24), // W RGB(0x08, 0x18, 0x28), // E RGB(0x0A, 0x1A, 0x2A), // R - RGB(0x00, 0x00, 0x00), // Unused RGB(0x0C, 0x1C, 0x2c), // T // Row 3 @@ -243,7 +243,6 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(0x05, 0x15, 0x25), // S RGB(0x09, 0x19, 0x29), // D RGB(0x0B, 0x1B, 0x2B), // F - RGB(0x00, 0x00, 0x00), // Unused RGB(0x0D, 0x1D, 0x2D), // G // Row 4 @@ -261,9 +260,10 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(0x33, 0x43, 0x53), // Left Super RGB(0x35, 0x45, 0x55), // Left Alt RGB(0x39, 0x49, 0x59), // Left Fn - RGB(0x00, 0x00, 0x00), // Left Space (no backlight) RGB(0x3C, 0x4C, 0x5C), // Left Mod - RGB(0x00, 0x00, 0x00), // Unused + + // Row 6 + RGB(0x00, 0x00, 0x00), // Left Space (no backlight) }, // Left module @@ -290,6 +290,7 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(14,13,15), // - RGB(32,31,33), // = RGB(194,193,195), // backspace + RGB(145,146,153), // y RGB(160,161,162), // u RGB(124,125,126), // i RGB(88,89,90), // o @@ -297,27 +298,26 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(16,17,18), // [ RGB(34,35,36), // ] RGB(196,197,198), // | - RGB(145,146,153), // y + RGB(147,148,149), // h RGB(109,110,117), // j RGB(73,74,81), // k RGB(37,38,45), // l RGB(1,2,9), // ; RGB(19,20,27), // ' RGB(181,182,189), // enter - RGB(147,148,149), // h RGB(151,150,152), // n RGB(111,112,113), // m RGB(39,40,41), // , RGB(3,4,5), // . RGB(21,22,23), // / RGB(183,184,185), // shift - RGB(0,0,0), // unused RGB(115,114,116), // space - RGB(79,78,80), // inner case button RGB(75,76,77), // fn RGB(7,6,8), // alt RGB(25,24,26), // super RGB(187,186,188), // ctrl + RGB(79,78,80), // inner case button + RGB(43,42,44), // right case button RGB(155,154,156), // f7 RGB(119,118,120), // f8 RGB(83,82,84), // f9 @@ -339,7 +339,6 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(97,96,98), // arrow left RGB(169,168,170), // arrow down RGB(133,132,134), // arrow right - RGB(43,42,44), // right case button }, // Left keyboard half @@ -356,14 +355,12 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(44,45,38), // w RGB(80,81,74), // e RGB(116,117,110), // r - RGB(0,0,0), // unused RGB(134,135,128), // t RGB(154,155,156), // mouse RGB(64,65,66), // a RGB(46,47,48), // s RGB(82,83,84), // d RGB(118,119,120), // f - RGB(0,0,0), // 19 RGB(136,137,138), // g RGB(190,191,192), // shift RGB(67,68,70), // isoKey @@ -376,8 +373,9 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(69,72,71), // super RGB(51,54,53), // alt RGB(141,144,143), // fn - RGB(123,126,125), // inner case button RGB(195,198,197), // mod + RGB(123,126,125), // inner case button + RGB(87,90,89), // left case button RGB(147,148,149), // esc RGB(57,58,59), // f1 RGB(39,40,41), // f2 @@ -385,7 +383,6 @@ static rgb_t LedMap[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = { RGB(111,112,113), // f4 RGB(129,130,131), // f5 RGB(183,184,185), // f6 - RGB(87,90,89), // left case button }, // Left module diff --git a/right/src/macros/keyid_parser.c b/right/src/macros/keyid_parser.c index f756bb560..b96baaba8 100644 --- a/right/src/macros/keyid_parser.c +++ b/right/src/macros/keyid_parser.c @@ -14,122 +14,122 @@ typedef struct { static const lookup_record_t lookup_table[] = { // ALWAYS keep the array sorted by `LC_ALL=C sort` - {"", 255}, - {"'", 19}, - {",", 24}, - {"-", 4}, - {".", 25}, - {"/", 26}, - {"0", 3}, - {"1", 65}, - {"2", 66}, - {"3", 67}, - {"4", 68}, - {"5", 69}, - {"6", 70}, {"7", 0}, {"8", 1}, {"9", 2}, - {";", 18}, + {"0", 3}, + {"-", 4}, + {"minusAndUnderscore", 4}, {"=", 5}, - {"[", 11}, - {"]", 12}, - {"`", 64}, - {"a", 79}, - {"apostropheAndQuote", 19}, - {"b", 91}, + {"equalAndPlus", 5}, {"backspace", 6}, - {"c", 89}, - {"capsLock", 78}, - {"closingBracketAndClosingBrace", 12}, + {"y", 7}, + {"u", 8}, + {"i", 9}, + {"o", 10}, + {"p", 11}, + {"[", 12}, + {"openingBracketAndOpeningBrace", 12}, + {"]", 13}, + {"closingBracketAndClosingBrace", 13}, + {"|", 14}, + {"h", 15}, + {"j", 16}, + {"k", 17}, + {"l", 18}, + {";", 19}, + {"semicolonAndColon", 19}, + {"'", 20}, + {"apostropheAndQuote", 20}, + {"enter", 21}, + {"n", 22}, + {"m", 23}, + {",", 24}, {"commaAndLessThanSign", 24}, - {"d", 81 }, - {"delete", 42}, + {".", 25}, {"dotAndGreaterThanSign", 25}, - {"downArrow", 54}, - {"e", 74 }, - {"end", 48}, - {"enter", 20}, - {"equalAndPlus", 5}, - {"escape", 98}, - {"f", 82}, - {"f1", 99}, - {"f10", 38}, - {"f11", 39}, - {"f12", 40}, - {"f2", 100}, - {"f3", 101}, - {"f4", 102}, - {"f5", 103}, - {"f6", 104}, + {"/", 26}, + {"slashAndQuestionMark", 26}, + {"rightShift", 27}, + {"rightSpace", 28}, + {"rightFn", 29}, + {"rightAlt", 30}, + {"rightSuper", 31}, + {"rightCtrl", 32}, + {"rightMod", 33}, + {"rightFn2", 34}, {"f7", 35}, {"f8", 36}, {"f9", 37}, - {"g", 84}, - {"graveAccentAndTilde", 63}, - {"h", 21}, - {"home", 46}, - {"i", 8}, + {"f10", 38}, + {"f11", 39}, + {"f12", 40}, + {"print", 41}, + {"delete", 42}, {"insert", 43}, - {"isoKey", 86}, - {"j", 15}, - {"k", 16}, - {"l", 17}, - {"leftAlt", 94}, + {"scrollLock", 44}, + {"pause", 45}, + {"home", 46}, + {"pageUp", 47}, + {"end", 48}, + {"pageDown", 49}, + {"previous", 50}, + {"upArrow", 51}, + {"next", 52}, {"leftArrow", 53}, - {"leftCtrl", 92}, - {"leftFn", 95}, - {"leftFn2", 105}, - {"leftMod", 97}, + {"downArrow", 54}, + {"rightArrow", 55}, + {"graveAccentAndTilde", 64}, + {"`", 64}, + {"1", 65}, + {"2", 66}, + {"3", 67}, + {"4", 68}, + {"5", 69}, + {"6", 70}, + {"tab", 71}, + {"q", 72}, + {"w", 73}, + {"e", 74 }, + {"r", 75}, + {"t", 76}, + {"capsLock", 77}, + {"leftMouse", 77}, + {"a", 78}, + {"s", 79}, + {"d", 80 }, + {"f", 81}, + {"g", 82}, + {"leftShift", 83}, + {"isoKey", 84}, + {"z", 85}, + {"x", 86}, + {"c", 87}, + {"v", 88}, + {"b", 89}, + {"leftCtrl", 90}, + {"leftSuper", 91}, + {"leftAlt", 92}, + {"leftFn", 93}, + {"leftMod", 94}, + {"leftSpace", 95}, + {"leftFn2", 96}, + {"escape", 97}, + {"f1", 98}, + {"f2", 99}, + {"f3", 100}, + {"f4", 101}, + {"f5", 102}, + {"f6", 103}, {"leftModule.key1", 128}, {"leftModule.key2", 129}, {"leftModule.key3", 130}, {"leftModule.leftButton", 131}, {"leftModule.middleButton", 132}, {"leftModule.rightButton", 133}, - {"leftMouse", 78}, - {"leftShift", 85}, - {"leftSpace", 96}, - {"leftSuper", 93}, - {"m", 23}, - {"minusAndUnderscore", 4}, - {"n", 22}, - {"next", 52}, - {"o", 9}, - {"openingBracketAndOpeningBrace", 11}, - {"p", 10}, - {"pageDown", 49}, - {"pageUp", 47}, - {"pause", 45}, - {"previous", 50}, - {"print", 41}, - {"q", 72}, - {"r", 75}, - {"rightAlt", 32}, - {"rightArrow", 55}, - {"rightCtrl", 34}, - {"rightFn", 31}, - {"rightFn2", 56}, - {"rightMod", 30}, {"rightModule.leftButton", 192}, {"rightModule.rightButton", 193}, - {"rightShift", 27}, - {"rightSpace", 29}, - {"rightSuper", 33}, - {"s", 80}, - {"scrollLock", 44}, - {"semicolonAndColon", 18}, - {"slashAndQuestionMark", 26}, - {"t", 77}, - {"tab", 71}, - {"u", 7}, - {"upArrow", 51}, - {"v", 90}, - {"w", 73}, - {"x", 88}, - {"y", 14}, - {"z", 87}, - {"|", 13}, + {"", 255}, }; static size_t lookup_size = sizeof(lookup_table)/sizeof(lookup_table[0]); diff --git a/right/src/main.c b/right/src/main.c index c3d380296..e29efa71e 100644 --- a/right/src/main.c +++ b/right/src/main.c @@ -1,3 +1,4 @@ +#include "config_parser/parse_config.h" #include "keymap.h" #include "slave_drivers/is31fl3xxx_driver.h" #include "slave_drivers/uhk_module_driver.h" @@ -27,6 +28,7 @@ #include "config_parser/config_globals.h" #include "user_logic.h" #include "usb_descriptors/usb_descriptor_strings.h" +#include "layouts/key_layout_60_to_universal.h" static bool IsEepromInitialized = false; static bool IsConfigInitialized = false; @@ -88,8 +90,17 @@ void CopyRightKeystateMatrix(void) ++MatrixScanCounter; bool stateChanged = false; for (uint8_t keyId = 0; keyId < RIGHT_KEY_MATRIX_KEY_COUNT; keyId++) { - if (KeyStates[SlotId_RightKeyboardHalf][keyId].hardwareSwitchState != RightKeyMatrix.keyStates[keyId]) { - KeyStates[SlotId_RightKeyboardHalf][keyId].hardwareSwitchState = RightKeyMatrix.keyStates[keyId]; + uint8_t targetKeyId; + + // TODO: optimize this? This translation is quite costly :-/ + if (DataModelMajorVersion >= 8) { + targetKeyId = KeyLayout_Uhk60_to_Universal[SlotId_RightKeyboardHalf][keyId]; + } else { + targetKeyId = keyId; + } + + if (KeyStates[SlotId_RightKeyboardHalf][targetKeyId].hardwareSwitchState != RightKeyMatrix.keyStates[keyId]) { + KeyStates[SlotId_RightKeyboardHalf][targetKeyId].hardwareSwitchState = RightKeyMatrix.keyStates[keyId]; stateChanged = true; } } diff --git a/right/src/slave_drivers/uhk_module_driver.c b/right/src/slave_drivers/uhk_module_driver.c index ffb289a1c..a1c8405eb 100644 --- a/right/src/slave_drivers/uhk_module_driver.c +++ b/right/src/slave_drivers/uhk_module_driver.c @@ -25,6 +25,7 @@ #include "debug.h" #include "macros/core.h" #include "versioning.h" +#include "layouts/key_layout_60_to_universal.h" uhk_module_state_t UhkModuleStates[UHK_MODULE_MAX_SLOT_COUNT]; module_connection_state_t ModuleConnectionStates[UHK_MODULE_MAX_SLOT_COUNT]; @@ -129,8 +130,17 @@ void UhkModuleSlaveDriver_ProcessKeystates(uint8_t uhkModuleDriverId, uhk_module bool stateChanged = false; bool nonzeroDeltas = false; for (uint8_t keyId=0; keyId < uhkModuleState->keyCount; keyId++) { - if (KeyStates[slotId][keyId].hardwareSwitchState != keyStatesBuffer[keyId]) { - KeyStates[slotId][keyId].hardwareSwitchState = keyStatesBuffer[keyId]; + uint8_t targetKeyId; + + // TODO: optimize this? This translation is quite costly :-/ + if (DataModelMajorVersion >= 8 && uhkModuleDriverId == UhkModuleDriverId_LeftKeyboardHalf) { + targetKeyId = KeyLayout_Uhk60_to_Universal[SlotId_LeftKeyboardHalf][keyId]; + } else { + targetKeyId = keyId; + } + + if (KeyStates[slotId][targetKeyId].hardwareSwitchState != keyStatesBuffer[targetKeyId]) { + KeyStates[slotId][targetKeyId].hardwareSwitchState = keyStatesBuffer[targetKeyId]; stateChanged = true; } } From 14137dfec074a4f0ea623bc682f80994867ab373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Tu=C4=8Dek?= Date: Tue, 15 Oct 2024 12:51:57 +0200 Subject: [PATCH 2/5] Fix UHK60 build. --- right/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/right/src/main.c b/right/src/main.c index fd4754e0c..92ef55b05 100644 --- a/right/src/main.c +++ b/right/src/main.c @@ -94,7 +94,7 @@ void CopyRightKeystateMatrix(void) uint8_t targetKeyId; // TODO: optimize this? This translation is quite costly :-/ - if (DataModelMajorVersion >= 8) { + if (DataModelVersion.major >= 8) { targetKeyId = KeyLayout_Uhk60_to_Universal[SlotId_RightKeyboardHalf][keyId]; } else { targetKeyId = keyId; From 1a40bbdf9d19cb617775b2b395bacb1cfade2c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Tu=C4=8Dek?= Date: Tue, 15 Oct 2024 13:48:59 +0200 Subject: [PATCH 3/5] Sort the keyid table again. --- right/src/macros/keyid_parser.c | 178 ++++++++++++++++---------------- 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/right/src/macros/keyid_parser.c b/right/src/macros/keyid_parser.c index ed5599afe..e038b6874 100644 --- a/right/src/macros/keyid_parser.c +++ b/right/src/macros/keyid_parser.c @@ -14,122 +14,122 @@ typedef struct { static const lookup_record_t lookup_table[] = { // ALWAYS keep the array sorted by `LC_ALL=C sort` - {"7", 0}, - {"8", 1}, - {"9", 2}, - {"0", 3}, - {"-", 4}, - {"minusAndUnderscore", 4}, - {"=", 5}, - {"equalAndPlus", 5}, - {"backspace", 6}, - {"y", 7}, - {"u", 8}, - {"i", 9}, - {"o", 10}, - {"p", 11}, - {"[", 12}, - {"openingBracketAndOpeningBrace", 12}, - {"]", 13}, - {"closingBracketAndClosingBrace", 13}, - {"|", 14}, - {"h", 15}, - {"j", 16}, - {"k", 17}, - {"l", 18}, - {";", 19}, - {"semicolonAndColon", 19}, + {"", 255}, {"'", 20}, - {"apostropheAndQuote", 20}, - {"enter", 21}, - {"n", 22}, - {"m", 23}, {",", 24}, - {"commaAndLessThanSign", 24}, + {"-", 4}, {".", 25}, - {"dotAndGreaterThanSign", 25}, {"/", 26}, - {"slashAndQuestionMark", 26}, - {"rightShift", 27}, - {"rightSpace", 28}, - {"rightFn", 29}, - {"rightAlt", 30}, - {"rightSuper", 31}, - {"rightCtrl", 32}, - {"rightMod", 33}, - {"rightFn2", 34}, - {"f7", 35}, - {"f8", 36}, - {"f9", 37}, - {"f10", 38}, - {"f11", 39}, - {"f12", 40}, - {"print", 41}, - {"delete", 42}, - {"insert", 43}, - {"scrollLock", 44}, - {"pause", 45}, - {"home", 46}, - {"pageUp", 47}, - {"end", 48}, - {"pageDown", 49}, - {"previous", 50}, - {"upArrow", 51}, - {"next", 52}, - {"leftArrow", 53}, - {"downArrow", 54}, - {"rightArrow", 55}, - {"graveAccentAndTilde", 64}, - {"`", 64}, + {"0", 3}, {"1", 65}, {"2", 66}, {"3", 67}, {"4", 68}, {"5", 69}, {"6", 70}, - {"tab", 71}, - {"q", 72}, - {"w", 73}, - {"e", 74 }, - {"r", 75}, - {"t", 76}, - {"capsLock", 77}, - {"leftMouse", 77}, + {"7", 0}, + {"8", 1}, + {"9", 2}, + {";", 19}, + {"=", 5}, + {"[", 12}, + {"]", 13}, + {"`", 64}, {"a", 78}, - {"s", 79}, - {"d", 80 }, - {"f", 81}, - {"g", 82}, - {"leftShift", 83}, - {"isoKey", 84}, - {"z", 85}, - {"x", 86}, - {"c", 87}, - {"v", 88}, + {"apostropheAndQuote", 20}, {"b", 89}, - {"leftCtrl", 90}, - {"leftSuper", 91}, - {"leftAlt", 92}, - {"leftFn", 93}, - {"leftMod", 94}, - {"leftSpace", 95}, - {"leftFn2", 96}, + {"backspace", 6}, + {"c", 87}, + {"capsLock", 77}, + {"closingBracketAndClosingBrace", 13}, + {"commaAndLessThanSign", 24}, + {"d", 80 }, + {"delete", 42}, + {"dotAndGreaterThanSign", 25}, + {"downArrow", 54}, + {"e", 74 }, + {"end", 48}, + {"enter", 21}, + {"equalAndPlus", 5}, {"escape", 97}, + {"f", 81}, {"f1", 98}, + {"f10", 38}, + {"f11", 39}, + {"f12", 40}, {"f2", 99}, {"f3", 100}, {"f4", 101}, {"f5", 102}, {"f6", 103}, + {"f7", 35}, + {"f8", 36}, + {"f9", 37}, + {"g", 82}, + {"graveAccentAndTilde", 64}, + {"h", 15}, + {"home", 46}, + {"i", 9}, + {"insert", 43}, + {"isoKey", 84}, + {"j", 16}, + {"k", 17}, + {"l", 18}, + {"leftAlt", 92}, + {"leftArrow", 53}, + {"leftCtrl", 90}, + {"leftFn", 93}, + {"leftFn2", 96}, + {"leftMod", 94}, {"leftModule.key1", 128}, {"leftModule.key2", 129}, {"leftModule.key3", 130}, {"leftModule.leftButton", 131}, {"leftModule.middleButton", 132}, {"leftModule.rightButton", 133}, + {"leftMouse", 77}, + {"leftShift", 83}, + {"leftSpace", 95}, + {"leftSuper", 91}, + {"m", 23}, + {"minusAndUnderscore", 4}, + {"n", 22}, + {"next", 52}, + {"o", 10}, + {"openingBracketAndOpeningBrace", 12}, + {"p", 11}, + {"pageDown", 49}, + {"pageUp", 47}, + {"pause", 45}, + {"previous", 50}, + {"print", 41}, + {"q", 72}, + {"r", 75}, + {"rightAlt", 30}, + {"rightArrow", 55}, + {"rightCtrl", 32}, + {"rightFn", 29}, + {"rightFn2", 34}, + {"rightMod", 33}, {"rightModule.leftButton", 192}, {"rightModule.rightButton", 193}, - {"", 255}, + {"rightShift", 27}, + {"rightSpace", 28}, + {"rightSuper", 31}, + {"s", 79}, + {"scrollLock", 44}, + {"semicolonAndColon", 19}, + {"slashAndQuestionMark", 26}, + {"t", 76}, + {"tab", 71}, + {"u", 8}, + {"upArrow", 51}, + {"v", 88}, + {"w", 73}, + {"x", 86}, + {"y", 7}, + {"z", 85}, + {"|", 14}, }; static size_t lookup_size = sizeof(lookup_table)/sizeof(lookup_table[0]); From 819708fd9fd46e2a056c8a0ffe9734b5e190e568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Tu=C4=8Dek?= Date: Tue, 15 Oct 2024 15:59:50 +0200 Subject: [PATCH 4/5] Fix things around keyid mappings and leds. --- device/src/state_sync.c | 15 +++++++++++++++ device/src/state_sync.h | 5 +++++ right/src/ledmap.h | 4 ++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/device/src/state_sync.c b/device/src/state_sync.c index 26994d11f..927a20427 100644 --- a/device/src/state_sync.c +++ b/device/src/state_sync.c @@ -123,6 +123,7 @@ static state_sync_prop_t stateSyncProps[StateSyncPropertyId_Count] = { SIMPLE(MergeSensor, SyncDirection_LeftToRight, DirtyState_Clean, &MergeSensor_HalvesAreMerged), SIMPLE(FunctionalColors, SyncDirection_RightToLeft, DirtyState_Clean, &Cfg.KeyActionColors), SIMPLE(PowerMode, SyncDirection_RightToLeft, DirtyState_Clean, &CurrentPowerMode), + CUSTOM(Config, SyncDirection_RightToLeft, DirtyState_Clean), }; static void invalidateProperty(state_sync_prop_id_t propId) { @@ -332,6 +333,12 @@ static void receiveProperty(device_id_t src, state_sync_prop_id_t propId, const EventVector_Set(EventVector_LedMapUpdateNeeded); } break; + case StateSyncPropertyId_Config: + if (!isLocalUpdate) { + sync_command_config_t* buffer = (sync_command_config_t*)data; + DataModelVersion = buffer->dataModelVersion; + } + break; case StateSyncPropertyId_MergeSensor: break; default: @@ -469,6 +476,12 @@ static void prepareData(device_id_t dst, const uint8_t *propDataPtr, state_sync_ submitPreparedData(dst, propId, (const uint8_t *)&buffer, sizeof(buffer)); return; } break; + case StateSyncPropertyId_Config: { + sync_command_config_t buffer; + buffer.dataModelVersion = DataModelVersion; + submitPreparedData(dst, propId, (const uint8_t *)&buffer, sizeof(buffer)); + return; + } break; default: break; } @@ -511,6 +524,7 @@ static void updateProperty(state_sync_prop_id_t propId) { static bool handlePropertyUpdateRightToLeft() { UPDATE_AND_RETURN_IF_DIRTY(StateSyncPropertyId_ResetRightLeftLink); + UPDATE_AND_RETURN_IF_DIRTY(StateSyncPropertyId_Config); if (KeyBacklightBrightness != 0 && Cfg.BacklightingMode != BacklightingMode_ConstantRGB) { // Update relevant data @@ -642,6 +656,7 @@ void StateSync_ResetRightLeftLink(bool bidirectional) { invalidateProperty(StateSyncPropertyId_ResetRightLeftLink); } if (DEVICE_ID == DeviceId_Uhk80_Right) { + invalidateProperty(StateSyncPropertyId_Config); state_sync_prop_id_t first = StateSyncPropertyId_LayerActionFirst; state_sync_prop_id_t last = StateSyncPropertyId_LayerActionLast; for (state_sync_prop_id_t propId = first; propId <= last; propId++) { diff --git a/device/src/state_sync.h b/device/src/state_sync.h index 4d516a17e..cda8280a2 100644 --- a/device/src/state_sync.h +++ b/device/src/state_sync.h @@ -59,6 +59,10 @@ char firmwareChecksum[MD5_CHECKSUM_LENGTH]; } ATTR_PACKED sync_command_module_state_t; + typedef struct { + version_t dataModelVersion; + } sync_command_config_t; + // Draft for generic properties typedef enum { StateSyncPropertyId_LayerActionsLayer1 = 1, @@ -89,6 +93,7 @@ StateSyncPropertyId_MergeSensor, StateSyncPropertyId_FunctionalColors, StateSyncPropertyId_PowerMode, + StateSyncPropertyId_Config, StateSyncPropertyId_Count, } state_sync_prop_id_t; diff --git a/right/src/ledmap.h b/right/src/ledmap.h index ee9cd1eac..a964a355e 100644 --- a/right/src/ledmap.h +++ b/right/src/ledmap.h @@ -30,8 +30,8 @@ } key_action_color_t; typedef enum { - LedMapIndex_LeftSlot_LeftShift = 21, - LedMapIndex_LeftSlot_IsoKey = 22, + LedMapIndex_LeftSlot_LeftShift = 19, + LedMapIndex_LeftSlot_IsoKey = 20, } led_map_index_t; typedef enum { From 39ad8e080c6aff51969909425981ce549b711bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Tu=C4=8Dek?= Date: Fri, 18 Oct 2024 16:40:59 +0200 Subject: [PATCH 5/5] Fix "universal" keyid parsing for uhk60 and bump config version. --- right/src/main.c | 2 +- right/src/slave_drivers/uhk_module_driver.c | 11 ++++++++--- scripts/package.json | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/right/src/main.c b/right/src/main.c index 92ef55b05..d8e6aed63 100644 --- a/right/src/main.c +++ b/right/src/main.c @@ -94,7 +94,7 @@ void CopyRightKeystateMatrix(void) uint8_t targetKeyId; // TODO: optimize this? This translation is quite costly :-/ - if (DataModelVersion.major >= 8) { + if (VERSION_AT_LEAST(DataModelVersion, 8, 2, 0)) { targetKeyId = KeyLayout_Uhk60_to_Universal[SlotId_RightKeyboardHalf][keyId]; } else { targetKeyId = keyId; diff --git a/right/src/slave_drivers/uhk_module_driver.c b/right/src/slave_drivers/uhk_module_driver.c index 311fdb83b..b88c58f54 100644 --- a/right/src/slave_drivers/uhk_module_driver.c +++ b/right/src/slave_drivers/uhk_module_driver.c @@ -1,4 +1,5 @@ #include +#include "config_parser/parse_config.h" #include "i2c_addresses.h" #include "i2c.h" @@ -133,14 +134,18 @@ void UhkModuleSlaveDriver_ProcessKeystates(uint8_t uhkModuleDriverId, uhk_module uint8_t targetKeyId; // TODO: optimize this? This translation is quite costly :-/ - if (DataModelVersion.major >= 8 && uhkModuleDriverId == UhkModuleDriverId_LeftKeyboardHalf) { + if ( + DEVICE_IS_UHK60 + && VERSION_AT_LEAST(DataModelVersion, 8, 2, 0) + && uhkModuleDriverId == UhkModuleDriverId_LeftKeyboardHalf + ) { targetKeyId = KeyLayout_Uhk60_to_Universal[SlotId_LeftKeyboardHalf][keyId]; } else { targetKeyId = keyId; } - if (KeyStates[slotId][targetKeyId].hardwareSwitchState != keyStatesBuffer[targetKeyId]) { - KeyStates[slotId][targetKeyId].hardwareSwitchState = keyStatesBuffer[targetKeyId]; + if (KeyStates[slotId][targetKeyId].hardwareSwitchState != keyStatesBuffer[keyId]) { + KeyStates[slotId][targetKeyId].hardwareSwitchState = keyStatesBuffer[keyId]; stateChanged = true; } } diff --git a/scripts/package.json b/scripts/package.json index 986fda36f..a645ed087 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -22,7 +22,7 @@ "firmwareVersion": "11.2.0", "deviceProtocolVersion": "4.10.0", "moduleProtocolVersion": "4.3.0", - "userConfigVersion": "8.1.0", + "userConfigVersion": "8.2.0", "hardwareConfigVersion": "1.0.0", "smartMacrosVersion": "2.5.0", "devices": [