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