Hi all! I'm glad to present to you, a new release! Source & binary installer is available at the bottom.
VERY IMPORTANT for users that compile their own binaries: Due to a lack of configuration options in ESP-IDF, multi-device support may not work if using a version below release v5.3 of ESP-IDF for compiling. ESPRESSIF added a new option to set CONFIG_BT_GATTC_NOTIF_REG_MAX to a number of at least 20 notification subscriptions which is crucial. USING RELEASE v5.3 IS NEEDED/RECOMMENDED for multidevice support! Also be sure to include the 'sdkconfigs.default' file included in the release!
Binary pins setup:
const int KB_CLK_PIN = 22
const int KB_DATA_PIN = 23
const int MOUSE_CLK_PIN = 26
const int MOUSE_DATA_PIN = 25
SERIAL_MOUSE_RS232_RTS = 15
static const int SERIAL_MOUSE_RS232_RX = 4
v0.7 release notes
SERIAL MOUSE SUPPORT
Serial mouse is now supported! For it to work, a TTL to RS232 adapter (FEMALE) is needed, as the ESP32 is unable to output the voltage levels necessary for serial communication to work.
The TTL-to-Serial adapter will need ground & power connection. For this connect the adapter to the 3.3v pin on the ESP32. The other two pins are RTS (serial pin 7) and RxD (serial pin 2). This is very confusing and the adaptor may label them differently, so pay attention when making the connections or ask me. Photos and video on this will be coming soon.
SERIAL MOUSE AUTODETECTION
The system will detect if a serial adapter is connected by monitoring the levels on the RTS pin. When serial is connected and mouse operational, the adapter should drop RTS to ground on the ESP32 side (high on the serial side). Mouse output will be via SERIAL if RTS is LOW on ESP32 side, and PS/2 if HIGH on ESP32 side. Pullup resistor is enabled on this pin so it will be HIGH when disconnected. DO NOT connect anything to it if not using serial mouse.
FREERTOS TASKS AND CORE WORKLOAD OPTIMIZATION
Mouse tasks are assigned to core 1, both PS/2 and serial. PS/2 Keyboard tasks are assigned to core 0. This improves performance and makes using KB and Mouse at the same time possible and with no lag.
For the users that adapt the code to other variants, please have in mind that simultaneous use of KB and MOUSE may be laggy because other ESP32 variants are not dual core.
v0.6 release notes
PS/2 MOUSE SUPPORT
By popular request, now mouse emulation is supported alongside keyboard emulation! For this, a dual bus is used and the pins must be configured accordingly. As always, check what you are doing with them and remember not all pins are suitable out of the box. For example, pins 12 & 13 are strapping pins and the board will not boot if voltage is present on them at startup. Also, applying voltage to pins 1 & 3 (U0 TXD and RXD) could cause the serial communication not to work, thus making serial console output impossible.
I personally use pins 12 & 13 because I've blown the E-FUSE to disable their strapping function (check README on the project main page), so I can solder a connector to have power & data all in a row and power the board from one cable. Pins 25 & 26 are great for the other bus because applying power to 14 & 27 won't cause any problems, so I can interchange the cables if I need and have all two
buses in a row.
If you have a combined port (mouse + keyboard shared connector) in your device, you can connect both at the same time if you buy a Y-splitter cable, or you can make your own. In these ports there's an extra bus hidden in the normally not-used/unassigned pins. Search online for info or ask me.
MULTI DEVICE SUPPORT
Naturally with mouse support we want to use a keyboard at the same time. Now the board isn't tied to a single device, so you can pair as many as you want and have them connected at any time during execution.
Once powered up, the board will enter pairing mode as usual. In this mode it will try both to pair with a new device (mouse or keyboard) or connect to an already paired one. After either one has connected and the board started, you can re-enter pairing mode and add more devices.
All the paired devices can be connected and disconnected during execution with no user input needed, both BT Classic and BLE, no need to enter pairing mode for that. BLE scanning is continuous since these devices need discovery from the board, not like BT Classic as they connect directly.
NEW FAST BOOT MODE & PAIRING-ON-DEMAND
The new variable 'const bool pairing_at_startup = true;' is now available at 'main.cpp'. Using 'false' will skip pairing mode at startup and go straight to main loop. This speeds up the boot process, much more if using a BT Classic device as they tare slower to exit the pairing loop, even if previously paired.
Pairing mode can be invoked on-demand at any point in execution (while the LED is on). Pressing the BOOT button on the board, effectively shorting GPIO_0 to ground, will enter pairing mode and turn the main LED off. If entered by mistake, pairing can be aborted by pressing the button again and holding it for 3 seconds, then main LED will be on again and pairing disabled. Note that pairing-abortion won't work on the startup pairing loop if 'pairing_at_startup' is enabled, it only works for pairing loops invoked form execution, while the LED is already lit.
MULTIMEDIA KEY SUPPORT
For keyboards that have multimedia keys, now they're processed and translated to the corresponding PS/2 codes. Note that very old operating systems like Windows 95/98 may not recognize them and may not work. I tested them on Windows 10.
Also note that the USB HID specification (the one that gets transported by Bluetooth), supports a lot more of multimedia key usages/types than the PS/2 multimedia key extension. I only mapped the ones supported on the PS/2 protocol, like play/pause, volume up/down, internet browser, mail app, etc. Other more specialized multimedia keys may not be supported by the PS/2 standard and won't do anything if pressed, this is expected. If you want to map any multimedia key to a special behaviour, even make them do macro functions, you can make that by editing the 'keyHid_send_CCONTROL()' function in 'esp32_ps2dev.cpp', which is the function that controls USB HID to PS/2 translation. If you need help with this, ask me.
BUG FIXES AND OPTIMIZATIONS
Many bugs have been fixed during development and optimizations made. I can't remember all of them. For example:
- A bug has been fixed where some random keys won't work, like C.
- PS/2 host responses for mouse have been optimized.
- The push_key() function now detects the BOOT/REPORT mode on the keboard report and changes the offset accordingly. Some odd keyboards had problems with this.
- Now the keys and mouse loops run continuously and won't stop, even when pairing-on-demand is entered.
- Mouse loop has it's own RTOS task with high priority.
- High/normal precision mouse reports are supported.
- Now connection supervision time is checked on every connection. If less than 1.2 sec connection parameters will be updated. Some keyboards like Draconic K530 used too-low settings for this and disconnected a lot.
- Many more things.