forked from Ryan-rsm-McKenzie/CommonLibF4
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from powerof3/master
feat: InputMap/BSInputEnableManager/HUDMenu
- Loading branch information
Showing
26 changed files
with
933 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
namespace F4SE | ||
{ | ||
namespace InputMap | ||
{ | ||
enum | ||
{ | ||
// first 256 for keyboard, then 8 mouse buttons, then mouse wheel up, wheel down, then 16 gamepad buttons | ||
kMacro_KeyboardOffset = 0, // not actually used, just for self-documentation | ||
kMacro_NumKeyboardKeys = 256, | ||
|
||
kMacro_MouseButtonOffset = kMacro_NumKeyboardKeys, // 256 | ||
kMacro_NumMouseButtons = 8, | ||
|
||
kMacro_MouseWheelOffset = kMacro_MouseButtonOffset + kMacro_NumMouseButtons, // 264 | ||
kMacro_MouseWheelDirections = 2, | ||
|
||
kMacro_GamepadOffset = kMacro_MouseWheelOffset + kMacro_MouseWheelDirections, // 266 | ||
kMacro_NumGamepadButtons = 16, | ||
|
||
kMaxMacros = kMacro_GamepadOffset + kMacro_NumGamepadButtons // 282 | ||
}; | ||
|
||
enum | ||
{ | ||
kGamepadButtonOffset_DPAD_UP = kMacro_GamepadOffset, // 266 | ||
kGamepadButtonOffset_DPAD_DOWN, | ||
kGamepadButtonOffset_DPAD_LEFT, | ||
kGamepadButtonOffset_DPAD_RIGHT, | ||
kGamepadButtonOffset_START, | ||
kGamepadButtonOffset_BACK, | ||
kGamepadButtonOffset_LEFT_THUMB, | ||
kGamepadButtonOffset_RIGHT_THUMB, | ||
kGamepadButtonOffset_LEFT_SHOULDER, | ||
kGamepadButtonOffset_RIGHT_SHOULDER, | ||
kGamepadButtonOffset_A, | ||
kGamepadButtonOffset_B, | ||
kGamepadButtonOffset_X, | ||
kGamepadButtonOffset_Y, | ||
kGamepadButtonOffset_LT, | ||
kGamepadButtonOffset_RT // 281 | ||
}; | ||
|
||
std::uint32_t XInputToScePadOffset(std::uint32_t keyMask); | ||
std::uint32_t ScePadOffsetToXInput(std::uint32_t keyMask); | ||
|
||
std::uint32_t GamepadMaskToKeycode(std::uint32_t keyMask); | ||
std::uint32_t GamepadKeycodeToMask(std::uint32_t keyCode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
#pragma once | ||
|
||
#include "RE/Bethesda/BSFixedString.h" | ||
#include "RE/Bethesda/BSLock.h" | ||
#include "RE/Bethesda/BSTArray.h" | ||
#include "RE/Bethesda/BSTSingleton.h" | ||
#include "RE/Bethesda/BSTSmartPointer.h" | ||
#include "RE/Bethesda/UserEvents.h" | ||
|
||
namespace RE | ||
{ | ||
class InputEnableLayerDestroyedEvent; | ||
class OtherEventEnabledEvent; | ||
class UserEventEnabledEvent; | ||
|
||
namespace OtherInputEvents | ||
{ | ||
enum class OTHER_EVENT_FLAG | ||
{ | ||
kAll = static_cast<std::underlying_type_t<OTHER_EVENT_FLAG>>(-1), | ||
|
||
kJournalTabs = 1 << 0, | ||
kActivation = 1 << 1, | ||
kFastTravel = 1 << 2, | ||
kPOVChange = 1 << 3, | ||
kVATS = 1 << 4, | ||
kFavorites = 1 << 5, | ||
kPipboyLight = 1 << 6, | ||
kZKey = 1 << 7, | ||
kRunning = 1 << 8, | ||
kCursor = 1 << 9, | ||
kSprinting = 1 << 10, | ||
}; | ||
} | ||
|
||
using OEFlag = OtherInputEvents::OTHER_EVENT_FLAG; | ||
|
||
class BSInputEnableLayer | ||
{ | ||
public: | ||
constexpr BSInputEnableLayer() noexcept {} // NOLINT(modernize-use-equals-default) | ||
|
||
[[nodiscard]] std::uint32_t DecRef() const | ||
{ | ||
using func_t = decltype(&BSInputEnableLayer::DecRef); | ||
REL::Relocation<func_t> func{ REL::ID(659989) }; | ||
return func(this); | ||
} | ||
|
||
std::uint32_t IncRef() const | ||
{ | ||
stl::atomic_ref myRefCount{ refCount }; | ||
return ++myRefCount; | ||
} | ||
|
||
// members | ||
std::uint32_t layerID; // 00 | ||
mutable std::uint32_t refCount; // 04 | ||
}; | ||
static_assert(sizeof(BSInputEnableLayer) == 0x08); | ||
|
||
class BSInputEnableManager : | ||
public BSTEventSource<UserEventEnabledEvent>, // 000 | ||
public BSTEventSource<OtherEventEnabledEvent>, // 058 | ||
public BSTEventSource<InputEnableLayerDestroyedEvent>, // 0B0 | ||
public BSTSingletonSDM<BSInputEnableManager> // 108 | ||
{ | ||
public: | ||
struct EnableLayer | ||
{ | ||
public: | ||
// members | ||
stl::enumeration<UEFlag, std::uint32_t> inputUserEvents; // 00 | ||
stl::enumeration<OEFlag, std::uint32_t> otherInputEvents; // 04 | ||
}; | ||
static_assert(sizeof(EnableLayer) == 0x08); | ||
|
||
[[nodiscard]] static BSInputEnableManager* GetSingleton() | ||
{ | ||
REL::Relocation<BSInputEnableManager**> singleton{ REL::ID(781703) }; | ||
return *singleton; | ||
} | ||
|
||
bool AllocateNewLayer(BSTSmartPointer<BSInputEnableLayer>& a_layer, const char* a_debugName) | ||
{ | ||
using func_t = decltype(&BSInputEnableManager::AllocateNewLayer); | ||
REL::Relocation<func_t> func{ REL::ID(537494) }; | ||
return func(this, a_layer, a_debugName); | ||
} | ||
|
||
void ClearForcedState() | ||
{ | ||
BSAutoLock locker(cacheLock); | ||
forceEnableInputUserEventsFlags.reset(); | ||
forceOtherInputEventsFlags.reset(); | ||
} | ||
|
||
bool EnableUserEvent(std::uint32_t a_layerID, UEFlag a_userEventFlags, bool a_enable, UserEvents::SENDER_ID a_senderID) | ||
{ | ||
using func_t = decltype(&BSInputEnableManager::EnableUserEvent); | ||
REL::Relocation<func_t> func{ REL::ID(1432984) }; | ||
return func(this, a_layerID, a_userEventFlags, a_enable, a_senderID); | ||
} | ||
|
||
bool EnableOtherEvent(std::uint32_t a_layerID, OEFlag a_otherEventFlags, bool a_enable, UserEvents::SENDER_ID a_senderID) | ||
{ | ||
using func_t = decltype(&BSInputEnableManager::EnableOtherEvent); | ||
REL::Relocation<func_t> func{ REL::ID(1419268) }; | ||
return func(this, a_layerID, a_otherEventFlags, a_enable, a_senderID); | ||
} | ||
|
||
void ForceUserEventEnabled(UEFlag a_userEventFlags, bool a_enable) | ||
{ | ||
BSAutoLock locker(cacheLock); | ||
if (a_enable) { | ||
forceEnableInputUserEventsFlags.set(a_userEventFlags); | ||
} else { | ||
forceEnableInputUserEventsFlags.reset(a_userEventFlags); | ||
} | ||
} | ||
|
||
void ForceOtherEventEnabled(OEFlag a_otherEventFlags, bool a_enable) | ||
{ | ||
BSAutoLock locker(cacheLock); | ||
if (a_enable) { | ||
forceOtherInputEventsFlags.set(a_otherEventFlags); | ||
} else { | ||
forceOtherInputEventsFlags.reset(a_otherEventFlags); | ||
} | ||
} | ||
|
||
// members | ||
BSSpinLock cacheLock; // 110 | ||
stl::enumeration<UEFlag, std::uint32_t> cachedInputUserEventsFlags; // 118 | ||
stl::enumeration<OEFlag, std::uint32_t> cachedOtherInputEventsFlags; // 11C | ||
stl::enumeration<UEFlag, std::uint32_t> forceEnableInputUserEventsFlags; // 120 | ||
stl::enumeration<OEFlag, std::uint32_t> forceOtherInputEventsFlags; // 124 | ||
BSSpinLock layerLock; // 128 | ||
BSTArray<BSInputEnableManager::EnableLayer> layers; // 130 | ||
BSTArray<BSTSmartPointer<BSInputEnableLayer>> layerWrappers; // 148 | ||
BSTArray<BSFixedString> debugNames; // 160 | ||
bool isCurrentlyInSaveLoad; // 178 | ||
}; | ||
static_assert(sizeof(BSInputEnableManager) == 0x180); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.