1 /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2 /* If you are missing that file, acquire a complete release at teeworlds.com. */
8 extern const char g_aaKeyStrings
[512][16];
10 class IInput
: public IInterface
12 MACRO_INTERFACE("input", 0)
28 // quick access to events
30 IInput::CEvent m_aInputEvents
[INPUT_BUFFER_SIZE
];
32 //quick access to input
35 unsigned char m_Presses
;
36 unsigned char m_Releases
;
37 } m_aInputCount
[2][1024];
39 unsigned char m_aInputState
[2][1024];
42 int KeyWasPressed(int Key
) { return m_aInputState
[m_InputCurrent
^1][Key
]; }
53 int NumEvents() const { return m_NumEvents
; }
54 void ClearEvents() { m_NumEvents
= 0; }
55 CEvent
GetEvent(int Index
) const
57 if(Index
< 0 || Index
>= m_NumEvents
)
59 IInput::CEvent e
= {0,0};
62 return m_aInputEvents
[Index
];
66 int KeyPressed(int Key
) { return m_aInputState
[m_InputCurrent
][Key
]; }
67 int KeyReleases(int Key
) { return m_aInputCount
[m_InputCurrent
][Key
].m_Releases
; }
68 int KeyPresses(int Key
) { return m_aInputCount
[m_InputCurrent
][Key
].m_Presses
; }
69 int KeyDown(int Key
) { return KeyPressed(Key
)&&!KeyWasPressed(Key
); }
70 const char *KeyName(int Key
) { return (Key
>= 0 && Key
< 512) ? g_aaKeyStrings
[Key
] : g_aaKeyStrings
[0]; }
73 virtual void MouseModeRelative() = 0;
74 virtual void MouseModeAbsolute() = 0;
75 virtual int MouseDoubleClick() = 0;
77 virtual void MouseRelative(float *x
, float *y
) = 0;
81 class IEngineInput
: public IInput
83 MACRO_INTERFACE("engineinput", 0)
85 virtual void Init() = 0;
86 virtual int Update() = 0;
89 extern IEngineInput
*CreateEngineInput();