]> icculus.org git repositories - btb/d2x.git/blob - arch/sdl/joydefs.c
begin refactoring to umbrella header
[btb/d2x.git] / arch / sdl / joydefs.c
1 /*
2  *
3  * SDL joystick support
4  *
5  *
6  */
7
8 #ifdef HAVE_CONFIG_H
9 #include <conf.h>
10 #endif
11
12 #include "joydefs.h"
13 #include "pstypes.h"
14 #include "newmenu.h"
15 #include "inferno.h"
16 #include "text.h"
17 #include "kconfig.h"
18
19 extern int num_joysticks;
20
21 int joydefs_calibrate_flag = 0;
22
23 void joydefs_calibrate()
24 {
25         joydefs_calibrate_flag = 0;
26
27         if (!num_joysticks) {
28                 nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK );
29                 return;
30         }
31
32         //Actual calibration if necessary
33
34 }
35
36 void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem )
37 {
38         int i;
39         int oc_type = Config_control_type.intval;
40
41         for (i=0; i<3; i++ )
42                 if (items[i].value)
43                         cvar_setint(&Config_control_type, i);
44
45         if (Config_control_type.intval == 2)
46                 cvar_setint(&Config_control_type, CONTROL_MOUSE);
47
48         if ( (oc_type != Config_control_type.intval) && (Config_control_type.intval == CONTROL_THRUSTMASTER_FCS ) ) {
49                 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
50         }
51
52         if (oc_type != Config_control_type.intval) {
53                 switch (Config_control_type.intval) {
54         //              case    CONTROL_NONE:
55                         case    CONTROL_JOYSTICK:
56                         case    CONTROL_FLIGHTSTICK_PRO:
57                         case    CONTROL_THRUSTMASTER_FCS:
58                         case    CONTROL_GRAVIS_GAMEPAD:
59         //              case    CONTROL_MOUSE:
60         //              case    CONTROL_CYBERMAN:
61                                 joydefs_calibrate_flag = 1;
62                 }
63                 kc_set_controls();
64         }
65 }
66
67 void joydefs_config()
68 {
69         newmenu_item m[13];
70         int i, i1 = 5, j;
71         int nitems = 10;
72
73         m[0].type = NM_TYPE_RADIO;  m[0].text = "KEYBOARD"; m[0].value = 0; m[0].group = 0;
74         m[1].type = NM_TYPE_RADIO;  m[1].text = "JOYSTICK"; m[1].value = 0; m[1].group = 0;
75         m[2].type = NM_TYPE_RADIO;  m[2].text = "MOUSE";    m[2].value = 0; m[2].group = 0;
76         m[3].type = NM_TYPE_TEXT;   m[3].text = "";
77         m[4].type = NM_TYPE_MENU;   m[4].text = TXT_CUST_ABOVE;
78         m[5].type = NM_TYPE_TEXT;   m[5].text = "";
79         m[6].type = NM_TYPE_SLIDER; m[6].text = TXT_JOYS_SENSITIVITY; m[6].value = Config_joystick_sensitivity.intval; m[6].min_value = 0; m[6].max_value = 16;
80         m[7].type = NM_TYPE_TEXT;   m[7].text = "";
81         m[8].type = NM_TYPE_MENU;   m[8].text = TXT_CUST_KEYBOARD;
82         m[9].type = NM_TYPE_MENU;   m[9].text = "CUSTOMIZE D2X KEYS";
83
84         do {
85
86                 i = Config_control_type.intval;
87                 if (i == CONTROL_MOUSE) i = 2;
88                 m[i].value = 1;
89
90                 i1 = newmenu_do1(NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1);
91
92                 cvar_setint(&Config_joystick_sensitivity, m[6].value);
93
94                 for (j = 0; j <= 2; j++)
95                         if (m[j].value)
96                                 cvar_setint(&Config_control_type, j);
97                 i = Config_control_type.intval;
98                 if (Config_control_type.intval == 2)
99                         cvar_setint(&Config_control_type, CONTROL_MOUSE);
100
101                 switch (i1) {
102                 case 4:
103                         kconfig(i, m[i].text);
104                         break;
105                 case 8:
106                         kconfig(0, "KEYBOARD");
107                         break;
108                 case 9:
109                         kconfig(4, "D2X KEYS");
110                         break;
111                 }
112
113         } while (i1>-1);
114
115 }