diff options
author | Simon Howard | 2011-04-11 19:49:45 +0000 |
---|---|---|
committer | Simon Howard | 2011-04-11 19:49:45 +0000 |
commit | eb86fcdf3099404ed8cc0feaf96dd94654d2b8dd (patch) | |
tree | 26acfbe82ee8ce3281e8f254467e6f66af095159 /setup | |
parent | d4ef7c37721ee261ac23305fd52239a91e58250a (diff) | |
download | chocolate-doom-eb86fcdf3099404ed8cc0feaf96dd94654d2b8dd.tar.gz chocolate-doom-eb86fcdf3099404ed8cc0feaf96dd94654d2b8dd.tar.bz2 chocolate-doom-eb86fcdf3099404ed8cc0feaf96dd94654d2b8dd.zip |
Allow the shift key to be held down when changing key/mouse/joystick
bindings to prevent bindings to the same key from being cleared (thanks
myk).
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2325
Diffstat (limited to 'setup')
-rw-r--r-- | setup/txt_joybinput.c | 11 | ||||
-rw-r--r-- | setup/txt_joybinput.h | 1 | ||||
-rw-r--r-- | setup/txt_keyinput.c | 11 | ||||
-rw-r--r-- | setup/txt_keyinput.h | 1 | ||||
-rw-r--r-- | setup/txt_mouseinput.c | 10 | ||||
-rw-r--r-- | setup/txt_mouseinput.h | 1 |
6 files changed, 32 insertions, 3 deletions
diff --git a/setup/txt_joybinput.c b/setup/txt_joybinput.c index 861414f7..9ad26a45 100644 --- a/setup/txt_joybinput.c +++ b/setup/txt_joybinput.c @@ -48,7 +48,12 @@ static int EventCallback(SDL_Event *event, TXT_UNCAST_ARG(joystick_input)) if (event->type == SDL_JOYBUTTONDOWN) { *joystick_input->variable = event->jbutton.button; - TXT_EmitSignal(joystick_input, "set"); + + if (joystick_input->check_conflicts) + { + TXT_EmitSignal(joystick_input, "set"); + } + TXT_CloseWindow(joystick_input->prompt_window); return 1; } @@ -89,6 +94,10 @@ static void OpenPromptWindow(txt_joystick_input_t *joystick_input) txt_label_t *label; SDL_Joystick *joystick; + // Silently update when the shift button is held down. + + joystick_input->check_conflicts = !TXT_GetModifierState(TXT_MOD_SHIFT); + if (SDL_Init(SDL_INIT_JOYSTICK) < 0) { return; diff --git a/setup/txt_joybinput.h b/setup/txt_joybinput.h index b2920b88..69ec4a1f 100644 --- a/setup/txt_joybinput.h +++ b/setup/txt_joybinput.h @@ -37,6 +37,7 @@ struct txt_joystick_input_s txt_widget_t widget; int *variable; txt_window_t *prompt_window; + int check_conflicts; }; txt_joystick_input_t *TXT_NewJoystickInput(int *variable); diff --git a/setup/txt_keyinput.c b/setup/txt_keyinput.c index dfa6ede2..6f1ee4dd 100644 --- a/setup/txt_keyinput.c +++ b/setup/txt_keyinput.c @@ -42,7 +42,12 @@ static int KeyPressCallback(txt_window_t *window, int key, // Got the key press. Save to the variable and close the window. *key_input->variable = key; - TXT_EmitSignal(key_input, "set"); + + if (key_input->check_conflicts) + { + TXT_EmitSignal(key_input, "set"); + } + TXT_CloseWindow(window); // Re-enable key mappings now that we have the key @@ -67,6 +72,10 @@ static void OpenPromptWindow(txt_key_input_t *key_input) txt_window_t *window; txt_label_t *label; + // Silently update when the shift button is held down. + + key_input->check_conflicts = !TXT_GetModifierState(TXT_MOD_SHIFT); + window = TXT_NewWindow(NULL); TXT_SetWindowAction(window, TXT_HORIZ_LEFT, NULL); TXT_SetWindowAction(window, TXT_HORIZ_CENTER, diff --git a/setup/txt_keyinput.h b/setup/txt_keyinput.h index 4952a970..5df0b2e3 100644 --- a/setup/txt_keyinput.h +++ b/setup/txt_keyinput.h @@ -35,6 +35,7 @@ struct txt_key_input_s { txt_widget_t widget; int *variable; + int check_conflicts; }; txt_key_input_t *TXT_NewKeyInput(int *variable); diff --git a/setup/txt_mouseinput.c b/setup/txt_mouseinput.c index 2c14a010..c3e17299 100644 --- a/setup/txt_mouseinput.c +++ b/setup/txt_mouseinput.c @@ -42,7 +42,12 @@ static int MousePressCallback(txt_window_t *window, // Got the mouse press. Save to the variable and close the window. *mouse_input->variable = b - TXT_MOUSE_BASE; - TXT_EmitSignal(mouse_input, "set"); + + if (mouse_input->check_conflicts) + { + TXT_EmitSignal(mouse_input, "set"); + } + TXT_CloseWindow(window); return 1; @@ -53,6 +58,9 @@ static void OpenPromptWindow(txt_mouse_input_t *mouse_input) txt_window_t *window; txt_label_t *label; + // Silently update when the shift key is held down. + mouse_input->check_conflicts = !TXT_GetModifierState(TXT_MOD_SHIFT); + window = TXT_NewWindow(NULL); TXT_SetWindowAction(window, TXT_HORIZ_LEFT, NULL); TXT_SetWindowAction(window, TXT_HORIZ_CENTER, diff --git a/setup/txt_mouseinput.h b/setup/txt_mouseinput.h index 57c258eb..ef3ec2aa 100644 --- a/setup/txt_mouseinput.h +++ b/setup/txt_mouseinput.h @@ -35,6 +35,7 @@ struct txt_mouse_input_s { txt_widget_t widget; int *variable; + int check_conflicts; }; txt_mouse_input_t *TXT_NewMouseInput(int *variable); |