Using the ESP32 BLE Keyboard and ESP32 BLE Mouse libraries, the device works on all desktop and mobile operating systems without any other apps, software, or other tools installed on the master machine. Connecting K-Ability to any device simply by Bluetooth pairing.
I organized the program in tasks with FreeRTOS. Although it seems a complicated approach, I preferred to divide the various features of the code into different files and tasks, in order to make easier to copy/paste the code for other projects.
handles bluetooth connection. It checks for disconnection every second and reports events on the screen.
prints the battery status every 30 seconds. It will also handle the graphical representation of the battery status.
handles the events of the 7 buttons.
Right now the firmware manages capacitive buttons only, by using default Esp32 "Capacitive Touch Sensor Pins" (gpio 2, 4, 12, 13, 14, 15, 27, 32 and 33 ). One of the upcoming developments will give the possibility to use normal tactile buttons as well.
4 out of 7 work as directional buttons (top, bottom, right and left), the fifth one as enter/click button, the sixth on as select button and the last one as cancel button.
"Select" button allows browsing through all over functions of the firmware.
"Cancel" button returns to the default function.
In this task I manage each button by valuing a global variable. Each individual function is managed by the mouseKeyboardTask task.
handles all main firmware functions.
Up to now, the following functions have been implemented:
- Move and click, like a regular mouse
- Move and double click
- DragDrop, for e.g. moving or deleting app icons from the home screen, or doing "long mouse press" and cursor moves actions at same time.
- Scroll/Zoom, useful, both for vertical scroll and for zooming a photo in the gallery
- Swipe, both vertical and horizontal, useful for scrolling photos in the gallery or, for example, reels in instagram.
All keyboard-related functions will be documented and committed later
showOnDisplay(), refreshScreenState(), startDisplay()
I used T-Display tft screen to get visual feedback from the program.
Getting access to functions from all parts of the firmware, I did not create a screen management task,.
These 3 functions initialize, display and refresh graphics on the screen.
Who hasn't a screen, just comment out these 3 functions and the TFT_eSPI library.
To better understand how it works, I share this old video. Of course the technology is different but the mechanism of operation is identical.