fixed joystick deadzone feature and moved it and sensitivity to controls sub-menu

This commit is contained in:
zicodxx 2006-09-29 21:42:06 +00:00
parent 2fff0b4ef5
commit 669eed87ce
3 changed files with 50 additions and 28 deletions

View file

@ -383,7 +383,16 @@ void joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max)
int joy_get_scaled_reading( int raw, int axis_num )
{
#if 1
return raw/256;
int x, d;
d = (joy_deadzone) * 6;
if (((raw/256) > (-1*d)) && ((raw/256) < d))
x = 0;
else
x = raw/256;
return x;
//return raw/256;
#else
int d, x;

View file

@ -18,6 +18,7 @@
#include "kconfig.h"
extern int num_joysticks;
extern int joy_deadzone;
int joydefs_calibrate_flag = 0;
@ -34,6 +35,13 @@ void joydefs_calibrate()
}
//this change was made in DESCENT.TEX, but since we're not including that
//file in the v1.1 update, we're making the change in the code here also
#ifdef SHAREWARE
#undef TXT_JOYS_SENSITIVITY
#define TXT_JOYS_SENSITIVITY "Joystick/Mouse\nSensitivity"
#endif
void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem )
{
int i;
@ -70,16 +78,21 @@ void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem
void joydefs_config()
{
newmenu_item m[13];
int i, i1 = 5, j;
int nitems = 6;
int i, i1 = 9, j;
int nitems = 10;
m[0].type = NM_TYPE_RADIO; m[0].text = "KEYBOARD"; m[0].value = 0; m[0].group = 0;
m[1].type = NM_TYPE_RADIO; m[1].text = "JOYSTICK"; m[1].value = 0; m[1].group = 0;
m[2].type = NM_TYPE_RADIO; m[2].text = "MOUSE"; m[2].value = 0; m[2].group = 0;
m[3].type = NM_TYPE_TEXT; m[3].text = "";
m[4].type = NM_TYPE_MENU; m[4].text = TXT_CUST_ABOVE;
m[5].type = NM_TYPE_MENU; m[5].text = TXT_CUST_KEYBOARD;
m[5].type = NM_TYPE_TEXT; m[5].text = "";
// from menu.c
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;
m[7].type = NM_TYPE_SLIDER; m[7].text="Joystick Deadzone"; m[7].value=joy_deadzone; m[7].min_value=0; m[7].max_value = 16;
m[8].type = NM_TYPE_TEXT; m[8].text="";
m[9].type = NM_TYPE_MENU; m[9].text = TXT_CUST_KEYBOARD;
do {
i = Config_control_type;
@ -88,7 +101,8 @@ void joydefs_config()
i1 = newmenu_do1(NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1);
// Config_joystick_sensitivity = m[6].value;
Config_joystick_sensitivity = m[6].value;
joy_deadzone = m[7].value;
for (j = 0; j <= 2; j++)
if (m[j].value)
@ -101,7 +115,7 @@ void joydefs_config()
case 4:
kconfig(i, m[i].text);
break;
case 5:
case 9:
kconfig(0, "KEYBOARD");
break;
}

View file

@ -913,7 +913,6 @@ void change_res()
int screen_width = 0;
int screen_height = 0;
int vr_mode = VR_NONE;
int screen_flags = 0;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200"; m[mc].value = (Game_screen_mode == SM(320,200)); m[mc].group = 0; modes[mc] = SM(320,200); mc++;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480"; m[mc].value = (Game_screen_mode == SM(640,480)); m[mc].group = 0; modes[mc] = SM(640,480); mc++;
@ -1162,16 +1161,16 @@ void joydef_menuset(int nitems, newmenu_item * items, int *last_key, int citem )
}
}
//this change was made in DESCENT.TEX, but since we're not including that
//file in the v1.1 update, we're making the change in the code here also
#ifdef SHAREWARE
#undef TXT_JOYS_SENSITIVITY
#define TXT_JOYS_SENSITIVITY "Joystick/Mouse\nSensitivity"
#endif
// //this change was made in DESCENT.TEX, but since we're not including that
// //file in the v1.1 update, we're making the change in the code here also
// #ifdef SHAREWARE
// #undef TXT_JOYS_SENSITIVITY
// #define TXT_JOYS_SENSITIVITY "Joystick/Mouse\nSensitivity"
// #endif
void do_options_menu()
{
newmenu_item m[14];
newmenu_item m[12];
int i = 0;
@ -1185,31 +1184,31 @@ void do_options_menu()
//end this section addition - Victor Rachels
m[5].type = NM_TYPE_TEXT; m[5].text="";
m[6].type = NM_TYPE_MENU; m[6].text=TXT_CONTROLS_;
m[7].type = NM_TYPE_MENU; m[7].text=TXT_DETAIL_LEVELS;
m[8].type = NM_TYPE_MENU; m[8].text=TXT_CAL_JOYSTICK;
m[7].type = NM_TYPE_MENU; m[7].text=TXT_CAL_JOYSTICK;
m[8].type = NM_TYPE_TEXT; m[8].text="";
m[9].type = NM_TYPE_MENU; m[9].text=TXT_DETAIL_LEVELS;
//added/changed on 10/27/98 by Victor Rachels to increase sensitivity range
m[9].type = NM_TYPE_SLIDER; m[9].text=TXT_JOYS_SENSITIVITY; m[9].value=Config_joystick_sensitivity; m[9].min_value =0; m[9].max_value = 16;
// m[9].type = NM_TYPE_SLIDER; m[9].text=TXT_JOYS_SENSITIVITY; m[9].value=Config_joystick_sensitivity; m[9].min_value =0; m[9].max_value = 16;
//end this section addition - Victor Rachels
//added on 4/13/99 by Victor Rachels to add joystick deadzone option
m[10].type = NM_TYPE_SLIDER; m[10].text="Joystick Deadzone"; m[10].value=joy_deadzone; m[10].min_value=0; m[10].max_value=16;
// m[10].type = NM_TYPE_SLIDER; m[10].text="Joystick Deadzone"; m[10].value=joy_deadzone; m[10].min_value=0; m[10].max_value=16;
//end this section addition - VR
m[11].type = NM_TYPE_TEXT; m[11].text="";
m[12].type = NM_TYPE_CHECK; m[12].text="Ship auto-leveling"; m[12].value=Auto_leveling_on;
m[13].type = NM_TYPE_MENU; m[13].text="D1X options...";
m[10].type = NM_TYPE_CHECK; m[10].text="Ship auto-leveling"; m[10].value=Auto_leveling_on;
m[11].type = NM_TYPE_MENU; m[11].text="D1X options...";
i = newmenu_do1( NULL, TXT_OPTIONS, 14, m, joydef_menuset, i );
i = newmenu_do1( NULL, TXT_OPTIONS, 12, m, joydef_menuset, i );
switch(i) {
case 6: joydefs_config(); break;
case 7: do_detail_level_menu(); break;
case 8: joydefs_calibrate(); break;
case 13: d1x_options_menu(); break;
case 7: joydefs_calibrate(); break;
case 9: do_detail_level_menu(); break;
case 11: d1x_options_menu(); break;
}
Config_channels_reversed = m[2].value;
Config_joystick_sensitivity = m[9].value;
joy_deadzone = m[10].value;
Auto_leveling_on = m[12].value;
// Config_joystick_sensitivity = m[9].value;
// joy_deadzone = m[10].value;
Auto_leveling_on = m[10].value;
} while( i>-1 );
write_player_file();