Author: janderwald Date: Wed Dec 28 11:36:05 2011 New Revision: 54772
URL: http://svn.reactos.org/svn/reactos?rev=54772&view=rev Log: [USB-BRINGUP] - Implement mouse move detection, wheel state detection
Modified: branches/usb-bringup/drivers/hid/mouhid/mouhid.c branches/usb-bringup/drivers/hid/mouhid/mouhid.h
Modified: branches/usb-bringup/drivers/hid/mouhid/mouhid.c URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/mouhid/m... ============================================================================== --- branches/usb-bringup/drivers/hid/mouhid/mouhid.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/hid/mouhid/mouhid.c [iso-8859-1] Wed Dec 28 11:36:05 2011 @@ -29,6 +29,35 @@ };
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, OUT PUSHORT ButtonFlags) @@ -146,6 +175,9 @@ { PMOUHID_DEVICE_EXTENSION DeviceExtension; USHORT ButtonFlags; + LONG UsageValue; + NTSTATUS Status; + LONG LastX, LastY; MOUSE_INPUT_DATA MouseInputData;
/* get device extension */ @@ -154,14 +186,34 @@ /* 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);
Modified: branches/usb-bringup/drivers/hid/mouhid/mouhid.h URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/mouhid/m... ============================================================================== --- branches/usb-bringup/drivers/hid/mouhid/mouhid.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/hid/mouhid/mouhid.h [iso-8859-1] Wed Dec 28 11:36:05 2011 @@ -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;