Index: src/hid/OFNintendo3DSGameController.h ================================================================== --- src/hid/OFNintendo3DSGameController.h +++ src/hid/OFNintendo3DSGameController.h @@ -22,10 +22,10 @@ OF_ASSUME_NONNULL_BEGIN @interface OFNintendo3DSGameController: OFGameController { OFMutableSet OF_GENERIC(OFGameControllerButton) *_pressedButtons; - OFPoint _leftAnalogStickPosition; + OFPoint _leftAnalogStickPosition, _rightAnalogStickPosition; } @end OF_ASSUME_NONNULL_END Index: src/hid/OFNintendo3DSGameController.m ================================================================== --- src/hid/OFNintendo3DSGameController.m +++ src/hid/OFNintendo3DSGameController.m @@ -31,10 +31,11 @@ static OFArray OF_GENERIC(OFGameController *) *controllers; @implementation OFNintendo3DSGameController @synthesize leftAnalogStickPosition = _leftAnalogStickPosition; +@synthesize rightAnalogStickPosition = _rightAnalogStickPosition; + (void)initialize { void *pool; @@ -55,11 +56,11 @@ - (instancetype)init { self = [super init]; @try { - _pressedButtons = [[OFMutableSet alloc] initWithCapacity: 18]; + _pressedButtons = [[OFMutableSet alloc] initWithCapacity: 14]; [self retrieveState]; } @catch (id e) { [self release]; @throw e; @@ -114,18 +115,10 @@ [_pressedButtons addObject: OFGameControllerDPadRightButton]; if (keys & KEY_START) [_pressedButtons addObject: OFGameControllerStartButton]; if (keys & KEY_SELECT) [_pressedButtons addObject: OFGameControllerSelectButton]; - if (keys & KEY_CSTICK_UP) - [_pressedButtons addObject: OFGameControllerCPadUpButton]; - if (keys & KEY_CSTICK_DOWN) - [_pressedButtons addObject: OFGameControllerCPadDownButton]; - if (keys & KEY_CSTICK_LEFT) - [_pressedButtons addObject: OFGameControllerCPadLeftButton]; - if (keys & KEY_CSTICK_RIGHT) - [_pressedButtons addObject: OFGameControllerCPadRightButton]; if (pos.dx > 150) pos.dx = 150; if (pos.dx < -150) pos.dx = -150; @@ -134,10 +127,13 @@ if (pos.dy < -150) pos.dy = -150; _leftAnalogStickPosition = OFMakePoint( (float)pos.dx / 150, -(float)pos.dy / 150); + _rightAnalogStickPosition = OFMakePoint( + -!!(keys & KEY_CSTICK_LEFT) + !!(keys & KEY_CSTICK_RIGHT), + -!!(keys & KEY_CSTICK_UP) + !!(keys & KEY_CSTICK_DOWN)); } - (OFString *)name { return @"Nintendo 3DS"; @@ -157,15 +153,11 @@ OFGameControllerDPadUpButton, OFGameControllerDPadDownButton, OFGameControllerDPadLeftButton, OFGameControllerDPadRightButton, OFGameControllerStartButton, - OFGameControllerSelectButton, - OFGameControllerCPadRightButton, - OFGameControllerCPadLeftButton, - OFGameControllerCPadUpButton, - OFGameControllerCPadDownButton, nil]; + OFGameControllerSelectButton, nil]; } - (OFSet OF_GENERIC(OFGameControllerButton) *)pressedButtons { return [[_pressedButtons copy] autorelease]; @@ -176,8 +168,8 @@ return true; } - (bool)hasRightAnalogStick { - return false; + return true; } @end