mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 18:24:24 +00:00
[MOUHID]
- Cleanup code - Fix distinguation between relative and absolute mice - Tested by Timo (Blame him ;)) svn path=/trunk/; revision=59044
This commit is contained in:
parent
deed915ead
commit
649ac591bb
|
@ -30,6 +30,7 @@ static USHORT MouHid_ButtonDownFlags[] =
|
|||
MOUSE_BUTTON_5_UP
|
||||
};
|
||||
|
||||
|
||||
VOID
|
||||
MouHid_GetButtonMove(
|
||||
IN PMOUHID_DEVICE_EXTENSION DeviceExtension,
|
||||
|
@ -43,8 +44,10 @@ MouHid_GetButtonMove(
|
|||
*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 @@ MouHid_GetButtonMove(
|
|||
DeviceExtension->PreparsedData,
|
||||
DeviceExtension->Report,
|
||||
DeviceExtension->ReportLength);
|
||||
if (Status != HIDP_STATUS_SUCCESS)
|
||||
{
|
||||
/* 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,
|
||||
if (Status != HIDP_STATUS_SUCCESS)
|
||||
{
|
||||
/* 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 @@ MouHid_GetButtonMove(
|
|||
DeviceExtension->Report,
|
||||
DeviceExtension->ReportLength);
|
||||
|
||||
/* FIXME handle error */
|
||||
ASSERT(Status == HIDP_STATUS_SUCCESS);
|
||||
/* FIXME handle error */
|
||||
ASSERT(Status == HIDP_STATUS_SUCCESS);
|
||||
|
||||
/* absolute pointing devices values need be in range 0 - 0xffff */
|
||||
ASSERT(DeviceExtension->ValueCapsX.LogicalMax > 0);
|
||||
/* absolute pointing devices values need be in range 0 - 0xffff */
|
||||
ASSERT(DeviceExtension->ValueCapsX.LogicalMax > 0);
|
||||
ASSERT(DeviceExtension->ValueCapsX.LogicalMax > DeviceExtension->ValueCapsX.LogicalMin);
|
||||
|
||||
*LastX = (ValueX * 0xFFFF) / DeviceExtension->ValueCapsX.LogicalMax;
|
||||
/* convert to logical range */
|
||||
*LastX = (ValueX * VIRTUAL_SCREEN_SIZE_X) / DeviceExtension->ValueCapsX.LogicalMax;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
/* get scaled usage value y */
|
||||
Status = HidP_GetScaledUsageValue(HidP_Input,
|
||||
/* 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 @@ MouHid_GetButtonMove(
|
|||
DeviceExtension->PreparsedData,
|
||||
DeviceExtension->Report,
|
||||
DeviceExtension->ReportLength);
|
||||
if (Status != HIDP_STATUS_SUCCESS)
|
||||
{
|
||||
// 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,
|
||||
if (Status != HIDP_STATUS_SUCCESS)
|
||||
{
|
||||
// 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,14 +139,40 @@ MouHid_GetButtonMove(
|
|||
DeviceExtension->Report,
|
||||
DeviceExtension->ReportLength);
|
||||
|
||||
/* FIXME handle error */
|
||||
ASSERT(Status == HIDP_STATUS_SUCCESS);
|
||||
/* 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;
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -323,7 +381,7 @@ MouHid_ReadCompletion(
|
|||
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 @@ MouHid_StartDevice(
|
|||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -132,6 +132,8 @@ typedef struct
|
|||
} 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(
|
||||
|
|
Loading…
Reference in a new issue