I’m working on a project to reuse a laptop touchpad. I’m interfacing it with an Atmel Mega32u4 microcontroller and present it as a USB HID mouse to the host.
Everything is functioning well. But I’m a little unhappy with the scrolling. Even if I send an HID report to the host with a scroll amount of 1, scrolling is still a little “jumpy”. I tested it on VS code and some other text editors on macOS. It scrolls one line at a time.
However, if I use the built-in trackpad, I’m able to scroll at a finer granularity. I can easily scroll half a line or even less with one movement. Noted that with a real mouse with a wheel, I am also only able to scroll one line with one detent.
But the behavior of the trackpad makes me suspect that finer control is achievable through USB HID. The trackpad is seen as a USB HID device on macOS.
I defined my USB HID report descriptor like this, which was basically copied from Linux kernel
// Mouse
0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 54
0x09, 0x02, // USAGE (Mouse)
0xa1, 0x01, // COLLECTION (Application)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x85, 0x01, // REPORT_ID (1)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x03, // USAGE_MAXIMUM (Button 3)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x95, 0x03, // REPORT_COUNT (3)
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x05, // REPORT_SIZE (5)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x09, 0x38, // USAGE (Wheel)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x03, // REPORT_COUNT (3)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
I’m sure the answer is somewhere in the USB spec. But can someone point me a rough direction where to look in the hundreds of pages? Thanks.