From 4368632c3bfdbc9991a5d718fd46b07bdec554e3 Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Wed, 17 Apr 2024 13:45:57 -0500 Subject: [PATCH] updated some button functions to media buttons --- code.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/code.py b/code.py index 36a3e08..0e1d73e 100755 --- a/code.py +++ b/code.py @@ -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)