Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Migrate to new keyid mappings.
Browse files Browse the repository at this point in the history
  • Loading branch information
kareltucek committed Sep 21, 2024
1 parent a005fca commit a12734f
Show file tree
Hide file tree
Showing 18 changed files with 473 additions and 159 deletions.
11 changes: 9 additions & 2 deletions device/src/keyboard/key_scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down Expand Up @@ -115,7 +116,13 @@ static void scanKeys() {
for (uint8_t rowId=0; rowId<KEY_MATRIX_ROWS; rowId++) {
for (uint8_t colId=0; colId<KEY_MATRIX_COLS; colId++) {
uint8_t sourceIndex = rowId*KEY_MATRIX_COLS + colId;
uint8_t targetKeyId = KeyLayout_Uhk80_to_Uhk60[slotId][sourceIndex];
uint8_t targetKeyId;

if (DataModelMajorVersion >= 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) {
Expand Down
1 change: 1 addition & 0 deletions device/src/legacy/layouts/key_layout.c
1 change: 1 addition & 0 deletions device/src/legacy/layouts/key_layout.h
1 change: 1 addition & 0 deletions device/src/legacy/layouts/key_layout_60_to_universal.c
1 change: 1 addition & 0 deletions device/src/legacy/layouts/key_layout_60_to_universal.h
1 change: 1 addition & 0 deletions device/src/legacy/layouts/key_layout_80_to_universal.c
1 change: 1 addition & 0 deletions device/src/legacy/layouts/key_layout_80_to_universal.h
46 changes: 17 additions & 29 deletions right/src/keymap.c

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -159,3 +160,4 @@ const uint8_t KeyLayout_Uhk80_to_Uhk60[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] = {
{},
{},
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
99 changes: 99 additions & 0 deletions right/src/layouts/key_layout_60_to_universal.c
Original file line number Diff line number Diff line change
@@ -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,
},
{},
{},
};
19 changes: 19 additions & 0 deletions right/src/layouts/key_layout_60_to_universal.h
Original file line number Diff line number Diff line change
@@ -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__

153 changes: 153 additions & 0 deletions right/src/layouts/key_layout_80_to_universal.c
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions right/src/layouts/key_layout_80_to_universal.h
Original file line number Diff line number Diff line change
@@ -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__

Loading

0 comments on commit a12734f

Please sign in to comment.