bsiever / microbit-pxt-blehid

Micro:bit MakeCode support to act as a Human Interface Devices (keyboard, mouse, etc.) over Bluetooth
https://bsiever.github.io/microbit-pxt-blehid/
MIT License
30 stars 10 forks source link

How do i use this code to transmit hid data over usb #27

Closed hhjjj75 closed 1 year ago

bsiever commented 1 year ago

This is a MakeCode extension and needs to be included in a MakeCode project. Here's an example project that would send "Hello!" as a Bluetooth Keyboard: https://makecode.microbit.org/_hKwaamXwziXe

This only works with the micro:bit v2 and newer (not older micro:bits) and only works from the real micro:bit, not in the simulator.

Here's a video that show several different uses: https://www.youtube.com/watch?v=n4J5GN72N_4

bsiever commented 1 year ago

Quick update: This extension is for HID over Bluetooth. It does not do HID over USB.

I don't think the micro:bit can do HID over USB due to the way the interface chip is configured.

hhjjj75 commented 1 year ago

Microbit is capable of hid but there isnt a library for it

bsiever commented 1 year ago

@hhjjj75 In case you didn't know, the micro:bit processor itself (the nRF51 or nRF 52) is not connected directly to USB. The USB is connected to an interface chip (different interface chips have been used in different versions of the micro:bit). The interface chip is connected to the micro:bit processor (the nRF51 or nRF52) by serial wire debug (SWD) connections. See the schematics at: https://tech.microbit.org/hardware/schematic/ for details. (The micro:bit v2.2 is unusual: One nRF52 is the interface and another is the main processor (the "target"))

Doing a general USB HID would require substantial changes to the interface chips or their firmware, which isn't possible with MakeCode extensions like this one. There are significant technical challenges to adding more general USB HID support, but if the Microbit Foundation updates the interfaces to support more general USB HID behavior, then MakeCode extensions can be written to support it.