ddnet/src/engine/client/input.h

79 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>
#include <stddef.h>
2010-05-29 07:25:38 +00:00
class CInput : public IEngineInput
{
IEngineGraphics *m_pGraphics;
int m_LastX;
int m_LastY;
int m_InputGrabbed;
char *m_pClipboardText;
2010-05-29 07:25:38 +00:00
2021-06-23 05:05:49 +00:00
int64_t m_LastRelease;
int64_t m_ReleaseDelta;
2010-05-29 07:25:38 +00:00
bool m_MouseFocus;
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();
bool IsEventValid(CEvent *pEvent) const { 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;
// 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();
virtual void Init();
bool ModifierIsPressed() const { return KeyState(KEY_LCTRL) || KeyState(KEY_RCTRL) || KeyState(KEY_LGUI) || KeyState(KEY_RGUI); }
bool KeyIsPressed(int Key) const { return KeyState(Key); }
bool KeyPress(int Key, bool CheckCounter) const { return CheckCounter ? (m_aInputCount[Key] == m_InputCounter) : m_aInputCount[Key]; }
virtual void MouseRelative(float *x, float *y);
virtual void MouseModeAbsolute();
virtual void MouseModeRelative();
2021-09-12 17:32:00 +00:00
virtual void NativeMousePos(int *x, int *y) const;
virtual bool NativeMousePressed(int index);
2010-05-29 07:25:38 +00:00
virtual int MouseDoubleClick();
2020-09-22 16:02:03 +00:00
virtual const char *GetClipboardText();
virtual void SetClipboardText(const char *Text);
2010-05-29 07:25:38 +00:00
virtual int Update();
virtual void NextFrame();
2014-06-16 11:29:18 +00:00
virtual int VideoRestartNeeded();
virtual bool GetIMEState();
virtual void SetIMEState(bool Activate);
int GetIMEEditingTextLength() const { return m_EditingTextLen; }
virtual const char *GetIMEEditingText();
virtual int GetEditingCursor();
virtual void SetEditingPosition(float X, float Y);
2010-05-29 07:25:38 +00:00
};
#endif