Advanced Strategic Command
Functions | Variables
events.cpp File Reference
#include <queue>
#include <SDL.h>
#include <SDL_thread.h>
#include "ctype.h"
#include "../events.h"
#include "../stack.h"
#include "../basegfx.h"
#include "../global.h"
#include "../errors.h"
#include "../util/messaginghub.h"
#include "graphicsqueue.h"
#include <iostream>
Include dependency graph for events.cpp:

Go to the source code of this file.

Functions

void setMouseUpdateFlag (const bool *flag)
 passes a references which' value determines if the mouse cursor is hidden on screen updates More...
 
void mousevisible (int an)
 
int getmousestatus ()
 
int mouseTranslate (int m)
 
void setmouseposition (int x, int y)
 
void setnewmousepointer (void *picture, int hotspotx, int hotspoty)
 
int mouseinrect (int x1, int y1, int x2, int y2)
 
int mouseinrect (const tmouserect *rect)
 
int keypress (void)
 
void getkeysyms (tkey *keysym, int *keyprnt)
 
char skeypress (tkey keynr)
 
bool isKeyPressed (SDLKey key)
 
void wait (void)
 
tkey char2key (int c)
 
int releasetimeslice (void)
 
void ndelay (int time)
 
void starttimer (void)
 
bool time_elapsed (int time)
 
int processEvents ()
 
void queueOperation (GraphicsQueueOperation *gqo, bool wait, bool forceAsync)
 
bool processGraphicsQueue ()
 
int eventthread (void *nothing)
 
int getTicker ()
 
int initializeEventHandling (int(*gamethread)(void *), void *data)
 
void exit_asc (int returnresult)
 
bool setEventRouting (bool queue, bool legacy)
 Defines what happens with the SDL events. More...
 
bool legacyEventSystemActive ()
 
bool getQueuedEvent (SDL_Event &event)
 if the events are being queue, get one. More...
 
bool peekEvent (SDL_Event &event)
 gets the next event without removing it from the queue. More...
 

Variables

volatile tmousesettings mouseparams
 
SDL_mutex * keyboardmutex = NULL
 
SDL_mutex * eventHandlingMutex = NULL
 
SDL_mutex * eventQueueMutex = NULL
 
SDL_mutex * graphicsQueueMutex = NULL
 
queue< tkeykeybuffer_sym
 
queue< Uint32 > keybuffer_prnt
 
queue< SDL_Event > eventQueue
 
bool _queueEvents = true
 
bool _fillLegacyEventStructures = false
 
volatile bool eventThreadRunning = false
 
std::list
< GraphicsQueueOperation * > 
graphicsQueue
 
int exitprogram = 0
 
bool redrawScreen = false
 
const bool trueflag = true
 
const bool * mouseUpdateFlag = &trueflag
 
volatile int ticker = 0
 
int tticker = 0
 
volatile int closeEventThread = 0
 
const int keyTranslationNum = 7
 
int keyTranslation [keyTranslationNum][2]
 
bool syncGraphics = true
 
sigc::signal< void, const
SDL_Surface * > 
postScreenUpdate
 
SDL_Thread * secondThreadHandle = NULL
 The handle for the second thread; depending on platform this could be the event handling thread or the game thread. More...
 

Function Documentation

tkey char2key ( int  c)

Definition at line 200 of file events.cpp.

References ct_invvalue.

Referenced by tdlgengine::addbutton().

int eventthread ( void *  nothing)
void exit_asc ( int  returnresult)

Definition at line 612 of file events.cpp.

References closeEventThread.

Referenced by main().

void getkeysyms ( tkey keysym,
int *  keyprnt 
)
int getmousestatus ( )
bool getQueuedEvent ( SDL_Event &  event)

if the events are being queue, get one.

Returns
false if no event available

Definition at line 657 of file events.cpp.

References eventQueue, and eventQueueMutex.

Referenced by EventSupplier::PollEvent(), and EventSupplier::WaitEvent().

int getTicker ( )

Definition at line 525 of file events.cpp.

Referenced by eventthread().

int initializeEventHandling ( int(*)(void *)  gamethread,
void *  data 
)
bool isKeyPressed ( SDLKey  key)
int keypress ( void  )
bool legacyEventSystemActive ( )
int mouseinrect ( int  x1,
int  y1,
int  x2,
int  y2 
)
int mouseinrect ( const tmouserect rect)
int mouseTranslate ( int  m)

Definition at line 84 of file events.cpp.

Referenced by processEvents().

void mousevisible ( int  an)
void ndelay ( int  time)

Definition at line 236 of file events.cpp.

References releasetimeslice(), and ticker.

bool peekEvent ( SDL_Event &  event)

gets the next event without removing it from the queue.

Returns
false if no event available

Definition at line 670 of file events.cpp.

References eventQueue, and eventQueueMutex.

Referenced by EventSupplier::PeepEvent().

