#include "uInputQueue.h"
#include "rScreen.h"
#include "tConfiguration.h"
#include <iostream>
#include "rSDL.h"
#include "tRecorder.h"
#include "uMenu.h"
Go to the source code of this file.
Classes | |
class | EventArchiver< Archiver > |
Read or write event data. More... | |
Defines | |
#define | MAX_PENDING_INPUT 100 |
Functions | |
static REAL | Time () |
static void | increase (int &i) |
void | su_FetchAndStoreSDLInput () |
bool | su_StoreSDLEvent (const SDL_Event &tEvent) |
stores an event so it will be returned by GetSDLInput() later | |
tRECORDING_ENUM (SDLKey) | |
tRECORDING_ENUM (SDLMod) | |
void | su_EndGetSDLInput () |
bool | su_GetSDLInput (SDL_Event &tEvent, REAL &time) |
fetches an event | |
Variables | |
static su_TimerCallback * | timer = NULL |
bool | su_prefetchInput = false |
bool | su_contInput = true |
static REAL | times [MAX_PENDING_INPUT] |
static SDL_Event | tEvents [MAX_PENDING_INPUT] |
static int | currentIn = 0 |
static int | current_out = 0 |
static int | next_in = 1 |
static bool | input_get = false |
static char const * | recordingSection = "INPUT" |
static const char * | su_end = "END" |
static const char * | su_endInput = "ENDINPUT" |
static bool | su_markerRequired = false |
#define MAX_PENDING_INPUT 100 |
static void increase | ( | int & | i | ) | [inline, static] |
Definition at line 70 of file uInputQueue.cpp.
References MAX_PENDING_INPUT.
Referenced by next_free_server(), su_GetSDLInput(), and su_StoreSDLEvent().
00070 { 00071 i++; 00072 if (i>=MAX_PENDING_INPUT) 00073 i=0; 00074 }
void su_EndGetSDLInput | ( | ) |
Definition at line 221 of file uInputQueue.cpp.
References tRecorder::Playback(), tRecorder::Record(), su_endInput, and su_markerRequired.
Referenced by uInputProcessGuard::~uInputProcessGuard().
00222 { 00223 if ( su_markerRequired ) 00224 { 00225 // record end of input fetching 00226 tRecorder::Playback(su_endInput); 00227 tRecorder::Record(su_endInput); 00228 su_markerRequired = false; 00229 } 00230 }
void su_FetchAndStoreSDLInput | ( | ) |
Definition at line 79 of file uInputQueue.cpp.
References tRecorderBase::IsRunning().
Referenced by eGrid::display_simple(), eGameObject::RenderAll(), eCamera::s_Timestep(), and eGameObject::TimestepThisWrapper().
00080 { 00081 #ifndef DEDICATED 00082 #ifndef WIN32 00083 #ifndef MACOSX 00084 if (!tRecorder::IsRunning() ) 00085 SDL_PumpEvents(); 00086 #endif 00087 #endif 00088 #endif 00089 }
bool su_GetSDLInput | ( | SDL_Event & | tEvent, | |
REAL & | time | |||
) |
fetches an event
Definition at line 256 of file uInputQueue.cpp.
References EventArchiver< Archiver >::Archive(), current_out, currentIn, increase(), input_get, tRecorder::Playback(), uMenu::quickexit, tRecorder::Record(), sr_LockSDL(), sr_UnlockSDL(), su_end, su_markerRequired, tEvents, Time, and times.
Referenced by gGame::GameLoop(), uMenu::IdleInput(), uMenu::Message(), uMenu::OnEnter(), su_GetSDLInput(), and welcome().
00256 { 00257 bool ret=false; 00258 00259 // clear out data 00260 memset( &tEvent, 0, sizeof( SDL_Event ) ); 00261 00262 // find end of recording in playback 00263 if ( tRecorder::Playback(su_end) ) 00264 { 00265 tRecorder::Record(su_end); 00266 uMenu::quickexit=true; 00267 } 00268 00269 // try to fetch event from playback 00270 if ( !EventArchiver< tPlaybackBlock >::Archive( tEvent, time, ret ) ) 00271 { 00272 // get real event 00273 sr_LockSDL(); 00274 input_get=true; 00275 if (current_out!=currentIn){ 00276 time=times[current_out]; 00277 tEvent=tEvents[current_out]; 00278 increase(current_out); 00279 ret=true; 00280 } 00281 else{ 00282 time=Time(); 00283 ret= 00284 #ifndef DEDICATED 00285 SDL_PollEvent(&tEvent); 00286 #else 00287 false; 00288 #endif 00289 } 00290 sr_UnlockSDL(); 00291 input_get=false; 00292 } 00293 00294 su_markerRequired |= ret; 00295 00296 // store event in recording 00297 if ( ret ) 00298 EventArchiver< tRecordingBlock >::Archive( tEvent, time, ret ); 00299 00300 return ret;
bool su_StoreSDLEvent | ( | const SDL_Event & | tEvent | ) |
stores an event so it will be returned by GetSDLInput() later
Definition at line 92 of file uInputQueue.cpp.
References current_out, currentIn, increase(), input_get, next_in, tEvents, Time, and times.
Referenced by filter().
00092 { 00093 if (next_in!=current_out && !input_get){ 00094 //con << "Extra input!\n"; 00095 tEvents[currentIn]=tEvent; 00096 times[currentIn]=Time(); 00097 increase(currentIn); 00098 next_in=currentIn; 00099 increase(next_in); 00100 return false; 00101 } 00102 return true; 00103 }
static REAL Time | ( | ) | [inline, static] |
Definition at line 52 of file uInputQueue.cpp.
References su_TimerCallback::GetTime().
tRECORDING_ENUM | ( | SDLMod | ) |
tRECORDING_ENUM | ( | SDLKey | ) |
int current_out = 0 [static] |
Definition at line 67 of file uInputQueue.cpp.
Referenced by su_GetSDLInput(), and su_StoreSDLEvent().
int currentIn = 0 [static] |
Definition at line 67 of file uInputQueue.cpp.
bool input_get = false [static] |
Definition at line 77 of file uInputQueue.cpp.
Referenced by su_GetSDLInput(), and su_StoreSDLEvent().
int next_in = 1 [static] |
char const* recordingSection = "INPUT" [static] |
Definition at line 111 of file uInputQueue.cpp.
bool su_contInput = true |
const char* su_end = "END" [static] |
const char* su_endInput = "ENDINPUT" [static] |
bool su_markerRequired = false [static] |
Definition at line 219 of file uInputQueue.cpp.
Referenced by su_EndGetSDLInput(), and su_GetSDLInput().
bool su_prefetchInput = false |
Definition at line 59 of file uInputQueue.cpp.
Referenced by exit_game_objects(), filter(), and init_game_objects().
SDL_Event tEvents[MAX_PENDING_INPUT] [static] |
Definition at line 65 of file uInputQueue.cpp.
Referenced by su_GetSDLInput(), and su_StoreSDLEvent().
su_TimerCallback* timer = NULL [static] |
Definition at line 41 of file uInputQueue.cpp.
Definition at line 64 of file uInputQueue.cpp.
Referenced by su_GetSDLInput(), and su_StoreSDLEvent().