Joypad HID
Hey,
I am trying to use the nice!nano for my own project, a bluetooth game controller. I was scraping TinyGo for the BLE HID support and the most mature project I found was yours. I have seen you have a branch blehid2 (which seems to be newer than blehid), as well as blekeyboard*. I would like to use it as a starter for my project. Can you recommend a branch / resources you used for you work?
Best regards
Hello,
I think the following branch will help BLE HID move forward a bit.
Currently, the blehid2 branch of tinygo-keyboard works as a BLE HID Keyboard on Android, but it does not work on Windows or other platforms. This requires additional implementations, such as LESC.
https://github.com/tinygo-org/bluetooth/pull/295 https://github.com/tinygo-org/bluetooth/issues/204
Ok, I started tinkering and... its not even compiling. It does not seem to find the following functions/constants:
bluetooth.SetSecParamsBonding()
bluetooth.SetSecCapabilities()
bluetooth.NoneGapIOCapability
I tried:
- tinygo.org/x/bluetooth v0.10.0
- tinygo.org/x/bluetooth v0.8.0
Both seem to miss them. Do you have an idea about that?
Further there are quite some magic value, can you elaborate a little on these?
- https://github.com/sago35/tinygo-keyboard/blob/blehid2/ble/ble.go#L83
- https://github.com/sago35/tinygo-keyboard/blob/blehid2/ble/ble.go#L84
- https://github.com/sago35/tinygo-keyboard/blob/blehid2/ble/ble.go#L93 80% battery?
- https://github.com/sago35/tinygo-keyboard/blob/blehid2/ble/ble.go#L118
- https://github.com/sago35/tinygo-keyboard/blob/blehid2/ble/ble.go#L148
- https://github.com/sago35/tinygo-keyboard/blob/blehid2/ble/ble.go#L167
- https://github.com/sago35/tinygo-keyboard/blob/blehid2/ble/ble.go#L175
First, check out the blehid2 branch and try building it as is. It successfully built on my end.
$ git checkout blehid2
$ tinygo build -o /tmp/out.uf2 --target xiao-ble --stack-size 8kb --size short ./targets/sgkey-ble/
code data bss | flash ram
100184 3644 11168 | 103828 14812
Further there are quite some magic value, can you elaborate a little on these?
There are still many magic numbers left, but there are no plans to fix them at this point. I think this will be revisited when the PR approaches completion. For now, please note that this is still a draft.
Seems like something is different in your setup:
$ git pull
Host key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU
+--[ED25519 256]--+
| |
| . |
| o |
| o o o . |
| .B S oo |
| =+^ =... |
| oo#[email protected]. |
| E+.&.=o |
| ooo.X=. |
+----[SHA256]-----+
Already up to date.
$ git st
On branch blehid2
Your branch is up to date with 'origin/blehid2'.
nothing to commit, working tree clean
$ tinygo build -o /tmp/out.uf2 --target xiao-ble --stack-size 8kb --size short ./targets/sgkey-ble/
# github.com/sago35/tinygo-keyboard
kbblesplit.go:155:30: cannot use (func(device bluetooth.Device, connected bool) literal) (value of type func(device bluetooth.Device,
connected bool)) as func(device bluetooth.Address, connected bool) value in argument to d.adapter.SetConnectHandler
Though not the error I expected.
Regarding the magic values, ChatGPT helped me out on that.
I haven't been able to respond for a while.
In the near future, I will investigate using the latest tinygo.org/x/bluetooth.