]> icculus.org git repositories - btb/d2x.git/blob - arch/sdl/joydefs.c
remove rcs tags
[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 "config.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;
40
41         for (i=0; i<3; i++ )
42                 if (items[i].value) Config_control_type = i;
43
44         if (Config_control_type == 2) Config_control_type = CONTROL_MOUSE;
45
46         if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) {
47                 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
48         }
49
50         if (oc_type != Config_control_type) {
51                 switch (Config_control_type) {
52         //              case    CONTROL_NONE:
53                         case    CONTROL_JOYSTICK:
54                         case    CONTROL_FLIGHTSTICK_PRO:
55                         case    CONTROL_THRUSTMASTER_FCS:
56                         case    CONTROL_GRAVIS_GAMEPAD:
57         //              case    CONTROL_MOUSE:
58         //              case    CONTROL_CYBERMAN:
59                                 joydefs_calibrate_flag = 1;
60                 }
61                 kc_set_controls();
62         }
63 }
64
65 void joydefs_config()
66 {
67         newmenu_item m[13];
68         int i, i1 = 5, j;
69 #ifdef D2X_KEYS
70         int nitems = 10;
71 #else
72         int nitems = 9;
73 #endif
74
75         m[0].type = NM_TYPE_RADIO;  m[0].text = "KEYBOARD"; m[0].value = 0; m[0].group = 0;
76         m[1].type = NM_TYPE_RADIO;  m[1].text = "JOYSTICK"; m[1].value = 0; m[1].group = 0;
77         m[2].type = NM_TYPE_RADIO;  m[2].text = "MOUSE";    m[2].value = 0; m[2].group = 0;
78         m[3].type = NM_TYPE_TEXT;   m[3].text = "";
79         m[4].type = NM_TYPE_MENU;   m[4].text = TXT_CUST_ABOVE;
80         m[5].type = NM_TYPE_TEXT;   m[5].text = "";
81         m[6].type = NM_TYPE_SLIDER; m[6].text = TXT_JOYS_SENSITIVITY; m[6].value = Config_joystick_sensitivity; m[6].min_value = 0; m[6].max_value = 16;
82         m[7].type = NM_TYPE_TEXT;   m[7].text = "";
83         m[8].type = NM_TYPE_MENU;   m[8].text = TXT_CUST_KEYBOARD;
84 #ifdef D2X_KEYS
85         m[9].type = NM_TYPE_MENU;   m[9].text = "CUSTOMIZE D2X KEYS";
86 #endif
87
88         do {
89
90                 i = Config_control_type;
91                 if (i == CONTROL_MOUSE) i = 2;
92                 m[i].value = 1;
93
94                 i1 = newmenu_do1(NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1);
95
96                 Config_joystick_sensitivity = m[6].value;
97
98                 for (j = 0; j <= 2; j++)
99                         if (m[j].value)
100                                 Config_control_type = j;
101                 i = Config_control_type;
102                 if (Config_control_type == 2)
103                         Config_control_type = CONTROL_MOUSE;
104
105                 switch (i1) {
106                 case 4:
107                         kconfig(i, m[i].text);
108                         break;
109                 case 8:
110                         kconfig(0, "KEYBOARD");
111                         break;
112 #ifdef D2X_KEYS
113                 case 9:
114                         kconfig(4, "D2X KEYS");
115                         break;
116 #endif
117                 }
118
119         } while (i1>-1);
120
121 }