mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 06:01:12 +00:00
Revert change to only fire special combos on key up
This commit is contained in:
@@ -24,7 +24,6 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s
|
|||||||
m_FakeCaptureActive(false),
|
m_FakeCaptureActive(false),
|
||||||
m_CaptureSystemKeysMode(prefs.captureSysKeysMode),
|
m_CaptureSystemKeysMode(prefs.captureSysKeysMode),
|
||||||
m_MouseCursorCapturedVisibilityState(SDL_DISABLE),
|
m_MouseCursorCapturedVisibilityState(SDL_DISABLE),
|
||||||
m_PendingKeyCombo(KeyComboMax),
|
|
||||||
m_LongPressTimer(0),
|
m_LongPressTimer(0),
|
||||||
m_StreamWidth(streamWidth),
|
m_StreamWidth(streamWidth),
|
||||||
m_StreamHeight(streamHeight),
|
m_StreamHeight(streamHeight),
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ private:
|
|||||||
|
|
||||||
void handleRelativeFingerEvent(SDL_TouchFingerEvent* event);
|
void handleRelativeFingerEvent(SDL_TouchFingerEvent* event);
|
||||||
|
|
||||||
void performPendingSpecialKeyCombo();
|
void performSpecialKeyCombo(KeyCombo combo);
|
||||||
|
|
||||||
static
|
static
|
||||||
Uint32 longPressTimerCallback(Uint32 interval, void* param);
|
Uint32 longPressTimerCallback(Uint32 interval, void* param);
|
||||||
@@ -200,7 +200,6 @@ private:
|
|||||||
SDL_Scancode scanCode;
|
SDL_Scancode scanCode;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
} m_SpecialKeyCombos[KeyComboMax];
|
} m_SpecialKeyCombos[KeyComboMax];
|
||||||
KeyCombo m_PendingKeyCombo;
|
|
||||||
|
|
||||||
SDL_TouchFingerEvent m_LastTouchDownEvent;
|
SDL_TouchFingerEvent m_LastTouchDownEvent;
|
||||||
SDL_TouchFingerEvent m_LastTouchUpEvent;
|
SDL_TouchFingerEvent m_LastTouchUpEvent;
|
||||||
|
|||||||
@@ -13,12 +13,9 @@
|
|||||||
#define VK_NUMPAD0 0x60
|
#define VK_NUMPAD0 0x60
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SdlInputHandler::performPendingSpecialKeyCombo()
|
void SdlInputHandler::performSpecialKeyCombo(KeyCombo combo)
|
||||||
{
|
{
|
||||||
// The caller must ensure all keys are up
|
switch (combo) {
|
||||||
Q_ASSERT(m_KeysDown.isEmpty());
|
|
||||||
|
|
||||||
switch (m_PendingKeyCombo) {
|
|
||||||
case KeyComboQuit:
|
case KeyComboQuit:
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Detected quit key combo");
|
"Detected quit key combo");
|
||||||
@@ -36,12 +33,20 @@ void SdlInputHandler::performPendingSpecialKeyCombo()
|
|||||||
|
|
||||||
// Stop handling future input
|
// Stop handling future input
|
||||||
setCaptureActive(!isCaptureActive());
|
setCaptureActive(!isCaptureActive());
|
||||||
|
|
||||||
|
// Force raise all keys to ensure they aren't stuck,
|
||||||
|
// since we won't get their key up events.
|
||||||
|
raiseAllKeys();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyComboToggleFullScreen:
|
case KeyComboToggleFullScreen:
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Detected full-screen toggle combo");
|
"Detected full-screen toggle combo");
|
||||||
Session::s_ActiveSession->toggleFullscreen();
|
Session::s_ActiveSession->toggleFullscreen();
|
||||||
|
|
||||||
|
// Force raise all keys just be safe across this full-screen/windowed
|
||||||
|
// transition just in case key events get lost.
|
||||||
|
raiseAllKeys();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyComboToggleStatsOverlay:
|
case KeyComboToggleStatsOverlay:
|
||||||
@@ -84,14 +89,18 @@ void SdlInputHandler::performPendingSpecialKeyCombo()
|
|||||||
case KeyComboToggleMinimize:
|
case KeyComboToggleMinimize:
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Detected minimize combo");
|
"Detected minimize combo");
|
||||||
|
|
||||||
SDL_MinimizeWindow(m_Window);
|
SDL_MinimizeWindow(m_Window);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyComboPasteText:
|
case KeyComboPasteText:
|
||||||
{
|
{
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Detected paste text combo");
|
"Detected type clipboard text combo");
|
||||||
|
|
||||||
|
// Force raise all keys to ensure that none of them interfere
|
||||||
|
// with the text we're going to type.
|
||||||
|
raiseAllKeys();
|
||||||
|
|
||||||
const char* text;
|
const char* text;
|
||||||
if (SDL_HasClipboardText() && (text = SDL_GetClipboardText()) != nullptr) {
|
if (SDL_HasClipboardText() && (text = SDL_GetClipboardText()) != nullptr) {
|
||||||
// Append this data to the clipboard data string for the thread to process
|
// Append this data to the clipboard data string for the thread to process
|
||||||
@@ -113,9 +122,6 @@ void SdlInputHandler::performPendingSpecialKeyCombo()
|
|||||||
default:
|
default:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset pending key combo
|
|
||||||
m_PendingKeyCombo = KeyComboMax;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IS_SYNTHETIC_KEY_EVENT(x) ((x)->timestamp == 0)
|
#define IS_SYNTHETIC_KEY_EVENT(x) ((x)->timestamp == 0)
|
||||||
@@ -125,6 +131,12 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
|
|||||||
short keyCode;
|
short keyCode;
|
||||||
char modifiers;
|
char modifiers;
|
||||||
|
|
||||||
|
if (event->repeat) {
|
||||||
|
// Ignore repeat key down events
|
||||||
|
SDL_assert(event->state == SDL_PRESSED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for our special key combos
|
// Check for our special key combos
|
||||||
// Ignore timestamp == 0 which are sent from our keyboard code.
|
// Ignore timestamp == 0 which are sent from our keyboard code.
|
||||||
if (!IS_SYNTHETIC_KEY_EVENT(event) &&
|
if (!IS_SYNTHETIC_KEY_EVENT(event) &&
|
||||||
@@ -143,36 +155,21 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
|
|||||||
// where the SDLK for one shortcut collides with
|
// where the SDLK for one shortcut collides with
|
||||||
// the scancode of another.
|
// the scancode of another.
|
||||||
|
|
||||||
if (m_PendingKeyCombo == KeyComboMax) {
|
for (int i = 0; i < KeyComboMax; i++) {
|
||||||
for (int i = 0; i < KeyComboMax; i++) {
|
if (m_SpecialKeyCombos[i].enabled && event->keysym.sym == m_SpecialKeyCombos[i].keyCode) {
|
||||||
if (m_SpecialKeyCombos[i].enabled && event->keysym.sym == m_SpecialKeyCombos[i].keyCode) {
|
performSpecialKeyCombo(m_SpecialKeyCombos[i].keyCombo);
|
||||||
m_PendingKeyCombo = m_SpecialKeyCombos[i].keyCombo;
|
return;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_PendingKeyCombo == KeyComboMax) {
|
for (int i = 0; i < KeyComboMax; i++) {
|
||||||
for (int i = 0; i < KeyComboMax; i++) {
|
if (m_SpecialKeyCombos[i].enabled && event->keysym.scancode == m_SpecialKeyCombos[i].scanCode) {
|
||||||
if (m_SpecialKeyCombos[i].enabled && event->keysym.scancode == m_SpecialKeyCombos[i].scanCode) {
|
performSpecialKeyCombo(m_SpecialKeyCombos[i].keyCombo);
|
||||||
m_PendingKeyCombo = m_SpecialKeyCombos[i].keyCombo;
|
return;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_SYNTHETIC_KEY_EVENT(event) && event->state == SDL_PRESSED && m_PendingKeyCombo != KeyComboMax) {
|
|
||||||
// Ignore further key presses until the special combo is raised
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event->repeat) {
|
|
||||||
// Ignore repeat key down events
|
|
||||||
SDL_assert(event->state == SDL_PRESSED);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set modifier flags
|
// Set modifier flags
|
||||||
modifiers = 0;
|
modifiers = 0;
|
||||||
if (event->keysym.mod & KMOD_CTRL) {
|
if (event->keysym.mod & KMOD_CTRL) {
|
||||||
@@ -422,19 +419,4 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
|
|||||||
event->state == SDL_PRESSED ?
|
event->state == SDL_PRESSED ?
|
||||||
KEY_ACTION_DOWN : KEY_ACTION_UP,
|
KEY_ACTION_DOWN : KEY_ACTION_UP,
|
||||||
modifiers);
|
modifiers);
|
||||||
|
|
||||||
if (!IS_SYNTHETIC_KEY_EVENT(event) && m_PendingKeyCombo != KeyComboMax && m_KeysDown.isEmpty()) {
|
|
||||||
int keys;
|
|
||||||
const Uint8 *keyState = SDL_GetKeyboardState(&keys);
|
|
||||||
|
|
||||||
// Make sure all client keys are up before we process the special key combo
|
|
||||||
for (int i = 0; i < keys; i++) {
|
|
||||||
if (keyState[i] == SDL_PRESSED) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we made it this far, no keys are pressed
|
|
||||||
performPendingSpecialKeyCombo();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user