Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8557 | maxcodehac | 1 | // |
2 | // ID Engine |
||
3 | // ID_IN.h - Header file for Input Manager |
||
4 | // v1.0d1 |
||
5 | // By Jason Blochowiak |
||
6 | // |
||
7 | |||
8 | #ifndef __ID_IN__ |
||
9 | #define __ID_IN__ |
||
10 | |||
11 | #ifdef __DEBUG__ |
||
12 | #define __DEBUG_InputMgr__ |
||
13 | #endif |
||
14 | |||
15 | typedef int ScanCode; |
||
16 | #define sc_None 0 |
||
17 | #define sc_Bad 0xff |
||
18 | #define sc_Return SDLK_RETURN |
||
19 | #define sc_Enter sc_Return |
||
20 | #define sc_Escape SDLK_ESCAPE |
||
21 | #define sc_Space SDLK_SPACE |
||
22 | #define sc_BackSpace SDLK_BACKSPACE |
||
23 | #define sc_Tab SDLK_TAB |
||
24 | #define sc_Alt SDLK_LALT |
||
25 | #define sc_Control SDLK_LCTRL |
||
26 | #define sc_CapsLock SDLK_CAPSLOCK |
||
27 | #define sc_LShift SDLK_LSHIFT |
||
28 | #define sc_RShift SDLK_RSHIFT |
||
29 | #define sc_UpArrow SDLK_UP |
||
30 | #define sc_DownArrow SDLK_DOWN |
||
31 | #define sc_LeftArrow SDLK_LEFT |
||
32 | #define sc_RightArrow SDLK_RIGHT |
||
33 | #define sc_Insert SDLK_INSERT |
||
34 | #define sc_Delete SDLK_DELETE |
||
35 | #define sc_Home SDLK_HOME |
||
36 | #define sc_End SDLK_END |
||
37 | #define sc_PgUp SDLK_PAGEUP |
||
38 | #define sc_PgDn SDLK_PAGEDOWN |
||
39 | #define sc_F1 SDLK_F1 |
||
40 | #define sc_F2 SDLK_F2 |
||
41 | #define sc_F3 SDLK_F3 |
||
42 | #define sc_F4 SDLK_F4 |
||
43 | #define sc_F5 SDLK_F5 |
||
44 | #define sc_F6 SDLK_F6 |
||
45 | #define sc_F7 SDLK_F7 |
||
46 | #define sc_F8 SDLK_F8 |
||
47 | #define sc_F9 SDLK_F9 |
||
48 | #define sc_F10 SDLK_F10 |
||
49 | #define sc_F11 SDLK_F11 |
||
50 | #define sc_F12 SDLK_F12 |
||
51 | |||
52 | #define sc_ScrollLock SDLK_SCROLLOCK |
||
53 | #define sc_PrintScreen SDLK_PRINT |
||
54 | |||
55 | #define sc_1 SDLK_1 |
||
56 | #define sc_2 SDLK_2 |
||
57 | #define sc_3 SDLK_3 |
||
58 | #define sc_4 SDLK_4 |
||
59 | #define sc_5 SDLK_5 |
||
60 | #define sc_6 SDLK_6 |
||
61 | #define sc_7 SDLK_7 |
||
62 | #define sc_8 SDLK_8 |
||
63 | #define sc_9 SDLK_9 |
||
64 | #define sc_0 SDLK_0 |
||
65 | |||
66 | #define sc_A SDLK_a |
||
67 | #define sc_B SDLK_b |
||
68 | #define sc_C SDLK_c |
||
69 | #define sc_D SDLK_d |
||
70 | #define sc_E SDLK_e |
||
71 | #define sc_F SDLK_f |
||
72 | #define sc_G SDLK_g |
||
73 | #define sc_H SDLK_h |
||
74 | #define sc_I SDLK_i |
||
75 | #define sc_J SDLK_j |
||
76 | #define sc_K SDLK_k |
||
77 | #define sc_L SDLK_l |
||
78 | #define sc_M SDLK_m |
||
79 | #define sc_N SDLK_n |
||
80 | #define sc_O SDLK_o |
||
81 | #define sc_P SDLK_p |
||
82 | #define sc_Q SDLK_q |
||
83 | #define sc_R SDLK_r |
||
84 | #define sc_S SDLK_s |
||
85 | #define sc_T SDLK_t |
||
86 | #define sc_U SDLK_u |
||
87 | #define sc_V SDLK_v |
||
88 | #define sc_W SDLK_w |
||
89 | #define sc_X SDLK_x |
||
90 | #define sc_Y SDLK_y |
||
91 | #define sc_Z SDLK_z |
||
92 | |||
93 | #define key_None 0 |
||
94 | |||
95 | typedef enum { |
||
96 | demo_Off,demo_Record,demo_Playback,demo_PlayDone |
||
97 | } Demo; |
||
98 | typedef enum { |
||
99 | ctrl_Keyboard, |
||
100 | ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2, |
||
101 | ctrl_Joystick, |
||
102 | ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2, |
||
103 | ctrl_Mouse |
||
104 | } ControlType; |
||
105 | typedef enum { |
||
106 | motion_Left = -1,motion_Up = -1, |
||
107 | motion_None = 0, |
||
108 | motion_Right = 1,motion_Down = 1 |
||
109 | } Motion; |
||
110 | typedef enum { |
||
111 | dir_North,dir_NorthEast, |
||
112 | dir_East,dir_SouthEast, |
||
113 | dir_South,dir_SouthWest, |
||
114 | dir_West,dir_NorthWest, |
||
115 | dir_None |
||
116 | } Direction; |
||
117 | typedef struct { |
||
118 | boolean button0,button1,button2,button3; |
||
119 | short x,y; |
||
120 | Motion xaxis,yaxis; |
||
121 | Direction dir; |
||
122 | } CursorInfo; |
||
123 | typedef CursorInfo ControlInfo; |
||
124 | typedef struct { |
||
125 | ScanCode button0,button1, |
||
126 | upleft, up, upright, |
||
127 | left, right, |
||
128 | downleft, down, downright; |
||
129 | } KeyboardDef; |
||
130 | typedef struct { |
||
131 | word joyMinX,joyMinY, |
||
132 | threshMinX,threshMinY, |
||
133 | threshMaxX,threshMaxY, |
||
134 | joyMaxX,joyMaxY, |
||
135 | joyMultXL,joyMultYL, |
||
136 | joyMultXH,joyMultYH; |
||
137 | } JoystickDef; |
||
138 | // Global variables |
||
139 | extern volatile boolean Keyboard[]; |
||
140 | extern boolean MousePresent; |
||
141 | extern volatile boolean Paused; |
||
142 | extern volatile char LastASCII; |
||
143 | extern volatile ScanCode LastScan; |
||
144 | extern int JoyNumButtons; |
||
145 | extern boolean forcegrabmouse; |
||
146 | |||
147 | |||
148 | // Function prototypes |
||
149 | #define IN_KeyDown(code) (Keyboard[(code)]) |
||
150 | #define IN_ClearKey(code) {Keyboard[code] = false;\ |
||
151 | if (code == LastScan) LastScan = sc_None;} |
||
152 | |||
153 | // DEBUG - put names in prototypes |
||
154 | extern void IN_Startup(void),IN_Shutdown(void); |
||
155 | extern void IN_ClearKeysDown(void); |
||
156 | extern void IN_ReadControl(int,ControlInfo *); |
||
157 | extern void IN_GetJoyAbs(word joy,word *xp,word *yp); |
||
158 | extern void IN_SetupJoy(word joy,word minx,word maxx, |
||
159 | word miny,word maxy); |
||
160 | extern void IN_StopDemo(void),IN_FreeDemoBuffer(void), |
||
161 | IN_Ack(void); |
||
162 | extern boolean IN_UserInput(longword delay); |
||
163 | extern char IN_WaitForASCII(void); |
||
164 | extern ScanCode IN_WaitForKey(void); |
||
165 | extern word IN_GetJoyButtonsDB(word joy); |
||
166 | extern const char *IN_GetScanName(ScanCode); |
||
167 | |||
168 | void IN_WaitAndProcessEvents(); |
||
169 | void IN_ProcessEvents(); |
||
170 | |||
171 | int IN_MouseButtons (void); |
||
172 | |||
173 | boolean IN_JoyPresent(); |
||
174 | void IN_SetJoyCurrent(int joyIndex); |
||
175 | int IN_JoyButtons (void); |
||
176 | void IN_GetJoyDelta(int *dx,int *dy); |
||
177 | void IN_GetJoyFineDelta(int *dx, int *dy); |
||
178 | |||
179 | void IN_StartAck(void); |
||
180 | boolean IN_CheckAck (void); |
||
181 | bool IN_IsInputGrabbed(); |
||
182 | void IN_CenterMouse(); |
||
183 | |||
184 | #endif |