OSDN Git Service

input ww
[proj16/16.git] / src / lib / 16_in.h
1 /* Catacomb Apocalypse Source Code\r
2  * Copyright (C) 1993-2014 Flat Rock Software\r
3  *\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
8  *\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
13  *\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
17  */\r
18 \r
19 //\r
20 //      ID Engine\r
21 //      ID_IN.h - Header file for Input Manager\r
22 //      v1.0d1w\r
23 //      By Jason Blochowiak\r
24 //      Open Watcom port by sparky4\r
25 //\r
26 \r
27 #ifndef __16_IN__\r
28 #define __16_IN__\r
29 \r
30 #include <string.h>\r
31 #include "src/lib/16_head.h"\r
32 \r
33 #ifdef  __DEBUG__\r
34 #define __DEBUG_InputMgr__\r
35 #endif\r
36 \r
37 #ifdef  __DEBUG_InputMgr__\r
38 //#define TESTKEYIN\r
39 #define TESTCONTROLNOISY\r
40 #endif\r
41 \r
42 #define KeyInt  9       // The keyboard ISR number\r
43 \r
44 // Stuff for the joystick\r
45 #define JoyScaleMax             32768\r
46 #define JoyScaleShift   8\r
47 #define MaxJoyValue             5000\r
48 \r
49 #define MaxPlayers      4\r
50 #define MaxKbds         2\r
51 #define MaxJoys         2\r
52 #define MaxPads         2\r
53 #define NumCodes        128\r
54 \r
55 typedef byte            ScanCode;\r
56 #define sc_None                 0\r
57 #define sc_Bad                  0xff\r
58 #define sc_Return               0x1c\r
59 #define sc_Enter                sc_Return\r
60 #define sc_Escape               0x01\r
61 #define sc_Space                0x39\r
62 #define sc_BackSpace    0x0e\r
63 #define sc_Tab                  0x0f\r
64 #define sc_Alt                  0x38\r
65 #define sc_Control              0x1d\r
66 #define sc_CapsLock             0x3a\r
67 #define sc_LShift               0x2a\r
68 #define sc_RShift               0x36\r
69 #define sc_UpArrow              0x48\r
70 #define sc_DownArrow    0x50\r
71 #define sc_LeftArrow    0x4b\r
72 #define sc_RightArrow   0x4d\r
73 #define sc_Insert               0x52\r
74 #define sc_Delete               0x53\r
75 #define sc_Home                 0x47\r
76 #define sc_End                  0x4f\r
77 #define sc_PgUp                 0x49\r
78 #define sc_PgDn                 0x51\r
79 #define sc_F1                   0x3b\r
80 #define sc_F2                   0x3c\r
81 #define sc_F3                   0x3d\r
82 #define sc_F4                   0x3e\r
83 #define sc_F5                   0x3f\r
84 #define sc_F6                   0x40\r
85 #define sc_F7                   0x41\r
86 #define sc_F8                   0x42\r
87 #define sc_F9                   0x43\r
88 #define sc_F10                  0x44\r
89 #define sc_F11                  0x57\r
90 #define sc_F12                  0x59\r
91 \r
92 #define sc_1                    0x02\r
93 #define sc_2                    0x03\r
94 #define sc_3                    0x04\r
95 #define sc_4                    0x05\r
96 #define sc_5                    0x06\r
97 #define sc_6                    0x07\r
98 #define sc_7                    0x08\r
99 #define sc_8                    0x09\r
100 #define sc_9                    0x0a\r
101 #define sc_0                    0x0b\r
102 \r
103 #define sc_A                    0x1e\r
104 #define sc_B                    0x30\r
105 #define sc_C                    0x2e\r
106 #define sc_D                    0x20\r
107 #define sc_E                    0x12\r
108 #define sc_F                    0x21\r
109 #define sc_G                    0x22\r
110 #define sc_H                    0x23\r
111 #define sc_I                    0x17\r
112 #define sc_J                    0x24\r
113 #define sc_K                    0x25\r
114 #define sc_L                    0x26\r
115 #define sc_M                    0x32\r
116 #define sc_N                    0x31\r
117 #define sc_O                    0x18\r
118 #define sc_P                    0x19\r
119 #define sc_Q                    0x10\r
120 #define sc_R                    0x13\r
121 #define sc_S                    0x1f\r
122 #define sc_T                    0x14\r
123 #define sc_U                    0x16\r
124 #define sc_V                    0x2f\r
125 #define sc_W                    0x11\r
126 #define sc_X                    0x2d\r
127 #define sc_Y                    0x15\r
128 #define sc_Z                    0x2c\r
129 \r
130 #define key_None                0\r
131 #define key_Return              0x0d\r
132 #define key_Enter               key_Return\r
133 #define key_Escape              0x1b\r
134 #define key_Space               0x20\r
135 #define key_BackSpace   0x08\r
136 #define key_Tab                 0x09\r
137 #define key_Delete              0x7f\r
138 \r
139 #define key_LSuper                      0x5b\r
140 #define key_RSuper                      0x5c\r
141 #define key_Menu                        0x5d\r
142 \r
143 //      Stuff for the mouse\r
144 #define MReset          0\r
145 #define MButtons        3\r
146 #define MDelta          11\r
147 \r
148 #define MouseInt        0x33\r
149 #ifdef DEMO0\r
150 typedef enum            {\r
151                                                 demo_Off,demo_Record,demo_Playback,demo_PlayDone\r
152                                         } Demo;\r
153 #endif\r
154 typedef enum            {\r
155                                                 //ctrl_None,                            // MDM (GAMERS EDGE) - added\r
156                                                 ctrl_Keyboard,\r
157                                                         ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,\r
158                                                 ctrl_Joystick,\r
159                                                         ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,\r
160                                                 ctrl_Mouse,\r
161                                                 ctrl_Joypad,\r
162                                                         ctrl_Joypad1 = ctrl_Joypad,ctrl_Joypad2\r
163                                         } ControlType;\r
164 typedef enum            {\r
165                                                 motion_Left = -1,motion_Up = -1,\r
166                                                 motion_None = 0,\r
167                                                 motion_Right = 1,motion_Down = 1\r
168                                         } Motion;\r
169 typedef enum            {\r
170                                                 dir_North,//dir_NorthEast,\r
171                                                 dir_West,//dir_Nortinest,\r
172                                                 dir_None,\r
173                                                 dir_East,//,dir_SouthEast,\r
174                                                 dir_South,//dir_Soutinest,\r
175                                         } Direction;\r
176 typedef struct          {\r
177                                                 boolean         button0,button1,button2,button3;\r
178                                                 int                     x,y;\r
179                                                 Motion          xaxis,yaxis;\r
180                                                 Direction       dir;\r
181                                         } CursorInfo;\r
182 \r
183 typedef struct          {\r
184                                                 ScanCode        button0,button1,\r
185                                                                         //upleft,\r
186                                                                         up,\r
187                                                                         down,\r
188                                                                         left,\r
189                                                                         right\r
190                                                                         //upright,\r
191                                                                         //downleft,\r
192                                                                         //,downright\r
193                                                                         ;\r
194                                         } KeyboardDef;\r
195 typedef struct          {\r
196                                                 word            joyMinX,joyMinY,\r
197                                                                         threshMinX,threshMinY,\r
198                                                                         threshMaxX,threshMaxY,\r
199                                                                         joyMaxX,joyMaxY,\r
200                                                                         joyMultXL,joyMultYL,\r
201                                                                         joyMultXH,joyMultYH;\r
202                                         } JoystickDef;\r
203 typedef struct\r
204 {\r
205         boolean w;\r
206 } JoypadDef;\r
207 \r
208 typedef struct\r
209 {\r
210         int x; //player exact position on the viewable map\r
211         int y; //player exact position on the viewable map\r
212         int tx; //player tile position on the viewable map\r
213         int ty; //player tile position on the viewable map\r
214         int triggerx; //player's trigger box tile position on the viewable map\r
215         int triggery; //player's trigger box tile position on the viewable map\r
216         int setx; //NOT USED YET! player sprite sheet set on the image x\r
217         int sety; //NOT USED YET! player sprite sheet set on the image y\r
218         word q; //loop variable\r
219 //      word d; //direction\r
220         //bitmap_t data; //supposively the sprite sheet data\r
221         int hp; //hitpoints of the player\r
222         CursorInfo      info;\r
223         ControlType     Controls;\r
224 } player_t;\r
225 \r
226 /*\r
227 =============================================================================\r
228 \r
229                                         GLOBAL VARIABLES\r
230 \r
231 =============================================================================\r
232 */\r
233 /*extern struct inconfig\r
234 {\r
235         boolean                 MousePresent;\r
236         boolean                 JoysPresent[MaxJoys];\r
237         boolean                 JoyPadPresent[MaxPads];\r
238         boolean         Keyboard[NumCodes];\r
239         boolean         Paused;\r
240         char            LastASCII;\r
241         ScanCode        LastScan;\r
242 \r
243         KeyboardDef     KbdDefs[MaxKbds];\r
244         JoystickDef     JoyDefs[MaxJoys];\r
245         JoypadDef       JoypadDefs[MaxPads];\r
246 } inpu;*/\r
247 \r
248 #ifdef DEMO0\r
249                 static Demo             DemoMode = demo_Off;\r
250                 static byte /*_seg*/    *DemoBuffer;\r
251                 static word             DemoOffset,DemoSize;\r
252 #endif\r
253 \r
254 extern dword far* clockdw;\r
255 \r
256 //      Internal routines\r
257 extern void interrupt INL_KeyService();\r
258 extern void Mouse(int x);\r
259 //static void INL_GetMouseDelta(int *x,int *y);\r
260 //static word INL_GetMouseButtons(void);\r
261 extern void IN_GetJoyAbs(word joy,word *xp,word *yp);\r
262 //static void INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive);\r
263 //static word INL_GetJoyButtons(word joy);\r
264 extern word IN_GetJoyButtonsDB(word joy);\r
265 //static void INL_StartKbd(void);\r
266 //static void INL_ShutKbd(void);\r
267 //static boolean INL_StartMouse(void);\r
268 //static void INL_ShutMouse(void);\r
269 //static void INL_SetJoyScale(word joy);\r
270 extern void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy);\r
271 //static boolean INL_StartJoy(word joy);\r
272 //static void INL_ShutJoy(word joy);\r
273 extern void IN_Startup();\r
274 extern void IN_Default(boolean gotit,player_t *player,ControlType nt);\r
275 extern void IN_Shutdown();\r
276 extern void IN_SetKeyHook(void (*hook)());\r
277 extern void IN_ClearKeysDown();\r
278 //static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy);\r
279 extern void IN_ReadCursor(CursorInfo *info);\r
280 extern void IN_ReadControl(int playnum,player_t *player);\r
281 extern void IN_SetControlType(word playnum,player_t *player,ControlType type);\r
282 #if DEMO0\r
283 extern boolean IN_StartDemoRecord(word bufsize);\r
284 extern void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize);\r
285 extern void IN_StopDemo(void);\r
286 extern void IN_FreeDemoBuffer(void);\r
287 #endif\r
288 extern byte *IN_GetScanName(ScanCode scan);\r
289 extern ScanCode IN_WaitForKey();\r
290 extern char IN_WaitForASCII();\r
291 extern void IN_AckBack();\r
292 extern void IN_Ack();\r
293 extern boolean IN_IsUserInput();\r
294 extern boolean IN_UserInput(dword delay,boolean clear);\r
295 extern boolean IN_KeyDown(byte code);\r
296 extern void IN_ClearKey(byte code);\r
297 extern boolean IN_qb(byte kee);\r
298 \r
299 #endif\r