Skip to content

Commit

Permalink
feat: 'Non-US \' on builtin keyboards
Browse files Browse the repository at this point in the history
'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.
  • Loading branch information
ids1024 committed Jul 13, 2022
1 parent 29da524 commit c0961c3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
18 changes: 11 additions & 7 deletions layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
'MO(2)': 'LAYER_ACCESS_3',
'MO(3)': 'LAYER_ACCESS_4',
}
EC_MAPPING = {
'INT_1': 'NONUS_BACKSLASH',
}
QMK_EXTRA_SCANCODES = [
"TG(0)",
"TG(1)",
Expand Down Expand Up @@ -130,7 +133,7 @@ def extract_scancodes(ecdir: str, board: str, is_qmk: bool, has_brightness: bool
common_keymap_h = open(includes[0]).read()
scancode_defines = re.findall(
'#define.*((?:K_\S+)|(?:KT_FN))', common_keymap_h)
mapping = {}
mapping = EC_MAPPING

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

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

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

code = code.replace('K_', '').replace('KC_', '').replace('KT_', '')

if is_qmk:
code = mapping.get(code, code)
code = mapping.get(code, code)

return code

Expand Down
1 change: 1 addition & 0 deletions layouts/keyboards/system76/14in_83/keymap.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
"NUM_7": 108,
"NUM_8": 117,
"NUM_9": 125,
"NONUS_BACKSLASH": 97,
"NONE": 0
}
1 change: 1 addition & 0 deletions layouts/keyboards/system76/14in_86/keymap.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
"NUM_7": 108,
"NUM_8": 117,
"NUM_9": 125,
"NONUS_BACKSLASH": 97,
"NONE": 0
}
1 change: 1 addition & 0 deletions layouts/keyboards/system76/15in_102/keymap.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
"NUM_7": 108,
"NUM_8": 117,
"NUM_9": 125,
"NONUS_BACKSLASH": 97,
"NONE": 0
}
1 change: 1 addition & 0 deletions layouts/keyboards/system76/15in_102_nkey/keymap.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
"NUM_7": 108,
"NUM_8": 117,
"NUM_9": 125,
"NONUS_BACKSLASH": 97,
"NONE": 0
}
2 changes: 1 addition & 1 deletion layouts/system76/gaze15/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"has_color": true,
"pressed_color": "#dfdfdf",
"keyboard": "system76/15in_102"
}
}

0 comments on commit c0961c3

Please sign in to comment.