Skip to content

Commit

Permalink
Extract some variables to make decoding the keymap more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilboBaggins authored Dec 25, 2023
1 parent 9ae12fb commit 36a5045
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions ExampleCode/CircuitPython/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,18 @@ def loginSequence():
while True:
for button, state in buttonChecker.check_all():
try:
actionType = keymap[button][0]
actionArgs = keymap[button][1]
if state == PRESSED:
if keymap[button][0] == KEY:
kbd.press(*keymap[button][1])
elif keymap[button][0] == FUNC:
keymap[button][1]()
if actionType == KEY:
kbd.press(*actionArgs)
elif actionType == FUNC:
actionArgs()
else:
cc.send(keymap[button][1])
cc.send(actionArgs)
elif state == RELEASED:
if keymap[button][0] == KEY:
kbd.release(*keymap[button][1])
if actionType == KEY:
kbd.release(*actionArgs)
except ValueError: # deals with six key limit
pass

Expand Down

0 comments on commit 36a5045

Please sign in to comment.