Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/include/ingame_overlay_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class OptionsTab : public brls::Box {
BRLS_BIND(brls::SelectorCell, keyboardType, "keyboard_type");
BRLS_BIND(brls::SelectorCell, keyboardFingers, "keyboard_fingers");
BRLS_BIND(brls::BooleanCell, touchscreenMouseMode, "touchscreen_mouse_mode");
BRLS_BIND(brls::SelectorCell, switchDisplay, "switch_display");
BRLS_BIND(brls::DetailCell, guideKeyButtons, "guide_key_buttons");
BRLS_BIND(brls::SelectorCell, guideBySystemButton, "guide_by_system_button");
BRLS_BIND(brls::Header, volumeHeader, "volume_header");
Expand Down
5 changes: 5 additions & 0 deletions app/include/streaming_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class StreamingView : public brls::Box {

void terminate(bool terminateApp);

// Whether the connected host is Sunshine, which supports switching the
// streamed display via the Ctrl+Alt+Shift+F<n> key combo.
bool isSunshineHost() const { return sunshineHost; }

bool draw_stats = false;

Host getHost() { return host; }
Expand All @@ -44,6 +48,7 @@ class StreamingView : public brls::Box {
Box* keyboardHolder = nullptr;
KeyboardView* keyboard = nullptr;
bool blocked = false;
bool sunshineHost = false;
bool terminated = false;
bool tempInputLock = false;
brls::Event<brls::KeyState>::Subscription keysSubscription;
Expand Down
19 changes: 19 additions & 0 deletions app/src/ingame_overlay_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ingame_overlay_view.hpp"
#include "streaming_input_overlay.hpp"
#include "button_selecting_dialog.hpp"
#include "InputManager.hpp"
#include "UpscalingSupport.hpp"

#include <cmath>
Expand Down Expand Up @@ -199,6 +200,24 @@ OptionsTab::OptionsTab(StreamingView* streamView) : streamView(streamView) {
return true;
});

// Display switching via Ctrl+Alt+Shift+F<n> is only supported by Sunshine
// hosts, so only show the option when connected to such a host.
if (streamView->isSunshineHost()) {
std::vector<std::string> switchDisplayOptions;
for (int i = 1; i <= 12; i++) {
switchDisplayOptions.push_back("streaming/display"_i18n + " " +
std::to_string(i));
}
switchDisplay->setText("streaming/switch_display"_i18n);
switchDisplay->setData(switchDisplayOptions);
switchDisplay->setSelection(0, true);
switchDisplay->getEvent()->subscribe([](int selected) {
MoonlightInputManager::switchDisplay(selected + 1);
});
} else {
switchDisplay->removeFromSuperView();
}

std::vector<std::string> keyboardTypes = {
"settings/keyboard_compact"_i18n, "settings/keyboard_fullsized"_i18n};
keyboardType->setText("settings/keyboard_type"_i18n);
Expand Down
32 changes: 32 additions & 0 deletions app/src/streaming/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,38 @@ void MoonlightInputManager::rightMouseClick() {
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_MOUSE_RIGHT);
}

void MoonlightInputManager::switchDisplay(int displayNumber) {
if (displayNumber < 1 || displayNumber > 12) {
brls::Logger::warning("Ignoring out-of-range display switch request {}", displayNumber);
return;
}

// Virtual key codes
const short VK_LSHIFT = 0xA0;
const short VK_LCONTROL = 0xA2;
const short VK_LMENU = 0xA4; // Left Alt
const short vkFKey = 0x70 + (displayNumber - 1); // VK_F1 .. VK_F12

const char modifiers = MODIFIER_CTRL | MODIFIER_ALT | MODIFIER_SHIFT;

brls::Logger::info("Switching streamed display to {} (Ctrl+Alt+Shift+F{})",
displayNumber, displayNumber);

// Press modifiers in order, accumulating the modifier flags.
LiSendKeyboardEvent(VK_LCONTROL, KEY_ACTION_DOWN, MODIFIER_CTRL);
LiSendKeyboardEvent(VK_LMENU, KEY_ACTION_DOWN, MODIFIER_CTRL | MODIFIER_ALT);
LiSendKeyboardEvent(VK_LSHIFT, KEY_ACTION_DOWN, modifiers);

// Tap the function key with all modifiers held.
LiSendKeyboardEvent(vkFKey, KEY_ACTION_DOWN, modifiers);
LiSendKeyboardEvent(vkFKey, KEY_ACTION_UP, modifiers);

// Release modifiers in reverse order.
LiSendKeyboardEvent(VK_LSHIFT, KEY_ACTION_UP, MODIFIER_CTRL | MODIFIER_ALT);
LiSendKeyboardEvent(VK_LMENU, KEY_ACTION_UP, MODIFIER_CTRL);
LiSendKeyboardEvent(VK_LCONTROL, KEY_ACTION_UP, 0);
}

short MoonlightInputManager::glfwKeyToVKKey(BrlsKeyboardScancode key) {
if (BRLS_KBD_KEY_F1 <= key && key <= BRLS_KBD_KEY_F12)
return key - BRLS_KBD_KEY_F1 + 0x70;
Expand Down
4 changes: 4 additions & 0 deletions app/src/streaming/InputManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class MoonlightInputManager : public Singleton<MoonlightInputManager> {
void setInputEnabled(bool enabled) { inputEnabled = enabled; }
static void leftMouseClick();
static void rightMouseClick();
// Sends the Ctrl+Alt+Shift+F<displayNumber> combo to the host, which
// tells Sunshine/GeForce Experience to switch the streamed display.
// displayNumber is 1-based (1 maps to F1, 12 maps to F12).
static void switchDisplay(int displayNumber);

private:
RumbleValues rumbleCache[GAMEPADS_MAX];
Expand Down
2 changes: 2 additions & 0 deletions app/src/streaming_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ StreamingView::StreamingView(const Host& host, const AppInfo& app) : host(host),
session->set_address(
GameStreamClient::instance().active_address(this->host));

this->sunshineHost = result.value().isSunshine();

ASYNC_RETAIN
session->start([ASYNC_TOKEN](GSResult<bool> result) {
ASYNC_RELEASE
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/de/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"connection": "Verbindung",
"debug_info": "Debug Informationen",
"disconnect": "Verbindung trennen",
"display": "Bildschirm",
"esc": "ESC Taste",
"input": "Eingabe",
"keys": "Tasten",
Expand All @@ -185,6 +186,7 @@
"mouse_speed": "Mausbeschleunigung",
"options": "Einstellungen",
"show_logs": "Protokolle anzeigen",
"switch_display": "Bildschirm wechseln",
"terminate": "Programm beenden",
"volume": "Lautstärke"
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/en-US/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"connection": "Connection",
"debug_info": "Debug info",
"disconnect": "Disconnect",
"display": "Display",
"esc": "ESC button",
"input": "Input",
"keys": "Keys",
Expand All @@ -185,6 +186,7 @@
"mouse_speed": "Mouse acceleration",
"options": "Options",
"show_logs": "Show logs",
"switch_display": "Switch display",
"terminate": "Terminate app",
"volume": "Volume"
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/es/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"connection": "Conexión",
"debug_info": "Información de debug",
"disconnect": "Desconectar",
"display": "Pantalla",
"esc": "Botón de Escape",
"input": "Entrada",
"keys": "Botones",
Expand All @@ -185,6 +186,7 @@
"mouse_speed": "Aceleración del ratón",
"options": "Ajustes",
"show_logs": "Mostrar logs",
"switch_display": "Cambiar de pantalla",
"terminate": "Cerrar aplicación",
"volume": "Volumen"
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"connection": "Connexion",
"debug_info": "Infos de Debug",
"disconnect": "Déconnecter",
"display": "Écran",
"esc": "Esc",
"input": "Modes de saisie",
"keys": "Touches",
Expand All @@ -185,6 +186,7 @@
"mouse_speed": "Vitesse de la souris",
"options": "Options",
"show_logs": "Voir les logs",
"switch_display": "Changer d'écran",
"terminate": "Fermer l'application",
"volume": "Volume"
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/it/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"connection": "Connessione",
"debug_info": "Info di Debug",
"disconnect": "Disconnetti",
"display": "Schermo",
"esc": "Pulsante ESC",
"input": "Input",
"keys": "Tasti",
Expand All @@ -185,6 +186,7 @@
"mouse_speed": "Accelerazione Mouse",
"options": "Opzioni",
"show_logs": "Mostra log",
"switch_display": "Cambia schermo",
"terminate": "Termina app",
"volume": "Volume"
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/ja/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"connection": "接続",
"debug_info": "デバッグ情報",
"disconnect": "切断する",
"display": "ディスプレイ",
"esc": "エスケープボタン",
"input": "入力",
"keys": "キー",
Expand All @@ -185,6 +186,7 @@
"mouse_speed": "マウスの加速",
"options": "設定",
"show_logs": "ログを表示する",
"switch_display": "ディスプレイを切り替える",
"terminate": "アプリを終了します",
"volume": "音量"
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/ko/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"connection": "연결",
"debug_info": "디버그 정보",
"disconnect": "연결 해제",
"display": "디스플레이",
"esc": "ESC 버튼",
"input": "입력",
"keys": "키",
Expand All @@ -185,6 +186,7 @@
"mouse_speed": "마우스 가속",
"options": "옵션",
"show_logs": "정보 표시",
"switch_display": "디스플레이 전환",
"terminate": "앱 종료",
"volume": "볼륨"
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/pt-BR/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"connection": "Conexão",
"debug_info": "Informações de debug",
"disconnect": "Desconectar",
"display": "Tela",
"esc": "Botão ESC",
"input": "Entrada",
"keys": "Teclas",
Expand All @@ -185,6 +186,7 @@
"mouse_speed": "Aceleração do mouse",
"options": "Opções",
"show_logs": "Mostrar logs",
"switch_display": "Trocar de tela",
"terminate": "Encerrar aplicativo",
"volume": "Volume"
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/ru/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"connection": "Соединение",
"debug_info": "Отладочная информация",
"disconnect": "Отключиться",
"display": "Дисплей",
"esc": "Кнопка ESC",
"input": "Ввод",
"keys": "Кнопки",
Expand All @@ -185,6 +186,7 @@
"mouse_speed": "Скорость мыши",
"options": "Настройки",
"show_logs": "Показать логи",
"switch_display": "Сменить дисплей",
"terminate": "Завершить приложение",
"volume": "Громкость звука"
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/zh-Hans/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"connection": "连接选项",
"debug_info": "调试信息",
"disconnect": "断开连接",
"display": "显示器",
"esc": "ESC按键",
"input": "输入",
"keys": "按键",
Expand All @@ -185,6 +186,7 @@
"mouse_speed": "鼠标速度",
"options": "选项",
"show_logs": "显示日志",
"switch_display": "切换显示器",
"terminate": "终止应用程序",
"volume": "音量"
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/zh-Hant/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"connection": "連接選項",
"debug_info": "除錯訊息",
"disconnect": "斷開連接",
"display": "顯示器",
"esc": "ESC按鍵",
"input": "輸入",
"keys": "按鍵",
Expand All @@ -185,6 +186,7 @@
"mouse_speed": "滑鼠速度",
"options": "選項",
"show_logs": "顯示日誌",
"switch_display": "切換顯示器",
"terminate": "終止應用程式",
"volume": "音量"
},
Expand Down
3 changes: 3 additions & 0 deletions resources/xml/views/ingame_overlay/options_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<brls:BooleanCell
id="touchscreen_mouse_mode"/>

<brls:SelectorCell
id="switch_display"/>

<brls:Header
title="@i18n/settings/guide_key"
paddingTop="60"/>
Expand Down