-
Notifications
You must be signed in to change notification settings - Fork 426
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
First test and a little report #1
Comments
That sounds pretty good so far. I hope I can find some more time to work on this tomorrow.
inside the class.. In theory report id 1 is for the keyboard functionality and report id 2 is for the media key functionality. |
I was not able to get it to work after applying your suggested changes. Was there anything else that you had to do?
I decoded the stacktrace:
But I have no idea what it means. I don't even know what Anyway, I applied your changes and modified the code so that it can send the media keys (hopefully). (See example) |
Hi, In the device desrciptor I had to make another change, the last REPORT_COUNT was on "0x07", with that I get a driver error in Win10. I changed it to "0x08" and then under Win10 I can send the "normal" keyboard keys. About the media buttons, a little succes. Then I removed the hardcoded stuff again, only the reportid stays 2 and I changed the struct "KeyReport" to only have the keys array (removed "modifiers" and "reserved"). This is, what I send through my arduino code then:
Also with that, the media controlls in Win10 are showing up, but I can't control anything. |
I'd love to test it, but I can't even get to the point where I would connect to the device. I'll try compiling and uploading from a different computer later today. |
Hi, with your new code I can't get it to work, too. I will revert back to the working code and send it to you. But I saw, what you changed, so I will try to adapt the changes to my "working" code. I am on Holiday, so I have some time to test ;) |
Here you can download the working code to sending the "normal" keyboard key strokes. In the examples you can find my code. |
Hi, Here you can download my last state, maybe it helps you a bit. |
Thanks, my crashes were caused by the deviceName being too long. Took me forever to figure that out. |
Nice work, I uploaded your example and with android it was working out of the box, but not with Win10. I then changed the REPORT_COUNT from 0x0f to 0x10 and it is also working with Win10. |
Awesome, now it works on Linux too! I'll see if I can make the interface a bit nicer so that it can be used like the usb keyboard library. |
I got it to the point where bleKeyboard.print("Hello") etc would work, but for the media keys I couldn't figure it out yet. https://github.com/T-vK/ESP32-BLE-Keyboard/tree/test Ideally, it would work just like that The main issue is definitely that the original USB keyboard lib is not designed to support media keys. |
Hm, with Win10 I had to change the report count from 0x0A to 0x10 again, but then it is working as expected. I am able to send media keys with So I would say, your library is nearly ready ;) 👍 |
Only problem now is, if the ESP32 is powered off and on again, I have to reconnect it, no matter if Win10 or android. |
I just made an important discovery. Apparently the device or device descriptor gets cached to some degree. At least on Android and Linux. After disconnecting the device, unpairing it and then disabling bluetooth the code from yesterday suddenly just worked for me on Android and Linux. Automatic reconnecting works fine for me on Android and Linux most of the time. But sometimes I have to disable and enable Bluetooth again on the device or manually connect again. I'm not really sure what is going wrong there. |
You are right, 0x0f is 16. I don't know, why the report count has to be n of usage +1, but with that it works ;) About the reconnect problem I found this: nkolban/esp32-snippets#632 (comment) Everytime I reboot the ESP or just plug it out and back in, I have to disable and enable Bluetooth in Android, otherwise I can't control Android. With Windows I have to remove it and then add it new. Simply disable and enable BT is not enough. Btw, thanks for including me in your credits. |
No, you are the one who is right: I'll take a look at it. I assume you've already tried:
in BleConnectionStatus.cpp |
Of course, 0x10 is 16, (I had the same thinking mistake as you😁 ) I tried in variuos ways, last thing I tried:
Also with `setNotifications(true);´ but no luck. |
I've had no luck either. Maybe @nkolban has an idea, as he's the author of all the low level BLE HID libraries. |
Hi @T-vK
Thanks, that was fast.
In general it is working. In your Hid device descriptor was a (2) instead of (1) at the report id 2.
REPORT_ID(1), 0x02, // REPORT_ID (2)
With that I get a driver error in Win10.
In the array keyReport.keys you wrote all in array 0 and for "a" the code is 0x04 not 0x61 ;)
I changed that to
Now I am able to sent 4 keys through my rotary encoder knob ("a" with short press, "b" with long press, "c" with rotate CW and "d" with rotate CCW). but I am not able to control "play/pause" and so on. I tried it with "0xcd" but I think, these keys are not handled in the same way as normal key strokes.
The text was updated successfully, but these errors were encountered: