Add separate keyboard and mouse input shortcuts
This commit is contained in:
parent
87f4e90ca2
commit
25310655c5
6 changed files with 78 additions and 15 deletions
|
|
@ -648,9 +648,22 @@ void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* eve
|
||||||
|
|
||||||
if (state->buttons == (BACK_FLAG | LB_FLAG | RB_FLAG | Y_FLAG)) {
|
if (state->buttons == (BACK_FLAG | LB_FLAG | RB_FLAG | Y_FLAG)) {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Detected keyboard/mouse input toggle gamepad combo");
|
"Detected keyboard input toggle gamepad combo");
|
||||||
|
|
||||||
Session::get()->toggleKeyboardMouseInputAllowed();
|
Session::get()->toggleKeyboardInputAllowed();
|
||||||
|
|
||||||
|
if (isGamepadInputAllowed()) {
|
||||||
|
LiSendMultiControllerEvent(state->index, m_GamepadMask,
|
||||||
|
0, 0, 0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state->buttons == (BACK_FLAG | LB_FLAG | RB_FLAG | UP_FLAG)) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected mouse input toggle gamepad combo");
|
||||||
|
|
||||||
|
Session::get()->toggleMouseInputAllowed();
|
||||||
|
|
||||||
if (isGamepadInputAllowed()) {
|
if (isGamepadInputAllowed()) {
|
||||||
LiSendMultiControllerEvent(state->index, m_GamepadMask,
|
LiSendMultiControllerEvent(state->index, m_GamepadMask,
|
||||||
|
|
|
||||||
|
|
@ -130,10 +130,15 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, int streamWidth, i
|
||||||
m_SpecialKeyCombos[KeyComboPasteText].scanCode = SDL_SCANCODE_V;
|
m_SpecialKeyCombos[KeyComboPasteText].scanCode = SDL_SCANCODE_V;
|
||||||
m_SpecialKeyCombos[KeyComboPasteText].enabled = true;
|
m_SpecialKeyCombos[KeyComboPasteText].enabled = true;
|
||||||
|
|
||||||
m_SpecialKeyCombos[KeyComboToggleKeyboardMouseInput].keyCombo = KeyComboToggleKeyboardMouseInput;
|
m_SpecialKeyCombos[KeyComboToggleKeyboardInput].keyCombo = KeyComboToggleKeyboardInput;
|
||||||
m_SpecialKeyCombos[KeyComboToggleKeyboardMouseInput].keyCode = SDLK_k;
|
m_SpecialKeyCombos[KeyComboToggleKeyboardInput].keyCode = SDLK_k;
|
||||||
m_SpecialKeyCombos[KeyComboToggleKeyboardMouseInput].scanCode = SDL_SCANCODE_K;
|
m_SpecialKeyCombos[KeyComboToggleKeyboardInput].scanCode = SDL_SCANCODE_K;
|
||||||
m_SpecialKeyCombos[KeyComboToggleKeyboardMouseInput].enabled = true;
|
m_SpecialKeyCombos[KeyComboToggleKeyboardInput].enabled = true;
|
||||||
|
|
||||||
|
m_SpecialKeyCombos[KeyComboToggleMouseInput].keyCombo = KeyComboToggleMouseInput;
|
||||||
|
m_SpecialKeyCombos[KeyComboToggleMouseInput].keyCode = SDLK_o;
|
||||||
|
m_SpecialKeyCombos[KeyComboToggleMouseInput].scanCode = SDL_SCANCODE_O;
|
||||||
|
m_SpecialKeyCombos[KeyComboToggleMouseInput].enabled = true;
|
||||||
|
|
||||||
m_SpecialKeyCombos[KeyComboToggleGamepadInput].keyCombo = KeyComboToggleGamepadInput;
|
m_SpecialKeyCombos[KeyComboToggleGamepadInput].keyCombo = KeyComboToggleGamepadInput;
|
||||||
m_SpecialKeyCombos[KeyComboToggleGamepadInput].keyCode = SDLK_g;
|
m_SpecialKeyCombos[KeyComboToggleGamepadInput].keyCode = SDLK_g;
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,8 @@ private:
|
||||||
KeyComboToggleCursorHide,
|
KeyComboToggleCursorHide,
|
||||||
KeyComboToggleMinimize,
|
KeyComboToggleMinimize,
|
||||||
KeyComboPasteText,
|
KeyComboPasteText,
|
||||||
KeyComboToggleKeyboardMouseInput,
|
KeyComboToggleKeyboardInput,
|
||||||
|
KeyComboToggleMouseInput,
|
||||||
KeyComboToggleGamepadInput,
|
KeyComboToggleGamepadInput,
|
||||||
KeyComboVolumeUp,
|
KeyComboVolumeUp,
|
||||||
KeyComboVolumeDown,
|
KeyComboVolumeDown,
|
||||||
|
|
|
||||||
|
|
@ -142,11 +142,19 @@ void SdlInputHandler::performSpecialKeyCombo(KeyCombo combo)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case KeyComboToggleKeyboardMouseInput:
|
case KeyComboToggleKeyboardInput:
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Detected keyboard/mouse input toggle combo");
|
"Detected keyboard input toggle combo");
|
||||||
if (auto session = Session::get(); session != nullptr) {
|
if (auto session = Session::get(); session != nullptr) {
|
||||||
session->toggleKeyboardMouseInputAllowed();
|
session->toggleKeyboardInputAllowed();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KeyComboToggleMouseInput:
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected mouse input toggle combo");
|
||||||
|
if (auto session = Session::get(); session != nullptr) {
|
||||||
|
session->toggleMouseInputAllowed();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -589,6 +589,28 @@ void Session::setGamepadInputAllowed(bool allowed)
|
||||||
notifyInputPermissionState();
|
notifyInputPermissionState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::setKeyboardInputAllowed(bool allowed)
|
||||||
|
{
|
||||||
|
const bool previous = m_AllowKeyboardInput.exchange(allowed, std::memory_order_relaxed);
|
||||||
|
if (previous && !allowed && m_InputHandler != nullptr) {
|
||||||
|
m_InputHandler->raiseAllKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
sendInputPermissionStateToHost(LI_SESSION_INPUT_POLICY_REASON_USER_TOGGLE);
|
||||||
|
notifyInputPermissionState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Session::setMouseInputAllowed(bool allowed)
|
||||||
|
{
|
||||||
|
const bool previous = m_AllowMouseInput.exchange(allowed, std::memory_order_relaxed);
|
||||||
|
if (previous && !allowed && m_InputHandler != nullptr) {
|
||||||
|
m_InputHandler->raiseAllMouseButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
sendInputPermissionStateToHost(LI_SESSION_INPUT_POLICY_REASON_USER_TOGGLE);
|
||||||
|
notifyInputPermissionState();
|
||||||
|
}
|
||||||
|
|
||||||
void Session::setAudioVolumeScalar(float scalar)
|
void Session::setAudioVolumeScalar(float scalar)
|
||||||
{
|
{
|
||||||
scalar = SDL_clamp(scalar, 0.0f, 1.0f);
|
scalar = SDL_clamp(scalar, 0.0f, 1.0f);
|
||||||
|
|
@ -647,6 +669,16 @@ void Session::toggleGamepadInputAllowed()
|
||||||
setGamepadInputAllowed(!isGamepadInputAllowed());
|
setGamepadInputAllowed(!isGamepadInputAllowed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::toggleKeyboardInputAllowed()
|
||||||
|
{
|
||||||
|
setKeyboardInputAllowed(!isKeyboardInputAllowed());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Session::toggleMouseInputAllowed()
|
||||||
|
{
|
||||||
|
setMouseInputAllowed(!isMouseInputAllowed());
|
||||||
|
}
|
||||||
|
|
||||||
void Session::toggleKeyboardMouseInputAllowed()
|
void Session::toggleKeyboardMouseInputAllowed()
|
||||||
{
|
{
|
||||||
setKeyboardMouseInputAllowed(!isKeyboardMouseInputAllowed());
|
setKeyboardMouseInputAllowed(!isKeyboardMouseInputAllowed());
|
||||||
|
|
@ -726,11 +758,11 @@ void Session::refreshControlPanelOverlay()
|
||||||
SDL_snprintf(panelText,
|
SDL_snprintf(panelText,
|
||||||
sizeof(panelText),
|
sizeof(panelText),
|
||||||
"Stream Controls\n"
|
"Stream Controls\n"
|
||||||
"Keyboard: %s\n"
|
"Keyboard: %s (KB: Ctrl+Alt+Shift+K, Pad: Select+L1+R1+Y)\n"
|
||||||
"Mouse: %s\n"
|
"Mouse: %s (KB: Ctrl+Alt+Shift+O, Pad: Select+L1+R1+DPad Up)\n"
|
||||||
"Pad: %s\n"
|
"Pad: %s (KB: Ctrl+Alt+Shift+G, Pad: Select+L1+R1+A)\n"
|
||||||
"Vol (U/J, mute N): %s\n"
|
"Vol: %s (KB: U/J, mute N; Pad: none)\n"
|
||||||
"UI (Ctrl+Alt+Shift+P / Select+L1+R1+B): ON\n"
|
"UI: ON (KB: Ctrl+Alt+Shift+P, Pad: Select+L1+R1+B)\n"
|
||||||
"Input policy: host controlled",
|
"Input policy: host controlled",
|
||||||
isKeyboardInputAllowed() ? "ON" : "OFF",
|
isKeyboardInputAllowed() ? "ON" : "OFF",
|
||||||
isMouseInputAllowed() ? "ON" : "OFF",
|
isMouseInputAllowed() ? "ON" : "OFF",
|
||||||
|
|
|
||||||
|
|
@ -147,8 +147,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void setGamepadInputAllowed(bool allowed);
|
void setGamepadInputAllowed(bool allowed);
|
||||||
|
void setKeyboardInputAllowed(bool allowed);
|
||||||
|
void setMouseInputAllowed(bool allowed);
|
||||||
void setKeyboardMouseInputAllowed(bool allowed);
|
void setKeyboardMouseInputAllowed(bool allowed);
|
||||||
void toggleGamepadInputAllowed();
|
void toggleGamepadInputAllowed();
|
||||||
|
void toggleKeyboardInputAllowed();
|
||||||
|
void toggleMouseInputAllowed();
|
||||||
void toggleKeyboardMouseInputAllowed();
|
void toggleKeyboardMouseInputAllowed();
|
||||||
void toggleControlPanelVisibility();
|
void toggleControlPanelVisibility();
|
||||||
void notifyInputPermissionState();
|
void notifyInputPermissionState();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue