From 7579f29afb9f48e01a7f21a0726b109f66b5f2b5 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 22 Jun 2007 19:14:49 +0000 Subject: Don't allow two actions bound to the same button in setup. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 926 --- setup/joystick.c | 33 ++++++++++++++++++++++++++++++++- setup/txt_joybinput.c | 1 + 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/setup/joystick.c b/setup/joystick.c index eb7f9bfa..ceea9603 100644 --- a/setup/joystick.c +++ b/setup/joystick.c @@ -21,6 +21,7 @@ #include +#include "doomtype.h" #include "textscreen.h" #include "txt_joybinput.h" @@ -64,6 +65,11 @@ int joystick_y_invert = 0; static txt_button_t *joystick_button; +static int *all_joystick_buttons[] = { + &joybstraferight, &joybstrafeleft, &joybfire, &joybspeed, + &joybuse, &joybstrafe, +}; + // // Calibration // @@ -308,6 +314,25 @@ 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); + 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; itype == SDL_JOYBUTTONDOWN) { *joystick_input->variable = event->jbutton.button; + TXT_EmitSignal(joystick_input, "set"); TXT_CloseWindow(joystick_input->prompt_window); return 1; } -- cgit v1.2.3