JOYDEFS.C 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/main/rcs/joydefs.c $
  15. * $Revision: 2.2 $
  16. * $Author: john $
  17. * $Date: 1995/06/30 12:30:22 $
  18. *
  19. * .
  20. *
  21. * $Log: joydefs.c $
  22. * Revision 2.2 1995/06/30 12:30:22 john
  23. * Added -Xname command line.
  24. *
  25. * Revision 2.1 1995/04/06 12:13:20 john
  26. * Made so you can calibrate Gravis Gamepad.
  27. *
  28. * Revision 2.0 1995/02/27 11:30:27 john
  29. * New version 2.0, which has no anonymous unions, builds with
  30. * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  31. *
  32. * Revision 1.71 1995/02/12 02:06:10 john
  33. * Fixed bug with joystick incorrectly asking for
  34. * calibration.
  35. *
  36. * Revision 1.70 1995/01/28 15:58:07 john
  37. * Made joystick calibration be only when wrong detected in
  38. * menu or joystick axis changed.
  39. *
  40. * Revision 1.69 1995/01/25 14:37:55 john
  41. * Made joystick only prompt for calibration once...
  42. *
  43. * Revision 1.68 1995/01/24 16:34:29 john
  44. * Made so that if you reconfigure joystick and
  45. * add or subtract an axis, it asks for a recalibration
  46. * upon leaving.
  47. *
  48. * Revision 1.67 1994/12/29 11:08:51 john
  49. * Fixed Thrustmaster and Logitech Wingman extreme
  50. * Hat by reading the y2 axis during the center stage
  51. * of the calibration, and using 75, 50, 27, and 3 %
  52. * as values for the 4 positions.
  53. *
  54. * Revision 1.66 1994/12/15 18:17:39 john
  55. * Fixed warning with previous.
  56. *
  57. * Revision 1.65 1994/12/15 18:15:48 john
  58. * Made the joy cal only write the .cfg file, not
  59. * the player file.
  60. *
  61. * Revision 1.64 1994/12/13 14:43:35 john
  62. * Took out the code in kconfig to build direction array.
  63. * Called kc_set_controls after selecting a new control type.
  64. *
  65. * Revision 1.63 1994/12/10 12:08:47 john
  66. * Changed some delays to use TICKER instead of timer_get_fixed_seconds.
  67. *
  68. * Revision 1.62 1994/12/09 11:01:07 mike
  69. * force calibration of joystick on joystick selection from Controls... menu.
  70. *
  71. * Revision 1.61 1994/12/07 21:50:27 john
  72. * Put stop/start time around joystick delay.
  73. *
  74. * Revision 1.60 1994/12/07 19:34:39 john
  75. * Added delay.
  76. *
  77. * Revision 1.59 1994/12/07 18:12:14 john
  78. * NEatened up joy cal.,
  79. *
  80. * Revision 1.58 1994/12/07 17:07:51 john
  81. * Fixed up joy cal.
  82. *
  83. * Revision 1.57 1994/12/07 16:48:53 yuan
  84. * localization
  85. *
  86. * Revision 1.56 1994/12/07 16:05:55 john
  87. * Changed the way joystick calibration works.
  88. *
  89. * Revision 1.55 1994/12/06 20:15:22 john
  90. * Took out code that unpauses songs that were never paused.
  91. *
  92. * Revision 1.54 1994/12/06 15:14:09 yuan
  93. * Localization
  94. *
  95. * Revision 1.53 1994/12/05 16:29:16 john
  96. * Took out music pause around the cheat menu.
  97. *
  98. * Revision 1.52 1994/12/04 12:39:10 john
  99. * MAde so that FCS calibration doesn't ask for axis #2.
  100. *
  101. * Revision 1.51 1994/12/03 15:14:59 john
  102. * Took out the delay mentioned previosuly cause it would
  103. * cause bigger problems than it helps, especially with netgames.
  104. *
  105. * Revision 1.50 1994/12/03 14:16:14 john
  106. * Put a delay between screens in joy cal to keep Yuan from
  107. * double hitting.
  108. *
  109. * Revision 1.49 1994/12/03 11:04:06 john
  110. * Changed newmenu code a bit to fix bug with bogus
  111. * backgrounds occcasionally.
  112. *
  113. * Revision 1.48 1994/12/02 11:03:44 yuan
  114. * Localization.
  115. *
  116. * Revision 1.47 1994/12/02 10:50:33 yuan
  117. * Localization
  118. *
  119. * Revision 1.46 1994/12/01 12:21:59 john
  120. * Added code to calibrate 2 joysticks separately.
  121. *
  122. * Revision 1.45 1994/12/01 11:52:31 john
  123. * Added message when you select FCS to say that if
  124. * you have WCS, see manuel.
  125. *
  126. * Revision 1.44 1994/11/29 02:26:28 john
  127. * Made the prompts for upper-left, lower right for joy
  128. * calibration more obvious.
  129. *
  130. * Revision 1.43 1994/11/26 13:13:59 matt
  131. * Changed "none" option to "keyboard only"
  132. *
  133. * Revision 1.42 1994/11/21 19:35:13 john
  134. * Replaced calls to joy_init with if (joy_present)
  135. *
  136. * Revision 1.41 1994/11/21 19:28:34 john
  137. * Changed warning for no joystick to use nm_messagebox..
  138. *
  139. * Revision 1.40 1994/11/21 19:06:25 john
  140. * Made it so that it only stops sound when your in game mode.
  141. *
  142. * Revision 1.39 1994/11/21 11:47:18 john
  143. * Made sound pause during joystick calibration.
  144. *
  145. * Revision 1.38 1994/11/10 20:34:18 rob
  146. * Removed menu-specific network mode support in favor in new stuff
  147. * in newmenu.c
  148. *
  149. * Revision 1.37 1994/11/08 21:21:38 john
  150. * Made Esc exit joystick calibration.
  151. *
  152. * Revision 1.36 1994/11/08 15:14:42 john
  153. * Added more calls so net doesn't die in net game.
  154. *
  155. * Revision 1.35 1994/11/08 14:59:12 john
  156. * Added code to respond to network while in menus.
  157. *
  158. * Revision 1.34 1994/10/24 19:56:32 john
  159. * Made the new user setup prompt for config options.
  160. *
  161. * Revision 1.33 1994/10/22 14:11:52 mike
  162. * Suppress compiler warning message.
  163. *
  164. * Revision 1.32 1994/10/19 12:44:24 john
  165. * Added hours field to player structure.
  166. *
  167. * Revision 1.31 1994/10/17 13:07:13 john
  168. * Moved the descent.cfg info into the player config file.
  169. *
  170. * Revision 1.30 1994/10/13 21:41:12 john
  171. * MAde Esc exit out of joystick calibration.
  172. *
  173. * Revision 1.29 1994/10/13 19:22:27 john
  174. * Added separate config saves for different devices.
  175. * Made all the devices work together better, such as mice won't
  176. * get read when you're playing with the joystick.
  177. *
  178. * Revision 1.28 1994/10/13 11:40:18 john
  179. * Took out warnings.
  180. *
  181. * Revision 1.27 1994/10/13 11:35:23 john
  182. * Made Thrustmaster FCS Hat work. Put a background behind the
  183. * keyboard configure. Took out turn_sensitivity. Changed sound/config
  184. * menu to new menu. Made F6 be calibrate joystick.
  185. *
  186. * Revision 1.26 1994/10/11 21:29:03 matt
  187. * Made a bunch of menus have good initial selected values
  188. *
  189. * Revision 1.25 1994/10/11 17:08:39 john
  190. * Added sliders for volume controls.
  191. *
  192. * Revision 1.24 1994/10/10 17:59:21 john
  193. * Neatend previous.
  194. *
  195. * Revision 1.23 1994/10/10 17:57:59 john
  196. * Neatend previous.
  197. *
  198. * Revision 1.22 1994/10/10 17:56:11 john
  199. * Added messagebox that tells that config has been saved.
  200. *
  201. * Revision 1.21 1994/09/30 12:37:26 john
  202. * Added midi,digi volume to configuration.
  203. *
  204. * Revision 1.20 1994/09/22 16:14:14 john
  205. * Redid intro sequecing.
  206. *
  207. * Revision 1.19 1994/09/19 18:50:15 john
  208. * Added switch to disable joystick.
  209. *
  210. * Revision 1.18 1994/09/12 11:47:36 john
  211. * Made stupid cruise work better. Make kconfig values get
  212. * read/written to disk.
  213. *
  214. * Revision 1.17 1994/09/10 15:46:47 john
  215. * First version of new keyboard configuration.
  216. *
  217. * Revision 1.16 1994/09/06 19:35:44 john
  218. * Fixed bug that didn';t load new size .cal file.
  219. *
  220. * Revision 1.15 1994/09/06 14:51:58 john
  221. * Added sensitivity adjustment, fixed bug with joystick button not
  222. * staying down.
  223. *
  224. * Revision 1.14 1994/09/02 16:13:47 john
  225. * Made keys fill in position.
  226. *
  227. * Revision 1.13 1994/08/31 17:58:50 john
  228. * Made a bit simpler.
  229. *
  230. * Revision 1.12 1994/08/31 14:17:54 john
  231. * *** empty log message ***
  232. *
  233. * Revision 1.11 1994/08/31 14:10:56 john
  234. * Made keys not work when KEY_DELETE pressed.
  235. *
  236. * Revision 1.10 1994/08/31 13:40:47 mike
  237. * Change constant
  238. *
  239. * Revision 1.9 1994/08/31 12:56:27 john
  240. * *** empty log message ***
  241. *
  242. * Revision 1.8 1994/08/30 20:38:29 john
  243. * Add more config stuff..
  244. *
  245. * Revision 1.7 1994/08/30 16:37:25 john
  246. * Added menu options to set controls.
  247. *
  248. * Revision 1.6 1994/08/30 09:27:18 john
  249. * *** empty log message ***
  250. *
  251. * Revision 1.5 1994/08/30 09:12:01 john
  252. * *** empty log message ***
  253. *
  254. * Revision 1.4 1994/08/29 21:18:32 john
  255. * First version of new keyboard/oystick remapping stuff.
  256. *
  257. * Revision 1.3 1994/08/24 19:00:29 john
  258. * Changed key_down_time to return fixed seconds instead of
  259. * milliseconds.
  260. *
  261. * Revision 1.2 1994/08/17 16:50:37 john
  262. * Added damaging fireballs, missiles.
  263. *
  264. * Revision 1.1 1994/08/17 10:07:12 john
  265. * Initial revision
  266. *
  267. *
  268. */
  269. #pragma off (unreferenced)
  270. static char rcsid[] = "$Id: joydefs.c 2.2 1995/06/30 12:30:22 john Exp $";
  271. #pragma on (unreferenced)
  272. #include <conio.h>
  273. #include <stdlib.h>
  274. #include <stdio.h>
  275. #include <io.h>
  276. #include <string.h>
  277. #include <dos.h>
  278. #include "mono.h"
  279. #include "key.h"
  280. #include "joy.h"
  281. #include "timer.h"
  282. #include "error.h"
  283. #include "inferno.h"
  284. #include "game.h"
  285. #include "object.h"
  286. #include "player.h"
  287. #include "controls.h"
  288. #include "joydefs.h"
  289. #include "victor.h"
  290. #include "render.h"
  291. #include "palette.h"
  292. #include "newmenu.h"
  293. #include "args.h"
  294. #include "text.h"
  295. #include "kconfig.h"
  296. #include "digi.h"
  297. #include "playsave.h"
  298. int joydefs_calibrate_flag = 0;
  299. void joy_delay()
  300. {
  301. int t1 = TICKER + 19/4; // Wait 1/4 second...
  302. stop_time();
  303. while( TICKER < t1 );
  304. joy_flush();
  305. start_time();
  306. }
  307. int joycal_message( char * title, char * text )
  308. {
  309. int i;
  310. newmenu_item m[2];
  311. m[0].type = NM_TYPE_TEXT; m[0].text = text;
  312. m[1].type = NM_TYPE_MENU; m[1].text = TXT_OK;
  313. i = newmenu_do( title, NULL, 2, m, NULL );
  314. if ( i < 0 )
  315. return 1;
  316. return 0;
  317. }
  318. extern int WriteConfigFile();
  319. void joydefs_calibrate()
  320. {
  321. ubyte masks;
  322. int org_axis_min[4];
  323. int org_axis_center[4];
  324. int org_axis_max[4];
  325. int axis_min[4] = { 0, 0, 0, 0 };
  326. int axis_cen[4] = { 0, 0, 0, 0 };
  327. int axis_max[4] = { 0, 0, 0, 0 };
  328. int temp_values[4];
  329. char title[50];
  330. char text[50];
  331. int nsticks = 0;
  332. joydefs_calibrate_flag = 0;
  333. if ( (Config_control_type!=CONTROL_JOYSTICK) && (Config_control_type!=CONTROL_FLIGHTSTICK_PRO) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) && (Config_control_type!=CONTROL_GRAVIS_GAMEPAD) )
  334. return;
  335. joy_get_cal_vals(org_axis_min, org_axis_center, org_axis_max);
  336. joy_set_cen();
  337. joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
  338. if (!joy_present) {
  339. nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK );
  340. return;
  341. }
  342. masks = joy_get_present_mask();
  343. if ( masks == JOY_ALL_AXIS )
  344. nsticks = 2;
  345. else
  346. nsticks = 1;
  347. if ( nsticks == 2 ) {
  348. sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
  349. sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
  350. } else {
  351. sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
  352. sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
  353. }
  354. if (joycal_message( title, text )) {
  355. joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
  356. return;
  357. }
  358. joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
  359. axis_min[0] = temp_values[0];
  360. axis_min[1] = temp_values[1];
  361. joy_delay();
  362. if ( nsticks == 2 ) {
  363. sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
  364. sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
  365. } else {
  366. sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
  367. sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
  368. }
  369. if (joycal_message( title, text)) {
  370. joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
  371. return;
  372. }
  373. joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
  374. axis_max[0] = temp_values[0];
  375. axis_max[1] = temp_values[1];
  376. joy_delay();
  377. if ( nsticks == 2 ) {
  378. sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_CENTER);
  379. sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
  380. } else {
  381. sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_CENTER);
  382. sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
  383. }
  384. if (joycal_message( title, text)) {
  385. joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
  386. return;
  387. }
  388. joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
  389. axis_cen[0] = temp_values[0];
  390. axis_cen[1] = temp_values[1];
  391. joy_delay();
  392. // The fcs uses axes 3 for hat, so don't calibrate it.
  393. if ( Config_control_type == CONTROL_THRUSTMASTER_FCS ) {
  394. axis_min[3] = 0;
  395. axis_cen[3] = temp_values[3]/2;
  396. axis_max[3] = temp_values[3];
  397. joy_delay();
  398. } else {
  399. masks = joy_get_present_mask();
  400. if ( nsticks == 2 ) {
  401. if ( kconfig_is_axes_used(2) || kconfig_is_axes_used(3) ) {
  402. sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
  403. sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
  404. if (joycal_message( title, text )) {
  405. joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
  406. return;
  407. }
  408. joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
  409. axis_min[2] = temp_values[2];
  410. axis_min[3] = temp_values[3];
  411. joy_delay();
  412. sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
  413. sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
  414. if (joycal_message( title, text )) {
  415. joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
  416. return;
  417. }
  418. joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
  419. axis_max[2] = temp_values[2];
  420. axis_max[3] = temp_values[3];
  421. joy_delay();
  422. sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_CENTER);
  423. sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
  424. if (joycal_message( title, text )) {
  425. joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
  426. return;
  427. }
  428. joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
  429. axis_cen[2] = temp_values[2];
  430. axis_cen[3] = temp_values[3];
  431. joy_delay();
  432. }
  433. } else if ( (!(masks & JOY_2_X_AXIS)) && (masks & JOY_2_Y_AXIS) ) {
  434. if ( kconfig_is_axes_used(3) ) {
  435. // A throttle axis!!!!!
  436. sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_FORWARD);
  437. if (joycal_message( title, TXT_MOVE_THROTTLE_F)) {
  438. joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
  439. return;
  440. }
  441. joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
  442. axis_min[3] = temp_values[3];
  443. joy_delay();
  444. sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_REVERSE);
  445. if (joycal_message( title, TXT_MOVE_THROTTLE_R)) {
  446. joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
  447. return;
  448. }
  449. joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
  450. axis_max[3] = temp_values[3];
  451. joy_delay();
  452. sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_CENTER);
  453. if (joycal_message( title, TXT_MOVE_THROTTLE_C)) {
  454. joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
  455. return;
  456. }
  457. joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
  458. axis_cen[3] = temp_values[3];
  459. joy_delay();
  460. }
  461. }
  462. }
  463. joy_set_cal_vals(axis_min, axis_cen, axis_max);
  464. WriteConfigFile();
  465. }
  466. //char *control_text[CONTROL_MAX_TYPES] = { "Keyboard only", "Joystick", "Flightstick Pro", "Thrustmaster FCS", "Gravis Gamepad", "Mouse", "Cyberman" };
  467. void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem )
  468. {
  469. int i;
  470. int oc_type = Config_control_type;
  471. nitems = nitems;
  472. last_key = last_key;
  473. citem = citem;
  474. for (i=0; i<CONTROL_MAX_TYPES; i++ )
  475. if (items[i].value) Config_control_type = i;
  476. if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) {
  477. nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
  478. }
  479. if (oc_type != Config_control_type) {
  480. switch (Config_control_type) {
  481. // case CONTROL_NONE:
  482. case CONTROL_JOYSTICK:
  483. case CONTROL_FLIGHTSTICK_PRO:
  484. case CONTROL_THRUSTMASTER_FCS:
  485. case CONTROL_GRAVIS_GAMEPAD:
  486. // case CONTROL_MOUSE:
  487. // case CONTROL_CYBERMAN:
  488. joydefs_calibrate_flag = 1;
  489. }
  490. kc_set_controls();
  491. }
  492. }
  493. extern ubyte kc_use_external_control;
  494. extern ubyte kc_enable_external_control;
  495. extern ubyte *kc_external_name;
  496. void joydefs_config()
  497. {
  498. char xtext[128];
  499. int i, old_masks, masks;
  500. newmenu_item m[13];
  501. int i1=9;
  502. int nitems;
  503. do {
  504. nitems = 10;
  505. m[0].type = NM_TYPE_RADIO; m[0].text = CONTROL_TEXT(0); m[0].value = 0; m[0].group = 0;
  506. m[1].type = NM_TYPE_RADIO; m[1].text = CONTROL_TEXT(1); m[1].value = 0; m[1].group = 0;
  507. m[2].type = NM_TYPE_RADIO; m[2].text = CONTROL_TEXT(2); m[2].value = 0; m[2].group = 0;
  508. m[3].type = NM_TYPE_RADIO; m[3].text = CONTROL_TEXT(3); m[3].value = 0; m[3].group = 0;
  509. m[4].type = NM_TYPE_RADIO; m[4].text = CONTROL_TEXT(4); m[4].value = 0; m[4].group = 0;
  510. m[5].type = NM_TYPE_RADIO; m[5].text = CONTROL_TEXT(5); m[5].value = 0; m[5].group = 0;
  511. m[6].type = NM_TYPE_RADIO; m[6].text = CONTROL_TEXT(6); m[6].value = 0; m[6].group = 0;
  512. m[7].type = NM_TYPE_MENU; m[7].text=TXT_CUST_ABOVE;
  513. m[8].type = NM_TYPE_TEXT; m[8].text="";
  514. m[9].type = NM_TYPE_MENU; m[9].text=TXT_CUST_KEYBOARD;
  515. if ( kc_use_external_control ) {
  516. sprintf( xtext, "Enable %s", kc_external_name );
  517. m[10].type = NM_TYPE_CHECK; m[10].text = xtext; m[10].value = kc_enable_external_control;
  518. nitems = nitems + 1;
  519. }
  520. m[Config_control_type].value = 1;
  521. i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 );
  522. switch(i1) {
  523. case 7: {
  524. old_masks = 0;
  525. for (i=0; i<4; i++ ) {
  526. if (kconfig_is_axes_used(i))
  527. old_masks |= (1<<i);
  528. }
  529. if ( Config_control_type==0 )
  530. // nothing...
  531. Config_control_type=0;
  532. else if ( Config_control_type<5 )
  533. kconfig(1, CONTROL_TEXT(Config_control_type) );
  534. else
  535. kconfig(2, CONTROL_TEXT(Config_control_type) );
  536. masks = 0;
  537. for (i=0; i<4; i++ ) {
  538. if (kconfig_is_axes_used(i))
  539. masks |= (1<<i);
  540. }
  541. switch (Config_control_type) {
  542. case CONTROL_JOYSTICK:
  543. case CONTROL_FLIGHTSTICK_PRO:
  544. case CONTROL_THRUSTMASTER_FCS:
  545. {
  546. for (i=0; i<4; i++ ) {
  547. if ( (masks&(1<<i)) && (!(old_masks&(1<<i))))
  548. joydefs_calibrate_flag = 1;
  549. }
  550. }
  551. break;
  552. }
  553. }
  554. break;
  555. case 9:
  556. kconfig(0, TXT_KEYBOARD);
  557. break;
  558. }
  559. if ( kc_use_external_control ) {
  560. kc_enable_external_control = m[10].value;
  561. }
  562. } while(i1>-1);
  563. switch (Config_control_type) {
  564. case CONTROL_JOYSTICK:
  565. case CONTROL_FLIGHTSTICK_PRO:
  566. case CONTROL_THRUSTMASTER_FCS:
  567. case CONTROL_GRAVIS_GAMEPAD:
  568. if ( joydefs_calibrate_flag )
  569. joydefs_calibrate();
  570. break;
  571. }
  572. }
  573.