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
41 #define KeyInt 9 // The keyboard ISR number
\r
43 // Stuff for the joystick
\r
44 #define JoyScaleMax 32768
\r
45 #define JoyScaleShift 8
\r
46 #define MaxJoyValue 5000
\r
48 #define MaxPlayers 4
\r
51 #define NumCodes 128
\r
53 typedef byte ScanCode;
\r
56 #define sc_Return 0x1c
\r
57 #define sc_Enter sc_Return
\r
58 #define sc_Escape 0x01
\r
59 #define sc_Space 0x39
\r
60 #define sc_BackSpace 0x0e
\r
63 #define sc_Control 0x1d
\r
64 #define sc_CapsLock 0x3a
\r
65 #define sc_LShift 0x2a
\r
66 #define sc_RShift 0x36
\r
67 #define sc_UpArrow 0x48
\r
68 #define sc_DownArrow 0x50
\r
69 #define sc_LeftArrow 0x4b
\r
70 #define sc_RightArrow 0x4d
\r
71 #define sc_Insert 0x52
\r
72 #define sc_Delete 0x53
\r
73 #define sc_Home 0x47
\r
75 #define sc_PgUp 0x49
\r
76 #define sc_PgDn 0x51
\r
129 #define key_Return 0x0d
\r
130 #define key_Enter key_Return
\r
131 #define key_Escape 0x1b
\r
132 #define key_Space 0x20
\r
133 #define key_BackSpace 0x08
\r
134 #define key_Tab 0x09
\r
135 #define key_Delete 0x7f
\r
137 // Stuff for the mouse
\r
142 #define MouseInt 0x33
\r
145 demo_Off,demo_Record,demo_Playback,demo_PlayDone
\r
149 ctrl_None, // MDM (GAMERS EDGE) - added
\r
151 ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,
\r
153 ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,
\r
157 motion_Left = -1,motion_Up = -1,
\r
159 motion_Right = 1,motion_Down = 1
\r
162 dir_North,//dir_NorthEast,
\r
163 dir_East,//dir_SouthEast,
\r
164 dir_South,//dir_SouthWest,
\r
165 dir_West,//dir_NorthWest,
\r
169 boolean button0,button1;
\r
171 Motion xaxis,yaxis;
\r
174 typedef CursorInfo ControlInfo;
\r
177 ScanCode button0,button1,
\r
188 word joyMinX,joyMinY,
\r
189 threshMinX,threshMinY,
\r
190 threshMaxX,threshMaxY,
\r
192 joyMultXL,joyMultYL,
\r
193 joyMultXH,joyMultYH;
\r
196 =============================================================================
\r
200 =============================================================================
\r
204 // configuration variables
\r
206 static boolean MousePresent;
\r
207 static boolean JoysPresent[MaxJoys];
\r
208 static boolean JoyPadPresent;
\r
210 // Global variables
\r
211 extern boolean JoystickCalibrated; // MDM (GAMERS EDGE) - added
\r
212 extern ControlType ControlTypeUsed; // MDM (GAMERS EDGE) - added
\r
214 extern boolean Keyboard[NumCodes];
\r
215 extern boolean Paused;
\r
216 extern char LastASCII;
\r
217 extern ScanCode LastScan;
\r
219 //extern KeyboardDef KbdDefs[];
220 static KeyboardDef KbdDefs[] = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};
\r
221 extern JoystickDef JoyDefs[MaxJoys];
\r
222 extern ControlType Controls[MaxPlayers];
\r
224 extern dword MouseDownCount;
\r
227 static Demo DemoMode = demo_Off;
\r
228 static byte /*_seg*/ *DemoBuffer;
\r
229 static word DemoOffset,DemoSize;
\r
232 extern dword far* clockdw;
\r
235 =============================================================================
\r
239 =============================================================================
\r
241 static byte far ASCIINames[] = // Unshifted ASCII for scan codes
\r
243 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
\r
244 0 ,27 ,'1','2','3','4','5','6','7','8','9','0','-','=',8 ,9 , // 0
\r
245 'q','w','e','r','t','y','u','i','o','p','[',']',13 ,0 ,'a','s', // 1
\r
246 'd','f','g','h','j','k','l',';',39 ,'`',0 ,92 ,'z','x','c','v', // 2
\r
247 'b','n','m',',','.','/',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3
\r
248 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4
\r
249 '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
\r
250 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
\r
251 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
\r
253 far ShiftNames[] = // Shifted ASCII for scan codes
\r
255 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
\r
256 0 ,27 ,'!','@','#','$','%','^','&','*','(',')','_','+',8 ,9 , // 0
\r
257 'Q','W','E','R','T','Y','U','I','O','P','{','}',13 ,0 ,'A','S', // 1
\r
258 'D','F','G','H','J','K','L',':',34 ,'~',0 ,'|','Z','X','C','V', // 2
\r
259 'B','N','M','<','>','?',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3
\r
260 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4
\r
261 '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
\r
262 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
\r
263 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
\r
265 far SpecialNames[] = // ASCII for 0xe0 prefixed codes
\r
267 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
\r
268 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 0
\r
269 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,13 ,0 ,0 ,0 , // 1
\r
270 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 2
\r
271 0 ,0 ,0 ,0 ,0 ,'/',0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 3
\r
272 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 4
\r
273 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
\r
274 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
\r
275 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
\r
279 static boolean IN_Started;
\r
280 static boolean CapsLock;
\r
281 static ScanCode CurCode,LastCode;
\r
283 static Direction DirTable[] = // Quick lookup for total direction
\r
288 dir_West, dir_None, dir_East,
\r
290 dir_South//,dir_SouthEast
\r
293 static void (*INL_KeyHook)(void);
\r
294 static void interrupt (*OldKeyVect)(void);
\r
296 static char *ParmStringsIN[] = {"nojoys","nomouse",nil};
\r
298 // Function prototypes
\r
299 #define IN_KeyDown(code) (Keyboard[(code)])
\r
300 #define IN_ClearKey(code) {Keyboard[code] = false;\
\r
301 if (code == LastScan) LastScan = sc_None;}
\r
303 // DEBUG - put names in prototypes
\r
304 extern void IN_Startup(void),IN_Shutdown(void),
\r
305 IN_Default(boolean gotit,ControlType in),
\r
306 IN_SetKeyHook(void (*)()),
\r
307 IN_ClearKeysDown(void),
\r
308 IN_ReadCursor(CursorInfo *),
\r
309 IN_ReadControl(int,ControlInfo *),
\r
310 IN_SetControlType(int,ControlType),
\r
311 IN_GetJoyAbs(word joy,word *xp,word *yp),
\r
312 IN_SetupJoy(word joy,word minx,word maxx,
\r
313 word miny,word maxy),
\r
316 IN_StartDemoPlayback(byte __segment *buffer,word bufsize),
\r
317 IN_StopDemo(void),IN_FreeDemoBuffer(void),
\r
319 IN_Ack(void),IN_AckBack(void);
\r
320 extern boolean IN_UserInput(dword delay,boolean clear),
\r
321 IN_IsUserInput(void)
\r
323 , IN_StartDemoRecord(word bufsize)
\r
326 extern byte *IN_GetScanName(ScanCode);
\r
327 extern char IN_WaitForASCII(void);
\r
328 extern ScanCode IN_WaitForKey(void);
\r
329 extern word IN_GetJoyButtonsDB(word joy);
\r
332 void interrupt INL_KeyService(void);
\r
333 boolean IN_qb(byte kee);
\r