Advanced Strategic Command
events.h
Go to the documentation of this file.
1 /***************************************************************************
2  events.h - description
3  -------------------
4  begin : Wed Oct 18 2000
5  copyright : (C) 2000 by Martin Bickel
6  email : bickel@asc-hq.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 /***************************************************************************
20  * *
21  * Event handling routines *
22  * *
23  ***************************************************************************/
24 
25 #ifndef events_h_included
26 #define events_h_included
27 
28 #include <SDL.h>
29 
36 extern bool setEventRouting( bool queue, bool legacy );
37 
38 extern bool legacyEventSystemActive();
39 
40 extern int initializeEventHandling ( int (*fn)(void *) , void *data );
41 
42 
44  public:
47 };
48 
49 
50 extern void exit_asc( int returnresult );
51 
53 
54 extern bool redrawScreen;
55 
56 /***************************************************************************
57  * *
58  * Mouse handling routines *
59  * *
60  ***************************************************************************/
61 
62 
63 struct tmouserect {
64  int x1, y1;
65  int x2, y2;
66  tmouserect operator+ ( const tmouserect& b ) const;
67 // tmouserect ( int _x1, int _y1, int _x2, int _y2 ) : x1(_x1), y1(_y1), x2(_x2), y2(_y2 ) {};
68 // tmouserect(){ x1=0;y1=0;x2=0;y2=0;};
69 };
70 
71 extern void mousevisible( int an );
72 extern int getmousestatus ();
73 
74 extern void setmouseposition ( int x, int y );
75 
76 extern void setnewmousepointer ( void* picture, int hotspotx, int hotspoty );
77 
78 extern int mouseinrect ( int x1, int y1, int x2, int y2 );
79 
80 
81 extern int mouseinrect ( const tmouserect* rect );
82 
84  public:
85  int x;
86  int y;
87  int x1;
88  int y1;
89  int altx;
90  int alty;
91  void *background;
92  void *pictpointer;
93  int xsize;
94  int ysize;
95  Uint8 taste;
96  Uint8 status;
98  int hotspotx;
99  int hotspoty;
101  tmousesettings ( ) { x=0;y=0;x1=0;y1=0;altx=0;alty=0;
102  background=NULL;pictpointer=NULL;
103  xsize=0;ysize=0;taste=0;status=0;
105  off.x1=0;off.y1=0;off.x2=0;off.y2=0;
106  };
107 };
108 
109 
110 
111 
112 
113 extern void mouseintproc2( void );
114 extern volatile tmousesettings mouseparams;
115 
116 
117 /***************************************************************************
118  * *
119  * Keyboard handling routines *
120  * *
121  ***************************************************************************/
122 
123 
124  #include "sdl/keysymbols.h"
125 
126  typedef int tkey;
127 
128  extern char skeypress( tkey keynr);
129  extern char *get_key(tkey keynr);
130  extern int keypress(void);
131  extern void wait(void);
132  extern tkey char2key (int ch);
133  extern void getkeysyms ( tkey* keysym, int* keyprnt );
134 
135  extern int exitprogram;
136 
137 
138  extern bool isKeyPressed(SDLKey key);
139 
140 /***************************************************************************
141  * *
142  * Timer routines *
143  * *
144  ***************************************************************************/
145 
146 
147  extern volatile int ticker;
148  extern void ndelay(int time);
149 
150  extern void starttimer(void); //resets Timer
151  extern bool time_elapsed(int time); //check if time msecs are elapsed, since starttimer
152  extern int releasetimeslice( void );
153 
154  extern int getTicker();
155 
157  extern bool getQueuedEvent ( SDL_Event& event );
158 
160  extern bool peekEvent ( SDL_Event& event );
161 
163  extern void setMouseUpdateFlag( const bool* flag );
164 
165 
166 #endif
bool getQueuedEvent(SDL_Event &event)
if the events are being queue, get one.
Definition: events.cpp:657
void * background
Definition: events.h:91
void wait(void)
Definition: events.cpp:195
void * pictpointer
Definition: events.h:92
void exit_asc(int returnresult)
Definition: events.cpp:612
int x1
Definition: events.h:64
int backgroundsize
Definition: events.h:100
void mouseintproc2(void)
int hotspotx
Definition: events.h:98
int getTicker()
Definition: events.cpp:525
Uint8 status
Definition: events.h:96
bool time_elapsed(int time)
Definition: events.cpp:254
tkey char2key(int ch)
Definition: events.cpp:200
void ndelay(int time)
Definition: events.cpp:236
void starttimer(void)
Definition: events.cpp:249
Uint8 taste
Definition: events.h:95
int getmousestatus()
Definition: events.cpp:79
int mouseinrect(int x1, int y1, int x2, int y2)
Definition: events.cpp:108
void setMouseUpdateFlag(const bool *flag)
passes a references which' value determines if the mouse cursor is hidden on screen updates ...
Definition: events.cpp:69
tmousesettings()
Definition: events.h:101
int hotspoty
Definition: events.h:99
int keypress(void)
Definition: events.cpp:146
int releasetimeslice(void)
Definition: events.cpp:209
void setmouseposition(int x, int y)
Definition: events.cpp:99
int exitprogram
Definition: events.cpp:53
int initializeEventHandling(int(*fn)(void *), void *data)
Definition: events.cpp:560
char skeypress(tkey keynr)
Definition: events.cpp:181
int tkey
Definition: events.h:126
bool isKeyPressed(SDLKey key)
Definition: events.cpp:187
int y2
Definition: events.h:65
bool legacyEventSystemActive()
Definition: events.cpp:651
bool setEventRouting(bool queue, bool legacy)
Defines what happens with the SDL events.
Definition: events.cpp:633
char * get_key(tkey keynr)
tmouserect off
Definition: events.h:97
tmouserect operator+(const tmouserect &b) const
Definition: events.cpp:126
int y1
Definition: events.h:64
void getkeysyms(tkey *keysym, int *keyprnt)
Definition: events.cpp:157
void setnewmousepointer(void *picture, int hotspotx, int hotspoty)
Definition: events.cpp:104
void mousevisible(int an)
Definition: events.cpp:75
volatile tmousesettings mouseparams
Definition: events.cpp:35
int x2
Definition: events.h:65
bool redrawScreen
Definition: events.cpp:63
bool peekEvent(SDL_Event &event)
gets the next event without removing it from the queue.
Definition: events.cpp:670
volatile int ticker
Definition: events.cpp:234