about summary refs log tree commit diff
path: root/src/game/client/components/binds.h
blob: ad51a47c4422ce93d3122d0f98e6fa0003fbc8c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* (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.                */
#ifndef GAME_CLIENT_COMPONENTS_BINDS_H
#define GAME_CLIENT_COMPONENTS_BINDS_H
#include <game/client/component.h>
#include <engine/keys.h>

class CBinds : public CComponent
{
	char m_aaKeyBindings[KEY_LAST][128];

	int GetKeyID(const char *pKeyName);

	static void ConBind(IConsole::IResult *pResult, void *pUserData);
	static void ConUnbind(IConsole::IResult *pResult, void *pUserData);
	static void ConUnbindAll(IConsole::IResult *pResult, void *pUserData);
	static void ConDumpBinds(IConsole::IResult *pResult, void *pUserData);
	class IConsole *GetConsole() const { return Console(); }
	
	static void ConfigSaveCallback(class IConfig *pConfig, void *pUserData);
	
public:
	CBinds();
	
	class CBindsSpecial : public CComponent
	{
	public:
		CBinds *m_pBinds;
		virtual bool OnInput(IInput::CEvent Event);
	};
	
	CBindsSpecial m_SpecialBinds;
	
	void Bind(int KeyID, const char *pStr);
	void SetDefaults();
	void UnbindAll();
	const char *Get(int KeyID);
	const char *GetKey(const char *pBindStr);
	
	virtual void OnConsoleInit();
	virtual bool OnInput(IInput::CEvent Event);
};
#endif