fix: stutters

This commit is contained in:
2026-08-16 18:30:23 -04:00
parent 0c24c663ef
commit 62c8f66bbe
+14 -14
View File
@@ -26,7 +26,6 @@ SOFTWARE.
#include "vendor\SDL\include\SDL3\SDL.h"
CInput InternalInputManager;
SDL_Event event;
CInput::CInput()
{
@@ -277,15 +276,11 @@ void CInput::SetJoypadValues(JOYPAD *pThisPad)
pThisPad->m_iLeftThumbY = sThumbLY - m_iDeadzone;
}
pThisPad->m_iNormalizedLeftThumbX = pThisPad->m_iLeftThumbX / m_iEffectiveRange;
pThisPad->m_iNormalizedLeftThumbY = pThisPad->m_iLeftThumbY / m_iEffectiveRange;
pThisPad->m_iNormalizedRightThumbX = pThisPad->m_iRightThumbX / m_iEffectiveRange;
pThisPad->m_iNormalizedRightThumbY = pThisPad->m_iRightThumbY / m_iEffectiveRange;
pThisPad->m_fNormalizedLeftThumbX = pThisPad->m_iLeftThumbX / m_fEffectiveRange;
pThisPad->m_fNormalizedLeftThumbY = pThisPad->m_iLeftThumbY / m_fEffectiveRange;
pThisPad->m_fNormalizedRightThumbX = pThisPad->m_iRightThumbX / m_fEffectiveRange;
pThisPad->m_fNormalizedRightThumbY = pThisPad->m_iRightThumbY / m_fEffectiveRange;
//str1k3r - silly piebot this was duplicated, also make these floats :3
pThisPad->m_fNormalizedLeftThumbX = (float)pThisPad->m_iLeftThumbX / m_fEffectiveRange;
pThisPad->m_fNormalizedLeftThumbY = (float)pThisPad->m_iLeftThumbY / m_fEffectiveRange;
pThisPad->m_fNormalizedRightThumbX = (float)pThisPad->m_iRightThumbX / m_fEffectiveRange;
pThisPad->m_fNormalizedRightThumbY = (float)pThisPad->m_iRightThumbY / m_fEffectiveRange;
}
void CInput::SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax)
@@ -625,21 +620,25 @@ FLOAT CInput::GetIdleSeconds(int iPad)
void CInput::HandleGamepadEvents()
{
while (SDL_PollEvent(&event))
//str1k3r - writing/reading a global can make stuff stutter alot
SDL_Event localEvent;
while (SDL_PollEvent(&localEvent))
{
switch (event.type)
switch (localEvent.type)
{
case SDL_EVENT_GAMEPAD_ADDED:
for (int i = 0; i < MAX_JOYPADS; i++)
{
if (!m_Joypads[i].m_pGamepad)
{
SDL_Gamepad *pad = SDL_OpenGamepad(event.gdevice.which);
SDL_Gamepad *pad = SDL_OpenGamepad(localEvent.gdevice.which);
if (pad)
{
SDL_SetGamepadPlayerIndex(pad, i);
m_Joypads[i].m_pGamepad = pad;
m_Joypads[i].m_bIsConnected = true;
}
break;
@@ -653,7 +652,7 @@ void CInput::HandleGamepadEvents()
for (int i = 0; i < MAX_JOYPADS; i++)
{
if (m_Joypads[i].m_pGamepad &&
SDL_GetGamepadID(m_Joypads[i].m_pGamepad) == event.gdevice.which)
SDL_GetGamepadID(m_Joypads[i].m_pGamepad) == localEvent.gdevice.which)
{
SDL_CloseGamepad(m_Joypads[i].m_pGamepad);
m_Joypads[i].m_pGamepad = nullptr;
@@ -667,6 +666,7 @@ void CInput::HandleGamepadEvents()
{
for (int i = 1; i < MAX_JOYPADS; i++)
{
//str1k3r - since we used to never set m_bIsConnected when a gamepad was added this never ran
if (m_Joypads[i].m_bIsConnected && m_Joypads[i].m_pGamepad)
{
ShiftGamepadData(0, i);