Enderal SE https://mod.pub/enderal-se/38-enderal-se
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
#pragma once
|
|
|
|
#include <XInput.h>
|
|
#pragma comment(lib, "XInput.lib")
|
|
|
|
namespace BinkInterruptPatch
|
|
{
|
|
struct BinkListener
|
|
{
|
|
static bool thunk()
|
|
{
|
|
auto result = func();
|
|
|
|
if (SKSE::WinAPI::GetKeyState(VK_SPACE) & 0x8000 || SKSE::WinAPI::GetKeyState(VK_ESCAPE) & 0x8000 || SKSE::WinAPI::GetKeyState(VK_LBUTTON) & 0x8000 || SKSE::WinAPI::GetKeyState(VK_RBUTTON) & 0x8000 || SKSE::WinAPI::GetKeyState(VK_LMENU) & 0x8000) {
|
|
return false;
|
|
}
|
|
|
|
if (RE::BSInputDeviceManager::GetSingleton()->IsGamepadEnabled()) {
|
|
for (DWORD index = 0; index < XUSER_MAX_COUNT; index++) {
|
|
XINPUT_STATE state;
|
|
if (XInputGetState(index, &state) == ERROR_SUCCESS) {
|
|
if ((state.Gamepad.wButtons & XINPUT_GAMEPAD_A) || (state.Gamepad.wButtons & XINPUT_GAMEPAD_START)) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
static inline REL::Relocation<decltype(thunk)> func;
|
|
};
|
|
|
|
void Install()
|
|
{
|
|
REL::Relocation<std::uintptr_t> target{ REL::RelocationID(87887, 90256), REL::Relocate(0x9F, 0x16F) };
|
|
auto& trampoline = SKSE::GetTrampoline();
|
|
|
|
SKSE::AllocTrampoline(14);
|
|
BinkListener::func = trampoline.write_call<5>(target.address(), BinkListener::thunk);
|
|
}
|
|
}
|
|
|