mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
Validate controllers when handling rumble events from GameStream
Rumble events may be received for controllers that are no longer present or attached so they should be dropped instead of being forwarded to JS for handling.
This commit is contained in:
parent
dccd8ec7ef
commit
ce52398dc5
@ -132,6 +132,14 @@ void MoonlightInstance::PollGamepads() {
|
|||||||
|
|
||||||
void MoonlightInstance::ClControllerRumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsigned short highFreqMotor)
|
void MoonlightInstance::ClControllerRumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsigned short highFreqMotor)
|
||||||
{
|
{
|
||||||
|
PP_GamepadsSampleData gamepadData;
|
||||||
|
g_Instance->m_GamepadApi->Sample(g_Instance->pp_instance(), &gamepadData);
|
||||||
|
|
||||||
|
// We must determine which gamepads are connected before sending rumble events.
|
||||||
|
const unsigned short activeGamepadMask = static_cast<unsigned short>(GetActiveGamepadMask(gamepadData));
|
||||||
|
if ((activeGamepadMask & (1 << controllerNumber)) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
const float weakMagnitude = static_cast<float>(highFreqMotor) / static_cast<float>(UINT16_MAX);
|
const float weakMagnitude = static_cast<float>(highFreqMotor) / static_cast<float>(UINT16_MAX);
|
||||||
const float strongMagnitude = static_cast<float>(lowFreqMotor) / static_cast<float>(UINT16_MAX);
|
const float strongMagnitude = static_cast<float>(lowFreqMotor) / static_cast<float>(UINT16_MAX);
|
||||||
|
|
||||||
|
@ -166,6 +166,9 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
|||||||
void NvHTTPInit(int32_t callbackId, pp::VarArray args);
|
void NvHTTPInit(int32_t callbackId, pp::VarArray args);
|
||||||
void NvHTTPRequest(int32_t, int32_t callbackId, pp::VarArray args);
|
void NvHTTPRequest(int32_t, int32_t callbackId, pp::VarArray args);
|
||||||
|
|
||||||
|
public:
|
||||||
|
const PPB_Gamepad* m_GamepadApi;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static CONNECTION_LISTENER_CALLBACKS s_ClCallbacks;
|
static CONNECTION_LISTENER_CALLBACKS s_ClCallbacks;
|
||||||
static DECODER_RENDERER_CALLBACKS s_DrCallbacks;
|
static DECODER_RENDERER_CALLBACKS s_DrCallbacks;
|
||||||
@ -198,7 +201,6 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
|||||||
pp::Audio m_AudioPlayer;
|
pp::Audio m_AudioPlayer;
|
||||||
|
|
||||||
double m_LastPadTimestamps[4];
|
double m_LastPadTimestamps[4];
|
||||||
const PPB_Gamepad* m_GamepadApi;
|
|
||||||
pp::CompletionCallbackFactory<MoonlightInstance> m_CallbackFactory;
|
pp::CompletionCallbackFactory<MoonlightInstance> m_CallbackFactory;
|
||||||
bool m_MouseLocked;
|
bool m_MouseLocked;
|
||||||
bool m_WaitingForAllModifiersUp;
|
bool m_WaitingForAllModifiersUp;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user