From 9da9ba616b7d9fc843a62120bb11e66b0374c6bd Mon Sep 17 00:00:00 2001 From: Chris Pritchard Date: Sun, 30 Oct 2016 10:36:53 +0000 Subject: [PATCH] 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 --- .../InputCommon/ControllerInterface/OSX/OSXJoystick.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm b/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm index 204e002e25..19aa9e23b7 100644 --- a/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm +++ b/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm @@ -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; }