Use the IOHIDElement cookie as a part of the axis name for unknown axis. Previously the 'usage' value was used to identify the axis by name, but this is not unique. For example on a PS3 controller *all* axis other than the well known ones return a usage of '1' so there are 30 or more axis all named "1". This stops things such as analog triggers being usable.

Using the element cookie uniquely identifies each axis and allows them to be assigned successfully as controls
This commit is contained in:
Chris Pritchard 2016-10-30 10:36:53 +00:00
parent 146ee6de91
commit 9da9ba616b
1 changed files with 7 additions and 1 deletions

View File

@ -144,8 +144,14 @@ Joystick::Axis::Axis(IOHIDElementRef element, IOHIDDeviceRef device, direction d
break;
default:
{
IOHIDElementCookie elementCookie = IOHIDElementGetCookie(m_element);
// This axis isn't a 'well-known' one so cook a descriptive and uniquely
// identifiable name. macOS provides a 'cookie' for each element that
// will persist between sessions and identify the same physical controller
// element so we can use that as a component of the axis name
std::ostringstream s;
s << usage;
s << "CK-";
s << elementCookie;
description = StripSpaces(s.str());
break;
}