2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_CLIENT_COMPONENTS_BINDS_H
|
|
|
|
#define GAME_CLIENT_COMPONENTS_BINDS_H
|
|
|
|
#include <engine/keys.h>
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <game/client/component.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
class CBinds : public CComponent
|
|
|
|
{
|
2011-02-12 10:40:36 +00:00
|
|
|
int GetKeyID(const char *pKeyName);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
static void ConBind(IConsole::IResult *pResult, void *pUserData);
|
2017-03-06 17:06:55 +00:00
|
|
|
static void ConDumpBinds(IConsole::IResult *pResult, void *pUserData);
|
2011-08-13 00:11:06 +00:00
|
|
|
static void ConUnbind(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void ConUnbindAll(IConsole::IResult *pResult, void *pUserData);
|
2010-05-29 07:25:38 +00:00
|
|
|
class IConsole *GetConsole() const { return Console(); }
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
static void ConfigSaveCallback(class IConfig *pConfig, void *pUserData);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
|
|
|
CBinds();
|
2017-04-11 23:36:48 +00:00
|
|
|
~CBinds();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CBindsSpecial : public CComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CBinds *m_pBinds;
|
|
|
|
virtual bool OnInput(IInput::CEvent Event);
|
|
|
|
};
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-09-04 20:48:39 +00:00
|
|
|
MODIFIER_NONE = 0,
|
2019-04-28 13:32:14 +00:00
|
|
|
MODIFIER_SHIFT,
|
|
|
|
MODIFIER_CTRL,
|
|
|
|
MODIFIER_ALT,
|
2020-09-04 20:48:39 +00:00
|
|
|
MODIFIER_COUNT,
|
|
|
|
MODIFIER_COMBINATION_COUNT = 1 << MODIFIER_COUNT
|
2019-04-28 13:32:14 +00:00
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CBindsSpecial m_SpecialBinds;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2019-04-28 13:32:14 +00:00
|
|
|
void Bind(int KeyID, const char *pStr, bool FreeOnly = false, int Modifier = MODIFIER_NONE);
|
2010-05-29 07:25:38 +00:00
|
|
|
void SetDefaults();
|
|
|
|
void UnbindAll();
|
2019-04-28 13:32:14 +00:00
|
|
|
const char *Get(int KeyID, int Modifier);
|
|
|
|
void GetKey(const char *pBindStr, char *aBuf, unsigned BufSize);
|
|
|
|
int GetBindSlot(const char *pBindString, int *Modifier);
|
2019-04-28 17:22:19 +00:00
|
|
|
static int GetModifierMask(IInput *i);
|
|
|
|
static int GetModifierMaskOfKey(int Key);
|
|
|
|
static bool ModifierMatchesKey(int Modifier, int Key);
|
|
|
|
static const char *GetModifierName(int Modifier);
|
2020-09-04 20:48:39 +00:00
|
|
|
static const char *GetKeyBindModifiersName(int Modifier);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void OnConsoleInit();
|
|
|
|
virtual bool OnInput(IInput::CEvent Event);
|
2011-04-17 17:14:49 +00:00
|
|
|
|
|
|
|
// DDRace
|
|
|
|
|
|
|
|
void SetDDRaceBinds(bool FreeOnly);
|
2019-04-28 13:32:14 +00:00
|
|
|
|
|
|
|
private:
|
2020-09-04 20:48:39 +00:00
|
|
|
char *m_aapKeyBindings[MODIFIER_COMBINATION_COUNT][KEY_LAST];
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
#endif
|