ddnet/src/engine/client/input.h

76 lines
2.2 KiB
C
Raw Normal View History

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 ENGINE_CLIENT_INPUT_H
#define ENGINE_CLIENT_INPUT_H
#include <engine/graphics.h>
#include <engine/input.h>
#include <engine/keys.h>
2010-05-29 07:25:38 +00:00
class CInput : public IEngineInput
{
IEngineGraphics *m_pGraphics;
int m_InputGrabbed;
char *m_pClipboardText;
2010-05-29 07:25:38 +00:00
bool m_MouseFocus;
bool m_MouseDoubleClick;
2014-06-16 11:29:18 +00:00
int m_VideoRestartNeeded;
2016-04-30 02:02:32 +00:00
void AddEvent(char *pText, int Key, int Flags);
void Clear() override;
bool IsEventValid(CEvent *pEvent) const override { return pEvent->m_InputCount == m_InputCounter; }
// quick access to input
2020-09-22 16:02:03 +00:00
unsigned short m_aInputCount[g_MaxKeys]; // tw-KEY
unsigned char m_aInputState[g_MaxKeys]; // SDL_SCANCODE
int m_InputCounter;
2022-06-06 18:18:33 +00:00
void UpdateMouseState();
// IME support
int m_NumTextInputInstances;
char m_aEditingText[INPUT_TEXT_SIZE];
int m_EditingTextLen;
int m_EditingCursor;
bool KeyState(int Key) const;
2010-05-29 07:25:38 +00:00
IEngineGraphics *Graphics() { return m_pGraphics; }
public:
CInput();
~CInput();
2010-05-29 07:25:38 +00:00
void Init() override;
2010-05-29 07:25:38 +00:00
bool ModifierIsPressed() const override { return KeyState(KEY_LCTRL) || KeyState(KEY_RCTRL) || KeyState(KEY_LGUI) || KeyState(KEY_RGUI); }
bool KeyIsPressed(int Key) const override { return KeyState(Key); }
bool KeyPress(int Key, bool CheckCounter) const override { return CheckCounter ? (m_aInputCount[Key] == m_InputCounter) : m_aInputCount[Key]; }
bool MouseRelative(float *pX, float *pY) override;
void MouseModeAbsolute() override;
void MouseModeRelative() override;
void NativeMousePos(int *pX, int *pY) const override;
bool NativeMousePressed(int Index) override;
bool MouseDoubleClick() override;
const char *GetClipboardText() override;
void SetClipboardText(const char *pText) override;
2010-05-29 07:25:38 +00:00
int Update() override;
2014-06-16 11:29:18 +00:00
int VideoRestartNeeded() override;
bool GetIMEState() override;
void SetIMEState(bool Activate) override;
int GetIMEEditingTextLength() const override { return m_EditingTextLen; }
const char *GetIMEEditingText() override;
int GetEditingCursor() override;
void SetEditingPosition(float X, float Y) override;
2010-05-29 07:25:38 +00:00
};
#endif