src/joystick/hidapi/SDL_hidapijoystick_c.h
changeset 12641 64597a7e8771
parent 12503 806492103856
child 12787 0411f841b035
     1.1 --- a/src/joystick/hidapi/SDL_hidapijoystick_c.h	Sat Mar 16 17:47:59 2019 -0700
     1.2 +++ b/src/joystick/hidapi/SDL_hidapijoystick_c.h	Tue Mar 12 20:27:54 2019 -0400
     1.3 @@ -30,6 +30,7 @@
     1.4  #define SDL_JOYSTICK_HIDAPI_SWITCH
     1.5  #define SDL_JOYSTICK_HIDAPI_XBOX360
     1.6  #define SDL_JOYSTICK_HIDAPI_XBOXONE
     1.7 +#define SDL_JOYSTICK_HIDAPI_GAMECUBE
     1.8  
     1.9  #ifdef __WINDOWS__
    1.10  /* On Windows, Xbox One controllers are handled by the Xbox 360 driver */
    1.11 @@ -43,16 +44,36 @@
    1.12  #undef SDL_JOYSTICK_HIDAPI_XBOXONE
    1.13  #endif
    1.14  
    1.15 +typedef struct _SDL_HIDAPI_DriverData
    1.16 +{
    1.17 +    hid_device *device;
    1.18 +    void *context;
    1.19 +} SDL_HIDAPI_DriverData;
    1.20 +
    1.21  typedef struct _SDL_HIDAPI_DeviceDriver
    1.22  {
    1.23      const char *hint;
    1.24      SDL_bool enabled;
    1.25      SDL_bool (*IsSupportedDevice)(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number);
    1.26      const char *(*GetDeviceName)(Uint16 vendor_id, Uint16 product_id);
    1.27 -    SDL_bool (*Init)(SDL_Joystick *joystick, hid_device *dev, Uint16 vendor_id, Uint16 product_id, void **context);
    1.28 -    int (*Rumble)(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
    1.29 -    SDL_bool (*Update)(SDL_Joystick *joystick, hid_device *dev, void *context);
    1.30 -    void (*Quit)(SDL_Joystick *joystick, hid_device *dev, void *context);
    1.31 +
    1.32 +    SDL_bool       (*InitDriver)(SDL_HIDAPI_DriverData *context,
    1.33 +                                 Uint16 vendor_id, Uint16 product_id, int *num_joysticks);
    1.34 +    void           (*QuitDriver)(SDL_HIDAPI_DriverData *context,
    1.35 +                                 SDL_bool send_event,
    1.36 +                                 int *num_joysticks);
    1.37 +    SDL_bool       (*UpdateDriver)(SDL_HIDAPI_DriverData *context,
    1.38 +                                   int *num_joysticks);
    1.39 +    int            (*NumJoysticks)(SDL_HIDAPI_DriverData *context);
    1.40 +    SDL_JoystickID (*InstanceIDForIndex)(SDL_HIDAPI_DriverData *context,
    1.41 +                                         int index);
    1.42 +    SDL_bool       (*OpenJoystick)(SDL_HIDAPI_DriverData *context,
    1.43 +                                   SDL_Joystick *joystick);
    1.44 +    int            (*Rumble)(SDL_HIDAPI_DriverData *context,
    1.45 +                             SDL_Joystick *joystick,
    1.46 +                             Uint16 low_frequency_rumble,
    1.47 +                             Uint16 high_frequency_rumble,
    1.48 +                             Uint32 duration_ms);
    1.49  
    1.50  } SDL_HIDAPI_DeviceDriver;
    1.51  
    1.52 @@ -62,6 +83,7 @@
    1.53  extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch;
    1.54  extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360;
    1.55  extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne;
    1.56 +extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube;
    1.57  
    1.58  /* Return true if a HID device is present and supported as a joystick */
    1.59  extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version);