forked from OpenLoco/OpenLoco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Input.h
157 lines (133 loc) · 4.5 KB
/
Input.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#pragma once
#include "Ui/WindowManager.h"
#include "Window.h"
#include <OpenLoco/Core/EnumFlags.hpp>
#include <OpenLoco/Engine/Ui/Point.hpp>
namespace OpenLoco::Input
{
enum class MouseButton : uint16_t
{
released = 0,
leftPressed = 1,
leftReleased = 2,
rightPressed = 3,
rightReleased = 4,
};
enum class State : uint8_t
{
reset, // 0
normal, // 1
widgetPressed, // 2
positioningWindow, // 3
viewportRight, // 4
dropdownActive, // 5
viewportLeft, // 6
scrollLeft, // 7
resizing, // 8
scrollRight, // 9
};
// TODO: move this
enum class ScreenshotType : uint8_t
{
regular = 0,
giant = 1,
};
enum class Flags : uint32_t
{
none = 0U,
widgetPressed = 1U << 0,
flag1 = 1U << 1,
flag2 = 1U << 2,
toolActive = 1U << 3,
flag4 = 1U << 4,
flag5 = 1U << 5,
flag6 = 1U << 6,
viewportScrolling = 1U << 7,
};
OPENLOCO_ENABLE_ENUM_OPERATORS(Flags);
enum class MapSelectionFlags : uint8_t
{
none = 0U,
enable = 1U << 0,
enableConstruct = 1U << 1,
enableConstructionArrow = 1U << 2,
unk_03 = 1U << 3,
unk_04 = 1U << 4, // Vehicle orders?
catchmentArea = 1U << 5,
hoveringOverStation = 1U << 6,
};
OPENLOCO_ENABLE_ENUM_OPERATORS(MapSelectionFlags);
enum class KeyModifier : uint8_t
{
none = 0U,
shift = 1U << 0,
control = 1U << 1,
unknown = 1U << 2,
cheat = 1U << 7,
invalid = 0xFF,
};
OPENLOCO_ENABLE_ENUM_OPERATORS(KeyModifier);
void init();
void initMouse();
bool hasFlag(Flags value);
void setFlag(Flags value);
void resetFlag(Flags value);
State state();
void state(State);
Ui::Point getMouseLocation();
Ui::Point getMouseLocation2();
bool isHovering(Ui::WindowType);
bool isHovering(Ui::WindowType, Ui::WindowNumber_t);
bool isHovering(Ui::WindowType type, Ui::WindowNumber_t number, Ui::WidgetIndex_t widgetIndex);
Ui::WidgetIndex_t getHoveredWidgetIndex();
bool isDropdownActive(Ui::WindowType type, Ui::WidgetIndex_t index);
bool isPressed(Ui::WindowType type, Ui::WindowNumber_t number);
bool isPressed(Ui::WindowType type, Ui::WindowNumber_t number, Ui::WidgetIndex_t index);
Ui::WidgetIndex_t getPressedWidgetIndex();
void setPressedWidgetIndex(Ui::WidgetIndex_t index);
void updateCursorPosition();
Ui::Window* toolGetActiveWindow();
bool isToolActive(Ui::WindowType);
bool isToolActive(Ui::WindowType, Ui::WindowNumber_t);
bool isToolActive(Ui::WindowType, Ui::WindowNumber_t, int16_t);
bool toolSet(Ui::Window* w, int16_t widgetIndex, Ui::CursorId cursorId);
void toolCancel();
void toolCancel(Ui::WindowType, Ui::WindowNumber_t);
int16_t getToolWidgetIndex();
void enqueueText(const char* text);
void enqueueKey(uint32_t key);
bool hasKeyModifier(KeyModifier modifier);
StationId getHoveredStationId();
MapSelectionFlags getMapSelectionFlags();
bool hasMapSelectionFlag(MapSelectionFlags flags);
void setMapSelectionFlags(MapSelectionFlags flags);
void resetMapSelectionFlag(MapSelectionFlags flags);
void triggerScreenshotCountdown(int8_t numTicks, ScreenshotType type);
void handleKeyboard();
void handleMouse(int16_t x, int16_t y, MouseButton button);
MouseButton getLastKnownButtonState();
void moveMouse(int32_t x, int32_t y, int32_t relX, int32_t relY);
void sub_407218();
void sub_407231();
Ui::Point getNextDragOffset();
void processMouseOver(int16_t x, int16_t y);
void processKeyboardInput();
void windowPositionBegin(int16_t x, int16_t y, Ui::Window* window, Ui::WidgetIndex_t widgetIndex);
Ui::Point getScrollLastLocation();
Ui::Point getDragLastLocation();
Ui::Point getTooltipMouseLocation();
void setTooltipMouseLocation(const Ui::Point& loc);
uint16_t getTooltipTimeout();
void setTooltipTimeout(uint16_t tooltipTimeout);
uint16_t getClickRepeatTicks();
void setClickRepeatTicks(uint16_t ticks);
bool isRightMouseButtonDown();
void setRightMouseButtonDown(bool status);
struct QueuedMouseInput
{
Ui::Point32 pos;
uint32_t button;
};
void enqueueMouseButton(const QueuedMouseInput& input);
MouseButton nextMouseInput(uint32_t& x, int16_t& y);
}