Keyboard Multimedia Key Support?
@projectgus がすでに取り組んでいます。
2025年7月31日 から。
評価
この issue はまだ評価されていません。
説明
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?
- 主要言語
- Python
- スター
- 2.9k
- フォーク
- 1.1k
- 平均マージ
- 7日 6時間
- マージ済み PR(30日)
- 3
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
micropython/micropython-lib のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
micropython/micropython-lib#1074 ·
-
needs-info
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
micropython/micropython-lib#943 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
micropython/micropython-lib#931 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
micropython/micropython-lib#795 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
micropython/micropython-lib#762 ·
micropython/micropython-lib の issue をすべて見る
似ている issue
-
link-check link-check:sphinx-theme
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
OpenHands/extensions#626 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
CSCfi/sd-search-api#39 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100