Skip to content

Commit

Permalink
Merge branch 'vial-kb:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jkutianski authored Dec 13, 2022
2 parents 4946688 + 59bb6c8 commit 5d1a7a2
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 21 deletions.
19 changes: 10 additions & 9 deletions src/main/python/editor/macro_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ def __init__(self):
self.recording_append = False

self.tabs = TabWidgetWithKeycodes()
for x in range(32):
tab = MacroTab(self, self.recorder is not None)
tab.changed.connect(self.on_change)
tab.record.connect(self.on_record)
tab.record_stop.connect(self.on_tab_stop)
self.macro_tabs.append(tab)
w = QWidget()
w.setLayout(tab)
self.macro_tab_w.append(w)

self.lbl_memory = QLabel()

Expand All @@ -81,6 +72,16 @@ def rebuild(self, device):
return
self.keyboard = self.device.keyboard

for x in range(self.keyboard.macro_count - len(self.macro_tab_w)):
tab = MacroTab(self, self.recorder is not None)
tab.changed.connect(self.on_change)
tab.record.connect(self.on_record)
tab.record_stop.connect(self.on_tab_stop)
self.macro_tabs.append(tab)
w = QWidget()
w.setLayout(tab)
self.macro_tab_w.append(w)

# only show the number of macro editors that keyboard supports
while self.tabs.count() > 0:
self.tabs.removeTab(0)
Expand Down
13 changes: 9 additions & 4 deletions src/main/python/keycodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,11 @@ def LT(layer):
RESET_KEYCODE = 0x5C00


