First, let me explain the functionality.
There are 9 buttons in total (from top to bottom):
- Mouse primary, mouse secondary (these are bent over the top and are pressed with the index finger)
- Fast rewind, fast forward
- Slow rewind, slow forward
- Previous play, next play
Then there's an analog stick that controls mouse movement.
When a button is pressed, it changes the result of the "buttonState()" function in the Controller class in the software. This, along with the stick input values mapped from 0 to 1023, are sent in a 7-byte package over serial with two '\n' characters sent along with them to help line up data transmission. It does this by using the (shared between both picos) Wireless class, which has a "putData(const uint8_t *, const size_t)" function.
Once received by the HID pico using the "getData(uint8_t *, const size_t)" function, this pico aligns the received data with the two '\n's and parses this information back. It then maps the button pressed with the corresponding keyboard functionality using the rather complex HID class. I've hidden a lot of functionality behind a relatively simple class that consists of things like "moveMouse(const int16_t, const int16_t)" and "pressKey(const uint8_t)." So ultimately, buttons => bluetooth => bluetooth => keyboard/mouse.
In Hudl's case, this means the play button gets mapped to a single space press, fast rewind is mapped to holding left, fast forward is holding right, slow rewind is holding up, slow forward is holding down, previous play is quick left, and next play is quick right, and yes, it was annoying to set up the distinction between a held key and a quickly pressed key, and no, there's no documentation out there explaining it and no, the examples don't really help either; it was pretty much guess-and-check lol.
Of course, mouse left and mouse right make sense, and the mouse move makes sense, so that was pretty simple.
Second, yes, this is "v2." Version 1 was made on an Arduino a couple years ago, and it used motion sensing to control the mouse, which didn't work very well, and it also was wired, and honestly, I don't even have it. I gave it to an ME to make a case for me, and I never got it back, so I decided to give it another try.
FInally, I should note. A lot of the APIs for C/C++ on the pico are non-existent or not very well documented, so there's a lot to learn by looking at the code for this project: HID keyboard/mouse, button and joystick input, serial bluetooth communication, etc. I could've used python here as performance is irrelevant, and I'd honestly recommend it for this stuff, but I couldn't get libraries working with Adafruit's CircuitPython, and I couldn't really get micropython at all since it kinda has to go through Thonny, and I couldn't get Thonny to connect on my x64 machine, and I didn't want to do all this on a Raspberry Pi, so I was stuck with C++, which I honestly prefer, but like I said, there wasn't good library support or examples, so here we are.
I have another project that has code for interacting with a few memory chips, an I2C OLED display, and some other stuff also on the pico that I hope to publish soon which will be yet another place that people can hopefully reference in the future as well.