As suggested in the comments, I edited the core libraries to achieve this.
I'm using PlatformIO, so the library files I needed to edit were here:
~/.platformio/packages/framework-arduinoavr/libraries/Mouse/src/
And the required changes (to change a wheel
parameter for horizontal (h
) and vertical (v
) scroll parameters were as follows:
Mouse.h
Change the declaration of move()
:
...
void move(signed char x, signed char y, signed char h = 0, signed char v = 0);
...
Mouse.cpp
Add the following to the report descriptor after the last INPUT
message:
...
0x05, 0x0c, // USAGE PAGE (Consumer Devices)
0x0a, 0x38, 0x02, // USAGE (AC Pan)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x06, // INPUT (Data, Var, Rel)
...
Change the definition of move()
:
void Mouse_::move(signed char x, signed char y, signed char h, signed char v)
{
uint8_t m[5];
m[0] = _buttons;
m[1] = x;
m[2] = y;
m[3] = v;
m[4] = h;
HID().SendReport(1, m, 5);
}
The following terminal commands were also useful in testing these changes:
# List input devices
xinput --list
# List device capabilities
xinput --list <device-id>
# Watch for data sent from the device
watch -n 0.1 xinput query-state <device-id>