mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-10-12 03:24:00 +00:00
Reorganize a couple mouse and keyboard functions
This commit is contained in:
@@ -270,45 +270,6 @@ void SdlInputHandler::setWindow(SDL_Window *window)
|
||||
m_Window = window;
|
||||
}
|
||||
|
||||
void SdlInputHandler::raiseAllKeys()
|
||||
{
|
||||
if (m_KeysDown.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Raising %d keys",
|
||||
(int)m_KeysDown.count());
|
||||
|
||||
for (auto keyDown : std::as_const(m_KeysDown)) {
|
||||
LiSendKeyboardEvent(keyDown, KEY_ACTION_UP, 0);
|
||||
}
|
||||
|
||||
m_KeysDown.clear();
|
||||
}
|
||||
|
||||
void SdlInputHandler::notifyMouseLeave()
|
||||
{
|
||||
if (m_NeedsManualCaptureOnLeave) {
|
||||
// SDL on Windows doesn't send the mouse button up until the mouse re-enters the window
|
||||
// after leaving it. This breaks some of the Aero snap gestures, so we'll capture it to
|
||||
// allow us to receive the mouse button up events later.
|
||||
//
|
||||
// On macOS and X11, capturing the mouse allows us to receive mouse motion outside the
|
||||
// window (button up already worked without capture).
|
||||
if (m_AbsoluteMouseMode && isCaptureActive()) {
|
||||
// NB: Not using SDL_GetGlobalMouseState() because we want our state not the system's
|
||||
Uint32 mouseState = SDL_GetMouseState(nullptr, nullptr);
|
||||
for (Uint32 button = SDL_BUTTON_LEFT; button <= SDL_BUTTON_X2; button++) {
|
||||
if (mouseState & SDL_BUTTON(button)) {
|
||||
SDL_CaptureMouse(SDL_TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SdlInputHandler::notifyFocusLost()
|
||||
{
|
||||
// Release mouse cursor when another window is activated (e.g. by using ALT+TAB).
|
||||
|
||||
@@ -478,3 +478,20 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
|
||||
modifiers,
|
||||
shouldNotConvertToScanCodeOnServer ? SS_KBE_FLAG_NON_NORMALIZED : 0);
|
||||
}
|
||||
|
||||
void SdlInputHandler::raiseAllKeys()
|
||||
{
|
||||
if (m_KeysDown.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Raising %d keys",
|
||||
(int)m_KeysDown.count());
|
||||
|
||||
for (auto keyDown : std::as_const(m_KeysDown)) {
|
||||
LiSendKeyboardEvent(keyDown, KEY_ACTION_UP, 0);
|
||||
}
|
||||
|
||||
m_KeysDown.clear();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,28 @@
|
||||
#include "SDL_compat.h"
|
||||
#include "streaming/streamutils.h"
|
||||
|
||||
void SdlInputHandler::notifyMouseLeave()
|
||||
{
|
||||
if (m_NeedsManualCaptureOnLeave) {
|
||||
// SDL on Windows doesn't send the mouse button up until the mouse re-enters the window
|
||||
// after leaving it. This breaks some of the Aero snap gestures, so we'll capture it to
|
||||
// allow us to receive the mouse button up events later.
|
||||
//
|
||||
// On macOS and X11, capturing the mouse allows us to receive mouse motion outside the
|
||||
// window (button up already worked without capture).
|
||||
if (m_AbsoluteMouseMode && isCaptureActive()) {
|
||||
// NB: Not using SDL_GetGlobalMouseState() because we want our state not the system's
|
||||
Uint32 mouseState = SDL_GetMouseState(nullptr, nullptr);
|
||||
for (Uint32 button = SDL_BUTTON_LEFT; button <= SDL_BUTTON_X2; button++) {
|
||||
if (mouseState & SDL_BUTTON(button)) {
|
||||
SDL_CaptureMouse(SDL_TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SdlInputHandler::handleMouseButtonEvent(SDL_MouseButtonEvent* event)
|
||||
{
|
||||
int button;
|
||||
|
||||
Reference in New Issue
Block a user