Ability to use media keys with Pico over USB HID #5004
Replies: 1 comment
-
Posted at 2021-06-27 by Stoaty Looks like I'd need to register the Pico as a Consumer Device (but not too sure what's involved with that) Compromise for now is to use a AutoHotkey script to control multimedia functions:
Along with my Pico script:
Posted at 2021-06-28 by @gfwilliams Hi! While we don't have a library for this via USB, there is one for Bluetooth HID (http://www.espruino.com/BLE+Keyboard). I haven't tried this out, but just mashing the two bits of code together may work:
Posted at 2021-06-29 by Stoaty Holy smokes, just tried swapping this in (just playpause for now) and it works! Will try replacing the rest later - see what happens and report back. Many thanks for the suggestion, Gordon! Posted at 2021-06-29 by Stoaty Here's the latest incarnation! Working pretty well. Sometimes the mute and playpause commands don't work the 2nd time you press them, but with subsequent presses work fine
Posted at 2021-06-29 by Stoaty Interestingly when hitting vol up/down, the command gets sent repeatedly until you press it again too Posted at 2021-06-30 by @gfwilliams Hmm - when pressing keys normally on the keyboard, you send one HID report for keydown, and another to show the key has been lifted. It didn't seem to be the case on the BLE version but maybe you need to do that here?
Thanks for posting up your code though - that's great! Maybe I should turn this into a module? Posted at 2021-07-01 by Stoaty
Yep that was exactly it! Thanks for the snippet Gordon, simply dropped it in and now it's working brilliantly. I think a module for this would have definitely helped me in the first instance. Posted at 2021-07-01 by Stoaty Final working code:
Posted at 2021-07-01 by Stoaty So happy I dug my Pico out to do this! Love it, thanks for all the help. It's so useful. Also have the Adafruit Rotary Trinkey programmed to control media which inspired me to try this (having completed your IR tutorial about 1y ago successfully!) Posted at 2021-07-02 by @gfwilliams Great - thanks! Glad it's working so well! I'll try and get this added as a module :) edit: just added a module and it should go live this week Posted at 2021-07-07 by Stoaty Oh, that's awesome!
edit: I did get ahead of myself - found it https://github.com/espruino/EspruinoDocs/blob/master/modules/USBMedia.js Posted at 2021-07-08 by @gfwilliams Thanks for the change in the docs! I think that was you? Posted at 2021-07-08 by Stoaty Yes indeed it was 🙂 no problem Gordon, thanks for the module! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-06-26 by Stoaty
Hi all!
I've just been following the docs to try out the USB HID keyboard module, it's great!
I was wondering if this module is able to send mediakey commands (vol up/down, play, pause)
My use case is, that I've created a IR Reciever Hat for my Pico which is plugged in to my computer via a USB port that has IR line-of-sight to my remote control, on my desk
I have used the IR communication Espruino examples to determine which button was pressed on my IR remote control, works perfectly!
Now, I want to be able to send volume/media commands to my PC by simply using the remote control.
Beta Was this translation helpful? Give feedback.
All reactions