-
Notifications
You must be signed in to change notification settings - Fork 376
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
Add Read Numlock/Capslock/Scrolllock state #70
base: master
Are you sure you want to change the base?
Conversation
Also add KEY_SCROLL_LOCK and KEY_NUM_LOCK
ESP32_USBHOST_TO_BLE_KEYBOARD looks amazing. I love it! |
I tested and this PR work well with my Windows PC (ThinkPad P51) and iPhone6s (ios 14.3). But with the iphone, "sometime" the ESP32 not appear on the pair list on Iphone so I have to use a external App like (BLE Scanner) to pair the phone with ESP32). Currently I don't have a Linux or Android for test. |
I tried the code (downloaded the PR and updated the INO), which is way beyond my skillset, but I have issues.
or [FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: CreateEvt (0x3ffd7a4c), owner: executeCreate for executeCreate
Update: Looks like the delay in the startup on my ESP requires 1.5s. Any suggestions on how to optimize and reduce this delay is appreciated. |
Might be worth adding a little more info too
I updated my loop test as follows
Which shows me when the CapsLock has been changed, but the I have a few ideas on how to monitor the Global variable for change, this might not be the correct place to discuss that. I can confirm the ESP32 to macOS Catalina (v10.15.7) MacBook Pro (15-inch,2017) works with this PR. |
I know the folder structure. I have narrowed the issue down to the setup delay. This delay also causes the issue where if the debug disabled, the initial interrogation of the states happens faster than the callback is able to be set allowing the data to be lost. Setting the callback prior to bleKeyboard.begin() does not work. |
Ok i modified the library where the blekeyboard has a private declaration of the callback (as defined in keyboardoutputcallbacks). Thus the callback now must be set prior to begin:
or invoke an overloaded begin function:
Then right when the code allocates the mem for: we immediately assign the callback If there is a better way, please let me know. Thanks everyone for the help and dev. |
I considered the connection time in my code here which can lower the delay time after |
I agree the delay would not impact connection, but it does prevent the main loop from running. The proposed change would reduce the dependency and any chance of kernel panics. I will have a look at your code, will take some time to digest. |
Just as a note,
Thou it's not directly related to the LED states PR, but info. OSX does not toggle the CapsLock state with As for the LED states PR, looks like it works perfectly with Android, thou it was not so easy to test. I could not find a on-screen keyboard that would reflect the CapsLock state, thou when writing the state, that did update on the Android device. I had to connect an external USB keyboard, that had CapsLock LED and I could see the CapsLock LED match the state in the ESP32 device when toggled with the USB keyboard. |
@T-vK , what's the status of this pull request? Are there any outstanding issues that stop you from merging it? 🙂 |
@fangfufu Yes, I'd like to get this one sorted out first: arduino-libraries/Keyboard#43 |
@T-vK Sorry to jump into the conversation like this but I see this hasn't been merged yet. Since this is - at least to me - critical feature, I think it would make sense to merge this rather than keep waiting for the other library author, it's been months already :) |
Excuse me, what's the progress now? Has the problem been solved? |
No, I'm still waiting for arduino-libraries/Keyboard#43 to be resolved. Kinda sad that it's taking so long. :/ |
Just keeping an eye on this. Thanks @T-vK |
Thank you for the contribution. However, it seems the original Arduino Keyboard library is not going to be patched accordingly in near future. It would be great to at least maintain another branch with lock state support since it is such an important feature to build a complete keyboard yet delayed over a year. |
Could somebody point me in the right direction on how to fumble this feature into the current master branch? |
@kilr00y First step to success is to learn to use github ;) You should be able to just use @Cemu0 's repository. https://github.com/Cemu0/ESP32-BLE-Keyboard |
@mcer12 been there, done that. Cemu0's repository is 2 years old and i have issues that are fixed in current. |
nevermind... sometime you just have to ask to reach the solution yourself :) |
@T-vK it looks like adding keyboard-led call back won't be solved in near future, so as @kilr00y pointed out, I think the callback feature is quite overkilling for this simple task since most of we just need to indicator the CAPLOCK_LED or so. if(bleKeyboard.isConnected()) {
if (bleKeyboard.getLedStatus(LED_CAPS_LOCK))
{
Serial.print("Cap Lock on ");
}
if (bleKeyboard.getLedStatus(LED_SCROLL_LOCK))
{
Serial.print("Scroll Lock on "); //not work
}
if (bleKeyboard.getLedStatus(LED_NUM_LOCK))
{
Serial.print("Num Lock on ");
}
} The BleKeyboard::onWrite does not call back when ScrLk changes on PC. So I think this is because NimBLE or PC does not support this key since I remember the last version it still works. So it would be helpful if test on other devices. Update: Sorry it's because of my cheap keyboard, the ScrLk button is fake and does not work in excel, I replaced it with a Logitech keyboard and everything works well. Even using |
Thank you for your repository, I transformed my wire keyboard to wireless :)
When type on the numpad the Numlock stage should be sync or the numpad just run wrong, same with caplock stage.
I also added an example for demonstration.
Hope this helpful