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