Index: src/hid/OFEvdevGameController.m ================================================================== --- src/hid/OFEvdevGameController.m +++ src/hid/OFEvdevGameController.m @@ -598,13 +598,8 @@ return _leftTriggerPressure; if (button == OFGameControllerRightTriggerButton && _hasRightTriggerPressure) return _rightTriggerPressure; - return ([self.pressedButtons containsObject: button] ? 1 : 0); -} - -- (OFString *)description -{ - return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name]; + return [super pressureForButton: button]; } @end Index: src/hid/OFGameController.m ================================================================== --- src/hid/OFGameController.m +++ src/hid/OFGameController.m @@ -19,10 +19,12 @@ #include "config.h" #import "OFGameController.h" #import "OFArray.h" +#import "OFNumber.h" +#import "OFSet.h" #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # include "OFEvdevGameController.h" #endif #ifdef OF_WINDOWS @@ -124,11 +126,23 @@ OF_UNRECOGNIZED_SELECTOR } - (float)pressureForButton: (OFGameControllerButton)button { - OF_UNRECOGNIZED_SELECTOR + return ([self.pressedButtons containsObject: button] ? 1 : 0); +} + +- (OFString *)description +{ + if (self.vendorID != nil && self.productID != nil) + return [OFString stringWithFormat: + @"<%@: %@ [%04X:%04X]>", + self.class, self.name, self.vendorID.unsignedShortValue, + self.productID.unsignedShortValue]; + else + return [OFString stringWithFormat: @"<%@: %@>", + self.class, self.name]; } @end #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # include "OFEvdevGameController.m" Index: src/hid/OFNintendo3DSGameController.m ================================================================== --- src/hid/OFNintendo3DSGameController.m +++ src/hid/OFNintendo3DSGameController.m @@ -172,16 +172,6 @@ - (bool)hasRightAnalogStick { return false; } - -- (float)pressureForButton: (OFGameControllerButton)button -{ - return ([self.pressedButtons containsObject: button] ? 1 : 0); -} - -- (OFString *)description -{ - return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name]; -} @end Index: src/hid/OFNintendoDSGameController.m ================================================================== --- src/hid/OFNintendoDSGameController.m +++ src/hid/OFNintendoDSGameController.m @@ -145,16 +145,6 @@ - (bool)hasRightAnalogStick { return false; } - -- (float)pressureForButton: (OFGameControllerButton)button -{ - return ([self.pressedButtons containsObject: button] ? 1 : 0); -} - -- (OFString *)description -{ - return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name]; -} @end Index: src/hid/OFXInputGameController.m ================================================================== --- src/hid/OFXInputGameController.m +++ src/hid/OFXInputGameController.m @@ -265,13 +265,8 @@ if (button == OFGameControllerLeftTriggerButton) return _leftTriggerPressure; if (button == OFGameControllerRightTriggerButton) return _rightTriggerPressure; - return ([self.pressedButtons containsObject: button] ? 1 : 0); -} - -- (OFString *)description -{ - return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name]; + return [super pressureForButton: button]; } @end Index: tests/gamecontroller/GameControllerTests.m ================================================================== --- tests/gamecontroller/GameControllerTests.m +++ tests/gamecontroller/GameControllerTests.m @@ -47,21 +47,11 @@ OFArray OF_GENERIC(OFGameControllerButton) *buttons = controller.buttons.allObjects.sortedArray; size_t i = 0; [OFStdOut setForegroundColor: [OFColor green]]; - [OFStdOut writeString: controller.name]; - - if (controller.vendorID != nil && - controller.productID != nil) { - [OFStdOut setForegroundColor: [OFColor teal]]; - [OFStdOut writeFormat: @" [%04X:%04X]", - controller.vendorID.unsignedShortValue, - controller.productID.unsignedShortValue]; - } - - [OFStdOut writeString: @"\n"]; + [OFStdOut writeLine: controller.description]; [controller retrieveState]; for (OFGameControllerButton button in buttons) { float pressure =