implementing change_layer action on shortcuts

This commit is contained in:
foamyguy 2021-05-15 11:03:22 -05:00
parent e277bd0de7
commit 13d08deca0
2 changed files with 14 additions and 3 deletions

View file

@ -23,9 +23,9 @@ from touch_deck_layers import (
MEDIA,
KEY_PRESS,
KEY_RELEASE,
CHANGE_LAYER,
)
# seems to help the touchscreen not get stuck with chip not found
time.sleep(3)
@ -40,7 +40,7 @@ kbd = Keyboard(usb_hid.devices)
cc = ConsumerControl(usb_hid.devices)
kbd_layout = KeyboardLayoutUS(kbd)
# variables to envorce timout between icon presses
# variables to enforce timout between icon presses
COOLDOWN_TIME = 0.5
LAST_PRESS_TIME = -1
@ -132,7 +132,6 @@ main_group.append(home_layer_btn)
# helper method to laod icons for an index by its index in the
# list of layers
def load_layer(layer_index):
# show the loading screen
main_group.append(loading_group)
time.sleep(0.05)
@ -299,6 +298,17 @@ while True:
elif _action[0] == KEY_RELEASE:
kbd.release(*_action[1])
# Change Layer
elif _action[0] == CHANGE_LAYER:
if isinstance(
_action[1], int
) and 0 <= _action[1] < len(
touch_deck_config["layers"]
):
current_layer = _action[1]
load_layer(_action[1])
# if there are multiple actions
if len(_cur_actions) > 1:
# small sleep to make sure

View file

@ -6,6 +6,7 @@ KEY = 2
STRING = 3
KEY_PRESS = 4
KEY_RELEASE = 5
CHANGE_LAYER = 6
touch_deck_config = {
"layers": [