KEYCODES_QUANTUM = [
K(RESET_KEYCODE, "RESET", "Reset", "Reboot to bootloader"),
KEYCODES_BOOT = [
K(RESET_KEYCODE, "RESET", "Reset", "Reboot to bootloader")
]

KEYCODES_MODIFIERS = [
K(QK_ONE_SHOT_MOD | MOD_LSFT, "OSM(MOD_LSFT)", "OSM\nLSft", "Enable Left Shift for one keypress"),
K(QK_ONE_SHOT_MOD | MOD_LCTL, "OSM(MOD_LCTL)", "OSM\nLCtl", "Enable Left Control for one keypress"),
K(QK_ONE_SHOT_MOD | MOD_LALT, "OSM(MOD_LALT)", "OSM\nLAlt", "Enable Left Alt for one keypress"),
Expand Down Expand Up @@ -402,7 +405,9 @@ def LT(layer):
K(0x5CF5, "KC_LAPO", "LA\n(", "Left Alt when held, ( when tapped"),
K(0x5CF6, "KC_RAPC", "RA\n)", "Right Alt when held, ) when tapped"),
K(0x5CD9, "KC_SFTENT", "RS\nEnter", "Right Shift when held, Enter when tapped"),
]

KEYCODES_QUANTUM = [
K(23554, "MAGIC_SWAP_CONTROL_CAPSLOCK", "Swap\nCtrl\nCaps", "Swap Caps Lock and Left Control", alias=["CL_SWAP"]),
K(23563, "MAGIC_UNSWAP_CONTROL_CAPSLOCK", "Unswap\nCtrl\nCaps", "Unswap Caps Lock and Left Control",
alias=["CL_NORM"]),
Expand Down Expand Up @@ -774,8 +779,8 @@ def recreate_keycodes():

KEYCODES.clear()
KEYCODES.extend(KEYCODES_SPECIAL + KEYCODES_BASIC + KEYCODES_SHIFTED + KEYCODES_ISO + KEYCODES_LAYERS +
KEYCODES_QUANTUM + KEYCODES_BACKLIGHT + KEYCODES_MEDIA + KEYCODES_TAP_DANCE + KEYCODES_MACRO +
KEYCODES_USER + KEYCODES_HIDDEN + KEYCODES_MIDI)
KEYCODES_BOOT + KEYCODES_MODIFIERS + KEYCODES_QUANTUM + KEYCODES_BACKLIGHT + KEYCODES_MEDIA +
KEYCODES_TAP_DANCE + KEYCODES_MACRO + KEYCODES_USER + KEYCODES_HIDDEN + KEYCODES_MIDI)
KEYCODES_MAP.clear()
for keycode in KEYCODES:
KEYCODES_MAP[keycode.code] = keycode
Expand Down
25 changes: 25 additions & 0 deletions src/main/python/keymap/swedish_swerty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# coding: utf-8

keymap = {
"KC_GRAVE": "~ ½\n` §",
"KC_2": '@\n2 "',
"KC_3": "#\n3 £",
"KC_4": "$\n4 ¤",
"KC_5": "%\n5 €",
"KC_6": "^\n6 ^",
"KC_7": "&\n7 {",
"KC_8": "*\n8 [",
"KC_9": "(\n9 ]",
"KC_0": ")\n0 }",
"KC_MINUS": "_ ^\n- ¨",
"KC_EQUAL": "+\n= ~",
"KC_E": "E\n €",
"KC_O": "O\n {",
"KC_P": "P\n }",
"KC_LBRACKET": "Å {\n [",
"KC_RBRACKET": "´ }\n` ]",
"KC_SCOLON": "Ö :\n ;",
"KC_QUOTE": 'Ä "\n \'',
"KC_M": "M\n µ",
"KC_DOT": ">\n. :"
}
3 changes: 2 additions & 1 deletion src/main/python/keymaps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from keycodes import Keycode
from keymap import danish, eurkey, french, german, hebrew, hungarian, latam, norwegian, russian, slovak, spanish, swedish, swiss
from keymap import danish, eurkey, french, german, hebrew, hungarian, latam, norwegian, russian, slovak, spanish, swedish, swedish_swerty, swiss

KEYMAPS = [
("QWERTY", dict()),
Expand All @@ -15,6 +15,7 @@
("Slovak (QWERTY)", slovak.keymap),
("Spanish (QWERTY)", spanish.keymap),
("Swedish (QWERTY)", swedish.keymap),
("Swedish (SWERTY)", swedish_swerty.keymap),
("Swiss (QWERTZ)", swiss.keymap)
]

Expand Down
11 changes: 6 additions & 5 deletions src/main/python/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from tabbed_keycodes import TabbedKeycodes
from editor.tap_dance import TapDance
from unlocker import Unlocker
from util import tr, EXAMPLE_KEYBOARDS, KeycodeDisplay
from util import tr, EXAMPLE_KEYBOARDS, KeycodeDisplay, EXAMPLE_KEYBOARD_PREFIX
from vial_device import VialKeyboard
from editor.matrix_test import MatrixTest

Expand Down Expand Up @@ -279,10 +279,11 @@ def on_device_selected(self):
QMessageBox.warning(self, "", "Unsupported protocol version!\n"
"Please download latest Vial from https://get.vial.today/")

if isinstance(self.autorefresh.current_device, VialKeyboard) \
and self.autorefresh.current_device.keyboard.keyboard_id in EXAMPLE_KEYBOARDS:
QMessageBox.warning(self, "", "An example keyboard UID was detected.\n"
"Please change your keyboard UID to be unique before you ship!")
if isinstance(self.autorefresh.current_device, VialKeyboard):
keyboard_id = self.autorefresh.current_device.keyboard.keyboard_id
if (keyboard_id in EXAMPLE_KEYBOARDS) or ((keyboard_id & 0xFFFFFFFFFFFFFF) == EXAMPLE_KEYBOARD_PREFIX):
QMessageBox.warning(self, "", "An example keyboard UID was detected.\n"
"Please change your keyboard UID to be unique before you ship!")

self.rebuild()
self.refresh_tabs()
Expand Down
7 changes: 5 additions & 2 deletions src/main/python/tabbed_keycodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

from constants import KEYCODE_BTN_RATIO
from widgets.display_keyboard import DisplayKeyboard
from widgets.display_keyboard_defs import ansi_100, ansi_80, ansi_70, iso_100, iso_80, iso_70
from widgets.display_keyboard_defs import ansi_100, ansi_80, ansi_70, iso_100, iso_80, iso_70, mods, mods_narrow
from widgets.flowlayout import FlowLayout
from keycodes import KEYCODES_BASIC, KEYCODES_ISO, KEYCODES_MACRO, KEYCODES_LAYERS, KEYCODES_QUANTUM, \
KEYCODES_BOOT, KEYCODES_MODIFIERS, \
KEYCODES_BACKLIGHT, KEYCODES_MEDIA, KEYCODES_SPECIAL, KEYCODES_SHIFTED, KEYCODES_USER, Keycode, \
KEYCODES_TAP_DANCE, KEYCODES_MIDI, KEYCODES_BASIC_NUMPAD, KEYCODES_BASIC_NAV, KEYCODES_ISO_KR
from widgets.square_button import SquareButton
Expand Down Expand Up @@ -172,7 +173,9 @@ def __init__(self, parent=None, keycode_filter=keycode_filter_any):
(None, KEYCODES_ISO),
], prefix_buttons=[("Any", -1)]),
SimpleTab(self, "Layers", KEYCODES_LAYERS),
SimpleTab(self, "Quantum", KEYCODES_QUANTUM),
Tab(self, "Quantum", [(mods, (KEYCODES_BOOT + KEYCODES_QUANTUM)),
(mods_narrow, (KEYCODES_BOOT + KEYCODES_QUANTUM)),
(None, (KEYCODES_BOOT + KEYCODES_MODIFIERS + KEYCODES_QUANTUM))]),
SimpleTab(self, "Backlight", KEYCODES_BACKLIGHT),
SimpleTab(self, "App, Media and Mouse", KEYCODES_MEDIA),
SimpleTab(self, "MIDI", KEYCODES_MIDI),
Expand Down
3 changes: 3 additions & 0 deletions src/main/python/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
0xBED2D31EC59A0BD8, # vial_stm32f401
]

