Files
ppsspp/SDL/SDLJoystick.h
Henrik RydgårdandClaude Opus 5 b115206a66 SDL: Release all input when a controller is disconnected
The last platform that was missing this - it was held back waiting for
the SDL 3.0 migration, which has now happened. Without it, whatever was
held when the pad vanished stays held, which tends to walk the player
off a cliff.

Fixes #20418

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01JvJR8oJNSCimCM9KXVLjfq
2026-09-04 13:10:54 -06:00

32 lines
776 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);
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_;
};