OSDN Git Service

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