Index: src/OFGameController.h ================================================================== --- src/OFGameController.h +++ src/OFGameController.h @@ -44,10 +44,11 @@ * * @ref OFGameControllerButtonZL * * @ref OFGameControllerButtonZR * * @ref OFGameControllerButtonSelect * * @ref OFGameControllerButtonStart * * @ref OFGameControllerButtonHome + * * @ref OFGameControllerButtonCapture * * @ref OFGameControllerButtonLeftStick * * @ref OFGameControllerButtonRightStick * * @ref OFGameControllerButtonDPadUp * * @ref OFGameControllerButtonDPadDown * * @ref OFGameControllerButtonDPadLeft @@ -54,10 +55,11 @@ * * @ref OFGameControllerButtonDPadRight * * @ref OFGameControllerButtonCPadUp * * @ref OFGameControllerButtonCPadDown * * @ref OFGameControllerButtonCPadLeft * * @ref OFGameControllerButtonCPadRight + * * @ref OFGameControllerButtonMode */ typedef OFConstantString *OFGameControllerButton; #ifdef __cplusplus extern "C" { @@ -180,10 +182,15 @@ /** * @brief The C-Pad Right button on a game controller. */ extern const OFGameControllerButton OFGameControllerButtonCPadRight; + +/** + * @brief The Mode button on a game controller. + */ +extern const OFGameControllerButton OFGameControllerButtonMode; #ifdef __cplusplus } #endif /** Index: src/OFGameController.m ================================================================== --- src/OFGameController.m +++ src/OFGameController.m @@ -44,10 +44,11 @@ const OFGameControllerButton OFGameControllerButtonDPadRight = @"D-Pad Right"; const OFGameControllerButton OFGameControllerButtonCPadUp = @"C-Pad Up"; const OFGameControllerButton OFGameControllerButtonCPadDown = @"C-Pad Down"; const OFGameControllerButton OFGameControllerButtonCPadLeft = @"C-Pad Left"; const OFGameControllerButton OFGameControllerButtonCPadRight = @"C-Pad Right"; +const OFGameControllerButton OFGameControllerButtonMode = @"Mode"; #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # include "platform/Linux/OFGameController.m" #elif defined(OF_WINDOWS) # include "platform/Windows/OFGameController.m" Index: src/platform/Linux/OFGameController.m ================================================================== --- src/platform/Linux/OFGameController.m +++ src/platform/Linux/OFGameController.m @@ -38,10 +38,11 @@ #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" static const uint16_t vendorIDNintendo = 0x057E; static const uint16_t productIDN64Controller = 0x2019; +static const uint16_t productIDMegaDriveController = 0x201E; @interface OFGameController () - (instancetype)of_initWithPath: (OFString *)path OF_METHOD_FAMILY(init); @end @@ -69,10 +70,26 @@ return OFGameControllerButtonCPadDown; case BTN_MODE: return OFGameControllerButtonHome; case BTN_Z: return OFGameControllerButtonCapture; + } + } else if (vendorID == vendorIDNintendo && + productID == productIDMegaDriveController) { + switch (button) { + case BTN_B: + return OFGameControllerButtonA; + case BTN_A: + return OFGameControllerButtonB; + case BTN_Z: + return OFGameControllerButtonC; + case BTN_TR2: + return OFGameControllerButtonStart; + case BTN_TR: + return OFGameControllerButtonMode; + case BTN_THUMBL: + return OFGameControllerButtonCapture; } } switch (button) { case BTN_A: