Firmware flow
How a joystick creates left and right key presses
Selected horizontal-axis Bluetooth keyboard handling.
When Bluetooth is connected, read the joystick and ignore small horizontal movement. A larger movement sends the matching arrow key, waits 150 ms and releases the keys.
The snippet reads both axes but only shows horizontal key handling. It does not establish behaviour after disconnection or the complete keyboard mapping.
Read the implementation
loop excerpt · selected source lines 40–58. Source inspection is not a hardware test.
void loop() {
// Ensure BLE keyboard is connected
if (bleKeyboard.isConnected()) {
// Read joystick values
int joystickX = analogRead(JOYSTICK_X) - 2048; // Adjust for ESP32 ADC range
int joystickY = analogRead(JOYSTICK_Y) - 2048;
// Handle joystick movements
if (abs(joystickX) > DEADZONE) {
if (joystickX > 0) {
bleKeyboard.press(KEY_RIGHT_ARROW); // Joystick moved RIGHT
Serial.println("Joystick RIGHT");
} else {
bleKeyboard.press(KEY_LEFT_ARROW); // Joystick moved LEFT
Serial.println("Joystick LEFT");
}
delay(150);
bleKeyboard.releaseAll(); // Release after press
}Open the exact source-level diagramTechnical notes
Input-to-key mapping
The firmware translates local control actions into keyboard input for the host.
BLE host connection
BLE carries keyboard input between the ESP32 and its host.
Keyboard interface scope
The module provides an embedded keyboard interface for custom controls used with applications that accept keyboard input.