source: trunk/src/kernel32/console/vio32.h@ 5087

Last change on this file since 5087 was 5024, checked in by sandervl, 25 years ago

added preliminary console code

File size: 7.2 KB
Line 
1#if !defined (_KBD32_)
2#define _KBD32_
3
4#define INCL_DOS
5#define INCL_PM
6#define INCL_WIN
7#define INCL_VIO
8#define INCL_SUB
9#define INCL_DOSERRORS
10#include <os2.h>
11#include "MonitorApi.h"
12
13#pragma pack (1)
14/** */
15typedef struct _KBD32KEYINFO {
16 BOOL keyUp;
17 ULONG status;
18 USHORT repeat;
19 USHORT scancode;
20 USHORT chr;
21 USHORT vKey;
22} KBD32KEYINFO;
23
24/** */
25typedef struct _VIO32MOUINFO {
26 USHORT x;
27 USHORT y;
28 ULONG buttonStatus;
29 ULONG status;
30 ULONG eventType;
31} VIO32MOUINFO;
32
33/** */
34typedef struct _pmMsg{
35 /** */
36 MPARAM mp1;
37 /** */
38 MPARAM mp2;
39} pmMsgType;
40
41// any of the possible messages
42typedef union _VIO32EVENTINFO {
43 /** generic mp1 mp2 message */
44 pmMsgType pmMsg;
45 /** */
46 KBDKEYINFO vioKbd;
47 /** */
48 MOUEVENTINFO vioMou;
49 /** */
50 MonRecord monKbd;
51 /** hook intercepted data */
52 CHRMSG wmchar;
53 /** */
54// MSEMSG wmmouse;
55 /** */
56 KBD32KEYINFO vio32Kbd;
57 /** */
58 VIO32MOUINFO vio32Mou;
59} VIO32EVENTINFO;
60
61// the kbd + mouse status (as scan codes)
62typedef struct _VIO32STATUSINFO {
63 // 256 bits (scan codes) + 32 bit special scans: mouse...
64 ULONG status[9];
65} VIO32STATUSINFO;
66
67/** to create hook-like plugins for vio32 */
68typedef struct _vio32Filter {
69 VOID *next;
70 /** associated information: MUST be unique for each filter! NOT NULL!! */
71 VOID *filterData;
72 /** filtering function */
73 BOOL (*filter)(ULONG *eventType,VIO32EVENTINFO *event,VOID *filterData);
74} vio32Filter;
75
76#pragma pack(4)
77
78// macro to check if a key is pressed on a VIO32STATUSINFO : BOOL
79#define KBD32_CHECKKEY(scanState,scanCode) ((scanState.status[scanCode >> 5] & (1 << (scanCode & 0x1F))) != 0)
80
81// macro to mark a key as pressed on a VIO32STATUSINFO : VOID
82#define KBD32_SETKEY(scanState,scanCode) (scanState.status[scanCode >> 5] |= (1 << (scanCode & 0x1F)))
83
84// macro to mark a key as dePressed on a VIO32STATUSINFO : VOID
85#define KBD32_UNSETKEY(scanState,scanCode) (scanState.status[scanCode >> 5] &= (~(1 << (scanCode & 0x1F))))
86
87// macro to toggle a key status : VOID
88#define KBD32_TOGGLEKEY(scanState,scanCode) (scanState.status[scanCode >> 5] ^= (1 << (scanCode & 0x1F)))
89
90// macro to cleanup a scanState structure
91#define KBD32_RESETKEYS(scanState) { \
92 scanState.status[0] = 0; \
93 scanState.status[1] = 0; \
94 scanState.status[2] = 0; \
95 scanState.status[3] = 0; \
96 scanState.status[4] = 0; \
97 scanState.status[5] = 0; \
98 scanState.status[6] = 0; \
99 scanState.status[7] = 0; \
100 scanState.status[8] = 0; \
101}
102
103
104// the scan assigned to mouse button 1
105#define KBD32_MB1_SCAN 0x101
106
107// the scan assigned to mouse button 2
108#define KBD32_MB2_SCAN 0x102
109
110// the scan assigned to mouse button 3
111#define KBD32_MB3_SCAN 0x103
112
113// the scan assigned to mouse button 4
114#define KBD32_MB4_SCAN 0x104
115
116// the scan assigned to mouse button 5
117#define KBD32_MB5_SCAN 0x105
118
119// the scan assigned to the caps lock status
120#define KBD32_CAPSLOCK_SCAN 0x106
121
122// the scan assigned to the scroll lock status
123#define KBD32_SCROLLLOCK_SCAN 0x107
124
125// the scan assigned to the num lock status
126#define KBD32_NUMLOCK_SCAN 0x108
127
128// the scan assigned to the insert status
129#define KBD32_INSERT_SCAN 0x109
130
131//
132#define KBD32_SHIFTL_SCAN 0x02A
133
134//
135#define KBD32_SHIFTR_SCAN 0x036
136
137// the normal scan code produced by the api, as a status it is the left ALT
138#define KBD32_ALTL_SCAN 0x038
139
140// only valid as status: right ALT
141#define KBD32_ALTR_SCAN 0x10A
142
143// the normal scan code produced by the api, as a status it is the left ALT
144#define KBD32_CTRLL_SCAN 0x01D
145
146// only valid as status: right ALT
147#define KBD32_CTRLR_SCAN 0x10B
148
149// only valid as status: Mouse button 1
150#define VIO32_MB1_SCAN 0x10C
151
152// only valid as status: Mouse button 2
153#define VIO32_MB2_SCAN 0x10D
154
155// only valid as status: Mouse button 3
156#define VIO32_MB3_SCAN 0x10E
157
158// only valid as status: Mouse button 4
159#define VIO32_MB4_SCAN 0x10F
160
161// only valid as status: Mouse button 5
162#define VIO32_MB5_SCAN 0x110
163
164// a message coming from the KbdCharIn call
165#define VIO_CHAR WM_USER
166
167// a message coming from the monitor routine
168#define MON_CHAR WM_USER+1
169
170// a char message translated to the KBD32KEYINFO
171#define KBD32_CHAR WM_USER+2
172
173// a message coming from the mouse calls
174#define VIO_MOU WM_USER+3
175
176// the translated mouse messages
177#define VIO32_MOU WM_USER+4
178
179// CTRL-BREAK is disallowed to break the program
180#define KBD32MODE_DISABLEBREAK 0x1
181
182// enable mouse click events
183#define KBD32MODE_ENABLEMOUSE 0x2
184
185// enable mouse move events
186#define KBD32MODE_ENABLEMMOVE 0x4
187
188// compatible with win32
189#define KBD32_SHIFT 0x00000010
190#define KBD32_CTRL_L 0x00000008
191#define KBD32_CTRL_R 0x00000004
192#define KBD32_ALT_L 0x00000002
193#define KBD32_ALT_R 0x00000001
194#define KBD32_NUMLOCK 0x00000020
195#define KBD32_CAPSLOCK 0x00000080
196#define KBD32_SCROLLLOCK 0x00000040
197#define KBD32_ENHANCED_KEY 0x00000100
198
199// compatible with win32: mouse button status
200#define VIO32_MB1 0x0001
201#define VIO32_MB2 0x0002
202#define VIO32_MB3 0x0004
203#define VIO32_MB4 0x0008
204#define VIO32_MB5 0x0010
205// compatible with win32: mouse event types
206#define VIO32_MOUSEMOVE 0x0001
207#define VIO32_DOUBLECLICK 0x0002
208
209// Filter where modes
210// first of the preprocessing filters
211#define VIO32_PRE_FIRST 0x000000000
212// last of the preprocessing filters
213#define VIO32_PRE_LAST 0x00000FFFF
214// first of the postprocessing filters (activated on read)
215#define VIO32_POST_FIRST 0x000010000
216// last of the postprocessing filters (activated on read)
217#define VIO32_POST_LAST 0x00001FFFF
218
219
220
221/** for client use */
222extern "C" {
223 /** */
224 APIRET EXPENTRY vio32Open();
225 /** */
226 APIRET EXPENTRY vio32Close();
227 /** */
228 APIRET EXPENTRY kbd32GetKey(KBD32KEYINFO *key,ULONG msecTimeout);
229 /** */
230 APIRET EXPENTRY vio32GetMouse(VIO32MOUINFO *mou,ULONG msecTimeout);
231 /** */
232 APIRET EXPENTRY vio32GetEvent(VIO32EVENTINFO *event,ULONG *eventType,ULONG msecTimeout);
233 /** */
234 APIRET EXPENTRY vio32GetEventQSize(ULONG *size,ULONG msecTimeout);
235 /** */
236 APIRET EXPENTRY vio32WriteEvent(VIO32EVENTINFO *event, ULONG *eventType);
237 /** inconsistency problems with the output filters To be Solved*/
238 APIRET EXPENTRY vio32PeekEvent(VIO32EVENTINFO *event,ULONG *eventType,ULONG position);
239 /** inconsistency problems with the output filters To be Solved*/
240 APIRET EXPENTRY vio32FlushEventQ();
241 /** */
242 APIRET EXPENTRY kbd32SetMode(ULONG mode);
243 /** */
244 APIRET EXPENTRY kbd32GetMode(ULONG *mode);
245 /** where is the position on the LIST returns the actual position 0x10000 ored indicates the output list */
246 APIRET EXPENTRY kbd32AddFilter(vio32Filter *filter,ULONG *where);
247 /** the filter is identified by its data field */
248 APIRET EXPENTRY kbd32RemoveFilter(VOID *filterData);
249 /** */
250 APIRET EXPENTRY kbd32GetKeyStatus(VIO32STATUSINFO *status);
251
252}
253
254
255
256
257
258
259
260#endif
Note: See TracBrowser for help on using the repository browser.