# anything starting with this prefix should not be allowed
EXAMPLE_KEYBOARD_PREFIX = 0xA6867BDFD3B00F


def hid_send(dev, msg, retries=1):
if len(msg) > MSG_LEN:
Expand Down
8 changes: 8 additions & 0 deletions src/main/python/widgets/display_keyboard_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@
iso_70 = r"""
[["KC_ESCAPE",{"x":1},"KC_F1","KC_F2","KC_F3","KC_F4",{"x":0.5},"KC_F5","KC_F6","KC_F7","KC_F8",{"x":0.5},"KC_F9","KC_F10","KC_F11","KC_F12"],[{"y":0.25},"KC_GRAVE","KC_1","KC_2","KC_3","KC_4","KC_5","KC_6","KC_7","KC_8","KC_9","KC_0","KC_MINUS","KC_EQUAL","KC_JYEN","KC_BSPACE"],[{"w":1.5},"KC_TAB","KC_Q","KC_W","KC_E","KC_R","KC_T","KC_Y","KC_U","KC_I","KC_O","KC_P","KC_LBRACKET","KC_RBRACKET",{"x":0.25,"w":1.25,"h":2},"KC_ENTER"],[{"w":1.75},"KC_CAPSLOCK","KC_A","KC_S","KC_D","KC_F","KC_G","KC_H","KC_J","KC_K","KC_L","KC_SCOLON","KC_QUOTE","KC_NONUS_HASH"],[{"w":1.25},"KC_LSHIFT","KC_NONUS_BSLASH","KC_Z","KC_X","KC_C","KC_V","KC_B","KC_N","KC_M","KC_COMMA","KC_DOT","KC_SLASH","KC_RO",{"w":1.75},"KC_RSHIFT"],[{"w":1.25},"KC_LCTRL",{"w":1.25},"KC_LGUI",{"w":1.25},"KC_LALT",{"w":1.25},"KC_MHEN",{"w":2.5},"KC_SPACE",{"w":1.25},"KC_HENK",{"w":1.25},"KC_KANA",{"w":1.25},"KC_RALT",{"w":1.25},"KC_RGUI",{"w":1.25},"KC_APPLICATION",{"w":1.25},"KC_RCTRL"]]
"""

