Mouse

screenSize()

Mouse.screenSize, screenSize

// SYNTAX
Mouse.screenSize(screenWidth, screenHeight);
Mouse.screenSize(screenWidth, screenHeight,
                 marginLeft, marginRight,
                 marginTop, marginBottom);
Mouse.screenSize(screenWidth, screenHeight,
                 std::array<4, float>);

Maps the default absolute movement range [0, 32767] used by moveTo() to actual screen resolution. After setting the screen size, moveTo() will accept screen coordinates and automatically map them to the default range.

// EXAMPLE USAGE
// Use STARTUP() macro to avoid USB disconnect/reconnect (see begin() documentation)
STARTUP(Mouse.begin());

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
  Mouse.moveTo(1920 / 2, 1080 / 2);
}

void loop() {
}

Parameters:

  • screenWidth: screen width in pixels - uint16_t
  • screenHeight: screen height in pixels - uint16_t
  • marginLeft: (optional) left screen margin in percent (e.g. 10.0) - float
  • marginRight: (optional) right screen margin in percent (e.g. 10.0) - float
  • marginTop: (optional) top screen margin in percent (e.g. 10.0) - float
  • marginBottom: (optional) bottom screen margin in percent (e.g. 10.0) - float

screenSize() does not return anything.