Author: janderwald
Date: Sun May 19 17:29:15 2013
New Revision: 59044
URL:
http://svn.reactos.org/svn/reactos?rev=59044&view=rev
Log:
[MOUHID]
- Cleanup code
- Fix distinguation between relative and absolute mice
- Tested by Timo (Blame him ;))
Modified:
trunk/reactos/drivers/hid/mouhid/mouhid.c
trunk/reactos/drivers/hid/mouhid/mouhid.h
Modified: trunk/reactos/drivers/hid/mouhid/mouhid.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/hid/mouhid/mouhid.…
==============================================================================
--- trunk/reactos/drivers/hid/mouhid/mouhid.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/hid/mouhid/mouhid.c [iso-8859-1] Sun May 19 17:29:15 2013
@@ -30,6 +30,7 @@
MOUSE_BUTTON_5_UP
};
+
VOID
MouHid_GetButtonMove(
IN PMOUHID_DEVICE_EXTENSION DeviceExtension,
@@ -43,8 +44,10 @@
*LastX = 0;
*LastY = 0;
- /* get scaled usage value x */
- Status = HidP_GetScaledUsageValue(HidP_Input,
+ if (!DeviceExtension->MouseAbsolute)
+ {
+ /* get scaled usage value x */
+ Status = HidP_GetScaledUsageValue(HidP_Input,
HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED,
HID_USAGE_GENERIC_X,
@@ -52,16 +55,17 @@
DeviceExtension->PreparsedData,
DeviceExtension->Report,
DeviceExtension->ReportLength);
- if (Status != HIDP_STATUS_SUCCESS)
- {
- /* FIXME: handle more errors */
- if (Status == HIDP_STATUS_BAD_LOG_PHY_VALUES)
+
+ if (Status != HIDP_STATUS_SUCCESS)
{
- /* FIXME: assume it operates in absolute mode */
- DeviceExtension->MouseAbsolute = TRUE;
-
- /* get unscaled value */
- Status = HidP_GetUsageValue(HidP_Input,
+ /* FIXME: handle more errors */
+ if (Status == HIDP_STATUS_BAD_LOG_PHY_VALUES)
+ {
+ /* FIXME: assume it operates in absolute mode */
+ DeviceExtension->MouseAbsolute = TRUE;
+
+ /* get unscaled value */
+ Status = HidP_GetUsageValue(HidP_Input,
HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED,
HID_USAGE_GENERIC_X,
@@ -70,18 +74,45 @@
DeviceExtension->Report,
DeviceExtension->ReportLength);
- /* FIXME handle error */
- ASSERT(Status == HIDP_STATUS_SUCCESS);
-
- /* absolute pointing devices values need be in range 0 - 0xffff */
- ASSERT(DeviceExtension->ValueCapsX.LogicalMax > 0);
-
- *LastX = (ValueX * 0xFFFF) / DeviceExtension->ValueCapsX.LogicalMax;
+ /* FIXME handle error */
+ ASSERT(Status == HIDP_STATUS_SUCCESS);
+
+ /* absolute pointing devices values need be in range 0 - 0xffff */
+ ASSERT(DeviceExtension->ValueCapsX.LogicalMax > 0);
+ ASSERT(DeviceExtension->ValueCapsX.LogicalMax >
DeviceExtension->ValueCapsX.LogicalMin);
+
+ /* convert to logical range */
+ *LastX = (ValueX * VIRTUAL_SCREEN_SIZE_X) /
DeviceExtension->ValueCapsX.LogicalMax;
+ }
}
}
-
- /* get scaled usage value y */
- Status = HidP_GetScaledUsageValue(HidP_Input,
+ else
+ {
+ /* get unscaled value */
+ Status = HidP_GetUsageValue(HidP_Input,
+ HID_USAGE_PAGE_GENERIC,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ HID_USAGE_GENERIC_X,
+ &ValueX,
+ DeviceExtension->PreparsedData,
+ DeviceExtension->Report,
+ DeviceExtension->ReportLength);
+
+ /* FIXME handle error */
+ ASSERT(Status == HIDP_STATUS_SUCCESS);
+
+ /* absolute pointing devices values need be in range 0 - 0xffff */
+ ASSERT(DeviceExtension->ValueCapsX.LogicalMax > 0);
+ ASSERT(DeviceExtension->ValueCapsX.LogicalMax >
DeviceExtension->ValueCapsX.LogicalMin);
+
+ /* convert to logical range */
+ *LastX = (ValueX * VIRTUAL_SCREEN_SIZE_X) /
DeviceExtension->ValueCapsX.LogicalMax;
+ }
+
+ if (!DeviceExtension->MouseAbsolute)
+ {
+ /* get scaled usage value y */
+ Status = HidP_GetScaledUsageValue(HidP_Input,
HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED,
HID_USAGE_GENERIC_Y,
@@ -89,16 +120,17 @@
DeviceExtension->PreparsedData,
DeviceExtension->Report,
DeviceExtension->ReportLength);
- if (Status != HIDP_STATUS_SUCCESS)
- {
- // FIXME: handle more errors
- if (Status == HIDP_STATUS_BAD_LOG_PHY_VALUES)
+
+ if (Status != HIDP_STATUS_SUCCESS)
{
- // assume it operates in absolute mode
- DeviceExtension->MouseAbsolute = TRUE;
-
- // get unscaled value
- Status = HidP_GetUsageValue(HidP_Input,
+ // FIXME: handle more errors
+ if (Status == HIDP_STATUS_BAD_LOG_PHY_VALUES)
+ {
+ // assume it operates in absolute mode
+ DeviceExtension->MouseAbsolute = TRUE;
+
+ // get unscaled value
+ Status = HidP_GetUsageValue(HidP_Input,
HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED,
HID_USAGE_GENERIC_Y,
@@ -107,13 +139,39 @@
DeviceExtension->Report,
DeviceExtension->ReportLength);
- /* FIXME handle error */
- ASSERT(Status == HIDP_STATUS_SUCCESS);
-
- /* absolute pointing devices values need be in range 0 - 0xffff */
- ASSERT(DeviceExtension->ValueCapsY.LogicalMax);
- *LastY = (ValueY * 0xFFFF) / DeviceExtension->ValueCapsY.LogicalMax;
+ /* FIXME handle error */
+ ASSERT(Status == HIDP_STATUS_SUCCESS);
+
+ /* absolute pointing devices values need be in range 0 - 0xffff */
+ ASSERT(DeviceExtension->ValueCapsY.LogicalMax > 0);
+ ASSERT(DeviceExtension->ValueCapsY.LogicalMax >
DeviceExtension->ValueCapsY.LogicalMin);
+
+ /* convert to logical range */
+ *LastY = (ValueY * VIRTUAL_SCREEN_SIZE_Y) /
DeviceExtension->ValueCapsY.LogicalMax;
+ }
}
+ }
+ else
+ {
+ // get unscaled value
+ Status = HidP_GetUsageValue(HidP_Input,
+ HID_USAGE_PAGE_GENERIC,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ HID_USAGE_GENERIC_Y,
+ &ValueY,
+ DeviceExtension->PreparsedData,
+ DeviceExtension->Report,
+ DeviceExtension->ReportLength);
+
+ /* FIXME handle error */
+ ASSERT(Status == HIDP_STATUS_SUCCESS);
+
+ /* absolute pointing devices values need be in range 0 - 0xffff */
+ ASSERT(DeviceExtension->ValueCapsY.LogicalMax > 0);
+ ASSERT(DeviceExtension->ValueCapsY.LogicalMax >
DeviceExtension->ValueCapsY.LogicalMin);
+
+ /* convert to logical range */
+ *LastY = (ValueY * VIRTUAL_SCREEN_SIZE_Y) /
DeviceExtension->ValueCapsY.LogicalMax;
}
}
@@ -323,7 +381,7 @@
DeviceExtension->Report[3] & 0xFF, DeviceExtension->Report[4] &
0xFF,
DeviceExtension->Report[5] & 0xFF, DeviceExtension->Report[6] &
0xFF);
- DPRINT("[MOUHID] LastX %ld LastY %ld Flags %x ButtonData %x\n",
MouseInputData.LastX, MouseInputData.LastY, MouseInputData.ButtonFlags,
MouseInputData.ButtonData);
+ DPRINT("[MOUHID] LastX %ld LastY %ld Flags %x ButtonFlags %x ButtonData
%x\n", MouseInputData.LastX, MouseInputData.LastY, MouseInputData.Flags,
MouseInputData.ButtonFlags, MouseInputData.ButtonData);
/* dispatch mouse action */
MouHid_DispatchInputData(DeviceExtension, &MouseInputData);
@@ -888,6 +946,14 @@
}
}
+ /* check if mice is absolute */
+ if (DeviceExtension->ValueCapsY.LogicalMax >
DeviceExtension->ValueCapsY.LogicalMin ||
+ DeviceExtension->ValueCapsX.LogicalMax >
DeviceExtension->ValueCapsX.LogicalMin)
+ {
+ /* mice is absolute */
+ DeviceExtension->MouseAbsolute = TRUE;
+ }
+
/* completed successfully */
return STATUS_SUCCESS;
}
Modified: trunk/reactos/drivers/hid/mouhid/mouhid.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/hid/mouhid/mouhid.…
==============================================================================
--- trunk/reactos/drivers/hid/mouhid/mouhid.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/hid/mouhid/mouhid.h [iso-8859-1] Sun May 19 17:29:15 2013
@@ -132,6 +132,8 @@
} MOUHID_DEVICE_EXTENSION, *PMOUHID_DEVICE_EXTENSION;
#define WHEEL_DELTA 120
+#define VIRTUAL_SCREEN_SIZE_X (65536)
+#define VIRTUAL_SCREEN_SIZE_Y (65536)
NTSTATUS
MouHid_InitiateRead(