src/joystick/SDL_sysjoystick.h
changeset 12088 399cc39583cc
parent 11934 a7061d1f4ee4
child 12090 c3209fca27b2
     1.1 --- a/src/joystick/SDL_sysjoystick.h	Wed Aug 08 15:39:20 2018 -0400
     1.2 +++ b/src/joystick/SDL_sysjoystick.h	Thu Aug 09 16:00:17 2018 -0700
     1.3 @@ -42,6 +42,7 @@
     1.4  {
     1.5      SDL_JoystickID instance_id; /* Device instance, monotonically increasing from 0 */
     1.6      char *name;                 /* Joystick name - system dependent */
     1.7 +    SDL_JoystickGUID guid;      /* Joystick guid */
     1.8  
     1.9      int naxes;                  /* Number of axis controls on the joystick */
    1.10      SDL_JoystickAxisInfo *axes;
    1.11 @@ -58,69 +59,95 @@
    1.12      int nbuttons;               /* Number of buttons on the joystick */
    1.13      Uint8 *buttons;             /* Current button states */
    1.14  
    1.15 +    SDL_bool is_game_controller;
    1.16 +    SDL_bool delayed_guide_button; /* SDL_TRUE if this device has the guide button event delayed */
    1.17 +    SDL_bool force_recentering; /* SDL_TRUE if this device needs to have its state reset to 0 */
    1.18 +    SDL_JoystickPowerLevel epowerlevel; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */
    1.19 +    struct _SDL_JoystickDriver *driver;
    1.20 +
    1.21      struct joystick_hwdata *hwdata;     /* Driver dependent information */
    1.22  
    1.23      int ref_count;              /* Reference count for multiple opens */
    1.24  
    1.25 -    SDL_bool is_game_controller;
    1.26 -    SDL_bool delayed_guide_button; /* SDL_TRUE if this device has the guide button event delayed */
    1.27 -    SDL_bool force_recentering; /* SDL_TRUE if this device needs to have its state reset to 0 */
    1.28 -    SDL_JoystickPowerLevel epowerlevel; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */
    1.29      struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
    1.30  };
    1.31  
    1.32 +#if defined(__IPHONEOS__) || defined(__ANDROID__)
    1.33 +#define HAVE_STEAMCONTROLLERS
    1.34 +#define USE_STEAMCONTROLLER_HIDAPI
    1.35 +#elif defined(__LINUX__)
    1.36 +#define HAVE_STEAMCONTROLLERS
    1.37 +#define USE_STEAMCONTROLLER_LINUX
    1.38 +#endif
    1.39 +
    1.40 +/* Device bus definitions */
    1.41 +#define SDL_HARDWARE_BUS_USB        0x03
    1.42 +#define SDL_HARDWARE_BUS_BLUETOOTH  0x05
    1.43 +
    1.44  /* Macro to combine a USB vendor ID and product ID into a single Uint32 value */
    1.45  #define MAKE_VIDPID(VID, PID)   (((Uint32)(VID))<<16|(PID))
    1.46  
    1.47 -/* Function to scan the system for joysticks.
    1.48 - * Joystick 0 should be the system default joystick.
    1.49 - * This function should return the number of available joysticks, or -1
    1.50 - * on an unrecoverable fatal error.
    1.51 - */
    1.52 -extern int SDL_SYS_JoystickInit(void);
    1.53 +typedef struct _SDL_JoystickDriver
    1.54 +{
    1.55 +    /* Function to scan the system for joysticks.
    1.56 +     * Joystick 0 should be the system default joystick.
    1.57 +     * This function should return 0, or -1 on an unrecoverable error.
    1.58 +     */
    1.59 +    int (*Init)(void);
    1.60  
    1.61 -/* Function to return the number of joystick devices plugged in right now */
    1.62 -extern int SDL_SYS_NumJoysticks(void);
    1.63 +    /* Function to return the number of joystick devices plugged in right now */
    1.64 +    int (*GetCount)(void);
    1.65  
    1.66 -/* Function to cause any queued joystick insertions to be processed */
    1.67 -extern void SDL_SYS_JoystickDetect(void);
    1.68 +    /* Function to cause any queued joystick insertions to be processed */
    1.69 +    void (*Detect)(void);
    1.70  
    1.71 -/* Function to get the device-dependent name of a joystick */
    1.72 -extern const char *SDL_SYS_JoystickNameForDeviceIndex(int device_index);
    1.73 +    /* Function to get the device-dependent name of a joystick */
    1.74 +    const char *(*GetDeviceName)(int device_index);
    1.75  
    1.76 -/* Function to get the current instance id of the joystick located at device_index */
    1.77 -extern SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index);
    1.78 +    /* Function to return the stable GUID for a plugged in device */
    1.79 +    SDL_JoystickGUID (*GetDeviceGUID)(int device_index);
    1.80  
    1.81 -/* Function to open a joystick for use.
    1.82 -   The joystick to open is specified by the device index.
    1.83 -   This should fill the nbuttons and naxes fields of the joystick structure.
    1.84 -   It returns 0, or -1 if there is an error.
    1.85 - */
    1.86 -extern int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index);
    1.87 +    /* Function to get the current instance id of the joystick located at device_index */
    1.88 +    SDL_JoystickID (*GetDeviceInstanceID)(int device_index);
    1.89  
    1.90 -/* Function to query if the joystick is currently attached
    1.91 - * It returns SDL_TRUE if attached, SDL_FALSE otherwise.
    1.92 - */
    1.93 -extern SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick * joystick);
    1.94 +    /* Function to open a joystick for use.
    1.95 +       The joystick to open is specified by the device index.
    1.96 +       This should fill the nbuttons and naxes fields of the joystick structure.
    1.97 +       It returns 0, or -1 if there is an error.
    1.98 +     */
    1.99 +    int (*Open)(SDL_Joystick * joystick, int device_index);
   1.100  
   1.101 -/* Function to update the state of a joystick - called as a device poll.
   1.102 - * This function shouldn't update the joystick structure directly,
   1.103 - * but instead should call SDL_PrivateJoystick*() to deliver events
   1.104 - * and update joystick device state.
   1.105 - */
   1.106 -extern void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick);
   1.107 +    /* Function to query if the joystick is currently attached
   1.108 +     * It returns SDL_TRUE if attached, SDL_FALSE otherwise.
   1.109 +     */
   1.110 +    SDL_bool (*IsAttached)(SDL_Joystick * joystick);
   1.111  
   1.112 -/* Function to close a joystick after use */
   1.113 -extern void SDL_SYS_JoystickClose(SDL_Joystick * joystick);
   1.114 +    /* Rumble functionality */
   1.115 +    int (*Rumble)(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
   1.116  
   1.117 -/* Function to perform any system-specific joystick related cleanup */
   1.118 -extern void SDL_SYS_JoystickQuit(void);
   1.119 +    /* Function to update the state of a joystick - called as a device poll.
   1.120 +     * This function shouldn't update the joystick structure directly,
   1.121 +     * but instead should call SDL_PrivateJoystick*() to deliver events
   1.122 +     * and update joystick device state.
   1.123 +     */
   1.124 +    void (*Update)(SDL_Joystick * joystick);
   1.125  
   1.126 -/* Function to return the stable GUID for a plugged in device */
   1.127 -extern SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index);
   1.128 +    /* Function to close a joystick after use */
   1.129 +    void (*Close)(SDL_Joystick * joystick);
   1.130  
   1.131 -/* Function to return the stable GUID for a opened joystick */
   1.132 -extern SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick);
   1.133 +    /* Function to perform any system-specific joystick related cleanup */
   1.134 +    void (*Quit)(void);
   1.135 +
   1.136 +} SDL_JoystickDriver;
   1.137 +
   1.138 +/* The available joystick drivers */
   1.139 +extern SDL_JoystickDriver SDL_ANDROID_JoystickDriver;
   1.140 +extern SDL_JoystickDriver SDL_DARWIN_JoystickDriver;
   1.141 +extern SDL_JoystickDriver SDL_DUMMY_JoystickDriver;
   1.142 +extern SDL_JoystickDriver SDL_HIDAPI_JoystickDriver;
   1.143 +extern SDL_JoystickDriver SDL_IOS_JoystickDriver;
   1.144 +extern SDL_JoystickDriver SDL_LINUX_JoystickDriver;
   1.145 +extern SDL_JoystickDriver SDL_WINDOWS_JoystickDriver;
   1.146  
   1.147  #endif /* SDL_sysjoystick_h_ */
   1.148