diff options
author | Simon Howard | 2014-05-01 00:19:51 -0400 |
---|---|---|
committer | Simon Howard | 2014-05-01 00:19:51 -0400 |
commit | 05f22d03aa25c55f5b7251d474eee16054f37e9e (patch) | |
tree | 93f5313511e47674e8ed3403966d40d079ac6caa /src/setup/joystick.c | |
parent | 4890591ba50bfc8b11cda684b223cb7c551e6dd3 (diff) | |
download | chocolate-doom-05f22d03aa25c55f5b7251d474eee16054f37e9e.tar.gz chocolate-doom-05f22d03aa25c55f5b7251d474eee16054f37e9e.tar.bz2 chocolate-doom-05f22d03aa25c55f5b7251d474eee16054f37e9e.zip |
setup: Configure joystick buttons with virtual mapping.
Refactor how joystick buttons are reassigned. Define a fixed
mapping from joyb* variables to virtual buttons, and change the
button assignments at the virtual->physical mapping level.
Diffstat (limited to 'src/setup/joystick.c')
-rw-r--r-- | src/setup/joystick.c | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/src/setup/joystick.c b/src/setup/joystick.c index cc5c4a8e..3eedda1e 100644 --- a/src/setup/joystick.c +++ b/src/setup/joystick.c @@ -90,18 +90,12 @@ static int joystick_strafe_axis = -1; static int joystick_strafe_invert = 0; // Virtual to physical mapping. -static int joystick_physical_buttons[NUM_VIRTUAL_BUTTONS] = { +int joystick_physical_buttons[NUM_VIRTUAL_BUTTONS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; static txt_button_t *joystick_button; -static int *all_joystick_buttons[] = { - &joybstraferight, &joybstrafeleft, &joybfire, &joybspeed, - &joybuse, &joybstrafe, &joybprevweapon, &joybnextweapon, &joybjump, - &joybmenu, -}; - // // Calibration // @@ -580,27 +574,7 @@ static void CalibrateJoystick(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) SetCalibrationLabel(); } -void JoyButtonSetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable)) -{ - TXT_CAST_ARG(int, variable); - unsigned int i; - - // Only allow a button to be bound to one action at a time. If - // we assign a key that another action is using, set that other action - // to -1. - - for (i=0; i<arrlen(all_joystick_buttons); ++i) - { - if (variable != all_joystick_buttons[i] - && *variable == *all_joystick_buttons[i]) - { - *all_joystick_buttons[i] = -1; - } - } -} - - -// +// // GUI // @@ -621,8 +595,6 @@ static void AddJoystickControl(txt_table_t *table, char *label, int *var) TXT_AddWidget(table, TXT_NewLabel(label)); TXT_AddWidget(table, joy_input); - - TXT_SignalConnect(joy_input, "set", JoyButtonSetCallback, var); } void ConfigJoystick(void) |