FreeTouchDeck with air mouse feature
I recently wrote a post about building a FreeTouchDeck an open source DIY alternative for Stream deck.
In this post, I will show you how I added an air mouse feature to it.
For this project, I used the following components
- FreeTouchDeck setup from an earlier post.
- MPU-6050 accelerometer/gyroscope sensor module
Replace BLE-keyboard by BLE-Combo
The FreeTouchDeck uses T-vK/ESP32-BLE-Keyboard library to set up the device as a BLE keyboard to connect to a device. To have the Air mouse feature we need to add the BLE mouse feature too. BLE-Combo library provides a way to connect as a keyboard-mouse combo. The original BLE-combo library is a bit outdated and has bugs, which is why I went with the fork by earthicko
Use NimBLE
#define USE_NIMBLE
I enabled NimBLE which had a smaller footprint and some improvements compared to Arduino’s native BLE.
Configure a page dedicated to the mouse actions
I configured one of the options on the homepage to have a mouse + Bluetooth icon and added all the mouse actions to its page.
The page contains three buttons for Mouse left middle and right click in that order, and the up arrow scrolls the page up and the down arrow scrolls down.
Add options for dropdowns on the configurator
The dropdown menu would allow users to select one of the options defined in the “subitems” array, which represents different mouse buttons and actions. When a user selects one of these options, the configurator could associate that selection with a virtual button on a touchscreen, allowing the user to trigger the corresponding action by tapping the virtual button.
For example, if a user selects the “Left Mouse Button” option from the dropdown, the configurator could map that selection to a virtual button on the touchscreen that corresponds to the left mouse button. This would allow the user to trigger the left mouse button action by tapping the virtual button on the touchscreen. Similarly, other options in the dropdown could be mapped to virtual buttons on the touchscreen to allow users to trigger different mouse actions.
{
name: "Mouse",
value: "14",
subitems: [
{
name: "Left Mouse Button",
value: "1",
},
{
name: "Right Mouse Button",
value: "2",
},
{
name: "Middle Mouse Button",
value: "3",
},
{
name: "Scroll up",
value: "4",
},
{
name: "Scroll down",
value: "5",
},
{
name: "Scroll left",
value: "6",
},
{
name: "Scroll right",
value: "7",
},
],
},