I’m working on HID Minidriver. Problem that im trying to solve requires me to use absolute mouse in report descriptor (shown below).
// Mouse with 3 buttons, middle button is wheel
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x02, // USAGE (Mouse)
0xA1, 0x01, // COLLECTION (Application)
0x85, REPORTID_ABSOLUTEMOUSE, // REPORT_ID (2)
0x09, 0x01, // USAGE (Pointer)
0xA1, 0x00, // COLLECTION (Physical)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x03, // USAGE_MAXIMUM (Button 3)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x75, 0x01, // REPORT_SIZE (1 bit)
0x95, 0x03, // REPORT_COUNT (3)
0x81, 0x02, // INPUT (Data, Variable, Absolute)
0x95, 0x05, // REPORT_COUNT (5 bits padding)
0x81, 0x03, // INPUT (Constant, Variable, Absolute)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x27, 0xFF, 0xFF, 0x00, 0x00, // LOGICAL_MAXIMUM (65535)
0x75, 0x10, // REPORT_SIZE (16 bits)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x02, // INPUT (Data, Variable, Absolute)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x38, // USAGE (Wheel)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x27, 0xFF, 0xFF, 0x00, 0x00, // LOGICAL_MAXIMUM (65535)
0x75, 0x10, // REPORT_SIZE (16 bits)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x02, // INPUT (Data, Variable, Absolute)
0xC0, // END_COLLECTION
0xC0 // END_COLLECTION
User mode app normalize X, Y data to 0 - 65535 and send it to minidriver, which further use hid reports to send data to HIDCLASS.
PROBLEM:
I used the code below to normalize screen X, Y coordinates to range 0 - 65535.
Mouse Cursor moved but at arbitrary positions.
normalizedX = (int)(x * (65535 / (float) GetSystemMetrics(SM_CXSCREEN)));
normalizedY = (int)(y * (65535 / (float) GetSystemMetrics(SM_CYSCREEN)));
Then i used the following code to normalize X, Y. Now mouse cursor move properly, but it only move upto half of the screen horizontally and vertically.
normalizedX = (int)(x * (32767 / (float) GetSystemMetrics(SM_CXSCREEN)));
normalizedY = (int)(y * (32767 / (float) GetSystemMetrics(SM_CYSCREEN)));
Is there any trick that I’m missing to send absolute mouse data so that mouse cursor moves on entire desktop.
Thanks