OpenRCT2/src/openrct2-ui/input/InputManager.h

68 lines
1.6 KiB
C
Raw Normal View History

2020-12-13 04:40:10 +01:00
/*****************************************************************************
* Copyright (c) 2014-2020 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
2020-12-15 20:55:49 +01:00
#include <openrct2/world/Location.hpp>
2020-12-13 04:40:10 +01:00
#include <queue>
2020-12-16 00:14:40 +01:00
typedef struct _SDL_Joystick SDL_Joystick;
typedef union SDL_Event SDL_Event;
2020-12-13 04:40:10 +01:00
namespace OpenRCT2::Ui
{
enum class InputDeviceKind
{
Mouse,
Keyboard,
2020-12-16 00:14:40 +01:00
JoyButton,
JoyHat,
2020-12-13 04:40:10 +01:00
};
enum class InputEventState
{
Down,
Release,
};
struct InputEvent
{
InputDeviceKind DeviceKind;
2020-12-13 23:51:50 +01:00
uint32_t Modifiers;
2020-12-13 04:40:10 +01:00
uint32_t Button;
InputEventState State;
};
class InputManager
{
private:
2020-12-16 00:14:40 +01:00
uint32_t _lastJoystickCheck;
std::vector<SDL_Joystick*> _joysticks;
2020-12-13 04:40:10 +01:00
std::queue<InputEvent> _events;
2020-12-15 20:55:49 +01:00
ScreenCoordsXY _viewScroll;
2020-12-13 04:40:10 +01:00
2020-12-16 00:14:40 +01:00
void CheckJoysticks();
2020-12-15 20:55:49 +01:00
void HandleViewScrolling();
2020-12-15 00:12:19 +01:00
void HandleModifiers();
void ProcessEvents();
2020-12-13 04:40:10 +01:00
void Process(const InputEvent& e);
2020-12-15 00:12:19 +01:00
void ProcessInGameConsole(const InputEvent& e);
void ProcessChat(const InputEvent& e);
2020-12-13 04:40:10 +01:00
public:
2020-12-16 00:14:40 +01:00
void QueueInputEvent(const SDL_Event& e);
2020-12-13 04:40:10 +01:00
void QueueInputEvent(InputEvent&& e);
void Process();
};
InputManager& GetInputManager();
} // namespace OpenRCT2::Ui