Since I'm new to this, I need your help. I'm trying to code my new GIGA R1 board to simulate keyboard actions. I've been using the USBHID library included in the core but I feel like it's somewhat limited. I might be mistaken but this library only provides the ability to send key_codes right? Is there a way to simulate holding keys? Something like press/release in the mouse.h library? Or do any of you know how I could achieve this with the available functions?
Thanks @steve9 - I was going to respond, that most of my USB work was on the host side and not on the USB to the PC side.
However, looking at the Arduino HID Keyboard documentation, I believe you should be able to do what you are asking: Keyboard | Arduino Documentation
That is you should be able to do something like:
Keyboard.press('a');
...
Keyboard.release('a');
Unfortunately looking at the code, it looks like they are not following their own
interface... Looks like, most of the code is still from what @facchinm did 6 years ago with the github commit: Start PluggableUSB-like porting.
It would probably not be hard to extend it to support the press/release.
You could probably do most of it outside of the library, by implementing your own press/release, that would break up the key_code_raw function to do the sends
of current state. You would either need to hold own to a HID_REPORT or
simply the 9 bytes for the modifier and keys, could be fewer number of bytes
depending on how many keys you want to emulate still being held down.
A couple of problems, most of the code like: send(&report) are public members
of the classes, however the _mutex is private, not sure if any problem not using it
Also their char to keycode translation is contained within the .cpp file, so not easy
to use it externally. However if you know the keycodes you are wanting to send, then...
Thank you very much both of u! And special thanks to KurtE and his awesome work regarding GigaHost stuff. It's been very helpful for some projects I'm currently working on.
I'll take a look at your explanations and see how it goes. Thanks!