With the introduction of the Arduino Leonardo and other ATMega32u4 based boards, Arduino introduced 3 new libraries HID.h, Mouse.h and Keyboard.h which allowed you to emulate a mouse or keyboard connected by USB to your computer. HID stands for "Human Interface Device" and refers to not only mouse and keyboard but other devices such as touchpads and game controllers. This opened up a world of possibilities especially for assistive technology applications for the disabled who need alternative ways to operate a computer.
This capability was extended when boards featuring the M0 (SAMD21 based) and M4 (SAMD51 based) systems became available. They were also able to perform mouse and keyboard emulation using the Arduino API originally developed for the Leonardo.
Newer boards and microprocessors have migrated to a new type of USB interface called TinyUSB. It is likely that most future boards will take advantage benefits of the TinyUSB platform. Additionally many new boards provide Bluetooth BLE capability that can emulate Bluetooth mouse and keyboard devices. Both TinyUSB and Adafruit Bluefruit libraries have powerful capabilities for emulating mouse and keyboard. However these APIs are not fully compatible with the old traditional Arduino Mouse.h and Keyboard.h APIs. Lots of legacy code has been written using these older Arduino APIs.
In this tutorial, 2 new libraries are presented which convert the traditional Arduino APIs into calls to the newer TinyUSB and Bluefruit commands. Although TinyUSB and Bluefruit HID interfaces provide capability not available in the traditional Arduino Mouse.h and Keyboard.h interfaces, these new conversion libraries will let you run legacy code and will be a stepping stone for new users to become familiar with mouse and keyboard emulation using a simpler interface. Using these simpler libraries does not require as much direct knowledge of USB and BLE protocols.
In the next section we will take a brief look at the traditional Arduino mouse and keyboard classes.
The parts may be any microcontroller compatible with TinyUSB. For Bluetooth use, this currently requires a nRF52840 microcontroller-based board. The following board is representable of the board that will work. See the TinyUSB GitHub repo for compatible microcontrollers.