-
- if (down)
- {
- if (!(kb = keybindings[key_bmap][key]))
- kb = keybindings[key_bmap2][key];
- if (kb && !strncmp(kb, "toggleconsole", strlen("toggleconsole")))
- {
- Cbuf_AddText (kb);
- Cbuf_AddText ("\n");
- return;
- }
- }
-
- if (key_consoleactive && consolekeys[key] && down)
- Key_Console (key, ascii);
- else
- {
- //
- // key up events only generate commands if the game key binding is a button
- // command (leading + sign). These will occur even in console mode, to
- // keep the character from continuing an action started before a console
- // switch. Button commands include the kenum as a parameter, so multiple
- // downs can be matched with ups
- //
- if (!down) {
- if (!(kb = keybindings[key_bmap][key]))
- kb = keybindings[key_bmap2][key];
-
- if (kb && kb[0] == '+') {
- dpsnprintf (cmd, sizeof(cmd), "-%s %i\n", kb + 1, key);
- Cbuf_AddText (cmd);
- }
- return;
- }
-
- //
- // during demo playback, most keys bring up the main menu
- //
- if (cls.demoplayback && down && consolekeys[key] && key_dest == key_game) {
- MR_ToggleMenu_f ();
- return;
- }
-
- //
- // if not a consolekey, send to the interpreter no matter what mode is
- //
- if ((key_dest == key_menu && menubound[key])
- || (key_consoleactive && !consolekeys[key])
- || (key_dest == key_game &&
- ((cls.state == ca_connected) || !consolekeys[key]))) {
- if (!(kb = keybindings[key_bmap][key]))
- kb = keybindings[key_bmap2][key];
- if (kb) {
- if (kb[0] == '+') { // button commands add keynum as a parm
- dpsnprintf (cmd, sizeof(cmd), "%s %i\n", kb, key);
- Cbuf_AddText (cmd);
- } else {
- Cbuf_AddText (kb);
- Cbuf_AddText ("\n");
- }
- }
- return;
- }
-
- if (!down)
- return; // other systems only care about key
- // down events
-
- switch (key_dest) {
- case key_message:
- Key_Message (key, ascii);
- break;
- case key_menu:
- MR_Keydown (key, ascii);
- break;
- case key_game:
- Key_Console (key, ascii);
- break;
- default:
- if(UI_Callback_IsSlotUsed(key_dest - 3))
- UI_Callback_KeyDown (key, ascii);
- else
- Sys_Error ("Bad key_dest");
- }
- }
-#endif