31 #if !SDL_EVENTS_DISABLED
32 #include "../events/SDL_events_c.h"
42 if (hint && *hint ==
'1') {
58 #if !SDL_EVENTS_DISABLED
105 const char *joystickname =
NULL;
116 while ( joysticklist )
119 joystick = joysticklist;
123 joysticklist = joysticklist->
next;
128 if (joystick ==
NULL) {
145 if (joystick->
naxes > 0) {
149 if (joystick->
nhats > 0) {
153 if (joystick->
nballs > 0) {
161 if (((joystick->
naxes > 0) && !joystick->
axes)
162 || ((joystick->
nhats > 0) && !joystick->
hats)
169 if (joystick->
axes) {
172 if (joystick->
hats) {
175 if (joystick->
balls) {
187 SDL_joysticks = joystick;
203 if ( joystick ==
NULL ) {
210 if ( joystick && joystick->
closed )
227 return (joystick->
naxes);
239 return (joystick->
nhats);
251 return (joystick->
nballs);
277 if (axis < joystick->naxes) {
278 state = joystick->
axes[axis];
297 if (hat < joystick->nhats) {
298 state = joystick->
hats[hat];
319 if (ball < joystick->nballs) {
321 *dx = joystick->
balls[ball].
dx;
324 *dy = joystick->
balls[ball].
dy;
345 if (button < joystick->nbuttons) {
346 state = joystick->
buttons[button];
391 return (joystick->
name);
412 if (joystick == SDL_updating_joystick) {
419 joysticklistprev =
NULL;
420 while ( joysticklist )
422 if (joystick == joysticklist)
424 if ( joysticklistprev )
427 joysticklistprev->
next = joysticklist->
next;
431 SDL_joysticks = joystick->
next;
436 joysticklistprev = joysticklist;
437 joysticklist = joysticklist->
next;
457 while ( SDL_joysticks )
466 #if !SDL_EVENTS_DISABLED
501 if (axis >= joystick->
naxes) {
506 if (value == joystick->
axes[axis]) {
522 #if !SDL_EVENTS_DISABLED
527 event.jaxis.axis = axis;
528 event.jaxis.value =
value;
541 if (hat >= joystick->
nhats) {
560 #if !SDL_EVENTS_DISABLED
565 event.jhat.hat = hat;
566 event.jhat.value =
value;
580 if (ball >= joystick->
nballs) {
590 joystick->
balls[ball].
dx += xrel;
591 joystick->
balls[ball].
dy += yrel;
595 #if !SDL_EVENTS_DISABLED
600 event.jball.ball = ball;
601 event.jball.xrel = xrel;
602 event.jball.yrel = yrel;
613 #if !SDL_EVENTS_DISABLED
641 joystick->
buttons[button] = state;
645 #if !SDL_EVENTS_DISABLED
648 event.jbutton.button = button;
649 event.jbutton.state = state;
668 joysticknext = joystick->
next;
670 SDL_updating_joystick = joystick;
679 for (i = 0; i < joystick->
naxes; i++)
682 for (i = 0; i < joystick->
nbuttons; i++)
685 for (i = 0; i < joystick->
nhats; i++)
691 SDL_updating_joystick =
NULL;
698 joystick = joysticknext;
710 #if SDL_EVENTS_DISABLED
713 const Uint32 event_list[] = {
743 if (SDL_joysticks !=
NULL) {
772 static const char k_rgchHexToASCII[] =
"0123456789abcdef";
775 if ((pszGUID ==
NULL) || (cbGUID <= 0)) {
779 for ( i = 0; i <
sizeof(guid.
data) && i < (cbGUID-1)/2; i++ )
783 unsigned char c = guid.
data[
i];
785 *pszGUID++ = k_rgchHexToASCII[ c >> 4 ];
786 *pszGUID++ = k_rgchHexToASCII[ c & 0x0F ];
802 return (
unsigned char)(c -
'0');
808 return (
unsigned char)(c -
'A' + 0x0a);
814 return (
unsigned char)(c -
'a' + 0x0a);
827 int maxoutputbytes=
sizeof(guid);
833 len = (
len ) & ~0
x1;
839 ( i <
len ) && ( ( p - (
Uint8 *)&guid ) < maxoutputbytes );
842 *p = (
nibble( pchGUID[i] ) << 4 ) |
nibble( pchGUID[i+1] );
#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
A variable that lets you enable joystick (and gamecontroller) events even when your app is in the bac...
DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index)
int SDL_PrivateJoystickValid(SDL_Joystick *joystick)
static SDL_Joystick * SDL_updating_joystick
DECLSPEC void SDLCALL SDL_JoystickUpdate(void)
DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event)
Add an event to the event queue.
DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick)
int SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value)
int SDL_SYS_NumJoysticks()
DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joystick)
struct _SDL_Joystick * next
DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick *joystick)
DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick)
int SDL_JoystickInit(void)
DECLSPEC void SDLCALL SDL_free(void *mem)
DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index)
int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID)
EGLImageKHR EGLint * name
DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state)
DECLSPEC void SDLCALL SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis)
void SDL_SYS_JoystickQuit(void)
int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button)
struct _SDL_Joystick::balldelta * balls
uint32_t Uint32
An unsigned 32-bit integer type.
int SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball, Sint16 xrel, Sint16 yrel)
DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags)
static SDL_bool SDL_joystick_allows_background_events
#define SDL_GetEventState(type)
DECLSPEC char *SDLCALL SDL_strdup(const char *str)
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags)
DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len)
void SDL_SYS_JoystickDetect()
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
const char * SDL_SYS_JoystickNameForDeviceIndex(int device_index)
DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick)
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick *joystick)
GLuint GLfloat GLfloat GLfloat x1
DECLSPEC int SDLCALL SDL_JoystickEventState(int state)
SDL_bool SDL_SYS_JoystickNeedsPolling()
#define SDL_assert(condition)
DECLSPEC size_t SDLCALL SDL_strlen(const char *str)
int SDL_SYS_JoystickInit(void)
DECLSPEC void SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID)
#define SDL_OutOfMemory()
#define SDL_arraysize(array)
EGLSurface EGLint void ** value
static unsigned char nibble(char c)
DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick)
DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick *joystick)
uint8_t Uint8
An unsigned 8-bit integer type.
DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick)
int16_t Sint16
A signed 16-bit integer type.
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index)
static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent()
int SDL_SYS_JoystickOpen(SDL_Joystick *joystick, int device_index)
DECLSPEC SDL_Window *SDLCALL SDL_GetKeyboardFocus(void)
Get the window which currently has keyboard focus.
void SDL_JoystickQuit(void)
static void SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
SDL_bool SDL_PrivateJoystickNeedsPolling()
DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick)
SDL_JoystickID instance_id
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index)
DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat)
DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags)
static SDL_Joystick * SDL_joysticks
DECLSPEC int SDLCALL SDL_NumJoysticks(void)