}
}
- if (!down)
+ if (down)
+ {
+ // increment key repeat count each time a down is received so that things
+ // which want to ignore key repeat can ignore it
+ keydown[key] = min(keydown[key] + 1, 2);
+ }
+ else
{
// clear repeat count now that the key is released
keydown[key] = 0;
// downs can be matched with ups
if (bind && bind[0] == '+')
Cbuf_AddText(va("-%s %i\n", bind + 1, key));
- return;
}
- // from here on we know this is a down event
-
- // increment key repeat count each time a down is received so that things
- // which want to ignore key repeat can ignore it
- keydown[key] = min(keydown[key] + 1, 2);
-
// key_consoleactive is a flag not a key_dest because the console is a
// high priority overlay ontop of the normal screen (designed as a safety
// feature so that developers and users can rescue themselves from a bad
// key_menu - go to parent menu (or key_game)
// key_game - open menu
// in all modes shift-escape toggles console
- if ((key_consoleactive & KEY_CONSOLEACTIVE_USER) || keydown[K_SHIFT])
+ if (((key_consoleactive & KEY_CONSOLEACTIVE_USER) || keydown[K_SHIFT]) && down)
{
Con_ToggleConsole_f ();
return;
switch (key_dest)
{
case key_message:
- Key_Message (key, ascii);
+ if (down)
+ Key_Message (key, ascii);
break;
case key_menu:
- MR_Keydown (key, ascii);
+ MR_KeyEvent (key, ascii, down);
break;
case key_game:
- MR_ToggleMenu_f ();
+ if (down)
+ MR_ToggleMenu_f ();
break;
default:
Con_Printf ("Key_Event: Bad key_dest\n");
}
// send function keydowns to interpreter no matter what mode is
- if (key >= K_F1 && key <= K_F12)
+ if (key >= K_F1 && key <= K_F12 && down)
{
// ignore key repeats on F1-F12 binds
if (keydown[key] > 1)
#if 1
// ignore binds (other than the above escape/F1-F12 keys) while in console
- if (key_consoleactive)
+ if (key_consoleactive && down)
#else
// respond to toggleconsole binds while in console unless the pressed key
// happens to be the color prefix character (such as on German keyboards)
- if (key_consoleactive && (strncmp(bind, "toggleconsole", strlen("toggleconsole")) || ascii == STRING_COLOR_TAG))
+ if (key_consoleactive && down && (strncmp(bind, "toggleconsole", strlen("toggleconsole")) || ascii == STRING_COLOR_TAG))
#endif
{
Key_Console (key, ascii);
switch (key_dest)
{
case key_message:
- Key_Message (key, ascii);
+ if (down)
+ Key_Message (key, ascii);
break;
case key_menu:
- MR_Keydown (key, ascii);
+ MR_KeyEvent (key, ascii, down);
break;
case key_game:
// ignore key repeats on binds
- if (bind && keydown[key] == 1)
+ if (bind && keydown[key] == 1 && down)
{
// button commands add keynum as a parm
if (bind[0] == '+')
//=============================================================================
/* Menu Subsystem */
-static void M_Keydown(int key, char ascii);
+static void M_KeyEvent(int key, char ascii, qboolean downevent);
static void M_Draw(void);
void M_ToggleMenu_f(void);
static void M_Shutdown(void);
}
-void M_Keydown (int key, char ascii)
+void M_KeyEvent (int key, char ascii, qboolean downevent)
{
+ if (!downevent)
+ return;
switch (m_state)
{
case m_none:
#define M_F_INIT "m_init"
#define M_F_KEYDOWN "m_keydown"
+#define M_F_KEYUP "m_keyup"
#define M_F_DRAW "m_draw"
// normal menu names (rest)
#define M_F_TOGGLE "m_toggle"
static int m_numrequiredfunc = sizeof(m_required_func) / sizeof(char*);
static func_t m_draw, m_keydown;
+static mfunction_t *m_keyup;
void MR_SetRouting (qboolean forceold);
Host_AbortCurrentFrame();
}
-void MP_Keydown (int key, char ascii)
+void MP_KeyEvent (int key, char ascii, qboolean downevent)
{
PRVM_Begin;
PRVM_SetProg(PRVM_MENUPROG);
// pass key
prog->globals.generic[OFS_PARM0] = (float) key;
prog->globals.generic[OFS_PARM1] = (float) ascii;
- PRVM_ExecuteProgram(m_keydown, M_F_KEYDOWN"(float key, float ascii) required\n");
+ if (downevent)
+ PRVM_ExecuteProgram(m_keydown, M_F_KEYDOWN"(float key, float ascii) required\n");
+ else if (m_keyup)
+ PRVM_ExecuteProgram((func_t)(m_keyup - prog->functions), M_F_KEYUP"(float key, float ascii) required\n");
PRVM_End;
}
// set m_draw and m_keydown
m_draw = (func_t) (PRVM_ED_FindFunction(M_F_DRAW) - prog->functions);
m_keydown = (func_t) (PRVM_ED_FindFunction(M_F_KEYDOWN) - prog->functions);
+ m_keyup = PRVM_ED_FindFunction(M_F_KEYUP);
#ifdef NG_MENU
m_displayed = false;
static cvar_t forceqmenu = { 0, "forceqmenu", "0", "enables the quake menu instead of the quakec menu.dat (if present)" };
-void (*MR_Keydown) (int key, char ascii);
+void (*MR_KeyEvent) (int key, char ascii, qboolean downevent);
void (*MR_Draw) (void);
void (*MR_ToggleMenu_f) (void);
void (*MR_Shutdown) (void);
if(!FS_FileExists(M_PROG_FILENAME) || forceqmenu.integer || forceold)
{
// set menu router function pointers
- MR_Keydown = M_Keydown;
+ MR_KeyEvent = M_KeyEvent;
MR_Draw = M_Draw;
MR_ToggleMenu_f = M_ToggleMenu_f;
MR_Shutdown = M_Shutdown;
else
{
// set menu router function pointers
- MR_Keydown = MP_Keydown;
+ MR_KeyEvent = MP_KeyEvent;
MR_Draw = MP_Draw;
MR_ToggleMenu_f = MP_ToggleMenu_f;
MR_Shutdown = MP_Shutdown;
// hard-coded menus
//
void M_Init (void);
-void M_Keydown (int key);
+void M_KeyEvent (int key);
void M_Draw (void);
void M_ToggleMenu_f (void);
// menu prog menu
//
void MP_Init (void);
-void MP_Keydown (int key);
+void MP_KeyEvent (int key);
void MP_Draw (void);
void MP_ToggleMenu_f (void);
void MP_Shutdown (void);*/
void MR_Init_Commands (void);
void MR_Init (void);
void MR_Restart (void);
-extern void (*MR_Keydown) (int key, char ascii);
+extern void (*MR_KeyEvent) (int key, char ascii, qboolean downevent);
extern void (*MR_Draw) (void);
extern void (*MR_ToggleMenu_f) (void);
extern void (*MR_Shutdown) (void);