src/events/SDL_events.c
changeset 1361 19418e4422cb
parent 1358 c71e05b4dc2e
child 1402 d910939febfa
equal deleted inserted replaced
1360:70a9cfb4cf1b 1361:19418e4422cb
    21 */
    21 */
    22 
    22 
    23 /* General event handling code for SDL */
    23 /* General event handling code for SDL */
    24 
    24 
    25 #include "SDL.h"
    25 #include "SDL.h"
    26 #include "SDL_events_c.h"
       
    27 #include "SDL_timer_c.h"
       
    28 #ifndef DISABLE_JOYSTICK
       
    29 #include "SDL_joystick_c.h"
       
    30 #endif
       
    31 #ifndef ENABLE_X11
       
    32 #define DISABLE_X11
       
    33 #endif
       
    34 #include "SDL_syswm.h"
    26 #include "SDL_syswm.h"
    35 #include "SDL_sysevents.h"
    27 #include "SDL_sysevents.h"
       
    28 #include "SDL_events_c.h"
       
    29 #include "../timer/SDL_timer_c.h"
       
    30 #if !SDL_JOYSTICK_DISABLED
       
    31 #include "../joystick/SDL_joystick_c.h"
       
    32 #endif
    36 
    33 
    37 /* Public data -- the event filter */
    34 /* Public data -- the event filter */
    38 SDL_EventFilter SDL_EventOK = NULL;
    35 SDL_EventFilter SDL_EventOK = NULL;
    39 Uint8 SDL_ProcessEvents[SDL_NUMEVENTS];
    36 Uint8 SDL_ProcessEvents[SDL_NUMEVENTS];
    40 static Uint32 SDL_eventstate = 0;
    37 static Uint32 SDL_eventstate = 0;
   110 		}
   107 		}
   111 
   108 
   112 		/* Queue pending key-repeat events */
   109 		/* Queue pending key-repeat events */
   113 		SDL_CheckKeyRepeat();
   110 		SDL_CheckKeyRepeat();
   114 
   111 
   115 #ifndef DISABLE_JOYSTICK
   112 #if !SDL_JOYSTICK_DISABLED
   116 		/* Check for joystick state change */
   113 		/* Check for joystick state change */
   117 		if ( SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK) ) {
   114 		if ( SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK) ) {
   118 			SDL_JoystickUpdate();
   115 			SDL_JoystickUpdate();
   119 		}
   116 		}
   120 #endif
   117 #endif
   148 	/* Reset everything to zero */
   145 	/* Reset everything to zero */
   149 	SDL_EventThread = NULL;
   146 	SDL_EventThread = NULL;
   150 	SDL_memset(&SDL_EventLock, 0, sizeof(SDL_EventLock));
   147 	SDL_memset(&SDL_EventLock, 0, sizeof(SDL_EventLock));
   151 
   148 
   152 	/* Create the lock and set ourselves active */
   149 	/* Create the lock and set ourselves active */
   153 #ifndef DISABLE_THREADS
   150 #if !SDL_THREADS_DISABLED
   154 	SDL_EventQ.lock = SDL_CreateMutex();
   151 	SDL_EventQ.lock = SDL_CreateMutex();
   155 	if ( SDL_EventQ.lock == NULL ) {
   152 	if ( SDL_EventQ.lock == NULL ) {
   156 #ifdef macintosh /* On MacOS 7/8, you can't multithread, so no lock needed */
   153 #ifdef macintosh /* MacOS classic you can't multithread, so no lock needed */
   157 		;
   154 		;
   158 #else
   155 #else
   159 		return(-1);
   156 		return(-1);
   160 #endif
   157 #endif
   161 	}
   158 	}
   162 #endif /* !DISABLE_THREADS */
   159 #endif /* !SDL_THREADS_DISABLED */
   163 	SDL_EventQ.active = 1;
   160 	SDL_EventQ.active = 1;
   164 
   161 
   165 	if ( (flags&SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD ) {
   162 	if ( (flags&SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD ) {
   166 		SDL_EventLock.lock = SDL_CreateMutex();
   163 		SDL_EventLock.lock = SDL_CreateMutex();
   167 		if ( SDL_EventLock.lock == NULL ) {
   164 		if ( SDL_EventLock.lock == NULL ) {
   377 		}
   374 		}
   378 
   375 
   379 		/* Queue pending key-repeat events */
   376 		/* Queue pending key-repeat events */
   380 		SDL_CheckKeyRepeat();
   377 		SDL_CheckKeyRepeat();
   381 
   378 
   382 #ifndef DISABLE_JOYSTICK
   379 #if !SDL_JOYSTICK_DISABLED
   383 		/* Check for joystick state change */
   380 		/* Check for joystick state change */
   384 		if ( SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK) ) {
   381 		if ( SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK) ) {
   385 			SDL_JoystickUpdate();
   382 			SDL_JoystickUpdate();
   386 		}
   383 		}
   387 #endif
   384 #endif