CommonLibSSE (Parapets fork)
ControlMap.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSFixedString.h"
4 #include "RE/B/BSInputDevice.h"
5 #include "RE/B/BSTArray.h"
6 #include "RE/B/BSTEvent.h"
7 #include "RE/B/BSTSingleton.h"
8 #include "RE/I/InputDevices.h"
9 #include "RE/P/PCGamepadType.h"
10 #include "RE/U/UserEvents.h"
11 
12 namespace RE
13 {
14  class UserEventEnabled;
15 
16  class ControlMap :
17  public BSTSingletonSDM<ControlMap>, // 00
18  public BSTEventSource<UserEventEnabled> // 08
19  {
20  public:
23 
24  enum : std::uint32_t
25  {
26  kInvalid = static_cast<std::uint8_t>(-1)
27  };
28 
30  {
31  public:
32  // members
34  std::uint16_t inputKey; // 08
35  std::uint16_t modifier; // 08
36  std::int8_t indexInContext; // 0C
37  bool remappable; // 0D
38  bool linked; // 0E
40  std::uint32_t pad14; // 14
41  };
42  static_assert(sizeof(UserEventMapping) == 0x18);
43 
44  struct InputContext
45  {
46  public:
47  // members
48  BSTArray<UserEventMapping> deviceMappings[INPUT_DEVICES::kTotal]; // 00
49  };
50 #if !defined(SKYRIMVR)
51  static_assert(sizeof(InputContext) == 0x60);
52 #else
53  static_assert(sizeof(InputContext) == 0xF0);
54 #endif
55 
57  {
58  public:
59  // members
64  std::uint32_t pad14; // 14
66  };
67  static_assert(sizeof(LinkedMapping) == 0x20);
68 
70 
71  std::int8_t AllowTextInput(bool a_allow);
72  constexpr bool AreControlsEnabled(UEFlag a_flags) const noexcept { return enabledControls.all(a_flags); }
73  bool GetButtonNameFromUserEvent(const BSFixedString& a_eventID, INPUT_DEVICE a_device, BSFixedString& a_buttonName);
74  std::uint32_t GetMappedKey(std::string_view a_eventID, INPUT_DEVICE a_device, InputContextID a_context = InputContextID::kGameplay) const;
75  bool GetMappingFromEventName(const BSFixedString& a_eventID, UserEvents::INPUT_CONTEXT_ID a_context, INPUT_DEVICE a_device, UserEventMapping& a_mapping);
76  std::string_view GetUserEventName(std::uint32_t a_buttonID, INPUT_DEVICE a_device, InputContextID a_context = InputContextID::kGameplay) const;
77  constexpr bool IsActivateControlsEnabled() const noexcept { return enabledControls.all(UEFlag::kActivate); }
78  constexpr bool IsConsoleControlsEnabled() const noexcept { return enabledControls.all(UEFlag::kConsole); }
79  constexpr bool IsFightingControlsEnabled() const noexcept { return enabledControls.all(UEFlag::kFighting); }
80  constexpr bool IsLookingControlsEnabled() const noexcept { return enabledControls.all(UEFlag::kLooking); }
81  constexpr bool IsMenuControlsEnabled() const noexcept { return enabledControls.all(UEFlag::kMenu); }
82  constexpr bool IsMainFourControlsEnabled() const noexcept { return enabledControls.all(UEFlag::kMainFour); }
83  constexpr bool IsMovementControlsEnabled() const noexcept { return enabledControls.all(UEFlag::kMovement); }
84  constexpr bool IsPOVSwitchControlsEnabled() const noexcept { return enabledControls.all(UEFlag::kPOVSwitch); }
85  constexpr bool IsSneakingControlsEnabled() const noexcept { return enabledControls.all(UEFlag::kSneaking); }
86  constexpr bool IsVATSControlsEnabled() const noexcept { return enabledControls.all(UEFlag::kVATS); }
87  constexpr bool IsWheelZoomControlsEnabled() const noexcept { return enabledControls.all(UEFlag::kWheelZoom); }
88  void StoreControls();
90  void ToggleControls(UEFlag a_flags, bool a_enable, bool a_storeState);
91 
92  // members
93  InputContext* controlMap[InputContextID::kTotal]; // 060
98  std::int8_t textEntryCount; // 128
99  bool ignoreKeyboardMouse; // 129
101  std::uint8_t pad12B; // 12B
103  };
104 #if !defined(SKYRIMVR)
105  static_assert(sizeof(ControlMap) == 0x130);
106 #else
107  static_assert(offsetof(ControlMap, textEntryCount) == 0x140);
108  static_assert(sizeof(ControlMap) == 0x148);
109 #endif
110 }
Definition: BSTArray.h:377
Definition: BSTEvent.h:28
Definition: ControlMap.h:19
void LoadStoredControls()
constexpr bool IsFightingControlsEnabled() const noexcept
Definition: ControlMap.h:79
constexpr bool AreControlsEnabled(UEFlag a_flags) const noexcept
Definition: ControlMap.h:72
std::int8_t textEntryCount
Definition: ControlMap.h:98
std::int8_t AllowTextInput(bool a_allow)
constexpr bool IsSneakingControlsEnabled() const noexcept
Definition: ControlMap.h:85
constexpr bool IsConsoleControlsEnabled() const noexcept
Definition: ControlMap.h:78
bool ignoreActivateDisabledEvents
Definition: ControlMap.h:100
bool GetMappingFromEventName(const BSFixedString &a_eventID, UserEvents::INPUT_CONTEXT_ID a_context, INPUT_DEVICE a_device, UserEventMapping &a_mapping)
constexpr bool IsMovementControlsEnabled() const noexcept
Definition: ControlMap.h:83
stl::enumeration< PC_GAMEPAD_TYPE, std::uint32_t > gamePadMapType
Definition: ControlMap.h:102
bool GetButtonNameFromUserEvent(const BSFixedString &a_eventID, INPUT_DEVICE a_device, BSFixedString &a_buttonName)
constexpr bool IsMainFourControlsEnabled() const noexcept
Definition: ControlMap.h:82
std::string_view GetUserEventName(std::uint32_t a_buttonID, INPUT_DEVICE a_device, InputContextID a_context=InputContextID::kGameplay) const
std::uint32_t GetMappedKey(std::string_view a_eventID, INPUT_DEVICE a_device, InputContextID a_context=InputContextID::kGameplay) const
constexpr bool IsPOVSwitchControlsEnabled() const noexcept
Definition: ControlMap.h:84
constexpr bool IsActivateControlsEnabled() const noexcept
Definition: ControlMap.h:77
InputContext * controlMap[InputContextID::kTotal]
Definition: ControlMap.h:93
static ControlMap * GetSingleton()
void ToggleControls(UEFlag a_flags, bool a_enable, bool a_storeState)
stl::enumeration< UEFlag, std::uint32_t > enabledControls
Definition: ControlMap.h:96
@ kInvalid
Definition: ControlMap.h:26
constexpr bool IsMenuControlsEnabled() const noexcept
Definition: ControlMap.h:81
void StoreControls()
constexpr bool IsLookingControlsEnabled() const noexcept
Definition: ControlMap.h:80
constexpr bool IsWheelZoomControlsEnabled() const noexcept
Definition: ControlMap.h:87
bool ignoreKeyboardMouse
Definition: ControlMap.h:99
constexpr bool IsVATSControlsEnabled() const noexcept
Definition: ControlMap.h:86
std::uint8_t pad12B
Definition: ControlMap.h:101
BSTArray< LinkedMapping > linkedMappings
Definition: ControlMap.h:94
BSTArray< InputContextID > contextPriorityStack
Definition: ControlMap.h:95
stl::enumeration< UEFlag, std::uint32_t > storedControls
Definition: ControlMap.h:97
INPUT_CONTEXT_IDS::INPUT_CONTEXT_ID INPUT_CONTEXT_ID
Definition: UserEvents.h:47
USER_EVENT_FLAG
Definition: UserEvents.h:50
constexpr bool all(Args... a_args) const noexcept requires(std
Definition: PCH.h:329
Definition: AbsorbEffect.h:6
Definition: BSTSingleton.h:50
Definition: ControlMap.h:45
BSTArray< UserEventMapping > deviceMappings[INPUT_DEVICES::kTotal]
Definition: ControlMap.h:48
Definition: ControlMap.h:57
std::uint32_t pad14
Definition: ControlMap.h:64
BSFixedString linkFromName
Definition: ControlMap.h:65
InputContextID linkedMappingContext
Definition: ControlMap.h:61
INPUT_DEVICE device
Definition: ControlMap.h:62
BSFixedString linkedMappingName
Definition: ControlMap.h:60
InputContextID linkFromContext
Definition: ControlMap.h:63
Definition: ControlMap.h:30
stl::enumeration< UEFlag, std::uint32_t > userEventGroupFlag
Definition: ControlMap.h:39
std::int8_t indexInContext
Definition: ControlMap.h:36
BSFixedString eventID
Definition: ControlMap.h:33
std::uint16_t modifier
Definition: ControlMap.h:35
std::uint16_t inputKey
Definition: ControlMap.h:34
bool linked
Definition: ControlMap.h:38
bool remappable
Definition: ControlMap.h:37
std::uint32_t pad14
Definition: ControlMap.h:40
INPUT_DEVICE
Definition: InputDevices.h:8
INPUT_CONTEXT_ID
Definition: UserEvents.h:14