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;
25struct ButtonEventData;
30struct InputMapping;
37// clang-format on
38
39class InputHandler {
40public:
41 // InputHandler inner types declare
42 // clang-format off
43 struct InputHandlerState;
44 // clang-format on
45
46 // InputHandler inner types define
47 struct InputHandlerState {
48 public:
49 // member variables
50 // NOLINTBEGIN
51 ::ll::TypedStorage<4, 4, ::InputMode> mCurrentInputMode;
52 ::ll::TypedStorage<4, 4, ::InputBindingMode> mCurrentBindingMode;
53 ::ll::TypedStorage<8, 24, ::std::vector<::std::string>> mInputMappingStack;
54 ::ll::TypedStorage<8, 64, ::std::unordered_set<uint>> mButtonsDown;
55 ::ll::TypedStorage<8, 64, ::std::unordered_set<int>> mTriggeredChordsSources;
56 ::ll::TypedStorage<4, 4, int> mCurrentChordSource;
57 ::ll::TypedStorage<1, 1, bool> mSuspendInput;
58 ::ll::TypedStorage<1, 1, bool> mSuspendDirectionalInput;
59 ::ll::TypedStorage<1, 1, bool> mDisableInput;
60 // NOLINTEND
61
62 public:
63 // member functions
64 // NOLINTBEGIN
65 MCAPI ~InputHandlerState();
66 // NOLINTEND
67
68 public:
69 // destructor thunk
70 // NOLINTBEGIN
71 MCAPI void $dtor();
72 // NOLINTEND
73 };
74
75 using InputModeHandler = ::std::function<void(::InputMode, ::IClientInstance&)>;
76
77 using ButtonPressHandler = ::std::function<void(::FocusImpact, ::IClientInstance&)>;
78
79 using TextCharHandler = ::std::function<void(::std::string const&, ::FocusImpact, ::IClientInstance&)>;
80
81 using PointerLocationHandler =
82 ::std::function<void(::PointerLocationEventData const&, ::FocusImpact, ::IClientInstance&)>;
83
84 using PointerLocationWithIdHandler =
85 ::std::function<void(::PointerLocationWithIdEventData const&, ::IClientInstance&)>;
86
87 using ClearPointerLocationWithIdHandler =
88 ::std::function<void(::ClearPointerLocationWithIdEventData const&, ::IClientInstance&)>;
89
90 using ClearPointerLocationsHandler = ::std::function<void(::IClientInstance&)>;
91
92 using DirectionHandler = ::std::function<void(float, float, ::FocusImpact, ::IClientInstance&)>;
93
94 using TurnHandler = ::std::function<void(float, float, ::FocusImpact, ::IClientInstance&)>;
95
96 using VectorHandler = ::std::function<void(short, float, float, float, ::FocusImpact, ::IClientInstance&)>;
97
98 using AnyInputHandler = ::std::function<void(::IClientInstance&)>;
99
100 using RawInputHandler = ::std::function<void(int, ::RawInputType, ::ButtonState, bool, ::IClientInstance&)>;
101
102 using AddClientHandler = ::std::function<void(::IMinecraftGame*, int, bool)>;
103
104 using ChangeUserHandler = ::std::function<void(::IMinecraftGame*, int, bool)>;
105
106 using ControllerConnectionStateChangeHandler = ::std::function<void(::IClientInstance&, bool, int)>;
107
108 using TouchPadTouchHandler =
109 ::std::function<void(::TouchPadTouchEventData const&, ::FocusImpact, ::IClientInstance&)>;
110
111 using ControlOptionHandler = ::std::function<void(::ControlOptionEventData const&, ::IClientInstance&)>;
112
113 using NumberOfEnabledControlOptionsHandler =
114 ::std::function<void(::NumberOfEnabledControlOptionsEventData const&, ::IClientInstance&)>;
115
116 using OverlappingControlsHandler = ::std::function<void(::OverlappingControlsEventData const&, ::IClientInstance&)>;
117
118 using PotentialOverlappingControlsHandler = ::std::function<void(::IClientInstance&)>;
119
120 using InputModeHandlers = ::std::vector<::std::function<void(::InputMode, ::IClientInstance&)>>;
121
122 using ButtonHandlerMap =
123 ::std::multimap<uint, ::std::pair<bool, ::std::function<void(::FocusImpact, ::IClientInstance&)>>>;
124
125 using TextCharHandlers =
126 ::std::vector<::std::function<void(::std::string const&, ::FocusImpact, ::IClientInstance&)>>;
127
128 using PointerLocationHandlers =
129 ::std::vector<::std::function<void(::PointerLocationEventData const&, ::FocusImpact, ::IClientInstance&)>>;
130
131 using PointerLocationWithIdHandlers =
132 ::std::vector<::std::function<void(::PointerLocationWithIdEventData const&, ::IClientInstance&)>>;
133
134 using ClearPointerLocationWithIdHandlers =
135 ::std::vector<::std::function<void(::ClearPointerLocationWithIdEventData const&, ::IClientInstance&)>>;
136
137 using ClearPointerLocationsHandlers = ::std::vector<::std::function<void(::IClientInstance&)>>;
138
139 using DirectionHandlerMap =
140 ::std::multimap<::DirectionId, ::std::function<void(float, float, ::FocusImpact, ::IClientInstance&)>>;
141
142 using VectorHandlers =
143 ::std::vector<::std::function<void(short, float, float, float, ::FocusImpact, ::IClientInstance&)>>;
144
145 using TouchPadHandlers =
146 ::std::vector<::std::function<void(::TouchPadTouchEventData const&, ::FocusImpact, ::IClientInstance&)>>;
147
148 using PointerLocationWithIdHandlersMap =
149 ::std::map<uint, ::std::function<void(::PointerLocationWithIdEventData const&, ::IClientInstance&)>>;
150
151 using ControlOptionHandlers =
152 ::std::vector<::std::function<void(::ControlOptionEventData const&, ::IClientInstance&)>>;
153
154 using NumberOfEnabledControlOptionsHandlers =
155 ::std::vector<::std::function<void(::NumberOfEnabledControlOptionsEventData const&, ::IClientInstance&)>>;
156
157 using OverlappingControlsHandlers =
158 ::std::vector<::std::function<void(::OverlappingControlsEventData const&, ::IClientInstance&)>>;
159
160 using PotentialOverlappingControlsHandlers = ::std::vector<::std::function<void(::IClientInstance&)>>;
161
162public:
163 // member variables
164 // NOLINTBEGIN
165 ::ll::TypedStorage<8, 24, ::std::vector<::std::function<void(::InputMode, ::IClientInstance&)>>> mInputModeHandlers;
166 ::ll::TypedStorage<
167 8,
168 16,
169 ::std::multimap<uint, ::std::pair<bool, ::std::function<void(::FocusImpact, ::IClientInstance&)>>>>
170 mButtonDownHandlerMap;
171 ::ll::TypedStorage<
172 8,
173 16,
174 ::std::multimap<uint, ::std::pair<bool, ::std::function<void(::FocusImpact, ::IClientInstance&)>>>>
175 mButtonUpHandlerMap;
176 ::ll::TypedStorage<
177 8,
178 24,
179 ::std::vector<::std::function<void(::std::string const&, ::FocusImpact, ::IClientInstance&)>>>
180 mTextCharHandlers;
181 ::ll::TypedStorage<
182 8,
183 24,
184 ::std::vector<::std::function<void(::PointerLocationEventData const&, ::FocusImpact, ::IClientInstance&)>>>
185 mPointerLocationHandlers;
186 ::ll::TypedStorage<
187 8,
188 24,
189 ::std::vector<::std::function<void(::PointerLocationWithIdEventData const&, ::IClientInstance&)>>>
190 mPointerLocationWithIdHandlers;
191 ::ll::TypedStorage<
192 8,
193 24,
194 ::std::vector<::std::function<void(::ClearPointerLocationWithIdEventData const&, ::IClientInstance&)>>>
195 mClearPointerLocationWithIdHandlers;
196 ::ll::TypedStorage<8, 24, ::std::vector<::std::function<void(::IClientInstance&)>>> mClearPointerLocationsHandlers;
197 ::ll::TypedStorage<
198 8,
199 16,
200 ::std::multimap<::DirectionId, ::std::function<void(float, float, ::FocusImpact, ::IClientInstance&)>>>
201 mDirectionHandlerMap;
202 ::ll::TypedStorage<8, 64, ::std::function<void(::IClientInstance&)>> mAnyInputHandler;
203 ::ll::TypedStorage<8, 64, ::std::function<void(int, ::RawInputType, ::ButtonState, bool, ::IClientInstance&)>>
204 mRawInputHandler;
205 ::ll::TypedStorage<8, 64, ::std::function<void(::IMinecraftGame*, int, bool)>> mAddClientHandler;
206 ::ll::TypedStorage<8, 64, ::std::function<void(::IMinecraftGame*, int, bool)>> mChangeUserHandler;
207 ::ll::TypedStorage<8, 64, ::std::function<void(::IClientInstance&, bool, int)>>
208 mControllerConnectionStateChangeHandler;
209 ::ll::TypedStorage<
210 8,
211 24,
212 ::std::vector<::std::function<void(::TouchPadTouchEventData const&, ::FocusImpact, ::IClientInstance&)>>>
213 mTouchPadHandlers;
214 ::ll::TypedStorage<
215 8,
216 16,
217 ::std::map<uint, ::std::function<void(::PointerLocationWithIdEventData const&, ::IClientInstance&)>>>
218 mCustomZoneHandlers;
219 ::ll::TypedStorage<8, 24, ::std::vector<::std::function<void(::ControlOptionEventData const&, ::IClientInstance&)>>>
220 mControlOptionHandlers;
221 ::ll::TypedStorage<
222 8,
223 24,
224 ::std::vector<::std::function<void(::NumberOfEnabledControlOptionsEventData const&, ::IClientInstance&)>>>
225 mNumberOfEnabledControlOptionsHandlers;
226 ::ll::TypedStorage<
227 8,
228 24,
229 ::std::vector<::std::function<void(::OverlappingControlsEventData const&, ::IClientInstance&)>>>
230 mOverlappingControlsHandlers;
231 ::ll::TypedStorage<8, 24, ::std::vector<::std::function<void(::IClientInstance&)>>>
232 mPotentialOverlappingControlsHandlers;
233 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::InputEventQueue>> mInputEventQueue;
234 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ButtonChordTracker>> mChordTracker;
235 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ButtonRepeater>> mButtonRepeater;
236 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::InputDeviceMapper>>> mInputDeviceMappers;
237 ::ll::TypedStorage<8, 8, ::BindingFactoryMap&> mBindingFactoryMap;
238 ::ll::TypedStorage<8, 8, ::InputMappingFactoryMap&> mInputMappingFactoryMap;
239 ::ll::TypedStorage<8, 64, ::std::unordered_map<int, ::InputHandler::InputHandlerState>> mPerIdState;
240 ::ll::TypedStorage<4, 4, int> mPrimaryGameControllerId;
241 // NOLINTEND
242
243public:
244 // prevent constructor by default
245 InputHandler& operator=(InputHandler const&);
246 InputHandler(InputHandler const&);
247 InputHandler();
248
249public:
250 // member functions
251 // NOLINTBEGIN
252 MCAPI InputHandler(
253 ::BindingFactoryMap& bindingFactoryMap,
254 ::InputMappingFactoryMap& mappingFactoryMap,
255 ::InputMode startingInputMode
256 );
257
258 MCAPI void _handleButtonEvent(
259 ::ButtonEventData const& button,
260 ::FocusImpact focusImpact,
261 ::IClientInstance& client,
262 int controllerId
263 );
264
265 MCAPI void _handleDirectionEvent(
266 ::DirectionEventData const& direction,
267 ::FocusImpact focusImpact,
268 ::IClientInstance& client,
269 bool suspendedDirectionalInput
270 );
271
272 MCAPI void
273 _handleMappingChange(::InputMapping const* newMapping, ::InputMapping const* oldMapping, int controllerId);
274
275 MCAPI void _handlePointerLocationEvent(
276 ::PointerLocationEventData const& pointerLocation,
277 ::FocusImpact focusImpact,
278 ::IClientInstance& client,
279 int controllerId
280 );
281
282 MCAPI void
283 _handleTextCharEvent(::TextCharEventData const& textChar, ::FocusImpact focusImpact, ::IClientInstance& client);
284
285 MCAPI void changeControllerId(int oldId, int newId);
286
287 MCAPI void clearInputDeviceQueues();
288
289 MCAPI void clearInputDeviceQueuesForFrame();
290
291 MCAPI void clearInputMapping(int controllerId);
292
293 MCAPI void clearInvalidDownKeys(int controllerId);
294
295 MCAPI ::std::string const& getCurrentInputMapping(int controllerId) const;
296
297 MCAPI ::InputMode getCurrentInputMode(int controllerId) const;
298
299 MCAPI void initNewControllerIdOwner(int controllerId, ::InputMode initialInputMode);
300
301 MCAPI void popInputMapping(int controllerId);
302
303 MCAPI void pushInputMapping(::std::string const& mappingName, int controllerId);
304
305 MCAPI void refreshInputMapping(int controllerId);
306
307 MCAPI void registerAddClientHandler(::std::function<void(::IMinecraftGame*, int, bool)> handler);
308
309 MCFOLD void registerAnyInputHandler(::std::function<void(::IClientInstance&)> handler);
310
311 MCAPI void registerButtonDownHandler(
312 ::std::string buttonName,
313 ::std::function<void(::FocusImpact, ::IClientInstance&)> handler,
314 bool suspendable
315 );
316
317 MCAPI void registerButtonUpHandler(
318 ::std::string buttonName,
319 ::std::function<void(::FocusImpact, ::IClientInstance&)> handler,
320 bool suspendable
321 );
322
323 MCAPI void registerChangeUserHandler(::std::function<void(::IMinecraftGame*, int, bool)> handler);
324
325 MCAPI void registerClearPointerLocationWithIdHandler(
326 ::std::function<void(::ClearPointerLocationWithIdEventData const&, ::IClientInstance&)> handler
327 );
328
329 MCAPI void registerClearPointerLocationsHandler(::std::function<void(::IClientInstance&)> handler);
330
331 MCAPI void
332 registerControlOptionHandler(::std::function<void(::ControlOptionEventData const&, ::IClientInstance&)> handler);
333
334 MCAPI void
335 registerControllerConnectionStateChangeHandler(::std::function<void(::IClientInstance&, bool, int)> handler);
336
337 MCAPI void registerDirectionHandler(
338 ::DirectionId directionId,
339 ::std::function<void(float, float, ::FocusImpact, ::IClientInstance&)> handler
340 );
341
342 MCAPI void registerInputDeviceMapper(::std::unique_ptr<::InputDeviceMapper> mapper);
343
344 MCAPI void registerInputModeHandler(::std::function<void(::InputMode, ::IClientInstance&)> handler);
345
346 MCAPI void registerNumberOfEnabledControlOptionsHandler(
347 ::std::function<void(::NumberOfEnabledControlOptionsEventData const&, ::IClientInstance&)> handler
348 );
349
350 MCAPI void registerOverlappingControlsHandler(
351 ::std::function<void(::OverlappingControlsEventData const&, ::IClientInstance&)> handler
352 );
353
354 MCAPI void registerPointerLocationHandler(
355 ::std::function<void(::PointerLocationEventData const&, ::FocusImpact, ::IClientInstance&)> handler
356 );
357
358 MCAPI void registerPointerLocationWithIdHandler(
359 ::std::function<void(::PointerLocationWithIdEventData const&, ::IClientInstance&)> handler
360 );
361
362 MCAPI void registerPotentialOverlappingControlsHandler(::std::function<void(::IClientInstance&)> handler);
363
364 MCAPI void registerRawInputHandler(
365 ::std::function<void(int, ::RawInputType, ::ButtonState, bool, ::IClientInstance&)> handler
366 );
367
368 MCAPI void
369 registerTextCharHandler(::std::function<void(::std::string const&, ::FocusImpact, ::IClientInstance&)> handler);
370
371 MCAPI void registerTouchPadTouchHandler(
372 ::std::function<void(::TouchPadTouchEventData const&, ::FocusImpact, ::IClientInstance&)> handler
373 );
374
375 MCAPI void releaseButtonsAndSticks(::std::string const& currentMappingName, int controllerId);
376
377 MCAPI void render(::InputRenderContext& renderContext) const;
378
379 MCAPI void setDisableInput(bool disable, int controllerId);
380
381 MCAPI void setInputBindingMode(::InputBindingMode mode, int controllerId);
382
383 MCAPI void setSuspendDirectionalInput(bool suspendDirectionalInput, int controllerId);
384
385 MCAPI void setSuspendInput(bool suspendInput, int controllerId);
386
387 MCAPI void setWindowSize(int width, int height);
388
389 MCAPI void tick(
390 ::IMinecraftGame* mcGame,
391 ::IClientInstance& primaryClientInstance,
392 ::Bedrock::NotNullNonOwnerPtr<::ControllerIDtoClientMap> const& controllerClientMap,
393 bool allowMultipleClients
394 );
395
396 MCAPI void updateInputMapping(::std::string const& mappingName, int controllerId);
397
398 MCAPI ~InputHandler();
399 // NOLINTEND
400
401public:
402 // constructor thunks
403 // NOLINTBEGIN
404 MCAPI void* $ctor(
405 ::BindingFactoryMap& bindingFactoryMap,
406 ::InputMappingFactoryMap& mappingFactoryMap,
407 ::InputMode startingInputMode
408 );
409 // NOLINTEND
410
411public:
412 // destructor thunk
413 // NOLINTBEGIN
414 MCAPI void $dtor();
415 // NOLINTEND
416};
Definition BindingFactoryMap.h:5
Definition ButtonChordTracker.h:5
Definition ButtonRepeater.h:5
Definition IClientInstance.h:5
Definition IMinecraftGame.h:5
Definition InputDeviceMapper.h:5
Definition InputEventQueue.h:5
Definition InputHandler.h:5
Definition InputMappingFactoryMap.h:5
Definition InputRenderContext.h:5
Definition ButtonEventData.h:5
Definition ClearPointerLocationWithIdEventData.h:5
Definition ControlOptionEventData.h:5
Definition ControllerIDtoClientMap.h:5
Definition DirectionEventData.h:5
Definition InputHandler.h:13
Definition InputMapping.h:5
Definition NumberOfEnabledControlOptionsEventData.h:5
Definition OverlappingControlsEventData.h:5
Definition PointerLocationEventData.h:5
Definition PointerLocationWithIdEventData.h:5
Definition TextCharEventData.h:5
Definition TouchPadTouchEventData.h:5