Polyphase Game Engine
Loading...
Searching...
No Matches
InputCaptureModal.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
6
7#include <functional>
8#include <string>
9
10// Modal "press any input" capture used by InputPromptMapInspector to fill in
11// an entry's input path and device. Mirrors the pattern in
12// Editor/Hotkeys/EditorHotkeysWindow.cpp:412 (DrawCaptureOverlay).
13//
14// While the modal is open it mutes PlayerInputSystem action evaluation via
15// SetActionEvaluationEnabled(false) so a captured key doesn't also fire a
16// registered game action.
17class InputCaptureModal
18{
19public:
20
21 struct Result
22 {
23 InputActionBinding binding; // synthesized binding
24 std::string path; // MakeInputPath(binding)
25 bool gamepadDetected = false;
26 int32_t gamepadIndex = -1;
28 };
29
30 using Callback = std::function<void(const Result&)>;
31
32 // Begin capture. The modal opens on the next Draw() call.
33 void Start(Callback onCaptured);
34
35 // Call once per editor frame from the parent inspector. Returns true while
36 // the modal is open (so the parent can early-out from other input).
37 bool Draw();
38
39 bool IsCapturing() const { return mCapturing; }
40
41private:
42
43 bool mCapturing = false;
44 bool mJustStarted = false;
45 float mTimer = 0.0f;
46 Callback mOnCaptured;
47};
48
49#endif // EDITOR
GamepadType
Definition InputTypes.h:27
Definition PlayerInputSystem.h:51