summaryrefslogtreecommitdiff
path: root/src/ui_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui_menu.c')
-rw-r--r--src/ui_menu.c63
1 files changed, 45 insertions, 18 deletions
diff --git a/src/ui_menu.c b/src/ui_menu.c
index 7ad0b2b..c6a6ab1 100644
--- a/src/ui_menu.c
+++ b/src/ui_menu.c
@@ -226,14 +226,6 @@ static void Keybind_Draw( menuKeybind_t *k ) {
k->generic.uiFlags | UI_LEFT, string );
}
-static menuSound_t Keybind_DoEnter( menuKeybind_t *k ) {
- menuFrameWork_t *menu = k->generic.parent;
-
- menu->keywait = qtrue;
- menu->status = "Press the desired key, Escape to cancel";
- return QMS_IN;
-}
-
static void Keybind_Push( menuKeybind_t *k ) {
int key = Key_EnumBindings( 0, k->cmd );
k->altbinding[0] = 0;
@@ -248,6 +240,10 @@ static void Keybind_Push( menuKeybind_t *k ) {
}
}
+static void Keybind_Pop( menuKeybind_t *k ) {
+ Key_WaitKey( NULL, NULL );
+}
+
static void Keybind_Update( menuFrameWork_t *menu ) {
menuKeybind_t *k;
int i;
@@ -272,20 +268,48 @@ static void Keybind_Remove( const char *cmd ) {
}
}
+static qboolean keybind_cb( void *arg, int key ) {
+ menuKeybind_t *k = arg;
+ menuFrameWork_t *menu = k->generic.parent;
+
+ // console key is hardcoded
+ if( key == '`' ) {
+ UI_StartSound( QMS_BEEP );
+ return qfalse;
+ }
+
+ // menu key is hardcoded
+ if( key != K_ESCAPE ) {
+ if( k->altbinding[0] ) {
+ Keybind_Remove( k->cmd );
+ }
+ Key_SetBinding( key, k->cmd );
+ }
+
+ Keybind_Update( menu );
+
+ menu->keywait = qfalse;
+ menu->status = "Press Enter to change, Backspace to clear";
+ Key_WaitKey( NULL, NULL );
+
+ UI_StartSound( QMS_OUT );
+ return qfalse;
+}
+
+static menuSound_t Keybind_DoEnter( menuKeybind_t *k ) {
+ menuFrameWork_t *menu = k->generic.parent;
+
+ menu->keywait = qtrue;
+ menu->status = "Press the desired key, Escape to cancel";
+ Key_WaitKey( keybind_cb, k );
+ return QMS_IN;
+}
+
static menuSound_t Keybind_Key( menuKeybind_t *k, int key ) {
menuFrameWork_t *menu = k->generic.parent;
if( menu->keywait ) {
- if( key != K_ESCAPE ) {
- if( k->altbinding[0] ) {
- Keybind_Remove( k->cmd );
- }
- Key_SetBinding( key, k->cmd );
- }
- Keybind_Update( menu );
- menu->keywait = qfalse;
- menu->status = "Press Enter to change, Backspace to clear";
- return QMS_OUT;
+ return QMS_OUT; // never gets there
}
if( key == K_BACKSPACE || key == K_DEL ) {
@@ -1943,6 +1967,9 @@ void Menu_Pop( menuFrameWork_t *menu ) {
case MTYPE_TOGGLE:
SpinControl_Pop( item );
break;
+ case MTYPE_KEYBIND:
+ Keybind_Pop( item );
+ break;
case MTYPE_FIELD:
Field_Pop( item );
break;