LeviLamina
Loading...
Searching...
No Matches
InputHandler.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/utility/NonOwnerPointer.h"
7#include "mc/deps/input/InputBindingMode.h"
8#include "mc/deps/input/InputMode.h"
9#include "mc/deps/input/enums/ButtonState.h"
10#include "mc/deps/input/enums/DirectionId.h"
11#include "mc/deps/input/enums/FocusImpact.h"
12#include "mc/deps/input/enums/RawInputType.h"
13
14// auto generated forward declare list
15// clang-format off
18class ButtonRepeater;
19class IClientInstance;
20class IMinecraftGame;
22class InputEventQueue;
24struct ButtonEventData;
27struct ControllerIDtoClientMap;
28struct InputMapping;
31struct PointerLocationEventData;
35// clang-format on
36
37class InputHandler {
38public:
39 // InputHandler inner types declare
40 // clang-format off
41 struct InputHandlerState;
42 // clang-format on
43
44 // InputHandler inner types define
46 public:
47 // member variables
48 // NOLINTBEGIN
49 ::ll::TypedStorage<4, 4, ::InputMode> mCurrentInputMode;
50 ::ll::TypedStorage<4, 4, ::InputBindingMode> mCurrentBindingMode;
51 ::ll::TypedStorage<8, 24, ::std::vector<::std::string>> mInputMappingStack;
52 ::ll::TypedStorage<8, 64, ::std::unordered_set<uint>> mButtonsDown;
53 ::ll::TypedStorage<8, 64, ::std::unordered_set<int>> mTriggeredChordsSources;
54 ::ll::TypedStorage<1, 1, bool> mSuspendInput;
55 ::ll::TypedStorage<1, 1, bool> mSuspendDirectionalInput;
56 ::ll::TypedStorage<1, 1, bool> mDisableInput;
57 // NOLINTEND
58
59 public:
60 // prevent constructor by default
61 InputHandlerState& operator=(InputHandlerState const&);
63
64 public:
65 // member functions
66 // NOLINTBEGIN
67 MCAPI InputHandlerState();
68
69 MCAPI ::InputHandler::InputHandlerState& operator=(::InputHandler::InputHandlerState&&);
70
71 MCAPI ~InputHandlerState();
72 // NOLINTEND
73
74 public:
75 // constructor thunks
76 // NOLINTBEGIN
77 MCAPI void* $ctor();
78 // NOLINTEND
79
80 public:
81 // destructor thunk
82 // NOLINTBEGIN
83 MCAPI void $dtor();
84 // NOLINTEND
85 };
86
87 using InputModeHandler = ::std::function<void(::InputMode, ::IClientInstance&)>;
88
89 using ButtonPressHandler = ::std::function<void(::FocusImpact, ::IClientInstance&)>;
90
91 using TextCharHandler = ::std::function<void(::std::string const&, bool, ::FocusImpact, ::IClientInstance&)>;
92
93 using CaretLocationHandler = ::std::function<void(int, ::FocusImpact, ::IClientInstance&)>;
94
95 using PointerLocationHandler =
96 ::std::function<void(::PointerLocationEventData const&, ::FocusImpact, ::IClientInstance&)>;
97
98 using PointerLocationWithIdHandler =
99 ::std::function<void(::PointerLocationWithIdEventData const&, ::IClientInstance&)>;
100
101 using ClearPointerLocationWithIdHandler =
102 ::std::function<void(::ClearPointerLocationWithIdEventData const&, ::IClientInstance&)>;
103
104 using ClearPointerLocationsHandler = ::std::function<void(::IClientInstance&)>;
105
106 using DirectionHandler = ::std::function<void(float, float, ::FocusImpact, ::IClientInstance&)>;
107
108 using TurnHandler = ::std::function<void(float, float, ::FocusImpact, ::IClientInstance&)>;
109
110 using VectorHandler = ::std::function<void(short, float, float, float, ::FocusImpact, ::IClientInstance&)>;
111
112 using AnyInputHandler = ::std::function<void(::IClientInstance&)>;
113
114 using RawInputHandler = ::std::function<void(int, ::RawInputType, ::ButtonState, bool, ::IClientInstance&)>;
115
116 using AddClientHandler = ::std::function<void(::IMinecraftGame*, int, bool)>;
117
118 using ChangeUserHandler = ::std::function<void(::IMinecraftGame*, int, bool)>;
119
120 using ControllerConnectionStateChangeHandler = ::std::function<void(::IClientInstance&, bool, int)>;
121
122 using TouchPadTouchHandler =
123 ::std::function<void(::TouchPadTouchEventData const&, ::FocusImpact, ::IClientInstance&)>;
124
125 using ControlOptionHandler = ::std::function<void(::ControlOptionEventData const&, ::IClientInstance&)>;
126
127 using NumberOfEnabledControlOptionsHandler =
128 ::std::function<void(::NumberOfEnabledControlOptionsEventData const&, ::IClientInstance&)>;
129
130 using OverlappingControlsHandler = ::std::function<void(::OverlappingControlsEventData const&, ::IClientInstance&)>;
131
132 using PotentialOverlappingControlsHandler = ::std::function<void(::IClientInstance&)>;
133
134 using InputModeHandlers = ::std::vector<::std::function<void(::InputMode, ::IClientInstance&)>>;
135
136 using ButtonHandlerMap =
137 ::std::multimap<uint, ::std::pair<bool, ::std::function<void(::FocusImpact, ::IClientInstance&)>>>;
138
139 using TextCharHandlers =
140 ::std::vector<::std::function<void(::std::string const&, bool, ::FocusImpact, ::IClientInstance&)>>;
141
142 using CaretLocationHandlers = ::std::vector<::std::function<void(int, ::FocusImpact, ::IClientInstance&)>>;
143
144 using PointerLocationHandlers =
145 ::std::vector<::std::function<void(::PointerLocationEventData const&, ::FocusImpact, ::IClientInstance&)>>;
146
147 using PointerLocationWithIdHandlers =
148 ::std::vector<::std::function<void(::PointerLocationWithIdEventData const&, ::IClientInstance&)>>;
149
150 using ClearPointerLocationWithIdHandlers =
151 ::std::vector<::std::function<void(::ClearPointerLocationWithIdEventData const&, ::IClientInstance&)>>;
152
153 using ClearPointerLocationsHandlers = ::std::vector<::std::function<void(::IClientInstance&)>>;
154
155 using DirectionHandlerMap =
156 ::std::multimap<::DirectionId, ::std::function<void(float, float, ::FocusImpact, ::IClientInstance&)>>;
157
158 using VectorHandlers =
159 ::std::vector<::std::function<void(short, float, float, float, ::FocusImpact, ::IClientInstance&)>>;
160
161 using TouchPadHandlers =
162 ::std::vector<::std::function<void(::TouchPadTouchEventData const&, ::FocusImpact, ::IClientInstance&)>>;
163
164 using PointerLocationWithIdHandlersMap =
165 ::std::map<uint, ::std::function<void(::PointerLocationWithIdEventData const&, ::IClientInstance&)>>;
166
167 using ControlOptionHandlers =
168 ::std::vector<::std::function<void(::ControlOptionEventData const&, ::IClientInstance&)>>;
169
170 using NumberOfEnabledControlOptionsHandlers =
171 ::std::vector<::std::function<void(::NumberOfEnabledControlOptionsEventData const&, ::IClientInstance&)>>;
172
173 using OverlappingControlsHandlers =
174 ::std::vector<::std::function<void(::OverlappingControlsEventData const&, ::IClientInstance&)>>;
175
176 using PotentialOverlappingControlsHandlers = ::std::vector<::std::function<void(::IClientInstance&)>>;
177
178public:
179 // member variables
180 // NOLINTBEGIN
181 ::ll::TypedStorage<8, 24, ::std::vector<::std::function<void(::InputMode, ::IClientInstance&)>>> mInputModeHandlers;
182 ::ll::TypedStorage<
183 8,
184 16,
185 ::std::multimap<uint, ::std::pair<bool, ::std::function<void(::FocusImpact, ::IClientInstance&)>>>>
186 mButtonDownHandlerMap;
187 ::ll::TypedStorage<
188 8,
189 16,
190 ::std::multimap<uint, ::std::pair<bool, ::std::function<void(::FocusImpact, ::IClientInstance&)>>>>
191 mButtonUpHandlerMap;
192 ::ll::TypedStorage<
193 8,
194 24,
195 ::std::vector<::std::function<void(::std::string const&, bool, ::FocusImpact, ::IClientInstance&)>>>
196 mTextCharHandlers;
197 ::ll::TypedStorage<8, 24, ::std::vector<::std::function<void(int, ::FocusImpact, ::IClientInstance&)>>>
198 mCaretLocationHandlers;
199 ::ll::TypedStorage<
200 8,
201 24,
202 ::std::vector<::std::function<void(::PointerLocationEventData const&, ::FocusImpact, ::IClientInstance&)>>>
203 mPointerLocationHandlers;
204 ::ll::TypedStorage<
205 8,
206 24,
207 ::std::vector<::std::function<void(::PointerLocationWithIdEventData const&, ::IClientInstance&)>>>
208 mPointerLocationWithIdHandlers;
209 ::ll::TypedStorage<
210 8,
211 24,
212 ::std::vector<::std::function<void(::ClearPointerLocationWithIdEventData const&, ::IClientInstance&)>>>
213 mClearPointerLocationWithIdHandlers;
214 ::ll::TypedStorage<8, 24, ::std::vector<::std::function<void(::IClientInstance&)>>> mClearPointerLocationsHandlers;
215 ::ll::TypedStorage<
216 8,
217 16,
218 ::std::multimap<::DirectionId, ::std::function<void(float, float, ::FocusImpact, ::IClientInstance&)>>>
219 mDirectionHandlerMap;
220 ::ll::TypedStorage<8, 64, ::std::function<void(::IClientInstance&)>> mAnyInputHandler;
221 ::ll::TypedStorage<8, 64, ::std::function<void(int, ::RawInputType, ::ButtonState, bool, ::IClientInstance&)>>
222 mRawInputHandler;
223 ::ll::TypedStorage<8, 64, ::std::function<void(::IMinecraftGame*, int, bool)>> mAddClientHandler;
224 ::ll::TypedStorage<8, 64, ::std::function<void(::IMinecraftGame*, int, bool)>> mChangeUserHandler;
225 ::ll::TypedStorage<8, 64, ::std::function<void(::IClientInstance&, bool, int)>>
226 mControllerConnectionStateChangeHandler;
227 ::ll::TypedStorage<
228 8,
229 24,
230 ::std::vector<::std::function<void(::TouchPadTouchEventData const&, ::FocusImpact, ::IClientInstance&)>>>
231 mTouchPadHandlers;
232 ::ll::TypedStorage<
233 8,
234 16,
235 ::std::map<uint, ::std::function<void(::PointerLocationWithIdEventData const&, ::IClientInstance&)>>>
236 mCustomZoneHandlers;
237 ::ll::TypedStorage<8, 24, ::std::vector<::std::function<void(::ControlOptionEventData const&, ::IClientInstance&)>>>
238 mControlOptionHandlers;
239 ::ll::TypedStorage<
240 8,
241 24,
242 ::std::vector<::std::function<void(::NumberOfEnabledControlOptionsEventData const&, ::IClientInstance&)>>>
243 mNumberOfEnabledControlOptionsHandlers;
244 ::ll::TypedStorage<
245 8,
246 24,
247 ::std::vector<::std::function<void(::OverlappingControlsEventData const&, ::IClientInstance&)>>>
248 mOverlappingControlsHandlers;
249 ::ll::TypedStorage<8, 24, ::std::vector<::std::function<void(::IClientInstance&)>>>
250 mPotentialOverlappingControlsHandlers;
251 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::InputEventQueue>> mInputEventQueue;
252 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ButtonChordTracker>> mChordTracker;
253 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ButtonRepeater>> mButtonRepeater;
254 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::InputDeviceMapper>>> mInputDeviceMappers;
255 ::ll::TypedStorage<8, 8, ::BindingFactoryMap&> mBindingFactoryMap;
256 ::ll::TypedStorage<8, 8, ::InputMappingFactoryMap&> mInputMappingFactoryMap;
257 ::ll::TypedStorage<8, 64, ::std::unordered_map<int, ::InputHandler::InputHandlerState>> mPerIdState;
258 ::ll::TypedStorage<4, 4, int> mPrimaryGameControllerId;
259 // NOLINTEND
260
261public:
262 // prevent constructor by default
263 InputHandler& operator=(InputHandler const&);
265 InputHandler();
266
267public:
268 // member functions
269 // NOLINTBEGIN
270 MCAPI InputHandler(
271 ::BindingFactoryMap& bindingFactoryMap,
272 ::InputMappingFactoryMap& mappingFactoryMap,
273 ::InputMode startingInputMode
274 );
275
276 MCAPI void _handleButtonEvent(
277 ::ButtonEventData const& button,
278 ::FocusImpact focusImpact,
279 ::IClientInstance& client,
280 int controllerId
281 );
282
283 MCAPI void
284 _handleMappingChange(::InputMapping const* newMapping, ::InputMapping const* oldMapping, int controllerId);
285
286 MCAPI void
287 _handleTextCharEvent(::TextCharEventData const& textChar, ::FocusImpact focusImpact, ::IClientInstance& client);
288
289 MCAPI void changeControllerId(int oldId, int newId);
290
291 MCAPI void clearInputMapping(int controllerId);
292
293 MCAPI ::std::string const& getCurrentInputMapping(int controllerId) const;
294
295 MCAPI ::InputMode getCurrentInputMode(int controllerId) const;
296
297 MCAPI void popInputMapping(int controllerId);
298
299 MCAPI void pushInputMapping(::std::string const& mappingName, int controllerId);
300
301 MCAPI void registerButtonDownHandler(
302 ::std::string buttonName,
303 ::std::function<void(::FocusImpact, ::IClientInstance&)> handler,
304 bool suspendable
305 );
306
307 MCAPI void registerButtonUpHandler(
308 ::std::string buttonName,
309 ::std::function<void(::FocusImpact, ::IClientInstance&)> handler,
310 bool suspendable
311 );
312
313 MCAPI void registerClearPointerLocationsHandler(::std::function<void(::IClientInstance&)> handler);
314
315 MCAPI void registerDirectionHandler(
316 ::DirectionId directionId,
317 ::std::function<void(float, float, ::FocusImpact, ::IClientInstance&)> handler
318 );
319
320 MCAPI void registerInputModeHandler(::std::function<void(::InputMode, ::IClientInstance&)> handler);
321
322 MCAPI void registerOverlappingControlsHandler(
323 ::std::function<void(::OverlappingControlsEventData const&, ::IClientInstance&)> handler
324 );
325
326 MCAPI void registerPotentialOverlappingControlsHandler(::std::function<void(::IClientInstance&)> handler);
327
328 MCAPI void registerTouchPadTouchHandler(
329 ::std::function<void(::TouchPadTouchEventData const&, ::FocusImpact, ::IClientInstance&)> handler
330 );
331
332 MCAPI void releaseButtonsAndSticks(::std::string const& currentMappingName, int controllerId);
333
334 MCAPI void tick(
335 ::IMinecraftGame* mcGame,
336 ::IClientInstance& primaryClientInstance,
337 ::Bedrock::NotNullNonOwnerPtr<::ControllerIDtoClientMap> const& controllerClientMap,
338 bool allowMultipleClients
339 );
340
341 MCAPI void updateInputMapping(::std::string const& mappingName, int controllerId);
342
343 MCAPI ~InputHandler();
344 // NOLINTEND
345
346public:
347 // constructor thunks
348 // NOLINTBEGIN
349 MCAPI void* $ctor(
350 ::BindingFactoryMap& bindingFactoryMap,
351 ::InputMappingFactoryMap& mappingFactoryMap,
352 ::InputMode startingInputMode
353 );
354 // NOLINTEND
355
356public:
357 // destructor thunk
358 // NOLINTBEGIN
359 MCAPI void $dtor();
360 // NOLINTEND
361};
Definition BindingFactoryMap.h:5
Definition ButtonChordTracker.h:5
Definition ButtonRepeater.h:5
Definition InputDeviceMapper.h:5
Definition InputEventQueue.h:5
Definition InputHandler.h:5
Definition InputMappingFactoryMap.h:5
Definition ClearPointerLocationWithIdEventData.h:5
Definition ControlOptionEventData.h:5
Definition InputHandler.h:45
Definition InputMapping.h:5
Definition NumberOfEnabledControlOptionsEventData.h:5
Definition OverlappingControlsEventData.h:5
Definition PointerLocationWithIdEventData.h:5
Definition TextCharEventData.h:5
Definition TouchPadTouchEventData.h:5