Debian Codegraph @

linux/lnxcontroller.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/lnxcontroller/lnxcontroller.cpp $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003/08/26 03:58:14 $
23 * $Author: kevinb $
24 *
25 * Linux controller routines
26 *
27 * $Log: lnxcontroller.cpp,v $
28 * Revision 1.1.1.1 2003/08/26 03:58:14 kevinb
29 * initial 1.5 import
30 *
31 *
32 * 7 9/23/99 12:10p Jeff
33 * changes to reflect new wincontroller
34 *
35 * 6 8/18/99 8:52p Jeff
36 * make up to date with windows
37 *
38 * 5 7/14/99 9:10p Jeff
39 * added comment header
40 *
41 * $NoKeywords: $
42 */
43
44 #include <cstring>
45 #include "Controller.h"cxx . . $ `<file>/lib/Controller.h`/
46 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
47 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
48 #include "joystick.h"cxx . . $ `<file>/lib/joystick.h`/
49 #include "inffile.h"cxx . . $ `<file>/cfile/inffile.h`/
50 #include "lnxcontroller.h"cxx . . $ `<file>/linux/lnxcontroller.h`/
51
52 // Sorry! This is needed for the semi-hacky mouselook support
53 #include "descent.h"cxx . . $ `<file>/Descent3/descent.h`/
54 #include "player.h"cxx . . $ `<file>/Descent3/player.h`/
55 #include "object.h"cxx . . $ `<file>/Descent3/object.h`/
56 #include "pilot.h"cxx . . $ `<file>/Descent3/pilot.h`/
57 #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/
58 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
59 // End of hacky includes
60
61 #define JOY_DEADZONEcxx . . $ `linux/lnxcontroller.cpp:61:9`! 0.20f
62 #define MOUSE_DEADZONEcxx . . $ `linux/lnxcontroller.cpp:62:9`! 0.00f
63
64 static float WinControllerTimercxx . . $ WinControllerTimer. = 0.0f;
65 static int64_tcxx . . $ int64_t# g_last_frame_timer_mscxx . . $ g_last_frame_timer_ms. = -1;
66 static float g_accum_frame_timecxx . . $ g_accum_frame_time. = 0.0f;
67
68 lnxgameControllercxx . . $ lnxgameController#::lnxgameControllercxx . . $ lnxgameController#lnxgameController(a236fb5fab16b1bf).(int num_funcs, ct_functioncxx . . $ ct_function# *funcs) : gameControllercxx . . $ gameController#(num_funcs, funcs) {
69 enum_controllerscxx . . $ lnxgameController#enum_controllers(c9857a73d68e59ba).();
70
71 for (int i = 0; i < num_funcs; i++)
72 assign_functioncxx . . $ lnxgameController#assign_function(2608e8495e192ac3).(&funcs[i]);
73
74 m_Suspendedcxx . . $ lnxgameController#m_Suspended. = 0;
75 m_frame_timer_mscxx . . $ lnxgameController#m_frame_timer_ms. = -1;
76 m_frame_timecxx . . $ lnxgameController#m_frame_time. = 1.0f;
77 g_last_frame_timer_mscxx . . $ g_last_frame_timer_ms. = -1;
78 g_accum_frame_timecxx . . $ g_accum_frame_time. = 0.0f;
79
80 lnxgameControllercxx . . $ lnxgameController#::flushcxx . . $ lnxgameController#flush(49f6e7a06ebc5aa8).();
81 }
82
83 lnxgameControllercxx . . $ lnxgameController#::~cxx . . $ lnxgameController#`~lnxgameController`(ced63f7c635d850d).lnxgameControllercxx . . $ lnxgameController#() {}
84
85 // these functions suspend or resume any controller reading. this is really only useful for
86 // preemptive controller polling, but they should be used to activate and deactivate controller
87 // reading.
88 void lnxgameControllercxx . . $ lnxgameController#::suspendcxx . . $ lnxgameController#suspend(49f6e7a06ebc5aa8).() { m_Suspendedcxx . . $ lnxgameController#m_Suspended. = 1; }
89 void lnxgameControllercxx . . $ lnxgameController#::resumecxx . . $ lnxgameController#resume(49f6e7a06ebc5aa8).() {
90 m_Suspendedcxx . . $ lnxgameController#m_Suspended. = 0;
91 m_frame_timer_mscxx . . $ lnxgameController#m_frame_timer_ms. = -1;
92 m_frame_timecxx . . $ lnxgameController#m_frame_time. = 1.0f;
93 }
94
95 #define CONTROLLER_POLLING_TIMEcxx . . $ `linux/lnxcontroller.cpp:95:9`! 50
96 #define MOUSE_POLLING_TIMEcxx . . $ `linux/lnxcontroller.cpp:96:9`! (1.0f / 20.0f)
97
98 // this functions polls the controllers if needed. some systems may not need to implement
99 // this function.
100 void lnxgameControllercxx . . $ lnxgameController#::pollcxx . . $ lnxgameController#poll(49f6e7a06ebc5aa8).() {
101 int64_tcxx . . $ int64_t# cur_frame_timer_ms;
102
103 if (m_Suspendedcxx . . $ lnxgameController#m_Suspended.)
104 return;
105
106 cur_frame_timer_ms = timer_GetMSTimecxx . . $ `ddio/ddio.h:237:9`!();
107 if (m_frame_timer_mscxx . . $ lnxgameController#m_frame_timer_ms. == -1) {
108 // don't poll this frame.
109 m_frame_timer_mscxx . . $ lnxgameController#m_frame_timer_ms. = cur_frame_timer_ms;
110 g_last_frame_timer_mscxx . . $ g_last_frame_timer_ms. = cur_frame_timer_ms;
111 g_accum_frame_timecxx . . $ g_accum_frame_time. = 0.0f;
112 return;
113 }
114
115 m_frame_timecxx . . $ lnxgameController#m_frame_time. = (float)((cur_frame_timer_ms - m_frame_timer_mscxx . . $ lnxgameController#m_frame_timer_ms.) / 1000.0);
116 m_frame_timer_mscxx . . $ lnxgameController#m_frame_timer_ms. = cur_frame_timer_ms;
117 g_accum_frame_timecxx . . $ g_accum_frame_time. += m_frame_timecxx . . $ lnxgameController#m_frame_time.;
118
119 if (g_accum_frame_timecxx . . $ g_accum_frame_time. >= MOUSE_POLLING_TIMEcxx . . $ `linux/lnxcontroller.cpp:96:9`!) {
120 g_accum_frame_timecxx . . $ g_accum_frame_time. = 0.0f;
121 }
122
123 for (int ctl = 0; ctl < m_NumControlscxx . . $ lnxgameController#m_NumControls.; ctl++) {
124 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].idcxx . . $ lnxgameController#t_controller#id. >= CTID_EXTCONTROL0cxx . . $ CTID_EXTCONTROL0.) {
125 extctl_getposcxx . . $ lnxgameController#extctl_getpos(d4f767463ce0a6b3).(m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].idcxx . . $ lnxgameController#t_controller#id.);
126 } else if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].idcxx . . $ lnxgameController#t_controller#id. == CTID_MOUSEcxx . . $ CTID_MOUSE.) {
127 // if ((cur_frame_timer_ms - g_last_frame_timer_ms) > CONTROLLER_POLLING_TIME) {
128 mouse_getevalcxx . . $ lnxgameController#mouse_geteval(49f6e7a06ebc5aa8).();
129 // g_last_frame_timer_ms = cur_frame_timer_ms;
130 // }
131 }
132 }
133 }
134
135 // toggles use of deadzone for controllers. ctl can be 0 to ???
136 // dead zone is from 0.0 to 0.5
137 void lnxgameControllercxx . . $ lnxgameController#::set_controller_deadzonecxx . . $ lnxgameController#set_controller_deadzone(43c79ee2f1b9aefe).(int ctl, float deadzone) {
138 if (ctl < 0 || ctl >= (m_NumControlscxx . . $ lnxgameController#m_NumControls. - 2)) {
139 return;
140 }
141
142 if (deadzone < 0.0f)
143 deadzone = 0.0f;
144 if (deadzone > 0.9f)
145 deadzone = 0.9f;
146
147 m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl + 2].deadzonecxx . . $ lnxgameController#t_controller#deadzone. = deadzone;
148 }
149
150 char Ctltext_AxisBindingscxx . . $ Ctltext_AxisBindings.[][16] = {"", "X-axis", "Y-axis", "Z-axis", "R-axis", "U-axis", "V-axis"};
151
152 static char Ctltext_BtnBindingscxx . . $ Ctltext_BtnBindings.[][16] = {
153 "", "btn1", "btn2", "btn3", "btn4", "btn5", "btn6", "btn7", "btn8", "btn9", "btn10",
154 "btn11", "btn12", "btn13", "btn14", "btn15", "btn16", "btn17", "btn18", "btn19", "btn20", "btn21",
155 "btn22", "btn23", "btn24", "btn25", "btn26", "btn27", "btn28", "btn29", "btn30", "btn31", "btn32"};
156
157 char Ctltext_PovBindingscxx . . $ Ctltext_PovBindings.[][16] = {"", "pov-U", "pov-R", "pov-D", "pov-L"};
158
159 #define NUM_AXISBINDSTRINGScxx . . $ `linux/lnxcontroller.cpp:159:9`! (sizeof(Ctltext_AxisBindings) / sizeof(Ctltext_AxisBindings[0]))
160 #define NUM_BTNBINDSTRINGScxx . . $ `linux/lnxcontroller.cpp:160:9`! (sizeof(Ctltext_BtnBindings) / sizeof(Ctltext_AxisBindings[0]))
161
162 // retrieves binding text for desired function, binding, etc.
163 const char *lnxgameControllercxx . . $ lnxgameController#::get_binding_textcxx . . $ lnxgameController#get_binding_text(c156078267dcf458).(ct_typecxx . . $ ct_type# type, uint8_tcxx . . $ uint8_t# ctrl, uint8_tcxx . . $ uint8_t# bind) {
164 static char binding_text[32];
165 const char *str;
166
167 if (ctrl == NULL_CONTROLLERcxx . . $ `lib/Controller.h:181:9`!) {
168 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
169 }
170
171 switch (type) {
172 int pov_n;
173 case ctAxiscxx . . $ ctAxis.: {
174 ASSERTcxx . . $ `misc/pserror.h:246:9`!(bind < NUM_AXISBINDSTRINGScxx . . $ `linux/lnxcontroller.cpp:159:9`!);
175 str = Ctltext_AxisBindingscxx . . $ Ctltext_AxisBindings.[bind];
176 if ((ctrl - 2) > 0) {
177 snprintf(binding_text, sizeof(binding_text), "J%d:%s", (ctrl - 2) + 1, str);
178 } else {
179 return str;
180 }
181 break;
182 }
183
184 case ctMouseAxiscxx . . $ ctMouseAxis.: {
185 str = ddio_MouseGetAxisTextcxx . . $ ddio_MouseGetAxisText(f7ae7e56280f18ae).(((int8_tcxx . . $ int8_t#)bind) - 1);
186 return str;
187 }
188
189 case ctButtoncxx . . $ ctButton.: {
190 ASSERTcxx . . $ `misc/pserror.h:246:9`!(bind < NUM_BTNBINDSTRINGScxx . . $ `linux/lnxcontroller.cpp:160:9`!);
191 str = Ctltext_BtnBindingscxx . . $ Ctltext_BtnBindings.[bind];
192 if ((ctrl - 2) > 0) {
193 snprintf(binding_text, sizeof(binding_text), "J%d:%s", (ctrl - 2) + 1, str);
194 } else {
195 return str;
196 }
197 break;
198 }
199
200 case ctMouseButtoncxx . . $ ctMouseButton.: {
201 str = ddio_MouseGetBtnTextcxx . . $ ddio_MouseGetBtnText(f7ae7e56280f18ae).(((int8_tcxx . . $ int8_t#)bind) - 1);
202 return str;
203 }
204
205 case ctPOVcxx . . $ ctPOV.:
206 case ctPOV2cxx . . $ ctPOV2.:
207 case ctPOV3cxx . . $ ctPOV3.:
208 case ctPOV4cxx . . $ ctPOV4.: {
209 uint16_tcxx . . $ uint16_t# povpos = bind;
210
211 if (type == ctPOVcxx . . $ ctPOV.)
212 pov_n = 0;
213 else
214 pov_n = (type - ctPOV2cxx . . $ ctPOV2.) + 1;
215
216 if (povpos == JOYPOV_UPcxx . . $ `lib/joystick.h:89:9`!)
217 str = Ctltext_PovBindingscxx . . $ Ctltext_PovBindings.[1];
218 else if (povpos == JOYPOV_DOWNcxx . . $ `lib/joystick.h:91:9`!)
219 str = Ctltext_PovBindingscxx . . $ Ctltext_PovBindings.[3];
220 else if (povpos == JOYPOV_LEFTcxx . . $ `lib/joystick.h:92:9`!)
221 str = Ctltext_PovBindingscxx . . $ Ctltext_PovBindings.[4];
222 else if (povpos == JOYPOV_RIGHTcxx . . $ `lib/joystick.h:90:9`!)
223 str = Ctltext_PovBindingscxx . . $ Ctltext_PovBindings.[2];
224 else
225 str = Ctltext_PovBindingscxx . . $ Ctltext_PovBindings.[0];
226 if ((ctrl - 2) > 0) {
227 if (pov_n) {
228 snprintf(binding_text, sizeof(binding_text), "J%d:%s%d", (ctrl - 2) + 1, str, pov_n);
229 } else {
230 snprintf(binding_text, sizeof(binding_text), "J%d:%s", (ctrl - 2) + 1, str);
231 }
232 } else {
233 if (pov_n) {
234 snprintf(binding_text, sizeof(binding_text), "%s%d", str, pov_n);
235 } else {
236 return str;
237 }
238 }
239 break;
240 }
241
242 case ctKeycxx . . $ ctKey.:
243 break;
244
245 default:
246 if (type == ctNonecxx . . $ ctNone.) {
247 Int3cxx . . $ `misc/pserror.h:247:9`!();
248 }
249 binding_text[0] = 0;
250 }
251
252 return binding_text;
253 }
254
255 // flushes all controller information
256 void lnxgameControllercxx . . $ lnxgameController#::flushcxx . . $ lnxgameController#flush(49f6e7a06ebc5aa8).() {
257 bool old_mse = m_MouseActivecxx . . $ lnxgameController#m_MouseActive., old_joy = m_JoyActivecxx . . $ lnxgameController#m_JoyActive.;
258
259 ddio_KeyFlushcxx . . $ ddio_KeyFlush(49f6e7a06ebc5aa8).();
260 ddio_MouseQueueFlushcxx . . $ ddio_MouseQueueFlush(49f6e7a06ebc5aa8).();
261
262 // does real flush
263 mask_controllerscxx . . $ lnxgameController#mask_controllers(b0b38cda41d4ede4).(false, false);
264 mask_controllerscxx . . $ lnxgameController#mask_controllers(b0b38cda41d4ede4).(old_joy, old_mse);
265 }
266
267 // returns the value of a requested controller type. make sure you flush the controller before polling.
268 ct_config_datacxx . . $ ct_config_data# lnxgameControllercxx . . $ lnxgameController#::get_controller_valuecxx . . $ lnxgameController#get_controller_value(1248184eb8b5e5af).(ct_typecxx . . $ ct_type# type_req) {
269 // will return the current value of a requested control type.
270 ct_config_datacxx . . $ ct_config_data# val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(INVALID_CONTROLLER_INFOcxx . . $ `lib/Controller.h:182:9`!, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!);
271 int i, j;
272
273 switch (type_req) {
274 int pov_n;
275
276 case ctNonecxx . . $ ctNone.:
277 break;
278 case ctKeycxx . . $ ctKey.:
279 val = makewordcxx . . $ `lib/Controller.h:170:9`!(0, ddio_KeyInKey());
280 break;
281
282 case ctButtoncxx . . $ ctButton.:
283 for (i = 2; i < m_NumControlscxx . . $ lnxgameController#m_NumControls.; i++) {
284 for (j = 0; j < m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].buttonscxx . . $ lnxgameController#t_controller#buttons.; j++) {
285 if (m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].idcxx . . $ lnxgameController#t_controller#id.].btnpressescxx . . $ lnxgameController#t_extctlstate#btnpresses.[j] &&
286 !(m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].idcxx . . $ lnxgameController#t_controller#id.].buttonscxx . . $ lnxgameController#t_extctlstate#buttons. & (1 << j))) {
287 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(CONTROLLER_CTL_INFOcxx . . $ `lib/Controller.h:194:9`!(i, NULL_CONTROLLERcxx . . $ `lib/Controller.h:181:9`!), CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(j + 1, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
288 return val;
289 }
290 }
291 }
292 break;
293
294 case ctMouseButtoncxx . . $ ctMouseButton.:
295 for (j = 0; j < CT_MAX_BUTTONScxx . . $ CT_MAX_BUTTONS.; j++) {
296 if (ddio_MouseBtnUpCountcxx . . $ ddio_MouseBtnUpCount(7864480464b09eea).(j)) {
297 // mprintf(0, "MseBtn %d down\n", j);
298 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(CONTROLLER_CTL_INFOcxx . . $ `lib/Controller.h:194:9`!(1, NULL_CONTROLLERcxx . . $ `lib/Controller.h:181:9`!), CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(j + 1, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
299 return val;
300 }
301 }
302 break;
303
304 case ctAxiscxx . . $ ctAxis.:
305 for (i = 2; i < m_NumControlscxx . . $ lnxgameController#m_NumControls.; i++) {
306 float pos;
307 float limit;
308 unsigned ctl = CONTROLLER_CTL_INFOcxx . . $ `lib/Controller.h:194:9`!(i, NULL_CONTROLLERcxx . . $ `lib/Controller.h:181:9`!);
309
310 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_V_AXIScxx . . $ CTF_V_AXIS.) {
311 limit = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_V_AXIScxx . . $ CT_V_AXIS. - 1] > 1.5f) ? 0.95f
312 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_V_AXIScxx . . $ CT_V_AXIS. - 1] > 1.0f) ? 0.80f
313 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_V_AXIScxx . . $ CT_V_AXIS. - 1] / 2);
314 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_V_AXIScxx . . $ CT_V_AXIS., ctAnalogcxx . . $ ctAnalog.);
315 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) > limit)
316 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_V_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
317 }
318 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_U_AXIScxx . . $ CTF_U_AXIS.) {
319 limit = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_U_AXIScxx . . $ CT_U_AXIS. - 1] > 1.5f) ? 0.95f
320 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_U_AXIScxx . . $ CT_U_AXIS. - 1] > 1.0f) ? 0.80f
321 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_U_AXIScxx . . $ CT_U_AXIS. - 1] / 2);
322 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_U_AXIScxx . . $ CT_U_AXIS., ctAnalogcxx . . $ ctAnalog.);
323 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) > limit)
324 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_U_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
325 }
326 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_R_AXIScxx . . $ CTF_R_AXIS.) {
327 limit = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_R_AXIScxx . . $ CT_R_AXIS. - 1] > 1.5f) ? 0.95f
328 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_R_AXIScxx . . $ CT_R_AXIS. - 1] > 1.0f) ? 0.80f
329 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_R_AXIScxx . . $ CT_R_AXIS. - 1] / 2);
330 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_R_AXIScxx . . $ CT_R_AXIS., ctAnalogcxx . . $ ctAnalog.);
331 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) > limit)
332 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_R_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
333 }
334 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_Z_AXIScxx . . $ CTF_Z_AXIS.) {
335 limit = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_Z_AXIScxx . . $ CT_Z_AXIS. - 1] > 1.5f) ? 0.95f
336 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_Z_AXIScxx . . $ CT_Z_AXIS. - 1] > 1.0f) ? 0.80f
337 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_Z_AXIScxx . . $ CT_Z_AXIS. - 1] / 2);
338 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_Z_AXIScxx . . $ CT_Z_AXIS., ctAnalogcxx . . $ ctAnalog.);
339 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) > limit)
340 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_Z_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
341 }
342 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_Y_AXIScxx . . $ CTF_Y_AXIS.) {
343 limit = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_Y_AXIScxx . . $ CT_Y_AXIS. - 1] > 1.5f) ? 0.95f
344 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_Y_AXIScxx . . $ CT_Y_AXIS. - 1] > 1.0f) ? 0.80f
345 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_Y_AXIScxx . . $ CT_Y_AXIS. - 1] / 2);
346 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_Y_AXIScxx . . $ CT_Y_AXIS., ctAnalogcxx . . $ ctAnalog.);
347 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) > limit)
348 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_Y_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
349 }
350 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_X_AXIScxx . . $ CTF_X_AXIS.) {
351 limit = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_X_AXIScxx . . $ CT_X_AXIS. - 1] > 1.5f) ? 0.95f
352 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_X_AXIScxx . . $ CT_X_AXIS. - 1] > 1.0f) ? 0.80f
353 : (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[CT_X_AXIScxx . . $ CT_X_AXIS. - 1] / 2);
354 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_X_AXIScxx . . $ CT_X_AXIS., ctAnalogcxx . . $ ctAnalog.);
355 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) > limit)
356 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_X_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
357 }
358 }
359 break;
360
361 case ctMouseAxiscxx . . $ ctMouseAxis.: {
362 float pos = 0.0f;
363 unsigned ctl = CONTROLLER_CTL_INFOcxx . . $ `lib/Controller.h:194:9`!(1, NULL_CONTROLLERcxx . . $ `lib/Controller.h:181:9`!), i = 1;
364
365 ASSERTcxx . . $ `misc/pserror.h:246:9`!(m_ControlList[i].id == CTID_MOUSE);
366
367 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_V_AXIScxx . . $ CTF_V_AXIS.) {
368 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_V_AXIScxx . . $ CT_V_AXIS., ctAnalogcxx . . $ ctAnalog.);
369 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) >= 0.50f)
370 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_V_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
371 }
372 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_U_AXIScxx . . $ CTF_U_AXIS.) {
373 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_U_AXIScxx . . $ CT_U_AXIS., ctAnalogcxx . . $ ctAnalog.);
374 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) >= 0.50f)
375 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_U_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
376 }
377 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_R_AXIScxx . . $ CTF_R_AXIS.) {
378 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_R_AXIScxx . . $ CT_R_AXIS., ctAnalogcxx . . $ ctAnalog.);
379 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) >= 0.90f)
380 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_R_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
381 }
382 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_Z_AXIScxx . . $ CTF_Z_AXIS.) {
383 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_Z_AXIScxx . . $ CT_Z_AXIS., ctAnalogcxx . . $ ctAnalog.);
384 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) >= 0.50f)
385 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_Z_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
386 }
387 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_Y_AXIScxx . . $ CTF_Y_AXIS.) {
388 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_Y_AXIScxx . . $ CT_Y_AXIS., ctAnalogcxx . . $ ctAnalog.);
389 // mprintf(0, "y=%.2f ", pos);
390 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) >= 0.90f)
391 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_Y_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
392 }
393 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & CTF_X_AXIScxx . . $ CTF_X_AXIS.) {
394 pos = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(i, CT_X_AXIScxx . . $ CT_X_AXIS., ctAnalogcxx . . $ ctAnalog.);
395 // mprintf(0, "x=%.2f\n", pos);
396 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pos) >= 0.90f)
397 val = MAKE_CONFIG_DATAcxx . . $ `lib/Controller.h:198:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(CT_X_AXIS, NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!));
398 }
399 } break;
400
401 case ctPOVcxx . . $ ctPOV.:
402 case ctPOV2cxx . . $ ctPOV2.:
403 case ctPOV3cxx . . $ ctPOV3.:
404 case ctPOV4cxx . . $ ctPOV4.:
405 if (type_req == ctPOVcxx . . $ ctPOV.) {
406 pov_n = 0;
407 } else {
408 pov_n = (type_req - ctPOV2cxx . . $ ctPOV2.) + 1;
409 }
410 for (i = 2; i < m_NumControlscxx . . $ lnxgameController#m_NumControls.; i++) {
411 float pos;
412 int ctl = CONTROLLER_CTL_INFOcxx . . $ `lib/Controller.h:194:9`!(i, -1);
413
414 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & (CTF_POVcxx . . $ CTF_POV. << pov_n)) {
415 pos = get_pov_valuecxx . . $ lnxgameController#get_pov_value(c199c3612abc2a26).(i, ctDigitalcxx . . $ ctDigital., pov_n, JOYPOV_RIGHTcxx . . $ `lib/joystick.h:90:9`!);
416 if (pos)
417 val = makewordcxx . . $ `lib/Controller.h:170:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(JOYPOV_RIGHTcxx . . $ `lib/joystick.h:90:9`!, 0));
418 }
419 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & (CTF_POVcxx . . $ CTF_POV. << pov_n)) {
420 pos = get_pov_valuecxx . . $ lnxgameController#get_pov_value(c199c3612abc2a26).(i, ctDigitalcxx . . $ ctDigital., pov_n, JOYPOV_LEFTcxx . . $ `lib/joystick.h:92:9`!);
421 if (pos)
422 val = makewordcxx . . $ `lib/Controller.h:170:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(JOYPOV_LEFTcxx . . $ `lib/joystick.h:92:9`!, 0));
423 }
424 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & (CTF_POVcxx . . $ CTF_POV. << pov_n)) {
425 pos = get_pov_valuecxx . . $ lnxgameController#get_pov_value(c199c3612abc2a26).(i, ctDigitalcxx . . $ ctDigital., pov_n, JOYPOV_DOWNcxx . . $ `lib/joystick.h:91:9`!);
426 if (pos)
427 val = makewordcxx . . $ `lib/Controller.h:170:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(JOYPOV_DOWNcxx . . $ `lib/joystick.h:91:9`!, 0));
428 }
429 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & (CTF_POVcxx . . $ CTF_POV. << pov_n)) {
430 pos = get_pov_valuecxx . . $ lnxgameController#get_pov_value(c199c3612abc2a26).(i, ctDigitalcxx . . $ ctDigital., pov_n, JOYPOV_UPcxx . . $ `lib/joystick.h:89:9`!);
431 if (pos)
432 val = makewordcxx . . $ `lib/Controller.h:170:9`!(ctl, CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(JOYPOV_UPcxx . . $ `lib/joystick.h:89:9`!, 0));
433 }
434 }
435 break;
436 }
437
438 return val;
439 }
440
441 // sets the configuration of a function (type must be of an array == CTLBINDS_PER_FUNC)
442 void lnxgameControllercxx . . $ lnxgameController#::set_controller_functioncxx . . $ lnxgameController#set_controller_function(a87bf4975f40b925).(int id, const ct_typecxx . . $ ct_type# *type, ct_config_datacxx . . $ ct_config_data# value, const uint8_tcxx . . $ uint8_t# *flags) {
443 ct_elementcxx . . $ lnxgameController#ct_element# elem;
444
445 if (id >= CT_MAX_ELEMENTScxx . . $ CT_MAX_ELEMENTS.)
446 return;
447
448 // auto assign keyboard controller if type is key.
449 if (type[0] == ctKeycxx . . $ ctKey.)
450 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[0] = CONTROLLER_CTL1_INFOcxx . . $ `lib/Controller.h:192:9`!(0);
451 else
452 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[0] = CONTROLLER_CTL1_INFOcxx . . $ `lib/Controller.h:192:9`!(CONTROLLER_INFOcxx . . $ `lib/Controller.h:197:9`!(value));
453
454 if (type[1] == ctKeycxx . . $ ctKey.)
455 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[1] = CONTROLLER_CTL2_INFOcxx . . $ `lib/Controller.h:193:9`!(0);
456 else
457 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[1] = CONTROLLER_CTL2_INFOcxx . . $ `lib/Controller.h:193:9`!(CONTROLLER_INFOcxx . . $ `lib/Controller.h:197:9`!(value));
458
459 elem.ctypecxx . . $ lnxgameController#ct_element#ctype.[0] = type[0];
460 elem.ctypecxx . . $ lnxgameController#ct_element#ctype.[1] = type[1];
461 elem.formatcxx . . $ lnxgameController#ct_element#format. = m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].formatcxx . . $ lnxgameController#ct_element#format.;
462 elem.valuecxx . . $ lnxgameController#ct_element#value.[0] = CONTROLLER_CTL1_VALUEcxx . . $ `lib/Controller.h:188:9`!(CONTROLLER_VALUEcxx . . $ `lib/Controller.h:196:9`!(value));
463 elem.valuecxx . . $ lnxgameController#ct_element#value.[1] = CONTROLLER_CTL2_VALUEcxx . . $ `lib/Controller.h:189:9`!(CONTROLLER_VALUEcxx . . $ `lib/Controller.h:196:9`!(value));
464 elem.flagscxx . . $ lnxgameController#ct_element#flags.[0] = flags[0];
465 elem.flagscxx . . $ lnxgameController#ct_element#flags.[1] = flags[1];
466 elem.enabledcxx . . $ lnxgameController#ct_element#enabled. = m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].enabledcxx . . $ lnxgameController#ct_element#enabled.;
467
468 // if controller doesn't exist, set it to invalid.
469 if (elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[0] > CT_MAX_CONTROLLERScxx . . $ CT_MAX_CONTROLLERS.)
470 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[0] = NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`!;
471 if (elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[1] >= CT_MAX_CONTROLLERScxx . . $ CT_MAX_CONTROLLERS.)
472 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[1] = NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`!;
473
474 assign_elementcxx . . $ lnxgameController#assign_element(3ef7288ee539ac42).(id, &elem);
475 }
476
477 // returns information about a requested function (type must be of an array == CTLBINDS_PER_FUNC)
478 void lnxgameControllercxx . . $ lnxgameController#::get_controller_functioncxx . . $ lnxgameController#get_controller_function(c004c324aa6068e0).(int id, ct_typecxx . . $ ct_type# *type, ct_config_datacxx . . $ ct_config_data# *value, uint8_tcxx . . $ uint8_t# *flags) {
479 type[0] = m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].ctypecxx . . $ lnxgameController#ct_element#ctype.[0];
480 type[1] = m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].ctypecxx . . $ lnxgameController#ct_element#ctype.[1];
481 *value = makewordcxx . . $ `lib/Controller.h:170:9`!(CONTROLLER_CTL_INFOcxx . . $ `lib/Controller.h:194:9`!(m_ElementList[id].ctl[0], m_ElementList[id].ctl[1]),
482 CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(m_ElementList[id].value[0], m_ElementList[id].value[1]));
483 flags[0] = m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].flagscxx . . $ lnxgameController#ct_element#flags.[0];
484 flags[1] = m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].flagscxx . . $ lnxgameController#ct_element#flags.[1];
485 }
486
487 // temporarily enables or disables a function
488 void lnxgameControllercxx . . $ lnxgameController#::enable_functioncxx . . $ lnxgameController#enable_function(918ebd27a9ddbad3).(int id, bool enable) { m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].enabledcxx . . $ lnxgameController#ct_element#enabled. = enable; }
489
490 // all systems need to implement this function. this returns information about the controller
491 bool lnxgameControllercxx . . $ lnxgameController#::get_packetcxx . . $ lnxgameController#get_packet(c1da47aee99b4b74).(int id, ct_packetcxx . . $ ct_packet# *packet, ct_formatcxx . . $ ct_format# alt_format) {
492 float val = (float)0.0;
493 int i;
494
495 ASSERTcxx . . $ `misc/pserror.h:246:9`!(id < CT_MAX_ELEMENTS);
496
497 packet->formatcxx . . $ ct_packet#format. = (alt_format != ctNoFormatcxx . . $ ctNoFormat.) ? alt_format : m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].formatcxx . . $ lnxgameController#ct_element#format.;
498 alt_format = packet->formatcxx . . $ ct_packet#format.;
499
500 WinControllerTimercxx . . $ WinControllerTimer. = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!();
501 packet->flagscxx . . $ ct_packet#flags. = 0;
502
503 if (!m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].enabledcxx . . $ lnxgameController#ct_element#enabled.) {
504 goto skip_packet_read;
505 }
506
507 // check if the element's controller is valid.
508
509 for (i = 0; i < CTLBINDS_PER_FUNCcxx . . $ `lib/Controller.h:200:9`!; i++) {
510 uint8_tcxx . . $ uint8_t# value = m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].valuecxx . . $ lnxgameController#ct_element#value.[i];
511 int8_tcxx . . $ int8_t# controller = m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].ctlcxx . . $ lnxgameController#ct_element#ctl.[i];
512
513 if (controller == -1 || m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id. == CTID_INVALIDcxx . . $ CTID_INVALID.) {
514 continue;
515 }
516 switch (m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].ctypecxx . . $ lnxgameController#ct_element#ctype.[i]) {
517 case ctKeycxx . . $ ctKey.:
518 if (value) {
519 val = get_key_valuecxx . . $ lnxgameController#get_key_value(5d9504f2bec60a96).(value, alt_format);
520 if (KEY_STATEcxx . . $ `ddio/ddio_common.h:204:9`!(value))
521 packet->flagscxx . . $ ct_packet#flags. |= CTPK_ELEMENTACTIVEcxx . . $ `lib/Controller.h:162:9`!;
522 }
523 break;
524
525 case ctMouseAxiscxx . . $ ctMouseAxis.:
526 packet->flagscxx . . $ ct_packet#flags. |= CTPK_MOUSEcxx . . $ `lib/Controller.h:163:9`!;
527 case ctAxiscxx . . $ ctAxis.:
528 val = get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(controller, value, alt_format, (m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].flagscxx . . $ lnxgameController#ct_element#flags.[i] & CTFNF_INVERTcxx . . $ `lib/Controller.h:178:9`!) ? true : false);
529 if (m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].flagscxx . . $ lnxgameController#ct_element#flags.[i] & CTFNF_INVERTcxx . . $ `lib/Controller.h:178:9`!) {
530 if (alt_format == ctDigitalcxx . . $ ctDigital.) {
531 val = (val == 0.0f) ? 1.0f : 0.0f;
532 } else if (alt_format == ctAnalogcxx . . $ ctAnalog.) {
533 val = -val;
534 }
535 }
536 break;
537
538 case ctMouseButtoncxx . . $ ctMouseButton.:
539 packet->flagscxx . . $ ct_packet#flags. |= CTPK_MOUSEcxx . . $ `lib/Controller.h:163:9`!;
540 case ctButtoncxx . . $ ctButton.:
541 val = get_button_valuecxx . . $ lnxgameController#get_button_value(aea33017bc1b5815).(controller, alt_format, value);
542 break;
543
544 case ctPOVcxx . . $ ctPOV.:
545 val = get_pov_valuecxx . . $ lnxgameController#get_pov_value(c199c3612abc2a26).(controller, alt_format, 0, value);
546 break;
547 case ctPOV2cxx . . $ ctPOV2.:
548 case ctPOV3cxx . . $ ctPOV3.:
549 case ctPOV4cxx . . $ ctPOV4.:
550 val = get_pov_valuecxx . . $ lnxgameController#get_pov_value(c199c3612abc2a26).(controller, alt_format, (m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].ctypecxx . . $ lnxgameController#ct_element#ctype.[i] - ctPOV2cxx . . $ ctPOV2.) + 1, value);
551 break;
552
553 default:
554 Int3cxx . . $ `misc/pserror.h:247:9`!();
555 val = 0.0f;
556 }
557
558 if (val)
559 break;
560 }
561
562 skip_packet_read:
563 if (val)
564 packet->flagscxx . . $ ct_packet#flags. |= CTPK_ELEMENTACTIVEcxx . . $ `lib/Controller.h:162:9`!;
565
566 packet->valuecxx . . $ ct_packet#value. = val;
567
568 return true;
569 }
570
571 // gets sensitivity of axis item
572 float lnxgameControllercxx . . $ lnxgameController#::get_axis_sensitivitycxx . . $ lnxgameController#get_axis_sensitivity(13d73da2a9b3a1ee).(ct_typecxx . . $ ct_type# axis_type, uint8_tcxx . . $ uint8_t# axis) {
573 axis--;
574 ASSERTcxx . . $ `misc/pserror.h:246:9`!(axis < CT_NUM_AXES);
575
576 switch (axis_type) {
577 case ctMouseAxiscxx . . $ ctMouseAxis.:
578 return m_ControlListcxx . . $ lnxgameController#m_ControlList.[1].senscxx . . $ lnxgameController#t_controller#sens.[axis];
579
580 case ctAxiscxx . . $ ctAxis.:
581 return m_ControlListcxx . . $ lnxgameController#m_ControlList.[2].senscxx . . $ lnxgameController#t_controller#sens.[axis];
582
583 default:
584 Int3cxx . . $ `misc/pserror.h:247:9`!();
585 }
586
587 return 0.0f;
588 }
589
590 // sets sensitivity of axis item
591 void lnxgameControllercxx . . $ lnxgameController#::set_axis_sensitivitycxx . . $ lnxgameController#set_axis_sensitivity(b979151824fed4c4).(ct_typecxx . . $ ct_type# axis_type, uint8_tcxx . . $ uint8_t# axis, float val) {
592 int i;
593
594 axis--;
595 ASSERTcxx . . $ `misc/pserror.h:246:9`!(axis < CT_NUM_AXES);
596
597 switch (axis_type) {
598 case ctMouseAxiscxx . . $ ctMouseAxis.:
599 m_ControlListcxx . . $ lnxgameController#m_ControlList.[1].senscxx . . $ lnxgameController#t_controller#sens.[axis] = val;
600 break;
601 case ctAxiscxx . . $ ctAxis.:
602 for (i = 2; i < CT_MAX_CONTROLLERScxx . . $ CT_MAX_CONTROLLERS.; i++)
603 m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].senscxx . . $ lnxgameController#t_controller#sens.[axis] = val;
604 break;
605 default:
606 Int3cxx . . $ `misc/pserror.h:247:9`!();
607 }
608 }
609
610 // assigns an individual function
611 int lnxgameControllercxx . . $ lnxgameController#::assign_functioncxx . . $ lnxgameController#assign_function(2608e8495e192ac3).(ct_functioncxx . . $ ct_function# *func) {
612 // for now this is a straight forward translation (that is, no mapping of needs to controller
613 // list to create elements.
614 ct_elementcxx . . $ lnxgameController#ct_element# elem;
615 int i;
616
617 for (i = 0; i < CTLBINDS_PER_FUNCcxx . . $ `lib/Controller.h:200:9`!; i++) {
618 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[i] = NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`!;
619
620 switch (func->ctypecxx . . $ ct_function#ctype.[i]) {
621 int pov_n;
622 case ctNonecxx . . $ ctNone.:
623 break;
624 case ctKeycxx . . $ ctKey.:
625 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[i] = 0;
626 break;
627 case ctAxiscxx . . $ ctAxis.:
628 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[i] = get_axis_controllercxx . . $ lnxgameController#get_axis_controller(bea2bd53c861b042).(func->valuecxx . . $ ct_function#value.[i]);
629 break;
630
631 case ctButtoncxx . . $ ctButton.:
632 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[i] = get_button_controllercxx . . $ lnxgameController#get_button_controller(bea2bd53c861b042).(func->valuecxx . . $ ct_function#value.[i]);
633 break;
634
635 case ctMouseAxiscxx . . $ ctMouseAxis.:
636 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[i] = 1;
637 break;
638
639 case ctMouseButtoncxx . . $ ctMouseButton.:
640 // find a free mouse button.
641 if ((m_ControlListcxx . . $ lnxgameController#m_ControlList.[1].btnmaskcxx . . $ lnxgameController#t_controller#btnmask. & (1 << (func->valuecxx . . $ ct_function#value.[i] - 1))) &&
642 ((func->valuecxx . . $ ct_function#value.[i] - 1) < m_ControlListcxx . . $ lnxgameController#m_ControlList.[1].buttonscxx . . $ lnxgameController#t_controller#buttons.)) {
643 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[i] = 1;
644 }
645 break;
646
647 case ctPOVcxx . . $ ctPOV.:
648 case ctPOV2cxx . . $ ctPOV2.:
649 case ctPOV3cxx . . $ ctPOV3.:
650 case ctPOV4cxx . . $ ctPOV4.:
651 if (func->ctypecxx . . $ ct_function#ctype.[i] == ctPOVcxx . . $ ctPOV.)
652 pov_n = 0;
653 else
654 pov_n = (func->ctypecxx . . $ ct_function#ctype.[i] - ctPOV2cxx . . $ ctPOV2.) + 1;
655
656 elem.ctlcxx . . $ lnxgameController#ct_element#ctl.[i] = get_pov_controllercxx . . $ lnxgameController#get_pov_controller(bea2bd53c861b042).(pov_n);
657 break;
658 }
659
660 elem.ctypecxx . . $ lnxgameController#ct_element#ctype.[i] = func->ctypecxx . . $ ct_function#ctype.[i];
661 elem.valuecxx . . $ lnxgameController#ct_element#value.[i] = func->valuecxx . . $ ct_function#value.[i];
662 }
663
664 elem.formatcxx . . $ lnxgameController#ct_element#format. = func->formatcxx . . $ ct_function#format.;
665 elem.flagscxx . . $ lnxgameController#ct_element#flags.[0] = func->flagscxx . . $ ct_function#flags.[0];
666 elem.flagscxx . . $ lnxgameController#ct_element#flags.[1] = func->flagscxx . . $ ct_function#flags.[1];
667 elem.enabledcxx . . $ lnxgameController#ct_element#enabled. = true;
668
669 assign_elementcxx . . $ lnxgameController#assign_element(3ef7288ee539ac42).(func->idcxx . . $ ct_function#id., &elem);
670
671 return func->idcxx . . $ ct_function#id.;
672 }
673
674 // get raw values for the controllers
675 int lnxgameControllercxx . . $ lnxgameController#::get_mouse_raw_valuescxx . . $ lnxgameController#get_mouse_raw_values(aa23d0250da59a45).(int *x, int *y) {
676 if (m_Suspendedcxx . . $ lnxgameController#m_Suspended.)
677 return 0;
678
679 *x = m_MseStatecxx . . $ lnxgameController#m_MseState..mxcxx . . $ lnxgameController#t_msestate#mx.;
680 *y = m_MseStatecxx . . $ lnxgameController#m_MseState..mycxx . . $ lnxgameController#t_msestate#my.;
681
682 return m_MseStatecxx . . $ lnxgameController#m_MseState..btnmaskcxx . . $ lnxgameController#t_msestate#btnmask.;
683 }
684
685 unsigned lnxgameControllercxx . . $ lnxgameController#::get_joy_raw_valuescxx . . $ lnxgameController#get_joy_raw_values(ef0362c0d321f56b).(int *x, int *y) {
686 unsigned btn = 0;
687
688 if (m_Suspendedcxx . . $ lnxgameController#m_Suspended.)
689 return 0;
690
691 for (int ctl = 0; ctl < m_NumControlscxx . . $ lnxgameController#m_NumControls.; ctl++) {
692 int dev = m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].idcxx . . $ lnxgameController#t_controller#id.;
693
694 if (dev >= CTID_EXTCONTROL0cxx . . $ CTID_EXTCONTROL0.) {
695 *x = m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].xcxx . . $ lnxgameController#t_extctlstate#x.;
696 *y = m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].ycxx . . $ lnxgameController#t_extctlstate#y.;
697 btn = m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].buttonscxx . . $ lnxgameController#t_extctlstate#buttons.;
698 if (*x || *y || btn)
699 return btn;
700 }
701 }
702
703 return 0;
704 }
705
706 gameControllercxx . . $ gameController# *CreateControllercxx . . $ CreateController(81c4a189a587b469).(int num_funcs, ct_functioncxx . . $ ct_function# *funcs, char *remote_ip) {
707 return new lnxgameControllercxx . . $ lnxgameController#(num_funcs, funcs);
708 }
709
710 void DestroyControllercxx . . $ DestroyController(66dd5cf3e0c6b3e1).(gameControllercxx . . $ gameController# *ctl) {
711 if (ctl)
712 delete ctl;
713 }
714
715 // activates or deactivates mouse and or controller
716 void lnxgameControllercxx . . $ lnxgameController#::mask_controllerscxx . . $ lnxgameController#mask_controllers(b0b38cda41d4ede4).(bool joystick, bool mouse) {
717 int i, j;
718
719 m_JoyActivecxx . . $ lnxgameController#m_JoyActive. = joystick;
720 m_MouseActivecxx . . $ lnxgameController#m_MouseActive. = mouse;
721
722 if (!m_MouseActivecxx . . $ lnxgameController#m_MouseActive.) {
723 m_MseStatecxx . . $ lnxgameController#m_MseState..xcxx . . $ lnxgameController#t_msestate#x. = 0;
724 m_MseStatecxx . . $ lnxgameController#m_MseState..ycxx . . $ lnxgameController#t_msestate#y. = 0;
725 m_MseStatecxx . . $ lnxgameController#m_MseState..zcxx . . $ lnxgameController#t_msestate#z. = 0;
726 m_MseStatecxx . . $ lnxgameController#m_MseState..mxcxx . . $ lnxgameController#t_msestate#mx. = 0;
727 m_MseStatecxx . . $ lnxgameController#m_MseState..mycxx . . $ lnxgameController#t_msestate#my. = 0;
728 m_MseStatecxx . . $ lnxgameController#m_MseState..btnmaskcxx . . $ lnxgameController#t_msestate#btnmask. = 0;
729 }
730
731 if (!m_JoyActivecxx . . $ lnxgameController#m_JoyActive.) {
732 for (int ctl = 0; ctl < m_NumControlscxx . . $ lnxgameController#m_NumControls.; ctl++) {
733 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].idcxx . . $ lnxgameController#t_controller#id. >= CTID_EXTCONTROL0cxx . . $ CTID_EXTCONTROL0.) {
734 // handle buttons
735 int dev = m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].idcxx . . $ lnxgameController#t_controller#id.;
736 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].xcxx . . $ lnxgameController#t_extctlstate#x. = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].normalizercxx . . $ lnxgameController#t_controller#normalizer.[0]);
737 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].ycxx . . $ lnxgameController#t_extctlstate#y. = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].normalizercxx . . $ lnxgameController#t_controller#normalizer.[1]);
738 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].zcxx . . $ lnxgameController#t_extctlstate#z. = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].normalizercxx . . $ lnxgameController#t_controller#normalizer.[2]);
739 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].rcxx . . $ lnxgameController#t_extctlstate#r. = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].normalizercxx . . $ lnxgameController#t_controller#normalizer.[3]);
740 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].ucxx . . $ lnxgameController#t_extctlstate#u. = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].normalizercxx . . $ lnxgameController#t_controller#normalizer.[4]);
741 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].vcxx . . $ lnxgameController#t_extctlstate#v. = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[ctl].normalizercxx . . $ lnxgameController#t_controller#normalizer.[5]);
742 for (j = 0; j < JOYPOV_NUMcxx . . $ `lib/joystick.h:72:9`!; j++) {
743 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].povcxx . . $ lnxgameController#t_extctlstate#pov.[j] = JOYPOV_CENTERcxx . . $ `lib/joystick.h:93:9`!;
744 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].last_povcxx . . $ lnxgameController#t_extctlstate#last_pov.[j] = JOYPOV_CENTERcxx . . $ `lib/joystick.h:93:9`!;
745
746 for (i = 0; i < JOYPOV_DIRcxx . . $ `lib/joystick.h:87:9`!; i++) {
747 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].povstartscxx . . $ lnxgameController#t_extctlstate#povstarts.[j][i] = (float)0.0;
748 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].povtimescxx . . $ lnxgameController#t_extctlstate#povtimes.[j][i] = (float)0.0;
749 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].povpressescxx . . $ lnxgameController#t_extctlstate#povpresses.[j][i] = 0;
750 }
751 }
752
753 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].buttonscxx . . $ lnxgameController#t_extctlstate#buttons. = 0;
754 for (i = 0; i < CT_MAX_BUTTONScxx . . $ CT_MAX_BUTTONS.; i++) {
755 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].btnpressescxx . . $ lnxgameController#t_extctlstate#btnpresses.[i] = 0;
756 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].btntimescxx . . $ lnxgameController#t_extctlstate#btntimes.[i] = (float)0.0;
757 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[dev].btnstartscxx . . $ lnxgameController#t_extctlstate#btnstarts.[i] = (float)0.0;
758 }
759 }
760 }
761 }
762 }
763
764 // ---------------------------------------------------------------------------
765 // controller functions
766
767 void lnxgameControllercxx . . $ lnxgameController#::extctl_getposcxx . . $ lnxgameController#extctl_getpos(d4f767463ce0a6b3).(int id) {
768 tJoyPoscxx . . $ tJoyPos# ji;
769 float timer_val;
770 int i;
771
772 if (!m_JoyActivecxx . . $ lnxgameController#m_JoyActive.) {
773 return;
774 }
775
776 timer_val = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!();
777
778 joy_GetRawPoscxx . . $ joy_GetRawPos(47f0a1b684eacd68).((tJoystickcxx . . $ tJoystick#)id, &ji);
779
780 // if(g_accum_frame_time == 0.0f) {
781 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].xcxx . . $ lnxgameController#t_extctlstate#x. = (int)ji.xcxx . . $ tJoyPos#x.;
782 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].ycxx . . $ lnxgameController#t_extctlstate#y. = (int)ji.ycxx . . $ tJoyPos#y.;
783 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].zcxx . . $ lnxgameController#t_extctlstate#z. = (int)ji.zcxx . . $ tJoyPos#z.;
784 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].rcxx . . $ lnxgameController#t_extctlstate#r. = (int)ji.rcxx . . $ tJoyPos#r.;
785 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].ucxx . . $ lnxgameController#t_extctlstate#u. = (int)ji.ucxx . . $ tJoyPos#u.;
786 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].vcxx . . $ lnxgameController#t_extctlstate#v. = (int)ji.vcxx . . $ tJoyPos#v.;
787
788 for (i = 0; i < JOYPOV_NUMcxx . . $ `lib/joystick.h:72:9`!; i++) {
789 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].last_povcxx . . $ lnxgameController#t_extctlstate#last_pov.[i] = m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povcxx . . $ lnxgameController#t_extctlstate#pov.[i];
790 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povcxx . . $ lnxgameController#t_extctlstate#pov.[i] = ji.povcxx . . $ tJoyPos#pov.[i];
791
792 // when pov changes position and new position is not in center, then set a new start time.
793 int pov_index = m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povcxx . . $ lnxgameController#t_extctlstate#pov.[i] / (JOYPOV_MAXVALcxx . . $ `lib/joystick.h:88:9`! / JOYPOV_DIRcxx . . $ `lib/joystick.h:87:9`!);
794 int last_pov_index = m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].last_povcxx . . $ lnxgameController#t_extctlstate#last_pov.[i] / (JOYPOV_MAXVALcxx . . $ `lib/joystick.h:88:9`! / JOYPOV_DIRcxx . . $ `lib/joystick.h:87:9`!);
795
796 if (m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povcxx . . $ lnxgameController#t_extctlstate#pov.[i] != m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].last_povcxx . . $ lnxgameController#t_extctlstate#last_pov.[i]) {
797 if (m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povcxx . . $ lnxgameController#t_extctlstate#pov.[i] != JOYPOV_CENTERcxx . . $ `lib/joystick.h:93:9`!)
798 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povstartscxx . . $ lnxgameController#t_extctlstate#povstarts.[i][pov_index] = timer_val;
799 if (m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].last_povcxx . . $ lnxgameController#t_extctlstate#last_pov.[i] != JOYPOV_CENTERcxx . . $ `lib/joystick.h:93:9`!)
800 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povtimescxx . . $ lnxgameController#t_extctlstate#povtimes.[i][last_pov_index] = timer_val - m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povstartscxx . . $ lnxgameController#t_extctlstate#povstarts.[i][last_pov_index];
801 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povpressescxx . . $ lnxgameController#t_extctlstate#povpresses.[i][pov_index]++;
802 }
803
804 if (m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povcxx . . $ lnxgameController#t_extctlstate#pov.[i] != JOYPOV_CENTERcxx . . $ `lib/joystick.h:93:9`!) {
805 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povtimescxx . . $ lnxgameController#t_extctlstate#povtimes.[i][pov_index] = timer_val - m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].povstartscxx . . $ lnxgameController#t_extctlstate#povstarts.[i][pov_index];
806 }
807 }
808 //}
809
810 // handle buttons
811 for (int i = 0; i < CT_MAX_BUTTONScxx . . $ CT_MAX_BUTTONS.; i++) {
812 // case if we read time before doing this again.
813 if ((ji.buttonscxx . . $ tJoyPos#buttons. & (1 << i)) && (m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].btnstartscxx . . $ lnxgameController#t_extctlstate#btnstarts.[i] == (float)0.0))
814 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].btnstartscxx . . $ lnxgameController#t_extctlstate#btnstarts.[i] = timer_val;
815 if ((ji.buttonscxx . . $ tJoyPos#buttons. & (1 << i)) && !(m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].buttonscxx . . $ lnxgameController#t_extctlstate#buttons. & (1 << i))) {
816 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].btnpressescxx . . $ lnxgameController#t_extctlstate#btnpresses.[i]++;
817 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].btnstartscxx . . $ lnxgameController#t_extctlstate#btnstarts.[i] = timer_val;
818 // mprintf(0, "Start time for %d = %f\n", i, timer_val);
819 }
820
821 if (ji.buttonscxx . . $ tJoyPos#buttons. & (1 << i)) // if button is down
822 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].btntimescxx . . $ lnxgameController#t_extctlstate#btntimes.[i] = timer_val - m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].btnstartscxx . . $ lnxgameController#t_extctlstate#btnstarts.[i];
823 else if (m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].buttonscxx . . $ lnxgameController#t_extctlstate#buttons. & (1 << i)) // if button is up and last pass it was down.
824 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].btntimescxx . . $ lnxgameController#t_extctlstate#btntimes.[i] = timer_val - m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].btnstartscxx . . $ lnxgameController#t_extctlstate#btnstarts.[i];
825 }
826
827 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[id].buttonscxx . . $ lnxgameController#t_extctlstate#buttons. = ji.buttonscxx . . $ tJoyPos#buttons.;
828 }
829
830 void lnxgameControllercxx . . $ lnxgameController#::mouse_getevalcxx . . $ lnxgameController#mouse_geteval(49f6e7a06ebc5aa8).() {
831 int x, y, dx, dy; //,z;
832 unsigned btnmask;
833
834 if (!m_MouseActivecxx . . $ lnxgameController#m_MouseActive.) {
835 return;
836 }
837
838 if (g_accum_frame_timecxx . . $ g_accum_frame_time. != 0.0f)
839 return;
840
841 btnmask = (unsigned)ddio_MouseGetStatecxx . . $ ddio_MouseGetState(150f8a26046a094b).(&x, &y, &dx, &dy);
842
843 m_MseStatecxx . . $ lnxgameController#m_MseState..xcxx . . $ lnxgameController#t_msestate#x. = dx;
844 m_MseStatecxx . . $ lnxgameController#m_MseState..ycxx . . $ lnxgameController#t_msestate#y. = dy;
845 m_MseStatecxx . . $ lnxgameController#m_MseState..zcxx . . $ lnxgameController#t_msestate#z. = 0;
846 m_MseStatecxx . . $ lnxgameController#m_MseState..mxcxx . . $ lnxgameController#t_msestate#mx. = x;
847 m_MseStatecxx . . $ lnxgameController#m_MseState..mycxx . . $ lnxgameController#t_msestate#my. = y;
848
849 m_MseStatecxx . . $ lnxgameController#m_MseState..btnmaskcxx . . $ lnxgameController#t_msestate#btnmask. = btnmask;
850 }
851
852 // enumerate all controllers on system
853 bool lnxgameControllercxx . . $ lnxgameController#::enum_controllerscxx . . $ lnxgameController#enum_controllers(c9857a73d68e59ba).() {
854 int num_devs = 0, dev;
855 int i;
856
857 for (i = 0; i < CT_MAX_CONTROLLERScxx . . $ CT_MAX_CONTROLLERS.; i++)
858 m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].idcxx . . $ lnxgameController#t_controller#id. = CTID_INVALIDcxx . . $ CTID_INVALID.;
859
860 // Add keyboard controller
861 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].idcxx . . $ lnxgameController#t_controller#id. = CTID_KEYBOARDcxx . . $ CTID_KEYBOARD.;
862 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].buttonscxx . . $ lnxgameController#t_controller#buttons. = 0;
863 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].flagscxx . . $ lnxgameController#t_controller#flags. = 0;
864 num_devs++;
865
866 // add mouse controller
867
868 int left, top, right, bottom, zmin, zmax; // btns, axes,
869 int nbtns, naxis, btnmask;
870 ddio_MouseGetLimitscxx . . $ ddio_MouseGetLimits(883f425df92af248).(&left, &top, &right, &bottom, &zmin, &zmax);
871 btnmask = ddio_MouseGetCapscxx . . $ ddio_MouseGetCaps(aa23d0250da59a45).(&nbtns, &naxis);
872
873 // we will try to support a mouse with 3 axis and N_MSEBTNS buttons.
874 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].idcxx . . $ lnxgameController#t_controller#id. = CTID_MOUSEcxx . . $ CTID_MOUSE.;
875 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].buttonscxx . . $ lnxgameController#t_controller#buttons. = nbtns;
876 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].flagscxx . . $ lnxgameController#t_controller#flags. = CTF_X_AXIScxx . . $ CTF_X_AXIS. | CTF_Y_AXIScxx . . $ CTF_Y_AXIS.; // | (naxis>=3 ? CTF_Z_AXIS : 0);
877 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].btnmaskcxx . . $ lnxgameController#t_controller#btnmask. = btnmask;
878 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].normalizercxx . . $ lnxgameController#t_controller#normalizer.[0] = 320.0f;
879 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].normalizercxx . . $ lnxgameController#t_controller#normalizer.[1] = 240.0f;
880 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].normalizercxx . . $ lnxgameController#t_controller#normalizer.[2] = 100.0f;
881 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].senscxx . . $ lnxgameController#t_controller#sens.[0] = 1.0f;
882 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].senscxx . . $ lnxgameController#t_controller#sens.[1] = 1.0f;
883 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].senscxx . . $ lnxgameController#t_controller#sens.[2] = 1.0f;
884 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].sensmodcxx . . $ lnxgameController#t_controller#sensmod.[0] = 1.0f;
885 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].sensmodcxx . . $ lnxgameController#t_controller#sensmod.[1] = 1.0f;
886 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].sensmodcxx . . $ lnxgameController#t_controller#sensmod.[2] = 1.0f;
887 num_devs++;
888
889 // we should initialize multiple controls
890 // before doing this, MAKE SURE REMOTE CONTROL SUPPORTS IT.
891 for (dev = JOYSTICK_1cxx . . $ `lib/joystick.h:99:9`!; dev <= JOYSTICK_8cxx . . $ `lib/joystick.h:106:9`!; dev++) {
892 tJoyInfocxx . . $ tJoyInfo# jc;
893
894 // check if device is plugged in.
895 if (joy_IsValidcxx . . $ joy_IsValid(83c267b20bac841a).(dev)) {
896 // query the joystick's capabilites to see if joystick is truly valid
897 joy_GetJoyInfocxx . . $ joy_GetJoyInfo(6d54e3a34f20aef).((tJoystickcxx . . $ tJoystick#)dev, &jc);
898
899 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].idcxx . . $ lnxgameController#t_controller#id. = dev;
900 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].buttonscxx . . $ lnxgameController#t_controller#buttons. = jc.num_btnscxx . . $ tJoyInfo#num_btns.;
901 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].btnmaskcxx . . $ lnxgameController#t_controller#btnmask. = 0;
902 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].flagscxx . . $ lnxgameController#t_controller#flags. =
903 CTF_X_AXIScxx . . $ CTF_X_AXIS. | CTF_Y_AXIScxx . . $ CTF_Y_AXIS. | ((jc.axes_maskcxx . . $ tJoyInfo#axes_mask. & JOYFLAG_ZVALIDcxx . . $ `lib/joystick.h:77:9`!) ? CTF_Z_AXIScxx . . $ CTF_Z_AXIS. : 0) |
904 ((jc.axes_maskcxx . . $ tJoyInfo#axes_mask. & JOYFLAG_RVALIDcxx . . $ `lib/joystick.h:78:9`!) ? CTF_R_AXIScxx . . $ CTF_R_AXIS. : 0) | ((jc.axes_maskcxx . . $ tJoyInfo#axes_mask. & JOYFLAG_UVALIDcxx . . $ `lib/joystick.h:79:9`!) ? CTF_U_AXIScxx . . $ CTF_U_AXIS. : 0) |
905 ((jc.axes_maskcxx . . $ tJoyInfo#axes_mask. & JOYFLAG_VVALIDcxx . . $ `lib/joystick.h:80:9`!) ? CTF_V_AXIScxx . . $ CTF_V_AXIS. : 0) | ((jc.axes_maskcxx . . $ tJoyInfo#axes_mask. & JOYFLAG_POVVALIDcxx . . $ `lib/joystick.h:81:9`!) ? CTF_POVcxx . . $ CTF_POV. : 0) |
906 ((jc.axes_maskcxx . . $ tJoyInfo#axes_mask. & JOYFLAG_POV2VALIDcxx . . $ `lib/joystick.h:82:9`!) ? CTF_POV2cxx . . $ CTF_POV2. : 0) | ((jc.axes_maskcxx . . $ tJoyInfo#axes_mask. & JOYFLAG_POV3VALIDcxx . . $ `lib/joystick.h:83:9`!) ? CTF_POV3cxx . . $ CTF_POV3. : 0) |
907 ((jc.axes_maskcxx . . $ tJoyInfo#axes_mask. & JOYFLAG_POV4VALIDcxx . . $ `lib/joystick.h:84:9`!) ? CTF_POV4cxx . . $ CTF_POV4. : 0);
908 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].normalizercxx . . $ lnxgameController#t_controller#normalizer.[0] = (jc.maxxcxx . . $ tJoyInfo#maxx. - jc.minxcxx . . $ tJoyInfo#minx.) / 2.0f;
909 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].normalizercxx . . $ lnxgameController#t_controller#normalizer.[1] = (jc.maxycxx . . $ tJoyInfo#maxy. - jc.minycxx . . $ tJoyInfo#miny.) / 2.0f;
910 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].normalizercxx . . $ lnxgameController#t_controller#normalizer.[2] = (jc.maxzcxx . . $ tJoyInfo#maxz. - jc.minzcxx . . $ tJoyInfo#minz.) / 2.0f;
911 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].normalizercxx . . $ lnxgameController#t_controller#normalizer.[3] = (jc.maxrcxx . . $ tJoyInfo#maxr. - jc.minrcxx . . $ tJoyInfo#minr.) / 2.0f;
912 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].normalizercxx . . $ lnxgameController#t_controller#normalizer.[4] = (jc.maxucxx . . $ tJoyInfo#maxu. - jc.minucxx . . $ tJoyInfo#minu.) / 2.0f;
913 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].normalizercxx . . $ lnxgameController#t_controller#normalizer.[5] = (jc.maxvcxx . . $ tJoyInfo#maxv. - jc.minvcxx . . $ tJoyInfo#minv.) / 2.0f;
914
915 for (i = 0; i < CT_NUM_AXEScxx . . $ CT_NUM_AXES.; i++) {
916 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].senscxx . . $ lnxgameController#t_controller#sens.[i] = 1.0f;
917 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].sensmodcxx . . $ lnxgameController#t_controller#sensmod.[i] = 1.0f;
918 }
919 m_ControlListcxx . . $ lnxgameController#m_ControlList.[num_devs].deadzonecxx . . $ lnxgameController#t_controller#deadzone. = JOY_DEADZONEcxx . . $ `linux/lnxcontroller.cpp:61:9`!;
920 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Controller %s found.\n", jc.name);
921
922 // okay, now search for a "****.ctl" file in the current directory
923 parse_ctl_filecxx . . $ lnxgameController#parse_ctl_file(66835f578de1bcb3).(num_devs, jc.namecxx . . $ tJoyInfo#name.);
924
925 num_devs++;
926 if (num_devs == CT_MAX_CONTROLLERScxx . . $ CT_MAX_CONTROLLERS.)
927 break;
928 }
929 }
930 for (i = num_devs; i < CT_MAX_CONTROLLERScxx . . $ CT_MAX_CONTROLLERS.; i++) {
931 m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].idcxx . . $ lnxgameController#t_controller#id. = CTID_INVALIDcxx . . $ CTID_INVALID.;
932 }
933
934 m_NumControlscxx . . $ lnxgameController#m_NumControls. = num_devs;
935
936 lnxgameControllercxx . . $ lnxgameController#::flushcxx . . $ lnxgameController#flush(49f6e7a06ebc5aa8).();
937
938 return 1;
939 }
940
941 // returns the controller with a pov hat
942 int8_tcxx . . $ int8_t# lnxgameControllercxx . . $ lnxgameController#::get_pov_controllercxx . . $ lnxgameController#get_pov_controller(bea2bd53c861b042).(uint8_tcxx . . $ uint8_t# pov) {
943 // start from controller 2 because 0, and 1 are reserved for keyboard and mouse
944 uint16_tcxx . . $ uint16_t# pov_flag = CTF_POVcxx . . $ CTF_POV. << (pov);
945
946 for (int i = 2; i < m_NumControlscxx . . $ lnxgameController#m_NumControls.; i++)
947 if ((m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & pov_flag) && m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].idcxx . . $ lnxgameController#t_controller#id. != CTID_INVALIDcxx . . $ CTID_INVALID.)
948 return i;
949
950 return NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`!;
951 }
952
953 int8_tcxx . . $ int8_t# lnxgameControllercxx . . $ lnxgameController#::get_button_controllercxx . . $ lnxgameController#get_button_controller(bea2bd53c861b042).(uint8_tcxx . . $ uint8_t# btn) {
954 unsigned mask;
955
956 // buttons range from 1-CT_MAX_BUTTONS
957 ASSERTcxx . . $ `misc/pserror.h:246:9`!(btn <= CT_MAX_BUTTONS);
958 if (btn == NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!)
959 return NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`!;
960
961 mask = 1 << (btn - 1);
962
963 // start from controller 2 because 0, and 1 are reserved for keyboard and mouse
964 for (int i = 2; i < m_NumControlscxx . . $ lnxgameController#m_NumControls.; i++)
965 //@@ if (((unsigned)btn < m_ControlList[i].buttons) && !(m_ControlList[i].btnmask & mask) &&
966 //(m_ControlList[i].id
967 //!= CTID_INVALID)) {
968 if (((unsigned)btn < m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].buttonscxx . . $ lnxgameController#t_controller#buttons.) && (m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].idcxx . . $ lnxgameController#t_controller#id. != CTID_INVALIDcxx . . $ CTID_INVALID.)) {
969 //@@ m_ControlList[i].btnmask |= mask;
970 return i;
971 }
972
973 return NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`!;
974 }
975
976 int8_tcxx . . $ int8_t# lnxgameControllercxx . . $ lnxgameController#::get_axis_controllercxx . . $ lnxgameController#get_axis_controller(bea2bd53c861b042).(uint8_tcxx . . $ uint8_t# axis) {
977 // start from controller 2 because 0, and 1 are reserved for keyboard and mouse
978 if (axis == NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!)
979 return NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`!;
980
981 for (int i = 2; i < m_NumControlscxx . . $ lnxgameController#m_NumControls.; i++)
982 if ((m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].flagscxx . . $ lnxgameController#t_controller#flags. & (1 << (axis - 1))) && m_ControlListcxx . . $ lnxgameController#m_ControlList.[i].idcxx . . $ lnxgameController#t_controller#id. != CTID_INVALIDcxx . . $ CTID_INVALID.)
983 return i;
984
985 return NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`!;
986 }
987
988 void lnxgameControllercxx . . $ lnxgameController#::assign_elementcxx . . $ lnxgameController#assign_element(3ef7288ee539ac42).(int id, ct_elementcxx . . $ lnxgameController#ct_element# *elem) {
989 // assign element, check to see if valid.
990 int i;
991
992 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].formatcxx . . $ lnxgameController#ct_element#format. = elem->formatcxx . . $ lnxgameController#ct_element#format.;
993 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].flagscxx . . $ lnxgameController#ct_element#flags.[0] = elem->flagscxx . . $ lnxgameController#ct_element#flags.[0];
994 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].flagscxx . . $ lnxgameController#ct_element#flags.[1] = elem->flagscxx . . $ lnxgameController#ct_element#flags.[1];
995 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].enabledcxx . . $ lnxgameController#ct_element#enabled. = elem->enabledcxx . . $ lnxgameController#ct_element#enabled.;
996
997 // look through each controller and validate each element
998 for (i = 0; i < CTLBINDS_PER_FUNCcxx . . $ `lib/Controller.h:200:9`!; i++) {
999 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].ctlcxx . . $ lnxgameController#ct_element#ctl.[i] = elem->ctlcxx . . $ lnxgameController#ct_element#ctl.[i];
1000 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].valuecxx . . $ lnxgameController#ct_element#value.[i] = elem->valuecxx . . $ lnxgameController#ct_element#value.[i];
1001 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].ctypecxx . . $ lnxgameController#ct_element#ctype.[i] = elem->ctypecxx . . $ lnxgameController#ct_element#ctype.[i];
1002
1003 if (m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].ctlcxx . . $ lnxgameController#ct_element#ctl.[i] != NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`!) {
1004 // this function shouldn't do any error checking!!!! keep same controller values and bindings unless
1005 // bindings are truly bogus.
1006 switch (m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].ctypecxx . . $ lnxgameController#ct_element#ctype.[i]) {
1007 case ctMouseButtoncxx . . $ ctMouseButton.:
1008 case ctButtoncxx . . $ ctButton.:
1009 if (elem->valuecxx . . $ lnxgameController#ct_element#value.[i] > CT_MAX_BUTTONScxx . . $ CT_MAX_BUTTONS.) {
1010 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].ctlcxx . . $ lnxgameController#ct_element#ctl.[i] = NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`!;
1011 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].valuecxx . . $ lnxgameController#ct_element#value.[i] = NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!;
1012 }
1013 break;
1014 case ctMouseAxiscxx . . $ ctMouseAxis.:
1015 case ctAxiscxx . . $ ctAxis.:
1016 // if (!(m_ControlList[elem->ctl[i]].flags & (1<<(elem->value[i]-1))))
1017 // m_ElementList[id].ctl[i] = NULL_WINCONTROLLER;
1018 break;
1019 case ctPOVcxx . . $ ctPOV.:
1020 case ctPOV2cxx . . $ ctPOV2.:
1021 case ctPOV3cxx . . $ ctPOV3.:
1022 case ctPOV4cxx . . $ ctPOV4.:
1023 // if (!(m_ControlList[elem->ctl[i]].flags & CTF_POV))
1024 // m_ElementList[id].ctl[i] = NULL_WINCONTROLLER;
1025 break;
1026 case ctKeycxx . . $ ctKey.:
1027 break;
1028 default:
1029 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].valuecxx . . $ lnxgameController#ct_element#value.[i] = NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!;
1030 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].ctlcxx . . $ lnxgameController#ct_element#ctl.[i] = NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`!;
1031 }
1032 } else {
1033 m_ElementListcxx . . $ lnxgameController#m_ElementList.[id].valuecxx . . $ lnxgameController#ct_element#value.[i] = NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!;
1034 }
1035 }
1036 }
1037
1038 float lnxgameControllercxx . . $ lnxgameController#::get_button_valuecxx . . $ lnxgameController#get_button_value(aea33017bc1b5815).(int8_tcxx . . $ int8_t# controller, ct_formatcxx . . $ ct_format# format, uint8_tcxx . . $ uint8_t# button) {
1039 float val = (float)0.0;
1040
1041 if (controller <= NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`! || controller >= CT_MAX_CONTROLLERScxx . . $ CT_MAX_CONTROLLERS.) {
1042 return 0.0f;
1043 }
1044 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id. == CTID_INVALIDcxx . . $ CTID_INVALID.) {
1045 return 0.0f;
1046 }
1047
1048 #ifdef _DEBUGcxx . . $ `<built-in>:479:9`!
1049 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id. == CTID_KEYBOARDcxx . . $ CTID_KEYBOARD.) {
1050 Int3cxx . . $ `misc/pserror.h:247:9`!();
1051 return 0.0f;
1052 }
1053 #endif
1054
1055 if (button == NULL_BINDINGcxx . . $ `lib/Controller.h:180:9`!) {
1056 return val;
1057 }
1058
1059 // buttons are idenitifed as 0=none, 1 = button 1, etc. so if we have a valid button, then
1060 // decrement counter.
1061 button--;
1062
1063 // verify valid button.
1064 if ((unsigned)button >= m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].buttonscxx . . $ lnxgameController#t_controller#buttons.)
1065 return val;
1066
1067 switch (format) {
1068 // note we take care of mouse controls and external controls here
1069 case ctDownCountcxx . . $ ctDownCount.:
1070 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id. == CTID_MOUSEcxx . . $ CTID_MOUSE.) {
1071 val = (float)ddio_MouseBtnDownCountcxx . . $ ddio_MouseBtnDownCount(7864480464b09eea).(button);
1072 } else {
1073 val = (float)m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].btnpressescxx . . $ lnxgameController#t_extctlstate#btnpresses.[button];
1074 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].btnpressescxx . . $ lnxgameController#t_extctlstate#btnpresses.[button] = 0;
1075 }
1076 break;
1077
1078 case ctTimecxx . . $ ctTime.:
1079 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id. == CTID_MOUSEcxx . . $ CTID_MOUSE.) {
1080 val = ddio_MouseBtnDownTimecxx . . $ ddio_MouseBtnDownTime(5cde91ea12d43f46).(button);
1081 } else {
1082 if (!(m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].buttonscxx . . $ lnxgameController#t_extctlstate#buttons. & (1 << button))) {
1083 val = m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].btntimescxx . . $ lnxgameController#t_extctlstate#btntimes.[button];
1084 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].btnstartscxx . . $ lnxgameController#t_extctlstate#btnstarts.[button] = (float)0.0;
1085 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].btntimescxx . . $ lnxgameController#t_extctlstate#btntimes.[button] = (float)0.0;
1086 } else {
1087 val = WinControllerTimercxx . . $ WinControllerTimer. - m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].btnstartscxx . . $ lnxgameController#t_extctlstate#btnstarts.[button];
1088 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].btnstartscxx . . $ lnxgameController#t_extctlstate#btnstarts.[button] = WinControllerTimercxx . . $ WinControllerTimer.;
1089 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].btntimescxx . . $ lnxgameController#t_extctlstate#btntimes.[button] = (float)0.0;
1090 }
1091 }
1092 break;
1093
1094 case ctDigitalcxx . . $ ctDigital.:
1095 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id. == CTID_MOUSEcxx . . $ CTID_MOUSE.) {
1096 if (m_MseStatecxx . . $ lnxgameController#m_MseState..btnmaskcxx . . $ lnxgameController#t_msestate#btnmask. & (1 << button))
1097 val = 1.0f;
1098 } else if (m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].buttonscxx . . $ lnxgameController#t_extctlstate#buttons. & (1 << button)) {
1099 val = 1.0f;
1100 }
1101 break;
1102
1103 default:
1104 mprintfcxx . . $ `ddebug/mono.h:82:9`!(1, "gameController::button unsupported format for function\n");
1105 }
1106
1107 return val;
1108 }
1109
1110 // note controller is index into ControlList.
1111 float lnxgameControllercxx . . $ lnxgameController#::get_axis_valuecxx . . $ lnxgameController#get_axis_value(a4bbe37243b73efe).(int8_tcxx . . $ int8_t# controller, uint8_tcxx . . $ uint8_t# axis, ct_formatcxx . . $ ct_format# format, bool invert) {
1112 struct lnxgameControllercxx . . $ lnxgameController#::t_controllercxx . . $ lnxgameController#t_controller# *ctldev;
1113 float val = (float)0.0;
1114 float normalizer, axisval = 0, nullzone; //, senszone;
1115
1116 if (controller <= NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`! || controller >= CT_MAX_CONTROLLERScxx . . $ CT_MAX_CONTROLLERS.) {
1117 return 0.0f;
1118 }
1119
1120 ctldev = &m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller];
1121 if (ctldev->idcxx . . $ lnxgameController#t_controller#id. == CTID_INVALIDcxx . . $ CTID_INVALID.) {
1122 return 0.0f;
1123 }
1124
1125 #ifdef _DEBUGcxx . . $ `<built-in>:479:9`!
1126 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id. == CTID_KEYBOARDcxx . . $ CTID_KEYBOARD.) {
1127 Int3cxx . . $ `misc/pserror.h:247:9`!();
1128 return 0.0f;
1129 }
1130 #endif
1131
1132 // verify controller axis
1133 if (!CHECK_FLAGcxx . . $ `lib/Macros.h:63:9`!(ctldev->flags, 1 << (axis - 1))) {
1134 return val;
1135 }
1136
1137 // get raw value
1138 switch (axis) {
1139 // note we take care of mouse controls and external controls here
1140 case CT_X_AXIScxx . . $ CT_X_AXIS.:
1141 axisval = (float)((ctldev->idcxx . . $ lnxgameController#t_controller#id. == CTID_MOUSEcxx . . $ CTID_MOUSE.) ? m_MseStatecxx . . $ lnxgameController#m_MseState..xcxx . . $ lnxgameController#t_msestate#x. : m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[ctldev->idcxx . . $ lnxgameController#t_controller#id.].xcxx . . $ lnxgameController#t_extctlstate#x.);
1142 break;
1143 case CT_Y_AXIScxx . . $ CT_Y_AXIS.:
1144 axisval = (float)((ctldev->idcxx . . $ lnxgameController#t_controller#id. == CTID_MOUSEcxx . . $ CTID_MOUSE.) ? m_MseStatecxx . . $ lnxgameController#m_MseState..ycxx . . $ lnxgameController#t_msestate#y. : m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[ctldev->idcxx . . $ lnxgameController#t_controller#id.].ycxx . . $ lnxgameController#t_extctlstate#y.);
1145 break;
1146 case CT_Z_AXIScxx . . $ CT_Z_AXIS.:
1147 axisval = (float)((ctldev->idcxx . . $ lnxgameController#t_controller#id. == CTID_MOUSEcxx . . $ CTID_MOUSE.) ? m_MseStatecxx . . $ lnxgameController#m_MseState..zcxx . . $ lnxgameController#t_msestate#z. : m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[ctldev->idcxx . . $ lnxgameController#t_controller#id.].zcxx . . $ lnxgameController#t_extctlstate#z.);
1148 break;
1149 case CT_R_AXIScxx . . $ CT_R_AXIS.:
1150 axisval = (float)m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[ctldev->idcxx . . $ lnxgameController#t_controller#id.].rcxx . . $ lnxgameController#t_extctlstate#r.;
1151 break;
1152 case CT_U_AXIScxx . . $ CT_U_AXIS.:
1153 axisval = (float)m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[ctldev->idcxx . . $ lnxgameController#t_controller#id.].ucxx . . $ lnxgameController#t_extctlstate#u.;
1154 break;
1155 case CT_V_AXIScxx . . $ CT_V_AXIS.:
1156 axisval = (float)m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[ctldev->idcxx . . $ lnxgameController#t_controller#id.].vcxx . . $ lnxgameController#t_extctlstate#v.;
1157 break;
1158 default:
1159 Int3cxx . . $ `misc/pserror.h:247:9`!(); // NOT A VALID AXIS
1160 }
1161
1162 // create normalizer
1163 axis--;
1164 if (ctldev->idcxx . . $ lnxgameController#t_controller#id. == CTID_MOUSEcxx . . $ CTID_MOUSE.) {
1165 if (m_frame_timecxx . . $ lnxgameController#m_frame_time. < 0.005f)
1166 m_frame_timecxx . . $ lnxgameController#m_frame_time. = 0.005f; // to trap potential errors.
1167 normalizer = ctldev->normalizercxx . . $ lnxgameController#t_controller#normalizer.[axis] * m_frame_timecxx . . $ lnxgameController#m_frame_time.;
1168 nullzone = MOUSE_DEADZONEcxx . . $ `linux/lnxcontroller.cpp:62:9`!;
1169 if (axis == CT_X_AXIScxx . . $ CT_X_AXIS.) {
1170 // mprintf_at(4, 4, 0, "m_dX:%03d normal:%03.2f", (int)axisval, normalizer);
1171 }
1172
1173 } else {
1174 normalizer = ctldev->normalizercxx . . $ lnxgameController#t_controller#normalizer.[axis];
1175 nullzone = (m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].deadzonecxx . . $ lnxgameController#t_controller#deadzone. < 0.05f) ? 0.05f : m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].deadzonecxx . . $ lnxgameController#t_controller#deadzone.;
1176 }
1177
1178 val = axisval / normalizer;
1179 val = val - ((ctldev->idcxx . . $ lnxgameController#t_controller#id. == CTID_MOUSEcxx . . $ CTID_MOUSE.) ? 0.0f : 1.0f); // joystick needs to be normalized to -1.0 to 1.0
1180
1181 // calculate adjusted value
1182 if (val > nullzone) {
1183 val = (val - nullzone) / (1.0f - nullzone);
1184 } else if (val < -nullzone) {
1185 val = (val + nullzone) / (1.0f - nullzone);
1186 } else {
1187 val = 0.0f;
1188 }
1189 val = ctldev->sensmodcxx . . $ lnxgameController#t_controller#sensmod.[axis] * ctldev->senscxx . . $ lnxgameController#t_controller#sens.[axis] * val;
1190 val = val + 1.0f;
1191
1192 if (val < 0.0f)
1193 val = 0.0f;
1194 if (val > 2.0f)
1195 val = 2.0f;
1196
1197 // determine value based off requested format.
1198 if (format == ctDigitalcxx . . $ ctDigital.) {
1199 if (val < 0.5)
1200 val = (float)0.0;
1201 else
1202 val = (float)1.0;
1203 } else if (format == ctAnalogcxx . . $ ctAnalog.) {
1204 val = val - (float)1.0;
1205 } else {
1206 val = (float)0.0;
1207 mprintfcxx . . $ `ddebug/mono.h:82:9`!(1, "gameController::axis unsupported format for function.\n");
1208 }
1209
1210 ct_packetcxx . . $ ct_packet# key_slide1, key_bank;
1211
1212 get_packetcxx . . $ lnxgameController#get_packet(c1da47aee99b4b74).(ctfTOGGLE_SLIDEKEYcxx . . $ ctfTOGGLE_SLIDEKEY., &key_slide1);
1213 get_packetcxx . . $ lnxgameController#get_packet(c1da47aee99b4b74).(ctfTOGGLE_BANKKEYcxx . . $ ctfTOGGLE_BANKKEY., &key_bank);
1214
1215 if (key_slide1.valuecxx . . $ ct_packet#value. || key_bank.valuecxx . . $ ct_packet#value.) {
1216 // Don't do mouse look if either toggle is happening
1217 return val;
1218 }
1219 if ((Current_pilotcxx . . $ Current_pilot..mouselook_controlcxx . . $ pilot#mouselook_control.) && (GAME_MODEcxx . . $ GAME_MODE. == GetFunctionModecxx . . $ GetFunctionMode(4270339a2fa9f0f5).())) {
1220 // Don't do mouselook controls if they aren't enabled in multiplayer
1221 if ((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && (!(Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_ALLOW_MLOOKcxx . . $ `Descent3/multi_external.h:242:9`!)))
1222 return val;
1223
1224 // Account for guided missile control
1225 if (Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].guided_objcxx . . $ player#guided_obj.)
1226 return val;
1227 axis++;
1228
1229 if ((axis == CT_X_AXIScxx . . $ CT_X_AXIS.) && (ctldev->idcxx . . $ lnxgameController#t_controller#id. == CTID_MOUSEcxx . . $ CTID_MOUSE.) && (val != 0.0f)) {
1230 matrixcxx . . $ matrix# orient;
1231
1232 if (!(Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].controller_bitflagscxx . . $ player#controller_bitflags. & PCBF_HEADINGLEFTcxx . . $ `Descent3/player_external.h:120:9`!)) {
1233 if (val < 0)
1234 val = 0.0f;
1235 }
1236 if (!(Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].controller_bitflagscxx . . $ player#controller_bitflags. & PCBF_HEADINGRIGHTcxx . . $ `Descent3/player_external.h:121:9`!)) {
1237 if (val > 0)
1238 val = 0.0f;
1239 }
1240
1241 if (invert)
1242 val = -val;
1243
1244 vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&orient, 0.0, val * (((float)(65535.0f / 20)) * .5), 0.0);
1245
1246 Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.].orientcxx . . $ object#orient. =cxx . . $ matrix#`operator=`(e859ffc26b91394f). Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.].orientcxx . . $ object#orient. *cxx . . $ `operator*`(683f8e040c904cb). orient;
1247
1248 vm_Orthogonalizecxx . . $ vm_Orthogonalize(dca75c48c9ab5b54).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.].orientcxx . . $ object#orient.);
1249 ObjSetOrientcxx . . $ ObjSetOrient(e1367e0f901c991f).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], &Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.].orientcxx . . $ object#orient.);
1250 return 0;
1251 }
1252 if ((axis == CT_Y_AXIScxx . . $ CT_Y_AXIS.) && (ctldev->idcxx . . $ lnxgameController#t_controller#id. == CTID_MOUSEcxx . . $ CTID_MOUSE.) && (val != 0.0f)) {
1253 matrixcxx . . $ matrix# orient;
1254
1255 if (!(Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].controller_bitflagscxx . . $ player#controller_bitflags. & PCBF_PITCHUPcxx . . $ `Descent3/player_external.h:118:9`!)) {
1256 if (val < 0)
1257 val = 0.0f;
1258 }
1259 if (!(Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].controller_bitflagscxx . . $ player#controller_bitflags. & PCBF_PITCHDOWNcxx . . $ `Descent3/player_external.h:119:9`!)) {
1260 if (val > 0)
1261 val = 0.0f;
1262 }
1263
1264 if (invert)
1265 val = -val;
1266
1267 vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&orient, val * (((float)(65535.0f / 20)) * .5), 0.0, 0.0);
1268
1269 Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.].orientcxx . . $ object#orient. =cxx . . $ matrix#`operator=`(e859ffc26b91394f). Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.].orientcxx . . $ object#orient. *cxx . . $ `operator*`(683f8e040c904cb). orient;
1270
1271 vm_Orthogonalizecxx . . $ vm_Orthogonalize(dca75c48c9ab5b54).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.].orientcxx . . $ object#orient.);
1272 ObjSetOrientcxx . . $ ObjSetOrient(e1367e0f901c991f).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], &Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.].orientcxx . . $ object#orient.);
1273 return 0;
1274 }
1275 }
1276
1277 return val;
1278 }
1279
1280 // do some pov stuff
1281 float lnxgameControllercxx . . $ lnxgameController#::get_pov_valuecxx . . $ lnxgameController#get_pov_value(c199c3612abc2a26).(int8_tcxx . . $ int8_t# controller, ct_formatcxx . . $ ct_format# format, uint8_tcxx . . $ uint8_t# pov_number, uint8_tcxx . . $ uint8_t# pov) {
1282 float val = (float)0.0;
1283
1284 if (controller <= NULL_LNXCONTROLLERcxx . . $ `linux/lnxcontroller.h:25:9`! || controller >= CT_MAX_CONTROLLERScxx . . $ CT_MAX_CONTROLLERS.) {
1285 return val;
1286 }
1287 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id. == CTID_INVALIDcxx . . $ CTID_INVALID.) {
1288 return val;
1289 }
1290 #ifdef _DEBUGcxx . . $ `<built-in>:479:9`!
1291 if (m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id. == CTID_KEYBOARDcxx . . $ CTID_KEYBOARD.) {
1292 Int3cxx . . $ `misc/pserror.h:247:9`!();
1293 return 0.0f;
1294 }
1295 #endif
1296 if (!(m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].flagscxx . . $ lnxgameController#t_controller#flags. & (CTF_POVcxx . . $ CTF_POV. << pov_number))) {
1297 return val;
1298 }
1299
1300 int pov_index = pov / (JOYPOV_MAXVALcxx . . $ `lib/joystick.h:88:9`! / JOYPOV_DIRcxx . . $ `lib/joystick.h:87:9`!);
1301 int cur_pov_index = m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].povcxx . . $ lnxgameController#t_extctlstate#pov.[pov_number] / (JOYPOV_MAXVALcxx . . $ `lib/joystick.h:88:9`! / JOYPOV_DIRcxx . . $ `lib/joystick.h:87:9`!);
1302
1303 switch (format) {
1304 // note we take care of mouse controls and external controls here
1305 case ctDownCountcxx . . $ ctDownCount.:
1306 if (pov_index == JOYPOV_DIRcxx . . $ `lib/joystick.h:87:9`!)
1307 val = 0.0f;
1308 else {
1309 val = m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].povpressescxx . . $ lnxgameController#t_extctlstate#povpresses.[pov_number][pov_index];
1310 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].povpressescxx . . $ lnxgameController#t_extctlstate#povpresses.[pov_number][pov_index] = 0;
1311 }
1312 break;
1313
1314 case ctDigitalcxx . . $ ctDigital.: {
1315 if (m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].povcxx . . $ lnxgameController#t_extctlstate#pov.[pov_number] == JOYPOV_CENTERcxx . . $ `lib/joystick.h:93:9`!)
1316 val = 0.0f;
1317 else if ((cur_pov_index == 0 || cur_pov_index == 1 || cur_pov_index == 7) && (pov == JOYPOV_UPcxx . . $ `lib/joystick.h:89:9`!))
1318 val = 1.0f;
1319 else if ((cur_pov_index == 1 || cur_pov_index == 2 || cur_pov_index == 3) && (pov == JOYPOV_RIGHTcxx . . $ `lib/joystick.h:90:9`!))
1320 val = 1.0f;
1321 else if ((cur_pov_index == 3 || cur_pov_index == 4 || cur_pov_index == 5) && (pov == JOYPOV_DOWNcxx . . $ `lib/joystick.h:91:9`!))
1322 val = 1.0f;
1323 else if ((cur_pov_index == 5 || cur_pov_index == 6 || cur_pov_index == 7) && (pov == JOYPOV_LEFTcxx . . $ `lib/joystick.h:92:9`!))
1324 val = 1.0f;
1325 break;
1326 }
1327
1328 case ctTimecxx . . $ ctTime.:
1329 if (cur_pov_index == pov_index) {
1330 val = WinControllerTimercxx . . $ WinControllerTimer. - m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].povstartscxx . . $ lnxgameController#t_extctlstate#povstarts.[pov_number][pov_index];
1331 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].povstartscxx . . $ lnxgameController#t_extctlstate#povstarts.[pov_number][pov_index] = WinControllerTimercxx . . $ WinControllerTimer.;
1332 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].povtimescxx . . $ lnxgameController#t_extctlstate#povtimes.[pov_number][pov_index] = 0.0f;
1333 } else {
1334 val = m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].povtimescxx . . $ lnxgameController#t_extctlstate#povtimes.[pov_number][pov_index];
1335 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].povstartscxx . . $ lnxgameController#t_extctlstate#povstarts.[pov_number][pov_index] = 0.0f;
1336 m_ExtCtlStatescxx . . $ lnxgameController#m_ExtCtlStates.[m_ControlListcxx . . $ lnxgameController#m_ControlList.[controller].idcxx . . $ lnxgameController#t_controller#id.].povtimescxx . . $ lnxgameController#t_extctlstate#povtimes.[pov_number][pov_index] = 0.0f;
1337 }
1338 break;
1339
1340 default:
1341 mprintfcxx . . $ `ddebug/mono.h:82:9`!(1, "gameController::pov unsupported format for function\n");
1342 }
1343
1344 return val;
1345 }
1346
1347 // get keyboard info
1348 float lnxgameControllercxx . . $ lnxgameController#::get_key_valuecxx . . $ lnxgameController#get_key_value(5d9504f2bec60a96).(int key, ct_formatcxx . . $ ct_format# format) {
1349 float val = (float)0.0;
1350
1351 ASSERTcxx . . $ `misc/pserror.h:246:9`!(key < DDIO_MAX_KEYScxx . . $ `ddio/ddio_common.h:205:9`!);
1352
1353 switch (format) {
1354 // note we take care of mouse controls and external controls here
1355 case ctDigitalcxx . . $ ctDigital.:
1356 if (KEY_STATEcxx . . $ `ddio/ddio_common.h:204:9`!(key))
1357 val = 1.0f;
1358 break;
1359
1360 case ctDownCountcxx . . $ ctDownCount.:
1361 val = (float)ddio_KeyDownCountcxx . . $ ddio_KeyDownCount(7864480464b09eea).(key);
1362 break;
1363
1364 case ctTimecxx . . $ ctTime.:
1365 val = (float)ddio_KeyDownTimecxx . . $ ddio_KeyDownTime(5cde91ea12d43f46).(key);
1366 break;
1367
1368 default:
1369 mprintfcxx . . $ `ddebug/mono.h:82:9`!(1, "gameController::key unsupported format for function\n");
1370 }
1371
1372 return val;
1373 }
1374
1375 // CTL file parser
1376 #define N_CTLCMDScxx . . $ `linux/lnxcontroller.cpp:1376:9`! 9
1377 #define CTLCMD_NAMEcxx . . $ `linux/lnxcontroller.cpp:1377:9`! 0
1378 #define CTLCMD_AXIScxx . . $ `linux/lnxcontroller.cpp:1378:9`! 1
1379 #define CTLCMD_DEADcxx . . $ `linux/lnxcontroller.cpp:1379:9`! 2
1380 #define CTLCMD_SXcxx . . $ `linux/lnxcontroller.cpp:1380:9`! 3
1381 #define CTLCMD_SYcxx . . $ `linux/lnxcontroller.cpp:1381:9`! 4
1382 #define CTLCMD_SZcxx . . $ `linux/lnxcontroller.cpp:1382:9`! 5
1383 #define CTLCMD_SRcxx . . $ `linux/lnxcontroller.cpp:1383:9`! 6
1384 #define CTLCMD_SUcxx . . $ `linux/lnxcontroller.cpp:1384:9`! 7
1385 #define CTLCMD_SVcxx . . $ `linux/lnxcontroller.cpp:1385:9`! 8
1386
1387 const char *CTLCommandscxx . . $ CTLCommands.[N_CTLCMDScxx . . $ `linux/lnxcontroller.cpp:1376:9`!] = {"name", "axis", "deadzone", "sensmodx", "sensmody",
1388 "sensmodz", "sensmodr", "sensmodu", "sensmodv"};
1389
1390 int CTLLexcxx . . $ CTLLex(5c4306d8553b3696).(const char *command) {
1391 int i;
1392 for (i = 0; i < N_CTLCMDScxx . . $ `linux/lnxcontroller.cpp:1376:9`!; i++) {
1393 if (strcmp(CTLCommandscxx . . $ CTLCommands.[i], command) == 0)
1394 return i;
1395 }
1396
1397 return INFFILE_ERRORcxx . . $ INFFILE_ERROR.;
1398 }
1399
1400 // okay, now search for a '****.ctl' file in the current directory.
1401 void lnxgameControllercxx . . $ lnxgameController#::parse_ctl_filecxx . . $ lnxgameController#parse_ctl_file(66835f578de1bcb3).(int devnum, const char *ctlname) {
1402 // parse each file until we find a name match, no name match, just return
1403 char filename[_MAX_FNAMEcxx . . $ `linux/linux_fix.h:35:9`!];
1404 int i;
1405
1406 if (ddio_FindFileStartcxx . . $ ddio_FindFileStart(84e74a5521f49206).("*.ctl", filename)) {
1407 do {
1408 InfFilecxx . . $ InfFile# filecxx . . $ InfFile#InfFile(49f6e7a06ebc5aa8).;
1409 bool found_name = false;
1410
1411 if (file.Opencxx . . $ InfFile#Open(a6c18f6c547e5631).(filename, "[controller settings]", CTLLexcxx . . $ CTLLex(5c4306d8553b3696).)) {
1412 // parse each line, setting the appropriate values, etc.
1413 while (file.ReadLinecxx . . $ InfFile#ReadLine(c9857a73d68e59ba).()) {
1414 int cmd;
1415 char operand[128];
1416
1417 while ((cmd = file.ParseLinecxx . . $ InfFile#ParseLine(6abd07ddb1a912f0).(operand, INFFILE_LINELENcxx . . $ INFFILE_LINELEN.)) > INFFILE_ERRORcxx . . $ INFFILE_ERROR.) {
1418 // we want to assert that the name command comes before any other to verify
1419 // this is the file we really want to change.
1420 switch (cmd) {
1421 case CTLCMD_NAMEcxx . . $ `linux/lnxcontroller.cpp:1377:9`!:
1422 if (strcmp(ctlname, operand) != 0)
1423 goto cancel_file_parse;
1424 found_name = true;
1425 break;
1426
1427 case CTLCMD_DEADcxx . . $ `linux/lnxcontroller.cpp:1379:9`!: // deadzone
1428 if (!found_name)
1429 goto cancel_file_parse;
1430 else {
1431 m_ControlListcxx . . $ lnxgameController#m_ControlList.[devnum].deadzonecxx . . $ lnxgameController#t_controller#deadzone. = atof(operand);
1432 }
1433 break;
1434
1435 case CTLCMD_AXIScxx . . $ `linux/lnxcontroller.cpp:1378:9`!: // allowable axis.
1436 // format of command is "+Z-R"
1437 // this would add a Z axis to the controller. -R would remove the Rudder.
1438 // you can do this for X,Y,Z,R,U,V.
1439 if (!found_name)
1440 goto cancel_file_parse;
1441 else {
1442 int slen = strlen(operand);
1443 for (i = 0; i <= slen; i += 2) {
1444 int axis_flag;
1445 if ((i + 1) <= slen) {
1446 char axis_cmd = tolower(operand[i + 1]);
1447 if (axis_cmd == 'x')
1448 axis_flag = CTF_X_AXIScxx . . $ CTF_X_AXIS.;
1449 else if (axis_cmd == 'y')
1450 axis_flag = CTF_Y_AXIScxx . . $ CTF_Y_AXIS.;
1451 else if (axis_cmd == 'z')
1452 axis_flag = CTF_Z_AXIScxx . . $ CTF_Z_AXIS.;
1453 else if (axis_cmd == 'r')
1454 axis_flag = CTF_R_AXIScxx . . $ CTF_R_AXIS.;
1455 else if (axis_cmd == 'u')
1456 axis_flag = CTF_U_AXIScxx . . $ CTF_U_AXIS.;
1457 else if (axis_cmd == 'v')
1458 axis_flag = CTF_V_AXIScxx . . $ CTF_V_AXIS.;
1459 else
1460 axis_flag = 0;
1461 if (operand[i] == '+') {
1462 m_ControlListcxx . . $ lnxgameController#m_ControlList.[devnum].flagscxx . . $ lnxgameController#t_controller#flags. |= axis_flag;
1463 } else if (operand[i] == '-') {
1464 m_ControlListcxx . . $ lnxgameController#m_ControlList.[devnum].flagscxx . . $ lnxgameController#t_controller#flags. &= (~axis_flag);
1465 } else {
1466 goto cancel_file_parse;
1467 }
1468 } else {
1469 break; // this should break out of the axis search but continue with the file
1470 }
1471 }
1472 }
1473 break;
1474
1475 case CTLCMD_SXcxx . . $ `linux/lnxcontroller.cpp:1380:9`!: // allow modification of global sensitivity modifiers
1476 case CTLCMD_SYcxx . . $ `linux/lnxcontroller.cpp:1381:9`!:
1477 case CTLCMD_SZcxx . . $ `linux/lnxcontroller.cpp:1382:9`!:
1478 case CTLCMD_SRcxx . . $ `linux/lnxcontroller.cpp:1383:9`!:
1479 case CTLCMD_SUcxx . . $ `linux/lnxcontroller.cpp:1384:9`!:
1480 case CTLCMD_SVcxx . . $ `linux/lnxcontroller.cpp:1385:9`!: {
1481 int idx = (cmd - CTLCMD_SXcxx . . $ `linux/lnxcontroller.cpp:1380:9`!);
1482 m_ControlListcxx . . $ lnxgameController#m_ControlList.[devnum].sensmodcxx . . $ lnxgameController#t_controller#sensmod.[idx] = atof(operand);
1483 break;
1484 }
1485 }
1486 }
1487 }
1488 cancel_file_parse:
1489 file.Closecxx . . $ InfFile#Close(49f6e7a06ebc5aa8).();
1490 }
1491 } while (ddio_FindNextFilecxx . . $ ddio_FindNextFile(c6b7e35ff6de5671).(filename));
1492 ddio_FindFileClosecxx . . $ ddio_FindFileClose(49f6e7a06ebc5aa8).();
1493 }
1494 }