From 62c8f66bbed4455cb3a725ed353ec4e474dab1a9 Mon Sep 17 00:00:00 2001 From: str1k3r <115313679+S1l3ntStr1ke87@users.noreply.github.com> Date: Sun, 16 Aug 2026 18:30:23 -0400 Subject: [PATCH] fix: stutters --- 4J_Input/Windows64/INP_Main.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/4J_Input/Windows64/INP_Main.cpp b/4J_Input/Windows64/INP_Main.cpp index f6070a6..f292d47 100644 --- a/4J_Input/Windows64/INP_Main.cpp +++ b/4J_Input/Windows64/INP_Main.cpp @@ -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);