dinput: On Mac, always use both HID usage page and usage for comparisons.
Signed-off-by: Brendan Shanks <bshanks@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7ba0cc9085
commit
e8332dece8
|
@ -96,6 +96,8 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
||||
|
||||
#define MAKEUINT64(high, low) (((uint64_t)high << 32) | (uint32_t)low)
|
||||
|
||||
static CFMutableArrayRef device_main_elements = NULL;
|
||||
|
||||
typedef struct JoystickImpl JoystickImpl;
|
||||
|
@ -614,7 +616,7 @@ static CFComparisonResult button_usage_comparator(const void *val1, const void *
|
|||
return kCFCompareEqualTo;
|
||||
}
|
||||
|
||||
static void get_osx_device_elements(JoystickImpl *device, int axis_map[8])
|
||||
static void get_osx_device_elements(JoystickImpl *device, uint64_t axis_map[8])
|
||||
{
|
||||
IOHIDElementRef device_main_element;
|
||||
CFMutableArrayRef elements;
|
||||
|
@ -680,33 +682,33 @@ static void get_osx_device_elements(JoystickImpl *device, int axis_map[8])
|
|||
case kIOHIDElementTypeInput_Misc:
|
||||
{
|
||||
uint32_t usage = IOHIDElementGetUsage( element );
|
||||
switch(usage)
|
||||
switch(MAKEUINT64(usage_page, usage))
|
||||
{
|
||||
case kHIDUsage_GD_Hatswitch:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Hatswitch):
|
||||
{
|
||||
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Hatswitch\n");
|
||||
CFArrayAppendValue(povs, element);
|
||||
break;
|
||||
}
|
||||
case kHIDUsage_GD_Slider:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Slider):
|
||||
sliders ++;
|
||||
if (sliders > 2)
|
||||
break;
|
||||
/* fallthrough, sliders are axis */
|
||||
case kHIDUsage_GD_X:
|
||||
case kHIDUsage_GD_Y:
|
||||
case kHIDUsage_GD_Z:
|
||||
case kHIDUsage_GD_Rx:
|
||||
case kHIDUsage_GD_Ry:
|
||||
case kHIDUsage_GD_Rz:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_X):
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Y):
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Z):
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Rx):
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Ry):
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Rz):
|
||||
{
|
||||
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_* (%d)\n", usage);
|
||||
axis_map[CFArrayGetCount(axes)]=usage;
|
||||
axis_map[CFArrayGetCount(axes)]=MAKEUINT64(usage_page, usage);
|
||||
CFArrayAppendValue(axes, element);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
FIXME("kIOHIDElementTypeInput_Misc / Unhandled usage %i\n", usage);
|
||||
FIXME("kIOHIDElementTypeInput_Misc / Unhandled usage %i/%i\n", usage_page, usage);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -827,10 +829,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
|
|||
break;
|
||||
case kIOHIDElementTypeInput_Misc:
|
||||
{
|
||||
uint32_t usage_page = IOHIDElementGetUsagePage( element );
|
||||
uint32_t usage = IOHIDElementGetUsage( element );
|
||||
switch(usage)
|
||||
switch(MAKEUINT64(usage_page, usage))
|
||||
{
|
||||
case kHIDUsage_GD_Hatswitch:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Hatswitch):
|
||||
{
|
||||
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Hatswitch\n");
|
||||
valueRef = NULL;
|
||||
|
@ -854,13 +857,13 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
|
|||
pov_idx ++;
|
||||
break;
|
||||
}
|
||||
case kHIDUsage_GD_X:
|
||||
case kHIDUsage_GD_Y:
|
||||
case kHIDUsage_GD_Z:
|
||||
case kHIDUsage_GD_Rx:
|
||||
case kHIDUsage_GD_Ry:
|
||||
case kHIDUsage_GD_Rz:
|
||||
case kHIDUsage_GD_Slider:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_X):
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Y):
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Z):
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Rx):
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Ry):
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Rz):
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Slider):
|
||||
{
|
||||
int wine_obj = -1;
|
||||
|
||||
|
@ -871,45 +874,45 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
|
|||
return;
|
||||
val = IOHIDValueGetIntegerValue(valueRef);
|
||||
newVal = joystick_map_axis(&device->generic.props[idx], val);
|
||||
switch (usage)
|
||||
switch (MAKEUINT64(usage_page, usage))
|
||||
{
|
||||
case kHIDUsage_GD_X:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_X):
|
||||
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_X\n");
|
||||
wine_obj = 0;
|
||||
oldVal = device->generic.js.lX;
|
||||
device->generic.js.lX = newVal;
|
||||
break;
|
||||
case kHIDUsage_GD_Y:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Y):
|
||||
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Y\n");
|
||||
wine_obj = 1;
|
||||
oldVal = device->generic.js.lY;
|
||||
device->generic.js.lY = newVal;
|
||||
break;
|
||||
case kHIDUsage_GD_Z:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Z):
|
||||
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Z\n");
|
||||
wine_obj = 2;
|
||||
oldVal = device->generic.js.lZ;
|
||||
device->generic.js.lZ = newVal;
|
||||
break;
|
||||
case kHIDUsage_GD_Rx:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Rx):
|
||||
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Rx\n");
|
||||
wine_obj = 3;
|
||||
oldVal = device->generic.js.lRx;
|
||||
device->generic.js.lRx = newVal;
|
||||
break;
|
||||
case kHIDUsage_GD_Ry:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Ry):
|
||||
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Ry\n");
|
||||
wine_obj = 4;
|
||||
oldVal = device->generic.js.lRy;
|
||||
device->generic.js.lRy = newVal;
|
||||
break;
|
||||
case kHIDUsage_GD_Rz:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Rz):
|
||||
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Rz\n");
|
||||
wine_obj = 5;
|
||||
oldVal = device->generic.js.lRz;
|
||||
device->generic.js.lRz = newVal;
|
||||
break;
|
||||
case kHIDUsage_GD_Slider:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Slider):
|
||||
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Slider\n");
|
||||
wine_obj = 6 + slider_idx;
|
||||
oldVal = device->generic.js.rglSlider[slider_idx];
|
||||
|
@ -1090,7 +1093,7 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
|
|||
HRESULT hr;
|
||||
LPDIDATAFORMAT df = NULL;
|
||||
int idx = 0;
|
||||
int axis_map[8]; /* max axes */
|
||||
uint64_t axis_map[8]; /* max axes */
|
||||
int slider_count = 0;
|
||||
FFCAPABILITIES ffcaps;
|
||||
|
||||
|
@ -1184,31 +1187,31 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
|
|||
BOOL has_ff = FALSE;
|
||||
switch (axis_map[i])
|
||||
{
|
||||
case kHIDUsage_GD_X:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_X):
|
||||
wine_obj = 0;
|
||||
has_ff = (newDevice->ff != 0) && osx_axis_has_ff(&ffcaps, FFJOFS_X);
|
||||
break;
|
||||
case kHIDUsage_GD_Y:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Y):
|
||||
wine_obj = 1;
|
||||
has_ff = (newDevice->ff != 0) && osx_axis_has_ff(&ffcaps, FFJOFS_Y);
|
||||
break;
|
||||
case kHIDUsage_GD_Z:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Z):
|
||||
wine_obj = 2;
|
||||
has_ff = (newDevice->ff != 0) && osx_axis_has_ff(&ffcaps, FFJOFS_Z);
|
||||
break;
|
||||
case kHIDUsage_GD_Rx:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Rx):
|
||||
wine_obj = 3;
|
||||
has_ff = (newDevice->ff != 0) && osx_axis_has_ff(&ffcaps, FFJOFS_RX);
|
||||
break;
|
||||
case kHIDUsage_GD_Ry:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Ry):
|
||||
wine_obj = 4;
|
||||
has_ff = (newDevice->ff != 0) && osx_axis_has_ff(&ffcaps, FFJOFS_RY);
|
||||
break;
|
||||
case kHIDUsage_GD_Rz:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Rz):
|
||||
wine_obj = 5;
|
||||
has_ff = (newDevice->ff != 0) && osx_axis_has_ff(&ffcaps, FFJOFS_RZ);
|
||||
break;
|
||||
case kHIDUsage_GD_Slider:
|
||||
case MAKEUINT64(kHIDPage_GenericDesktop, kHIDUsage_GD_Slider):
|
||||
wine_obj = 6 + slider_count;
|
||||
has_ff = (newDevice->ff != 0) && osx_axis_has_ff(&ffcaps, FFJOFS_SLIDER(slider_count));
|
||||
slider_count++;
|
||||
|
|
Loading…
Reference in New Issue