-
Notifications
You must be signed in to change notification settings - Fork 408
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 |
i made a combination of others and your code, i was wondering if i should post it and then link here, sorry, im kinda new and im not familiar. i think it could be of help to some folks and it took me a long time to figure it all out. its not perfect but i think with yalls help a lot could be ironed out but its working pretty smoothly. sorry if this is the wrong place but it does have to do with the topic at hand. im just not familiar with the licensing or anything like that. |
@codemaster010 did you fork the repo and make changes we can look at? |
As a side note - Could also look at ESP32-BLE-CompositeHID, which I think has all this merged in, with mouse and gamepad too. |
@LeeNX its not an exact copy but is it best to do fork or start another? im new to github uploading, is there any specific things i need to do in the proccess? it also uses another code thats has open license. i think as long as i give credit to original people should be ok right? my apologies for the newbie questions, just trying to do it right. i think the fork is the way to go |
@codemaster010 no worries. My go to would be to make a fork, possible also make a branch and put your changes in that. Fork would be easier to pull in upstream changes and making Pull Requests back to up stream. Can also update your fork's default branch to point to updated ReadMe and working code, with notes on why it works. In your PR you can point out how and why your changes are better or more tested that this PR. GitHub and git can be quite a big task to become comfortable with, but well worth it in the long run. Hope to see more feedback from you. |
@LeeNX i used fabgl for the keyboard and some other things, so the code is a bit different and im sure there are mistakes but i added code to compensate and seems to run pretty decent just not native like the buttons should be pushed. since the code i made with gpt has many different workings but based on the same and similar principles to get the job done. My project just made it work with ps/2 when i could not find it online to do it. i found @Cemu0 fork a few days ago and im blown away but still his does not use ps/2 that im aware so i made my own version. i also made it work with some really cool hardware with extra fun and usefull features that i havnt seen in most keyboards. if you think its ok to fork ill do that asap, thank you for all the advice. The topics of Pull requests all the github terms are are kind above my head but doing my best to understand. hopefully i can remove the fork if its not done correctly for some reason. . its likely this build uses less power due to not needing a hid interface. I hope to see some feedback to see what you think. i have two code, one is more of a test and was wondering if that can or should be added too or can i share that in pull requests in the future? update, here is the link to the branch. the issues and features are in the commit description. there are more things to mention but thats what i have for now. https://github.com/codemaster010/ESP32-BLE-Keyboard-PS2-/blob/PS2-FabGL-BLE-Keyboard/BLEKeyboardPS2.ino |
here is an updated readme file that hopefully satisfies for the most part the requirements needed as mentioned above. all feedback is highly welcomed. https://github.com/codemaster010/ESP32-BLE-Keyboard-PS2-/blob/PS2-FabGL-BLE-Keyboard/BLEKeyboardPS2.txt |
After reviewing the way things work i am still unclear if i should of made a independent repository with attribution and everything like that since the main part of the code works in different ways and combines other libraries, if anyone could help clarify that would be greatly appreciated. |
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