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
33 //++++#ifdef __DEBUG__
\r
34 #define __DEBUG_InputMgr__
\r
38 #define TESTCONTROLNOISY
\r
40 #define KeyInt 9 // The keyboard ISR number
\r
42 // Stuff for the joystick
\r
43 #define JoyScaleMax 32768
\r
44 #define JoyScaleShift 8
\r
45 #define MaxJoyValue 5000
\r
47 #define MaxPlayers 4
\r
50 #define NumCodes 128
\r
52 typedef byte ScanCode;
\r
55 #define sc_Return 0x1c
\r
56 #define sc_Enter sc_Return
\r
57 #define sc_Escape 0x01
\r
58 #define sc_Space 0x39
\r
59 #define sc_BackSpace 0x0e
\r
62 #define sc_Control 0x1d
\r
63 #define sc_CapsLock 0x3a
\r
64 #define sc_LShift 0x2a
\r
65 #define sc_RShift 0x36
\r
66 #define sc_UpArrow 0x48
\r
67 #define sc_DownArrow 0x50
\r
68 #define sc_LeftArrow 0x4b
\r
69 #define sc_RightArrow 0x4d
\r
70 #define sc_Insert 0x52
\r
71 #define sc_Delete 0x53
\r
72 #define sc_Home 0x47
\r
74 #define sc_PgUp 0x49
\r
75 #define sc_PgDn 0x51
\r
128 #define key_Return 0x0d
\r
129 #define key_Enter key_Return
\r
130 #define key_Escape 0x1b
\r
131 #define key_Space 0x20
\r
132 #define key_BackSpace 0x08
\r
133 #define key_Tab 0x09
\r
134 #define key_Delete 0x7f
\r
136 #define key_LSuper 0x5b
137 #define key_RSuper 0x5c
138 #define key_Menu 0x5d
140 // Stuff for the mouse
\r
145 #define MouseInt 0x33
\r
148 demo_Off,demo_Record,demo_Playback,demo_PlayDone
\r
152 ctrl_None, // MDM (GAMERS EDGE) - added
\r
154 ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,
\r
156 ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,
\r
161 motion_Left = -1,motion_Up = -1,
\r
163 motion_Right = 1,motion_Down = 1
\r
166 dir_North,//dir_NorthEast,
\r
167 dir_East,//dir_SouthEast,
\r
168 dir_South,//dir_SouthWest,
\r
169 dir_West,//dir_NorthWest,
\r
173 boolean button0,button1,button2,button3;
\r
175 Motion xaxis,yaxis;
\r
178 typedef CursorInfo ControlInfo;
\r
181 ScanCode button0,button1,
\r
192 word joyMinX,joyMinY,
\r
193 threshMinX,threshMinY,
\r
194 threshMaxX,threshMaxY,
\r
196 joyMultXL,joyMultYL,
\r
197 joyMultXH,joyMultYH;
\r
200 =============================================================================
\r
204 =============================================================================
\r
208 // configuration variables
\r
210 static boolean MousePresent;
\r
211 static boolean JoysPresent[MaxJoys];
\r
212 static boolean JoyPadPresent;
\r
214 // Global variables
\r
215 // extern boolean JoystickCalibrated; // MDM (GAMERS EDGE) - added
\r
216 // extern ControlType ControlTypeUsed; // MDM (GAMERS EDGE) - added
\r
218 extern boolean Keyboard[NumCodes];
\r
219 extern boolean Paused;
\r
220 extern char LastASCII;
\r
221 extern ScanCode LastScan;
\r
223 //extern KeyboardDef KbdDefs[];
224 static KeyboardDef KbdDefs[] = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};
\r
225 extern JoystickDef JoyDefs[MaxJoys];
\r
226 extern ControlType Controls[MaxPlayers];
\r
228 extern dword MouseDownCount;
\r
231 static Demo DemoMode = demo_Off;
\r
232 static byte /*_seg*/ *DemoBuffer;
\r
233 static word DemoOffset,DemoSize;
\r
236 extern dword far* clockdw;
\r
239 =============================================================================
\r
243 =============================================================================
\r
245 static byte far ASCIINames[] = // Unshifted ASCII for scan codes
\r
247 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
\r
248 0 ,27 ,'1','2','3','4','5','6','7','8','9','0','-','=',8 ,9 , // 0
\r
249 'q','w','e','r','t','y','u','i','o','p','[',']',13 ,0 ,'a','s', // 1
\r
250 'd','f','g','h','j','k','l',';',39 ,'`',0 ,92 ,'z','x','c','v', // 2
\r
251 'b','n','m',',','.','/',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3
\r
252 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4
\r
253 '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
\r
254 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
\r
255 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
\r
257 far ShiftNames[] = // Shifted ASCII for scan codes
\r
259 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
\r
260 0 ,27 ,'!','@','#','$','%','^','&','*','(',')','_','+',8 ,9 , // 0
\r
261 'Q','W','E','R','T','Y','U','I','O','P','{','}',13 ,0 ,'A','S', // 1
\r
262 'D','F','G','H','J','K','L',':',34 ,'~',0 ,'|','Z','X','C','V', // 2
\r
263 'B','N','M','<','>','?',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3
\r
264 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4
\r
265 '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
\r
266 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
\r
267 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
\r
269 far SpecialNames[] = // ASCII for 0xe0 prefixed codes
\r
271 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
\r
272 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 0
\r
273 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,13 ,0 ,0 ,0 , // 1
\r
274 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 2
\r
275 0 ,0 ,0 ,0 ,0 ,'/',0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 3
\r
276 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 4
\r
277 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
\r
278 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
\r
279 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
\r
283 static boolean IN_Started;
\r
284 static boolean CapsLock;
\r
285 static ScanCode CurCode,LastCode;
\r
287 static Direction DirTable[] = // Quick lookup for total direction
\r
292 dir_West, dir_None, dir_East,
\r
294 dir_South//,dir_SouthEast
\r
297 static void (*INL_KeyHook)(void);
\r
298 static void interrupt (*OldKeyVect)(void);
\r
300 static char *ParmStringsIN[] = {"nojoys","nomouse",nil};
\r
302 // Function prototypes
\r
303 #define IN_KeyDown(code) (Keyboard[(code)])
\r
304 #define IN_ClearKey(code) {Keyboard[code] = false; if (code == LastScan) LastScan = sc_None;}
\r
306 // DEBUG - put names in prototypes
307 /* Catacomb Armageddon Source Code
308 * Copyright (C) 1993-2014 Flat Rock Software
310 * This program is free software; you can redistribute it and/or modify
311 * it under the terms of the GNU General Public License as published by
312 * the Free Software Foundation; either version 2 of the License, or
313 * (at your option) any later version.
315 * This program is distributed in the hope that it will be useful,
316 * but WITHOUT ANY WARRANTY; without even the implied warranty of
317 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
318 * GNU General Public License for more details.
320 * You should have received a copy of the GNU General Public License along
321 * with this program; if not, write to the Free Software Foundation, Inc.,
322 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
327 // ID_IN.c - Input Manager
329 // By Jason Blochowiak
330 // Open Watcom port by sparky4
334 // This module handles dealing with the various input devices
336 // Depends on: Memory Mgr (for demo recording), Sound Mgr (for timing stuff),
337 // User Mgr (for command line parms)
340 // LastScan - The keyboard scan code of the last key pressed
341 // LastASCII - The ASCII value of the last key pressed
342 // DEBUG - there are more globals
345 #include "src/lib/16_in.h"
348 =============================================================================
\r
352 =============================================================================
\r
355 boolean JoystickCalibrated=false; // MDM (GAMERS EDGE) - added
\r
356 ControlType ControlTypeUsed; // MDM (GAMERS EDGE) - added
\r
357 boolean Keyboard[NumCodes];
\r
362 //KeyboardDef KbdDefs = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};
\r
363 JoystickDef JoyDefs[MaxJoys];
\r
364 ControlType Controls[MaxPlayers];
\r
366 dword MouseDownCount;
369 void interrupt INL_KeyService(void);
371 //static void INL_GetMouseDelta(int *x,int *y);
372 //static word INL_GetMouseButtons(void);
373 void IN_GetJoyAbs(word joy,word *xp,word *yp);
374 //static void INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive);
375 //static word INL_GetJoyButtons(word joy);
376 word IN_GetJoyButtonsDB(word joy);
377 //static void INL_StartKbd(void);
378 //static void INL_ShutKbd(void);
379 //static boolean INL_StartMouse(void);
380 //static void INL_ShutMouse(void);
381 //static void INL_SetJoyScale(word joy);
382 void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy);
383 //static boolean INL_StartJoy(word joy);
384 //static void INL_ShutJoy(word joy);
385 void IN_Startup(void);
386 void IN_Default(boolean gotit,ControlType in);
387 void IN_Shutdown(void);
388 void IN_SetKeyHook(void (*hook)());
389 void IN_ClearKeysDown(void);
390 //static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy);
391 void IN_ReadCursor(CursorInfo *info);
392 void IN_ReadControl(int player,ControlInfo *info);
393 void IN_SetControlType(int player,ControlType type);
395 boolean IN_StartDemoRecord(word bufsize);
396 void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize);
397 void IN_StopDemo(void);
398 void IN_FreeDemoBuffer(void);
400 byte *IN_GetScanName(ScanCode scan);
401 ScanCode IN_WaitForKey(void);
402 char IN_WaitForASCII(void);
403 void IN_AckBack(void);
405 boolean IN_IsUserInput(void);
406 boolean IN_UserInput(dword delay,boolean clear);
409 /*extern void IN_Startup(void),IN_Shutdown(void),
\r
410 IN_Default(boolean gotit,ControlType in),
\r
411 IN_SetKeyHook(void (*)()),
\r
412 IN_ClearKeysDown(void),
\r
413 IN_ReadCursor(CursorInfo *),
\r
414 IN_ReadControl(int,ControlInfo *),
\r
415 IN_SetControlType(int,ControlType),
\r
416 IN_GetJoyAbs(word joy,word *xp,word *yp),
\r
417 IN_SetupJoy(word joy,word minx,word maxx,
\r
418 word miny,word maxy),
\r
421 IN_StartDemoPlayback(byte __segment *buffer,word bufsize),
\r
422 IN_StopDemo(void),IN_FreeDemoBuffer(void),
\r
424 IN_Ack(void),IN_AckBack(void);
\r
425 extern boolean IN_UserInput(dword delay,boolean clear),
\r
426 IN_IsUserInput(void)
\r
428 , IN_StartDemoRecord(word bufsize)
\r
431 extern byte *IN_GetScanName(ScanCode);
\r
432 extern char IN_WaitForASCII(void);
\r
433 extern ScanCode IN_WaitForKey(void);
\r
434 extern word IN_GetJoyButtonsDB(word joy);*/
\r
437 void interrupt INL_KeyService(void);
\r
438 boolean IN_qb(byte kee);
\r