You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, these are awesome libraries. I would like to implement USB HID keyboard multimedia keys, but I cannot get them to work. I am using the keyboard-example.py and keyboard.py file as a starting point. Is there some trick to this?
My project idea is to use a Pico W connected to a PC which doesn't have Ethernet, but does have Wi-Fi. I want to wake it up using usb-wake and then put it back to sleep. The Pico W will connect to an MQTT server and send keyboard commands based on the payload. The main multimedia keys I'd like to send are "Sleep", "Mute", and "Power". The host machine is Debian Bookworm running KDE.
I saw that on a subset of keycodes are defined in keyboard.py. I was able to add some additional keys, including KP_DOT = 99 #0x63, but not every value above 100 worked. I took line 85 of keyboard-example.py and changed it to keys.append(code) to keys.append(my_key) and set my_key to various integer values. I got the mapping from this gist
I tried several values:
#my_key = 102 # KEY_POWER 0x66
#my_key = 248 #define KEY_MEDIA_SLEEP 0xf8
#my_key = 239 #define KEY_MEDIA_MUTE 0xef
#my_key = 127 #define KEY_MUTE 0x7f
Unfortunately, none of these values worked, but I confirmed setting my_key = 4 did print the letter a, and so did many basic input keys and function keys. I plugged in a keyboard which has a mute key and used xev to examine the output.
a
KeyRelease event, serial 40, synthetic NO, window 0x7600001,
root 0x1e3, subw 0x0, time 16518608, (89,64), root:(1920,1047),
state 0x10, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 bytes: (61) "a"
XFilterEvent returns: False
Mute
KeyRelease event, serial 52, synthetic NO, window 0x9000001,
root 0x1e3, subw 0x0, time 15116196, (108,91), root:(1939,1074),
state 0x10, keycode 121 (keysym 0x1008ff12, XF86AudioMute), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
The mute key on the keyboard does mute system audio, but I cannot get the Pico to mute the PC.
The output states the keycode value should be 121, but when I try that, nothing comes through on xev. Comparing both events, I see that the keysim value is much larger for the mute key versus the a key.
I also don't have a keyboard with a power or sleep button on it, so I cannot verify what those key codes for real hardware are.
Any ideas?
The text was updated successfully, but these errors were encountered:
Hello, these are awesome libraries. I would like to implement USB HID keyboard multimedia keys, but I cannot get them to work. I am using the
keyboard-example.py
andkeyboard.py
file as a starting point. Is there some trick to this?My project idea is to use a Pico W connected to a PC which doesn't have Ethernet, but does have Wi-Fi. I want to wake it up using usb-wake and then put it back to sleep. The Pico W will connect to an MQTT server and send keyboard commands based on the payload. The main multimedia keys I'd like to send are "Sleep", "Mute", and "Power". The host machine is Debian Bookworm running KDE.
I saw that on a subset of keycodes are defined in keyboard.py. I was able to add some additional keys, including
KP_DOT = 99 #0x63
, but not every value above 100 worked. I took line 85 of keyboard-example.py and changed it tokeys.append(code)
tokeys.append(my_key)
and set my_key to various integer values. I got the mapping from this gistI tried several values:
Unfortunately, none of these values worked, but I confirmed setting
my_key = 4
did print the letter a, and so did many basic input keys and function keys. I plugged in a keyboard which has a mute key and usedxev
to examine the output.a
Mute
The mute key on the keyboard does mute system audio, but I cannot get the Pico to mute the PC.
The output states the keycode value should be 121, but when I try that, nothing comes through on xev. Comparing both events, I see that the keysim value is much larger for the mute key versus the a key.
I also don't have a keyboard with a power or sleep button on it, so I cannot verify what those key codes for real hardware are.
Any ideas?
The text was updated successfully, but these errors were encountered: