HID Report Descriptor, Absolute mouse mapping

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

Is this occurring on a machine with more than one monitor? Absolute
mouse positioning absolute to the entire virtual desktop. Mouhid will
normalize the mouse data to the range of 0->65535 for you based on your
logical min/max range of X and Y

d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: Wednesday, April 11, 2007 7:03 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] HID Report Descriptor, Absolute mouse mapping

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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

It’s slightly complicated and involve two different HID report descriptors (second being pen digitizer report descriptor for tablet pc).
Let me elaborate more. With the report descriptor in my original post i use following code to nomalize X, Y

normalizedX = (int)(x * (32767 / (float) GetSystemMetrics(SM_CXSCREEN)));
normalizedY = (int)(y * (32767 / (float) GetSystemMetrics(SM_CYSCREEN)));

and mouse works on primary monitor. But if i send X, Y from second monitor (X, Y after normalize is > 32767) mouse appears on left edge of primary monitor.

In report descriptor i specified LOGICAL_MAXIMUM (65535). Then why any normalized X, Y > 32767 make cursor appears on left edge of primary monitor rather than appearing on second monitor?

> Mouhid will normalize the mouse data to the range of 0->65535 for you based on your logical min/max range of X and Y

Is that mean i don’t have to nomalize X, Y data and simply send desktop X, Y coordinate in report.

Thanks,

> Is that mean i don’t have to nomalize X, Y data and simply send
desktop X, Y coordinate in report
No, mouhid has no idea about what the desktop layout is, GDI knows that.
Mouhid just reports absolute data in the range of 0->65535 and GDI maps
this to the desktop coordinates. So, this means that if you report a
physical (not logical) range of 0-100 and report 50, mouhid would
normalize the X value to (50*65535)/100. IIRC, the RIT then maps the
coordinates in the range from 0-65525 to the entire virtual desktop, but
it could map them to just the primary.

d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: Wednesday, April 11, 2007 8:26 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] HID Report Descriptor, Absolute mouse mapping

It’s slightly complicated and involve two different HID report
descriptors (second being pen digitizer report descriptor for tablet
pc).
Let me elaborate more. With the report descriptor in my original post i
use following code to nomalize X, Y

normalizedX = (int)(x * (32767 / (float)
GetSystemMetrics(SM_CXSCREEN)));
normalizedY = (int)(y * (32767 / (float)
GetSystemMetrics(SM_CYSCREEN)));

and mouse works on primary monitor. But if i send X, Y from second
monitor (X, Y after normalize is > 32767) mouse appears on left edge of
primary monitor.

In report descriptor i specified LOGICAL_MAXIMUM (65535). Then why any
normalized X, Y > 32767 make cursor appears on left edge of primary
monitor rather than appearing on second monitor?

> Mouhid will normalize the mouse data to the range of 0->65535 for you
based on your logical min/max range of X and Y

Is that mean i don’t have to nomalize X, Y data and simply send desktop
X, Y coordinate in report.

Thanks,


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

okay, if i modify descriptor to following

// USAGE (X)
// LOGICAL_MINIMUM (0)
// LOGICAL_MAXIMUM (65535)
// PHYSICAL_MINIMUM (0)
// PHYSICAL_MAXIMUM (65535)

And i have dual monitor, each with 1280x1024 resolution. Lets say I’m going to send X from second monitor, X coordinate value being 2000. I do the normalization.

(2000 * 65535)/(1280 + 1280) => 51199

And I send 51199 in report as absolute X.
Mouhid would normalize X to (51199 * 65535)/65535 => 51199

As you said IIRC, the RIT then maps 51199 to entire virtual desktop and cursor will show up on second monitor.

But what i’ve seen (correct me if wrong) if i send normalized X value > 32767 in report, cursor shows up on left edge of primary monitor.

> but it could map them to just the primary

Is there any defined behavior, when IIRC, the RIT would map entire virtual desktop to just primary monitor even though second monitor is connected.