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

Adding support for getting numlock/capslock/scrolllock states #43

Open
T-vK opened this issue Jan 27, 2021 · 5 comments
Open

Adding support for getting numlock/capslock/scrolllock states #43

T-vK opened this issue Jan 27, 2021 · 5 comments
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@T-vK
Copy link

T-vK commented Jan 27, 2021

I would like to keep ESP32-BLE-Keyboard compatible with the Keyboard library and now we're about to add support for retrieving the numlock, capslock and scrolllock states.
So I would like to agree on a set of methods that we try to implement in both libraries.

Would you be okay with a method called setLedChangeCallBack that would allow providing a callback function?

Keyboard.setLedChangeCallBack(KbdLedCb);

E.g.

#include <Keyboard.h>

void onKeyboardLedChange(KbdLeds *kbls)
{
  if (kbls->bmNumLock == HIGH)
     Seriel.println("Numlock On!");
  else
     Seriel.println("Numlock Off!");

  if (kbls->bmCapsLock == HIGH)
     Seriel.println("CapsLock On!");
  else
     Seriel.println("CapsLock Off!");

  if (kbls->bmScrollLock == HIGH)
     Seriel.println("ScrollLock On!");
  else
     Seriel.println("ScrollLock Off!");
}

void setup()
{
  Serial.begin(9600);
  Keyboard.begin();
  Keyboard.setLedChangeCallBack(KbdLedCb);
}

void loop()
{
}

and 3 methods to retrieve the states of the lock keys manually without a callback:

Keyboard.GetNumLockState();
Keyboard.GetCapsLockState();
Keyboard.GetScrollLockState();

e.g.

#include <Keyboard.h>

void setup()
{
  Serial.begin(9600);
  Keyboard.begin();
}

void loop()
{
  bool numLockState = Keyboard.GetNumLockState();
  bool capsLockState = Keyboard.GetCapsLockState();
  bool scrollLockState = Keyboard.GetScrollLockState();
  if (numLockState == HIGH)
     Seriel.println("Numlock On!");
  else
     Seriel.println("Numlock Off!");

  if (capsLockState == HIGH)
     Seriel.println("CapsLock On!");
  else
     Seriel.println("CapsLock Off!");

  if (scrollLockState == HIGH)
     Seriel.println("ScrollLock On!");
  else
     Seriel.println("ScrollLock Off!");
  delay(1000);
}

Maybe it would make more sense to use true/false instead of HIGH/LOW?
Or different names for the methods?

Just to clarify: I'm not asking you to actually implement this, I will try to do it once I find the time.

@per1234 per1234 added the type: enhancement Proposed improvement label Jan 28, 2021
@T-vK
Copy link
Author

T-vK commented Feb 4, 2021

@per1234 I see you added the enhancement tag, but I wasn't making a feature request, I was asking if we could agree on how this feature would be implemented so that we can keep compatibility between our libraries.

@per1234
Copy link
Contributor

per1234 commented Feb 4, 2021

Are you telling me you wouldn't consider that to be an enhancement?

There are three issue types: enhancement, bug, and invalid.

@T-vK
Copy link
Author

T-vK commented Feb 5, 2021

Sorry, I thought there were 7 types. I was thinking it would be a better fit for question or help wanted, but it doesn't really matter to me, I was just making sure that we don't have a misunderstanding. ;)

@per1234 per1234 added the topic: code Related to content of the project itself label Mar 6, 2022
@per1234
Copy link
Contributor

per1234 commented Mar 6, 2022

Related proposal: #61
Related request: #40

@60999
Copy link

60999 commented May 8, 2022

Excuse me, what's the progress now? Has the problem been solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

3 participants