2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** c_bind.cpp
|
|
|
|
** Functions for using and maintaining key bindings
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-06-11 01:37:00 +00:00
|
|
|
** Copyright 1998-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "doomtype.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "cmdlib.h"
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
#include "c_bind.h"
|
|
|
|
#include "g_level.h"
|
|
|
|
#include "hu_stuff.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "configfile.h"
|
|
|
|
#include "i_system.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "d_event.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
/* Default keybindings for Doom (and all other games)
|
|
|
|
*/
|
|
|
|
static const FBinding DefBindings[] =
|
|
|
|
{
|
|
|
|
{ "`", "toggleconsole" },
|
|
|
|
{ "1", "slot 1" },
|
|
|
|
{ "2", "slot 2" },
|
|
|
|
{ "3", "slot 3" },
|
|
|
|
{ "4", "slot 4" },
|
|
|
|
{ "5", "slot 5" },
|
|
|
|
{ "6", "slot 6" },
|
|
|
|
{ "7", "slot 7" },
|
|
|
|
{ "8", "slot 8" },
|
|
|
|
{ "9", "slot 9" },
|
|
|
|
{ "0", "slot 0" },
|
|
|
|
{ "[", "invprev" },
|
|
|
|
{ "]", "invnext" },
|
2009-06-06 02:55:58 +00:00
|
|
|
{ "mwheelleft", "invprev" },
|
|
|
|
{ "mwheelright", "invnext" },
|
2006-02-24 04:48:15 +00:00
|
|
|
{ "enter", "invuse" },
|
|
|
|
{ "-", "sizedown" },
|
|
|
|
{ "=", "sizeup" },
|
|
|
|
{ "ctrl", "+attack" },
|
|
|
|
{ "alt", "+strafe" },
|
|
|
|
{ "shift", "+speed" },
|
|
|
|
{ "space", "+use" },
|
|
|
|
{ "rightarrow", "+right" },
|
|
|
|
{ "leftarrow", "+left" },
|
|
|
|
{ "uparrow", "+forward" },
|
|
|
|
{ "downarrow", "+back" },
|
|
|
|
{ ",", "+moveleft" },
|
|
|
|
{ ".", "+moveright" },
|
|
|
|
{ "mouse1", "+attack" },
|
|
|
|
{ "mouse2", "+strafe" },
|
|
|
|
{ "mouse3", "+forward" },
|
|
|
|
{ "mouse4", "+speed" },
|
|
|
|
{ "capslock", "toggle cl_run" },
|
|
|
|
{ "f1", "menu_help" },
|
|
|
|
{ "f2", "menu_save" },
|
|
|
|
{ "f3", "menu_load" },
|
|
|
|
{ "f4", "menu_options" },
|
|
|
|
{ "f5", "menu_display" },
|
|
|
|
{ "f6", "quicksave" },
|
|
|
|
{ "f7", "menu_endgame" },
|
|
|
|
{ "f8", "togglemessages" },
|
|
|
|
{ "f9", "quickload" },
|
|
|
|
{ "f11", "bumpgamma" },
|
|
|
|
{ "f10", "menu_quit" },
|
|
|
|
{ "tab", "togglemap" },
|
|
|
|
{ "pause", "pause" },
|
|
|
|
{ "sysrq", "screenshot" },
|
|
|
|
{ "t", "messagemode" },
|
|
|
|
{ "\\", "+showscores" },
|
|
|
|
{ "f12", "spynext" },
|
|
|
|
{ "mwheeldown", "weapnext" },
|
|
|
|
{ "mwheelup", "weapprev" },
|
2009-07-23 05:06:38 +00:00
|
|
|
|
|
|
|
// Generic joystick buttons
|
|
|
|
{ "joy1", "+attack" },
|
|
|
|
{ "joy2", "+strafe" },
|
|
|
|
{ "joy3", "+speed" },
|
|
|
|
{ "joy4", "+use" },
|
|
|
|
|
|
|
|
// Xbox 360 / PS2 controllers
|
|
|
|
{ "pad_a", "+use" },
|
|
|
|
{ "pad_y", "+jump" },
|
|
|
|
{ "rtrigger", "+attack" },
|
|
|
|
{ "ltrigger", "+altattack" },
|
|
|
|
{ "lshoulder", "weapprev" },
|
|
|
|
{ "rshoulder", "weapnext" },
|
|
|
|
{ "dpadleft", "invprev" },
|
|
|
|
{ "dpadright", "invnext" },
|
|
|
|
{ "dpaddown", "invuse" },
|
|
|
|
{ "dpadup", "togglemap" },
|
|
|
|
{ "pad_start", "pause" },
|
|
|
|
{ "pad_back", "menu_main" },
|
|
|
|
{ "lthumb", "crouch" },
|
2011-02-19 08:59:43 +00:00
|
|
|
{ NULL, NULL }
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const FBinding DefRavenBindings[] =
|
|
|
|
{
|
|
|
|
{ "pgup", "+moveup" },
|
|
|
|
{ "insert", "+movedown" },
|
|
|
|
{ "home", "land" },
|
|
|
|
{ "pgdn", "+lookup" },
|
|
|
|
{ "del", "+lookdown" },
|
|
|
|
{ "end", "centerview" },
|
2011-02-19 08:59:43 +00:00
|
|
|
{ NULL, NULL }
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2006-04-11 16:27:41 +00:00
|
|
|
static const FBinding DefHereticBindings[] =
|
|
|
|
{
|
|
|
|
{ "backspace", "use ArtiTomeOfPower" },
|
2011-02-19 08:59:43 +00:00
|
|
|
{ NULL, NULL }
|
2006-04-11 16:27:41 +00:00
|
|
|
};
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
static const FBinding DefHexenBindings[] =
|
|
|
|
{
|
|
|
|
{ "/", "+jump" },
|
|
|
|
{ "backspace", "invuseall" },
|
|
|
|
{ "\\", "use ArtiHealth" },
|
|
|
|
{ "0", "useflechette" },
|
|
|
|
{ "9", "use ArtiBlastRadius" },
|
|
|
|
{ "8", "use ArtiTeleport" },
|
|
|
|
{ "7", "use ArtiTeleportOther" },
|
2010-02-12 22:44:54 +00:00
|
|
|
{ "6", "use ArtiPork" },
|
|
|
|
{ "5", "use ArtiInvulnerability2" },
|
2006-02-24 04:48:15 +00:00
|
|
|
{ "scroll", "+showscores" },
|
2011-02-19 08:59:43 +00:00
|
|
|
{ NULL, NULL }
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const FBinding DefStrifeBindings[] =
|
|
|
|
{
|
|
|
|
{ "a", "+jump" },
|
|
|
|
{ "w", "showpop 1" },
|
|
|
|
{ "backspace", "invdrop" },
|
|
|
|
{ "z", "showpop 3" },
|
|
|
|
{ "k", "showpop 2" },
|
2009-02-28 21:38:20 +00:00
|
|
|
{ "q", "invquery" },
|
2011-02-19 08:59:43 +00:00
|
|
|
{ NULL, NULL }
|
2006-02-24 04:48:15 +00:00
|
|
|
// not done
|
|
|
|
// h - use health
|
|
|
|
};
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
static const FBinding DefAutomapBindings[] =
|
|
|
|
{
|
|
|
|
{ "f", "am_togglefollow" },
|
|
|
|
{ "g", "am_togglegrid" },
|
2010-08-28 01:46:26 +00:00
|
|
|
{ "p", "am_toggletexture" },
|
2010-08-27 15:20:05 +00:00
|
|
|
{ "m", "am_setmark" },
|
|
|
|
{ "c", "am_clearmarks" },
|
|
|
|
{ "0", "am_gobig" },
|
|
|
|
{ "rightarrow", "+am_panright" },
|
|
|
|
{ "leftarrow", "+am_panleft" },
|
|
|
|
{ "uparrow", "+am_panup" },
|
|
|
|
{ "downarrow", "+am_pandown" },
|
|
|
|
{ "-", "+am_zoomout" },
|
|
|
|
{ "=", "+am_zoomin" },
|
|
|
|
{ "kp-", "+am_zoomout" },
|
|
|
|
{ "kp+", "+am_zoomin" },
|
2010-09-01 05:03:17 +00:00
|
|
|
{ "mwheelup", "am_zoom 1.2" },
|
|
|
|
{ "mwheeldown", "am_zoom -1.2" },
|
2011-02-19 08:59:43 +00:00
|
|
|
{ NULL, NULL }
|
2010-08-27 15:20:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
const char *KeyNames[NUM_KEYS] =
|
|
|
|
{
|
|
|
|
// This array is dependant on the particular keyboard input
|
|
|
|
// codes generated in i_input.c. If they change there, they
|
|
|
|
// also need to change here. In this case, we use the
|
|
|
|
// DirectInput codes and assume a qwerty keyboard layout.
|
|
|
|
// See <dinput.h> for the DIK_* codes
|
|
|
|
|
|
|
|
NULL, "escape", "1", "2", "3", "4", "5", "6", //00
|
|
|
|
"7", "8", "9", "0", "-", "=", "backspace","tab", //08
|
|
|
|
"q", "w", "e", "r", "t", "y", "u", "i", //10
|
|
|
|
"o", "p", "[", "]", "enter", "ctrl", "a", "s", //18
|
|
|
|
"d", "f", "g", "h", "j", "k", "l", ";", //20
|
|
|
|
"'", "`", "shift", "\\", "z", "x", "c", "v", //28
|
|
|
|
"b", "n", "m", ",", ".", "/", "rshift", "kp*", //30
|
|
|
|
"alt", "space", "capslock", "f1", "f2", "f3", "f4", "f5", //38
|
|
|
|
"f6", "f7", "f8", "f9", "f10", "numlock", "scroll", "kp7", //40
|
|
|
|
"kp8", "kp9", "kp-", "kp4", "kp5", "kp6", "kp+", "kp1", //48
|
|
|
|
"kp2", "kp3", "kp0", "kp.", NULL, NULL, "oem102", "f11", //50
|
|
|
|
"f12", NULL, NULL, NULL, NULL, NULL, NULL, NULL, //58
|
2009-06-06 02:06:38 +00:00
|
|
|
NULL, NULL, NULL, NULL, "f13", "f14", "f15", "f16", //60
|
2006-02-24 04:48:15 +00:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, //68
|
|
|
|
"kana", NULL, NULL, "abnt_c1", NULL, NULL, NULL, NULL, //70
|
|
|
|
NULL, "convert", NULL, "noconvert",NULL, "yen", "abnt_c2", NULL, //78
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, //80
|
|
|
|
NULL, NULL, NULL, NULL, NULL, "kp=", NULL, NULL, //88
|
|
|
|
"circumflex","@", ":", "_", "kanji", "stop", "ax", "unlabeled",//90
|
|
|
|
NULL, "prevtrack",NULL, NULL, "kp-enter", "rctrl", NULL, NULL, //98
|
|
|
|
"mute", "calculator","play", NULL, "stop", NULL, NULL, NULL, //A0
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, "voldown", NULL, //A8
|
|
|
|
"volup", NULL, "webhome", "kp,", NULL, "kp/", NULL, "sysrq", //B0
|
|
|
|
"ralt", NULL, NULL, NULL, NULL, NULL, NULL, NULL, //B8
|
2009-05-27 03:16:46 +00:00
|
|
|
NULL, NULL, NULL, NULL, NULL, "pause", NULL, "home", //C0
|
2006-02-24 04:48:15 +00:00
|
|
|
"uparrow", "pgup", NULL, "leftarrow",NULL, "rightarrow",NULL, "end", //C8
|
|
|
|
"downarrow","pgdn", "ins", "del", NULL, NULL, NULL, NULL, //D0
|
2014-08-03 09:18:15 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
NULL, NULL, NULL, "command", NULL, "apps", "power", "sleep", //D8
|
|
|
|
#else // !__APPLE__
|
2006-02-24 04:48:15 +00:00
|
|
|
NULL, NULL, NULL, "lwin", "rwin", "apps", "power", "sleep", //D8
|
2014-08-03 09:18:15 +00:00
|
|
|
#endif // __APPLE__
|
2006-02-24 04:48:15 +00:00
|
|
|
NULL, NULL, NULL, "wake", NULL, "search", "favorites","refresh", //E0
|
|
|
|
"webstop", "webforward","webback", "mycomputer","mail", "mediaselect",NULL, NULL, //E8
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, //F0
|
2009-05-27 03:16:46 +00:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, //F8
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// non-keyboard buttons that can be bound
|
|
|
|
"mouse1", "mouse2", "mouse3", "mouse4", // 8 mouse buttons
|
|
|
|
"mouse5", "mouse6", "mouse7", "mouse8",
|
|
|
|
|
|
|
|
"joy1", "joy2", "joy3", "joy4", // 128 joystick buttons!
|
|
|
|
"joy5", "joy6", "joy7", "joy8",
|
|
|
|
"joy9", "joy10", "joy11", "joy12",
|
|
|
|
"joy13", "joy14", "joy15", "joy16",
|
|
|
|
"joy17", "joy18", "joy19", "joy20",
|
|
|
|
"joy21", "joy22", "joy23", "joy24",
|
|
|
|
"joy25", "joy26", "joy27", "joy28",
|
|
|
|
"joy29", "joy30", "joy31", "joy32",
|
|
|
|
"joy33", "joy34", "joy35", "joy36",
|
|
|
|
"joy37", "joy38", "joy39", "joy40",
|
|
|
|
"joy41", "joy42", "joy43", "joy44",
|
|
|
|
"joy45", "joy46", "joy47", "joy48",
|
|
|
|
"joy49", "joy50", "joy51", "joy52",
|
|
|
|
"joy53", "joy54", "joy55", "joy56",
|
|
|
|
"joy57", "joy58", "joy59", "joy60",
|
|
|
|
"joy61", "joy62", "joy63", "joy64",
|
|
|
|
"joy65", "joy66", "joy67", "joy68",
|
|
|
|
"joy69", "joy70", "joy71", "joy72",
|
|
|
|
"joy73", "joy74", "joy75", "joy76",
|
|
|
|
"joy77", "joy78", "joy79", "joy80",
|
|
|
|
"joy81", "joy82", "joy83", "joy84",
|
|
|
|
"joy85", "joy86", "joy87", "joy88",
|
|
|
|
"joy89", "joy90", "joy91", "joy92",
|
|
|
|
"joy93", "joy94", "joy95", "joy96",
|
|
|
|
"joy97", "joy98", "joy99", "joy100",
|
|
|
|
"joy101", "joy102", "joy103", "joy104",
|
|
|
|
"joy105", "joy106", "joy107", "joy108",
|
|
|
|
"joy109", "joy110", "joy111", "joy112",
|
|
|
|
"joy113", "joy114", "joy115", "joy116",
|
|
|
|
"joy117", "joy118", "joy119", "joy120",
|
|
|
|
"joy121", "joy122", "joy123", "joy124",
|
|
|
|
"joy125", "joy126", "joy127", "joy128",
|
|
|
|
|
|
|
|
"pov1up", "pov1right","pov1down", "pov1left", // First POV hat
|
|
|
|
"pov2up", "pov2right","pov2down", "pov2left", // Second POV hat
|
|
|
|
"pov3up", "pov3right","pov3down", "pov3left", // Third POV hat
|
|
|
|
"pov4up", "pov4right","pov4down", "pov4left", // Fourth POV hat
|
|
|
|
|
|
|
|
"mwheelup", "mwheeldown", // the mouse wheel
|
2009-06-06 02:55:58 +00:00
|
|
|
"mwheelright", "mwheelleft",
|
2009-06-27 00:35:41 +00:00
|
|
|
|
|
|
|
"axis1plus","axis1minus","axis2plus","axis2minus", // joystick axes as buttons
|
|
|
|
"axis3plus","axis3minus","axis4plus","axis4minus",
|
|
|
|
"axis5plus","axis5minus","axis6plus","axis6minus",
|
|
|
|
"axis7plus","axis7minus","axis8plus","axis8minus",
|
2009-06-28 03:09:17 +00:00
|
|
|
|
|
|
|
"lstickright","lstickleft","lstickdown","lstickup", // Gamepad axis-based buttons
|
|
|
|
"rstickright","rstickleft","rstickdown","rstickup",
|
|
|
|
|
|
|
|
"dpadup","dpaddown","dpadleft","dpadright", // Gamepad buttons
|
|
|
|
"pad_start","pad_back","lthumb","rthumb",
|
|
|
|
"lshoulder","rshoulder","ltrigger","rtrigger",
|
|
|
|
"pad_a", "pad_b", "pad_x", "pad_y"
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
FKeyBindings Bindings;
|
|
|
|
FKeyBindings DoubleBindings;
|
|
|
|
FKeyBindings AutomapBindings;
|
|
|
|
|
2006-04-12 03:03:58 +00:00
|
|
|
static unsigned int DClickTime[NUM_KEYS];
|
2006-09-14 00:02:31 +00:00
|
|
|
static BYTE DClicked[(NUM_KEYS+7)/8];
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
static int GetKeyFromName (const char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// Names of the form #xxx are translated to key xxx automatically
|
|
|
|
if (name[0] == '#' && name[1] != 0)
|
|
|
|
{
|
|
|
|
return atoi (name + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, we scan the KeyNames[] array for a matching name
|
|
|
|
for (i = 0; i < NUM_KEYS; i++)
|
|
|
|
{
|
|
|
|
if (KeyNames[i] && !stricmp (KeyNames[i], name))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
static int GetConfigKeyFromName (const char *key)
|
|
|
|
{
|
|
|
|
int keynum = GetKeyFromName(key);
|
|
|
|
if (keynum == 0)
|
|
|
|
{
|
|
|
|
if (stricmp (key, "LeftBracket") == 0)
|
|
|
|
{
|
|
|
|
keynum = GetKeyFromName ("[");
|
|
|
|
}
|
|
|
|
else if (stricmp (key, "RightBracket") == 0)
|
|
|
|
{
|
|
|
|
keynum = GetKeyFromName ("]");
|
|
|
|
}
|
|
|
|
else if (stricmp (key, "Equals") == 0)
|
|
|
|
{
|
|
|
|
keynum = GetKeyFromName ("=");
|
|
|
|
}
|
|
|
|
else if (stricmp (key, "KP-Equals") == 0)
|
|
|
|
{
|
|
|
|
keynum = GetKeyFromName ("kp=");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return keynum;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
static const char *KeyName (int key)
|
|
|
|
{
|
|
|
|
static char name[5];
|
|
|
|
|
|
|
|
if (KeyNames[key])
|
|
|
|
return KeyNames[key];
|
|
|
|
|
About a week's worth of changes here. As a heads-up, I wouldn't be
surprised if this doesn't build in Linux right now. The CMakeLists.txt
were checked with MinGW and NMake, but how they fair under Linux is an
unknown to me at this time.
- Converted most sprintf (and all wsprintf) calls to either mysnprintf or
FStrings, depending on the situation.
- Changed the strings in the wbstartstruct to be FStrings.
- Changed myvsnprintf() to output nothing if count is greater than INT_MAX.
This is so that I can use a series of mysnprintf() calls and advance the
pointer for each one. Once the pointer goes beyond the end of the buffer,
the count will go negative, but since it's an unsigned type it will be
seen as excessively huge instead. This should not be a problem, as there's
no reason for ZDoom to be using text buffers larger than 2 GB anywhere.
- Ripped out the disabled bit from FGameConfigFile::MigrateOldConfig().
- Changed CalcMapName() to return an FString instead of a pointer to a static
buffer.
- Changed startmap in d_main.cpp into an FString.
- Changed CheckWarpTransMap() to take an FString& as the first argument.
- Changed d_mapname in g_level.cpp into an FString.
- Changed DoSubstitution() in ct_chat.cpp to place the substitutions in an
FString.
- Fixed: The MAPINFO parser wrote into the string buffer to construct a map
name when given a Hexen map number. This was fine with the old scanner
code, but only a happy coincidence prevents it from crashing with the new
code
- Added the 'B' conversion specifier to StringFormat::VWorker() for printing
binary numbers.
- Added CMake support for building with MinGW, MSYS, and NMake. Linux support
is probably broken until I get around to booting into Linux again. Niceties
provided over the existing Makefiles they're replacing:
* All command-line builds can use the same build system, rather than having
a separate one for MinGW and another for Linux.
* Microsoft's NMake tool is supported as a target.
* Progress meters.
* Parallel makes work from a fresh checkout without needing to be primed
first with a single-threaded make.
* Porting to other architectures should be simplified, whenever that day
comes.
- Replaced the makewad tool with zipdir. This handles the dependency tracking
itself instead of generating an external makefile to do it, since I couldn't
figure out how to generate a makefile with an external tool and include it
with a CMake-generated makefile. Where makewad used a master list of files
to generate the package file, zipdir just zips the entire contents of one or
more directories.
- Added the gdtoa package from netlib's fp library so that ZDoom's printf-style
formatting can be entirely independant of the CRT.
SVN r1082 (trunk)
2008-07-23 04:57:26 +00:00
|
|
|
mysnprintf (name, countof(name), "#%d", key);
|
2006-02-24 04:48:15 +00:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
static const char *ConfigKeyName(int keynum)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
const char *name = KeyName(keynum);
|
|
|
|
if (name[1] == 0) // Make sure given name is config-safe
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
if (name[0] == '[')
|
|
|
|
return "LeftBracket";
|
|
|
|
else if (name[0] == ']')
|
|
|
|
return "RightBracket";
|
|
|
|
else if (name[0] == '=')
|
|
|
|
return "Equals";
|
|
|
|
else if (strcmp (name, "kp=") == 0)
|
|
|
|
return "KP-Equals";
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
return name;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void C_NameKeys (char *str, int first, int second)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
int c = 0;
|
|
|
|
|
|
|
|
*str = 0;
|
|
|
|
if (first)
|
|
|
|
{
|
|
|
|
c++;
|
|
|
|
strcpy (str, KeyName (first));
|
|
|
|
if (second)
|
|
|
|
strcat (str, " or ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (second)
|
|
|
|
{
|
|
|
|
c++;
|
|
|
|
strcat (str, KeyName (second));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!c)
|
|
|
|
*str = '\0';
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void FKeyBindings::DoBind (const char *key, const char *bind)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
int keynum = GetConfigKeyFromName (key);
|
|
|
|
if (keynum != 0)
|
|
|
|
{
|
|
|
|
Binds[keynum] = bind;
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void FKeyBindings::SetBinds(const FBinding *binds)
|
|
|
|
{
|
|
|
|
while (binds->Key)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
DoBind (binds->Key, binds->Bind);
|
|
|
|
binds++;
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void FKeyBindings::UnbindAll ()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < NUM_KEYS; ++i)
|
|
|
|
{
|
|
|
|
Binds[i] = "";
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void FKeyBindings::UnbindKey(const char *key)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ( (i = GetKeyFromName (key)) )
|
|
|
|
{
|
|
|
|
Binds[i] = "";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Printf ("Unknown key \"%s\"\n", key);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void FKeyBindings::PerformBind(FCommandLine &argv, const char *msg)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (argv.argc() > 1)
|
|
|
|
{
|
|
|
|
i = GetKeyFromName (argv[1]);
|
|
|
|
if (!i)
|
|
|
|
{
|
|
|
|
Printf ("Unknown key \"%s\"\n", argv[1]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (argv.argc() == 2)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
Printf ("\"%s\" = \"%s\"\n", argv[1], Binds[i].GetChars());
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
Binds[i] = argv[2];
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
Printf ("%s:\n", msg);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_KEYS; i++)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
if (!Binds[i].IsEmpty())
|
|
|
|
Printf ("%s \"%s\"\n", KeyName (i), Binds[i].GetChars());
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
|
|
|
|
//=============================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
2010-08-27 15:20:05 +00:00
|
|
|
// This function is first called for functions in custom key sections.
|
|
|
|
// In this case, matchcmd is non-NULL, and only keys bound to that command
|
|
|
|
// are stored. If a match is found, its binding is set to "\1".
|
|
|
|
// After all custom key sections are saved, it is called one more for the
|
|
|
|
// normal Bindings and DoubleBindings sections for this game. In this case
|
|
|
|
// matchcmd is NULL and all keys will be stored. The config section was not
|
|
|
|
// previously cleared, so all old bindings are still in place. If the binding
|
|
|
|
// for a key is empty, the corresponding key in the config is removed as well.
|
|
|
|
// If a binding is "\1", then the binding itself is cleared, but nothing
|
|
|
|
// happens to the entry in the config.
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
void FKeyBindings::ArchiveBindings(FConfigFile *f, const char *matchcmd)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_KEYS; i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
if (Binds[i].IsEmpty())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
if (matchcmd == NULL)
|
|
|
|
{
|
|
|
|
f->ClearKey(ConfigKeyName(i));
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
else if (matchcmd == NULL || stricmp(Binds[i], matchcmd) == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
if (Binds[i][0] == '\1')
|
|
|
|
{
|
|
|
|
Binds[i] = "";
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
f->SetValueForKey(ConfigKeyName(i), Binds[i]);
|
|
|
|
if (matchcmd != NULL)
|
|
|
|
{ // If saving a specific command, set a marker so that
|
|
|
|
// it does not get saved in the general binding list.
|
|
|
|
Binds[i] = "\1";
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2010-09-14 17:28:18 +00:00
|
|
|
int FKeyBindings::GetKeysForCommand (const char *cmd, int *first, int *second)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
int c, i;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
*first = *second = c = i = 0;
|
|
|
|
|
|
|
|
while (i < NUM_KEYS && c < 2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
if (stricmp (cmd, Binds[i]) == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
if (c++ == 0)
|
|
|
|
*first = i;
|
|
|
|
else
|
|
|
|
*second = i;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2010-09-14 17:28:18 +00:00
|
|
|
void FKeyBindings::UnbindACommand (const char *str)
|
2010-08-27 15:20:05 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_KEYS; i++)
|
|
|
|
{
|
|
|
|
if (!stricmp (str, Binds[i]))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
Binds[i] = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void FKeyBindings::DefaultBind(const char *keyname, const char *cmd)
|
|
|
|
{
|
|
|
|
int key = GetKeyFromName (keyname);
|
|
|
|
if (key == 0)
|
|
|
|
{
|
|
|
|
Printf ("Unknown key \"%s\"\n", keyname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!Binds[key].IsEmpty())
|
|
|
|
{ // This key is already bound.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < NUM_KEYS; ++i)
|
|
|
|
{
|
|
|
|
if (!Binds[i].IsEmpty() && stricmp (Binds[i], cmd) == 0)
|
|
|
|
{ // This command is already bound to a key.
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
}
|
|
|
|
// It is safe to do the bind, so do it.
|
|
|
|
Binds[key] = cmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
void C_UnbindAll ()
|
|
|
|
{
|
|
|
|
Bindings.UnbindAll();
|
|
|
|
DoubleBindings.UnbindAll();
|
|
|
|
AutomapBindings.UnbindAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
CCMD (unbindall)
|
|
|
|
{
|
|
|
|
C_UnbindAll ();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
CCMD (unbind)
|
|
|
|
{
|
|
|
|
if (argv.argc() > 1)
|
|
|
|
{
|
|
|
|
Bindings.UnbindKey(argv[1]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
CCMD (undoublebind)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
if (argv.argc() > 1)
|
|
|
|
{
|
|
|
|
DoubleBindings.UnbindKey(argv[1]);
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
CCMD (unmapbind)
|
|
|
|
{
|
2006-02-24 04:48:15 +00:00
|
|
|
if (argv.argc() > 1)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
AutomapBindings.UnbindKey(argv[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
CCMD (bind)
|
|
|
|
{
|
|
|
|
Bindings.PerformBind(argv, "Current key bindings");
|
|
|
|
}
|
|
|
|
|
|
|
|
CCMD (doublebind)
|
|
|
|
{
|
|
|
|
DoubleBindings.PerformBind(argv, "Current key doublebindings");
|
|
|
|
}
|
|
|
|
|
|
|
|
CCMD (mapbind)
|
|
|
|
{
|
|
|
|
AutomapBindings.PerformBind(argv, "Current automap key bindings");
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// CCMD defaultbind
|
|
|
|
//
|
|
|
|
// Binds a command to a key if that key is not already bound and if
|
|
|
|
// that command is not already bound to another key.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
CCMD (defaultbind)
|
|
|
|
{
|
|
|
|
if (argv.argc() < 3)
|
|
|
|
{
|
|
|
|
Printf ("Usage: defaultbind <key> <command>\n");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
Bindings.DefaultBind(argv[1], argv[2]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
CCMD (rebind)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
FKeyBindings *bindings;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (key == 0)
|
|
|
|
{
|
|
|
|
Printf ("Rebind cannot be used from the console\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key & KEY_DBLCLICKED)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
bindings = &DoubleBindings;
|
2006-02-24 04:48:15 +00:00
|
|
|
key &= KEY_DBLCLICKED-1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
bindings = &Bindings;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (argv.argc() > 1)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
bindings->SetBind(key, argv[1]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void C_BindDefaults ()
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
Bindings.SetBinds (DefBindings);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (gameinfo.gametype & (GAME_Raven|GAME_Strife))
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
Bindings.SetBinds (DefRavenBindings);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-04-11 16:27:41 +00:00
|
|
|
if (gameinfo.gametype == GAME_Heretic)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
Bindings.SetBinds (DefHereticBindings);
|
2006-04-11 16:27:41 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (gameinfo.gametype == GAME_Hexen)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
Bindings.SetBinds (DefHexenBindings);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gameinfo.gametype == GAME_Strife)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
Bindings.SetBinds (DefStrifeBindings);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
|
|
|
|
AutomapBindings.SetBinds(DefAutomapBindings);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CCMD(binddefaults)
|
|
|
|
{
|
|
|
|
C_BindDefaults ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void C_SetDefaultBindings ()
|
|
|
|
{
|
|
|
|
C_UnbindAll ();
|
|
|
|
C_BindDefaults ();
|
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-05-16 02:50:18 +00:00
|
|
|
FString binding;
|
2006-02-24 04:48:15 +00:00
|
|
|
bool dclick;
|
|
|
|
int dclickspot;
|
2006-09-14 00:02:31 +00:00
|
|
|
BYTE dclickmask;
|
2012-02-11 01:44:56 +00:00
|
|
|
unsigned int nowtime;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (ev->type != EV_KeyDown && ev->type != EV_KeyUp)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ((unsigned int)ev->data1 >= NUM_KEYS)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
dclickspot = ev->data1 >> 3;
|
|
|
|
dclickmask = 1 << (ev->data1 & 7);
|
|
|
|
dclick = false;
|
|
|
|
|
|
|
|
// This used level.time which didn't work outside a level.
|
2012-02-11 01:44:56 +00:00
|
|
|
nowtime = I_MSTime();
|
|
|
|
if (doublebinds != NULL && DClickTime[ev->data1] > nowtime && ev->type == EV_KeyDown)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// Key pressed for a double click
|
2012-02-11 01:44:56 +00:00
|
|
|
binding = doublebinds->GetBinding(ev->data1);
|
2006-02-24 04:48:15 +00:00
|
|
|
DClicked[dclickspot] |= dclickmask;
|
|
|
|
dclick = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ev->type == EV_KeyDown)
|
|
|
|
{ // Key pressed for a normal press
|
2010-08-27 15:20:05 +00:00
|
|
|
binding = binds->GetBinding(ev->data1);
|
2012-02-11 01:44:56 +00:00
|
|
|
DClickTime[ev->data1] = nowtime + 571;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2012-02-11 01:44:56 +00:00
|
|
|
else if (doublebinds != NULL && DClicked[dclickspot] & dclickmask)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Key released from a double click
|
2012-02-11 01:44:56 +00:00
|
|
|
binding = doublebinds->GetBinding(ev->data1);
|
2006-02-24 04:48:15 +00:00
|
|
|
DClicked[dclickspot] &= ~dclickmask;
|
|
|
|
DClickTime[ev->data1] = 0;
|
|
|
|
dclick = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Key released from a normal press
|
2010-08-27 15:20:05 +00:00
|
|
|
binding = binds->GetBinding(ev->data1);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-07 00:27:22 +00:00
|
|
|
|
2006-05-16 02:50:18 +00:00
|
|
|
if (binding.IsEmpty())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
binding = binds->GetBinding(ev->data1);
|
2006-02-24 04:48:15 +00:00
|
|
|
dclick = false;
|
|
|
|
}
|
|
|
|
|
2006-05-16 02:50:18 +00:00
|
|
|
if (!binding.IsEmpty() && (chatmodeon == 0 || ev->data1 < 256))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-05-16 02:50:18 +00:00
|
|
|
if (ev->type == EV_KeyUp && binding[0] != '+')
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-05-16 02:50:18 +00:00
|
|
|
return false;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-16 02:50:18 +00:00
|
|
|
char *copy = binding.LockBuffer();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (ev->type == EV_KeyUp)
|
|
|
|
{
|
2006-05-16 02:50:18 +00:00
|
|
|
copy[0] = '-';
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-05-16 02:50:18 +00:00
|
|
|
|
|
|
|
AddCommandString (copy, dclick ? ev->data1 | KEY_DBLCLICKED : ev->data1);
|
2006-02-24 04:48:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|