]> icculus.org git repositories - btb/d2x.git/blob - arch/sdl/joydefs.c
422873a37e9280cc781e6fb487cc202e4a0742d0
[btb/d2x.git] / arch / sdl / joydefs.c
1 /* $Id: joydefs.c,v 1.5 2003-01-15 02:40:54 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         nitems = nitems;
43         last_key = last_key;
44         citem = citem;          
45
46         for (i=0; i<3; i++ )
47                 if (items[i].value) Config_control_type = i;
48
49         if (Config_control_type == 2) Config_control_type = CONTROL_MOUSE;
50
51         if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) {
52                 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
53         }
54
55         if (oc_type != Config_control_type) {
56                 switch (Config_control_type) {
57         //              case    CONTROL_NONE:
58                         case    CONTROL_JOYSTICK:
59                         case    CONTROL_FLIGHTSTICK_PRO:
60                         case    CONTROL_THRUSTMASTER_FCS:
61                         case    CONTROL_GRAVIS_GAMEPAD:
62         //              case    CONTROL_MOUSE:
63         //              case    CONTROL_CYBERMAN:
64                                 joydefs_calibrate_flag = 1;
65                 }
66                 kc_set_controls();
67         }
68 }
69
70 void joydefs_config()
71 {
72         newmenu_item m[13];
73         int i, i1=5, j, nitems=7;
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="CUSTOMIZE ABOVE";
80         m[5].type = NM_TYPE_MENU; m[5].text="CUSTOMIZE KEYBOARD";
81         m[6].type = NM_TYPE_MENU; m[6].text="CUSTOMIZE D1X KEYS";
82
83         do {
84
85                 i = Config_control_type;
86                 if(i==CONTROL_MOUSE) i = 2;
87                 m[i].value=1;
88
89                 i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 );
90
91                 for (j = 0; j <= 2; j++)
92                         if (m[j].value)
93                                 Config_control_type = j;
94                 i = Config_control_type;
95                 if (Config_control_type == 2)
96                         Config_control_type = CONTROL_MOUSE;
97
98                 switch(i1)      {
99                 case 4: 
100                         kconfig (i, m[i].text);
101                         break;
102                 case 5: 
103                         kconfig(0, "KEYBOARD"); 
104                         break;
105                 case 6:
106                         kconfig(3, "D1X KEYS");
107                         break;
108                 } 
109
110         } while(i1>-1);
111
112 }