Split keyboard and mouse policy handling
This commit is contained in:
parent
d174341b6d
commit
87f4e90ca2
7 changed files with 75 additions and 43 deletions
|
|
@ -557,7 +557,8 @@ Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *prefere
|
|||
m_ManualAudioMuted(false),
|
||||
m_AudioVolumeScalar(1.0f),
|
||||
m_AllowGamepadInput(true),
|
||||
m_AllowKeyboardMouseInput(false),
|
||||
m_AllowKeyboardInput(false),
|
||||
m_AllowMouseInput(false),
|
||||
m_ControlPanelVisible(true),
|
||||
m_ConnectionStatus(CONN_STATUS_OKAY),
|
||||
m_StatusOverlayGeneration(0),
|
||||
|
|
@ -627,9 +628,13 @@ void Session::notifyAudioVolumeState()
|
|||
|
||||
void Session::setKeyboardMouseInputAllowed(bool allowed)
|
||||
{
|
||||
bool previous = m_AllowKeyboardMouseInput.exchange(allowed, std::memory_order_relaxed);
|
||||
if (previous && !allowed && m_InputHandler != nullptr) {
|
||||
const bool previousKeyboard = m_AllowKeyboardInput.exchange(allowed, std::memory_order_relaxed);
|
||||
if (previousKeyboard && !allowed && m_InputHandler != nullptr) {
|
||||
m_InputHandler->raiseAllKeys();
|
||||
}
|
||||
|
||||
const bool previousMouse = m_AllowMouseInput.exchange(allowed, std::memory_order_relaxed);
|
||||
if (previousMouse && !allowed && m_InputHandler != nullptr) {
|
||||
m_InputHandler->raiseAllMouseButtons();
|
||||
}
|
||||
|
||||
|
|
@ -656,11 +661,12 @@ void Session::toggleControlPanelVisibility()
|
|||
|
||||
void Session::notifyInputPermissionState()
|
||||
{
|
||||
char buffer[96];
|
||||
char buffer[160];
|
||||
SDL_snprintf(buffer,
|
||||
sizeof(buffer),
|
||||
"Keyboard/Mouse: %s\nGamepad: %s",
|
||||
isKeyboardMouseInputAllowed() ? "ON" : "OFF",
|
||||
"Input policy: host controlled\nKeyboard: %s\nMouse: %s\nGamepad: %s",
|
||||
isKeyboardInputAllowed() ? "ON" : "OFF",
|
||||
isMouseInputAllowed() ? "ON" : "OFF",
|
||||
isGamepadInputAllowed() ? "ON" : "OFF");
|
||||
|
||||
showTemporaryStatusOverlay(buffer);
|
||||
|
|
@ -668,10 +674,11 @@ void Session::notifyInputPermissionState()
|
|||
|
||||
void Session::sendInputPermissionStateToHost(uint8_t reason)
|
||||
{
|
||||
const bool allowKeyboardMouse = isKeyboardMouseInputAllowed();
|
||||
const bool allowKeyboard = isKeyboardInputAllowed();
|
||||
const bool allowMouse = isMouseInputAllowed();
|
||||
const bool allowGamepad = isGamepadInputAllowed();
|
||||
const int err = LiSendSessionInputPolicy(allowKeyboardMouse,
|
||||
allowKeyboardMouse,
|
||||
const int err = LiSendSessionInputPolicy(allowKeyboard,
|
||||
allowMouse,
|
||||
allowGamepad,
|
||||
reason);
|
||||
|
||||
|
|
@ -719,11 +726,14 @@ void Session::refreshControlPanelOverlay()
|
|||
SDL_snprintf(panelText,
|
||||
sizeof(panelText),
|
||||
"Stream Controls\n"
|
||||
"KB/M (Ctrl+Alt+Shift+K): %s\n"
|
||||
"Pad (Ctrl+Alt+Shift+G): %s\n"
|
||||
"Keyboard: %s\n"
|
||||
"Mouse: %s\n"
|
||||
"Pad: %s\n"
|
||||
"Vol (U/J, mute N): %s\n"
|
||||
"UI (Ctrl+Alt+Shift+P / Select+L1+R1+B): ON",
|
||||
isKeyboardMouseInputAllowed() ? "ON" : "OFF",
|
||||
"UI (Ctrl+Alt+Shift+P / Select+L1+R1+B): ON\n"
|
||||
"Input policy: host controlled",
|
||||
isKeyboardInputAllowed() ? "ON" : "OFF",
|
||||
isMouseInputAllowed() ? "ON" : "OFF",
|
||||
isGamepadInputAllowed() ? "ON" : "OFF",
|
||||
volumeState);
|
||||
|
||||
|
|
@ -774,10 +784,13 @@ void Session::showTemporaryStatusOverlay(const char* text, Uint32 timeoutMs)
|
|||
|
||||
void Session::applyHostInputPolicy(bool allowKeyboard, bool allowMouse, bool allowGamepad, uint8_t reason)
|
||||
{
|
||||
const bool allowKeyboardMouse = allowKeyboard && allowMouse;
|
||||
const bool previousKeyboardMouse = m_AllowKeyboardMouseInput.exchange(allowKeyboardMouse, std::memory_order_relaxed);
|
||||
if (previousKeyboardMouse && !allowKeyboardMouse && m_InputHandler != nullptr) {
|
||||
const bool previousKeyboard = m_AllowKeyboardInput.exchange(allowKeyboard, std::memory_order_relaxed);
|
||||
if (previousKeyboard && !allowKeyboard && m_InputHandler != nullptr) {
|
||||
m_InputHandler->raiseAllKeys();
|
||||
}
|
||||
|
||||
const bool previousMouse = m_AllowMouseInput.exchange(allowMouse, std::memory_order_relaxed);
|
||||
if (previousMouse && !allowMouse && m_InputHandler != nullptr) {
|
||||
m_InputHandler->raiseAllMouseButtons();
|
||||
}
|
||||
|
||||
|
|
@ -786,11 +799,18 @@ void Session::applyHostInputPolicy(bool allowKeyboard, bool allowMouse, bool all
|
|||
m_InputHandler->raiseAllGamepadInputs();
|
||||
}
|
||||
|
||||
if (reason != LI_SESSION_INPUT_POLICY_REASON_STREAM_START) {
|
||||
notifyInputPermissionState();
|
||||
const bool policyChanged =
|
||||
previousKeyboard != allowKeyboard ||
|
||||
previousMouse != allowMouse ||
|
||||
previousGamepad != allowGamepad;
|
||||
if (reason == LI_SESSION_INPUT_POLICY_REASON_STREAM_START ||
|
||||
reason == LI_SESSION_INPUT_POLICY_REASON_HOST_ACK ||
|
||||
reason == LI_SESSION_INPUT_POLICY_REASON_HOST_OVERRIDE ||
|
||||
!policyChanged) {
|
||||
refreshControlPanelOverlay();
|
||||
}
|
||||
else {
|
||||
refreshControlPanelOverlay();
|
||||
notifyInputPermissionState();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1975,7 +1995,8 @@ void Session::start()
|
|||
s_ActiveSession = this;
|
||||
|
||||
m_AllowGamepadInput.store(true, std::memory_order_relaxed);
|
||||
m_AllowKeyboardMouseInput.store(false, std::memory_order_relaxed);
|
||||
m_AllowKeyboardInput.store(false, std::memory_order_relaxed);
|
||||
m_AllowMouseInput.store(false, std::memory_order_relaxed);
|
||||
m_ManualAudioMuted.store(false, std::memory_order_relaxed);
|
||||
m_AudioMuted.store(false, std::memory_order_relaxed);
|
||||
m_AudioVolumeScalar.store(1.0f, std::memory_order_relaxed);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue