mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2025-01-23 16:15:02 +00:00
Add Share+PS combo for clickpad button emulation on PS4/5 controllers
This commit is contained in:
parent
8ffadde9cc
commit
53c2c612c9
2 changed files with 26 additions and 1 deletions
|
@ -54,9 +54,23 @@ SdlInputHandler::findStateForGamepad(SDL_JoystickID id)
|
|||
void SdlInputHandler::sendGamepadState(GamepadState* state)
|
||||
{
|
||||
SDL_assert(m_GamepadMask == 0x1 || m_MultiController);
|
||||
|
||||
// Handle Select+PS as the clickpad button on PS4/5 controllers without a clickpad mapping
|
||||
int buttons = state->buttons;
|
||||
if (state->clickpadButtonEmulationEnabled) {
|
||||
if (state->buttons == (BACK_FLAG | SPECIAL_FLAG)) {
|
||||
buttons = MISC_FLAG;
|
||||
state->emulatedClickpadButtonDown = true;
|
||||
}
|
||||
else if (state->emulatedClickpadButtonDown) {
|
||||
buttons &= ~MISC_FLAG;
|
||||
state->emulatedClickpadButtonDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
LiSendMultiControllerEvent(state->index,
|
||||
m_GamepadMask,
|
||||
state->buttons,
|
||||
buttons,
|
||||
state->lt,
|
||||
state->rt,
|
||||
state->lsX,
|
||||
|
@ -639,6 +653,14 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve
|
|||
break;
|
||||
}
|
||||
|
||||
// If this is a PlayStation controller that doesn't have a touchpad button mapped,
|
||||
// we'll allow the Select+PS button combo to act as the touchpad.
|
||||
state->clickpadButtonEmulationEnabled =
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 14)
|
||||
SDL_GameControllerGetBindForButton(state->controller, SDL_CONTROLLER_BUTTON_TOUCHPAD).bindType == SDL_CONTROLLER_BINDTYPE_NONE &&
|
||||
#endif
|
||||
type == LI_CTYPE_PS;
|
||||
|
||||
LiSendControllerArrivalEvent(state->index, m_GamepadMask, type, supportedButtonFlags, capabilities);
|
||||
#else
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@ struct GamepadState {
|
|||
SDL_TimerID mouseEmulationTimer;
|
||||
uint32_t lastStartDownTime;
|
||||
|
||||
bool clickpadButtonEmulationEnabled;
|
||||
bool emulatedClickpadButtonDown;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 14)
|
||||
uint8_t gyroReportPeriodMs;
|
||||
float lastGyroEventData[SDL_arraysize(SDL_ControllerSensorEvent::data)];
|
||||
|
|
Loading…
Reference in a new issue