From f85bdd8a45e83d304cbf8ab826588d65c7032d26 Mon Sep 17 00:00:00 2001 From: str1k3r <115313679+S1l3ntStr1ke87@users.noreply.github.com> Date: Mon, 14 Sep 2026 21:27:48 -0400 Subject: [PATCH] feat: SDL3 for rumble & PS touchpad thingy --- 4J_Input/Windows64/INP_ForceFeedback.cpp | 19 ++++++++++--------- 4J_Input/Windows64/INP_ForceFeedback.h | 6 ++++-- 4J_Input/Windows64/INP_Main.cpp | 5 +++++ Headers/Windows64/4J_Input.h | 4 +++- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/4J_Input/Windows64/INP_ForceFeedback.cpp b/4J_Input/Windows64/INP_ForceFeedback.cpp index 804615c..02fa3b4 100644 --- a/4J_Input/Windows64/INP_ForceFeedback.cpp +++ b/4J_Input/Windows64/INP_ForceFeedback.cpp @@ -85,8 +85,8 @@ void CForceFeedback::AddRumble(unsigned int uiPad, WORD leftMotorSpeed, WORD rig QueryPerformanceCounter(&qwCurrentTime); pRumble->m_TimeLeft = (m_TicksPerSecond * fSeconds) + qwCurrentTime.QuadPart; - pRumble->m_RumbleData.wLeftMotorSpeed = leftMotorSpeed; - pRumble->m_RumbleData.wRightMotorSpeed = rightMotorSpeed; + pRumble->m_LowFreqRumble = leftMotorSpeed; + pRumble->m_HighFreqRumble = rightMotorSpeed; pRumble->m_Pad = uiPad; m_RumbleList.AddToTail(pRumble); @@ -108,14 +108,15 @@ void CForceFeedback::Tick(void) LinkedList::_LL_NODE *pRumbleNode = m_RumbleList.m_Head; while (pRumbleNode) { - if (pRumbleNode->GetDataAs()->m_TimeLeft <= qwCurrentTime.QuadPart) + RUMBLE_EFFECT *pRumble = pRumbleNode->GetDataAs(); + SDL_Gamepad* m_pGamepad = SDL_GetGamepadFromPlayerIndex(pRumble->m_Pad); + + if (pRumble->m_TimeLeft <= qwCurrentTime.QuadPart) { - RUMBLE_EFFECT *pRumble = pRumbleNode->GetDataAs(); + pRumble->m_LowFreqRumble = 0; + pRumble->m_HighFreqRumble = 0; - pRumble->m_RumbleData.wLeftMotorSpeed = 0; - pRumble->m_RumbleData.wRightMotorSpeed = 0; - - XInputSetState(pRumble->m_Pad, &pRumble->m_RumbleData); + if (m_pGamepad != nullptr) SDL_RumbleGamepad(m_pGamepad, 0, 0, 0); m_RumbleList.RemoveNode(pRumbleNode); @@ -127,7 +128,7 @@ void CForceFeedback::Tick(void) } else { - XInputSetState(pRumbleNode->GetDataAs()->m_Pad, &pRumbleNode->GetDataAs()->m_RumbleData); + if (m_pGamepad != nullptr) SDL_RumbleGamepad(m_pGamepad, pRumble->m_LowFreqRumble, pRumble->m_HighFreqRumble, 30000); pRumbleNode = pRumbleNode->m_Next; } } diff --git a/4J_Input/Windows64/INP_ForceFeedback.h b/4J_Input/Windows64/INP_ForceFeedback.h index df75a47..1f647e1 100644 --- a/4J_Input/Windows64/INP_ForceFeedback.h +++ b/4J_Input/Windows64/INP_ForceFeedback.h @@ -24,6 +24,7 @@ SOFTWARE. */ #include "LinkedList.h" +#include "SDL3\SDL_gamepad.h" #define MAX_EFFECTS 10 @@ -38,9 +39,10 @@ public: struct RUMBLE_EFFECT { - DWORD m_Pad; + int m_Pad; uint64_t m_TimeLeft; - XINPUT_VIBRATION m_RumbleData; + uint16_t m_LowFreqRumble; + uint16_t m_HighFreqRumble; WORD unk; }; diff --git a/4J_Input/Windows64/INP_Main.cpp b/4J_Input/Windows64/INP_Main.cpp index 4d34fb1..7435bd4 100644 --- a/4J_Input/Windows64/INP_Main.cpp +++ b/4J_Input/Windows64/INP_Main.cpp @@ -148,6 +148,11 @@ void CInput::SetJoypadValues(JOYPAD *pThisPad) pThisPad->m_uiButtons |= _360_JOY_BUTTON_BACK; } + if (SDL_GetGamepadButton(pGamePad, SDL_GAMEPAD_BUTTON_TOUCHPAD)) + { + pThisPad->m_uiButtons |= _PS_JOY_BUTTON_TOUCHPAD; + } + if (SDL_GetGamepadButton(pGamePad, SDL_GAMEPAD_BUTTON_LEFT_STICK)) { pThisPad->m_uiButtons |= _360_JOY_BUTTON_LTHUMB; diff --git a/Headers/Windows64/4J_Input.h b/Headers/Windows64/4J_Input.h index 545e7a7..5b7c322 100644 --- a/Headers/Windows64/4J_Input.h +++ b/Headers/Windows64/4J_Input.h @@ -1,6 +1,5 @@ #pragma once - #define MAP_STYLE_0 0 #define MAP_STYLE_1 1 #define MAP_STYLE_2 2 @@ -36,6 +35,9 @@ #define _360_JOY_BUTTON_RT 0x00400000 #define _360_JOY_BUTTON_LT 0x00800000 +//str1k3r - DualShock 4 / DualSense Touchpad +#define _PS_JOY_BUTTON_TOUCHPAD _360_JOY_BUTTON_BACK + // Stick axis maps - to allow changes for SouthPaw in-game axis mapping #define AXIS_MAP_LX 0 #define AXIS_MAP_LY 1