]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_in.h
update doslib
[16.git] / src / lib / 16_in.h
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 //\r
23 //      ID Engine\r
24 //      ID_IN.h - Header file for Input Manager\r
25 //      v1.0d1w\r
26 //      By Jason Blochowiak\r
27 //      Open Watcom port by sparky4\r
28 //\r
29 \r
30 #ifndef __16_IN__\r
31 #define __16_IN__\r
32 \r
33 #include <string.h>\r
34 #include "src/lib/16_head.h"\r
35 #include "src/lib/16_timer.h"\r
36 #include "src/lib/16_dbg.h"\r
37 #ifdef __WATCOMC__      //borland C BCEXMM.EXE\r
38 #include "src/lib/16_spri.h"\r
39 #include "src/lib/16_enti.h"\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              2//future plans for multiple playable charaters and being able to alternate\r
50 #define MaxKbds         2\r
51 #define MaxJoys         2\r
52 #define NumCodes        128\r
53 \r
54 //typedef       byte            ScanCode;\r
55 #define sc_None                 0\r
56 #define sc_Bad                  0xff\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
62 #define sc_Tab                  0x0f\r
63 #define sc_Alt                  0x38\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
75 #define sc_End                  0x4f\r
76 #define sc_PgUp                 0x49\r
77 #define sc_PgDn                 0x51\r
78 #define sc_F1                   0x3b\r
79 #define sc_F2                   0x3c\r
80 #define sc_F3                   0x3d\r
81 #define sc_F4                   0x3e\r
82 #define sc_F5                   0x3f\r
83 #define sc_F6                   0x40\r
84 #define sc_F7                   0x41\r
85 #define sc_F8                   0x42\r
86 #define sc_F9                   0x43\r
87 #define sc_F10                  0x44\r
88 #define sc_F11                  0x57\r
89 #define sc_F12                  0x59\r
90 \r
91 #define sc_1                    0x02\r
92 #define sc_2                    0x03\r
93 #define sc_3                    0x04\r
94 #define sc_4                    0x05\r
95 #define sc_5                    0x06\r
96 #define sc_6                    0x07\r
97 #define sc_7                    0x08\r
98 #define sc_8                    0x09\r
99 #define sc_9                    0x0a\r
100 #define sc_0                    0x0b\r
101 \r
102 #define sc_A                    0x1e\r
103 #define sc_B                    0x30\r
104 #define sc_C                    0x2e\r
105 #define sc_D                    0x20\r
106 #define sc_E                    0x12\r
107 #define sc_F                    0x21\r
108 #define sc_G                    0x22\r
109 #define sc_H                    0x23\r
110 #define sc_I                    0x17\r
111 #define sc_J                    0x24\r
112 #define sc_K                    0x25\r
113 #define sc_L                    0x26\r
114 #define sc_M                    0x32\r
115 #define sc_N                    0x31\r
116 #define sc_O                    0x18\r
117 #define sc_P                    0x19\r
118 #define sc_Q                    0x10\r
119 #define sc_R                    0x13\r
120 #define sc_S                    0x1f\r
121 #define sc_T                    0x14\r
122 #define sc_U                    0x16\r
123 #define sc_V                    0x2f\r
124 #define sc_W                    0x11\r
125 #define sc_X                    0x2d\r
126 #define sc_Y                    0x15\r
127 #define sc_Z                    0x2c\r
128 \r
129 #define key_None                0\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
137 \r
138 #define key_LSuper                      0x5b\r
139 #define key_RSuper                      0x5c\r
140 #define key_Menu                        0x5d\r
141 #define sc_LBrkt                0x1a    //      [\r
142 #define sc_RBrkt                0x1b    //      ]\r
143 #define sc_BackSlash    0x2b    //      |\r
144 #define sc_ForeSlash    0x35    //      / ?\r
145 \r
146 //      Stuff for the mouse\r
147 #define MReset          0\r
148 #define MButtons        3\r
149 #define MDelta          11\r
150 \r
151 #define MouseInt        0x33\r
152 #ifdef DEMO0\r
153 typedef enum            {\r
154                                                 demo_Off,demo_Record,demo_Playback,demo_PlayDone\r
155                                         } Demo;\r
156 #endif\r
157 //moved to 16_tdef.h\r
158 /*typedef       enum            {\r
159                                                 //ctrl_None,                            // MDM (GAMERS EDGE) - added\r
160                                                 ctrl_Keyboard,\r
161                                                         ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,\r
162                                                 ctrl_Joystick,\r
163                                                         ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,\r
164                                                 ctrl_Mouse,\r
165                                         } ControlType;\r
166 typedef enum            {\r
167                                                 motion_Left = -1,motion_Up = -1,\r
168                                                 motion_None = 0,\r
169                                                 motion_Right = 1,motion_Down = 1\r
170                                         } Motion;\r
171 typedef enum            {\r
172                                                 dir_North,//dir_NorthEast,\r
173                                                 dir_West,//dir_Nortinest,\r
174                                                 dir_None,\r
175                                                 dir_East,//,dir_SouthEast,\r
176                                                 dir_South,//dir_Soutinest,\r
177                                         } Direction;\r
178 typedef struct          {\r
179                                                 boolean near    button0,button1,button2,button3;\r
180                                                 int     near            x,y;\r
181                                                 Motion  near    xaxis,yaxis;\r
182                                                 Direction near  dir;\r
183                                         } CursorInfo;\r
184 \r
185 typedef struct          {\r
186                                                 ScanCode near   button0,button1,\r
187                                                                         //upleft,\r
188                                                                         up,\r
189                                                                         down,\r
190                                                                         left,\r
191                                                                         right\r
192                                                                         //upright,\r
193                                                                         //downleft,\r
194                                                                         //,downright\r
195                                                                         ;\r
196                                         } KeyboardDef;\r
197 typedef struct          {\r
198                                                 word    near    joyMinX,joyMinY,\r
199                                                                         threshMinX,threshMinY,\r
200                                                                         threshMaxX,threshMaxY,\r
201                                                                         joyMaxX,joyMaxY,\r
202                                                                         joyMultXL,joyMultYL,\r
203                                                                         joyMultXH,joyMultYH;\r
204                                         } JoystickDef;*/\r
205 \r
206 /*\r
207 =============================================================================\r
208 \r
209                                         GLOBAL VARIABLES\r
210 \r
211 =============================================================================\r
212 */\r
213 #ifdef DEMO0\r
214                 static Demo             DemoMode = demo_Off;\r
215                 static byte /*_seg*/    *DemoBuffer;\r
216                 static word             DemoOffset,DemoSize;\r
217 #endif\r
218 \r
219 //      Internal routines\r
220 extern  void            IN_Startup(global_game_variables_t *gvar),IN_Shutdown(global_game_variables_t *gvar),\r
221                                         IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar),\r
222                                         IN_SetKeyHook(void (*)()),\r
223                                         IN_ClearKeysDown(void),\r
224                                         IN_ReadCursor(CursorInfo *, global_game_variables_t *gvar),\r
225                                         IN_ReadControl(player_t *player, global_game_variables_t *gvar),\r
226                                         IN_SetControlType(player_t *player,ControlType type),\r
227                                         IN_GetJoyAbs(word joy,word *xp,word *yp),\r
228                                         IN_SetupJoy(word joy,word minx,word maxx,\r
229                                                                 word miny,word maxy, global_game_variables_t *gvar),\r
230 #if DEMO0\r
231                                         IN_StopDemo(void),IN_FreeDemoBuffer(void),\r
232 #endif\r
233                                         IN_Ack(global_game_variables_t *gvar),IN_AckBack(void);\r
234 extern  boolean         IN_UserInput(word delay, global_game_variables_t *gvar);\r
235 extern  char            IN_WaitForASCII(void);\r
236 extern  ScanCode        IN_WaitForKey(void);\r
237 extern  word            IN_GetJoyButtonsDB(word joy);\r
238 extern  byte            *IN_GetScanName(ScanCode);\r
239 \r
240 \r
241 byte    IN_MouseButtons (global_game_variables_t *gvar);\r
242 byte    IN_JoyButtons (void);\r
243 \r
244 void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/, global_game_variables_t *gvar);\r
245 void IN_StartAck(global_game_variables_t *gvar);\r
246 boolean IN_CheckAck (global_game_variables_t *gvar);\r
247 boolean IN_IsUserInput(global_game_variables_t *gvar);\r
248 #define Mouse(x)         INL_Mouse(x)\r
249 //void IN_SetKeyHook(void (*hook)());\r
250 #if DEMO0\r
251 boolean IN_StartDemoRecord(word bufsize);\r
252 void IN_StartDemoPlayback(byte *buffer,word bufsize);\r
253 void IN_StopDemo(void);\r
254 void IN_FreeDemoBuffer(void);\r
255 #endif\r
256 \r
257 //boolean       IN_KeyDown(byte code),\r
258 //              IN_qb(byte kee);\r
259 void            IN_ClearKey(byte code),\r
260                 IN_KbdLED();\r
261 ScanCode        IN_GetLastScan(),\r
262                 IN_GetCurCode();\r
263 \r
264 #endif\r