Add hat support to the JoystickProtocolHandler. Completely untested for lack of
hardware though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42035 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9028fd53bd
commit
1b7d2a5498
@ -66,6 +66,19 @@ JoystickProtocolHandler::JoystickProtocolHandler(HIDReport &report)
|
|||||||
|
|
||||||
case B_HID_USAGE_PAGE_GENERIC_DESKTOP:
|
case B_HID_USAGE_PAGE_GENERIC_DESKTOP:
|
||||||
{
|
{
|
||||||
|
if (item->UsageID() == B_HID_UID_GD_HAT_SWITCH) {
|
||||||
|
HIDReportItem **newHats = (HIDReportItem **)realloc(fHats,
|
||||||
|
++fHatCount * sizeof(HIDReportItem *));
|
||||||
|
if (newHats == NULL) {
|
||||||
|
fHatCount--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fHats = newHats;
|
||||||
|
fHats[fHatCount - 1] = item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
uint16 axis = 0;
|
uint16 axis = 0;
|
||||||
if (item->UsageID() >= B_HID_UID_GD_X
|
if (item->UsageID() >= B_HID_UID_GD_X
|
||||||
&& item->UsageID() <= B_HID_UID_GD_WHEEL) {
|
&& item->UsageID() <= B_HID_UID_GD_WHEEL) {
|
||||||
@ -346,6 +359,17 @@ JoystickProtocolHandler::_Update()
|
|||||||
fCurrentValues.axes[i] = (int16)fAxis[i]->ScaledData(16, true);
|
fCurrentValues.axes[i] = (int16)fAxis[i]->ScaledData(16, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < fHatCount; i++) {
|
||||||
|
HIDReportItem *hat = fHats[i];
|
||||||
|
if (hat == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (hat->Extract() != B_OK || !hat->Valid())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fCurrentValues.hats[i] = hat->ScaledRangeData(1, 8);
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32 i = 0; i < fButtonCount; i++) {
|
for (uint32 i = 0; i < fButtonCount; i++) {
|
||||||
HIDReportItem *button = fButtons[i];
|
HIDReportItem *button = fButtons[i];
|
||||||
if (button == NULL)
|
if (button == NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user