// Use STARTUP() macro to avoid USB disconnect/reconnect (see begin() documentation)

void setup() {
  // Set screen size to 1920x1080 (to scale [0, 32767] absolute Mouse coordinates)
  Mouse.screenSize(1920, 1080);
  // Move mouse to the center of the screen and click left button
  Mouse.moveTo(1920 / 2, 1080 / 2);;
  // Move mouse from the current position by 100 points (not pixels) left
  Mouse.move(-100, 0);
  // Press right mouse button (and leave it pressed);
  // Scroll wheel in the negative direction
  // Release right mouse button

void loop() {

Since 0.6.0:

This object allows devices to act as a native USB HID Mouse.

In terms of USB HID, the device presents itself as two separate devices: Mouse (supporting relative movement) and Digitizer (supporting absolute movement).

Full capabilities include:

  • Relative XY movement [-32767, 32767]
  • Absolute XY movement [0, 32767]
  • 3-buttons (left, right, middle)
  • Wheel [-127, 127]

NOTE: Linux X11 doesn't support HID devices reporting both absolute and relative coordinates. By default only absolute movement is possible by using Mouse.moveTo(). In order for regular relative Mouse.move() to work, a call to Mouse.enableMoveTo(false) is required.

Gen 2 Devices (E Series, Electron, Photon, and P2; does not include E404X):

Mouse and Keyboard are available only on Gen 2 devices (Photon, P1, Electron, and E Series).

These features are not available on the P2, Photon 2, or Gen 3 devices (Argon, Boron, B Series SoM, Tracker SoM).