mods = r"""
[["KC_GESC",{"x":0.75,"w":1.25},"KC_LSPO",{"w":1.25},"KC_RSPC",{"x":0.25,"w":1.25},"KC_LCPO",{"w":1.25},"KC_RCPC",{"x":0.25,"w":1.25},"KC_LAPO",{"w":1.25},"KC_RAPC",{"x":0.5,"w":2.25},"KC_SFTENT"],[{"y":0.5},"OSM(MOD_LSFT)","OSM(MOD_LCTL)","OSM(MOD_LALT)","OSM(MOD_LGUI)",{"x":0.25},"OSM(MOD_RSFT)","OSM(MOD_RCTL)","OSM(MOD_RALT)","OSM(MOD_RGUI)",{"x":0.25},"OSM(MOD_LCTL|MOD_LSFT)","OSM(MOD_LCTL|MOD_LALT)","OSM(MOD_LCTL|MOD_LGUI)","OSM(MOD_LCTL|MOD_LSFT|MOD_LGUI)","OSM(MOD_LSFT|MOD_LALT)","OSM(MOD_LSFT|MOD_LGUI)","OSM(MOD_LSFT|MOD_LALT|MOD_LGUI)","OSM(MOD_LCTL|MOD_LALT|MOD_LGUI)","OSM(MOD_LALT|MOD_LGUI)","OSM(MOD_MEH)","OSM(MOD_HYPR)"],["LSFT(kc)","LCTL(kc)","LALT(kc)","LGUI(kc)",{"x":0.25},"RSFT(kc)","RCTL(kc)","RALT(kc)","RGUI(kc)",{"x":0.25},"C_S(kc)","LCA(kc)","LCG(kc)","RCG(kc)","LSA(kc)","SGUI(kc)",{"x":1},"LCAG(kc)",{"x":1},"MEH(kc)","HYPR(kc)"],["LSFT_T(kc)","LCTL_T(kc)","LALT_T(kc)","LGUI_T(kc)",{"x":0.25},"RSFT_T(kc)","RCTL_T(kc)","RALT_T(kc)","RGUI_T(kc)",{"x":0.25},"C_S_T(kc)","LCA_T(kc)","LCG_T(kc)","RCG_T(kc)","LSA_T(kc)","SGUI_T(kc)",{"x":1},"LCAG_T(kc)","RCAG_T(kc)","MEH_T(kc)","ALL_T(kc)"]]
"""

mods_narrow = r"""
[["KC_GESC",{"x":0.75},"KC_LSPO","KC_RSPC",{"x":0.5},"KC_LCPO","KC_RCPC",{"x":0.5},"KC_LAPO","KC_RAPC",{"x":0.5,"w":1.25},"KC_SFTENT"],[{"y":0.5},"OSM(MOD_LSFT)","OSM(MOD_LCTL)","OSM(MOD_LALT)","OSM(MOD_LGUI)",{"x":0.5},"OSM(MOD_LCTL|MOD_LSFT)","OSM(MOD_LCTL|MOD_LALT)","OSM(MOD_LCTL|MOD_LGUI)","OSM(MOD_LCTL|MOD_LSFT|MOD_LGUI)","OSM(MOD_LSFT|MOD_LALT)","OSM(MOD_LSFT|MOD_LGUI)"],["OSM(MOD_RSFT)","OSM(MOD_RCTL)","OSM(MOD_RALT)","OSM(MOD_RGUI)",{"x":0.5},"OSM(MOD_LSFT|MOD_LALT|MOD_LGUI)","OSM(MOD_LCTL|MOD_LALT|MOD_LGUI)","OSM(MOD_LALT|MOD_LGUI)","OSM(MOD_MEH)","OSM(MOD_HYPR)"],["LSFT(kc)","LCTL(kc)","LALT(kc)","LGUI(kc)",{"x":0.5},"C_S(kc)","LCA(kc)","LCG(kc)","RCG(kc)","LSA(kc)","SGUI(kc)"],["RSFT(kc)","RCTL(kc)","RALT(kc)","RGUI(kc)",{"x":1.5},"LCAG(kc)",{"x":1},"MEH(kc)","HYPR(kc)"],["LSFT_T(kc)","LCTL_T(kc)","LALT_T(kc)","LGUI_T(kc)",{"x":0.5},"C_S_T(kc)","LCA_T(kc)","LCG_T(kc)","RCG_T(kc)","LSA_T(kc)","SGUI_T(kc)"],["RSFT_T(kc)","RCTL_T(kc)","RALT_T(kc)","RGUI_T(kc)",{"x":1.5},"LCAG_T(kc)","RCAG_T(kc)","MEH_T(kc)","ALL_T(kc)"]]
"""

0 comments on commit 5d1a7a2

Please sign in to comment.