Index: src/OFGameController.h ================================================================== --- src/OFGameController.h +++ src/OFGameController.h @@ -24,10 +24,11 @@ /** @file */ @class OFArray OF_GENERIC(ObjectType); @class OFMutableSet OF_GENERIC(ObjectType); +@class OFNumber; @class OFSet OF_GENERIC(ObjectType); /** * @brief A button on a controller. * @@ -235,10 +236,20 @@ /** * @brief The name of the controller. */ @property (readonly, nonatomic, copy) OFString *name; +/** + * @brief The vendor ID of the controller or `nil` if unavailable. + */ +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFNumber *vendorID; + +/** + * @brief The product ID of the controller or `nil` if unavailable. + */ +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFNumber *productID; + /** * @brief The buttons the controller has. */ @property (readonly, nonatomic, copy) OFSet OF_GENERIC(OFGameControllerButton) *buttons; Index: src/OFGameController.m ================================================================== --- src/OFGameController.m +++ src/OFGameController.m @@ -68,10 +68,20 @@ - (instancetype)init { OF_INVALID_INIT_METHOD } + +- (OFNumber *)vendorID +{ + return nil; +} + +- (OFNumber *)productID +{ + return nil; +} - (void)retrieveState { } Index: src/platform/Linux/OFGameController.m ================================================================== --- src/platform/Linux/OFGameController.m +++ src/platform/Linux/OFGameController.m @@ -25,10 +25,11 @@ #import "OFGameController.h" #import "OFArray.h" #import "OFFileManager.h" #import "OFLocale.h" +#import "OFNumber.h" #import "OFSet.h" #include #include @@ -349,10 +350,20 @@ [_buttons release]; [_pressedButtons release]; [super dealloc]; } + +- (OFNumber *)vendorID +{ + return [OFNumber numberWithUnsignedShort: _vendorID]; +} + +- (OFNumber *)productID +{ + return [OFNumber numberWithUnsignedShort: _productID]; +} - (void)retrieveState { struct input_event event; Index: src/platform/Nintendo3DS/OFGameController.m ================================================================== --- src/platform/Nintendo3DS/OFGameController.m +++ src/platform/Nintendo3DS/OFGameController.m @@ -143,10 +143,20 @@ - (OFString *)name { return @"Nintendo 3DS"; } + +- (OFNumber *)vendorID +{ + return nil; +} + +- (OFNumber *)productID +{ + return nil; +} - (OFSet OF_GENERIC(OFGameControllerButton) *)buttons { return [OFSet setWithObjects: OFGameControllerButtonA, OFGameControllerButtonB, OFGameControllerButtonSelect, Index: src/platform/NintendoDS/OFGameController.m ================================================================== --- src/platform/NintendoDS/OFGameController.m +++ src/platform/NintendoDS/OFGameController.m @@ -123,10 +123,20 @@ - (OFString *)name { return @"Nintendo DS"; } + +- (OFNumber *)vendorID +{ + return nil; +} + +- (OFNumber *)productID +{ + return nil; +} - (OFSet OF_GENERIC(OFGameControllerButton) *)buttons { return [OFSet setWithObjects: OFGameControllerButtonA, OFGameControllerButtonB, OFGameControllerButtonSelect, Index: src/platform/Windows/OFGameController.m ================================================================== --- src/platform/Windows/OFGameController.m +++ src/platform/Windows/OFGameController.m @@ -177,10 +177,20 @@ - (OFString *)name { return @"XInput 1.3"; } + +- (OFNumber *)vendorID +{ + return nil; +} + +- (OFNumber *)productID +{ + return nil; +} - (OFSet OF_GENERIC(OFGameControllerButton) *)buttons { return [OFSet setWithObjects: OFGameControllerButtonA, OFGameControllerButtonB, Index: tests/gamecontroller/GameControllerTests.m ================================================================== --- tests/gamecontroller/GameControllerTests.m +++ tests/gamecontroller/GameControllerTests.m @@ -21,10 +21,11 @@ #import "OFApplication.h" #import "OFArray.h" #import "OFColor.h" #import "OFGameController.h" +#import "OFNumber.h" #import "OFSet.h" #import "OFStdIOStream.h" #import "OFThread.h" @interface GameControllerTests: OFObject @@ -46,11 +47,21 @@ OFArray OF_GENERIC(OFGameControllerButton) *buttons = controller.buttons.allObjects.sortedArray; size_t i = 0; [OFStdOut setForegroundColor: [OFColor green]]; - [OFStdOut writeLine: controller.name]; + [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"]; [controller retrieveState]; for (OFGameControllerButton button in buttons) { float pressure =