src/joystick/hidapi/SDL_hidapijoystick_c.h
changeset 12641 64597a7e8771
parent 12503 806492103856
child 12787 0411f841b035
equal deleted inserted replaced
12640:b708d2c3fe08 12641:64597a7e8771
    28 /* This is the full set of HIDAPI drivers available */
    28 /* This is the full set of HIDAPI drivers available */
    29 #define SDL_JOYSTICK_HIDAPI_PS4
    29 #define SDL_JOYSTICK_HIDAPI_PS4
    30 #define SDL_JOYSTICK_HIDAPI_SWITCH
    30 #define SDL_JOYSTICK_HIDAPI_SWITCH
    31 #define SDL_JOYSTICK_HIDAPI_XBOX360
    31 #define SDL_JOYSTICK_HIDAPI_XBOX360
    32 #define SDL_JOYSTICK_HIDAPI_XBOXONE
    32 #define SDL_JOYSTICK_HIDAPI_XBOXONE
       
    33 #define SDL_JOYSTICK_HIDAPI_GAMECUBE
    33 
    34 
    34 #ifdef __WINDOWS__
    35 #ifdef __WINDOWS__
    35 /* On Windows, Xbox One controllers are handled by the Xbox 360 driver */
    36 /* On Windows, Xbox One controllers are handled by the Xbox 360 driver */
    36 #undef SDL_JOYSTICK_HIDAPI_XBOXONE
    37 #undef SDL_JOYSTICK_HIDAPI_XBOXONE
    37 /* It turns out HIDAPI for Xbox controllers doesn't allow background input */
    38 /* It turns out HIDAPI for Xbox controllers doesn't allow background input */
    41 #ifdef __MACOSX__
    42 #ifdef __MACOSX__
    42 /* On Mac OS X, Xbox One controllers are handled by the Xbox 360 driver */
    43 /* On Mac OS X, Xbox One controllers are handled by the Xbox 360 driver */
    43 #undef SDL_JOYSTICK_HIDAPI_XBOXONE
    44 #undef SDL_JOYSTICK_HIDAPI_XBOXONE
    44 #endif
    45 #endif
    45 
    46 
       
    47 typedef struct _SDL_HIDAPI_DriverData
       
    48 {
       
    49     hid_device *device;
       
    50     void *context;
       
    51 } SDL_HIDAPI_DriverData;
       
    52 
    46 typedef struct _SDL_HIDAPI_DeviceDriver
    53 typedef struct _SDL_HIDAPI_DeviceDriver
    47 {
    54 {
    48     const char *hint;
    55     const char *hint;
    49     SDL_bool enabled;
    56     SDL_bool enabled;
    50     SDL_bool (*IsSupportedDevice)(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number);
    57     SDL_bool (*IsSupportedDevice)(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number);
    51     const char *(*GetDeviceName)(Uint16 vendor_id, Uint16 product_id);
    58     const char *(*GetDeviceName)(Uint16 vendor_id, Uint16 product_id);
    52     SDL_bool (*Init)(SDL_Joystick *joystick, hid_device *dev, Uint16 vendor_id, Uint16 product_id, void **context);
    59 
    53     int (*Rumble)(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
    60     SDL_bool       (*InitDriver)(SDL_HIDAPI_DriverData *context,
    54     SDL_bool (*Update)(SDL_Joystick *joystick, hid_device *dev, void *context);
    61                                  Uint16 vendor_id, Uint16 product_id, int *num_joysticks);
    55     void (*Quit)(SDL_Joystick *joystick, hid_device *dev, void *context);
    62     void           (*QuitDriver)(SDL_HIDAPI_DriverData *context,
       
    63                                  SDL_bool send_event,
       
    64                                  int *num_joysticks);
       
    65     SDL_bool       (*UpdateDriver)(SDL_HIDAPI_DriverData *context,
       
    66                                    int *num_joysticks);
       
    67     int            (*NumJoysticks)(SDL_HIDAPI_DriverData *context);
       
    68     SDL_JoystickID (*InstanceIDForIndex)(SDL_HIDAPI_DriverData *context,
       
    69                                          int index);
       
    70     SDL_bool       (*OpenJoystick)(SDL_HIDAPI_DriverData *context,
       
    71                                    SDL_Joystick *joystick);
       
    72     int            (*Rumble)(SDL_HIDAPI_DriverData *context,
       
    73                              SDL_Joystick *joystick,
       
    74                              Uint16 low_frequency_rumble,
       
    75                              Uint16 high_frequency_rumble,
       
    76                              Uint32 duration_ms);
    56 
    77 
    57 } SDL_HIDAPI_DeviceDriver;
    78 } SDL_HIDAPI_DeviceDriver;
    58 
    79 
    59 /* HIDAPI device support */
    80 /* HIDAPI device support */
    60 extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4;
    81 extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4;
    61 extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam;
    82 extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam;
    62 extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch;
    83 extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch;
    63 extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360;
    84 extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360;
    64 extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne;
    85 extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne;
       
    86 extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube;
    65 
    87 
    66 /* Return true if a HID device is present and supported as a joystick */
    88 /* Return true if a HID device is present and supported as a joystick */
    67 extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version);
    89 extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version);
    68 
    90 
    69 /* Return the name of an Xbox 360 or Xbox One controller */
    91 /* Return the name of an Xbox 360 or Xbox One controller */