FreeTouchDeck with air mouse feature

a year ago, April 30, 2023
Reading time: 5 mins

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

  1. FreeTouchDeck setup from an earlier post.
  2. MPU-6050 accelerometer/gyroscope sensor module
FreeTouchDeck with air mouse feature
FreeTouchDeck setup ESP32 module + TFT LCD with touch
FreeTouchDeck with air mouse feature
MPU-6050 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.

FreeTouchDeck with air mouse feature
Added an option for Mouse page
FreeTouchDeck with air mouse feature
Options for mouse actions

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",
            },
          ],
        },

Premature demo

Air mouse feature on FreeTouchDeck
Previous
A cry for Help turns out a goat. ChatGPT continues the story with the help of Mid-journey and Firefly
Next
Live coding – Flappy Bird game using P5js
© 2024 Anil Maharjan