implementing change_layer action on shortcuts
This commit is contained in:
parent
e277bd0de7
commit
13d08deca0
2 changed files with 14 additions and 3 deletions
|
|
@ -23,9 +23,9 @@ from touch_deck_layers import (
|
||||||
MEDIA,
|
MEDIA,
|
||||||
KEY_PRESS,
|
KEY_PRESS,
|
||||||
KEY_RELEASE,
|
KEY_RELEASE,
|
||||||
|
CHANGE_LAYER,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# seems to help the touchscreen not get stuck with chip not found
|
# seems to help the touchscreen not get stuck with chip not found
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ kbd = Keyboard(usb_hid.devices)
|
||||||
cc = ConsumerControl(usb_hid.devices)
|
cc = ConsumerControl(usb_hid.devices)
|
||||||
kbd_layout = KeyboardLayoutUS(kbd)
|
kbd_layout = KeyboardLayoutUS(kbd)
|
||||||
|
|
||||||
# variables to envorce timout between icon presses
|
# variables to enforce timout between icon presses
|
||||||
COOLDOWN_TIME = 0.5
|
COOLDOWN_TIME = 0.5
|
||||||
LAST_PRESS_TIME = -1
|
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
|
# helper method to laod icons for an index by its index in the
|
||||||
# list of layers
|
# list of layers
|
||||||
def load_layer(layer_index):
|
def load_layer(layer_index):
|
||||||
|
|
||||||
# show the loading screen
|
# show the loading screen
|
||||||
main_group.append(loading_group)
|
main_group.append(loading_group)
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
@ -299,6 +298,17 @@ while True:
|
||||||
elif _action[0] == KEY_RELEASE:
|
elif _action[0] == KEY_RELEASE:
|
||||||
kbd.release(*_action[1])
|
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 there are multiple actions
|
||||||
if len(_cur_actions) > 1:
|
if len(_cur_actions) > 1:
|
||||||
# small sleep to make sure
|
# small sleep to make sure
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ KEY = 2
|
||||||
STRING = 3
|
STRING = 3
|
||||||
KEY_PRESS = 4
|
KEY_PRESS = 4
|
||||||
KEY_RELEASE = 5
|
KEY_RELEASE = 5
|
||||||
|
CHANGE_LAYER = 6
|
||||||
|
|
||||||
touch_deck_config = {
|
touch_deck_config = {
|
||||||
"layers": [
|
"layers": [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue