Files
ppsspp/SDL/SDLJoystick.h
T
HalexxanderandClaude Opus 5 e5bd8e8e58 Add optional controller rumble on button press
New "Vibrate controller on button press" setting under Controls. When enabled,
pressing a gamepad button rumbles that pad for as long as it's held - something
the PSP hardware never had, but which some people want from a modern pad.

Implemented per platform behind System_ControllerRumbleStart/Stop: SDL uses
SDL_RumbleGamepad, Windows feeds it into XinputDevice's existing vibration path
so it doesn't fight with the vibration games request through sceCtrl, and
Android goes through InputDevice.getVibrator() in Java. Stubbed elsewhere.

The D-pad is excluded, since it gets tapped constantly while navigating.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GgACRqkQNpfJQ4fjwyoEup
2026-09-05 12:08:09 -06:00

33 lines
816 B
C++

#pragma once
#include <SDL3/SDL.h>
#include <map>
#include <vector>
#include "Common/Input/InputState.h"
#include "Common/Input/KeyCodes.h"
#include "Common/Net/Resolve.h"
class SDLJoystick{
public:
SDLJoystick(bool init_SDL = false);
~SDLJoystick();
void registerEventHandler();
void ProcessInput(const SDL_Event &event);
void Rumble(int padIndex, bool start);
private:
void setUpController(SDL_JoystickID deviceID);
void setUpControllers();
InputKeyCode getKeycodeForButton(SDL_GamepadButton button);
int getDeviceIndex(int instanceId);
void releaseAllKeys();
bool registeredAsEventHandler;
std::vector<SDL_Gamepad *> controllers;
std::map<int, int> controllerDeviceMap;
// Deduplicate axis events. Pair is device, axis.
std::map<std::pair<InputDeviceID, InputAxis>, float> prevAxisValue_;
};