Index: src/hid/OHEvdevGamepad.m ================================================================== --- src/hid/OHEvdevGamepad.m +++ src/hid/OHEvdevGamepad.m @@ -205,31 +205,29 @@ - (OHGameControllerDirectionalPad *)dPad { OHGameControllerAxis *xAxis = [_rawProfile.axes objectForKey: @"HAT0X"]; OHGameControllerAxis *yAxis = [_rawProfile.axes objectForKey: @"HAT0Y"]; - OHGameControllerButton *upButton, *downButton; - OHGameControllerButton *leftButton, *rightButton; + OHGameControllerButton *up, *down, *left, *right; if (xAxis != nil && yAxis != nil) return [[[OHGameControllerDirectionalPad alloc] initWithName: @"D-Pad" xAxis: xAxis yAxis: yAxis] autorelease]; - upButton = [_rawProfile.buttons objectForKey: @"D-Pad Up"]; - downButton = [_rawProfile.buttons objectForKey: @"D-Pad Down"]; - leftButton = [_rawProfile.buttons objectForKey: @"D-Pad Left"]; - rightButton = [_rawProfile.buttons objectForKey: @"D-Pad Right"]; + up = [_rawProfile.buttons objectForKey: @"D-Pad Up"]; + down = [_rawProfile.buttons objectForKey: @"D-Pad Down"]; + left = [_rawProfile.buttons objectForKey: @"D-Pad Left"]; + right = [_rawProfile.buttons objectForKey: @"D-Pad Right"]; - if (upButton != nil && downButton != nil && - leftButton != nil && rightButton != nil) + if (up != nil && down != nil && left != nil && right != nil) return [[[OHGameControllerDirectionalPad alloc] initWithName: @"D-Pad" - upButton: upButton - downButton: downButton - leftButton: leftButton - rightButton: rightButton] autorelease]; + up: up + down: down + left: left + right: right] autorelease]; return nil; } @end Index: src/hid/OHGameControllerDirectionalPad.h ================================================================== --- src/hid/OHGameControllerDirectionalPad.h +++ src/hid/OHGameControllerDirectionalPad.h @@ -32,12 +32,11 @@ */ OF_SUBCLASSING_RESTRICTED @interface OHGameControllerDirectionalPad: OHGameControllerElement { OHGameControllerAxis *_xAxis, *_yAxis; - OHGameControllerButton *_upButton, *_downButton; - OHGameControllerButton *_leftButton, *_rightButton; + OHGameControllerButton *_up, *_down, *_left, *_right; } /** * @brief The X axis of the directional pad. */ @@ -49,36 +48,36 @@ @property (readonly, nonatomic) OHGameControllerAxis *yAxis; /** * @brief The up button of the directional pad. */ -@property (readonly, nonatomic) OHGameControllerButton *upButton; +@property (readonly, nonatomic) OHGameControllerButton *up; /** * @brief The down button of the directional pad. */ -@property (readonly, nonatomic) OHGameControllerButton *downButton; +@property (readonly, nonatomic) OHGameControllerButton *down; /** * @brief The left button of the directional pad. */ -@property (readonly, nonatomic) OHGameControllerButton *leftButton; +@property (readonly, nonatomic) OHGameControllerButton *left; /** * @brief The right button of the directional pad. */ -@property (readonly, nonatomic) OHGameControllerButton *rightButton; +@property (readonly, nonatomic) OHGameControllerButton *right; - (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE; - (instancetype)initWithName: (OFString *)name xAxis: (OHGameControllerAxis *)xAxis yAxis: (OHGameControllerAxis *)yAxis; - (instancetype)initWithName: (OFString *)name - upButton: (OHGameControllerButton *)upButton - downButton: (OHGameControllerButton *)downButton - leftButton: (OHGameControllerButton *)leftButton - rightButton: (OHGameControllerButton *)rightButton; + up: (OHGameControllerButton *)up + down: (OHGameControllerButton *)down + left: (OHGameControllerButton *)left + right: (OHGameControllerButton *)right; @end OF_ASSUME_NONNULL_END Index: src/hid/OHGameControllerDirectionalPad.m ================================================================== --- src/hid/OHGameControllerDirectionalPad.m +++ src/hid/OHGameControllerDirectionalPad.m @@ -23,12 +23,11 @@ #import "OHGameControllerEmulatedAxis.h" #import "OHGameControllerEmulatedButton.h" @implementation OHGameControllerDirectionalPad @synthesize xAxis = _xAxis, yAxis = _yAxis; -@synthesize upButton = _upButton, downButton = _downButton; -@synthesize leftButton = _leftButton, rightButton = _rightButton; +@synthesize up = _up, down = _down, left = _left, right = _right; - (instancetype)initWithName: (OFString *)name { OF_INVALID_INIT_METHOD } @@ -41,20 +40,20 @@ @try { _xAxis = [xAxis retain]; _yAxis = [yAxis retain]; - _upButton = [[OHGameControllerEmulatedButton alloc] + _up = [[OHGameControllerEmulatedButton alloc] initWithAxis: _yAxis positive: false]; - _downButton = [[OHGameControllerEmulatedButton alloc] + _down = [[OHGameControllerEmulatedButton alloc] initWithAxis: _yAxis positive: true]; - _leftButton = [[OHGameControllerEmulatedButton alloc] + _left = [[OHGameControllerEmulatedButton alloc] initWithAxis: _xAxis positive: false]; - _rightButton = [[OHGameControllerEmulatedButton alloc] + _right = [[OHGameControllerEmulatedButton alloc] initWithAxis: _xAxis positive: true]; } @catch (id e) { [self release]; @throw e; @@ -62,29 +61,29 @@ return self; } - (instancetype)initWithName: (OFString *)name - upButton: (OHGameControllerButton *)upButton - downButton: (OHGameControllerButton *)downButton - leftButton: (OHGameControllerButton *)leftButton - rightButton: (OHGameControllerButton *)rightButton + up: (OHGameControllerButton *)up + down: (OHGameControllerButton *)down + left: (OHGameControllerButton *)left + right: (OHGameControllerButton *)right { self = [super initWithName: name]; @try { - _upButton = [upButton retain]; - _downButton = [downButton retain]; - _leftButton = [leftButton retain]; - _rightButton = [rightButton retain]; + _up = [up retain]; + _down = [down retain]; + _left = [left retain]; + _right = [right retain]; _xAxis = [[OHGameControllerEmulatedAxis alloc] - initWithNegativeButton: _leftButton - positiveButton: _rightButton]; + initWithNegativeButton: _left + positiveButton: _right]; _yAxis = [[OHGameControllerEmulatedAxis alloc] - initWithNegativeButton: _upButton - positiveButton: _downButton]; + initWithNegativeButton: _up + positiveButton: _down]; } @catch (id e) { [self release]; @throw e; } @@ -93,18 +92,18 @@ - (void)dealloc { [_xAxis release]; [_yAxis release]; - [_upButton release]; - [_downButton release]; - [_leftButton release]; - [_rightButton release]; + [_up release]; + [_down release]; + [_left release]; + [_right release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name]; } @end Index: src/hid/OHXInputGameController.m ================================================================== --- src/hid/OHXInputGameController.m +++ src/hid/OHXInputGameController.m @@ -209,17 +209,17 @@ (state.Gamepad.sThumbRX < 0 ? -INT16_MIN : INT16_MAX); _gamepad.rightThumbstick.yAxis.value = -(float)state.Gamepad.sThumbRY / (state.Gamepad.sThumbRY < 0 ? -INT16_MIN : INT16_MAX); - _gamepad.dPad.upButton.value = + _gamepad.dPad.up.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP); - _gamepad.dPad.downButton.value = + _gamepad.dPad.down.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN); - _gamepad.dPad.leftButton.value = + _gamepad.dPad.left.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT); - _gamepad.dPad.rightButton.value = + _gamepad.dPad.right.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT); } - (OFString *)name { Index: src/hid/OHXInputGamepad.m ================================================================== --- src/hid/OHXInputGamepad.m +++ src/hid/OHXInputGamepad.m @@ -41,12 +41,11 @@ OFMutableDictionary *buttons = [OFMutableDictionary dictionaryWithCapacity: numButtons]; OFMutableDictionary *directionalPads; OHGameControllerAxis *xAxis, *yAxis; OHGameControllerDirectionalPad *directionalPad; - OHGameControllerButton *upButton, *downButton; - OHGameControllerButton *leftButton, *rightButton; + OHGameControllerButton *up, *down, *left, *right; for (size_t i = 0; i < numButtons; i++) { OHGameControllerButton *button = [[OHGameControllerButton alloc] initWithName: buttonNames[i]]; @@ -86,24 +85,24 @@ xAxis: xAxis yAxis: yAxis] autorelease]; [directionalPads setObject: directionalPad forKey: @"Right Thumbstick"]; - upButton = [[[OHGameControllerButton alloc] + up = [[[OHGameControllerButton alloc] initWithName: @"D-Pad Up"] autorelease]; - downButton = [[[OHGameControllerButton alloc] + down = [[[OHGameControllerButton alloc] initWithName: @"D-Pad Down"] autorelease]; - leftButton = [[[OHGameControllerButton alloc] + left = [[[OHGameControllerButton alloc] initWithName: @"D-Pad Left"] autorelease]; - rightButton = [[[OHGameControllerButton alloc] + right = [[[OHGameControllerButton alloc] initWithName: @"D-Pad Right"] autorelease]; directionalPad = [[[OHGameControllerDirectionalPad alloc] initWithName: @"D-Pad" - upButton: upButton - downButton: downButton - leftButton: leftButton - rightButton: rightButton] autorelease]; + up: up + down: down + left: left + right: right] autorelease]; [directionalPads setObject: directionalPad forKey: @"D-Pad"]; [directionalPads makeImmutable]; _directionalPads = [directionalPads retain];