int processEvents ( )
bool processGraphicsQueue ( )

Definition at line 478 of file events.cpp.

References GraphicsQueueOperation::execute(), graphicsQueue, and graphicsQueueMutex.

Referenced by eventthread().

void queueOperation ( GraphicsQueueOperation gqo,
bool  wait,
bool  forceAsync 
)
int releasetimeslice ( void  )
bool setEventRouting ( bool  queue,
bool  legacy 
)

Defines what happens with the SDL events.

Parameters
queueEvents are queued to be extracted with getQueuedEvent
legacyEvents are evaluated and the global legacy structures updated
Returns
the previous state of the event queing

Definition at line 633 of file events.cpp.

References _fillLegacyEventStructures, _queueEvents, eventQueue, and eventQueueMutex.

Referenced by ASC_PG_App::enableLegacyEventHandling(), tdialogbox::tdialogbox(), and tdialogbox::~tdialogbox().

void setmouseposition ( int  x,
int  y 
)

Definition at line 99 of file events.cpp.

void setMouseUpdateFlag ( const bool *  flag)

passes a references which' value determines if the mouse cursor is hidden on screen updates

Definition at line 69 of file events.cpp.

References mouseUpdateFlag.

Referenced by ASC_PG_App::ASC_PG_App().

void setnewmousepointer ( void *  picture,
int  hotspotx,
int  hotspoty 
)

Definition at line 104 of file events.cpp.

char skeypress ( tkey  keynr)

Definition at line 181 of file events.cpp.

Referenced by tviewtextwithscrolling::checkscrolling(), and researchinfo().

void starttimer ( void  )

Definition at line 249 of file events.cpp.

References ticker, and tticker.

bool time_elapsed ( int  time)

Definition at line 254 of file events.cpp.

References ticker, and tticker.

void wait ( void  )

Definition at line 195 of file events.cpp.

Variable Documentation

bool _fillLegacyEventStructures = false

Definition at line 46 of file events.cpp.

Referenced by legacyEventSystemActive(), processEvents(), and setEventRouting().

bool _queueEvents = true

Definition at line 45 of file events.cpp.

Referenced by processEvents(), and setEventRouting().

volatile int closeEventThread = 0

Definition at line 270 of file events.cpp.

Referenced by eventthread(), exit_asc(), and initializeEventHandling().

SDL_mutex* eventHandlingMutex = NULL
queue<SDL_Event> eventQueue

Definition at line 44 of file events.cpp.

Referenced by getQueuedEvent(), peekEvent(), processEvents(), and setEventRouting().

SDL_mutex* eventQueueMutex = NULL
volatile bool eventThreadRunning = false

Definition at line 48 of file events.cpp.

Referenced by eventthread(), and queueOperation().

int exitprogram = 0

Definition at line 53 of file events.cpp.

Referenced by processEvents().

std::list<GraphicsQueueOperation*> graphicsQueue

Definition at line 51 of file events.cpp.

Referenced by processGraphicsQueue(), and queueOperation().

SDL_mutex* graphicsQueueMutex = NULL

Definition at line 40 of file events.cpp.

Referenced by initializeEventHandling(), processGraphicsQueue(), and queueOperation().

SDL_mutex* keyboardmutex = NULL

Definition at line 37 of file events.cpp.

Referenced by getkeysyms(), initializeEventHandling(), keypress(), and processEvents().

queue<Uint32> keybuffer_prnt

Definition at line 43 of file events.cpp.

Referenced by getkeysyms(), and processEvents().

queue<tkey> keybuffer_sym

Definition at line 42 of file events.cpp.

Referenced by getkeysyms(), keypress(), and processEvents().

int keyTranslation[keyTranslationNum][2]
Initial value:
= { { 228, 132 },
{ 246, 148 },
{ 252, 129 },
{ 196, 142 },
{ 214, 153 },
{ 220, 154 },
{ 223, 225 } }

Definition at line 273 of file events.cpp.

Referenced by processEvents().

const int keyTranslationNum = 7

Definition at line 272 of file events.cpp.

Referenced by processEvents().

volatile tmousesettings mouseparams
const bool* mouseUpdateFlag = &trueflag
sigc::signal<void,const SDL_Surface*> postScreenUpdate
bool redrawScreen = false

Definition at line 63 of file events.cpp.

Referenced by ASC_PG_App::eventIdle(), processEvents(), and releasetimeslice().

SDL_Thread* secondThreadHandle = NULL

The handle for the second thread; depending on platform this could be the event handling thread or the game thread.

Definition at line 556 of file events.cpp.

bool syncGraphics = true

Definition at line 389 of file events.cpp.

Referenced by queueOperation().

volatile int ticker = 0
const bool trueflag = true

Definition at line 65 of file events.cpp.

int tticker = 0

Definition at line 247 of file events.cpp.

Referenced by starttimer(), and time_elapsed().