mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[USB-BRINGUP]
- Implement mouse move detection, wheel state detection svn path=/branches/usb-bringup/; revision=54772
This commit is contained in:
parent
d4bb27774a
commit
012eac6d8f
2 changed files with 118 additions and 3 deletions
|
@ -28,6 +28,35 @@ static USHORT MouHid_ButtonUpFlags[] =
|
|||
MOUSE_BUTTON_5_UP
|
||||
};
|
||||
|
||||
VOID
|
||||
MouHid_GetButtonMove(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
OUT PLONG LastX,
|
||||
OUT PLONG LastY)
|
||||
{
|
||||
PMOUHID_DEVICE_EXTENSION DeviceExtension;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* get device extension */
|
||||
DeviceExtension = (PMOUHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
/* init result */
|
||||
*LastX = 0;
|
||||
*LastY = 0;
|
||||
|
||||
/* get scaled usage value x */
|
||||
Status = HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_X, (PLONG)&LastX, DeviceExtension->PreparsedData, DeviceExtension->Report, DeviceExtension->ReportLength);
|
||||
/* FIXME handle error */
|
||||
ASSERT(Status == HIDP_STATUS_SUCCESS);
|
||||
|
||||
/* get scaled usage value y */
|
||||
Status = HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_Y, (PLONG)&LastY, DeviceExtension->PreparsedData, DeviceExtension->Report, DeviceExtension->ReportLength);
|
||||
/* FIXME handle error */
|
||||
ASSERT(Status == HIDP_STATUS_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
MouHid_GetButtonFlags(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -146,6 +175,9 @@ MouHid_ReadCompletion(
|
|||
{
|
||||
PMOUHID_DEVICE_EXTENSION DeviceExtension;
|
||||
USHORT ButtonFlags;
|
||||
LONG UsageValue;
|
||||
NTSTATUS Status;
|
||||
LONG LastX, LastY;
|
||||
MOUSE_INPUT_DATA MouseInputData;
|
||||
|
||||
/* get device extension */
|
||||
|
@ -154,14 +186,34 @@ MouHid_ReadCompletion(
|
|||
/* get mouse change flags */
|
||||
MouHid_GetButtonFlags(DeviceObject, &ButtonFlags);
|
||||
|
||||
/* FIXME detect mouse move change */
|
||||
/* FIXME detect mouse wheel change */
|
||||
/* get mouse change */
|
||||
MouHid_GetButtonMove(DeviceObject, &LastX, &LastY);
|
||||
|
||||
/* init input data */
|
||||
RtlZeroMemory(&MouseInputData, sizeof(MOUSE_INPUT_DATA));
|
||||
|
||||
/* init input data */
|
||||
MouseInputData.ButtonFlags = ButtonFlags;
|
||||
MouseInputData.LastX = LastX;
|
||||
MouseInputData.LastY = LastY;
|
||||
|
||||
/* detect mouse wheel change */
|
||||
if (DeviceExtension->MouseIdentifier == WHEELMOUSE_HID_HARDWARE)
|
||||
{
|
||||
/* get usage */
|
||||
UsageValue = 0;
|
||||
Status = HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_WHEEL, &UsageValue, DeviceExtension->PreparsedData, DeviceExtension->Report, DeviceExtension->ReportLength);
|
||||
if (Status == HIDP_STATUS_SUCCESS)
|
||||
{
|
||||
/* store wheel status */
|
||||
MouseInputData.ButtonFlags |= MOUSE_WHEEL;
|
||||
MouseInputData.ButtonData = (USHORT)UsageValue; /* FIXME */
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("[MOUHID] failed to get wheel status with %x\n", Status);
|
||||
}
|
||||
}
|
||||
|
||||
/* dispatch mouse action */
|
||||
MouHid_DispatchInputData(DeviceObject, &MouseInputData);
|
||||
|
|
|
@ -12,26 +12,89 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// lower device object
|
||||
//
|
||||
PDEVICE_OBJECT NextDeviceObject;
|
||||
|
||||
//
|
||||
// irp which is used for reading input reports
|
||||
//
|
||||
PIRP Irp;
|
||||
|
||||
//
|
||||
// event
|
||||
//
|
||||
KEVENT Event;
|
||||
|
||||
//
|
||||
// device object for class callback
|
||||
//
|
||||
PDEVICE_OBJECT ClassDeviceObject;
|
||||
|
||||
//
|
||||
// class callback
|
||||
//
|
||||
PVOID ClassService;
|
||||
|
||||
//
|
||||
// mouse type
|
||||
//
|
||||
USHORT MouseIdentifier;
|
||||
|
||||
//
|
||||
// wheel usage page
|
||||
//
|
||||
USHORT WheelUsagePage;
|
||||
|
||||
//
|
||||
// usage list length
|
||||
//
|
||||
USHORT UsageListLength;
|
||||
|
||||
//
|
||||
// current usage list length
|
||||
//
|
||||
PUSAGE CurrentUsageList;
|
||||
|
||||
//
|
||||
// previous usage list
|
||||
//
|
||||
PUSAGE PreviousUsageList;
|
||||
|
||||
//
|
||||
// removed usage item list
|
||||
//
|
||||
PUSAGE BreakUsageList;
|
||||
|
||||
//
|
||||
// new item usage list
|
||||
//
|
||||
PUSAGE MakeUsageList;
|
||||
|
||||
//
|
||||
// preparsed data
|
||||
//
|
||||
PVOID PreparsedData;
|
||||
|
||||
//
|
||||
// mdl for reading input report
|
||||
//
|
||||
PMDL ReportMDL;
|
||||
|
||||
//
|
||||
// input report buffer
|
||||
//
|
||||
PUCHAR Report;
|
||||
|
||||
//
|
||||
// input report length
|
||||
//
|
||||
ULONG ReportLength;
|
||||
|
||||
|
||||
//
|
||||
// file object the device is reading reports from
|
||||
//
|
||||
PFILE_OBJECT FileObject;
|
||||
|
||||
}MOUHID_DEVICE_EXTENSION, *PMOUHID_DEVICE_EXTENSION;
|
||||
|
|
Loading…
Reference in a new issue