Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
This commit is contained in:
parent
2a4a81ad63
commit
34b88dfaae
30 changed files with 4191 additions and 580 deletions
|
@ -23,12 +23,13 @@
|
|||
/* This is the system specific header for the SDL joystick API */
|
||||
|
||||
#include "SDL_joystick.h"
|
||||
#include "SDL_joystick_c.h"
|
||||
|
||||
/* The SDL joystick structure */
|
||||
struct _SDL_Joystick
|
||||
{
|
||||
Uint8 index; /* Device index */
|
||||
const char *name; /* Joystick name - system dependent */
|
||||
int instance_id; /* Device instance, monotonically increasing from 0 */
|
||||
char *name; /* Joystick name - system dependent */
|
||||
|
||||
int naxes; /* Number of axis controls on the joystick */
|
||||
Sint16 *axes; /* Current axis states */
|
||||
|
@ -49,6 +50,10 @@ struct _SDL_Joystick
|
|||
struct joystick_hwdata *hwdata; /* Driver dependent information */
|
||||
|
||||
int ref_count; /* Reference count for multiple opens */
|
||||
|
||||
Uint8 closed; /* 1 if this device is no longer valid */
|
||||
Uint8 uncentered; /* 1 if this device needs to have its state reset to 0 */
|
||||
struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
|
||||
};
|
||||
|
||||
/* Function to scan the system for joysticks.
|
||||
|
@ -59,14 +64,17 @@ struct _SDL_Joystick
|
|||
extern int SDL_SYS_JoystickInit(void);
|
||||
|
||||
/* Function to get the device-dependent name of a joystick */
|
||||
extern const char *SDL_SYS_JoystickName(int index);
|
||||
extern const char *SDL_SYS_JoystickNameForIndex(int index);
|
||||
|
||||
/* Function to get the current instance id of the joystick located at device_index */
|
||||
extern SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex( int device_index );
|
||||
|
||||
/* Function to open a joystick for use.
|
||||
The joystick to open is specified by the index field of the joystick.
|
||||
This should fill the nbuttons and naxes fields of the joystick structure.
|
||||
It returns 0, or -1 if there is an error.
|
||||
*/
|
||||
extern int SDL_SYS_JoystickOpen(SDL_Joystick * joystick);
|
||||
extern int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index );
|
||||
|
||||
/* Function to update the state of a joystick - called as a device poll.
|
||||
* This function shouldn't update the joystick structure directly,
|
||||
|
@ -81,4 +89,32 @@ extern void SDL_SYS_JoystickClose(SDL_Joystick * joystick);
|
|||
/* Function to perform any system-specific joystick related cleanup */
|
||||
extern void SDL_SYS_JoystickQuit(void);
|
||||
|
||||
/* Function to query if the joystick is currently attached
|
||||
* It returns 1 if attached, 0 otherwise.
|
||||
*/
|
||||
extern int SDL_SYS_JoystickAttached(SDL_Joystick * joystick);
|
||||
|
||||
/* Function to return the number of joystick devices plugged in right now*/
|
||||
extern int SDL_SYS_NumJoysticks();
|
||||
|
||||
/* Function to cause any queued joystick insertions to be processed
|
||||
*/
|
||||
extern void SDL_SYS_JoystickDetect();
|
||||
|
||||
/* Function to determine if the joystick loop needs to run right now
|
||||
*/
|
||||
extern int SDL_SYS_JoystickNeedsPolling();
|
||||
|
||||
/* Function to return the stable GUID for a plugged in device
|
||||
*/
|
||||
extern JoystickGUID SDL_SYS_PrivateJoystickGetDeviceID( int device_index );
|
||||
|
||||
/* Function to return the stable GUID for a opened joystick
|
||||
*/
|
||||
extern JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick);
|
||||
|
||||
#ifdef __WIN32__
|
||||
/* Function to get the current instance id of the joystick located at device_index */
|
||||
extern int SDL_SYS_IsXInputDeviceIndex( int device_index );
|
||||
#endif
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue