mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
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
39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <XInput.h>
|
|
#include "Core/HLE/sceCtrl.h"
|
|
#include "Windows/InputDevice.h"
|
|
|
|
// Button rumble ("Vibrate controller on button press"), driven from
|
|
// System_ControllerRumbleStart/Stop. Mixed into whatever vibration the game itself
|
|
// asked for, so the two don't fight over the motors.
|
|
void XinputSetButtonRumble(int pad, bool on);
|
|
|
|
class XinputDevice final : public InputDevice {
|
|
public:
|
|
XinputDevice();
|
|
~XinputDevice();
|
|
int UpdateState() override;
|
|
|
|
private:
|
|
void UpdatePad(int pad, const XINPUT_STATE &state, XINPUT_VIBRATION &vibration);
|
|
void ReleaseAllKeys(int pad);
|
|
void ApplyButtons(int pad, const XINPUT_STATE &state);
|
|
void ApplyVibration(int pad, XINPUT_VIBRATION &vibration);
|
|
void ApplyButtonRumble(int pad, XINPUT_VIBRATION &vibration);
|
|
|
|
struct PadData {
|
|
bool connected = false;
|
|
int checkDelayUpdates = 0;
|
|
XINPUT_STATE prevState{};
|
|
XINPUT_VIBRATION prevVibration{};
|
|
u16 vendorId = 0;
|
|
u16 productId = 0;
|
|
float prevAxisValue[6]{};
|
|
u32 prevButtons = 0;
|
|
};
|
|
PadData padData_[XUSER_MAX_COUNT];
|
|
double prevVibrationTime_ = 0.0;
|
|
double newVibrationTime_ = 0.0;
|
|
};
|