I’ve looked at the BeOS, Linux, and Win32 implementations, and the following
seems very reasonable:
/* Joystick axis motion event structure /
typedef struct {
Uint8 type; / SDL_JOYMOTION /
Uint8 which; / The joystick device index /
Uint8 index; / The joystick axis index /
float tx; / Translation in the X direction /
float ty; / Translation in the Y direction /
float tz; / Translation in the Z direction /
float rx; / Rotation in the X direction /
float ry; / Rotation in the Y direction /
float rz; / Rotation in the Z direction */
} SDL_JoyMotionEvent;
/* Joystick button event structure /
typedef struct {
Uint8 type; / SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP /
Uint8 which; / The joystick device index /
Uint8 button; / The joystick button index /
Uint8 state; / SDL_PRESSED or SDL_RELEASED */
} SDL_JoyButtonEvent;
/* Function prototypes /
/
- Count the number of joysticks attached to the system
*/
extern DECLSPEC int SDL_NumJoysticks(void);
/*
- Open a joystick for use - the index passed as an argument refers to
- the N’th joystick on the system. This index is the value which will
- identify this joystick in future joystick events.*
- This function returns a joystick identifier, or NULL if an error occurred.
*/
extern DECLSPEC SDL_Joystick *SDL_JoystickOpen(int index);
/*
- Get the implementation dependent name of a joystick
*/
extern DECLSPEC const char *SDL_JoystickName(SDL_Joystick *joystick);
/*
- Get the device index of an opened joystick.
*/
extern DECLSPEC int SDL_JoystickIndex(SDL_Joystick *joystick);
/*
- Get the number of buttons on a joystick
*/
extern DECLSPEC int SDL_JoystickNumButtons(SDL_Joystick *joystick);
/*
- Get the number of multi-dimensional axes on a joystick
*/
extern DECLSPEC int SDL_JoystickNumAxes(SDL_Joystick *joystick);
/*
- Get the current state of a button on a joystick
*/
extern DECLSPEC Uint8 SDL_GetJoystickButton(SDL_Joystick joystick, int button);
/ - Get the current state of an axis on a joystick
*/
extern DECLSPEC const struct SDL_AxisState *SDL_GetJoystickAxis
(SDL_Joystick *joystick, int axis);
/*
- Close a joystick previously opened with SDL_JoystickOpen()
*/
extern DECLSPEC void SDL_JoystickClose(SDL_Joystick *joystick);
–
This is just a preliminary API without any code. Comments are welcome.
See ya!
-Sam Lantinga (slouken at devolution.com)
Lead Programmer, Loki Entertainment Software
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec