src/joystick/hidapi/SDL_hidapi_gamecube.c
changeset 12704 704ec541957d
parent 12641 64597a7e8771
child 12787 0411f841b035
equal deleted inserted replaced
12703:f6c7e5e03f60 12704:704ec541957d
   207             READ_BUTTON(1, 0x20, 5) /* DPAD_RIGHT */
   207             READ_BUTTON(1, 0x20, 5) /* DPAD_RIGHT */
   208             READ_BUTTON(1, 0x40, 6) /* DPAD_DOWN */
   208             READ_BUTTON(1, 0x40, 6) /* DPAD_DOWN */
   209             READ_BUTTON(1, 0x80, 7) /* DPAD_UP */
   209             READ_BUTTON(1, 0x80, 7) /* DPAD_UP */
   210             READ_BUTTON(2, 0x01, 8) /* START */
   210             READ_BUTTON(2, 0x01, 8) /* START */
   211             READ_BUTTON(2, 0x02, 9) /* RIGHTSHOULDER */
   211             READ_BUTTON(2, 0x02, 9) /* RIGHTSHOULDER */
   212             /* [2] 0x04 - R, [2] 0x08 - L */
   212             /* These two buttons are for the bottoms of the analog triggers.
       
   213              * More than likely, you're going to want to read the axes instead!
       
   214              * -flibit
       
   215              */
       
   216             READ_BUTTON(2, 0x04, 10) /* TRIGGERRIGHT */
       
   217             READ_BUTTON(2, 0x08, 11) /* TRIGGERLEFT */
   213             #undef READ_BUTTON
   218             #undef READ_BUTTON
   214 
   219 
   215             /* Axis math taken from SDL_xinputjoystick.c */
   220             /* Axis math taken from SDL_xinputjoystick.c */
   216             #define READ_AXIS(off, axis) \
   221             #define READ_AXIS(off, axis) \
   217                 SDL_PrivateJoystickAxis( \
   222                 SDL_PrivateJoystickAxis( \
   284     SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)context->context;
   289     SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)context->context;
   285     SDL_JoystickID instance = SDL_JoystickInstanceID(joystick);
   290     SDL_JoystickID instance = SDL_JoystickInstanceID(joystick);
   286     Uint8 i;
   291     Uint8 i;
   287     for (i = 0; i < 4; i += 1) {
   292     for (i = 0; i < 4; i += 1) {
   288         if (instance == ctx->joysticks[i]) {
   293         if (instance == ctx->joysticks[i]) {
   289             joystick->nbuttons = 10;
   294             joystick->nbuttons = 12;
   290             joystick->naxes = 6;
   295             joystick->naxes = 6;
   291             joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
   296             joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
   292             return SDL_TRUE;
   297             return SDL_TRUE;
   293         }
   298         }
   294     }
   299     }