Setup joystick axis also when saving the conf file

This commit is contained in:
simon.kagstrom 2009-05-24 05:55:20 +00:00
parent ebc0063a9e
commit fabdbbf5c5
2 changed files with 49 additions and 25 deletions

View File

@ -374,6 +374,46 @@ static void insert_keyboard_map(const char *key, const char *fmt, ...)
read_inputdevice_config (&currprefs, buf, key);
}
static void setup_joystick(int joy, const char *key, int sdl_key)
{
int fire_buttons[] = {3,7,9,10};
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
* lines should be removed when this is properly figured out */
for (i = 0; i < 6; i++)
{
const char *what = "JOY2_HORIZ"; /* Assume port 1 */
/* Odd - vertical */
if (i % 2 != 0)
{
if (joy == 1)
what = "JOY1_VERT";
else
what = "JOY2_VERT";
}
else if (joy == 1) /* Even - horizontal (and port 2) */
what = "JOY1_HORIZ";
insert_keyboard_map(what,
"input.1.joystick.%d.axis.%d", joy, i);
}
insert_keyboard_map("SPC_ENTERGUI", "input.1.joystick.%d.button.6", joy);
insert_keyboard_map("SPC_ENTERGUI", "input.1.joystick.%d.button.19", joy);
for (i = 0; i < sizeof(fire_buttons) / sizeof(fire_buttons[0]); i++)
{
const char *btn = joy == 0 ? "JOY2_FIRE_BUTTON" : "JOY1_FIRE_BUTTON";
insert_keyboard_map(btn, "input.1.joystick.%d.button.%d",
joy, fire_buttons[i]);
}
}
static void keyboard_options(void)
{
const int wiimote_to_sdl[] = {2, 4, 5};
@ -408,25 +448,7 @@ static void keyboard_options(void)
}
for (i = 0; i < 2; i++)
{
int fire_buttons[] = {3,7,9,10};
int j;
insert_keyboard_map(key, "input.1.joystick.%d.button.%d", i, sdl_key);
/* For some reason, the user uaerc removes these. The following
* lines should be removed when this is properly figured out */
insert_keyboard_map("SPC_ENTERGUI", "input.1.joystick.%d.button.6", i);
insert_keyboard_map("SPC_ENTERGUI", "input.1.joystick.%d.button.19", i);
for (j = 0; j < sizeof(fire_buttons) / sizeof(fire_buttons[0]); j++)
{
const char *btn = i == 0 ? "JOY2_FIRE_BUTTON" : "JOY1_FIRE_BUTTON";
insert_keyboard_map(btn, "input.1.joystick.%d.button.%d",
i, fire_buttons[j]);
}
}
setup_joystick(i, key, sdl_key);
prefs_has_changed = 1;
}

View File

@ -66,23 +66,25 @@ input.1.mouse.0.button.2=JOY1_3RD_BUTTON
input.1.joystick.0.disabled=0
input.1.joystick.0.axis.0=JOY2_HORIZ
input.1.joystick.0.axis.1=JOY2_VERT
input.1.joystick.0.axis.2=JOY2_HORIZ
input.1.joystick.0.axis.3=JOY2_VERT
input.1.joystick.0.axis.4=JOY2_HORIZ
input.1.joystick.0.axis.5=JOY2_VERT
# 2 on wiimote, Z on nunchuck and a/b on the classic controller
input.1.joystick.0.button.3=JOY2_FIRE_BUTTON
input.1.joystick.0.button.7=JOY2_FIRE_BUTTON
input.1.joystick.0.button.9=JOY2_FIRE_BUTTON
input.1.joystick.0.button.10=JOY2_FIRE_BUTTON
# Bind +/- to some keys just for testing
input.1.joystick.0.button.4=KEY_A
input.1.joystick.0.button.5=KEY_RETURN
input.1.joystick.0.button.17=KEY_A
input.1.joystick.0.button.18=KEY_RETURN
# Wiimote 2
input.1.joystick.1.disabled=0
input.1.joystick.1.axis.0=JOY1_HORIZ
input.1.joystick.1.axis.1=JOY1_VERT
input.1.joystick.1.axis.2=JOY1_HORIZ
input.1.joystick.1.axis.3=JOY1_VERT
input.1.joystick.1.axis.4=JOY1_HORIZ
input.1.joystick.1.axis.5=JOY1_VERT
input.1.joystick.1.button.3=JOY1_FIRE_BUTTON
input.1.joystick.1.button.7=JOY1_FIRE_BUTTON
input.1.joystick.1.button.9=JOY1_FIRE_BUTTON