1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Replaced SDL user events list with dispatching of arbitrary functors

This commit is contained in:
Ivan Savenko
2023-06-26 21:51:10 +03:00
parent 7fc66c2797
commit 0f8d53e978
15 changed files with 176 additions and 177 deletions

View File

@@ -15,12 +15,12 @@
enum class EUserEvent;
enum class MouseButton;
union SDL_Event;
struct SDL_UserEvent;
class InputSourceMouse;
class InputSourceKeyboard;
class InputSourceTouch;
class InputSourceText;
class UserEventHandler;
class InputHandler
{
@@ -31,12 +31,12 @@ class InputHandler
void preprocessEvent(const SDL_Event & event);
void handleCurrentEvent(const SDL_Event & current);
void handleUserEvent(const SDL_UserEvent & current);
std::unique_ptr<InputSourceMouse> mouseHandler;
std::unique_ptr<InputSourceKeyboard> keyboardHandler;
std::unique_ptr<InputSourceTouch> fingerHandler;
std::unique_ptr<InputSourceText> textHandler;
std::unique_ptr<UserEventHandler> userHandler;
public:
InputHandler();
@@ -66,8 +66,8 @@ public:
/// returns true if system has active touchscreen
bool hasTouchInputDevice() const;
/// Generates new user event that will be processed on next frame
void pushUserEvent(EUserEvent usercode, void * userdata);
/// Calls provided functor in main thread on next execution frame
void dispatchMainThread(const std::function<void()> & functor);
/// Returns current position of cursor, in VCMI logical screen coordinates
const Point & getCursorPosition() const;