vlp-10 using coding style in eventque
[vlp.git] / src / int / eventque.h
1 /**
2  ** EVENTQUE.H
3  **
4  **  Copyright (C) 1992, Csaba Biegl
5  **    820 Stirrup Dr, Nashville, TN, 37221
6  **    csaba@vuse.vanderbilt.edu
7  **
8  **  This file is distributed under the terms listed in the document
9  **  "copying.cb", available from the author at the address above.
10  **  A copy of "copying.cb" should accompany this file; if not, a copy
11  **  should be available from where this file was obtained.  This file
12  **  may not be distributed without a verbatim copy of "copying.cb".
13  **  You should also have received a copy of the GNU General Public
14  **  License along with this program (it is in the file "copying");
15  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
16  **  Cambridge, MA 02139, USA.
17  **
18  **  This program is distributed in the hope that it will be useful,
19  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  **  GNU General Public License for more details.
22  **/
23
24 #ifndef _EVENTQUE_H_
25 #define _EVENTQUE_H_
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /*
32  * structures:
33  *  BE CAREFUL when hacking!!! -- 16 and 32 bit compilers have to generate
34  *  the same alignments
35  */
36 typedef struct {
37         /** event type: 0: keyboard, 1: mouse */
38         unsigned char   evt_type;
39         
40         /** keyboard status (ALT, SHIFT, etc..) */
41         unsigned char   evt_kbstat;
42         
43         /** mouse event mask */
44         unsigned char   evt_mask;
45         
46         /** button status */
47         unsigned char   evt_button;
48         
49         /** X coord (or keycode if keybd event) */
50         unsigned short  evt_xpos;
51         
52         /** Y coord */
53         unsigned short  evt_ypos;
54         
55         /** time stamp of event */
56         unsigned long   evt_time;
57         
58         /** reuse this slot for keybd events !! */
59 #define evt_keycode   evt_xpos
60
61         /** store here the BIOS scan code */
62 #define evt_scancode  evt_ypos
63 } EventRecord;
64
65 typedef struct {
66         /** max size of event queue */
67         unsigned short evq_maxsize;
68         
69         /** number of events in the queue */
70         unsigned short evq_cursize;
71         
72         /** next event to read */
73         unsigned short evq_rdptr;
74         
75         /** next event to be written */
76         unsigned short evq_wrptr;
77         
78         /** current X coordinate of mouse */
79         short evq_xpos;
80         
81         /** current Y coordinate of mouse */
82         short evq_ypos;
83         
84         /** minimal mouse X coordinate */
85         short evq_xmin;
86         
87         /** minimal mouse Y coordinate */
88         short evq_ymin;
89         
90         /** maximal mouse X coordinate */
91         short evq_xmax;
92         
93         /** maximal mouse Y coordinate */
94         short evq_ymax;
95         
96         /** horizontal speed (mickey/coord) */
97         short evq_xspeed;
98         
99         /** vertical speed (mickey/coord) */
100         short evq_yspeed;
101         
102         /** fast movement threshold */
103         unsigned short evq_thresh;
104         
105         /** multiplier for fast move */
106         unsigned short evq_accel;
107         
108         /** interrupt handler has to draw mouse */
109         unsigned char evq_drawmouse;
110         
111         /** set if mouse moved */
112         unsigned char evq_moved;
113         
114         /** character removed from BIOS buffer */
115         unsigned char evq_delchar;
116         
117         /** event generation control flag */
118         unsigned char evq_enable;
119         
120         /** event buffer space */
121         EventRecord evq_events[1];
122 } EventQueue;
123
124 /**
125  * event types
126  */
127 #define EVENT_KEYBD     0
128 #define EVENT_MOUSE     1
129
130 /**
131  * MOUSE event flag bits
132  * (also defined in "mousex.h" of the graphics library)
133  * \defgroup MouseEventFlagBits MOUSE event flag bits
134  * @{
135  */
136 #ifndef M_MOTION
137
138 #define M_MOTION        0x001
139 #define M_LEFT_DOWN     0x002
140 #define M_LEFT_UP       0x004
141 #define M_RIGHT_DOWN    0x008
142 #define M_RIGHT_UP      0x010
143 #define M_MIDDLE_DOWN   0x020
144 #define M_MIDDLE_UP     0x040
145 #define M_BUTTON_DOWN   (M_LEFT_DOWN | M_MIDDLE_DOWN | M_RIGHT_DOWN)
146 #define M_BUTTON_UP     (M_LEFT_UP   | M_MIDDLE_UP   | M_RIGHT_UP)
147 #define M_BUTTON_CHANGE (M_BUTTON_UP | M_BUTTON_DOWN )
148
149 /**
150  * MOUSE button status bits
151  * \defgroup MouseButtonStatusBits MOUSE button status bits
152  * @{
153  */
154 #define M_LEFT          1
155 #define M_RIGHT         2
156 #define M_MIDDLE        4
157 /** @} */
158
159 #endif
160 /** @} */
161
162 /**
163  * KEYBOARD status word bits
164  * (also defined in "mousex.h" of the graphics library)
165  * \defgroup KeyboardStatusWordBits KEYBOARD status word bits
166  * @{
167  */
168 #ifndef KB_SHIFT
169
170 /** right shift key depressed */
171 #define KB_RIGHTSHIFT   0x01
172
173 /** left shift key depressed */
174 #define KB_LEFTSHIFT    0x02
175
176 /** CTRL depressed */
177 #define KB_CTRL         0x04
178
179 /** ALT depressed */
180 #define KB_ALT          0x08
181
182 /** SCROLL LOCK active */
183 #define KB_SCROLLOCK    0x10
184
185 /** NUM LOCK active */
186 #define KB_NUMLOCK      0x20
187
188 /** CAPS LOCK active */
189 #define KB_CAPSLOCK     0x40
190
191 /** INSERT state active */
192 #define KB_INSERT       0x80
193
194 #define KB_SHIFT        (KB_LEFTSHIFT | KB_RIGHTSHIFT)
195
196 #endif
197 /** @} */
198
199 /*
200  * set this bit in 'evq_enable' to generate the corresponding event
201  */
202 #define EVENT_ENABLE(type)      (1 << (type))
203
204 /*
205  * prototypes
206  */
207 #if defined(__TURBOC__) && defined(FOR_GO32)
208 EventQueue *EventQueueInit(int qsize,int ms_stksize,void (*msdraw)(void),int,int);
209 #else
210 EventQueue *EventQueueInit(int qsize,int ms_stksize,void (*msdraw)(void));
211 #endif
212
213 void   EventQueueDeInit(void);
214 int    EventQueueNextEvent(EventQueue *q,EventRecord *e);
215
216 #ifdef __cplusplus
217 }
218 #endif
219
220 #endif /* whole file */
221
222