usb hid: implement horizontal scrollwheel
- Fix USB_hid_page_consumer.h: some values are skipped in the spec so our defines were off - Handle the horizontal wheel on my mouse which is declared as a CON_AC_PAN, but otherwise works just like the vertical wheel - Input server and interface kit already handle the events properly (they were available for serial mice already). Change-Id: Ie0080ebb27e9478bcfe9f9dc5fd2a936ae05a848 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2201 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
8a0fd7e14e
commit
a206dcc221
@@ -263,7 +263,7 @@ enum {
|
||||
B_HID_UID_CON_AC_SAVE,
|
||||
B_HID_UID_CON_AC_PRINT,
|
||||
B_HID_UID_CON_AC_PROPERTIES,
|
||||
B_HID_UID_CON_AC_UNDO,
|
||||
B_HID_UID_CON_AC_UNDO = 0x21A,
|
||||
B_HID_UID_CON_AC_COPY,
|
||||
B_HID_UID_CON_AC_CUT,
|
||||
B_HID_UID_CON_AC_PASTE,
|
||||
|
||||
@@ -32,6 +32,7 @@ MouseProtocolHandler::MouseProtocolHandler(HIDReport &report,
|
||||
fXAxis(xAxis),
|
||||
fYAxis(yAxis),
|
||||
fWheel(NULL),
|
||||
fHorizontalPan(NULL),
|
||||
|
||||
fLastButtons(0),
|
||||
fClickCount(0),
|
||||
@@ -54,8 +55,11 @@ MouseProtocolHandler::MouseProtocolHandler(HIDReport &report,
|
||||
|
||||
fWheel = report.FindItem(B_HID_USAGE_PAGE_GENERIC_DESKTOP,
|
||||
B_HID_UID_GD_WHEEL);
|
||||
fHorizontalPan = report.FindItem(B_HID_USAGE_PAGE_CONSUMER,
|
||||
B_HID_UID_CON_AC_PAN);
|
||||
|
||||
TRACE("mouse device with %lu buttons and %swheel\n", buttonCount,
|
||||
TRACE("mouse device with %lu buttons %sand %swheel\n", buttonCount,
|
||||
fHorizontalPan == NULL ? "" : ", horizontal pan ",
|
||||
fWheel == NULL ? "no " : "");
|
||||
TRACE("report id: %u\n", report.ID());
|
||||
}
|
||||
@@ -204,9 +208,12 @@ MouseProtocolHandler::_ReadReport(void *buffer, uint32 *cookie)
|
||||
if (fYAxis.Extract() == B_OK && fYAxis.Valid())
|
||||
axisRelativeData[1] = fYAxis.Data();
|
||||
|
||||
uint32 wheelData = 0;
|
||||
uint32 wheelData[2] = {0};
|
||||
if (fWheel != NULL && fWheel->Extract() == B_OK && fWheel->Valid())
|
||||
wheelData = fWheel->Data();
|
||||
wheelData[0] = fWheel->Data();
|
||||
if (fHorizontalPan != NULL && fHorizontalPan->Extract() == B_OK
|
||||
&& fHorizontalPan->Valid())
|
||||
wheelData[1] = fHorizontalPan->Data();
|
||||
|
||||
uint32 buttons = 0;
|
||||
for (uint32 i = 0; i < B_MAX_MOUSE_BUTTONS; i++) {
|
||||
@@ -245,7 +252,8 @@ MouseProtocolHandler::_ReadReport(void *buffer, uint32 *cookie)
|
||||
info->ydelta = -axisRelativeData[1];
|
||||
info->clicks = clicks;
|
||||
info->timestamp = timestamp;
|
||||
info->wheel_ydelta = -wheelData;
|
||||
info->wheel_ydelta = -wheelData[0];
|
||||
info->wheel_xdelta = wheelData[1];
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ private:
|
||||
HIDReportItem & fXAxis;
|
||||
HIDReportItem & fYAxis;
|
||||
HIDReportItem * fWheel;
|
||||
HIDReportItem * fHorizontalPan;
|
||||
HIDReportItem * fButtons[B_MAX_MOUSE_BUTTONS];
|
||||
|
||||
uint32 fLastButtons;
|
||||
|
||||
Reference in New Issue
Block a user