Refactor joystick setup (so that it is always saved in the .user configuration file)

This commit is contained in:
simon.kagstrom 2009-05-26 05:26:37 +00:00
parent 3d0a18b087
commit 718ff877b5

View File

@ -375,13 +375,11 @@ static void insert_keyboard_map(const char *key, const char *fmt, ...)
read_inputdevice_config (&currprefs, buf, key); read_inputdevice_config (&currprefs, buf, key);
} }
static void setup_joystick(int joy, const char *key, int sdl_key) static void setup_joystick_defaults(int joy)
{ {
int fire_buttons[] = {3,7,9,10}; int fire_buttons[] = {3,7,9,10};
int i; int i;
insert_keyboard_map(key, "input.1.joystick.%d.button.%d", joy, sdl_key);
/* For some reason, the user uaerc removes these. The following /* For some reason, the user uaerc removes these. The following
* lines should be removed when this is properly figured out */ * lines should be removed when this is properly figured out */
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
@ -415,6 +413,11 @@ static void setup_joystick(int joy, const char *key, int sdl_key)
} }
} }
static void setup_joystick(int joy, const char *key, int sdl_key)
{
insert_keyboard_map(key, "input.1.joystick.%d.button.%d", joy, sdl_key);
}
static void keyboard_options(void) static void keyboard_options(void)
{ {
const int wiimote_to_sdl[] = {2, 4, 5}; const int wiimote_to_sdl[] = {2, 4, 5};
@ -734,6 +737,7 @@ void gui_display(int shortcut)
if (prefs_has_changed) if (prefs_has_changed)
{ {
char user_options[255] = ""; char user_options[255] = "";
int i;
#ifdef OPTIONS_IN_HOME #ifdef OPTIONS_IN_HOME
char *home = getenv ("HOME"); char *home = getenv ("HOME");
@ -746,6 +750,9 @@ void gui_display(int shortcut)
strcat(user_options, OPTIONSFILENAME); strcat(user_options, OPTIONSFILENAME);
strcat(user_options, ".user"); strcat(user_options, ".user");
for (i = 0; i < 2; i++)
setup_joystick_defaults(i);
cfgfile_save(&changed_prefs, user_options, 0); cfgfile_save(&changed_prefs, user_options, 0);
} }
} }