Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacement for Usb.setReport()? #459

Closed
JoeMalt opened this issue Apr 26, 2019 · 2 comments
Closed

Replacement for Usb.setReport()? #459

JoeMalt opened this issue Apr 26, 2019 · 2 comments

Comments

@JoeMalt
Copy link

JoeMalt commented Apr 26, 2019

I'm trying to toggle the state of some LEDs (Caps Lock indicator etc.) on a USB keyboard.

An example (linked to cached version since site seems to be down) calls Usb.setReport(), but this method doesn't seem to exist.

There seems to be a SetReport() method in usbhid.cpp, I'm trying to use that instead (after creating a USBHID object), but I'm not sure if it's a replacement or just something with a similar name.

Am I on the right track?

@DanielGibson
Copy link
Contributor

DanielGibson commented Jan 1, 2021

(I know this is late, but maybe you still wonder how this works or someone gets here via google or whatever)
Take a look at

virtual uint8_t HandleLockingKeys(USBHID* hid, uint8_t key) {
uint8_t old_keys = kbdLockingKeys.bLeds;
switch(key) {
case UHS_HID_BOOT_KEY_NUM_LOCK:
kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock;
break;
case UHS_HID_BOOT_KEY_CAPS_LOCK:
kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock;
break;
case UHS_HID_BOOT_KEY_SCROLL_LOCK:
kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock;
break;
}
if(old_keys != kbdLockingKeys.bLeds && hid) {
uint8_t lockLeds = kbdLockingKeys.bLeds;
return (hid->SetReport(0, 0/*hid->GetIface()*/, 2, 0, 1, &lockLeds));
}
return 0;
};
to see how to set the keyboard LEDs.
Note that this doesn't work reliably with the "current" release (1.3.2 which is almost 3 years old now) you'd get from the Arduino Library Manager, but it does work with the latest git code (see https://github.com/felis/USB_Host_Shield_2.0#manual-installation)

@Lauszus
Copy link
Collaborator

Lauszus commented Feb 7, 2021

This has been fixed with the 1.4.0 release.

@Lauszus Lauszus closed this as completed Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants