mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 04:41:39 +00:00
options_menu: prohibit right stick input to prevent camera moving in villages
This commit is contained in:
parent
8220f6772b
commit
5e525bd18d
5 changed files with 55 additions and 22 deletions
|
|
@ -7,10 +7,14 @@ hid::EInputDevice hid::g_inputDeviceController;
|
|||
hid::EInputDeviceExplicit hid::g_inputDeviceExplicit;
|
||||
|
||||
uint16_t hid::g_prohibitedButtons;
|
||||
bool hid::g_isLeftStickProhibited;
|
||||
bool hid::g_isRightStickProhibited;
|
||||
|
||||
void hid::SetProhibitedButtons(uint16_t wButtons)
|
||||
void hid::SetProhibitedInputs(uint16_t wButtons, bool leftStick, bool rightStick)
|
||||
{
|
||||
hid::g_prohibitedButtons = wButtons;
|
||||
hid::g_isLeftStickProhibited = leftStick;
|
||||
hid::g_isRightStickProhibited = rightStick;
|
||||
}
|
||||
|
||||
bool hid::IsInputAllowed()
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ namespace hid
|
|||
extern EInputDeviceExplicit g_inputDeviceExplicit;
|
||||
|
||||
extern uint16_t g_prohibitedButtons;
|
||||
extern bool g_isLeftStickProhibited;
|
||||
extern bool g_isRightStickProhibited;
|
||||
|
||||
void Init();
|
||||
|
||||
|
|
@ -40,7 +42,7 @@ namespace hid
|
|||
uint32_t SetState(uint32_t dwUserIndex, XAMINPUT_VIBRATION* pVibration);
|
||||
uint32_t GetCapabilities(uint32_t dwUserIndex, XAMINPUT_CAPABILITIES* pCaps);
|
||||
|
||||
void SetProhibitedButtons(uint16_t wButtons);
|
||||
void SetProhibitedInputs(uint16_t wButtons = 0, bool leftStick = false, bool rightStick = false);
|
||||
bool IsInputAllowed();
|
||||
bool IsInputDeviceController();
|
||||
std::string GetInputDeviceName();
|
||||
|
|
|
|||
|
|
@ -466,6 +466,18 @@ uint32_t XamInputGetState(uint32_t userIndex, uint32_t flags, XAMINPUT_STATE* st
|
|||
|
||||
state->Gamepad.wButtons &= ~hid::g_prohibitedButtons;
|
||||
|
||||
if (hid::g_isLeftStickProhibited)
|
||||
{
|
||||
state->Gamepad.sThumbLX = 0;
|
||||
state->Gamepad.sThumbLY = 0;
|
||||
}
|
||||
|
||||
if (hid::g_isRightStickProhibited)
|
||||
{
|
||||
state->Gamepad.sThumbRX = 0;
|
||||
state->Gamepad.sThumbRY = 0;
|
||||
}
|
||||
|
||||
ByteSwapInplace(state->Gamepad.wButtons);
|
||||
ByteSwapInplace(state->Gamepad.sThumbLX);
|
||||
ByteSwapInplace(state->Gamepad.sThumbLY);
|
||||
|
|
|
|||
|
|
@ -783,7 +783,7 @@ void AchievementMenu::Open()
|
|||
ResetSelection();
|
||||
Game_PlaySound("sys_actstg_pausewinopen");
|
||||
|
||||
hid::SetProhibitedButtons(XAMINPUT_GAMEPAD_START);
|
||||
hid::SetProhibitedInputs(XAMINPUT_GAMEPAD_START);
|
||||
}
|
||||
|
||||
void AchievementMenu::Close()
|
||||
|
|
@ -793,7 +793,7 @@ void AchievementMenu::Close()
|
|||
g_appearTime = ImGui::GetTime();
|
||||
g_isClosing = true;
|
||||
|
||||
hid::SetProhibitedButtons(0);
|
||||
hid::SetProhibitedInputs();
|
||||
}
|
||||
|
||||
ButtonGuide::Close();
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include <app.h>
|
||||
#include <decompressor.h>
|
||||
#include <exports.h>
|
||||
#include <sdl_listener.h>
|
||||
|
||||
#include <res/images/options_menu/miles_electric.dds.h>
|
||||
|
||||
|
|
@ -101,6 +102,24 @@ static double g_appearTime = 0.0;
|
|||
|
||||
static std::unique_ptr<GuestTexture> g_upMilesElectric;
|
||||
|
||||
static float g_rightStickY;
|
||||
|
||||
class SDLEventListenerForOptionsMenu : public SDLEventListener
|
||||
{
|
||||
public:
|
||||
bool OnSDLEvent(SDL_Event* event) override
|
||||
{
|
||||
if (!OptionsMenu::s_isVisible || !hid::IsInputAllowed())
|
||||
return false;
|
||||
|
||||
if (event->type == SDL_CONTROLLERAXISMOTION && event->caxis.axis == SDL_CONTROLLER_AXIS_RIGHTY)
|
||||
g_rightStickY = event->caxis.value / 32767.0f;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
g_sdlEventListenerForOptionsMenu;
|
||||
|
||||
static void DrawTitle()
|
||||
{
|
||||
static constexpr double fadeOffset = 3.0;
|
||||
|
|
@ -1476,23 +1495,19 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax)
|
|||
|
||||
if (scrollMax > 0.0f)
|
||||
{
|
||||
if (auto pInputState = SWA::CInputState::GetInstance())
|
||||
{
|
||||
auto& rPadState = pInputState->GetPadState();
|
||||
auto& vert = rPadState.RightStickVertical;
|
||||
auto vert = -g_rightStickY;
|
||||
|
||||
if (fabs(vert) > 0.25f)
|
||||
{
|
||||
isManualScrolling = true;
|
||||
scrollOffset += vert * scrollSpeed * App::s_deltaTime;
|
||||
}
|
||||
else if (isManualScrolling && fabs(vert) <= 0.25f)
|
||||
{
|
||||
isScrolling = false;
|
||||
isManualScrolling = false;
|
||||
scrollTimer = 0.0f;
|
||||
scrollDirection = vert > 0.0f ? 1.0f : -1.0f;
|
||||
}
|
||||
if (fabs(vert) > 0.25f)
|
||||
{
|
||||
isManualScrolling = true;
|
||||
scrollOffset += vert * scrollSpeed * App::s_deltaTime;
|
||||
}
|
||||
else if (isManualScrolling && fabs(vert) <= 0.25f)
|
||||
{
|
||||
isScrolling = false;
|
||||
isManualScrolling = false;
|
||||
scrollTimer = 0.0f;
|
||||
scrollDirection = vert > 0.0f ? 1.0f : -1.0f;
|
||||
}
|
||||
|
||||
if (!isManualScrolling)
|
||||
|
|
@ -1750,7 +1765,7 @@ void OptionsMenu::Open(bool isPause, SWA::EMenuType pauseMenuType)
|
|||
ButtonGuide::Open(buttons);
|
||||
ButtonGuide::SetSideMargins(250);
|
||||
|
||||
hid::SetProhibitedButtons(XAMINPUT_GAMEPAD_START);
|
||||
hid::SetProhibitedInputs(XAMINPUT_GAMEPAD_START, false, true);
|
||||
}
|
||||
|
||||
void OptionsMenu::Close()
|
||||
|
|
@ -1764,7 +1779,7 @@ void OptionsMenu::Close()
|
|||
ButtonGuide::Close();
|
||||
Config::Save();
|
||||
|
||||
hid::SetProhibitedButtons(0);
|
||||
hid::SetProhibitedInputs();
|
||||
}
|
||||
|
||||
// Skip Miles Electric animation at main menu.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue