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

Problem with keyboard and lock keys #160

Closed
custodium opened this issue Jun 30, 2015 · 6 comments
Closed

Problem with keyboard and lock keys #160

custodium opened this issue Jun 30, 2015 · 6 comments

Comments

@custodium
Copy link

Hello,

I've a problem with a Keyboard and USB Host Shield libraries, when I press any lock key (CapsLock, NumLock or ScrollLock) the led came on, but if I press again it does not came off, it only came off when I press any other lock key.

Best regards.

@Lauszus
Copy link
Collaborator

Lauszus commented Jul 1, 2015

Please describe your setup. What development board are you using, keyboard etc.

@gorakk
Copy link

gorakk commented Aug 27, 2015

Hi there,

I happened to notice this issue yesterday - pressing a lock key will turn on the appropriate LED on the keyboard - but another press will not turn it off. Also - multiple LEDs cannot be turned on. If NumLock is pressed the NumLock LED will turn on, if CapsLock is then pressed the NumLock LED will turn off and the CapsLock LED will turn on.

In hidboot.h starting at line 166 - it appears that SetReport is clearing kbdLockingKeys.bLeds - here is the original:

  if(old_keys != kbdLockingKeys.bLeds && hid)
    return (hid->SetReport(0, 0/*hid->GetIface()*/, 2, 0, 1, &kbdLockingKeys.bLeds));

My quick and dirty fix was to add a temp variable. I haven't dug further into the code so I'm not sure if there is some reason for kbdLockingKeys.bLeds to be cleared. But with this change the LEDs will toggle properly and multiple LEDs will light.

  if(old_keys != kbdLockingKeys.bLeds && hid)
  {
    uint8_t lockLeds = kbdLockingKeys.bLeds;  // added

    return (hid->SetReport(0, 0/*hid->GetIface()*/, 2, 0, 1, &lockLeds));  // changed to use the temp variable
  }

@Lauszus
Copy link
Collaborator

Lauszus commented Aug 30, 2015

@gorakk thanks. Do you mind sending a pull request?

@Lauszus
Copy link
Collaborator

Lauszus commented Sep 3, 2015

#172 should fix this issue.

@Lauszus Lauszus closed this as completed Sep 3, 2015
romerod pushed a commit to romerod/USB_Host_Shield_2.0 that referenced this issue Jul 13, 2018
@lnxsrt
Copy link

lnxsrt commented Oct 21, 2020

I am still having an issue with keyboard lock LEDs inconsistently lighting. The kbdLockingKeys.bLeds variable is consistent and updating appropriately. However, I think the SetReport call may not be working correctly. It looks like it occasionally sends an incorrect value causing all of the LEDs to turn off. I am just using the default USBHIDBootKbd.ino code with a standard wired keyboard. Everything else works well so I don't suspect a physical setup issue.

@DanielGibson
Copy link
Contributor

@lnxsrt: try using the latest code from git instead of version 1.3.2 from the Arduino library manager - seems like this issue has been fixed since then (see also #577)

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

5 participants