Fix WUP-028 on Catalina, make controller configuration compatible between macOS versions

This commit is contained in:
Lior Halphon 2020-04-30 23:56:14 +03:00
parent 60ad3160cf
commit 160282c42a
7 changed files with 12 additions and 6 deletions

View File

@ -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

View File

@ -36,7 +36,7 @@
- (uint64_t)uniqueID
{
return _element1.uniqueID;
return _element1.persistentUniqueID;
}
- (NSString *)description

View File

@ -40,7 +40,7 @@
- (uint64_t)uniqueID
{
return _element.uniqueID;
return _element.persistentUniqueID;
}
- (NSString *)description

View File

@ -50,7 +50,7 @@
- (uint64_t)uniqueID
{
return _element.uniqueID;
return _element.persistentUniqueID;
}
- (NSString *)description

View File

@ -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<NSDictionary <NSString *,NSNumber *>*> *subElementDefs = hacks[JOYSubElementStructs][@(element.uniqueID)];
NSArray<NSDictionary <NSString *,NSNumber *>*> *subElementDefs = hacks[JOYSubElementStructs][@(element.persistentUniqueID)];
bool isOutput = false;
if (subElementDefs && element.uniqueID != element.parentID) {

View File

@ -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;

View File

@ -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;