Add option to build for embedded environments

This commit is contained in:
Cameron Gutman 2021-03-13 15:20:58 -06:00
parent d7a150ffa8
commit d6b314f573
10 changed files with 47 additions and 24 deletions

View file

@ -68,6 +68,8 @@ You can follow development on our [Discord server](https://moonlight-stream.org/
* For macOS builds, use `scripts/generate-dmg.sh`. Execute this script from the root of the repository and ensure Qt's `bin` folder is in your `$PATH`. * For macOS builds, use `scripts/generate-dmg.sh`. Execute this script from the root of the repository and ensure Qt's `bin` folder is in your `$PATH`.
* For Steam Link builds, run `scripts/build-steamlink-app.sh` from the root of the repository. * For Steam Link builds, run `scripts/build-steamlink-app.sh` from the root of the repository.
* To build from the command line for development use, run `qmake moonlight-qt.pro` then `make debug` or `make release` * To build from the command line for development use, run `qmake moonlight-qt.pro` then `make debug` or `make release`
* To create an embedded build for a single-purpose device, use `qmake "CONFIG+=embedded" moonlight-qt.pro` and build normally.
* This build will lack windowed mode, Discord/Help links, and other features that don't make sense on an embedded device.
## Contribute ## Contribute
1. Fork us 1. Fork us

View file

@ -271,7 +271,7 @@ config_EGL {
config_SL { config_SL {
message(Steam Link build configuration selected) message(Steam Link build configuration selected)
DEFINES += STEAM_LINK HAVE_SLVIDEO HAVE_SLAUDIO DEFINES += EMBEDDED_BUILD STEAM_LINK HAVE_SLVIDEO HAVE_SLAUDIO
LIBS += -lSLVideo -lSLAudio LIBS += -lSLVideo -lSLAudio
SOURCES += \ SOURCES += \
@ -314,6 +314,11 @@ discord-rpc {
LIBS += -ldiscord-rpc LIBS += -ldiscord-rpc
DEFINES += HAVE_DISCORD DEFINES += HAVE_DISCORD
} }
embedded {
message(Embedded build)
DEFINES += EMBEDDED_BUILD
}
RESOURCES += \ RESOURCES += \
resources.qrc \ resources.qrc \

View file

@ -14,7 +14,7 @@
SystemProperties::SystemProperties() SystemProperties::SystemProperties()
{ {
versionString = QString(VERSION_STR); versionString = QString(VERSION_STR);
hasWindowManager = WMUtils::isRunningWindowManager(); hasDesktopEnvironment = WMUtils::isRunningDesktopEnvironment();
isRunningWayland = WMUtils::isRunningWayland(); isRunningWayland = WMUtils::isRunningWayland();
isRunningXWayland = isRunningWayland && QGuiApplication::platformName() == "xcb"; isRunningXWayland = isRunningWayland && QGuiApplication::platformName() == "xcb";
QString nativeArch = QSysInfo::currentCpuArchitecture(); QString nativeArch = QSysInfo::currentCpuArchitecture();
@ -55,12 +55,8 @@ SystemProperties::SystemProperties()
friendlyNativeArchName = nativeArch.toUpper(); friendlyNativeArchName = nativeArch.toUpper();
} }
#ifndef STEAM_LINK
// Assume we can probably launch a browser if we're in a GUI environment // Assume we can probably launch a browser if we're in a GUI environment
hasBrowser = hasWindowManager; hasBrowser = hasDesktopEnvironment;
#else
hasBrowser = false;
#endif
#ifdef HAVE_DISCORD #ifdef HAVE_DISCORD
hasDiscordIntegration = true; hasDiscordIntegration = true;

View file

@ -19,7 +19,7 @@ public:
Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT) Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT)
Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT) Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT)
Q_PROPERTY(QString friendlyNativeArchName MEMBER friendlyNativeArchName CONSTANT) Q_PROPERTY(QString friendlyNativeArchName MEMBER friendlyNativeArchName CONSTANT)
Q_PROPERTY(bool hasWindowManager MEMBER hasWindowManager CONSTANT) Q_PROPERTY(bool hasDesktopEnvironment MEMBER hasDesktopEnvironment CONSTANT)
Q_PROPERTY(bool hasBrowser MEMBER hasBrowser CONSTANT) Q_PROPERTY(bool hasBrowser MEMBER hasBrowser CONSTANT)
Q_PROPERTY(bool hasDiscordIntegration MEMBER hasDiscordIntegration CONSTANT) Q_PROPERTY(bool hasDiscordIntegration MEMBER hasDiscordIntegration CONSTANT)
Q_PROPERTY(QString unmappedGamepads MEMBER unmappedGamepads NOTIFY unmappedGamepadsChanged) Q_PROPERTY(QString unmappedGamepads MEMBER unmappedGamepads NOTIFY unmappedGamepadsChanged)
@ -45,7 +45,7 @@ private:
bool isRunningXWayland; bool isRunningXWayland;
bool isWow64; bool isWow64;
QString friendlyNativeArchName; QString friendlyNativeArchName;
bool hasWindowManager; bool hasDesktopEnvironment;
bool hasBrowser; bool hasBrowser;
bool hasDiscordIntegration; bool hasDiscordIntegration;
QString unmappedGamepads; QString unmappedGamepads;

