Index: src/hid/OHEvdevDualSense.m ================================================================== --- src/hid/OHEvdevDualSense.m +++ src/hid/OHEvdevDualSense.m @@ -19,13 +19,10 @@ #include "config.h" #import "OHEvdevDualSense.h" #import "OFDictionary.h" -#import "OFNumber.h" -#import "OHEvdevGameController.h" -#import "OHGameControllerDirectionalPad.h" #import "OHGameControllerEmulatedTriggerButton.h" #import "OFInvalidArgumentException.h" @implementation OHEvdevDualSense @@ -69,10 +66,34 @@ - (OHGameControllerButton *)leftShoulderButton { return [_rawProfile.buttons objectForKey: @"L1"]; } + +- (OHGameControllerButton *)leftTriggerButton +{ + OHGameControllerAxis *axis = [_rawProfile.axes objectForKey: @"Z"]; + + if (axis != nil) + return [[[OHGameControllerEmulatedTriggerButton alloc] + initWithName: @"L2" + axis: axis] autorelease]; + + return [_rawProfile.buttons objectForKey: @"L2"]; +} + +- (OHGameControllerButton *)rightTriggerButton +{ + OHGameControllerAxis *axis = [_rawProfile.axes objectForKey: @"RZ"]; + + if (axis != nil) + return [[[OHGameControllerEmulatedTriggerButton alloc] + initWithName: @"R2" + axis: axis] autorelease]; + + return [_rawProfile.buttons objectForKey: @"R2"]; +} - (OHGameControllerButton *)rightShoulderButton { return [_rawProfile.buttons objectForKey: @"R1"]; } Index: src/hid/OHEvdevGamepad.m ================================================================== --- src/hid/OHEvdevGamepad.m +++ src/hid/OHEvdevGamepad.m @@ -146,11 +146,12 @@ { OHGameControllerAxis *axis = [_rawProfile.axes objectForKey: @"Z"]; if (axis != nil) return [[[OHGameControllerEmulatedTriggerButton alloc] - initWithAxis: axis] autorelease]; + initWithName: @"LT" + axis: axis] autorelease]; return [_rawProfile.buttons objectForKey: @"LT"]; } - (OHGameControllerButton *)rightTriggerButton @@ -157,11 +158,12 @@ { OHGameControllerAxis *axis = [_rawProfile.axes objectForKey: @"RZ"]; if (axis != nil) return [[[OHGameControllerEmulatedTriggerButton alloc] - initWithAxis: axis] autorelease]; + initWithName: @"RT" + axis: axis] autorelease]; return [_rawProfile.buttons objectForKey: @"RT"]; } - (OHGameControllerButton *)leftThumbstickButton Index: src/hid/OHGameControllerEmulatedTriggerButton.h ================================================================== --- src/hid/OHGameControllerEmulatedTriggerButton.h +++ src/hid/OHGameControllerEmulatedTriggerButton.h @@ -28,9 +28,10 @@ { OHGameControllerAxis *_axis; } - (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE; -- (instancetype)initWithAxis: (OHGameControllerAxis *)axis; +- (instancetype)initWithName: (OFString *)name + axis: (OHGameControllerAxis *)axis; @end OF_ASSUME_NONNULL_END Index: src/hid/OHGameControllerEmulatedTriggerButton.m ================================================================== --- src/hid/OHGameControllerEmulatedTriggerButton.m +++ src/hid/OHGameControllerEmulatedTriggerButton.m @@ -26,25 +26,14 @@ - (instancetype)initWithName: (OFString *)name { OF_INVALID_INIT_METHOD } -- (instancetype)initWithAxis: (OHGameControllerAxis *)axis -{ - void *pool = objc_autoreleasePoolPush(); - OFString *name; - - @try { - name = axis.name; - } @catch (id e) { - [self release]; - @throw e; - } - - self = [super initWithName: name]; - - objc_autoreleasePoolPop(pool); +- (instancetype)initWithName: (OFString *)name + axis: (OHGameControllerAxis *)axis +{ + self = [super initWithName: name]; _axis = [axis retain]; return self; }