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
|
|
|
|
|
Make sure headers compile standalone
Not planning to do this automatically, but at least cleaning it up once
provides some benefit. Every header should include what it uses.
$ for i in src/**/*.h; do j=${i#"src/"}; echo $j; echo "#include <$j>\nint main() { return 0; }" | /usr/bin/c++ -DCONF_OPENSSL -DCONF_SQL -DCONF_VIDEORECORDER -DCONF_WAVPACK_CLOSE_FILE -DCONF_WAVPACK_OPEN_FILE_INPUT_EX -DGAME_RELEASE_VERSION=\"15.0.5\" -DGLEW_STATIC -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/SDL2 -I/usr/include/wavpack -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -Isrc -I/usr/include/mysql -I/home/deen/sys/include/ -O2 -g -DNDEBUG -fdiagnostics-color=always -fstack-protector-all -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wno-nullability-completeness -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -std=gnu++11 -o /dev/null -x c++ -; done
Ignored: tuning.h, variables.h, config_common.h, mapitems_ex_types.h, mapbugs_list.h, protocol7.h, teehistorian_ex_chunks.h, protocol_ex_msgs.h, config.h, config_variables.h, external, keynames.h
2020-09-26 08:23:33 +00:00
|
|
|
#include <engine/graphics.h>
|
|
|
|
#include <engine/input.h>
|
2021-12-18 11:23:20 +00:00
|
|
|
#include <engine/keys.h>
|
Make sure headers compile standalone
Not planning to do this automatically, but at least cleaning it up once
provides some benefit. Every header should include what it uses.
$ for i in src/**/*.h; do j=${i#"src/"}; echo $j; echo "#include <$j>\nint main() { return 0; }" | /usr/bin/c++ -DCONF_OPENSSL -DCONF_SQL -DCONF_VIDEORECORDER -DCONF_WAVPACK_CLOSE_FILE -DCONF_WAVPACK_OPEN_FILE_INPUT_EX -DGAME_RELEASE_VERSION=\"15.0.5\" -DGLEW_STATIC -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/SDL2 -I/usr/include/wavpack -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -Isrc -I/usr/include/mysql -I/home/deen/sys/include/ -O2 -g -DNDEBUG -fdiagnostics-color=always -fstack-protector-all -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wno-nullability-completeness -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -std=gnu++11 -o /dev/null -x c++ -; done
Ignored: tuning.h, variables.h, config_common.h, mapitems_ex_types.h, mapbugs_list.h, protocol7.h, teehistorian_ex_chunks.h, protocol_ex_msgs.h, config.h, config_variables.h, external, keynames.h
2020-09-26 08:23:33 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CInput : public IEngineInput
|
|
|
|
{
|
|
|
|
IEngineGraphics *m_pGraphics;
|
|
|
|
|
2021-10-23 11:48:21 +00:00
|
|
|
int m_InputGrabbed;
|
2015-08-25 12:24:46 +00:00
|
|
|
char *m_pClipboardText;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2016-05-01 12:00:53 +00:00
|
|
|
bool m_MouseFocus;
|
2019-01-06 09:23:25 +00:00
|
|
|
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);
|
2022-05-17 20:13:44 +00:00
|
|
|
void Clear() override;
|
|
|
|
bool IsEventValid(CEvent *pEvent) const override { return pEvent->m_InputCount == m_InputCounter; }
|
2016-04-30 18:11:26 +00:00
|
|
|
|
2017-07-26 01:58:00 +00:00
|
|
|
// 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
|
2016-04-30 18:11:26 +00:00
|
|
|
int m_InputCounter;
|
|
|
|
|
2022-06-06 18:18:33 +00:00
|
|
|
void UpdateMouseState();
|
|
|
|
|
2017-07-26 01:58:00 +00:00
|
|
|
// IME support
|
2020-10-25 15:48:12 +00:00
|
|
|
int m_NumTextInputInstances;
|
|
|
|
char m_aEditingText[INPUT_TEXT_SIZE];
|
2020-09-22 16:01:13 +00:00
|
|
|
int m_EditingTextLen;
|
2016-08-15 04:01:31 +00:00
|
|
|
int m_EditingCursor;
|
|
|
|
|
2016-04-30 18:11:26 +00:00
|
|
|
bool KeyState(int Key) const;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
IEngineGraphics *Graphics() { return m_pGraphics; }
|
|
|
|
|
|
|
|
public:
|
|
|
|
CInput();
|
2022-06-06 18:29:03 +00:00
|
|
|
~CInput();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2022-05-17 20:13:44 +00:00
|
|
|
void Init() override;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2022-05-17 20:13:44 +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]; }
|
2016-04-29 19:51:54 +00:00
|
|
|
|
2022-06-06 18:10:46 +00:00
|
|
|
bool MouseRelative(float *pX, float *pY) override;
|
2022-05-17 20:13:44 +00:00
|
|
|
void MouseModeAbsolute() override;
|
|
|
|
void MouseModeRelative() override;
|
2022-06-06 17:58:03 +00:00
|
|
|
void NativeMousePos(int *pX, int *pY) const override;
|
|
|
|
bool NativeMousePressed(int Index) override;
|
2022-05-17 20:13:44 +00:00
|
|
|
bool MouseDoubleClick() override;
|
2022-06-06 17:58:03 +00:00
|
|
|
|
2022-05-17 20:13:44 +00:00
|
|
|
const char *GetClipboardText() override;
|
2022-06-06 17:58:03 +00:00
|
|
|
void SetClipboardText(const char *pText) override;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2022-05-17 20:13:44 +00:00
|
|
|
int Update() override;
|
2014-06-16 11:29:18 +00:00
|
|
|
|
2022-05-17 20:13:44 +00:00
|
|
|
int VideoRestartNeeded() override;
|
2016-08-15 04:01:31 +00:00
|
|
|
|
2022-05-17 20:13:44 +00:00
|
|
|
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
|