View file

@ -527,7 +527,7 @@ Flickable {
text: qsTr("Display mode") text: qsTr("Display mode")
font.pointSize: 12 font.pointSize: 12
wrapMode: Text.Wrap wrapMode: Text.Wrap
visible: SystemProperties.hasWindowManager visible: SystemProperties.hasDesktopEnvironment
} }
AutoResizingComboBox { AutoResizingComboBox {
@ -563,7 +563,7 @@ Flickable {
} }
id: windowModeComboBox id: windowModeComboBox
visible: SystemProperties.hasWindowManager visible: SystemProperties.hasDesktopEnvironment
enabled: !SystemProperties.rendererAlwaysFullScreen enabled: !SystemProperties.rendererAlwaysFullScreen
hoverEnabled: true hoverEnabled: true
textRole: "text" textRole: "text"
@ -708,7 +708,7 @@ Flickable {
width: parent.width width: parent.width
text: qsTr("Mute audio stream when Moonlight is not the active window") text: qsTr("Mute audio stream when Moonlight is not the active window")
font.pointSize: 12 font.pointSize: 12
visible: SystemProperties.hasWindowManager visible: SystemProperties.hasDesktopEnvironment
checked: StreamingPreferences.muteOnFocusLoss checked: StreamingPreferences.muteOnFocusLoss
onCheckedChanged: { onCheckedChanged: {
StreamingPreferences.muteOnFocusLoss = checked StreamingPreferences.muteOnFocusLoss = checked
@ -806,7 +806,7 @@ Flickable {
text: qsTr("GUI display mode") text: qsTr("GUI display mode")
font.pointSize: 12 font.pointSize: 12
wrapMode: Text.Wrap wrapMode: Text.Wrap
visible: SystemProperties.hasWindowManager visible: SystemProperties.hasDesktopEnvironment
} }
AutoResizingComboBox { AutoResizingComboBox {
@ -831,7 +831,7 @@ Flickable {
} }
id: uiDisplayModeComboBox id: uiDisplayModeComboBox
visible: SystemProperties.hasWindowManager visible: SystemProperties.hasDesktopEnvironment
textRole: "text" textRole: "text"
model: ListModel { model: ListModel {
id: uiDisplayModeListModel id: uiDisplayModeListModel
@ -910,7 +910,7 @@ Flickable {
width: parent.width width: parent.width
text: qsTr("Optimize mouse for remote desktop instead of games") text: qsTr("Optimize mouse for remote desktop instead of games")
font.pointSize: 12 font.pointSize: 12
visible: SystemProperties.hasWindowManager visible: SystemProperties.hasDesktopEnvironment
checked: StreamingPreferences.absoluteMouseMode checked: StreamingPreferences.absoluteMouseMode
onCheckedChanged: { onCheckedChanged: {
StreamingPreferences.absoluteMouseMode = checked StreamingPreferences.absoluteMouseMode = checked
@ -933,8 +933,8 @@ Flickable {
hoverEnabled: true hoverEnabled: true
text: qsTr("Capture system keyboard shortcuts") text: qsTr("Capture system keyboard shortcuts")
font.pointSize: 12 font.pointSize: 12
enabled: SystemProperties.hasWindowManager enabled: SystemProperties.hasDesktopEnvironment
checked: StreamingPreferences.captureSysKeysMode !== StreamingPreferences.CSK_OFF || !SystemProperties.hasWindowManager checked: StreamingPreferences.captureSysKeysMode !== StreamingPreferences.CSK_OFF || !SystemProperties.hasDesktopEnvironment
ToolTip.delay: 1000 ToolTip.delay: 1000
ToolTip.timeout: 10000 ToolTip.timeout: 10000
@ -1111,7 +1111,7 @@ Flickable {
width: parent.width width: parent.width
text: qsTr("Process gamepad input when Moonlight is in the background") text: qsTr("Process gamepad input when Moonlight is in the background")
font.pointSize: 12 font.pointSize: 12
visible: SystemProperties.hasWindowManager visible: SystemProperties.hasDesktopEnvironment
checked: StreamingPreferences.backgroundGamepad checked: StreamingPreferences.backgroundGamepad
onCheckedChanged: { onCheckedChanged: {
StreamingPreferences.backgroundGamepad = checked StreamingPreferences.backgroundGamepad = checked

View file

@ -23,7 +23,7 @@ ApplicationWindow {
height: 600 height: 600
visibility: { visibility: {
if (SystemProperties.hasWindowManager) { if (SystemProperties.hasDesktopEnvironment) {
if (StreamingPreferences.uiDisplayMode == StreamingPreferences.UI_WINDOWED) return "Windowed" if (StreamingPreferences.uiDisplayMode == StreamingPreferences.UI_WINDOWED) return "Windowed"
else if (StreamingPreferences.uiDisplayMode == StreamingPreferences.UI_MAXIMIZED) return "Maximized" else if (StreamingPreferences.uiDisplayMode == StreamingPreferences.UI_MAXIMIZED) return "Maximized"
else if (StreamingPreferences.uiDisplayMode == StreamingPreferences.UI_FULLSCREEN) return "FullScreen" else if (StreamingPreferences.uiDisplayMode == StreamingPreferences.UI_FULLSCREEN) return "FullScreen"

View file

@ -36,8 +36,8 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s
m_NumFingersDown(0), m_NumFingersDown(0),
m_ClipboardData() m_ClipboardData()
{ {
// System keys are always captured when running without a WM // System keys are always captured when running without a DE
if (!WMUtils::isRunningWindowManager()) { if (!WMUtils::isRunningDesktopEnvironment()) {
m_CaptureSystemKeysMode = StreamingPreferences::CSK_ALWAYS; m_CaptureSystemKeysMode = StreamingPreferences::CSK_ALWAYS;
} }

View file

@ -351,7 +351,7 @@ bool Session::populateDecoderProperties(SDL_Window* window)
Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *preferences) Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *preferences)
: m_Preferences(preferences ? preferences : new StreamingPreferences(this)), : m_Preferences(preferences ? preferences : new StreamingPreferences(this)),
m_IsFullScreen(m_Preferences->windowMode != StreamingPreferences::WM_WINDOWED || !WMUtils::isRunningWindowManager()), m_IsFullScreen(m_Preferences->windowMode != StreamingPreferences::WM_WINDOWED || !WMUtils::isRunningDesktopEnvironment()),
m_Computer(computer), m_Computer(computer),
m_App(app), m_App(app),
m_Window(nullptr), m_Window(nullptr),
@ -511,8 +511,8 @@ bool Session::initialize()
{ {
default: default:
case StreamingPreferences::WM_FULLSCREEN_DESKTOP: case StreamingPreferences::WM_FULLSCREEN_DESKTOP:
// Only use full-screen desktop mode if we're running a window manager // Only use full-screen desktop mode if we're running a desktop environment
if (WMUtils::isRunningWindowManager()) { if (WMUtils::isRunningDesktopEnvironment()) {
m_FullScreenFlag = SDL_WINDOW_FULLSCREEN_DESKTOP; m_FullScreenFlag = SDL_WINDOW_FULLSCREEN_DESKTOP;
break; break;
} }

View file

@ -7,4 +7,5 @@ namespace WMUtils {
bool isRunningX11(); bool isRunningX11();
bool isRunningWayland(); bool isRunningWayland();
bool isRunningWindowManager(); bool isRunningWindowManager();
bool isRunningDesktopEnvironment();
} }

View file

@ -77,3 +77,22 @@ bool WMUtils::isRunningWindowManager()
return WMUtils::isRunningWayland() || WMUtils::isRunningX11(); return WMUtils::isRunningWayland() || WMUtils::isRunningX11();
#endif #endif
} }
bool WMUtils::isRunningDesktopEnvironment()
{
if (qEnvironmentVariableIsSet("HAS_DESKTOP_ENVIRONMENT")) {
return qEnvironmentVariableIntValue("HAS_DESKTOP_ENVIRONMENT");
}
#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN)
// Windows and macOS are always running a desktop environment
return true;
#elif defined(EMBEDDED_BUILD)
// Embedded systems don't run desktop environments
return false;
#else
// On non-embedded systems, assume we have a desktop environment
// if we have a WM running.
return isRunningWindowManager();
#endif
}