Skip to content

Commit b751d1f

Browse files
committed
feat: 'Non-US \' on builtin keyboards
'Non-US #' is not listed, since the PS/2 keycode for that is the same as 'Backlash'. The UI around non-US layouts could be improved, but that's already an issue and this at least makes it possible to set this mapping. This does not add the `PAUSE` and `SCROLL_LOCK` keycodes that have been added to EC. At least with `PAUSE`, this is complicated since it won't work on older firmware, and we should probably test for that (#140). Fixes #127.
1 parent 29da524 commit b751d1f

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

layouts.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
'MO(2)': 'LAYER_ACCESS_3',
8181
'MO(3)': 'LAYER_ACCESS_4',
8282
}
83+
EC_MAPPING = {
84+
'INT_1': 'NONUS_BSLASH',
85+
}
8386
QMK_EXTRA_SCANCODES = [
8487
"TG(0)",
8588
"TG(1)",
@@ -130,7 +133,7 @@ def extract_scancodes(ecdir: str, board: str, is_qmk: bool, has_brightness: bool
130133
common_keymap_h = open(includes[0]).read()
131134
scancode_defines = re.findall(
132135
'#define.*((?:K_\S+)|(?:KT_FN))', common_keymap_h)
133-
mapping = {}
136+
mapping = EC_MAPPING
134137

135138
tmpdir = tempfile.mkdtemp()
136139
with open(f'{tmpdir}/keysym-extract.c', 'w') as f:
@@ -157,8 +160,7 @@ def extract_scancodes(ecdir: str, board: str, is_qmk: bool, has_brightness: bool
157160
for name in scancode_defines:
158161
if '_' in name and name.split('_')[0] != 'RGB':
159162
name = name.split('_', 1)[1]
160-
if is_qmk:
161-
name = mapping.get(name, name)
163+
name = mapping.get(name, name)
162164
scancode_names.append(name)
163165
scancode_list = OrderedDict(zip(scancode_names, scancodes))
164166

@@ -167,7 +169,11 @@ def extract_scancodes(ecdir: str, board: str, is_qmk: bool, has_brightness: bool
167169
else:
168170
scancode_list['NONE'] = 0x0000
169171

170-
excluded_scancodes = ['INT_1', 'INT_2']
172+
# INT_2 has same PS/2 scancode as BACKSLASH
173+
excluded_scancodes = ['INT_2']
174+
# Need new firmware to support; omit for now
175+
if not is_qmk:
176+
excluded_scancodes += ['SCROLL_LOCK', 'PAUSE']
171177
if has_color or board == 'system76/bonw14':
172178
excluded_scancodes += ['KBD_BKL']
173179
elif has_brightness:
@@ -223,9 +229,7 @@ def scancode_map(x: int, code: str) -> str:
223229
return 'NONE'
224230

225231
code = code.replace('K_', '').replace('KC_', '').replace('KT_', '')
226-
227-
if is_qmk:
228-
code = mapping.get(code, code)
232+
code = mapping.get(code, code)
229233

230234
return code
231235

layouts/keyboards/system76/14in_83/keymap.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,6 @@
121121
"NUM_7": 108,
122122
"NUM_8": 117,
123123
"NUM_9": 125,
124+
"NONUS_BSLASH": 97,
124125
"NONE": 0
125126
}

layouts/keyboards/system76/14in_86/keymap.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,6 @@
121121
"NUM_7": 108,
122122
"NUM_8": 117,
123123
"NUM_9": 125,
124+
"NONUS_BSLASH": 97,
124125
"NONE": 0
125126
}

layouts/keyboards/system76/15in_102/keymap.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,6 @@
121121
"NUM_7": 108,
122122
"NUM_8": 117,
123123
"NUM_9": 125,
124+
"NONUS_BSLASH": 97,
124125
"NONE": 0
125126
}

layouts/keyboards/system76/15in_102_nkey/keymap.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,6 @@
121121
"NUM_7": 108,
122122
"NUM_8": 117,
123123
"NUM_9": 125,
124+
"NONUS_BSLASH": 97,
124125
"NONE": 0
125126
}

layouts/system76/gaze15/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
"has_color": true,
55
"pressed_color": "#dfdfdf",
66
"keyboard": "system76/15in_102"
7-
}
7+
}

0 commit comments

Comments
 (0)