1 /* Catacomb Armageddon Source Code
\r
2 * Copyright (C) 1993-2014 Flat Rock Software
\r
4 * This program is free software; you can redistribute it and/or modify
\r
5 * it under the terms of the GNU General Public License as published by
\r
6 * the Free Software Foundation; either version 2 of the License, or
\r
7 * (at your option) any later version.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License along
\r
15 * with this program; if not, write to the Free Software Foundation, Inc.,
\r
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
21 // ID_IN.h - Header file for Input Manager
\r
23 // By Jason Blochowiak
24 // Open Watcom port by sparky4
\r
31 #include "src/lib/lib_head.h"
\r
32 //#include "src/lib/16_us.h"
\r
34 //++++#ifdef __DEBUG__
\r
35 #define __DEBUG_InputMgr__
\r
40 #define TESTCONTROLNOISY
\r
42 #define KeyInt 9 // The keyboard ISR number
\r
44 // Stuff for the joystick
\r
45 #define JoyScaleMax 32768
\r
46 #define JoyScaleShift 8
\r
47 #define MaxJoyValue 5000
\r
49 #define MaxPlayers 4
\r
52 #define NumCodes 128
\r
54 typedef byte ScanCode;
\r
57 #define sc_Return 0x1c
\r
58 #define sc_Enter sc_Return
\r
59 #define sc_Escape 0x01
\r
60 #define sc_Space 0x39
\r
61 #define sc_BackSpace 0x0e
\r
64 #define sc_Control 0x1d
\r
65 #define sc_CapsLock 0x3a
\r
66 #define sc_LShift 0x2a
\r
67 #define sc_RShift 0x36
\r
68 #define sc_UpArrow 0x48
\r
69 #define sc_DownArrow 0x50
\r
70 #define sc_LeftArrow 0x4b
\r
71 #define sc_RightArrow 0x4d
\r
72 #define sc_Insert 0x52
\r
73 #define sc_Delete 0x53
\r
74 #define sc_Home 0x47
\r
76 #define sc_PgUp 0x49
\r
77 #define sc_PgDn 0x51
\r
130 #define key_Return 0x0d
\r
131 #define key_Enter key_Return
\r
132 #define key_Escape 0x1b
\r
133 #define key_Space 0x20
\r
134 #define key_BackSpace 0x08
\r
135 #define key_Tab 0x09
\r
136 #define key_Delete 0x7f
\r
138 #define key_LSuper 0x5b
139 #define key_RSuper 0x5c
140 #define key_Menu 0x5d
142 // Stuff for the mouse
\r
147 #define MouseInt 0x33
\r
150 demo_Off,demo_Record,demo_Playback,demo_PlayDone
\r
154 ctrl_None, // MDM (GAMERS EDGE) - added
\r
156 ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,
\r
158 ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,
\r
162 motion_Left = -1,motion_Up = -1,
\r
164 motion_Right = 1,motion_Down = 1
\r
167 dir_North,//dir_NorthEast,
\r
168 dir_East,//dir_SouthEast,
\r
169 dir_South,//dir_SouthWest,
\r
170 dir_West,//dir_NorthWest,
\r
174 boolean button0,button1;
\r
176 Motion xaxis,yaxis;
\r
179 typedef CursorInfo ControlInfo;
\r
182 ScanCode button0,button1,
\r
193 word joyMinX,joyMinY,
\r
194 threshMinX,threshMinY,
\r
195 threshMaxX,threshMaxY,
\r
197 joyMultXL,joyMultYL,
\r
198 joyMultXH,joyMultYH;
\r
201 =============================================================================
\r
205 =============================================================================
\r
209 // configuration variables
\r
211 static boolean MousePresent;
\r
212 static boolean JoysPresent[MaxJoys];
\r
213 static boolean JoyPadPresent;
\r
215 // Global variables
\r
216 extern boolean JoystickCalibrated; // MDM (GAMERS EDGE) - added
\r
217 extern ControlType ControlTypeUsed; // MDM (GAMERS EDGE) - added
\r
219 extern boolean Keyboard[NumCodes];
\r
220 extern boolean Paused;
\r
221 extern char LastASCII;
\r
222 extern ScanCode LastScan;
\r
224 //extern KeyboardDef KbdDefs[];
225 static KeyboardDef KbdDefs[] = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};
\r
226 extern JoystickDef JoyDefs[MaxJoys];
\r
227 extern ControlType Controls[MaxPlayers];
\r
229 extern dword MouseDownCount;
\r
232 static Demo DemoMode = demo_Off;
\r
233 static byte /*_seg*/ *DemoBuffer;
\r
234 static word DemoOffset,DemoSize;
\r
237 extern dword far* clockdw;
\r
240 =============================================================================
\r
244 =============================================================================
\r
246 static byte far ASCIINames[] = // Unshifted ASCII for scan codes
\r
248 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
\r
249 0 ,27 ,'1','2','3','4','5','6','7','8','9','0','-','=',8 ,9 , // 0
\r
250 'q','w','e','r','t','y','u','i','o','p','[',']',13 ,0 ,'a','s', // 1
\r
251 'd','f','g','h','j','k','l',';',39 ,'`',0 ,92 ,'z','x','c','v', // 2
\r
252 'b','n','m',',','.','/',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3
\r
253 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4
\r
254 '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
\r
255 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
\r
256 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
\r
258 far ShiftNames[] = // Shifted ASCII for scan codes
\r
260 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
\r
261 0 ,27 ,'!','@','#','$','%','^','&','*','(',')','_','+',8 ,9 , // 0
\r
262 'Q','W','E','R','T','Y','U','I','O','P','{','}',13 ,0 ,'A','S', // 1
\r
263 'D','F','G','H','J','K','L',':',34 ,'~',0 ,'|','Z','X','C','V', // 2
\r
264 'B','N','M','<','>','?',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3
\r
265 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4
\r
266 '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
\r
267 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
\r
268 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
\r
270 far SpecialNames[] = // ASCII for 0xe0 prefixed codes
\r
272 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
\r
273 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 0
\r
274 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,13 ,0 ,0 ,0 , // 1
\r
275 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 2
\r
276 0 ,0 ,0 ,0 ,0 ,'/',0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 3
\r
277 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 4
\r
278 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
\r
279 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
\r
280 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
\r
284 static boolean IN_Started;
\r
285 static boolean CapsLock;
\r
286 static ScanCode CurCode,LastCode;
\r
288 static Direction DirTable[] = // Quick lookup for total direction
\r
293 dir_West, dir_None, dir_East,
\r
295 dir_South//,dir_SouthEast
\r
298 static void (*INL_KeyHook)(void);
\r
299 static void interrupt (*OldKeyVect)(void);
\r
301 static char *ParmStringsIN[] = {"nojoys","nomouse",nil};
\r
303 // Function prototypes
\r
304 #define IN_KeyDown(code) (Keyboard[(code)])
\r
305 #define IN_ClearKey(code) {Keyboard[code] = false;\
\r
306 if (code == LastScan) LastScan = sc_None;}
\r
308 // DEBUG - put names in prototypes
\r
309 extern void IN_Startup(void),IN_Shutdown(void),
\r
310 IN_Default(boolean gotit,ControlType in),
\r
311 IN_SetKeyHook(void (*)()),
\r
312 IN_ClearKeysDown(void),
\r
313 IN_ReadCursor(CursorInfo *),
\r
314 IN_ReadControl(int,ControlInfo *),
\r
315 IN_SetControlType(int,ControlType),
\r
316 IN_GetJoyAbs(word joy,word *xp,word *yp),
\r
317 IN_SetupJoy(word joy,word minx,word maxx,
\r
318 word miny,word maxy),
\r
321 IN_StartDemoPlayback(byte __segment *buffer,word bufsize),
\r
322 IN_StopDemo(void),IN_FreeDemoBuffer(void),
\r
324 IN_Ack(void),IN_AckBack(void);
\r
325 extern boolean IN_UserInput(dword delay,boolean clear),
\r
326 IN_IsUserInput(void)
\r
328 , IN_StartDemoRecord(word bufsize)
\r
331 extern byte *IN_GetScanName(ScanCode);
\r
332 extern char IN_WaitForASCII(void);
\r
333 extern ScanCode IN_WaitForKey(void);
\r
334 extern word IN_GetJoyButtonsDB(word joy);
\r
337 void interrupt INL_KeyService(void);
\r
338 boolean IN_qb(byte kee);
\r