mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2025-01-10 10:18:46 +00:00
Implement trigger rumble using Sunshine protocol extension
This commit is contained in:
parent
2165f56aee
commit
b945c8c2dc
4 changed files with 43 additions and 4 deletions
|
@ -566,6 +566,20 @@ void SdlInputHandler::rumble(unsigned short controllerNumber, unsigned short low
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::rumbleTriggers(uint16_t controllerNumber, uint16_t leftTrigger, uint16_t rightTrigger)
|
||||||
|
{
|
||||||
|
// Make sure the controller number is within our supported count
|
||||||
|
if (controllerNumber >= MAX_GAMEPADS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 14)
|
||||||
|
if (m_GamepadState[controllerNumber].controller != nullptr) {
|
||||||
|
SDL_GameControllerRumbleTriggers(m_GamepadState[controllerNumber].controller, leftTrigger, rightTrigger, 30000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
QString SdlInputHandler::getUnmappedGamepads()
|
QString SdlInputHandler::getUnmappedGamepads()
|
||||||
{
|
{
|
||||||
QString ret;
|
QString ret;
|
||||||
|
|
|
@ -62,7 +62,9 @@ public:
|
||||||
|
|
||||||
void sendText(QString& string);
|
void sendText(QString& string);
|
||||||
|
|
||||||
void rumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsigned short highFreqMotor);
|
void rumble(uint16_t controllerNumber, uint16_t lowFreqMotor, uint16_t highFreqMotor);
|
||||||
|
|
||||||
|
void rumbleTriggers(uint16_t controllerNumber, uint16_t leftTrigger, uint16_t rightTrigger);
|
||||||
|
|
||||||
void handleTouchFingerEvent(SDL_TouchFingerEvent* event);
|
void handleTouchFingerEvent(SDL_TouchFingerEvent* event);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#define SDL_CODE_FLUSH_WINDOW_EVENT_BARRIER 100
|
#define SDL_CODE_FLUSH_WINDOW_EVENT_BARRIER 100
|
||||||
#define SDL_CODE_GAMECONTROLLER_RUMBLE 101
|
#define SDL_CODE_GAMECONTROLLER_RUMBLE 101
|
||||||
|
#define SDL_CODE_GAMECONTROLLER_RUMBLE_TRIGGERS 102
|
||||||
|
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ CONNECTION_LISTENER_CALLBACKS Session::k_ConnCallbacks = {
|
||||||
Session::clRumble,
|
Session::clRumble,
|
||||||
Session::clConnectionStatusUpdate,
|
Session::clConnectionStatusUpdate,
|
||||||
Session::clSetHdrMode,
|
Session::clSetHdrMode,
|
||||||
|
Session::clRumbleTriggers,
|
||||||
};
|
};
|
||||||
|
|
||||||
Session* Session::s_ActiveSession;
|
Session* Session::s_ActiveSession;
|
||||||
|
@ -213,6 +215,19 @@ void Session::clSetHdrMode(bool enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::clRumbleTriggers(uint16_t controllerNumber, uint16_t leftTrigger, uint16_t rightTrigger)
|
||||||
|
{
|
||||||
|
// We push an event for the main thread to handle in order to properly synchronize
|
||||||
|
// with the removal of game controllers that could result in our game controller
|
||||||
|
// going away during this callback.
|
||||||
|
SDL_Event rumbleEvent = {};
|
||||||
|
rumbleEvent.type = SDL_USEREVENT;
|
||||||
|
rumbleEvent.user.code = SDL_CODE_GAMECONTROLLER_RUMBLE_TRIGGERS;
|
||||||
|
rumbleEvent.user.data1 = (void*)(uintptr_t)controllerNumber;
|
||||||
|
rumbleEvent.user.data2 = (void*)(uintptr_t)((leftTrigger << 16) | rightTrigger);
|
||||||
|
SDL_PushEvent(&rumbleEvent);
|
||||||
|
}
|
||||||
|
|
||||||
bool Session::chooseDecoder(StreamingPreferences::VideoDecoderSelection vds,
|
bool Session::chooseDecoder(StreamingPreferences::VideoDecoderSelection vds,
|
||||||
SDL_Window* window, int videoFormat, int width, int height,
|
SDL_Window* window, int videoFormat, int width, int height,
|
||||||
int frameRate, bool enableVsync, bool enableFramePacing, bool testOnly, IVideoDecoder*& chosenDecoder)
|
int frameRate, bool enableVsync, bool enableFramePacing, bool testOnly, IVideoDecoder*& chosenDecoder)
|
||||||
|
@ -1635,9 +1650,14 @@ void Session::execInternal()
|
||||||
m_FlushingWindowEventsRef--;
|
m_FlushingWindowEventsRef--;
|
||||||
break;
|
break;
|
||||||
case SDL_CODE_GAMECONTROLLER_RUMBLE:
|
case SDL_CODE_GAMECONTROLLER_RUMBLE:
|
||||||
m_InputHandler->rumble((unsigned short)(uintptr_t)event.user.data1,
|
m_InputHandler->rumble((uint16_t)(uintptr_t)event.user.data1,
|
||||||
(unsigned short)((uintptr_t)event.user.data2 >> 16),
|
(uint16_t)((uintptr_t)event.user.data2 >> 16),
|
||||||
(unsigned short)((uintptr_t)event.user.data2 & 0xFFFF));
|
(uint16_t)((uintptr_t)event.user.data2 & 0xFFFF));
|
||||||
|
break;
|
||||||
|
case SDL_CODE_GAMECONTROLLER_RUMBLE_TRIGGERS:
|
||||||
|
m_InputHandler->rumbleTriggers((uint16_t)(uintptr_t)event.user.data1,
|
||||||
|
(uint16_t)((uintptr_t)event.user.data2 >> 16),
|
||||||
|
(uint16_t)((uintptr_t)event.user.data2 & 0xFFFF));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SDL_assert(false);
|
SDL_assert(false);
|
||||||
|
|
|
@ -124,6 +124,9 @@ private:
|
||||||
static
|
static
|
||||||
void clSetHdrMode(bool enabled);
|
void clSetHdrMode(bool enabled);
|
||||||
|
|
||||||
|
static
|
||||||
|
void clRumbleTriggers(uint16_t controllerNumber, uint16_t leftTrigger, uint16_t rightTrigger);
|
||||||
|
|
||||||
static
|
static
|
||||||
int arInit(int audioConfiguration,
|
int arInit(int audioConfiguration,
|
||||||
const POPUS_MULTISTREAM_CONFIGURATION opusConfig,
|
const POPUS_MULTISTREAM_CONFIGURATION opusConfig,
|
||||||
|
|
Loading…
Reference in a new issue