Close

BLE keyboard works! BLE mouse works!

A project log for Ergonomic handheld mouse / keyboard alternative

A wireless input alternative that's actually ergonomic!

shervin-emamiShervin Emami 08/26/2018 at 10:010 Comments

The hardware in Tiny BLE is capable of being a BLE keyboard and mouse, but unfortunately they don't provide source code for this right out of the box. There is a demo project for Tiny BLE using the mbed online compiler (https://github.com/Seeed-Studio/Tiny_BLE), and I also found sample code of a BLE keyboard and of a BLE mouse using mbed (https://github.com/jpbrucker/BLE_HID), but they aren't designed specifically for Tiny BLE. So they need to be merged together.

Unfortunately I didn't find good sample code that allows a single Bluetooth BLE device to behave as both a keyboard and mouse at the same time. The only code I did find that is capable of both at the same time was some code on a forum at https://community.cypress.com/thread/11130 that uses theCypress PSoC Creator graphical tool, and therefore the generated code is quite large and tricky to understand.

So my device will act as either a keyboard or a mouse, but not both at the same time.

Anyway, after a bunch of trial & error (is it just me or is Bluetooth extremely unreliable?!), I got it to work as a keyboard, and then with a code rebuild, as a mouse! I used the free mbed OS and online compiler, because BLE apparently doesn't easily fit into the restricted flash size that free versions of compilers such as Keil and IAR support.

Discussions