winejoystick.drv: Add sim page element controls.
Support for input features defined by HID Simulation page: Rudder (Rz), Throttle (Z), Steering (X), Accelerator (Y), Brake (Rz). Signed-off-by: David Lawrie <david.dljunk@gmail.com> Signed-off-by: Ken Thomases <ken@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f457f25b71
commit
dd37dc4a3e
|
@ -165,8 +165,7 @@ static const char* debugstr_element(IOHIDElementRef element)
|
||||||
IOHIDElementGetUsage(element), IOHIDElementGetDevice(element));
|
IOHIDElementGetUsage(element), IOHIDElementGetDevice(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int axis_for_usage_GD(int usage)
|
||||||
static int axis_for_usage(int usage)
|
|
||||||
{
|
{
|
||||||
switch (usage)
|
switch (usage)
|
||||||
{
|
{
|
||||||
|
@ -181,6 +180,19 @@ static int axis_for_usage(int usage)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int axis_for_usage_Sim(int usage)
|
||||||
|
{
|
||||||
|
switch (usage)
|
||||||
|
{
|
||||||
|
case kHIDUsage_Sim_Rudder: return AXIS_RZ;
|
||||||
|
case kHIDUsage_Sim_Throttle: return AXIS_Z;
|
||||||
|
case kHIDUsage_Sim_Steering: return AXIS_X;
|
||||||
|
case kHIDUsage_Sim_Accelerator: return AXIS_Y;
|
||||||
|
case kHIDUsage_Sim_Brake: return AXIS_RZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* joystick_from_id
|
* joystick_from_id
|
||||||
|
@ -383,10 +395,13 @@ static void collect_joystick_elements(joystick_t* joystick, IOHIDElementRef coll
|
||||||
{
|
{
|
||||||
IOHIDElementRef child;
|
IOHIDElementRef child;
|
||||||
int type;
|
int type;
|
||||||
|
uint32_t usage_page;
|
||||||
|
|
||||||
child = (IOHIDElementRef)CFArrayGetValueAtIndex(children, i);
|
child = (IOHIDElementRef)CFArrayGetValueAtIndex(children, i);
|
||||||
TRACE("child %s\n", debugstr_element(child));
|
TRACE("child %s\n", debugstr_element(child));
|
||||||
type = IOHIDElementGetType(child);
|
type = IOHIDElementGetType(child);
|
||||||
|
usage_page = IOHIDElementGetUsagePage(child);
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case kIOHIDElementTypeCollection:
|
case kIOHIDElementTypeCollection:
|
||||||
|
@ -394,8 +409,6 @@ static void collect_joystick_elements(joystick_t* joystick, IOHIDElementRef coll
|
||||||
break;
|
break;
|
||||||
case kIOHIDElementTypeInput_Button:
|
case kIOHIDElementTypeInput_Button:
|
||||||
{
|
{
|
||||||
int usage_page = IOHIDElementGetUsagePage(child);
|
|
||||||
|
|
||||||
TRACE("kIOHIDElementTypeInput_Button usage_page %d\n", usage_page);
|
TRACE("kIOHIDElementTypeInput_Button usage_page %d\n", usage_page);
|
||||||
|
|
||||||
/* avoid strange elements found on the 360 controller */
|
/* avoid strange elements found on the 360 controller */
|
||||||
|
@ -411,6 +424,10 @@ static void collect_joystick_elements(joystick_t* joystick, IOHIDElementRef coll
|
||||||
case kIOHIDElementTypeInput_Misc:
|
case kIOHIDElementTypeInput_Misc:
|
||||||
{
|
{
|
||||||
uint32_t usage = IOHIDElementGetUsage( child );
|
uint32_t usage = IOHIDElementGetUsage( child );
|
||||||
|
switch (usage_page)
|
||||||
|
{
|
||||||
|
case kHIDPage_GenericDesktop:
|
||||||
|
{
|
||||||
switch(usage)
|
switch(usage)
|
||||||
{
|
{
|
||||||
case kHIDUsage_GD_Hatswitch:
|
case kHIDUsage_GD_Hatswitch:
|
||||||
|
@ -429,7 +446,7 @@ static void collect_joystick_elements(joystick_t* joystick, IOHIDElementRef coll
|
||||||
case kHIDUsage_GD_Ry:
|
case kHIDUsage_GD_Ry:
|
||||||
case kHIDUsage_GD_Rz:
|
case kHIDUsage_GD_Rz:
|
||||||
{
|
{
|
||||||
int axis = axis_for_usage(usage);
|
int axis = axis_for_usage_GD(usage);
|
||||||
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_<axis> (%d) axis %d\n", usage, axis);
|
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_<axis> (%d) axis %d\n", usage, axis);
|
||||||
if (axis < 0 || joystick->axes[axis].element)
|
if (axis < 0 || joystick->axes[axis].element)
|
||||||
TRACE(" ignoring\n");
|
TRACE(" ignoring\n");
|
||||||
|
@ -462,7 +479,41 @@ static void collect_joystick_elements(joystick_t* joystick, IOHIDElementRef coll
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
FIXME("kIOHIDElementTypeInput_Misc / Unhandled usage %d\n", usage);
|
FIXME("kIOHIDElementTypeInput_Misc / Unhandled GD Page usage %d\n", usage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kHIDPage_Simulation:
|
||||||
|
{
|
||||||
|
switch(usage)
|
||||||
|
{
|
||||||
|
case kHIDUsage_Sim_Rudder:
|
||||||
|
case kHIDUsage_Sim_Throttle:
|
||||||
|
case kHIDUsage_Sim_Steering:
|
||||||
|
case kHIDUsage_Sim_Accelerator:
|
||||||
|
case kHIDUsage_Sim_Brake:
|
||||||
|
{
|
||||||
|
int axis = axis_for_usage_Sim(usage);
|
||||||
|
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_Sim_<axis> (%d) axis %d\n", usage, axis);
|
||||||
|
if (axis < 0 || joystick->axes[axis].element)
|
||||||
|
TRACE(" ignoring\n");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
joystick->axes[axis].element = (IOHIDElementRef)CFRetain(child);
|
||||||
|
joystick->axes[axis].min_value = IOHIDElementGetLogicalMin(child);
|
||||||
|
joystick->axes[axis].max_value = IOHIDElementGetLogicalMax(child);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
FIXME("kIOHIDElementTypeInput_Misc / Unhandled Sim Page usage %d\n", usage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
FIXME("kIOHIDElementTypeInput_Misc / Unhandled Usage Page %d\n", usage_page);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue