diff --git a/JoyKit/ControllerConfiguration.inc b/JoyKit/ControllerConfiguration.inc index cf327f9..6c81e9f 100644 --- a/JoyKit/ControllerConfiguration.inc +++ b/JoyKit/ControllerConfiguration.inc @@ -126,14 +126,14 @@ hacksByName = @{ JOYSubElementStructs: @{ // Rumble - @(1364): @[ + @(1357): @[ @{@"reportID": @(1), @"size":@1, @"offset":@0, @"usagePage":@(0xFF00), @"usage":@1, @"min": @0, @"max": @1}, @{@"reportID": @(2), @"size":@1, @"offset":@1, @"usagePage":@(0xFF00), @"usage":@1, @"min": @0, @"max": @1}, @{@"reportID": @(3), @"size":@1, @"offset":@2, @"usagePage":@(0xFF00), @"usage":@1, @"min": @0, @"max": @1}, @{@"reportID": @(4), @"size":@1, @"offset":@3, @"usagePage":@(0xFF00), @"usage":@1, @"min": @0, @"max": @1}, ], - @(11): @[ + @(4): @[ // Player 1 diff --git a/JoyKit/JOYAxes2D.m b/JoyKit/JOYAxes2D.m index 624ccef..a1b91d2 100644 --- a/JoyKit/JOYAxes2D.m +++ b/JoyKit/JOYAxes2D.m @@ -36,7 +36,7 @@ - (uint64_t)uniqueID { - return _element1.uniqueID; + return _element1.persistentUniqueID; } - (NSString *)description diff --git a/JoyKit/JOYAxis.m b/JoyKit/JOYAxis.m index 169eaee..74a4563 100644 --- a/JoyKit/JOYAxis.m +++ b/JoyKit/JOYAxis.m @@ -40,7 +40,7 @@ - (uint64_t)uniqueID { - return _element.uniqueID; + return _element.persistentUniqueID; } - (NSString *)description diff --git a/JoyKit/JOYButton.m b/JoyKit/JOYButton.m index 3e6026d..a904299 100644 --- a/JoyKit/JOYButton.m +++ b/JoyKit/JOYButton.m @@ -50,7 +50,7 @@ - (uint64_t)uniqueID { - return _element.uniqueID; + return _element.persistentUniqueID; } - (NSString *)description diff --git a/JoyKit/JOYController.m b/JoyKit/JOYController.m index b4810ab..10ec6e4 100644 --- a/JoyKit/JOYController.m +++ b/JoyKit/JOYController.m @@ -173,13 +173,17 @@ typedef struct __attribute__((packed)) { JOYElement *previousAxisElement = nil; id previous = nil; + unsigned persistentUniqueID = 0; for (id _element in array) { if (_element == previous) continue; // Some elements are reported twice for some reason previous = _element; NSArray *elements = nil; JOYElement *element = [[JOYElement alloc] initWithElement:(__bridge IOHIDElementRef)_element]; + /* Cookie is not persistent across macOS versions because Apple added kIOHIDElementTypeInput_NULL + in a backwards incompatible manner. We must maintain our own cookie-like ID. */ + element.persistentUniqueID = persistentUniqueID++; - NSArray*> *subElementDefs = hacks[JOYSubElementStructs][@(element.uniqueID)]; + NSArray*> *subElementDefs = hacks[JOYSubElementStructs][@(element.persistentUniqueID)]; bool isOutput = false; if (subElementDefs && element.uniqueID != element.parentID) { diff --git a/JoyKit/JOYElement.h b/JoyKit/JOYElement.h index 860c247..4a6c311 100644 --- a/JoyKit/JOYElement.h +++ b/JoyKit/JOYElement.h @@ -10,6 +10,7 @@ @property (readonly) uint16_t usage; @property (readonly) uint16_t usagePage; @property (readonly) uint32_t uniqueID; +@property unsigned persistentUniqueID; @property int32_t min; @property int32_t max; @property (readonly) int32_t reportID; diff --git a/JoyKit/JOYSubElement.m b/JoyKit/JOYSubElement.m index 55e289e..01b121a 100644 --- a/JoyKit/JOYSubElement.m +++ b/JoyKit/JOYSubElement.m @@ -34,6 +34,7 @@ _usage = usage; _usagePage = usagePage; _uniqueID = (uint32_t)((_parent.uniqueID << 16) | offset); + self.persistentUniqueID = (uint32_t)((_parent.persistentUniqueID << 16) | offset); _min = min; _max = max; _reportID = _parent.reportID;