updated some button functions to media buttons

This commit is contained in:
Rudis Muiznieks 2024-04-17 13:45:57 -05:00
parent 7753055416
commit 4368632c3b
Signed by: rudism
GPG key ID: CABF2F86EF7884F9

21
code.py
View file

@ -6,6 +6,7 @@ from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
from adafruit_hid.mouse import Mouse
from adafruit_hid.consumer_control import ConsumerControl
from adafruit_hid.consumer_control_code import ConsumerControlCode
led = DigitalInOut(board.LED)
led.direction = Direction.OUTPUT
@ -28,10 +29,10 @@ pins = [
]
def press(key):
if key == 0: # xf86copy
ctl.send(0x21B)
elif key == 1: # xf86paste
ctl.send(0x21D)
if key == 0:
ctl.send(ConsumerControlCode.VOLUME_INCREMENT)
elif key == 1:
ctl.send(ConsumerControlCode.PLAY_PAUSE)
elif key == 2:
mse.press(Mouse.MIDDLE_BUTTON)
elif key == 3:
@ -40,11 +41,13 @@ def press(key):
ctl.send(0x225) # forward (browser)
elif key == 5:
mse.press(Mouse.RIGHT_BUTTON)
elif key == 6: # ctrl-w
kbd.press(Keycode.CONTROL)
kbd.press(Keycode.W)
kbd.release(Keycode.W)
kbd.release(Keycode.CONTROL)
elif key == 6:
ctl.send(ConsumerControlCode.VOLUME_DECREMENT)
# ctrl-w
#kbd.press(Keycode.CONTROL)
#kbd.press(Keycode.W)
#kbd.release(Keycode.W)
#kbd.release(Keycode.CONTROL)
elif key == 7:
# toggles scroll mode in ploopy nano using maddie layout
kbd.press(Keycode.KEYPAD_NUMLOCK)