Skip to content
Draft
12 changes: 4 additions & 8 deletions kalamine/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@ def file_creation_context(ext: str = "") -> Iterator[Path]:

# Linux driver, user-space
with file_creation_context(".xkb_keymap") as xkb_path:
with xkb_path.open("w", encoding="utf-8", newline="\n") as file:
file.write(xkb.xkb_keymap(layout))
xkb.xkb_write_files(xkb_path, xkb.xkb_keymap(layout))

# Linux driver, root
with file_creation_context(".xkb_symbols") as xkb_custom_path:
with xkb_custom_path.open("w", encoding="utf-8", newline="\n") as file:
file.write(xkb.xkb_symbols(layout))
xkb.xkb_write_files(xkb_custom_path, xkb.xkb_symbols(layout))

# JSON data
with file_creation_context(".json") as json_path:
Expand Down Expand Up @@ -141,12 +139,10 @@ def build(
file.write(keylayout.keylayout(layout))

elif output_file.suffix == ".xkb_keymap":
with output_file.open("w", encoding="utf-8", newline="\n") as file:
file.write(xkb.xkb_keymap(layout))
xkb.xkb_write_files(output_file, xkb.xkb_keymap(layout))

elif output_file.suffix == ".xkb_symbols":
with output_file.open("w", encoding="utf-8", newline="\n") as file:
file.write(xkb.xkb_symbols(layout))
xkb.xkb_write_files(output_file, xkb.xkb_symbols(layout))

elif output_file.suffix == ".json":
output_file.write_text(web.pretty_json(layout), encoding="utf8")
Expand Down
2 changes: 1 addition & 1 deletion kalamine/data/dead_keys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

- char: '*‟' # there’s no “double grave accent” Unicode character :(
name: doublegrave
base: AaEeIiOoRrUuѴѴ
base: AaEeIiOoRrUuѴѵ
alt: ȀȁȄȅȈȉȌȍȐȑȔȕѶѷ
alt_space: '‟' # U+201F HIGH REVERSED-9 QUOTATION MARK
alt_self: '‟' # U+201F HIGH REVERSED-9 QUOTATION MARK
Expand Down
41 changes: 41 additions & 0 deletions kalamine/data/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,44 @@ ERGO:
keys: [ ac01, ac02, ac03, ac04, ac05, ac06, ac07, ac08, ac09, ac10, ac11, bksl ]
- offset: 2
keys: [ lsgt, ab01, ab02, ab03, ab04, ab05, ab06, ab07, ab08, ab09, ab10 ]

TYPEMATRIX:
template: |
╭╌╌╌╌╌┰─────┬─────┬─────┬─────┬─────┰─────┰─────┬─────┬─────┬─────┬─────┰╌╌╌╌╌┬╌╌╌╌╌┬╌╌╌╌╌╮
┆ ⎋ ┆ ┆ ┆ ┆ ┆ ┆ ⌦ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ Num ┆
┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆
├╌╌╌╌╌╁─────┼─────┼─────┼─────┼─────╁─────╁─────┼─────┼─────┼─────┼─────╁╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
┆ ┃ │ │ │ │ ┃ ⌫ ┃ │ │ │ │ ┃ ┆ ┆ ┆
┆ ┃ 1 │ 2 │ 3 │ 4 │ 5 ┃ ┃ 6 │ 7 │ 8 │ 9 │ 0 ┃ ┆ ┆ ┆
├╌╌╌╌╌╂─────┼─────┼─────┼─────┼─────┨ ┠─────┼─────┼─────┼─────┼─────╂╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
┆ ↹ ┃ │ │ │ │ ┃ ┃ │ │ │ │ ┃ ┆ ┆ ┆
┆ ┃ │ │ │ │ ┃ ┃ │ │ │ │ ┃ ┆ ┆ ┆
├╌╌╌╌╌╂─────┼─────┼─────┼─────┼─────╂─────╂─────┼─────┼─────┼─────┼─────╂╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
┆ ⇧ ┃ │ │ │ │ ┃ ⏎ ┃ │ │ │ │ ┃ ┆ ⇧ ┆ ⇬ ┆
┆ ┃ │ │ │ │ ┃ ┃ │ │ │ │ ┃ ┆ ┆ ┆
┆ ┠─────┼─────┼─────┼─────┼─────┨ ┠─────┼─────┼─────┼─────┼─────╂╌╌╌╌╌┤ ├╌╌╌╌╌┤
┆ ┃ │ │ │ │ ┃ ┃ │ │ │ │ ┃ ┆ ┆ ┆
┆ ┃ │ │ │ │ ┃ ┃ │ │ │ │ ┃ ┆ ┆ ┆
├╌╌╌╌╌╀─────┼─────┼─────┼─────┴─────┸─────┸─────┴─────┼─────┼─────┼─────╀╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
┆ ⎈ ┆ ┆ ≣ ┆ ┆ ␣ ┆ ┆ ⇱ ┆ ⬆ ┆ ⇲ ┆ ⎈ ┆ ⎗ ┆
┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆
├╌╌╌╌╌┼╌╌╌╌╌┴╌╌┬╌╌┴╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤ ├╌╌╌╌╌┤
┆ Fn ┆ ◆ ┆ ⎇ ┆ ┆ ⎇ ┆ ⬅ ┆ ⬇ ┆ ➡ ┆ ┆ ⎘ ┆
┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆
╰╌╌╌╌╌┴╌╌╌╌╌╌╌╌┴╌╌╌╌╌╌╌╌╯ ╰╌╌╌╌╌┴╌╌╌╌╌┴╌╌╌╌╌┴╌╌╌╌╌┴╌╌╌╌╌╯╌╌╌╌╌╯
digits_row: 1
rows:
- offset: 2
keys: [ esc, fk01, fk02, fk03, fk04, fk05, dele, fk06, fk07, fk08, fk09, fk10, fk11, fk12 ]
- offset: 2
keys: [ tlde, ae01, ae02, ae03, ae04, ae05, bksp, ae06, ae07, ae08, ae09, ae10, ae11, ae12, i148 ]
- offset: 2
keys: [ tab, ad01, ad02, ad03, ad04, ad05, xxxx, ad06, ad07, ad08, ad09, ad10, ad11, ad12, i163 ]
- offset: 2
keys: [ lfsh, ac01, ac02, ac03, ac04, ac05, rtrn, ac06, ac07, ac08, ac09, ac10, ac11, rtsh, caps ]
- offset: 2
keys: [ xxxx, ab01, ab02, ab03, ab04, ab05, xxxx, ab06, ab07, ab08, ab09, ab10, bksl, xxxx, i180 ]
- offset: 2
keys: [ lctl, lsgt, menu, muhe, spce, xxxx, spce, xxxx, spce, henk, home, up, end, rctl, pgup ]
- offset: 8
keys: [ lwin, xxxx, lalt, xxxx, xxxx, xxxx, xxxx, xxxx, ralt, left, down, rght, xxxx, pgdn ]
169 changes: 119 additions & 50 deletions kalamine/data/qwerty_vk.yaml
Original file line number Diff line number Diff line change
@@ -1,61 +1,130 @@
# Scancodes <-> Virtual Keys as in qwerty
# this is to keep shortcuts at their qwerty location
'39': 'SPACE'
'T39': 'SPACE'

# digits
'02': '1'
'03': '2'
'04': '3'
'05': '4'
'06': '5'
'07': '6'
'08': '7'
'09': '8'
'0a': '9'
'0b': '0'
'T02': '1'
'T03': '2'
'T04': '3'
'T05': '4'
'T06': '5'
'T07': '6'
'T08': '7'
'T09': '8'
'T0A': '9'
'T0B': '0'

# letters, first row
'10': 'Q'
'11': 'W'
'12': 'E'
'13': 'R'
'14': 'T'
'15': 'Y'
'16': 'U'
'17': 'I'
'18': 'O'
'19': 'P'
'T10': 'Q'
'T11': 'W'
'T12': 'E'
'T13': 'R'
'T14': 'T'
'T15': 'Y'
'T16': 'U'
'T17': 'I'
'T18': 'O'
'T19': 'P'

# letters, second row
'1e': 'A'
'1f': 'S'
'20': 'D'
'21': 'F'
'22': 'G'
'23': 'H'
'24': 'J'
'25': 'K'
'26': 'L'
'27': 'OEM_1'
'T1E': 'A'
'T1F': 'S'
'T20': 'D'
'T21': 'F'
'T22': 'G'
'T23': 'H'
'T24': 'J'
'T25': 'K'
'T26': 'L'
'T27': 'OEM_1'

# letters, third row
'2c': 'Z'
'2d': 'X'
'2e': 'C'
'2f': 'V'
'30': 'B'
'31': 'N'
'32': 'M'
'33': 'OEM_COMMA'
'34': 'OEM_PERIOD'
'35': 'OEM_2'
'T2C': 'Z'
'T2D': 'X'
'T2E': 'C'
'T2F': 'V'
'T30': 'B'
'T31': 'N'
'T32': 'M'
'T33': 'OEM_COMMA'
'T34': 'OEM_PERIOD'
'T35': 'OEM_2'

# pinky keys
'29': 'OEM_3'
'0c': 'OEM_MINUS'
'0d': 'OEM_PLUS'
'1a': 'OEM_4'
'1b': 'OEM_6'
'28': 'OEM_7'
'2b': 'OEM_5'
'56': 'OEM_102'
'T29': 'OEM_3'
'T0C': 'OEM_MINUS'
'T0D': 'OEM_PLUS'
'T1A': 'OEM_4'
'T1B': 'OEM_6'
'T28': 'OEM_7'
'T2B': 'OEM_5'
'T56': 'OEM_102'

# Numpad
'T52': 'NUMPAD0'
'T4F': 'NUMPAD1'
'T50': 'NUMPAD2'
'T51': 'NUMPAD3'
'T4B': 'NUMPAD4'
'T4C': 'NUMPAD5'
'T4D': 'NUMPAD6'
'T47': 'NUMPAD7'
'T48': 'NUMPAD8'
'T49': 'NUMPAD9'
'T37': 'MULTIPLY'
'T4E': 'ADD'
'T4A': 'SUBTRACT'
'X35': 'DIVIDE'
'T53': 'DECIMAL'
# 'X1C': '' # NumpadEnter (maps to Return)
# 'T59': 'VK_CLEAR' # NumpadEqual (VK not mappable)
'T7E': 'VK_ABNT_C2' # NumadComma
# 'T45': 'NUMLOCK' # (VK not mappable)

# System
'T0F': 'TAB'
'T1C': 'RETURN'
'T0E': 'BACK' # Backspace
# 'X52': 'INSERT' # (VK not mappable)
# 'X53': 'DELETE' # (VK not mappable)
# 'T3B': 'F1' # (VK not mappable)
# 'T3C': 'F2' # (VK not mappable)
# 'T3D': 'F3' # (VK not mappable)
# 'T3E': 'F4' # (VK not mappable)
# 'T3F': 'F5' # (VK not mappable)
# 'T40': 'F6' # (VK not mappable)
# 'T41': 'F7' # (VK not mappable)
# 'T42': 'F8' # (VK not mappable)
# 'T43': 'F9' # (VK not mappable)
# 'T44': 'F10' # (VK not mappable)
# 'T57': 'F11' # (VK not mappable)
# 'T58': 'F12' # (VK not mappable)
# 'X47': 'HOME' # (VK not mappable)
# 'X4F': 'END' # (VK not mappable)
# 'X49': 'PRIOR' # PageUp (VK not mappable)
# 'X51': 'NEXT' # PageDown (VK not mappable)
# 'T01': 'ESCAPE' # (VK not mappable)
# 'X48': 'UP' # (VK not mappable)
# 'X50': 'DOWN' # (VK not mappable)
# 'X4B': 'LEFT' # (VK not mappable)
# 'X4D': 'RIGHT' # (VK not mappable)
# 'X5D': 'APPS' # ContextMenu (VK not mappable)

# Modifiers
# 'T2A': 'LSHIFT' # ShiftLeft (VK not mappable)
# 'T36': 'RSHIFT' # ShiftRight (VK not mappable)
# 'T3A': 'CAPITAL' # CapsLock (VK not mappable)
# 'T1D': 'LCONTROL' # ControlLeft (VK not mappable)
# 'X1D': 'RCONTROL' # ControlRight (VK not mappable)
# 'T38': 'LMENU' # AltLeft (VK not mappable)
# 'X38': 'RMENU' # AltRight (VK not mappable)
# 'X5B': 'LWIN' # MetaLeft (VK not mappable)
# 'X5C': 'RWIN' # MetaRight (VK not mappable)

# Input method
# 'T7B': 'NONCONVERT' # Muhenkan (VK not mappable)
# 'T79': 'CONVERT' # Henkan (VK not mappable)

# Miscellaneous
# 'X22': 'MEDIA_PLAY_PAUSE' # (VK not mappable)
# 'X32': 'BROWSER_HOME' # (VK not mappable)
Loading