Compare commits

...
119 Commits
Author SHA1 Message Date
Cameron Gutman 14a6a69dc0 Version 3.0.0 2021-01-17 10:33:10 -06:00
Cameron Gutman 3191182009 Update Windows SDL to Hg a5b970d28bfd 2021-01-17 10:17:27 -06:00
Cameron Gutman e210dc748f Update macOS SDL to Hg a5b970d28bfd 2021-01-17 10:08:45 -06:00
Cameron Gutman 724dcb557f Hide irrelevant options on embedded devices 2021-01-15 19:46:27 -06:00
Cameron Gutman 11d274ff07 Fix X11 keyboard grab when starting in windowed mode 2021-01-15 19:32:38 -06:00
Cameron Gutman ae246b1005 Trim keyboard shortcut setting text slightly 2021-01-15 19:25:28 -06:00
Cameron Gutman ca0250280a Update moonlight-common-c submodule 2021-01-14 19:32:32 -06:00
Cameron Gutman f49d6e15a4 Fix clearing the wrong flag when activating mouse capture 2021-01-14 19:30:30 -06:00
Cameron Gutman 7172cfd889 Properly handle multiple window event flush barriers in flight at once
Fixes streaming on macOS Mojave without Metal support
2021-01-14 19:28:21 -06:00
Cameron Gutman 89e9652075 Save preferences on destruction in case the user closes Moonlight directly from the settings page 2021-01-13 19:43:52 -06:00
Cameron Gutman 53098edc85 Print which archs were bundled in the installer after the build completes 2021-01-13 19:36:46 -06:00
Cameron Gutman e9968fbab3 Add system key capture to the feature list 2021-01-13 19:36:17 -06:00
Cameron Gutman bc10fd0aba Disable the system keyboard capture option on Wayland 2021-01-12 20:41:20 -06:00
Cameron Gutman 76b4922bbe Add toggle for system key capture 2021-01-12 20:05:18 -06:00
Cameron Gutman 8e790c4745 Use real full-screen on macOS when capturing keys 2021-01-12 19:57:01 -06:00
Cameron Gutman c331b180cb Fix modifier keys being stuck down after key combos when capturing system keys on Windows 2021-01-12 18:40:00 -06:00
Cameron Gutman 30e3b02867 Start implementation of system key capture 2021-01-11 23:43:32 -06:00
Cameron Gutman bedea4a093 Rebuild SDL2_ttf.framework as a Universal binary 2021-01-10 14:32:43 -06:00
Cameron Gutman 5372cfba20 Minor fixes to kiosk mode PR
- UI_FULLSCREEN_WINDOWED -> UI_MAXIMIZED
- Propagate user configuration from old "start windowed" option
- Use FullScreen when a window manager isn't present
- Set disabled control to FullScreen with no window manager
2021-01-10 10:09:31 -06:00
jmt-ghandjmt-gh 19dac306d1 Add support for Fullscreen UI in Moonlight (#492)
* initial UI and window decoration removal toggle

* revert default height change

* add fullscreen support to kiosk mode

* add tool tip for kiosk mode

* change to fullscreen rather than kiosk

* update to Fullscreen instead of Full-screen or Full Screen

* update UI text

* convert to display mode picker

* add UI label for picker

* clean up references to startMaximized and fullScreenUIMode

* remove flags property, as fullscreen visiblity handles this already

* use Maximized in selection text

* account for running moonlight without a window manager

* lock display mode from being changed if there is no window manager running

Co-authored-by: jmt-gh <jmt-gh@users.noreply.github.com>
2021-01-10 09:50:12 -06:00
Cameron Gutman e9a98a3402 Add note about multi-monitor bug to remote desktop tooltip 2021-01-09 18:03:48 -06:00
Cameron Gutman 7020749987 Change mute on minimize to mute on focus loss
Minimization doesn't always happen on focus loss in full-screen mode,
so it could lead to unpredictable behavior.
2021-01-09 17:56:23 -06:00
Cameron Gutman 2d62d090df Use a barrier to ensure we don't flush important window events 2021-01-09 17:51:25 -06:00
Cameron Gutman e6f59062fa Update SDL to Hg d7abc11bb69a
https://github.com/cgutman/moonlight-deps/commit/20ce1c15eddb0ee9b216b0928844412e3e63e1d6
2021-01-08 21:43:37 -06:00
Cameron Gutman 0d3092d62c Update SDL to Hg d7abc11bb69a
https://github.com/cgutman/moonlight-deps/commit/20ce1c15eddb0ee9b216b0928844412e3e63e1d6
2021-01-08 21:35:07 -06:00
Cameron Gutman af0921c5b2 Set new hints present in SDL 2.0.15 development builds 2021-01-08 18:14:49 -06:00
Cameron Gutman 137454beff Use SDL_UpdateNVTexture on SDL 2.0.15+ 2021-01-08 18:05:27 -06:00
Cameron Gutman a0cc93b813 Fix EGL renderer build on SDL 2.0.9 and earlier 2021-01-03 14:24:30 -06:00
Cameron Gutman ff516f63b4 Set QT_QPA_EGLFS_ALWAYS_SET_MODE=1 by default for RetroPie compatibility 2021-01-03 11:16:59 -06:00
Cameron Gutman 68acb78ae6 Use specific resuming text when reconnecting to a game 2020-12-31 21:33:41 -06:00
Cameron Gutman 949aaaff2a Add tooltip for hide games option 2020-12-31 21:31:46 -06:00
Cameron Gutman 390544cd9a Charge time spent in the decode unit queue to the decoder rather than receive time 2020-12-31 16:10:01 -06:00
Cameron Gutman 766a923f86 Reduce size of Windows installers and portable packages 2020-12-31 11:44:59 -06:00
Cameron Gutman 202ce14afa Update SDL_GameControllerDB 2020-12-30 13:34:01 -06:00
Cameron Gutman 8ff9d8123d Switch VT renderer pacing logic to be enabled by the frame pacing checkbox 2020-12-29 20:26:56 -06:00
Cameron Gutman 2715367411 Fix default audio output change detection on macOS 2020-12-28 14:37:17 -06:00
Cameron Gutman 44b61d9252 Fix accidental static import of IsWow64Process2() and tweak message text 2020-12-28 13:32:02 -06:00
Cameron Gutman 565bba6e55 Point users to ARM64 version of Moonlight if running the x86 or x64 versions 2020-12-28 12:27:22 -06:00
Cameron Gutman 2ecfb7af64 Improve description of gamepad mouse mode 2020-12-27 15:41:47 -06:00
Cameron Gutman 998d3b2cc1 Fix tooltip line wrapping 2020-12-27 15:34:49 -06:00
Cameron Gutman c923d643b9 Rebuild FFmpeg 4.3.1 (patched), discord-rpc, Opus, and OpenSSL 1.1.1i as Universal binaries
https://github.com/cgutman/moonlight-deps
4c2815b5f2045ef0e8b098ed2fa8c4f9c1f5cd77

Built locally with Xcode 12.3 with ARM64 targets enabled
2020-12-27 00:14:39 -06:00
Cameron Gutman bc39c721e3 Add a key combo to toggle cursor display in remote desktop mouse mode 2020-12-26 19:47:00 -06:00
Cameron Gutman 5096ff6496 Add options to invert scroll direction and swap gamepad buttons
Fixes #463
Fixes #467
2020-12-25 22:21:20 -06:00
Cameron Gutman a11f623b17 Add option to mute audio on minimize and background gamepad input
Fixes #461
2020-12-25 15:32:11 -06:00
Cameron Gutman f7ffb30bc6 Reorganize settings and improve descriptions 2020-12-25 12:19:22 -06:00
Cameron Gutman c7ddb54e67 Add support for bundling ARM64 binaries into the installer
It is disabled by default because Qt doesn't have official ARM64 builds yet
2020-12-24 17:21:35 -06:00
Cameron Gutman c4108feb15 Add SDL 2.0.14 hints 2020-12-24 14:31:47 -06:00
Cameron Gutman 47cad71fcd Add special error text for an early termination 2020-12-24 11:24:01 -06:00
Cameron Gutman 0b56b1685a Use LiStringifyPortFlags() instead of coding it ourselves 2020-12-23 14:08:20 -06:00
Cameron Gutman c414e1a168 Display the failing ports when the connection fails 2020-12-23 13:56:15 -06:00
Cameron Gutman 22bebb6bbc Maxwell 2 doesn't support 8K HEVC encoding 2020-12-22 18:57:45 -06:00
Cameron Gutman c3f9742bb6 Update to SDL 2.0.14 for Windows
Defines:
#undef SDL_JOYSTICK_RAWINPUT
#undef SDL_JOYSTICK_WGI
#define USE_D3D9EX 1
2020-12-21 21:00:55 -06:00
Cameron Gutman 3defccb6e2 Work around poor video scaling quality on Qualcomm GPUs 2020-12-21 21:00:55 -06:00
Cameron Gutman 1197b17509 Update AppImage to SDL 2.0.14 2020-12-21 20:30:21 -06:00
Cameron Gutman 265e28e7c3 Update to SDL 2.0.14 for macOS
This is a fat binary with both Intel and ARM64 code.
2020-12-21 20:29:55 -06:00
Cameron Gutman 9c758f1628 Create power-of-2 overlay surfaces for better performance
This lets us take the fast copy path in the DXVA2 renderer.
2020-12-20 17:31:02 -06:00
Cameron Gutman 5f4975ca5c Fix DXVA2 overlay rendering quality issus 2020-12-20 17:30:06 -06:00
Cameron Gutman e5bcc793e5 Implement overlay support in EGLRenderer
Fixes #405
2020-12-19 23:01:41 -06:00
Cameron Gutman cd5b0e74e3 Draw background in MMAL renderer on X11
Fixes #412
2020-12-19 21:25:20 -06:00
Cameron Gutman 3162d2c17d Fix aspect ratio of MMAL renderer output 2020-12-19 17:48:36 -06:00
Cameron Gutman 6a54fb649c Fix synchronization issues between render and overlay update threads in DXVA2 2020-12-18 20:23:52 -06:00
Cameron Gutman 8031ed7fe1 Run a GC before and after streaming 2020-12-18 19:54:11 -06:00
Cameron Gutman dcbf5affda Fix use-after-free in VDPAU overlay rendering 2020-12-18 19:39:24 -06:00
Cameron Gutman 027c8dcd41 Add overlay support to VDPAU renderer 2020-12-17 18:35:08 -06:00
Cameron Gutman 94b46a2173 Use a vertex buffer for rendering the DXVA2 overlays 2020-12-16 18:16:35 -06:00
Cameron Gutman b66f7f6c8b Don't persist the server cert until pairing is successful
Fixes #484
2020-12-15 21:24:21 -06:00
Cameron Gutman 355e4a5c67 Handle MSVC mkspecs with version number suffixes
ARM64 build uses win32-arm64-msvc2017
2020-12-13 23:58:13 -06:00
Cameron Gutman 1e7cb7f13e Replace D3DX9 with SDL_ttf for overlay rendering 2020-12-13 23:43:31 -06:00
Cameron Gutman d58837421f Refactor SDL overlay drawing into OverlayManager for sharing with other renderers 2020-12-13 15:51:50 -06:00
Cameron Gutman 19d5358b97 Add a PC menu header to show the current PC status 2020-12-13 12:50:56 -06:00
Cameron Gutman a6551c320d Finish Windows ARM64 bringup
SDL2  for ARM64 is not yet checked-in, but I will do that when SDL 2.0.14 is released.
2020-12-12 16:44:41 -06:00
Cameron Gutman 59a73817c8 Don't use AntiHooking.dll or use D3DX9 on ARM64 2020-12-12 13:59:47 -06:00
Cameron Gutman 1231f3eeb1 Stub out ARM64 build support in build-arch.bat 2020-12-12 13:08:45 -06:00
Cameron Gutman cd40c1dacd Update bundled libraries for AppImage 2020-12-12 12:51:00 -06:00
Cameron Gutman 33286a5bde Add ARM64 VCRedist definitions for later use 2020-12-12 12:43:21 -06:00
Cameron Gutman b61c35aff9 Rebuild SDL_ttf 2.0.15 for x86, x64, and ARM64 using FreeType 2.10.4 2020-12-10 21:16:16 -06:00
Cameron Gutman 2a3e1ba62e Rebuild FFmpeg 4.3.1, discord-rpc, Opus, and OpenSSL 1.1.1i for x86, x64, and ARM64
https://github.com/cgutman/moonlight-deps
382270e6c9a9c42addce06ef5dc6522b1368b5e2
2020-12-10 21:03:34 -06:00
Cameron Gutman d95f3277b2 Merge pull request #479 from TotalCaesar659/patch-1
Update URLs to HTTPS
2020-12-10 09:06:35 -06:00
TotalCaesar659 e0a2c8cb8a Update URLs to HTTPS 2020-12-10 16:37:29 +03:00
Cameron Gutman 0aa46a57fe Update moonlight-common-c submodule 2020-12-07 20:05:25 -06:00
Cameron Gutman 53e3cd143e Refresh display resolutions when opening the settings page 2020-12-07 19:58:42 -06:00
Cameron Gutman 8381039f97 Remove extra includes 2020-12-06 17:15:30 -06:00
Cameron Gutman a91c61e5e2 Remove Raspberry Pi PulseAudio avoidance hack
Not only is it no longer required (PA works great now), it actually breaks audio with Pi OS's new PA config
2020-12-06 16:58:41 -06:00
Cameron Gutman f90efd7e38 Fix infinite polish() loop when quitting a game due to removal of the 'overlay' property on Qt 6.0 2020-12-01 20:46:28 -06:00
Cameron Gutman fab142dd38 Add workaround for problems with Qt 6.0's Metal renderer 2020-12-01 19:13:17 -06:00
Cameron Gutman 125d546cea Fix installer build warning 2020-11-29 21:22:30 -06:00
Cameron Gutman 179f7ecc23 Fix AppVeyor artifact archival 2020-11-29 21:22:16 -06:00
Cameron Gutman 0fc30a70ca Build unified Windows installer bundles 2020-11-29 21:13:27 -06:00
Cameron Gutman f81509a892 Download VCRedist on demand rather than always bundling it in the installer 2020-11-29 20:24:23 -06:00
watchhaandwatchha fc4488f17f French update (#476)
Co-authored-by: watchha <watchha@users.noreply.github.com>
2020-11-29 11:20:25 -06:00
Cameron Gutman 2748f3d22e Update build instructions 2020-11-29 11:10:16 -06:00
Cameron Gutman e0d42cbe9c Fix index out of bounds when an app is hidden 2020-11-28 17:33:15 -06:00
Cameron Gutman 1780d9417f Disable app menu options instead of hiding them 2020-11-28 17:32:39 -06:00
Cameron Gutman 5f182b1e62 Remove "View Apps" and change "View Hidden Apps" to "View All Apps" 2020-11-28 17:29:13 -06:00
Cameron Gutman 80cee8367f Make sure the last modified time for the GCDB is not in the future 2020-11-24 00:18:34 -06:00
Cameron Gutman 7325d5657d Add custom resolution option 2020-11-24 00:13:39 -06:00
Cameron Gutman 72182c7caa Add support for selecting an app to launch directly 2020-11-23 21:38:22 -06:00
Cameron Gutman d7ca3801be Fix build on Qt 5.14 and earlier 2020-11-23 20:39:50 -06:00
Cameron Gutman 2ef714f87b Avoid runtime QT_OPENGL warning on Qt 6.0 2020-11-23 18:36:32 -06:00
Cameron Gutman 46940eb15a Enable HTTP/2 for update checking and mapping updates 2020-11-23 18:35:46 -06:00
Cameron Gutman 3485983553 Delete the cached mappings if they are empty or corrupt 2020-11-23 18:34:53 -06:00
Cameron Gutman 861ebc151a Only update gamepad mappings if they're newer than what we already have 2020-11-23 18:31:21 -06:00
Cameron Gutman ae5df938b6 Update macOS icon to match new Big Sur style 2020-11-21 16:37:56 -06:00
Cameron Gutman e224a7f0c7 Fetch updated gamepad mappings each launch 2020-11-21 14:45:34 -06:00
Cameron Gutman aa4684077d Fix inability to open app menu with gamepad 2020-11-21 13:28:04 -06:00
Cameron Gutman 193e196c46 Update searching message 2020-11-21 13:18:17 -06:00
Cameron Gutman 6e7a42065c Translation updates and refactoring 2020-11-21 13:15:54 -06:00
watchhaandwatchha 2c987d2912 French translation (#451)
* french translation

* Update main.cpp

* Update main.cpp

Co-authored-by: watchha <watchha@users.noreply.github.com>
2020-11-21 11:42:16 -06:00
Cameron Gutman 19f5dc12fb Fix fill color of Discord logo on Qt 5.9 2020-11-21 11:29:55 -06:00
Cameron Gutman 38b59aa1a9 Fix DXVA2 renderer compilation with Qt 6.0 2020-11-21 11:12:40 -06:00
Cameron Gutman 201b59cd4c Compilation fixes for Qt 6.0 Beta 3 2020-11-07 19:23:23 -06:00
Cameron Gutman de3afe27c1 Fix LSMinimumSystemVersion to match Qt 5.15 2020-11-01 09:42:03 -06:00
Cameron Gutman 7bee8e73f0 Update moonlight-common-c with QoS fix 2020-10-28 20:39:37 -05:00
Cameron Gutman 17e0fbbaf8 Update moonlight-common-c with MTU test 2020-10-17 21:53:33 -05:00
Cameron Gutman ec486e89e4 Use char16_t overload of QString::fromUtf16() for Qt 6.0 compatibility 2020-10-16 00:07:58 -05:00
Cameron Gutman ec3b000264 QTextStream::setCodec() is gone in Qt 6.0, so use the replacement setEncoding() function 2020-10-15 18:57:04 -05:00
Cameron Gutman 90a513dc3d Improve source compatibility with Qt 6.0 2020-10-15 18:54:12 -05:00
Cameron Gutman 32a74e3416 Update qmdnsengine to build with Qt 6.0 2020-10-14 22:40:25 -05:00
Cameron Gutman 1d90bf9230 Trim spaces from the provided IP address or hostname 2020-10-06 21:39:01 -05:00
586 changed files with 22042 additions and 36710 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
url = https://github.com/gabomdq/SDL_GameControllerDB.git
[submodule "soundio/libsoundio"]
path = soundio/libsoundio
url = https://github.com/andrewrk/libsoundio.git
url = https://github.com/cgutman/libsoundio.git
[submodule "h264bitstream/h264bitstream"]
path = h264bitstream/h264bitstream
url = https://github.com/aizvorski/h264bitstream.git
+12 -10
View File
@@ -2,7 +2,7 @@
[Moonlight PC](https://moonlight-stream.org) is an open source implementation of NVIDIA's GameStream, as used by the NVIDIA Shield, but built to run on Windows, Mac, and Linux. This client is the successor to [Moonlight Chrome](https://github.com/moonlight-stream/moonlight-chrome) for streaming on PC.
Moonlight also has mobile versions for [Android](https://github.com/moonlight-stream/moonlight-android) and [iOS](https://github.com/moonlight-stream/moonlight-ios).
Moonlight also has mobile versions for [Android](https://github.com/moonlight-stream/moonlight-android) and [iOS](https://github.com/moonlight-stream/moonlight-ios).
You can follow development on our [Discord server](https://moonlight-stream.org/discord).
@@ -15,6 +15,7 @@ You can follow development on our [Discord server](https://moonlight-stream.org/
- Supports streaming at 720p, 1080p, 1440p, 4K, and the client PC's native screen resolution
- 7.1 surround sound audio support
- Support for both pointer capture (for games) and direct mouse control (for remote desktop)
- Support for passing system-wide keyboard shortcuts like Alt+Tab to the host in fullscreen mode
- Direct touchscreen mouse control
- HEVC support for better image quality at reduced bandwidth
- Gamepad support with force feedback for up to 4 players
@@ -30,16 +31,15 @@ You can follow development on our [Discord server](https://moonlight-stream.org/
## Building
### Windows Build Requirements
* Qt 5.12.4 SDK or later
* Qt 5.15 SDK or later
* Windows 7 or later
* [Visual Studio](https://visualstudio.microsoft.com/downloads/) 2017 (Community edition is fine)
* Select MSVC Desktop toolchain during Qt installation
* [DirectX SDK](https://www.microsoft.com/en-us/download/details.aspx?id=6812)
* [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) (Community edition is fine)
* Select **MSVC 2019** option during Qt installation. MinGW is not supported.
* [7-Zip](https://www.7-zip.org/) (only if building installers for non-development PCs)
* [WiX Toolset](http://wixtoolset.org/releases/) v3.11 or later (only if building installers for non-development PCs)
* [WiX Toolset](https://wixtoolset.org/releases/) v3.11 or later (only if building installers for non-development PCs)
### macOS Build Requirements
* Qt 5.14 SDK or later
* Qt 5.15 SDK or later
* macOS High Sierra (10.13) or later
* Xcode 11
* [create-dmg](https://github.com/sindresorhus/create-dmg) (only if building DMGs for use on non-development Macs)
@@ -47,8 +47,10 @@ You can follow development on our [Discord server](https://moonlight-stream.org/
### Linux/Unix Build Requirements
* Qt 5.9 SDK or later
* GCC or Clang
* Install your distro equivalents of: `openssl-devel qt5-devel SDL2-devel ffmpeg-devel qt5-qtquickcontrols2-devel libva-devel libvdpau-devel opus-devel pulseaudio-libs-devel alsa-lib-devel SDL2_ttf-devel`
* FFmpeg 4.0 is required to build. If your distro doesn't package FFmpeg 4.0, you can build and install it from source on http://ffmpeg.org/
* Install the required packages:
* Debian/Ubuntu: `libegl1-mesa-dev libgl1-mesa-dev libopus-dev libqt5svg5-dev libsdl2-dev libsdl2-ttf-dev libssl-dev libavcodec-dev libva-dev libvdpau-dev libxkbcommon-dev qt5-default qt5-qmake qtbase5-dev qtdeclarative5-dev qtquickcontrols2-5-dev wayland-protocols qml-module-qtquick-controls2 qml-module-qtquick-layouts qml-module-qtquick-window2 qml-module-qtquick2`
* RedHat/Fedora: `openssl-devel qt5-devel SDL2-devel ffmpeg-devel qt5-qtquickcontrols2-devel libva-devel libvdpau-devel opus-devel pulseaudio-libs-devel alsa-lib-devel SDL2_ttf-devel`
* FFmpeg 4.0+ is required to build. If your distro doesn't package FFmpeg 4.0 or later, you can build and install it from source on https://ffmpeg.org/
### Steam Link Build Requirements
* [Steam Link SDK](https://github.com/ValveSoftware/steamlink-sdk) cloned on your build system
@@ -62,7 +64,7 @@ You can follow development on our [Discord server](https://moonlight-stream.org/
2. Run `git submodule update --init --recursive` from within `moonlight-qt/`
3. Open the project in Qt Creator or build from qmake on the command line.
* To build a binary for use on non-development machines, use the scripts in the `scripts` folder.
* For Windows builds, use `scripts\generate-installers.bat`. Execute this script from the root of the repository within a Qt command prompt. Ensure WiX and 7-Zip binary directories are in your `%PATH%`.
* For Windows builds, use `scripts\build-arch.bat` and `scripts\generate-bundle.bat`. Execute these scripts from the root of the repository within a Qt command prompt. Ensure WiX and 7-Zip binary directories are 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.
* To build from the command line for development use, run `qmake moonlight-qt.pro` then `make debug` or `make release`
+1 -1
View File
@@ -17,7 +17,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
<string>10.13</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
+16 -10
View File
@@ -33,17 +33,16 @@ DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
win32 {
INCLUDEPATH += \
$$PWD/../libs/windows/include \
$$(DXSDK_DIR)/Include
INCLUDEPATH += $$PWD/../libs/windows/include
contains(QT_ARCH, i386) {
LIBS += -L$$PWD/../libs/windows/lib/x86
LIBS += -L$$(DXSDK_DIR)/Lib/x86
}
contains(QT_ARCH, x86_64) {
LIBS += -L$$PWD/../libs/windows/lib/x64
LIBS += -L$$(DXSDK_DIR)/Lib/x64
}
contains(QT_ARCH, arm64) {
LIBS += -L$$PWD/../libs/windows/lib/arm64
}
LIBS += ws2_32.lib winmm.lib dxva2.lib ole32.lib gdi32.lib user32.lib d3d9.lib dwmapi.lib dbghelp.lib qwave.lib
@@ -102,7 +101,7 @@ unix:!macx {
}
}
win32 {
LIBS += -llibssl -llibcrypto -lSDL2 -lSDL2_ttf -lavcodec -lavutil -lopus -ld3dx9
LIBS += -llibssl -llibcrypto -lSDL2 -lSDL2_ttf -lavcodec -lavutil -lopus
CONFIG += ffmpeg
}
win32:!winrt {
@@ -132,6 +131,7 @@ SOURCES += \
cli/commandlineparser.cpp \
cli/quitstream.cpp \
cli/startstream.cpp \
settings/mappingfetcher.cpp \
settings/streamingpreferences.cpp \
streaming/input/abstouch.cpp \
streaming/input/gamepad.cpp \
@@ -155,6 +155,7 @@ SOURCES += \
HEADERS += \
backend/nvapp.h \
settings/mappingfetcher.h \
utils.h \
backend/computerseeker.h \
backend/identitymanager.h \
@@ -311,6 +312,9 @@ RESOURCES += \
resources.qrc \
qml.qrc
TRANSLATIONS += \
languages/qml_fr.ts
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
@@ -348,11 +352,13 @@ INCLUDEPATH += $$PWD/../h264bitstream/h264bitstream
DEPENDPATH += $$PWD/../h264bitstream/h264bitstream
!winrt {
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/release/ -lAntiHooking
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/debug/ -lAntiHooking
contains(QT_ARCH, i386)|contains(QT_ARCH, x86_64) {
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/release/ -lAntiHooking
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/debug/ -lAntiHooking
INCLUDEPATH += $$PWD/../AntiHooking
DEPENDPATH += $$PWD/../AntiHooking
INCLUDEPATH += $$PWD/../AntiHooking
DEPENDPATH += $$PWD/../AntiHooking
}
}
unix:!macx: {
+12 -1
View File
@@ -39,7 +39,13 @@ void AutoUpdateChecker::start()
// We'll get a callback when this is finished
QUrl url("https://moonlight-stream.org/updates/qt.json");
m_Nam.get(QNetworkRequest(url));
QNetworkRequest request(url);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
request.setAttribute(QNetworkRequest::Http2AllowedAttribute, true);
#else
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true);
#endif
m_Nam.get(request);
#endif
}
@@ -68,7 +74,12 @@ void AutoUpdateChecker::handleUpdateCheckRequestFinished(QNetworkReply* reply)
if (reply->error() == QNetworkReply::NoError) {
QTextStream stream(reply);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
stream.setEncoding(QStringConverter::Utf8);
#else
stream.setCodec("UTF-8");
#endif
// Read all data and queue the reply for deletion
QString jsonString = stream.readAll();
+2 -2
View File
@@ -536,8 +536,8 @@ private:
}
if (e.getStatusCode() == 599) {
// 599 is a special code we make a custom message for
emit quitAppFailed("The running game wasn't started by this PC. "
"You must quit the game on the host PC manually or use the device that originally started the game.");
emit quitAppFailed(tr("The running game wasn't started by this PC. "
"You must quit the game on the host PC manually or use the device that originally started the game."));
}
else {
emit quitAppFailed(e.toQString());
+3
View File
@@ -5,6 +5,7 @@
#define SER_APPHDR "hdr"
#define SER_APPCOLLECTOR "appcollector"
#define SER_HIDDEN "hidden"
#define SER_DIRECTLAUNCH "directlaunch"
NvApp::NvApp(QSettings& settings)
{
@@ -13,6 +14,7 @@ NvApp::NvApp(QSettings& settings)
hdrSupported = settings.value(SER_APPHDR).toBool();
isAppCollectorGame = settings.value(SER_APPCOLLECTOR).toBool();
hidden = settings.value(SER_HIDDEN).toBool();
directLaunch = settings.value(SER_DIRECTLAUNCH).toBool();
}
void NvApp::serialize(QSettings& settings) const
@@ -22,4 +24,5 @@ void NvApp::serialize(QSettings& settings) const
settings.setValue(SER_APPHDR, hdrSupported);
settings.setValue(SER_APPCOLLECTOR, isAppCollectorGame);
settings.setValue(SER_HIDDEN, hidden);
settings.setValue(SER_DIRECTLAUNCH, directLaunch);
}
+3 -1
View File
@@ -14,7 +14,8 @@ public:
name == other.name &&
hdrSupported == other.hdrSupported &&
isAppCollectorGame == other.isAppCollectorGame &&
hidden == other.hidden;
hidden == other.hidden &&
directLaunch == other.directLaunch;
}
bool operator!=(const NvApp& other) const
@@ -35,6 +36,7 @@ public:
bool hdrSupported = false;
bool isAppCollectorGame = false;
bool hidden = false;
bool directLaunch = false;
};
Q_DECLARE_METATYPE(NvApp)
+1
View File
@@ -317,6 +317,7 @@ bool NvComputer::updateAppList(QVector<NvApp> newAppList) {
for (NvApp& newApp : newAppList) {
if (existingApp.id == newApp.id) {
newApp.hidden = existingApp.hidden;
newApp.directLaunch = existingApp.directLaunch;
}
}
}
+19 -13
View File
@@ -233,17 +233,17 @@ NvHTTP::getDisplayModeList(QString serverInfo)
while (!xmlReader.atEnd()) {
while (xmlReader.readNextStartElement()) {
QStringRef name = xmlReader.name();
if (name == "DisplayMode") {
auto name = xmlReader.name();
if (name == QString("DisplayMode")) {
modes.append(NvDisplayMode());
}
else if (name == "Width") {
else if (name == QString("Width")) {
modes.last().width = xmlReader.readElementText().toInt();
}
else if (name == "Height") {
else if (name == QString("Height")) {
modes.last().height = xmlReader.readElementText().toInt();
}
else if (name == "RefreshRate") {
else if (name == QString("RefreshRate")) {
modes.last().refreshRate = xmlReader.readElementText().toInt();
}
}
@@ -266,8 +266,8 @@ NvHTTP::getAppList()
QVector<NvApp> apps;
while (!xmlReader.atEnd()) {
while (xmlReader.readNextStartElement()) {
QStringRef name = xmlReader.name();
if (name == "App") {
auto name = xmlReader.name();
if (name == QString("App")) {
// We must have a valid app before advancing to the next one
if (!apps.isEmpty() && !apps.last().isInitialized()) {
qWarning() << "Invalid applist XML";
@@ -276,16 +276,16 @@ NvHTTP::getAppList()
}
apps.append(NvApp());
}
else if (name == "AppTitle") {
else if (name == QString("AppTitle")) {
apps.last().name = xmlReader.readElementText();
}
else if (name == "ID") {
else if (name == QString("ID")) {
apps.last().id = xmlReader.readElementText().toInt();
}
else if (name == "IsHdrSupported") {
else if (name == QString("IsHdrSupported")) {
apps.last().hdrSupported = xmlReader.readElementText() == "1";
}
else if (name == "IsAppCollectorGame") {
else if (name == QString("IsAppCollectorGame")) {
apps.last().isAppCollectorGame = xmlReader.readElementText() == "1";
}
}
@@ -301,7 +301,7 @@ NvHTTP::verifyResponseStatus(QString xml)
while (xmlReader.readNextStartElement())
{
if (xmlReader.name() == "root")
if (xmlReader.name() == QString("root"))
{
// Status code can be 0xFFFFFFFF in some rare cases on GFE 3.20.3, and
// QString::toInt() will fail in that case, so use QString::toUInt()
@@ -323,7 +323,7 @@ NvHTTP::verifyResponseStatus(QString xml)
// Special case handling an audio capture error which GFE doesn't
// provide any useful status message for.
statusCode = 418;
statusMessage = "Missing audio capture device. Reinstalling GeForce Experience should resolve this error.";
statusMessage = tr("Missing audio capture device. Reinstalling GeForce Experience should resolve this error.");
}
throw GfeHttpResponseException(statusCode, statusMessage);
}
@@ -414,7 +414,13 @@ NvHTTP::openConnectionToString(QUrl baseUrl,
QString ret;
QTextStream stream(reply);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
stream.setEncoding(QStringConverter::Utf8);
#else
stream.setCodec("UTF-8");
#endif
ret = stream.readAll();
delete reply;
+7 -5
View File
@@ -238,17 +238,18 @@ NvPairingManager::pair(QString appVersion, QString pin, QSslCertificate& serverC
return PairState::ALREADY_IN_PROGRESS;
}
serverCert = QSslCertificate(serverCertStr);
if (serverCert.isNull()) {
Q_ASSERT(!serverCert.isNull());
QSslCertificate unverifiedServerCert = QSslCertificate(serverCertStr);
if (unverifiedServerCert.isNull()) {
Q_ASSERT(!unverifiedServerCert.isNull());
qCritical() << "Failed to parse plaincert";
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, REQUEST_TIMEOUT_MS);
return PairState::FAILED;
}
// Pin this cert for TLS
m_Http.setServerCert(serverCert);
// Pin this cert for TLS until pairing is complete. If successful, we will propagate
// the cert into the NvComputer object and persist it.
m_Http.setServerCert(unverifiedServerCert);
QByteArray randomChallenge = generateRandomBytes(16);
QByteArray encryptedChallenge = encrypt(randomChallenge, aesKey);
@@ -353,5 +354,6 @@ NvPairingManager::pair(QString appVersion, QString pin, QSslCertificate& serverC
return PairState::FAILED;
}
serverCert = std::move(unverifiedServerCert);
return PairState::PAIRED;
}
+79 -27
View File
@@ -6,19 +6,55 @@
#include "streaming/session.h"
#include "streaming/streamutils.h"
#ifdef Q_OS_WIN32
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#endif
SystemProperties::SystemProperties()
{
versionString = QString(VERSION_STR);
hasWindowManager = WMUtils::isRunningWindowManager();
isRunningWayland = WMUtils::isRunningWayland();
isRunningXWayland = isRunningWayland && QGuiApplication::platformName() == "xcb";
QString nativeArch = QSysInfo::currentCpuArchitecture();
#ifdef Q_OS_WIN32
isWow64 = QSysInfo::currentCpuArchitecture() != QSysInfo::buildCpuArchitecture();
{
USHORT processArch, machineArch;
// Use IsWow64Process2 on TH2 and later, because it supports ARM64
auto fnIsWow64Process2 = (decltype(IsWow64Process2)*)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process2");
if (fnIsWow64Process2 != nullptr && fnIsWow64Process2(GetCurrentProcess(), &processArch, &machineArch)) {
switch (machineArch) {
case IMAGE_FILE_MACHINE_I386:
nativeArch = "i386";
break;
case IMAGE_FILE_MACHINE_AMD64:
nativeArch = "x86_64";
break;
case IMAGE_FILE_MACHINE_ARM64:
nativeArch = "arm64";
break;
}
}
isWow64 = nativeArch != QSysInfo::buildCpuArchitecture();
}
#else
isWow64 = false;
#endif
if (nativeArch == "i386") {
friendlyNativeArchName = "x86";
}
else if (nativeArch == "x86_64") {
friendlyNativeArchName = "x64";
}
else {
friendlyNativeArchName = nativeArch.toUpper();
}
#ifndef STEAM_LINK
// Assume we can probably launch a browser if we're in a GUI environment
hasBrowser = hasWindowManager;
@@ -57,13 +93,8 @@ QRect SystemProperties::getNativeResolution(int displayIndex)
void SystemProperties::querySdlVideoInfo()
{
monitorDesktopResolutions.clear();
monitorNativeResolutions.clear();
hasHardwareAcceleration = false;
// Never let the maximum drop below 60 FPS
maximumStreamingFrameRate = 60;
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
@@ -71,6 +102,48 @@ void SystemProperties::querySdlVideoInfo()
return;
}
// Update display related attributes (max FPS, native resolution, etc).
refreshDisplays();
SDL_Window* testWindow = SDL_CreateWindow("", 0, 0, 1280, 720,
SDL_WINDOW_HIDDEN | StreamUtils::getPlatformWindowFlags());
if (!testWindow) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Failed to create test window with platform flags: %s",
SDL_GetError());
testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, SDL_WINDOW_HIDDEN);
if (!testWindow) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Failed to create window for hardware decode test: %s",
SDL_GetError());
SDL_QuitSubSystem(SDL_INIT_VIDEO);
return;
}
}
Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen, maximumResolution);
SDL_DestroyWindow(testWindow);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
void SystemProperties::refreshDisplays()
{
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
SDL_GetError());
return;
}
monitorDesktopResolutions.clear();
monitorNativeResolutions.clear();
// Never let the maximum drop below 60 FPS
maximumStreamingFrameRate = 60;
SDL_DisplayMode bestMode;
for (int displayIndex = 0; displayIndex < SDL_GetNumVideoDisplays(); displayIndex++) {
SDL_DisplayMode desktopMode;
@@ -120,26 +193,5 @@ void SystemProperties::querySdlVideoInfo()
}
}
SDL_Window* testWindow = SDL_CreateWindow("", 0, 0, 1280, 720,
SDL_WINDOW_HIDDEN | StreamUtils::getPlatformWindowFlags());
if (!testWindow) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Failed to create test window with platform flags: %s",
SDL_GetError());
testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, SDL_WINDOW_HIDDEN);
if (!testWindow) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Failed to create window for hardware decode test: %s",
SDL_GetError());
SDL_QuitSubSystem(SDL_INIT_VIDEO);
return;
}
}
Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen, maximumResolution);
SDL_DestroyWindow(testWindow);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
+3
View File
@@ -15,6 +15,7 @@ public:
Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT)
Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT)
Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT)
Q_PROPERTY(QString friendlyNativeArchName MEMBER friendlyNativeArchName CONSTANT)
Q_PROPERTY(bool hasWindowManager MEMBER hasWindowManager CONSTANT)
Q_PROPERTY(bool hasBrowser MEMBER hasBrowser CONSTANT)
Q_PROPERTY(bool hasDiscordIntegration MEMBER hasDiscordIntegration CONSTANT)
@@ -23,6 +24,7 @@ public:
Q_PROPERTY(QSize maximumResolution MEMBER maximumResolution CONSTANT)
Q_PROPERTY(QString versionString MEMBER versionString CONSTANT)
Q_INVOKABLE void refreshDisplays();
Q_INVOKABLE QRect getDesktopResolution(int displayIndex);
Q_INVOKABLE QRect getNativeResolution(int displayIndex);
@@ -37,6 +39,7 @@ private:
bool isRunningWayland;
bool isRunningXWayland;
bool isWow64;
QString friendlyNativeArchName;
bool hasWindowManager;
bool hasBrowser;
bool hasDiscordIntegration;
+20
View File
@@ -303,6 +303,11 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
parser.addToggleOption("game-optimization", "game optimizations");
parser.addToggleOption("audio-on-host", "audio on host PC");
parser.addToggleOption("frame-pacing", "frame pacing");
parser.addToggleOption("mute-on-focus-loss", "mute audio when Moonlight window loses focus");
parser.addToggleOption("background-gamepad", "background gamepad input");
parser.addToggleOption("reverse-scroll-direction", "inverted scroll direction");
parser.addToggleOption("swap-gamepad-buttons", "swap A/B and X/Y gamepad buttons (Nintendo-style)");
parser.addToggleOption("capture-system-keys", "capture system key combos in fullscreen mode");
parser.addChoiceOption("video-codec", "video codec", m_VideoCodecMap.keys());
parser.addChoiceOption("video-decoder", "video decoder", m_VideoDecoderMap.keys());
@@ -405,6 +410,21 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
// Resolve --frame-pacing and --no-frame-pacing options
preferences->framePacing = parser.getToggleOptionValue("frame-pacing", preferences->framePacing);
// Resolve --mute-on-focus-loss and --no-mute-on-focus-loss options
preferences->muteOnFocusLoss = parser.getToggleOptionValue("mute-on-focus-loss", preferences->muteOnFocusLoss);
// Resolve --background-gamepad and --no-background-gamepad options
preferences->backgroundGamepad = parser.getToggleOptionValue("background-gamepad", preferences->backgroundGamepad);
// Resolve --reverse-scroll-direction and --no-reverse-scroll-direction options
preferences->reverseScrollDirection = parser.getToggleOptionValue("reverse-scroll-direction", preferences->reverseScrollDirection);
// Resolve --swap-gamepad-buttons and --no-swap-gamepad-buttons options
preferences->swapFaceButtons = parser.getToggleOptionValue("swap-gamepad-buttons", preferences->swapFaceButtons);
// Resolve --capture-system-keys and --no-capture-system-keys options
preferences->captureSysKeys = parser.getToggleOptionValue("capture-system-keys", preferences->captureSysKeys);
// Resolve --video-codec option
if (parser.isSet("video-codec")) {
preferences->videoCodecConfig = mapValue(m_VideoCodecMap, parser.getChoiceOptionValue("video-codec"));
+4 -4
View File
@@ -73,7 +73,7 @@ public:
case Event::ComputerSeekTimedout:
if (m_State == StateSeekComputer) {
m_State = StateFailure;
emit q->failed(QString("Failed to connect to %1").arg(m_ComputerName));
emit q->failed(QObject::tr("Failed to connect to %1").arg(m_ComputerName));
}
break;
// Occurs when searched computer is found
@@ -85,8 +85,8 @@ public:
m_ComputerManager->quitRunningApp(event.computer);
} else {
m_State = StateFailure;
QString msg = QString("Computer %1 has not been paired. "
"Please open Moonlight to pair before streaming.")
QString msg = QObject::tr("Computer %1 has not been paired. "
"Please open Moonlight to pair before streaming.")
.arg(event.computer->name);
emit q->failed(msg);
}
@@ -99,7 +99,7 @@ public:
QCoreApplication::exit(0);
} else {
m_State = StateFailure;
emit q->failed(QString("Quitting app failed, reason: %1").arg(event.errorMessage));
emit q->failed(QObject::tr("Quitting app failed, reason: %1").arg(event.errorMessage));
}
}
break;
+5 -5
View File
@@ -86,8 +86,8 @@ public:
emit q->searchingApp();
} else {
m_State = StateFailure;
QString msg = QString("Computer %1 has not been paired. "
"Please open Moonlight to pair before streaming.")
QString msg = QObject::tr("Computer %1 has not been paired. "
"Please open Moonlight to pair before streaming.")
.arg(event.computer->name);
emit q->failed(msg);
}
@@ -123,18 +123,18 @@ public:
case Event::AppQuitCompleted:
if (m_State == StateSeekApp && !event.errorMessage.isEmpty()) {
m_State = StateFailure;
emit q->failed(QString("Quitting app failed, reason: %1").arg(event.errorMessage));
emit q->failed(QObject::tr("Quitting app failed, reason: %1").arg(event.errorMessage));
}
break;
// Occurs when computer or app search timed out
case Event::Timedout:
if (m_State == StateSeekComputer) {
m_State = StateFailure;
emit q->failed(QString("Failed to connect to %1").arg(m_ComputerName));
emit q->failed(QObject::tr("Failed to connect to %1").arg(m_ComputerName));
}
if (m_State == StateSeekApp) {
m_State = StateFailure;
emit q->failed(QString("Failed to find application %1").arg(m_AppName));
emit q->failed(QObject::tr("Failed to find application %1").arg(m_AppName));
}
break;
}
@@ -15,6 +15,7 @@
<li>Hardware accelerated video decoding with VAAPI, VDPAU, and NVDEC support</li>
<li>7.1 surround sound audio support</li>
<li>Support for both pointer capture (for games) and direct mouse control (for remote desktop)</li>
<li>Support for passing system-wide keyboard shortcuts like Alt+Tab to the host in fullscreen mode on X11</li>
<li>Direct touchscreen mouse control</li>
<li>HEVC support for better video compression efficiency</li>
<li>Gamepad support with force feedback for up to 4 players</li>
@@ -35,6 +36,33 @@
</screenshots>
<releases>
<release version="3.0.0" date="2021-01-17">
<description>
<p>New features:</p>
<ul>
<li>Added the ability to define a custom streaming resolution using the UI</li>
<li>Added the option to capture system key combinations (Alt+Tab, Ctrl+Shift+Esc, Win+Tab, etc) in fullscreen mode</li>
<li>Updated gamepad mappings are automatically downloaded each time Moonlight launches</li>
<li>The performance overlay is now supported for Linux clients using VAAPI and VDPAU hardware acceleration</li>
<li>Added the option to enable "Direct Launch" which immediately launches the specified game when clicking on a PC</li>
<li>Added the option to mute audio when the Moonlight window loses input focus</li>
<li>Added the option to toggle background gamepad input</li>
<li>Added the option to invert scroll direction</li>
<li>Added the option to swap gamepad button layout to Nintendo-style</li>
<li>Added the option to start the Moonlight UI in fullscreen mode</li>
<li>The failing TCP or UDP ports are now displayed when the connection fails</li>
</ul>
<p>Bugfixes:</p>
<ul>
<li>Fixed PS4 controllers not reading inputs during haptics in some games</li>
<li>Fixed some slow decoders causing the receive time value to increase rather than the decode time</li>
<li>Native resolution options now refresh each time the settings page is opened, rather than once per launch of Moonlight</li>
<li>Fixed no video or audio while streaming over Internet connections that drop packets with QoS tagging enabled</li>
<li>Improved connection testing accuracy for connections with low MTUs</li>
<li>Fixed inability to open an app's context menu with a gamepad</li>
</ul>
</description>
</release>
<release version="2.2.0" date="2020-09-10">
<description>
<p>New features:</p>
+58 -22
View File
@@ -10,6 +10,7 @@ CenteredGridView {
property AppModel appModel : createModel()
property bool activated
property bool showHiddenGames
property bool showGames
id: appGrid
focus: true
@@ -39,6 +40,19 @@ CenteredGridView {
if (currentIndex == -1 && SdlGamepadKeyNavigation.getConnectedGamepads() > 0) {
currentIndex = 0
}
if (!showGames && !showHiddenGames) {
// Check if there's a direct launch app
var directLaunchAppIndex = model.getDirectLaunchAppIndex();
if (directLaunchAppIndex >= 0) {
// Start the direct launch app if nothing else is running
currentIndex = directLaunchAppIndex
currentItem.launchOrResumeSelectedApp(false)
// Set showGames so we will not loop when the stream ends
showGames = true
}
}
}
StackView.onDeactivating: {
@@ -112,10 +126,10 @@ CenteredGridView {
}
onClicked: {
launchOrResumeSelectedApp()
launchOrResumeSelectedApp(true)
}
ToolTip.text: "Resume Game"
ToolTip.text: qsTr("Resume Game")
ToolTip.delay: 1000
ToolTip.timeout: 3000
ToolTip.visible: hovered
@@ -143,7 +157,7 @@ CenteredGridView {
doQuitGame()
}
ToolTip.text: "Quit Game"
ToolTip.text: qsTr("Quit Game")
ToolTip.delay: 1000
ToolTip.timeout: 3000
ToolTip.visible: hovered
@@ -167,20 +181,27 @@ CenteredGridView {
elide: Text.ElideRight
}
function launchOrResumeSelectedApp()
function launchOrResumeSelectedApp(quitExistingApp)
{
var runningId = appModel.getRunningAppId()
if (runningId !== 0 && runningId !== model.appid) {
quitAppDialog.appName = appModel.getRunningAppName()
quitAppDialog.segueToStream = true
quitAppDialog.nextAppName = model.name
quitAppDialog.nextAppIndex = index
quitAppDialog.open()
if (quitExistingApp) {
quitAppDialog.appName = appModel.getRunningAppName()
quitAppDialog.segueToStream = true
quitAppDialog.nextAppName = model.name
quitAppDialog.nextAppIndex = index
quitAppDialog.open()
}
return
}
var component = Qt.createComponent("StreamSegue.qml")
var segue = component.createObject(stackView, {"appName": model.name, "session": appModel.createSessionForApp(index)})
var segue = component.createObject(stackView, {
"appName": model.name,
"session": appModel.createSessionForApp(index),
"isResume": runningId === model.appid
})
stackView.push(segue)
}
@@ -190,7 +211,7 @@ CenteredGridView {
// will handle starting the game and clicks on the box art will
// be ignored.
if (!model.running) {
launchOrResumeSelectedApp()
launchOrResumeSelectedApp(true)
}
}
@@ -225,11 +246,8 @@ CenteredGridView {
}
Keys.onMenuPressed: {
if (model.running) {
// This will be keyboard/gamepad driven so use
// open() instead of popup()
appContextMenu.open()
}
// This will be keyboard/gamepad driven so use open() instead of popup()
appContextMenu.open()
}
function doQuitGame() {
@@ -242,22 +260,40 @@ CenteredGridView {
id: appContextMenu
NavigableMenuItem {
parentMenu: appContextMenu
text: model.running ? "Resume Game" : "Launch Game"
onTriggered: launchOrResumeSelectedApp()
text: model.running ? qsTr("Resume Game") : qsTr("Launch Game")
onTriggered: launchOrResumeSelectedApp(true)
}
NavigableMenuItem {
parentMenu: appContextMenu
text: "Quit Game"
text: qsTr("Quit Game")
onTriggered: doQuitGame()
visible: model.running
}
NavigableMenuItem {
parentMenu: appContextMenu
checkable: true
checked: model.directLaunch
text: qsTr("Direct Launch")
onTriggered: appModel.setAppDirectLaunch(model.index, !model.directLaunch)
enabled: !model.hidden
ToolTip.text: qsTr("Launch this app immediately when the host is selected, bypassing the app selection grid.")
ToolTip.delay: 1000
ToolTip.timeout: 3000
ToolTip.visible: hovered
}
NavigableMenuItem {
parentMenu: appContextMenu
checkable: true
checked: model.hidden
text: "Hide Game"
text: qsTr("Hide Game")
onTriggered: appModel.setAppHidden(model.index, !model.hidden)
visible: !model.running || model.hidden
enabled: model.hidden || (!model.running && !model.directLaunch)
ToolTip.text: qsTr("Hide this game from the app grid. To access hidden games, right-click on the host and choose %1.").arg(qsTr("View All Apps"))
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
}
}
}
@@ -268,7 +304,7 @@ CenteredGridView {
property bool segueToStream : false
property string nextAppName: ""
property int nextAppIndex: 0
text:"Are you sure you want to quit " + appName +"? Any unsaved progress will be lost."
text:qsTr("Are you sure you want to quit %1? Any unsaved progress will be lost.").arg(appName)
standardButtons: Dialog.Yes | Dialog.No
function quitApp() {
+5 -3
View File
@@ -19,9 +19,7 @@ ComboBox {
id: textMetrics
}
// We call this every time the options change (and init)
// so we can adjust the combo box width here too
onActivated: {
function recalculateWidth() {
textMetrics.font = font
popupMetrics.font = popup.font
textWidth = 0
@@ -33,6 +31,10 @@ ComboBox {
}
}
// We call this every time the options change (and init)
// so we can adjust the combo box width here too
onActivated: recalculateWidth()
popup.onAboutToShow: {
// Switch to normal navigation for combo boxes
SdlGamepadKeyNavigation.setUiNavMode(false)
+2 -2
View File
@@ -6,11 +6,11 @@ import Session 1.0
Item {
function onSearchingComputer() {
stageLabel.text = "Establishing connection to PC..."
stageLabel.text = qsTr("Establishing connection to PC...")
}
function onQuittingApp() {
stageLabel.text = "Quitting app..."
stageLabel.text = qsTr("Quitting app...")
}
function onFailure(message) {
+3 -3
View File
@@ -6,11 +6,11 @@ import SdlGamepadKeyNavigation 1.0
Item {
function onSearchingComputer() {
stageLabel.text = "Establishing connection to PC..."
stageLabel.text = qsTr("Establishing connection to PC...")
}
function onSearchingApp() {
stageLabel.text = "Loading app list..."
stageLabel.text = qsTr("Loading app list...")
}
function onSessionCreated(appName, session) {
@@ -78,7 +78,7 @@ Item {
NavigableMessageDialog {
id: quitAppDialog
text:"Are you sure you want to quit " + appName +"? Any unsaved progress will be lost."
text:qsTr("Are you sure you want to quit %1? Any unsaved progress will be lost.").arg(appName)
standardButtons: Dialog.Yes | Dialog.No
property string appName : ""
+1 -1
View File
@@ -1,5 +1,5 @@
import QtQuick 2.0
Item {
objectName: "Gamepad Mapping"
objectName: qsTr("Gamepad Mapping")
}
+2 -1
View File
@@ -2,7 +2,8 @@ import QtQuick 2.0
import QtQuick.Controls 2.2
Dialog {
parent: overlay
// We should use Overlay.overlay here but that's not available in Qt 5.9 :(
parent: ApplicationWindow.contentItem
x: Math.round((parent.width - width) / 2)
y: Math.round((parent.height - height) / 2)
+8 -1
View File
@@ -3,6 +3,13 @@ import QtQuick.Controls 2.2
Menu {
onOpened: {
itemAt(0).forceActiveFocus(Qt.TabFocusReason)
// Give focus to the first visible and enabled menu item
for (var i = 0; i < count; i++) {
var item = itemAt(i)
if (item.visible && item.enabled) {
item.forceActiveFocus(Qt.TabFocusReason)
break
}
}
}
}
+23 -28
View File
@@ -17,7 +17,7 @@ CenteredGridView {
topMargin: 20
bottomMargin: 5
cellWidth: 310; cellHeight: 330;
objectName: "Computers"
objectName: qsTr("Computers")
Component.onCompleted: {
// Don't show any highlighted item until interacting with them.
@@ -64,13 +64,13 @@ CenteredGridView {
function addComplete(success, detectedPortBlocking)
{
if (!success) {
errorDialog.text = "Unable to connect to the specified PC."
errorDialog.text = qsTr("Unable to connect to the specified PC.")
if (detectedPortBlocking) {
errorDialog.text += "\n\nThis PC's Internet connection is blocking Moonlight. Streaming over the Internet may not work while connected to this network."
errorDialog.text += "\n\n" + qsTr("This PC's Internet connection is blocking Moonlight. Streaming over the Internet may not work while connected to this network.")
}
else {
errorDialog.helpText = "Click the Help button for possible solutions."
errorDialog.helpText = qsTr("Click the Help button for possible solutions.")
}
errorDialog.open()
@@ -99,8 +99,8 @@ CenteredGridView {
Label {
height: searchSpinner.height
elide: Label.ElideRight
text: StreamingPreferences.enableMdns ? "Searching for PCs with NVIDIA GameStream enabled..."
: "Automatic PC discovery is disabled. Add your PC manually."
text: StreamingPreferences.enableMdns ? qsTr("Searching for PCs on your local network with NVIDIA GameStream enabled...")
: qsTr("Automatic PC discovery is disabled. Add your PC manually.")
font.pointSize: 20
verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap
@@ -162,19 +162,14 @@ CenteredGridView {
NavigableMenu {
id: pcContextMenu
NavigableMenuItem {
parentMenu: pcContextMenu
text: "View Apps"
onTriggered: {
var component = Qt.createComponent("AppView.qml")
var appView = component.createObject(stackView, {"computerIndex": index, "objectName": model.name})
stackView.push(appView)
}
visible: model.online && model.paired
MenuItem {
text: qsTr("PC Status: %1").arg(model.online ? qsTr("Online") : qsTr("Offline"))
font.bold: true
enabled: false
}
NavigableMenuItem {
parentMenu: pcContextMenu
text: "View Hidden Apps"
text: qsTr("View All Apps")
onTriggered: {
var component = Qt.createComponent("AppView.qml")
var appView = component.createObject(stackView, {"computerIndex": index, "objectName": model.name, "showHiddenGames": true})
@@ -184,13 +179,13 @@ CenteredGridView {
}
NavigableMenuItem {
parentMenu: pcContextMenu
text: "Wake PC"
text: qsTr("Wake PC")
onTriggered: computerModel.wakeComputer(index)
visible: !model.online && model.wakeable
}
NavigableMenuItem {
parentMenu: pcContextMenu
text: "Test Network"
text: qsTr("Test Network")
onTriggered: {
computerModel.testConnectionForComputer(index)
testConnectionDialog.open()
@@ -199,7 +194,7 @@ CenteredGridView {
NavigableMenuItem {
parentMenu: pcContextMenu
text: "Rename PC"
text: qsTr("Rename PC")
onTriggered: {
renamePcDialog.pcIndex = index
renamePcDialog.originalName = model.name
@@ -208,7 +203,7 @@ CenteredGridView {
}
NavigableMenuItem {
parentMenu: pcContextMenu
text: "Delete PC"
text: qsTr("Delete PC")
onTriggered: {
deletePcDialog.pcIndex = index
// get confirmation first, actual closing is called from the dialog
@@ -238,7 +233,7 @@ CenteredGridView {
}
else {
// cannot pair while something is streaming or attempting to pair
errorDialog.text = "You cannot pair while a previous session is still running on the host PC. Quit any running games or reboot the host PC, then try pairing again."
errorDialog.text = qsTr("You cannot pair while a previous session is still running on the host PC. Quit any running games or reboot the host PC, then try pairing again.")
errorDialog.helpText = ""
errorDialog.open()
}
@@ -293,7 +288,7 @@ CenteredGridView {
// don't allow edits to the rest of the window while open
property string pin : "0000"
text:"Please enter " + pin + " on your GameStream PC. This dialog will close when pairing is completed."
text:qsTr("Please enter %1 on your GameStream PC. This dialog will close when pairing is completed.").arg(pin)
standardButtons: Dialog.Cancel
onRejected: {
// FIXME: We should interrupt pairing here
@@ -304,7 +299,7 @@ CenteredGridView {
id: deletePcDialog
// don't allow edits to the rest of the window while open
property int pcIndex : -1;
text:"Are you sure you want to remove this PC?"
text:qsTr("Are you sure you want to remove this PC?")
standardButtons: Dialog.Yes | Dialog.No
function deletePc() {
@@ -321,22 +316,22 @@ CenteredGridView {
standardButtons: Dialog.Ok
onAboutToShow: {
testConnectionDialog.text = "Moonlight is testing your network connection to determine if NVIDIA GameStream is blocked.\n\nThis may take a few seconds…"
testConnectionDialog.text = qsTr("Moonlight is testing your network connection to determine if NVIDIA GameStream is blocked.") + "\n\n" + qsTr("This may take a few seconds…")
showSpinner = true
}
function connectionTestComplete(result, blockedPorts)
{
if (result === -1) {
text = "The network test could not be performed because none of Moonlight's connection testing servers were reachable from this PC. Check your Internet connection or try again later."
text = qsTr("The network test could not be performed because none of Moonlight's connection testing servers were reachable from this PC. Check your Internet connection or try again later.")
imageSrc = "qrc:/res/baseline-warning-24px.svg"
}
else if (result === 0) {
text = "This network does not appear to be blocking Moonlight. If you still have trouble connecting, check your PC's firewall settings.\n\nIf you are trying to stream over the Internet, install the Moonlight Internet Hosting Tool on your gaming PC and run the included Internet Streaming Tester to check your gaming PC's Internet connection."
text = qsTr("This network does not appear to be blocking Moonlight. If you still have trouble connecting, check your PC's firewall settings.") + "\n\n" + qsTr("If you are trying to stream over the Internet, install the Moonlight Internet Hosting Tool on your gaming PC and run the included Internet Streaming Tester to check your gaming PC's Internet connection.")
imageSrc = "qrc:/res/baseline-check_circle_outline-24px.svg"
}
else {
text = "Your PC's current network connection seems to be blocking Moonlight. Streaming over the Internet may not work while connected to this network.\n\nThe following network ports were blocked:\n"
text = qsTr("Your PC's current network connection seems to be blocking Moonlight. Streaming over the Internet may not work while connected to this network.") + "\n\n" + qsTr("The following network ports were blocked:") + "\n"
text += blockedPorts
imageSrc = "qrc:/res/baseline-error_outline-24px.svg"
}
@@ -348,7 +343,7 @@ CenteredGridView {
NavigableDialog {
id: renamePcDialog
property string label: "Enter the new name for this PC:"
property string label: qsTr("Enter the new name for this PC:")
property string originalName
property int pcIndex : -1;
+1 -1
View File
@@ -9,7 +9,7 @@ Item {
property Session nextSession : null
property string nextAppName : ""
property string stageText : "Quitting " + appName + "..."
property string stageText : qsTr("Quitting %1...").arg(appName)
function quitAppCompleted(error)
{
+448 -123
View File
@@ -1,5 +1,6 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.2
import StreamingPreferences 1.0
import ComputerManager 1.0
@@ -8,7 +9,7 @@ import SystemProperties 1.0
Flickable {
id: settingsPage
objectName: "Settings"
objectName: qsTr("Settings")
boundsBehavior: Flickable.OvershootBounds
@@ -40,6 +41,12 @@ Flickable {
StreamingPreferences.save()
}
Component.onDestruction: {
// Also save preferences on destruction, since we won't get a
// deactivating callback if the user just closes Moonlight
StreamingPreferences.save()
}
Column {
padding: 10
id: settingsColumn1
@@ -50,7 +57,7 @@ Flickable {
id: basicSettingsGroupBox
width: (parent.width - (parent.leftPadding + parent.rightPadding))
padding: 12
title: "<font color=\"skyblue\">Basic Settings</font>"
title: "<font color=\"skyblue\">" + qsTr("Basic Settings") + "</font>"
font.pointSize: 12
Column {
@@ -78,8 +85,13 @@ Flickable {
width: parent.width
AutoResizingComboBox {
property int lastIndexValue
// ignore setting the index at first, and actually set it when the component is loaded
Component.onCompleted: {
// Refresh display data before using it to build the list
SystemProperties.refreshDisplays()
// Add native resolutions for all attached displays
var done = false
for (var displayIndex = 0; !done; displayIndex++) {
@@ -123,7 +135,8 @@ Flickable {
{
"text": "Native ("+screenRect.width+"x"+screenRect.height+")",
"video_width": ""+screenRect.width,
"video_height": ""+screenRect.height
"video_height": ""+screenRect.height,
"is_custom": false
})
}
}
@@ -147,19 +160,42 @@ Flickable {
// and set it to that index.
var saved_width = StreamingPreferences.width
var saved_height = StreamingPreferences.height
currentIndex = 0
var index_set = false
for (var i = 0; i < resolutionListModel.count; i++) {
var el_width = parseInt(resolutionListModel.get(i).video_width);
var el_height = parseInt(resolutionListModel.get(i).video_height);
// Pick the highest value lesser or equal to the saved resolution
if (saved_width * saved_height >= el_width * el_height) {
if (saved_width === el_width && saved_height === el_height) {
currentIndex = i
index_set = true
break
}
}
// Persist the selected value
activated(currentIndex)
if (!index_set) {
// We did not find a match. This must be a custom resolution.
resolutionListModel.append({
"text": "Custom ("+StreamingPreferences.width+"x"+StreamingPreferences.height+")",
"video_width": ""+StreamingPreferences.width,
"video_height": ""+StreamingPreferences.height,
"is_custom": true
})
currentIndex = resolutionListModel.count - 1
}
else {
resolutionListModel.append({
"text": "Custom",
"video_width": "",
"video_height": "",
"is_custom": true
})
}
// Since we don't call activate() here, we need to trigger
// width calculation manually
recalculateWidth()
lastIndexValue = currentIndex
}
id: resolutionComboBox
@@ -170,28 +206,32 @@ Flickable {
// Other elements may be added at runtime
// based on attached display resolution
ListElement {
text: "720p"
text: qsTr("720p")
video_width: "1280"
video_height: "720"
is_custom: false
}
ListElement {
text: "1080p"
text: qsTr("1080p")
video_width: "1920"
video_height: "1080"
is_custom: false
}
ListElement {
text: "1440p"
text: qsTr("1440p")
video_width: "2560"
video_height: "1440"
is_custom: false
}
ListElement {
text: "4K"
text: qsTr("4K")
video_width: "3840"
video_height: "2160"
is_custom: false
}
}
// ::onActivated must be used, as it only listens for when the index is changed by a human
onActivated : {
function updateBitrateForSelection() {
var selectedWidth = parseInt(resolutionListModel.get(currentIndex).video_width)
var selectedHeight = parseInt(resolutionListModel.get(currentIndex).video_height)
@@ -205,6 +245,146 @@ Flickable {
StreamingPreferences.fps);
slider.value = StreamingPreferences.bitrateKbps
}
lastIndexValue = currentIndex
}
// ::onActivated must be used, as it only listens for when the index is changed by a human
onActivated : {
if (resolutionListModel.get(currentIndex).is_custom) {
customResolutionDialog.open()
}
else {
updateBitrateForSelection()
}
}
NavigableDialog {
id: customResolutionDialog
standardButtons: Dialog.Ok | Dialog.Cancel
onOpened: {
// Force keyboard focus on the textbox so keyboard navigation works
widthField.forceActiveFocus()
// standardButton() was added in Qt 5.10, so we must check for it first
if (customResolutionDialog.standardButton) {
customResolutionDialog.standardButton(Dialog.Ok).enabled = customResolutionDialog.isInputValid()
}
}
onClosed: {
widthField.clear()
heightField.clear()
}
onRejected: {
resolutionComboBox.currentIndex = resolutionComboBox.lastIndexValue
}
function isInputValid() {
// If we have text in either textbox that isn't valid,
// reject the input.
if ((!widthField.acceptableInput && widthField.text) ||
(!heightField.acceptableInput && heightField.text)) {
return false
}
// The textboxes need to have text or placeholder text
if ((!widthField.text && !widthField.placeholderText) ||
(!heightField.text && !heightField.placeholderText)) {
return false
}
return true
}
onAccepted: {
// Reject if there's invalid input
if (!isInputValid()) {
reject()
return
}
var width = widthField.text ? widthField.text : widthField.placeholderText
var height = heightField.text ? heightField.text : heightField.placeholderText
// Find and update the custom entry
for (var i = 0; i < resolutionListModel.count; i++) {
if (resolutionListModel.get(i).is_custom) {
resolutionListModel.setProperty(i, "video_width", width)
resolutionListModel.setProperty(i, "video_height", height)
resolutionListModel.setProperty(i, "text", "Custom ("+width+"x"+height+")")
// Now update the bitrate using the custom resolution
resolutionComboBox.currentIndex = i
resolutionComboBox.updateBitrateForSelection()
// Update the combobox width too
resolutionComboBox.recalculateWidth()
break
}
}
}
ColumnLayout {
Label {
text: qsTr("Custom resolutions are not officially supported by GeForce Experience, so it will not set your host display resolution. You will need to set it manually while in game.") + "\n\n" +
qsTr("Resolutions that are not supported by your client or host PC may cause streaming errors.") + "\n"
wrapMode: Label.WordWrap
Layout.maximumWidth: 300
}
Label {
text: qsTr("Enter a custom resolution:")
font.bold: true
}
RowLayout {
TextField {
id: widthField
maximumLength: 5
inputMethodHints: Qt.ImhDigitsOnly
placeholderText: resolutionListModel.get(resolutionComboBox.currentIndex).video_width
validator: IntValidator{bottom:128; top:8192}
focus: true
onTextChanged: {
// standardButton() was added in Qt 5.10, so we must check for it first
if (customResolutionDialog.standardButton) {
customResolutionDialog.standardButton(Dialog.Ok).enabled = customResolutionDialog.isInputValid()
}
}
Keys.onReturnPressed: {
customResolutionDialog.accept()
}
}
Label {
text: "x"
font.bold: true
}
TextField {
id: heightField
maximumLength: 5
inputMethodHints: Qt.ImhDigitsOnly
placeholderText: resolutionListModel.get(resolutionComboBox.currentIndex).video_height
validator: IntValidator{bottom:128; top:8192}
onTextChanged: {
// standardButton() was added in Qt 5.10, so we must check for it first
if (customResolutionDialog.standardButton) {
customResolutionDialog.standardButton(Dialog.Ok).enabled = customResolutionDialog.isInputValid()
}
}
Keys.onReturnPressed: {
customResolutionDialog.accept()
}
}
}
}
}
}
@@ -215,16 +395,16 @@ Flickable {
var max_fps = SystemProperties.maximumStreamingFrameRate
// Default entries
fpsListModel.append({"text": "30 FPS", "video_fps": "30"})
fpsListModel.append({"text": "60 FPS", "video_fps": "60"})
fpsListModel.append({"text": qsTr("%1 FPS").arg("30"), "video_fps": "30"})
fpsListModel.append({"text": qsTr("%1 FPS").arg("60"), "video_fps": "60"})
// Add unsupported FPS values that come before the display max FPS
if (StreamingPreferences.unsupportedFps) {
if (max_fps > 90) {
fpsListModel.append({"text": "90 FPS (Unsupported)", "video_fps": "90"})
fpsListModel.append({"text": qsTr("%1 FPS (Unsupported)").arg("90"), "video_fps": "90"})
}
if (max_fps > 120) {
fpsListModel.append({"text": "120 FPS (Unsupported)", "video_fps": "120"})
fpsListModel.append({"text": qsTr("%1 FPS (Unsupported)").arg("120"), "video_fps": "120"})
}
}
@@ -233,23 +413,23 @@ Flickable {
if (max_fps > 64) {
// Mark any FPS value greater than 120 as unsupported
if (StreamingPreferences.unsupportedFps && max_fps > 120) {
fpsListModel.append({"text": max_fps+" FPS (Unsupported)", "video_fps": ""+max_fps})
fpsListModel.append({"text": qsTr("%1 FPS (Unsupported)").arg(max_fps), "video_fps": ""+max_fps})
}
else if (max_fps > 120) {
fpsListModel.append({"text": "120 FPS", "video_fps": "120"})
fpsListModel.append({"text": qsTr("%1 FPS").arg("120"), "video_fps": "120"})
}
else {
fpsListModel.append({"text": max_fps+" FPS", "video_fps": ""+max_fps})
fpsListModel.append({"text": qsTr("%1 FPS").arg(max_fps), "video_fps": ""+max_fps})
}
}
// Add unsupported FPS values that come after the display max FPS
if (StreamingPreferences.unsupportedFps) {
if (max_fps < 90) {
fpsListModel.append({"text": "90 FPS (Unsupported)", "video_fps": "90"})
fpsListModel.append({"text":qsTr("%1 FPS (Unsupported)").arg("90"), "video_fps": "90"})
}
if (max_fps < 120) {
fpsListModel.append({"text": "120 FPS (Unsupported)", "video_fps": "120"})
fpsListModel.append({"text":qsTr("%1 FPS (Unsupported)").arg("120"), "video_fps": "120"})
}
}
@@ -302,7 +482,7 @@ Flickable {
Label {
width: parent.width
id: bitrateTitle
text: qsTr("Video bitrate: ")
text: qsTr("Video bitrate:")
font.pointSize: 12
wrapMode: Text.Wrap
}
@@ -328,7 +508,7 @@ Flickable {
width: Math.min(bitrateDesc.implicitWidth, parent.width)
onValueChanged: {
bitrateTitle.text = "Video bitrate: " + (value / 1000.0) + " Mbps"
bitrateTitle.text = qsTr("Video bitrate: %1 Mbps").arg(value / 1000.0)
StreamingPreferences.bitrateKbps = value
}
}
@@ -339,6 +519,7 @@ Flickable {
text: qsTr("Display mode")
font.pointSize: 12
wrapMode: Text.Wrap
visible: SystemProperties.hasWindowManager
}
AutoResizingComboBox {
@@ -348,7 +529,7 @@ Flickable {
for (var i = 0; i < windowModeListModel.count; i++) {
var thisWm = windowModeListModel.get(i).val;
if (thisWm === StreamingPreferences.recommendedFullScreenMode) {
windowModeListModel.get(i).text += " (Recommended)"
windowModeListModel.get(i).text += qsTr(" (Recommended)")
windowModeListModel.move(i, 0, 1);
break
}
@@ -371,21 +552,22 @@ Flickable {
}
id: windowModeComboBox
enabled: SystemProperties.hasWindowManager && !SystemProperties.rendererAlwaysFullScreen
visible: SystemProperties.hasWindowManager
enabled: !SystemProperties.rendererAlwaysFullScreen
hoverEnabled: true
textRole: "text"
model: ListModel {
id: windowModeListModel
ListElement {
text: "Full-screen"
text: qsTr("Fullscreen")
val: StreamingPreferences.WM_FULLSCREEN
}
ListElement {
text: "Borderless windowed"
text: qsTr("Borderless windowed")
val: StreamingPreferences.WM_FULLSCREEN_DESKTOP
}
ListElement {
text: "Windowed"
text: qsTr("Windowed")
val: StreamingPreferences.WM_WINDOWED
}
}
@@ -396,14 +578,14 @@ Flickable {
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: "Full-screen generally provides the best performance, but borderless windowed may work better with features like macOS Spaces, Alt+Tab, screenshot tools, on-screen overlays, etc."
ToolTip.text: qsTr("Fullscreen generally provides the best performance, but borderless windowed may work better with features like macOS Spaces, Alt+Tab, screenshot tools, on-screen overlays, etc.")
}
CheckBox {
id: vsyncCheck
width: parent.width
hoverEnabled: true
text: "V-Sync"
text: qsTr("V-Sync")
font.pointSize: 12
checked: StreamingPreferences.enableVsync
onCheckedChanged: {
@@ -413,14 +595,14 @@ Flickable {
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: "Disabling V-Sync allows sub-frame rendering latency, but it can display visible tearing"
ToolTip.text: qsTr("Disabling V-Sync allows sub-frame rendering latency, but it can display visible tearing")
}
CheckBox {
id: framePacingCheck
width: parent.width
hoverEnabled: true
text: "Frame pacing"
text: qsTr("Frame pacing")
font.pointSize: 12
enabled: StreamingPreferences.enableVsync
checked: StreamingPreferences.enableVsync && StreamingPreferences.framePacing
@@ -430,7 +612,7 @@ Flickable {
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: "Frame pacing reduces micro-stutter by delaying frames that come in too early"
ToolTip.text: qsTr("Frame pacing reduces micro-stutter by delaying frames that come in too early")
}
}
}
@@ -440,7 +622,7 @@ Flickable {
id: audioSettingsGroupBox
width: (parent.width - (parent.leftPadding + parent.rightPadding))
padding: 12
title: "<font color=\"skyblue\">Audio Settings</font>"
title: "<font color=\"skyblue\">" + qsTr("Audio Settings") + "</font>"
font.pointSize: 12
Column {
@@ -475,15 +657,15 @@ Flickable {
model: ListModel {
id: audioListModel
ListElement {
text: "Stereo"
text: qsTr("Stereo")
val: StreamingPreferences.AC_STEREO
}
ListElement {
text: "5.1 surround sound"
text: qsTr("5.1 surround sound")
val: StreamingPreferences.AC_51_SURROUND
}
ListElement {
text: "7.1 surround sound"
text: qsTr("7.1 surround sound")
val: StreamingPreferences.AC_71_SURROUND
}
}
@@ -493,6 +675,39 @@ Flickable {
}
}
CheckBox {
id: audioPcCheck
width: parent.width
text: qsTr("Mute host PC speakers while streaming")
font.pointSize: 12
checked: !StreamingPreferences.playAudioOnHost
onCheckedChanged: {
StreamingPreferences.playAudioOnHost = !checked
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("You must restart any game currently in progress for this setting to take effect")
}
CheckBox {
id: muteOnFocusLossCheck
width: parent.width
text: qsTr("Mute audio stream when Moonlight is not the active window")
font.pointSize: 12
visible: SystemProperties.hasWindowManager
checked: StreamingPreferences.muteOnFocusLoss
onCheckedChanged: {
StreamingPreferences.muteOnFocusLoss = checked
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("Mutes Moonlight's audio when you Alt+Tab out of the stream or click on a different window.")
}
}
}
@@ -500,29 +715,72 @@ Flickable {
id: uiSettingsGroupBox
width: (parent.width - (parent.leftPadding + parent.rightPadding))
padding: 12
title: "<font color=\"skyblue\">UI Settings</font>"
title: "<font color=\"skyblue\">" + qsTr("UI Settings") + "</font>"
font.pointSize: 12
Column {
anchors.fill: parent
spacing: 5
CheckBox {
id: startMaximizedCheck
Label {
width: parent.width
text: "Maximize Moonlight window on startup"
id: uiDisplayModeTitle
text: qsTr("GUI display mode")
font.pointSize: 12
enabled: SystemProperties.hasWindowManager
checked: !StreamingPreferences.startWindowed || !SystemProperties.hasWindowManager
onCheckedChanged: {
StreamingPreferences.startWindowed = !checked
wrapMode: Text.Wrap
visible: SystemProperties.hasWindowManager
}
AutoResizingComboBox {
// ignore setting the index at first, and actually set it when the component is loaded
Component.onCompleted: {
if (SystemProperties.hasWindowManager) {
var saved_uidisplaymode = StreamingPreferences.uiDisplayMode
currentIndex = 0
for (var i = 0; i < uiDisplayModeListModel.count; i++) {
var el_uidisplaymode = uiDisplayModeListModel.get(i).val;
if (saved_uidisplaymode === el_uidisplaymode) {
currentIndex = i
break
}
}
}
else {
// Full-screen is always selected when there is no window manager
currentIndex = 2
}
activated(currentIndex)
}
id: uiDisplayModeComboBox
visible: SystemProperties.hasWindowManager
textRole: "text"
model: ListModel {
id: uiDisplayModeListModel
ListElement {
text: qsTr("Windowed")
val: StreamingPreferences.UI_WINDOWED
}
ListElement {
text: qsTr("Maximized")
val: StreamingPreferences.UI_MAXIMIZED
}
ListElement {
text: qsTr("Fullscreen")
val: StreamingPreferences.UI_FULLSCREEN
}
}
// ::onActivated must be used, as it only listens for when the index is changed by a human
onActivated : {
StreamingPreferences.uiDisplayMode = uiDisplayModeListModel.get(currentIndex).val
}
}
CheckBox {
id: connectionWarningsCheck
width: parent.width
text: "Show connection quality warnings"
text: qsTr("Show connection quality warnings")
font.pointSize: 12
checked: StreamingPreferences.connectionWarnings
onCheckedChanged: {
@@ -534,7 +792,7 @@ Flickable {
visible: SystemProperties.hasDiscordIntegration
id: discordPresenceCheck
width: parent.width
text: "Discord Rich Presence integration"
text: qsTr("Discord Rich Presence integration")
font.pointSize: 12
checked: StreamingPreferences.richPresence
onCheckedChanged: {
@@ -544,7 +802,7 @@ Flickable {
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: "Updates your Discord status to display the name of the game you're streaming."
ToolTip.text: qsTr("Updates your Discord status to display the name of the game you're streaming.")
}
}
}
@@ -559,57 +817,62 @@ Flickable {
spacing: 15
GroupBox {
id: gamepadSettingsGroupBox
id: inputSettingsGroupBox
width: (parent.width - (parent.leftPadding + parent.rightPadding))
padding: 12
title: "<font color=\"skyblue\">Input Settings</font>"
title: "<font color=\"skyblue\">" + qsTr("Input Settings") + "</font>"
font.pointSize: 12
Column {
anchors.fill: parent
spacing: 5
CheckBox {
id: singleControllerCheck
width: parent.width
text: "Force gamepad #1 always present"
font.pointSize: 12
checked: !StreamingPreferences.multiController
onCheckedChanged: {
StreamingPreferences.multiController = !checked
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: "Forces a single gamepad to always stay connected to the host, even if no gamepads are actually connected to this PC.\n" +
"Only enable this option when streaming a game that doesn't support gamepads being connected after startup."
}
CheckBox {
id: absoluteMouseCheck
hoverEnabled: true
width: parent.width
text: "Optimize mouse for remote desktop instead of games"
text: qsTr("Optimize mouse for remote desktop instead of games")
font.pointSize: 12
enabled: SystemProperties.hasWindowManager
checked: StreamingPreferences.absoluteMouseMode && SystemProperties.hasWindowManager
visible: SystemProperties.hasWindowManager
checked: StreamingPreferences.absoluteMouseMode
onCheckedChanged: {
StreamingPreferences.absoluteMouseMode = checked
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.timeout: 10000
ToolTip.visible: hovered
ToolTip.text: "This enables mouse control without capturing the client's mouse cursor. It will not work in most games.\n
You can toggle this while streaming using Ctrl+Alt+Shift+M."
ToolTip.text: qsTr("This enables seamless mouse control without capturing the client's mouse cursor. It is ideal for remote desktop usage but will not work in most games.") + " " +
qsTr("You can toggle this while streaming using Ctrl+Alt+Shift+M.") + "\n\n" +
qsTr("NOTE: Due to a bug in GeForce Experience, this option may not work properly if your host PC has multiple monitors.")
}
CheckBox {
id: captureSysKeysCheck
hoverEnabled: true
width: parent.width
text: qsTr("Capture system keyboard shortcuts ") +
(!SystemProperties.isRunningWayland ? qsTr("while streaming in fullscreen") :
qsTr("(unsupported on Wayland)"))
font.pointSize: 12
enabled: SystemProperties.hasWindowManager && !SystemProperties.isRunningWayland
checked: (StreamingPreferences.captureSysKeys || !SystemProperties.hasWindowManager) && !SystemProperties.isRunningWayland
onCheckedChanged: {
StreamingPreferences.captureSysKeys = checked
}
ToolTip.delay: 1000
ToolTip.timeout: 10000
ToolTip.visible: hovered
ToolTip.text: qsTr("This enables the capture of system-wide keyboard shortcuts like Alt+Tab that would normally be handled by the client OS while streaming in fullscreen.") + "\n\n" +
qsTr("NOTE: Certain keyboard shortcuts like Ctrl+Alt+Del on Windows cannot be intercepted by any application, including Moonlight.")
}
CheckBox {
id: absoluteTouchCheck
hoverEnabled: true
width: parent.width
text: "Use touchscreen as a trackpad"
text: qsTr("Use touchscreen as a virtual trackpad")
font.pointSize: 12
checked: !StreamingPreferences.absoluteTouchMode
onCheckedChanged: {
@@ -619,41 +882,114 @@ Flickable {
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: "When checked, the touchscreen acts like a trackpad. When unchecked, the touchscreen will directly control the mouse pointer."
}
CheckBox {
id: gamepadMouseCheck
hoverEnabled: true
width: parent.width
text: "Gamepad mouse mode support"
font.pointSize: 12
checked: StreamingPreferences.gamepadMouse
onCheckedChanged: {
StreamingPreferences.gamepadMouse = checked
}
ToolTip.delay: 1000
ToolTip.timeout: 3000
ToolTip.visible: hovered
ToolTip.text: "When enabled, holding the Start button will toggle mouse mode"
ToolTip.text: qsTr("When checked, the touchscreen acts like a trackpad. When unchecked, the touchscreen will directly control the mouse pointer.")
}
CheckBox {
id: swapMouseButtonsCheck
hoverEnabled: true
width: parent.width
text: "Swap mouse buttons"
text: qsTr("Swap left and right mouse buttons")
font.pointSize: 12
checked: StreamingPreferences.swapMouseButtons
onCheckedChanged: {
StreamingPreferences.swapMouseButtons = checked
}
}
CheckBox {
id: reverseScrollButtonsCheck
hoverEnabled: true
width: parent.width
text: qsTr("Reverse mouse scrolling direction")
font.pointSize: 12
checked: StreamingPreferences.reverseScrollDirection
onCheckedChanged: {
StreamingPreferences.reverseScrollDirection = checked
}
}
}
}
GroupBox {
id: gamepadSettingsGroupBox
width: (parent.width - (parent.leftPadding + parent.rightPadding))
padding: 12
title: "<font color=\"skyblue\">" + qsTr("Gamepad Settings") + "</font>"
font.pointSize: 12
Column {
anchors.fill: parent
spacing: 5
CheckBox {
id: swapFaceButtonsCheck
width: parent.width
text: qsTr("Swap A/B and X/Y gamepad buttons")
font.pointSize: 12
checked: StreamingPreferences.swapFaceButtons
onCheckedChanged: {
// Check if the value changed (this is called on init too)
if (StreamingPreferences.swapFaceButtons !== checked) {
StreamingPreferences.swapFaceButtons = checked
// Save and restart SdlGamepadKeyNavigation so it can pull the new value
StreamingPreferences.save()
SdlGamepadKeyNavigation.disable()
SdlGamepadKeyNavigation.enable()
}
}
ToolTip.delay: 1000
ToolTip.timeout: 3000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: "When checked, swap the left and right mouse buttons"
ToolTip.text: qsTr("This switches gamepads into a Nintendo-style button layout")
}
CheckBox {
id: singleControllerCheck
width: parent.width
text: qsTr("Force gamepad #1 always connected")
font.pointSize: 12
checked: !StreamingPreferences.multiController
onCheckedChanged: {
StreamingPreferences.multiController = !checked
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("Forces a single gamepad to always stay connected to the host, even if no gamepads are actually connected to this PC.") + " " +
qsTr("Only enable this option when streaming a game that doesn't support gamepads being connected after startup.")
}
CheckBox {
id: gamepadMouseCheck
hoverEnabled: true
width: parent.width
text: qsTr("Enable mouse control with gamepads by holding the 'Start' button")
font.pointSize: 12
checked: StreamingPreferences.gamepadMouse
onCheckedChanged: {
StreamingPreferences.gamepadMouse = checked
}
}
CheckBox {
id: backgroundGamepadCheck
width: parent.width
text: qsTr("Process gamepad input when Moonlight is in the background")
font.pointSize: 12
visible: SystemProperties.hasWindowManager
checked: StreamingPreferences.backgroundGamepad
onCheckedChanged: {
StreamingPreferences.backgroundGamepad = checked
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("Allows Moonlight to capture gamepad inputs even if it's not the current window in focus")
}
}
}
@@ -662,7 +998,7 @@ Flickable {
id: hostSettingsGroupBox
width: (parent.width - (parent.leftPadding + parent.rightPadding))
padding: 12
title: "<font color=\"skyblue\">Host Settings</font>"
title: "<font color=\"skyblue\">" + qsTr("Host Settings") + "</font>"
font.pointSize: 12
Column {
@@ -672,7 +1008,7 @@ Flickable {
CheckBox {
id: optimizeGameSettingsCheck
width: parent.width
text: "Optimize game settings for streaming"
text: qsTr("Optimize game settings for streaming")
font.pointSize: 12
checked: StreamingPreferences.gameOptimizations
onCheckedChanged: {
@@ -680,21 +1016,10 @@ Flickable {
}
}
CheckBox {
id: audioPcCheck
width: parent.width
text: "Play audio on host PC"
font.pointSize: 12
checked: StreamingPreferences.playAudioOnHost
onCheckedChanged: {
StreamingPreferences.playAudioOnHost = checked
}
}
CheckBox {
id: quitAppAfter
width: parent.width
text: "Quit app on host PC after ending stream"
text: qsTr("Quit app on host PC after ending stream")
font.pointSize: 12
checked: StreamingPreferences.quitAppAfter
onCheckedChanged: {
@@ -704,7 +1029,7 @@ Flickable {
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: "This will close the app or game you are streaming when you end your stream. You will lose any unsaved progress!"
ToolTip.text: qsTr("This will close the app or game you are streaming when you end your stream. You will lose any unsaved progress!")
}
}
}
@@ -713,7 +1038,7 @@ Flickable {
id: advancedSettingsGroupBox
width: (parent.width - (parent.leftPadding + parent.rightPadding))
padding: 12
title: "<font color=\"skyblue\">Advanced Settings</font>"
title: "<font color=\"skyblue\">" + qsTr("Advanced Settings") + "</font>"
font.pointSize: 12
Column {
@@ -748,15 +1073,15 @@ Flickable {
model: ListModel {
id: decoderListModel
ListElement {
text: "Automatic (Recommended)"
text: qsTr("Automatic (Recommended)")
val: StreamingPreferences.VDS_AUTO
}
ListElement {
text: "Force software decoding"
text: qsTr("Force software decoding")
val: StreamingPreferences.VDS_FORCE_SOFTWARE
}
ListElement {
text: "Force hardware decoding"
text: qsTr("Force hardware decoding")
val: StreamingPreferences.VDS_FORCE_HARDWARE
}
}
@@ -794,19 +1119,19 @@ Flickable {
model: ListModel {
id: codecListModel
ListElement {
text: "Automatic (Recommended)"
text: qsTr("Automatic (Recommended)")
val: StreamingPreferences.VCC_AUTO
}
ListElement {
text: "H.264"
text: qsTr("H.264")
val: StreamingPreferences.VCC_FORCE_H264
}
ListElement {
text: "HEVC (H.265)"
text: qsTr("HEVC (H.265)")
val: StreamingPreferences.VCC_FORCE_HEVC
}
/*ListElement {
text: "HEVC HDR (Experimental)"
text: qsTr("HEVC HDR (Experimental)")
val: StreamingPreferences.VCC_FORCE_HEVC_HDR
}*/
}
@@ -819,7 +1144,7 @@ Flickable {
CheckBox {
id: unlockUnsupportedFps
width: parent.width
text: "Unlock unsupported FPS options"
text: qsTr("Unlock unsupported FPS options")
font.pointSize: 12
checked: StreamingPreferences.unsupportedFps
onCheckedChanged: {
@@ -838,7 +1163,7 @@ Flickable {
CheckBox {
id: enableMdns
width: parent.width
text: "Automatically find PCs on the local network (Recommended)"
text: qsTr("Automatically find PCs on the local network (Recommended)")
font.pointSize: 12
checked: StreamingPreferences.enableMdns
onCheckedChanged: {
@@ -863,7 +1188,7 @@ Flickable {
CheckBox {
id: detectNetworkBlocking
width: parent.width
text: "Automatically detect blocked connections (Recommended)"
text: qsTr("Automatically detect blocked connections (Recommended)")
font.pointSize: 12
checked: StreamingPreferences.detectNetworkBlocking
onCheckedChanged: {
+23 -8
View File
@@ -8,19 +8,25 @@ import Session 1.0
Item {
property Session session
property string appName
property string stageText : "Starting " + appName + "..."
property string stageText : isResume ? qsTr("Resuming %1...").arg(appName) :
qsTr("Starting %1...").arg(appName)
property bool isResume : false
property bool quitAfter : false
function stageStarting(stage)
{
// Update the spinner text
stageText = "Starting " + stage + "..."
stageText = qsTr("Starting %1...").arg(stage)
}
function stageFailed(stage, errorCode)
function stageFailed(stage, errorCode, failingPorts)
{
// Display the error dialog after Session::exec() returns
streamSegueErrorDialog.text = "Starting " + stage + " failed: Error " + errorCode
streamSegueErrorDialog.text = qsTr("Starting %1 failed: Error %2").arg(stage).arg(errorCode)
if (failingPorts) {
streamSegueErrorDialog.text += "\n\n" + qsTr("Check your firewall and port forwarding rules for port(s): %1").arg(failingPorts)
}
}
function connectionStarted()
@@ -65,7 +71,7 @@ Item {
function sessionFinished(portTestResult)
{
if (portTestResult !== 0 && portTestResult !== -1 && streamSegueErrorDialog.text) {
streamSegueErrorDialog.text += "\n\nThis PC's Internet connection is blocking Moonlight. Streaming over the Internet may not work while connected to this network."
streamSegueErrorDialog.text += "\n\n" + qsTr("This PC's Internet connection is blocking Moonlight. Streaming over the Internet may not work while connected to this network.")
}
// Enable GUI gamepad usage now
@@ -97,6 +103,11 @@ Item {
streamSegueErrorDialog.open()
}
}
// Garbage collect the Session object since it's pretty heavyweight
// and keeps other libraries (like SDL_TTF) around until it is deleted.
session = null
gc()
}
StackView.onDeactivating: {
@@ -147,13 +158,17 @@ Item {
// in the hintText control itself to synchronize
// with Session.exec() which requires no concurrent
// gamepad usage.
hintText.text = SdlGamepadKeyNavigation.getConnectedGamepads() > 0 ?
"Tip: Press Start+Select+L1+R1 to disconnect your session" :
"Tip: Press Ctrl+Alt+Shift+Q to disconnect your session"
hintText.text = qsTr("Tip:") + " " + qsTr("Press %1 to disconnect your session").arg(SdlGamepadKeyNavigation.getConnectedGamepads() > 0 ?
qsTr("Start+Select+L1+R1") : qsTr("Ctrl+Alt+Shift+Q"))
// Stop GUI gamepad usage now
SdlGamepadKeyNavigation.disable()
// Garbage collect QML stuff before we start streaming,
// since we'll probably be streaming for a while and we
// won't be able to GC during the stream.
gc()
// Run the streaming session to completion
session.exec(Screen.virtualX, Screen.virtualY)
}
+40
View File
@@ -47,6 +47,17 @@ Session* AppModel::createSessionForApp(int appIndex)
return new Session(m_Computer, app);
}
int AppModel::getDirectLaunchAppIndex()
{
for (int i = 0; i < m_VisibleApps.count(); i++) {
if (m_VisibleApps[i].directLaunch) {
return i;
}
}
return -1;
}
int AppModel::rowCount(const QModelIndex &parent) const
{
// For list models only the root node (an invalid parent) should return the list's size. For all
@@ -78,6 +89,8 @@ QVariant AppModel::data(const QModelIndex &index, int role) const
return app.hidden;
case AppIdRole:
return app.id;
case DirectLaunchRole:
return app.directLaunch;
default:
return QVariant();
}
@@ -92,6 +105,7 @@ QHash<int, QByteArray> AppModel::roleNames() const
names[BoxArtRole] = "boxart";
names[HiddenRole] = "hidden";
names[AppIdRole] = "appid";
names[DirectLaunchRole] = "directLaunch";
return names;
}
@@ -207,6 +221,32 @@ void AppModel::setAppHidden(int appIndex, bool hidden)
m_ComputerManager->clientSideAttributeUpdated(m_Computer);
}
void AppModel::setAppDirectLaunch(int appIndex, bool directLaunch)
{
Q_ASSERT(appIndex < m_VisibleApps.count());
int appId = m_VisibleApps.at(appIndex).id;
{
QWriteLocker lock(&m_Computer->lock);
for (NvApp& app : m_Computer->appList) {
if (directLaunch) {
// We must clear direct launch from all other apps
// to set it on the new app.
app.directLaunch = app.id == appId;
}
else if (app.id == appId) {
// If we're clearing direct launch, we're done once we
// find our matching app ID.
app.directLaunch = false;
break;
}
}
}
m_ComputerManager->clientSideAttributeUpdated(m_Computer);
}
void AppModel::handleComputerStateChanged(NvComputer* computer)
{
// Ignore updates for computers that aren't ours
+5
View File
@@ -17,6 +17,7 @@ class AppModel : public QAbstractListModel
BoxArtRole,
HiddenRole,
AppIdRole,
DirectLaunchRole
};
public:
@@ -27,6 +28,8 @@ public:
Q_INVOKABLE Session* createSessionForApp(int appIndex);
Q_INVOKABLE int getDirectLaunchAppIndex();
Q_INVOKABLE int getRunningAppId();
Q_INVOKABLE QString getRunningAppName();
@@ -35,6 +38,8 @@ public:
Q_INVOKABLE void setAppHidden(int appIndex, bool hidden);
Q_INVOKABLE void setAppDirectLaunch(int appIndex, bool directLaunch);
QVariant data(const QModelIndex &index, int role) const override;
int rowCount(const QModelIndex &parent) const override;
+3 -20
View File
@@ -158,26 +158,9 @@ public:
emit connectionTestCompleted(-1, QString());
}
else {
QString blockedPorts;
for (int i = 0; i < 32; i++) {
if (portTestResult & (1 << i)) {
if (!blockedPorts.isEmpty()) {
blockedPorts += "\n";
}
if (LiGetProtocolFromPortFlagIndex(i) == 17 /* IPPROTO_UDP */) {
blockedPorts += "UDP ";
}
else {
blockedPorts += "TCP ";
}
blockedPorts += QString::number(LiGetPortFromPortFlagIndex(i));
}
}
emit connectionTestCompleted(portTestResult, blockedPorts);
char blockedPorts[512];
LiStringifyPortFlags(portTestResult, "\n", blockedPorts, sizeof(blockedPorts));
emit connectionTestCompleted(portTestResult, QString(blockedPorts));
}
}
+37 -25
View File
@@ -17,7 +17,19 @@ ApplicationWindow {
width: 1280
height: 600
visibility: (SystemProperties.hasWindowManager && StreamingPreferences.startWindowed) ? "Windowed" : "Maximized"
visibility: {
if (SystemProperties.hasWindowManager) {
if (StreamingPreferences.uiDisplayMode == StreamingPreferences.UI_WINDOWED) return "Windowed"
else if (StreamingPreferences.uiDisplayMode == StreamingPreferences.UI_MAXIMIZED) return "Maximized"
else if (StreamingPreferences.uiDisplayMode == StreamingPreferences.UI_FULLSCREEN) return "FullScreen"
} else {
return "FullScreen"
}
}
// This configures the maximum width of the singleton attached QML ToolTip. If left unconstrained,
// it will never insert a line break and just extend on forever.
ToolTip.toolTip.contentWidth: ToolTip.toolTip.implicitContentWidth < 400 ? ToolTip.toolTip.implicitContentWidth : 400
StackView {
id: stackView
@@ -223,8 +235,8 @@ ApplicationWindow {
Label {
id: versionLabel
visible: stackView.currentItem.objectName === "Settings"
text: "Version " + SystemProperties.versionString
visible: stackView.currentItem.objectName === qsTr("Settings")
text: qsTr("Version %1").arg(SystemProperties.versionString)
font.pointSize: 12
horizontalAlignment: Qt.AlignRight
verticalAlignment: Qt.AlignVCenter
@@ -233,14 +245,14 @@ ApplicationWindow {
NavigableToolButton {
id: discordButton
visible: SystemProperties.hasBrowser &&
stackView.currentItem.objectName === "Settings"
stackView.currentItem.objectName === qsTr("Settings")
iconSource: "qrc:/res/Discord-Logo-White.svg"
ToolTip.delay: 1000
ToolTip.timeout: 3000
ToolTip.visible: hovered
ToolTip.text: "Join our community on Discord"
ToolTip.text: qsTr("Join our community on Discord")
// TODO need to make sure browser is brought to foreground.
onClicked: Qt.openUrlExternally("https://moonlight-stream.org/discord");
@@ -252,14 +264,14 @@ ApplicationWindow {
NavigableToolButton {
id: addPcButton
visible: stackView.currentItem.objectName === "Computers"
visible: stackView.currentItem.objectName === qsTr("Computers")
iconSource: "qrc:/res/ic_add_to_queue_white_48px.svg"
ToolTip.delay: 1000
ToolTip.timeout: 3000
ToolTip.visible: hovered
ToolTip.text: "Add PC manually" + (newPcShortcut.nativeText ? (" ("+newPcShortcut.nativeText+")") : "")
ToolTip.text: qsTr("Add PC manually") + (newPcShortcut.nativeText ? (" ("+newPcShortcut.nativeText+")") : "")
Shortcut {
id: newPcShortcut
@@ -299,7 +311,7 @@ ApplicationWindow {
function updateAvailable(version, url)
{
ToolTip.text = "Update available for Moonlight: Version " + version
ToolTip.text = qsTr("Update available for Moonlight: Version %1").arg(version)
updateButton.browserUrl = url
updateButton.visible = true
}
@@ -323,7 +335,7 @@ ApplicationWindow {
ToolTip.delay: 1000
ToolTip.timeout: 3000
ToolTip.visible: hovered
ToolTip.text: "Help" + (helpShortcut.nativeText ? (" ("+helpShortcut.nativeText+")") : "")
ToolTip.text: qsTr("Help") + (helpShortcut.nativeText ? (" ("+helpShortcut.nativeText+")") : "")
Shortcut {
id: helpShortcut
@@ -346,11 +358,11 @@ ApplicationWindow {
ToolTip.delay: 1000
ToolTip.timeout: 3000
ToolTip.visible: hovered
ToolTip.text: "Gamepad Mapper"
ToolTip.text: qsTr("Gamepad Mapper")
iconSource: "qrc:/res/ic_videogame_asset_white_48px.svg"
onClicked: navigateTo("qrc:/gui/GamepadMapper.qml", "Gamepad Mapping")
onClicked: navigateTo("qrc:/gui/GamepadMapper.qml", qsTr("Gamepad Mapping"))
Keys.onDownPressed: {
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
@@ -362,7 +374,7 @@ ApplicationWindow {
iconSource: "qrc:/res/settings.svg"
onClicked: navigateTo("qrc:/gui/SettingsView.qml", "Settings")
onClicked: navigateTo("qrc:/gui/SettingsView.qml", qsTr("Settings"))
Keys.onDownPressed: {
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
@@ -377,31 +389,31 @@ ApplicationWindow {
ToolTip.delay: 1000
ToolTip.timeout: 3000
ToolTip.visible: hovered
ToolTip.text: "Settings" + (settingsShortcut.nativeText ? (" ("+settingsShortcut.nativeText+")") : "")
ToolTip.text: qsTr("Settings") + (settingsShortcut.nativeText ? (" ("+settingsShortcut.nativeText+")") : "")
}
}
}
ErrorMessageDialog {
id: noHwDecoderDialog
text: "No functioning hardware accelerated H.264 video decoder was detected by Moonlight. " +
"Your streaming performance may be severely degraded in this configuration."
helpText: "Click the Help button for more information on solving this problem."
text: qsTr("No functioning hardware accelerated H.264 video decoder was detected by Moonlight. " +
"Your streaming performance may be severely degraded in this configuration.")
helpText: qsTr("Click the Help button for more information on solving this problem.")
helpUrl: "https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems"
}
ErrorMessageDialog {
id: xWaylandDialog
text: "Hardware acceleration doesn't work on XWayland. Continuing on XWayland may result in poor streaming performance. " +
"Try running with QT_QPA_PLATFORM=wayland or switch to X11."
helpText: "Click the Help button for more information."
text: qsTr("Hardware acceleration doesn't work on XWayland. Continuing on XWayland may result in poor streaming performance. " +
"Try running with QT_QPA_PLATFORM=wayland or switch to X11.")
helpText: qsTr("Click the Help button for more information.")
helpUrl: "https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems"
}
NavigableMessageDialog {
id: wow64Dialog
standardButtons: Dialog.Ok | Dialog.Cancel
text: "This PC is running a 64-bit version of Windows. Please download the x64 version of Moonlight for the best streaming performance."
text: qsTr("This version of Moonlight isn't optimized for your PC. Please download the '%1' version of Moonlight for the best streaming performance.").arg(SystemProperties.friendlyNativeArchName)
onAccepted: {
Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-qt/releases");
}
@@ -410,9 +422,9 @@ ApplicationWindow {
ErrorMessageDialog {
id: unmappedGamepadDialog
property string unmappedGamepads : ""
text: "Moonlight detected gamepads without a mapping:\n" + unmappedGamepads
text: qsTr("Moonlight detected gamepads without a mapping:") + "\n" + unmappedGamepads
helpTextSeparator: "\n\n"
helpText: "Click the Help button for information on how to map your gamepads."
helpText: qsTr("Click the Help button for information on how to map your gamepads.")
helpUrl: "https://github.com/moonlight-stream/moonlight-docs/wiki/Gamepad-Mapping"
}
@@ -420,7 +432,7 @@ ApplicationWindow {
NavigableMessageDialog {
id: quitConfirmationDialog
standardButtons: Dialog.Yes | Dialog.No
text: "Are you sure you want to quit?"
text: qsTr("Are you sure you want to quit?")
// For keyboard/gamepad navigation
onAccepted: Qt.quit()
}
@@ -450,7 +462,7 @@ ApplicationWindow {
NavigableDialog {
id: addPcDialog
property string label: "Enter the IP address of your GameStream PC:"
property string label: qsTr("Enter the IP address of your GameStream PC:")
standardButtons: Dialog.Ok | Dialog.Cancel
@@ -465,7 +477,7 @@ ApplicationWindow {
onAccepted: {
if (editText.text) {
ComputerManager.addNewHost(editText.text, false)
ComputerManager.addNewHost(editText.text.trim(), false)
}
}
+20
View File
@@ -4,6 +4,7 @@
#include <QGuiApplication>
#include <QWindow>
#include "settings/streamingpreferences.h"
#include "settings/mappingmanager.h"
#define AXIS_NAVIGATION_REPEAT_DELAY 150
@@ -88,6 +89,7 @@ void SdlGamepadKeyNavigation::disable()
void SdlGamepadKeyNavigation::onPollingTimerFired()
{
SDL_Event event;
StreamingPreferences prefs;
while (SDL_PollEvent(&event)) {
switch (event.type) {
@@ -104,6 +106,24 @@ void SdlGamepadKeyNavigation::onPollingTimerFired()
event.type == SDL_CONTROLLERBUTTONDOWN ?
QEvent::Type::KeyPress : QEvent::Type::KeyRelease;
// Swap face buttons if needed
if (prefs.swapFaceButtons) {
switch (event.cbutton.button) {
case SDL_CONTROLLER_BUTTON_A:
event.cbutton.button = SDL_CONTROLLER_BUTTON_B;
break;
case SDL_CONTROLLER_BUTTON_B:
event.cbutton.button = SDL_CONTROLLER_BUTTON_A;
break;
case SDL_CONTROLLER_BUTTON_X:
event.cbutton.button = SDL_CONTROLLER_BUTTON_Y;
break;
case SDL_CONTROLLER_BUTTON_Y:
event.cbutton.button = SDL_CONTROLLER_BUTTON_X;
break;
}
}
switch (event.cbutton.button) {
case SDL_CONTROLLER_BUTTON_DPAD_UP:
if (m_UiNavMode) {
Binary file not shown.
+824
View File
@@ -0,0 +1,824 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="fr_FR">
<context>
<name>AppView</name>
<message>
<location filename="../gui/AppView.qml" line="118"/>
<location filename="../gui/AppView.qml" line="242"/>
<source>Resume Game</source>
<translation>Reprendre le jeu</translation>
</message>
<message>
<location filename="../gui/AppView.qml" line="146"/>
<location filename="../gui/AppView.qml" line="247"/>
<source>Quit Game</source>
<translation>Quitter le jeu</translation>
</message>
<message>
<location filename="../gui/AppView.qml" line="242"/>
<source>Launch Game</source>
<translation>Lancer le jeu</translation>
</message>
<message>
<location filename="../gui/AppView.qml" line="255"/>
<source>Hide Game</source>
<translation>Cacher le jeu</translation>
</message>
<message>
<location filename="../gui/AppView.qml" line="268"/>
<source>Are you sure you want to quit %1? Any unsaved progress will be lost.</source>
<translation>Vous êtes sûr de vouloir arrêter %1? Tout progrès non enregistré sera perdu.</translation>
</message>
</context>
<context>
<name>CliQuitStreamSegue</name>
<message>
<location filename="../gui/CliQuitStreamSegue.qml" line="9"/>
<source>Establishing connection to PC...</source>
<translation>connexion au PC...</translation>
</message>
<message>
<location filename="../gui/CliQuitStreamSegue.qml" line="13"/>
<source>Quitting app...</source>
<translation>Fermeture de l&apos;app...</translation>
</message>
</context>
<context>
<name>CliStartStreamSegue</name>
<message>
<location filename="../gui/CliStartStreamSegue.qml" line="9"/>
<source>Establishing connection to PC...</source>
<translation>connexion au PC...</translation>
</message>
<message>
<location filename="../gui/CliStartStreamSegue.qml" line="13"/>
<source>Loading app list...</source>
<translation>Chargement de la liste des applications...</translation>
</message>
<message>
<location filename="../gui/CliStartStreamSegue.qml" line="81"/>
<source>Are you sure you want to quit %1? Any unsaved progress will be lost.</source>
<translation>Vous êtes sûr de vouloir arrêter %1? Tout progrès non enregistré sera perdu.</translation>
</message>
</context>
<context>
<name>GamepadMapper</name>
<message>
<location filename="../gui/GamepadMapper.qml" line="4"/>
<source>Gamepad Mapping</source>
<translation>Configuration du controleur</translation>
</message>
</context>
<context>
<name>NvHTTP</name>
<message>
<location filename="../backend/nvhttp.cpp" line="326"/>
<source>Missing audio capture device. Reinstalling GeForce Experience should resolve this error.</source>
<translation>Dispositif de capture audio manquant. La réinstallation de GeForce Experience devrait résoudre cette erreur.</translation>
</message>
</context>
<context>
<name>PcView</name>
<message>
<location filename="../gui/PcView.qml" line="20"/>
<source>Computers</source>
<translation>Ordinateurs</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="67"/>
<source>Unable to connect to the specified PC.</source>
<translation>Impossible de se connecter au PC spécifié.</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="70"/>
<source>This PC&apos;s Internet connection is blocking Moonlight. Streaming over the Internet may not work while connected to this network.</source>
<translation>La connexion Internet de ce PC bloque Moonlight. Le streaming sur Internet peut ne pas fonctionner lorsqu&apos;il est connecté à ce réseau.</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="73"/>
<source>Click the Help button for possible solutions.</source>
<translation>Cliquez sur le bouton Aide pour connaître les solutions possibles.</translation>
</message>
<message>
<source>Searching for PCs with NVIDIA GameStream enabled...</source>
<translation type="vanished">La recherche de PC avec NVIDIA GameStream activé...</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="103"/>
<source>Automatic PC discovery is disabled. Add your PC manually.</source>
<translation>La découverte automatique des PC est désactivée. Ajoutez votre PC manuellement.</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="167"/>
<source>View Apps</source>
<translation>Voir les applications</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="177"/>
<source>View Hidden Apps</source>
<translation>Voir les applications cachées</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="187"/>
<source>Wake PC</source>
<translation>Réveiller le PC</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="193"/>
<source>Test Network</source>
<translation>Test Réseau</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="202"/>
<source>Rename PC</source>
<translation>Renommer le PC</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="211"/>
<source>Delete PC</source>
<translation>Supprimer le PC</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="241"/>
<source>You cannot pair while a previous session is still running on the host PC. Quit any running games or reboot the host PC, then try pairing again.</source>
<translation>Vous ne pouvez pas effectuer de couplage alors qu&apos;une session précédente est encore en cours sur le PC hôte. Fermez les jeux en cours ou redémarrez le PC hôte, puis essayez à nouveau d&apos;effectuer l&apos;appariement.</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="296"/>
<source>Please enter %1 on your GameStream PC. This dialog will close when pairing is completed.</source>
<translation>Veuillez saisir %1 sur votre PC GameStream. Cette boîte de dialogue se fermera lorsque l&apos;appariement sera terminé.</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="307"/>
<source>Are you sure you want to remove this PC?</source>
<translation>Êtes-vous sûr de vouloir supprimer ce PC ?</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="324"/>
<source>Moonlight is testing your network connection to determine if NVIDIA GameStream is blocked.</source>
<translation>Moonlight teste votre connexion réseau pour déterminer si NVIDIA GameStream est bloqué.</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="324"/>
<source>This may take a few seconds…</source>
<translation>Cela peut prendre quelques secondes...</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="335"/>
<source>This network does not appear to be blocking Moonlight. If you still have trouble connecting, check your PC&apos;s firewall settings.</source>
<translation>Ce réseau ne semble pas bloquer Moonlight. Si vous avez toujours des problèmes de connexion, vérifiez les paramètres du pare-feu de votre PC.</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="335"/>
<source>If you are trying to stream over the Internet, install the Moonlight Internet Hosting Tool on your gaming PC and run the included Internet Streaming Tester to check your gaming PC&apos;s Internet connection.</source>
<translation>Si vous essayez d&apos;utiliser la diffusion en continu sur Internet, installez l&apos;outil d&apos;hébergement Internet Moonlight sur votre PC de jeu et exécutez le testeur de diffusion en continu sur Internet inclus pour vérifier la connexion Internet de votre PC de jeu.</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="339"/>
<source>Your PC&apos;s current network connection seems to be blocking Moonlight. Streaming over the Internet may not work while connected to this network.</source>
<translation>La connexion réseau actuelle de votre PC semble bloquer le Moonlight. Il se peut que la diffusion en continu sur Internet ne fonctionne pas lorsque vous êtes connecté à ce réseau.</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="339"/>
<source>The following network ports were blocked:</source>
<translation>Les ports de réseau suivants ont été bloqués :</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="331"/>
<source>The network test could not be performed because none of Moonlight&apos;s connection testing servers were reachable from this PC. Check your Internet connection or try again later.</source>
<translation>Le test de réseau n&apos;a pas pu être effectué car aucun des serveurs de test de connexion de Moonlight n&apos;était accessible depuis ce PC. Vérifiez votre connexion Internet ou réessayez plus tard.</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="102"/>
<source>Searching for PCs on your local network with NVIDIA GameStream enabled...</source>
<translation>Recherche de PC sur votre réseau local avec NVIDIA GameStream activé...</translation>
</message>
<message>
<location filename="../gui/PcView.qml" line="351"/>
<source>Enter the new name for this PC:</source>
<translation>Saisissez le nouveau nom de ce PC :</translation>
</message>
</context>
<context>
<name>PendingQuitTask</name>
<message>
<location filename="../backend/computermanager.cpp" line="539"/>
<source>The running game wasn&apos;t started by this PC. You must quit the game on the host PC manually or use the device that originally started the game.</source>
<translation>Le jeu en cours d’exécution n&apos;a pas été démarré par ce PC. Vous devez fermer le jeu sur le PC hôte manuellement ou utiliser l&apos;appareil qui a démarré le jeu à l&apos;origine.</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../cli/quitstream.cpp" line="76"/>
<location filename="../cli/startstream.cpp" line="133"/>
<source>Failed to connect to %1</source>
<translation>N&apos;a pas pu se connecter à %1</translation>
</message>
<message>
<location filename="../cli/quitstream.cpp" line="88"/>
<location filename="../cli/startstream.cpp" line="89"/>
<source>Computer %1 has not been paired. Please open Moonlight to pair before streaming.</source>
<translation>Le %1 de l&apos;ordinateur n&apos;a pas été jumelé. Veuillez ouvrir Moonlight pour jumeler avant le streaming.</translation>
</message>
<message>
<location filename="../cli/quitstream.cpp" line="102"/>
<location filename="../cli/startstream.cpp" line="126"/>
<source>Quitting app failed, reason: %1</source>
<translation>La fermeture de l&apos;application a échoué, raison : %1</translation>
</message>
<message>
<location filename="../cli/startstream.cpp" line="137"/>
<source>Failed to find application %1</source>
<translation>N&apos;a pas trouvé l&apos;application %1</translation>
</message>
</context>
<context>
<name>QuitSegue</name>
<message>
<location filename="../gui/QuitSegue.qml" line="12"/>
<source>Quitting %1...</source>
<translation>Fermeture %1...</translation>
</message>
</context>
<context>
<name>Session</name>
<message>
<location filename="../streaming/session.cpp" line="97"/>
<source>No video received from host. Check the host PC&apos;s firewall and port forwarding rules.</source>
<translation>Aucune vidéo reçue de l&apos;hôte. Vérifiez le pare-feu et les règles de transfert de port du PC hôte.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="102"/>
<source>Your network connection isn&apos;t performing well. Reduce your video bitrate setting or try a faster connection.</source>
<translation>Votre connexion réseau ne fonctionne pas bien. Réduisez votre débit vidéo ou essayez une connexion plus rapide.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="107"/>
<source>Connection terminated</source>
<translation>Connexion terminée</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="567"/>
<source>Your selection to enable remote desktop mouse mode may cause problems in games.</source>
<translation>Votre sélection pour activer le mode de souris de bureau à distance peut causer des problèmes dans les jeux.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="572"/>
<source>HDR is not supported with software decoding.</source>
<translation>Le HDR n&apos;est pas pris en charge par le décodage logiciel.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="576"/>
<source>Your settings selection to force software decoding may cause poor streaming performance.</source>
<translation>La sélection de vos paramètres pour forcer le décodage du logiciel peut entraîner de mauvaises performances de streaming.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="581"/>
<source>Using unsupported FPS options may cause stuttering or lag.</source>
<translation>L&apos;utilisation d&apos;options de FPS non prises en charge peut entraîner un stuttering ou des lag.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="584"/>
<source>V-sync will be disabled when streaming at a higher frame rate than the display.</source>
<translation>La synchronisation vertical sera désactivée lors de la diffusion en continu à une fréquence d&apos;images supérieure à celle de l&apos;affichage.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="601"/>
<source>Using software decoding due to your selection to force HEVC without GPU support. This may cause poor streaming performance.</source>
<translation>Utilisation du décodage logiciel dû à votre sélection pour forcer les HEVC sans support GPU. Cela peut entraîner de mauvaises performances de streaming.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="604"/>
<source>This PC&apos;s GPU doesn&apos;t support HEVC decoding.</source>
<translation>Le GPU de ce PC ne prend pas en charge le décodage HEVC.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="611"/>
<source>Your host PC GPU doesn&apos;t support HEVC. A GeForce GTX 900-series (Maxwell) or later GPU is required for HEVC streaming.</source>
<translation>Le GPU de votre PC hôte ne prend pas en charge les HEVC. Un GPU GeForce GTX série 900 (Maxwell) ou plus récent est nécessaire pour le streaming HEVC.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="628"/>
<source>%1 doesn&apos;t support HDR10.</source>
<translation>%1 ne prend pas en charge le HDR10.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="632"/>
<source>Your host PC GPU doesn&apos;t support HDR streaming. A GeForce GTX 1000-series (Pascal) or later GPU is required for HDR streaming.</source>
<translation>Le GPU de votre PC hôte ne prend pas en charge le streaming HDR. Un GPU GeForce GTX série 1000 (Pascal) ou plus récent est nécessaire pour la diffusion HDR.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="641"/>
<source>This PC&apos;s GPU doesn&apos;t support HEVC Main10 decoding for HDR streaming.</source>
<translation>Le GPU de ce PC ne prend pas en charge le décodage HEVC pour le streaming HDR.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="654"/>
<source>GeForce Experience 3.0 or higher is required for 4K streaming.</source>
<translation>Une expérience GeForce 3.0 ou supérieure est requise pour le streaming 4K.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="669"/>
<source>Your selected surround sound setting is not supported by the current audio device.</source>
<translation>Le réglage du son surround que vous avez sélectionné n&apos;est pas pris en charge par l&apos;appareil audio actuel.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="676"/>
<source>Failed to open audio device. Audio will be unavailable during this session.</source>
<translation>Echec de l&apos;ouverture de l&apos;appareil audio. L&apos;audio ne sera pas disponible pendant cette session.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="681"/>
<source>An attached gamepad has no mapping and won&apos;t be usable. Visit the Moonlight help to resolve this.</source>
<translation>Une manette de jeun n&apos;a pas était configurée et ne sera pas utilisable. Visitez le Moonlight pour aider à résoudre ce problème.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="687"/>
<source>Your host PC&apos;s GPU doesn&apos;t support streaming video resolutions over 4K.</source>
<translation>Le GPU de votre PC hôte ne prend pas en charge les résolutions vidéo en continu supérieures à 4K.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="691"/>
<source>Video resolutions over 4K are only supported by the HEVC codec.</source>
<translation>Les résolutions vidéo supérieures à 4K sont uniquement prises en charge par le codec HEVC.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="705"/>
<source>Your selection to force hardware decoding cannot be satisfied due to missing hardware decoding support on this PC&apos;s GPU.</source>
<translation>Votre choix pour forcer le décodage matériel ne peut être satisfait en raison de l&apos;absence de support de décodage matériel sur le GPU de ce PC.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="708"/>
<source>Your codec selection and force hardware decoding setting are not compatible. This PC&apos;s GPU lacks support for decoding your chosen codec.</source>
<translation>Votre sélection de codecs et le réglage du décodage matériel ne sont pas compatibles. Le GPU de ce PC ne prend pas en charge le décodage du codec que vous avez choisi.</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="1016"/>
<source>GeForce Experience returned error: %1</source>
<translation>GeForce Experience a renvoyé l&apos;erreur : %1</translation>
</message>
<message>
<location filename="../streaming/session.cpp" line="1397"/>
<source>Unable to initialize video decoder. Please check your streaming settings and try again.</source>
<translation>Impossible d&apos;initialiser le décodeur vidéo. Veuillez vérifier vos paramètres de diffusion en continu et réessayer.</translation>
</message>
</context>
<context>
<name>SettingsView</name>
<message>
<location filename="../gui/SettingsView.qml" line="11"/>
<source>Settings</source>
<translation>Paramètres</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="63"/>
<source>Resolution and FPS</source>
<translation>Résolution et FPS</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="71"/>
<source>Setting values too high for your PC or network connection may cause lag, stuttering, or errors.</source>
<translation>Le fait de fixer des valeurs trop élevées pour votre PC ou votre connexion réseau peut entraîner un décalage, des bégaiements ou des erreurs.</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="53"/>
<source>Basic Settings</source>
<translation>Paramètres de base</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="173"/>
<source>720p</source>
<translation>720p</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="178"/>
<source>1080p</source>
<translation>1080p</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="183"/>
<source>1440p</source>
<translation>1440p</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="188"/>
<source>4K</source>
<translation>4K</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="218"/>
<location filename="../gui/SettingsView.qml" line="219"/>
<location filename="../gui/SettingsView.qml" line="239"/>
<location filename="../gui/SettingsView.qml" line="242"/>
<source>%1 FPS</source>
<translation>%1 FPS</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="224"/>
<location filename="../gui/SettingsView.qml" line="227"/>
<location filename="../gui/SettingsView.qml" line="236"/>
<location filename="../gui/SettingsView.qml" line="249"/>
<location filename="../gui/SettingsView.qml" line="252"/>
<source>%1 FPS (Unsupported)</source>
<translation>%1 FPS (Non supporté)</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="305"/>
<source>Video bitrate:</source>
<translation>Bitrate vidéo :</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="313"/>
<source>Lower the bitrate on slower connections. Raise the bitrate to increase image quality.</source>
<translation>Baissez le débit binaire sur les connexions plus lentes. Augmentez le débit binaire pour améliorer la qualité de l&apos;image.</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="331"/>
<source>Video bitrate: %1 Mbps</source>
<translation>Bitrate vidéo : %1 Mbps</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="339"/>
<source>Display mode</source>
<translation>Mode d&apos;affichage</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="351"/>
<source> (Recommended)</source>
<translation> (Recommandé)</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="380"/>
<source>Full-screen</source>
<translation>Plein écran</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="384"/>
<source>Borderless windowed</source>
<translation>fenêtré sans bordure</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="388"/>
<source>Windowed</source>
<translation>Fenêtré</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="399"/>
<source>Full-screen generally provides the best performance, but borderless windowed may work better with features like macOS Spaces, Alt+Tab, screenshot tools, on-screen overlays, etc.</source>
<translation>Le plein écran offre généralement les meilleures performances, mais les fenêtres sans bordure peuvent fonctionner mieux avec des fonctionnalités telles que MacOS Spaces, Alt+Tab, les outils de capture d&apos;écran, les superpositions à l&apos;écran, etc.</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="406"/>
<source>V-Sync</source>
<translation>synchronisation verticale</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="416"/>
<source>Disabling V-Sync allows sub-frame rendering latency, but it can display visible tearing</source>
<translation>La désactivation de V-Sync permet une latence de rendu des sous-images plus faible, mais elle peut afficher des déchirures visibles</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="423"/>
<source>Frame pacing</source>
<translation>Frame pacing</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="433"/>
<source>Frame pacing reduces micro-stutter by delaying frames that come in too early</source>
<translation>Frame pacing réduit les micro-bégaiements en retardant les images qui arrivent trop tôt</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="443"/>
<source>Audio Settings</source>
<translation>Réglages audio</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="478"/>
<source>Stereo</source>
<translation>Stereo</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="482"/>
<source>5.1 surround sound</source>
<translation>5.1 son surround</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="486"/>
<source>7.1 surround sound</source>
<translation>7.1 son surround</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="503"/>
<source>UI Settings</source>
<translation>Réglages de l&apos;interface utilisateur</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="565"/>
<source>Input Settings</source>
<translation>Paramètres d&apos;entrée</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="585"/>
<source>Forces a single gamepad to always stay connected to the host, even if no gamepads are actually connected to this PC.</source>
<translation>Forces a single gamepad to always stay connected to the host, even if no gamepads are actually connected to this PC.</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="604"/>
<source>This enables mouse control without capturing the client&apos;s mouse cursor. It will not work in most games.</source>
<translation>Cela permet de contrôler la souris sans avoir à capturer le curseur du client. Cela ne fonctionne pas dans la plupart des jeux.</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="605"/>
<source>You can toggle this while streaming using Ctrl+Alt+Shift+M.</source>
<translation>Vous pouvez le basculer pendant la diffusion en utilisant Ctrl+Alt+Shift+M.</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="665"/>
<source>Host Settings</source>
<translation>Paramètres de l&apos;hôte</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="716"/>
<source>Advanced Settings</source>
<translation>Paramètres avancés</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="453"/>
<source>Audio configuration</source>
<translation>Configuration audio</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="513"/>
<source>Maximize Moonlight window on startup</source>
<translation>Maximiser la fenêtre Moonlight au démarrage</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="525"/>
<source>Show connection quality warnings</source>
<translation>Afficher les avertissements sur la qualité de la connexion</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="537"/>
<source>Discord Rich Presence integration</source>
<translation>Intégration de la présence Discord Rich</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="547"/>
<source>Updates your Discord status to display the name of the game you&apos;re streaming.</source>
<translation>Met à jour votre statut Discord pour afficher le nom du jeu que vous diffusez en continu.</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="575"/>
<source>Force gamepad #1 always present</source>
<translation>Forcé la manette de jeu Force #1 à être toujours présente</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="586"/>
<source>Only enable this option when streaming a game that doesn&apos;t support gamepads being connected after startup.</source>
<translation>N&apos;activez cette option que lorsque vous diffusez en continu un jeu qui ne prend pas en charge la connexion des manettes de jeu après le démarrage.</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="593"/>
<source>Optimize mouse for remote desktop instead of games</source>
<translation>Optimiser la souris pour le bureau à distance plutôt que pour les jeux</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="612"/>
<source>Use touchscreen as a trackpad</source>
<translation>Utiliser l&apos;écran tactile comme trackpad</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="622"/>
<source>When checked, the touchscreen acts like a trackpad. When unchecked, the touchscreen will directly control the mouse pointer.</source>
<translation>Lorsqu&apos;on le vérifie, l&apos;écran tactile agit comme un pavé tactile. Lorsqu&apos;il n&apos;est pas coché, l&apos;écran tactile contrôle directement le pointeur de la souris.</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="629"/>
<source>Gamepad mouse mode support</source>
<translation>Prise en charge du mode souris de la manette de jeu</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="639"/>
<source>When enabled, holding the Start button will toggle mouse mode</source>
<translation>Lorsqu&apos;il est activé, le maintien du bouton &quot;Start&quot; permet de passer en mode souris</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="646"/>
<source>Swap mouse buttons</source>
<translation>Échanger les boutons de la souris</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="656"/>
<source>When checked, swap the left and right mouse buttons</source>
<translation>Lorsque la case est cochée, permuter les boutons gauche et droit de la souris</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="675"/>
<source>Optimize game settings for streaming</source>
<translation>Optimiser les paramètres du jeu pour la diffusion en continu</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="686"/>
<source>Play audio on host PC</source>
<translation>Lecture audio sur le PC hôte</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="697"/>
<source>Quit app on host PC after ending stream</source>
<translation>Quitter l&apos;application sur le PC hôte après avoir terminé le flux</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="707"/>
<source>This will close the app or game you are streaming when you end your stream. You will lose any unsaved progress!</source>
<translation>Cela fermera l&apos;application ou le jeu que vous êtes en train de diffuser lorsque vous aurez terminé votre flux. Vous perdrez tout progrès non sauvegardé !</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="726"/>
<source>Video decoder</source>
<translation>Décodeur vidéo</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="751"/>
<location filename="../gui/SettingsView.qml" line="797"/>
<source>Automatic (Recommended)</source>
<translation>Automatique (recommandé)</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="755"/>
<source>Force software decoding</source>
<translation>Forcer le décodage des logiciels</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="759"/>
<source>Force hardware decoding</source>
<translation>Forcer le décodage du matériel</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="772"/>
<source>Video codec</source>
<translation>Codec vidéo</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="801"/>
<source>H.264</source>
<translation>H.264</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="805"/>
<source>HEVC (H.265)</source>
<translation>HEVC (H.265)</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="822"/>
<source>Unlock unsupported FPS options</source>
<translation>Débloquer les options non supportées du FPS</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="841"/>
<source>Automatically find PCs on the local network (Recommended)</source>
<translation>Trouver automatiquement les PC sur le réseau local (recommandé)</translation>
</message>
<message>
<location filename="../gui/SettingsView.qml" line="866"/>
<source>Automatically detect blocked connections (Recommended)</source>
<translation>Détecter automatiquement les connexions bloquées (recommandé)</translation>
</message>
</context>
<context>
<name>StreamSegue</name>
<message>
<location filename="../gui/StreamSegue.qml" line="11"/>
<location filename="../gui/StreamSegue.qml" line="17"/>
<source>Starting %1...</source>
<translation>Démarrage de %1...</translation>
</message>
<message>
<location filename="../gui/StreamSegue.qml" line="23"/>
<source>Starting %1 failed: Error %2</source>
<translation>Démarrage de %1... echec: erreur %2</translation>
</message>
<message>
<location filename="../gui/StreamSegue.qml" line="68"/>
<source>This PC&apos;s Internet connection is blocking Moonlight. Streaming over the Internet may not work while connected to this network.</source>
<translation>La connexion Internet de ce PC bloque Moonlight. Le streaming sur Internet peut ne pas fonctionner lorsqu&apos;il est connecté à ce réseau.</translation>
</message>
<message>
<location filename="../gui/StreamSegue.qml" line="150"/>
<source>Tip:</source>
<translation>Aide:</translation>
</message>
<message>
<location filename="../gui/StreamSegue.qml" line="150"/>
<source>Press %1 to disconnect your session</source>
<translation>Appuyez sur %1 pour déconnecter votre session</translation>
</message>
<message>
<location filename="../gui/StreamSegue.qml" line="151"/>
<source>Start+Select+L1+R1</source>
<translation>Start+Select+L1+R1</translation>
</message>
<message>
<location filename="../gui/StreamSegue.qml" line="151"/>
<source>Ctrl+Alt+Shift+Q</source>
<translation>Ctrl + Alt + Shift + Q</translation>
</message>
</context>
<context>
<name>main</name>
<message>
<location filename="../gui/main.qml" line="226"/>
<location filename="../gui/main.qml" line="236"/>
<location filename="../gui/main.qml" line="365"/>
<location filename="../gui/main.qml" line="380"/>
<source>Settings</source>
<translation>Paramètres</translation>
</message>
<message>
<location filename="../gui/main.qml" line="227"/>
<source>Version %1</source>
<translation>Version %1</translation>
</message>
<message>
<location filename="../gui/main.qml" line="243"/>
<source>Join our community on Discord</source>
<translation>Rejoignez notre communauté sur Discord</translation>
</message>
<message>
<location filename="../gui/main.qml" line="255"/>
<source>Computers</source>
<translation>Ordinateurs</translation>
</message>
<message>
<location filename="../gui/main.qml" line="262"/>
<source>Add PC manually</source>
<translation>Ajouter un PC manuellement</translation>
</message>
<message>
<location filename="../gui/main.qml" line="302"/>
<source>Update available for Moonlight: Version %1</source>
<translation>Mise à jour disponible pour Moonlight : Version %1</translation>
</message>
<message>
<location filename="../gui/main.qml" line="349"/>
<source>Gamepad Mapper</source>
<translation>configuration du controleur</translation>
</message>
<message>
<location filename="../gui/main.qml" line="353"/>
<source>Gamepad Mapping</source>
<translation>configuration du controleur</translation>
</message>
<message>
<location filename="../gui/main.qml" line="387"/>
<source>No functioning hardware accelerated H.264 video decoder was detected by Moonlight. Your streaming performance may be severely degraded in this configuration.</source>
<translation>Aucun décodeur vidéo H.264 accéléré par le matériel n&apos;a été détecté par Moonlight. Dans cette configuration, les performances de votre streaming peuvent être fortement dégradées.</translation>
</message>
<message>
<location filename="../gui/main.qml" line="395"/>
<source>Hardware acceleration doesn&apos;t work on XWayland. Continuing on XWayland may result in poor streaming performance. Try running with QT_QPA_PLATFORM=wayland or switch to X11.</source>
<translation>L&apos;accélération matérielle ne fonctionne pas sur XWayland. Continuer sur XWayland peut entraîner de mauvaises performances de streaming. Essayez de fonctionner avec QT_QPA_PLATFORM=wayland ou passez à X11.</translation>
</message>
<message>
<location filename="../gui/main.qml" line="413"/>
<source>Moonlight detected gamepads without a mapping:</source>
<translation>Moonlight a détecté des manettes de jeu san configuration:</translation>
</message>
<message>
<location filename="../gui/main.qml" line="326"/>
<source>Help</source>
<translation>Aide</translation>
</message>
<message>
<location filename="../gui/main.qml" line="389"/>
<source>Click the Help button for more information on solving this problem.</source>
<translation>Cliquez sur le bouton Aide pour obtenir plus d&apos;informations sur la manière de résoudre ce problème.</translation>
</message>
<message>
<location filename="../gui/main.qml" line="397"/>
<source>Click the Help button for more information.</source>
<translation>Cliquez sur le bouton Aide pour plus d&apos;informations.</translation>
</message>
<message>
<location filename="../gui/main.qml" line="404"/>
<source>This PC is running a 64-bit version of Windows. Please download the x64 version of Moonlight for the best streaming performance.</source>
<translation>Ce PC fonctionne avec une version 64 bits de Windows. Veuillez télécharger la version x64 de Moonlight pour obtenir les meilleures performances de diffusion en continu.</translation>
</message>
<message>
<location filename="../gui/main.qml" line="415"/>
<source>Click the Help button for information on how to map your gamepads.</source>
<translation>Cliquez sur le bouton Aide pour obtenir des informations sur la configuration de vos manettes de jeu.</translation>
</message>
<message>
<location filename="../gui/main.qml" line="423"/>
<source>Are you sure you want to quit?</source>
<translation>Vous êtes sûr de vouloir quitter?</translation>
</message>
<message>
<location filename="../gui/main.qml" line="453"/>
<source>Enter the IP address of your GameStream PC:</source>
<translation>Saisissez l&apos;adresse IP de votre PC GameStream :</translation>
</message>
</context>
</TS>
+48 -7
View File
@@ -11,6 +11,7 @@
#include <QCursor>
#include <QElapsedTimer>
#include <QFile>
#include<QTranslator>
// Don't let SDL hook our main function, since Qt is already
// doing the same thing. This needs to be before any headers
@@ -22,7 +23,7 @@
#include "streaming/video/ffmpeg.h"
#endif
#if defined(Q_OS_WIN32)
#if defined(Q_OS_WIN32) && defined(Q_PROCESSOR_X86)
#include "antihookingprotection.h"
#elif defined(Q_OS_LINUX)
#include <openssl/ssl.h>
@@ -196,7 +197,7 @@ LONG WINAPI UnhandledExceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo)
WCHAR dmpFileName[MAX_PATH];
swprintf_s(dmpFileName, L"%ls\\Moonlight-%I64u.dmp",
(PWCHAR)QDir::toNativeSeparators(Path::getLogDir()).utf16(), QDateTime::currentSecsSinceEpoch());
QString qDmpFileName = QString::fromUtf16((unsigned short*)dmpFileName);
QString qDmpFileName = QString::fromUtf16((const char16_t*)dmpFileName);
HANDLE dumpHandle = CreateFileW(dmpFileName, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (dumpHandle != INVALID_HANDLE_VALUE) {
MINIDUMP_EXCEPTION_INFORMATION info;
@@ -288,9 +289,10 @@ int main(int argc, char *argv[])
SetUnhandledExceptionFilter(UnhandledExceptionHandler);
#endif
#if defined(Q_OS_WIN32)
#if defined(Q_OS_WIN32) && defined(Q_PROCESSOR_X86)
// Force AntiHooking.dll to be statically imported and loaded
// by ntdll by calling a dummy function.
// by ntdll on x86/x64 platforms by calling a dummy function.
// AntiHooking.dll is not currently built for ARM64.
AntiHookingDummyImport();
#elif defined(Q_OS_LINUX)
// Force libssl.so to be directly linked to our binary, so
@@ -305,8 +307,10 @@ int main(int argc, char *argv[])
// NB: We can't use QGuiApplication::platformName() here because it is only
// set once the QGuiApplication is created, which is too late to enable High DPI :(
if (WMUtils::isRunningWindowManager()) {
// Enable High DPI support
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// Enable High DPI support on Qt 5.x. It is always enabled on Qt 6.0
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
// Enable fractional High DPI scaling on Qt 5.14 and later
@@ -319,6 +323,13 @@ int main(int argc, char *argv[])
qInfo() << "Unable to detect Wayland or X11, so EGLFS will be used by default. Set QT_QPA_PLATFORM to override this.";
qputenv("QT_QPA_PLATFORM", "eglfs");
if (!qEnvironmentVariableIsSet("QT_QPA_EGLFS_ALWAYS_SET_MODE")) {
qInfo() << "Setting display mode by default. Set QT_QPA_EGLFS_ALWAYS_SET_MODE=0 to override this.";
// The UI doesn't appear on RetroPie without this option.
qputenv("QT_QPA_EGLFS_ALWAYS_SET_MODE", "1");
}
if (!QFile("/dev/dri").exists()) {
qWarning() << "Unable to find a KMSDRM display device!";
qWarning() << "On the Raspberry Pi, you must enable the 'fake KMS' driver in raspi-config to use Moonlight outside of the GUI environment.";
@@ -331,7 +342,7 @@ int main(int argc, char *argv[])
// password prompts on macOS.
qputenv("QT_SSL_USE_TEMPORARY_KEYCHAIN", "1");
#ifdef Q_OS_WIN32
#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!qEnvironmentVariableIsSet("QT_OPENGL")) {
// On Windows, use ANGLE so we don't have to load OpenGL
// user-mode drivers into our app. OGL drivers (especially Intel)
@@ -340,6 +351,16 @@ int main(int argc, char *argv[])
}
#endif
#if defined(Q_OS_DARWIN) && QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (!qEnvironmentVariableIsSet("QSG_RHI_BACKEND")) {
// The Metal backend in Qt 6.0.0 causes really strange issues transitioning to
// full-screen in our SDL window (hangs in SDL's Cocoa_SetWindowFullscreenSpace())
// and breaks drawing our status updates in the StreamSegue, so use OpenGL like
// Qt 5 does until we figure out the cause of these issues.
qputenv("QSG_RHI_BACKEND", "opengl");
}
#endif
// We don't want system proxies to apply to us
QNetworkProxyFactory::setUseSystemConfiguration(false);
@@ -373,6 +394,11 @@ int main(int argc, char *argv[])
// future KMSDRM platforms that use SDL for rendering.
SDL_SetHint(SDL_HINT_VIDEO_DOUBLE_BUFFER, "1");
// Use Direct3D 9Ex to avoid a deadlock caused by the D3D device being reset when
// the user triggers a UAC prompt. This option controls the software/SDL renderer.
// The DXVA2 renderer uses Direct3D 9Ex itself directly.
SDL_SetHint("SDL_WINDOWS_USE_D3D9EX", "1");
if (SDL_InitSubSystem(SDL_INIT_TIMER) != 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_InitSubSystem(SDL_INIT_TIMER) failed: %s",
@@ -408,6 +434,14 @@ int main(int argc, char *argv[])
// releases of Moonlight.
SDL_SetHint("SDL_GAMECONTROLLER_USE_BUTTON_LABELS", "0");
// Disable relative mouse scaling to renderer size or logical DPI. We want to send
// the mouse motion exactly how it was given to us.
SDL_SetHint("SDL_MOUSE_RELATIVE_SCALING", "0");
// Set our app name for SDL to use with PulseAudio. This matches what we provide
// as our app name to libsoundio too.
SDL_SetHint("SDL_AUDIO_DEVICE_APP_NAME", "Moonlight");
#ifdef QT_DEBUG
// Allow thread naming using exceptions on debug builds. SDL doesn't use SEH
// when throwing the exceptions, so we don't enable it for release builds out
@@ -417,6 +451,10 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
QTranslator translator;
qDebug() << "Translation loaded:" << translator.load(QString(":/languages/qml_") + QLocale::system().name());
app.installTranslator(&translator);
// After the QGuiApplication is created, the platform stuff will be initialized
// and we can set the SDL video driver to match Qt.
if (WMUtils::isRunningWayland() && QGuiApplication::platformName() == "xcb") {
@@ -455,7 +493,11 @@ int main(int argc, char *argv[])
}
#endif
#ifndef Q_OS_DARWIN
// Set the window icon except on macOS where we want to keep the
// modified macOS 11 style rounded corner icon.
app.setWindowIcon(QIcon(":/res/moonlight.svg"));
#endif
// Register our C++ types for QML
qmlRegisterType<ComputerModel>("ComputerModel", 1, 0, "ComputerModel");
@@ -551,7 +593,6 @@ int main(int argc, char *argv[])
engine.load(QUrl(QStringLiteral("qrc:/gui/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
int err = app.exec();
// Give worker tasks time to properly exit. Fixes PendingQuitTask
Binary file not shown.
+40 -2
View File
@@ -6,6 +6,7 @@
#include <QSettings>
#include <QCoreApplication>
QString Path::s_CacheDir;
QString Path::s_LogDir;
QString Path::s_BoxArtCacheDir;
@@ -28,11 +29,43 @@ QByteArray Path::readDataFile(QString fileName)
return dataFile.readAll();
}
void Path::writeCacheFile(QString fileName, QByteArray data)
{
QDir cacheDir(s_CacheDir);
// Create the cache path if it does not exist
if (!cacheDir.exists()) {
cacheDir.mkpath(".");
}
QFile dataFile(cacheDir.absoluteFilePath(fileName));
dataFile.open(QIODevice::WriteOnly);
dataFile.write(data);
}
void Path::deleteCacheFile(QString fileName)
{
QFile dataFile(QDir(s_CacheDir).absoluteFilePath(fileName));
dataFile.remove();
}
QFileInfo Path::getCacheFileInfo(QString fileName)
{
return QFileInfo(QDir(s_CacheDir), fileName);
}
QString Path::getDataFilePath(QString fileName)
{
QString candidatePath;
// Check the current directory first
// Check the cache location first (used by Path::writeDataFile())
candidatePath = QDir(s_CacheDir).absoluteFilePath(fileName);
if (QFile::exists(candidatePath)) {
qInfo() << "Found" << fileName << "at" << candidatePath;
return candidatePath;
}
// Check the current directory
candidatePath = QDir(QDir::currentPath()).absoluteFilePath(fileName);
if (QFile::exists(candidatePath)) {
qInfo() << "Found" << fileName << "at" << candidatePath;
@@ -40,7 +73,7 @@ QString Path::getDataFilePath(QString fileName)
}
// Now check the data directories (for Linux, in particular)
candidatePath = QStandardPaths::locate(QStandardPaths::DataLocation, fileName);
candidatePath = QStandardPaths::locate(QStandardPaths::AppDataLocation, fileName);
if (!candidatePath.isEmpty() && QFile::exists(candidatePath)) {
qInfo() << "Found" << fileName << "at" << candidatePath;
return candidatePath;
@@ -64,6 +97,10 @@ void Path::initialize(bool portable)
if (portable) {
s_LogDir = QDir::currentPath();
s_BoxArtCacheDir = QDir::currentPath() + "/boxart";
// In order for the If-Modified-Since logic to work in MappingFetcher,
// the cache directory must be different than the current directory.
s_CacheDir = QDir::currentPath() + "/cache";
}
else {
#ifdef Q_OS_DARWIN
@@ -73,6 +110,7 @@ void Path::initialize(bool portable)
#else
s_LogDir = QDir::tempPath();
#endif
s_CacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
s_BoxArtCacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/boxart";
}
}
+5
View File
@@ -1,6 +1,7 @@
#pragma once
#include <QString>
#include <QFileInfo>
class Path
{
@@ -10,6 +11,9 @@ public:
static QString getBoxArtCacheDir();
static QByteArray readDataFile(QString fileName);
static void writeCacheFile(QString fileName, QByteArray data);
static void deleteCacheFile(QString fileName);
static QFileInfo getCacheFileInfo(QString fileName);
// Only safe to use directly for Qt classes
static QString getDataFilePath(QString fileName);
@@ -17,6 +21,7 @@ public:
static void initialize(bool portable);
private:
static QString s_CacheDir;
static QString s_LogDir;
static QString s_BoxArtCacheDir;
};
+1 -1
View File
@@ -1 +1 @@
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 245 240"><style>.st0{fill:#FFFFFF;}</style><path class="st0" d="M104.4 103.9c-5.7 0-10.2 5-10.2 11.1s4.6 11.1 10.2 11.1c5.7 0 10.2-5 10.2-11.1.1-6.1-4.5-11.1-10.2-11.1zM140.9 103.9c-5.7 0-10.2 5-10.2 11.1s4.6 11.1 10.2 11.1c5.7 0 10.2-5 10.2-11.1s-4.5-11.1-10.2-11.1z"/><path class="st0" d="M189.5 20h-134C44.2 20 35 29.2 35 40.6v135.2c0 11.4 9.2 20.6 20.5 20.6h113.4l-5.3-18.5 12.8 11.9 12.1 11.2 21.5 19V40.6c0-11.4-9.2-20.6-20.5-20.6zm-38.6 130.6s-3.6-4.3-6.6-8.1c13.1-3.7 18.1-11.9 18.1-11.9-4.1 2.7-8 4.6-11.5 5.9-5 2.1-9.8 3.5-14.5 4.3-9.6 1.8-18.4 1.3-25.9-.1-5.7-1.1-10.6-2.7-14.7-4.3-2.3-.9-4.8-2-7.3-3.4-.3-.2-.6-.3-.9-.5-.2-.1-.3-.2-.4-.3-1.8-1-2.8-1.7-2.8-1.7s4.8 8 17.5 11.8c-3 3.8-6.7 8.3-6.7 8.3-22.1-.7-30.5-15.2-30.5-15.2 0-32.2 14.4-58.3 14.4-58.3 14.4-10.8 28.1-10.5 28.1-10.5l1 1.2c-18 5.2-26.3 13.1-26.3 13.1s2.2-1.2 5.9-2.9c10.7-4.7 19.2-6 22.7-6.3.6-.1 1.1-.2 1.7-.2 6.1-.8 13-1 20.2-.2 9.5 1.1 19.7 3.9 30.1 9.6 0 0-7.9-7.5-24.9-12.7l1.4-1.6s13.7-.3 28.1 10.5c0 0 14.4 26.1 14.4 58.3 0 0-8.5 14.5-30.6 15.2z"/></svg>
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 245 240" fill="white"><path class="st0" d="M104.4 103.9c-5.7 0-10.2 5-10.2 11.1s4.6 11.1 10.2 11.1c5.7 0 10.2-5 10.2-11.1.1-6.1-4.5-11.1-10.2-11.1zM140.9 103.9c-5.7 0-10.2 5-10.2 11.1s4.6 11.1 10.2 11.1c5.7 0 10.2-5 10.2-11.1s-4.5-11.1-10.2-11.1z"/><path class="st0" d="M189.5 20h-134C44.2 20 35 29.2 35 40.6v135.2c0 11.4 9.2 20.6 20.5 20.6h113.4l-5.3-18.5 12.8 11.9 12.1 11.2 21.5 19V40.6c0-11.4-9.2-20.6-20.5-20.6zm-38.6 130.6s-3.6-4.3-6.6-8.1c13.1-3.7 18.1-11.9 18.1-11.9-4.1 2.7-8 4.6-11.5 5.9-5 2.1-9.8 3.5-14.5 4.3-9.6 1.8-18.4 1.3-25.9-.1-5.7-1.1-10.6-2.7-14.7-4.3-2.3-.9-4.8-2-7.3-3.4-.3-.2-.6-.3-.9-.5-.2-.1-.3-.2-.4-.3-1.8-1-2.8-1.7-2.8-1.7s4.8 8 17.5 11.8c-3 3.8-6.7 8.3-6.7 8.3-22.1-.7-30.5-15.2-30.5-15.2 0-32.2 14.4-58.3 14.4-58.3 14.4-10.8 28.1-10.5 28.1-10.5l1 1.2c-18 5.2-26.3 13.1-26.3 13.1s2.2-1.2 5.9-2.9c10.7-4.7 19.2-6 22.7-6.3.6-.1 1.1-.2 1.7-.2 6.1-.8 13-1 20.2-.2 9.5 1.1 19.7 3.9 30.1 9.6 0 0-7.9-7.5-24.9-12.7l1.4-1.6s13.7-.3 28.1 10.5c0 0 14.4 26.1 14.4 58.3 0 0-8.5 14.5-30.6 15.2z"/></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

+4
View File
@@ -17,11 +17,15 @@
<file>res/baseline-error_outline-24px.svg</file>
<file>res/baseline-check_circle_outline-24px.svg</file>
<file>res/Discord-Logo-White.svg</file>
<file>languages/qml_fr.ts</file>
<file>languages/qml_fr.qm</file>
</qresource>
<qresource prefix="/data">
<file alias="gamecontrollerdb.txt">SDL_GameControllerDB/gamecontrollerdb.txt</file>
<file alias="ModeSeven.ttf">ModeSeven.ttf</file>
<file alias="egl.frag">shaders/egl.frag</file>
<file alias="egl.vert">shaders/egl.vert</file>
<file alias="egl_overlay.frag">shaders/egl_overlay.frag</file>
<file alias="egl_overlay.vert">shaders/egl_overlay.vert</file>
</qresource>
</RCC>
+91
View File
@@ -0,0 +1,91 @@
#include "mappingfetcher.h"
#include "path.h"
#include <QNetworkReply>
MappingFetcher::MappingFetcher(QObject *parent) :
QObject(parent),
m_Nam(this)
{
// Never communicate over HTTP
m_Nam.setStrictTransportSecurityEnabled(true);
// Allow HTTP redirects
m_Nam.setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy);
connect(&m_Nam, SIGNAL(finished(QNetworkReply*)),
this, SLOT(handleMappingListFetched(QNetworkReply*)));
}
void MappingFetcher::start()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) && QT_VERSION < QT_VERSION_CHECK(5, 15, 1) && !defined(QT_NO_BEARERMANAGEMENT)
// HACK: Set network accessibility to work around QTBUG-80947 (introduced in Qt 5.14.0 and fixed in Qt 5.15.1)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
m_Nam.setNetworkAccessible(QNetworkAccessManager::Accessible);
QT_WARNING_POP
#endif
QUrl url("https://moonlight-stream.org/SDL_GameControllerDB/gamecontrollerdb.txt");
QNetworkRequest request(url);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
request.setAttribute(QNetworkRequest::Http2AllowedAttribute, true);
#else
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true);
#endif
// Qt 5.12 introduced QNetworkRequest::IfModifiedSinceHeader. We _could_ implement it
// by hand (including QDateTime conversion to the correct string form) for earlier Qt
// versions, but that's a pain and this is just an optimization anyway. We'll do a bit
// of extra work on those legacy Qt versions by fetching the GCDB each time we launch.
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
// Only download the file if it's newer than what we have
QFileInfo existingFileInfo = Path::getCacheFileInfo("gamecontrollerdb.txt");
if (existingFileInfo.exists()) {
// Make sure the cached file looks reasonable. It should have some data and
// the last modified time should not be in the future.
QDateTime lastModifiedTime = existingFileInfo.lastModified().toUTC();
if (existingFileInfo.size() > 0 && lastModifiedTime <= QDateTime::currentDateTimeUtc()) {
request.setHeader(QNetworkRequest::IfModifiedSinceHeader, existingFileInfo.lastModified().toUTC());
}
else {
Path::deleteCacheFile("gamecontrollerdb.txt");
}
}
#endif
// We'll get a callback when this is finished
m_Nam.get(request);
}
void MappingFetcher::handleMappingListFetched(QNetworkReply* reply)
{
Q_ASSERT(reply->isFinished());
if (reply->error() == QNetworkReply::NoError) {
// Queue the reply for deletion
reply->deleteLater();
// If we get a 304 back, Qt will happily just tell us our request was
// successful and let us try to write our empty response to disk. Check
// the status code directly to prevent this.
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 304) {
qInfo() << "Gamepad mappings are up to date";
}
else {
// Update the cached data on disk for next call to applyMappings()
QByteArray data = reply->readAll();
if (!data.isEmpty()) {
Path::writeCacheFile("gamecontrollerdb.txt", data);
}
qInfo() << "Downloaded updated gamepad mappings";
}
}
else {
qWarning() << "Failed to download updated gamepad mappings:" << reply->error();
reply->deleteLater();
}
}
+20
View File
@@ -0,0 +1,20 @@
#pragma once
#include <QObject>
#include <QNetworkAccessManager>
class MappingFetcher : public QObject
{
Q_OBJECT
public:
explicit MappingFetcher(QObject *parent = nullptr);
void start();
private slots:
void handleMappingListFetched(QNetworkReply* reply);
private:
QNetworkAccessManager m_Nam;
};
+24 -6
View File
@@ -10,10 +10,18 @@
#define SER_GUID "guid"
#define SER_MAPPING "mapping"
MappingFetcher* MappingManager::s_MappingFetcher;
MappingManager::MappingManager()
{
QSettings settings;
// Load updated mappings from the Internet once per Moonlight launch
if (s_MappingFetcher == nullptr) {
s_MappingFetcher = new MappingFetcher();
s_MappingFetcher->start();
}
// First load existing saved mappings. This ensures the user's
// hints can always override the old data.
int mappingCount = settings.beginReadArray(SER_GAMEPADMAPPING);
@@ -64,16 +72,26 @@ void MappingManager::applyMappings()
if (!mappingData.isEmpty()) {
int newMappings = SDL_GameControllerAddMappingsFromRW(
SDL_RWFromConstMem(mappingData.constData(), mappingData.size()), 1);
if (newMappings < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Error loading gamepad mappings: %s",
SDL_GetError());
}
else {
if (newMappings > 0) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Loaded %d new gamepad mappings",
newMappings);
}
else {
if (newMappings < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Error loading gamepad mappings: %s",
SDL_GetError());
}
else if (newMappings == 0) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"0 new mappings found in gamecontrollerdb.txt. Is it corrupt?");
}
// Try deleting the cached mapping list just in case it's corrupt
Path::deleteCacheFile("gamecontrollerdb.txt");
}
}
else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+4
View File
@@ -1,5 +1,7 @@
#pragma once
#include "mappingfetcher.h"
#include <QSettings>
class SdlGamepadMapping
@@ -70,5 +72,7 @@ public:
private:
QMap<QString, SdlGamepadMapping> m_Mappings;
static MappingFetcher* s_MappingFetcher;
};
+28 -3
View File
@@ -24,12 +24,18 @@
#define SER_STARTWINDOWED "startwindowed"
#define SER_FRAMEPACING "framepacing"
#define SER_CONNWARNINGS "connwarnings"
#define SER_UIDISPLAYMODE "uidisplaymode"
#define SER_RICHPRESENCE "richpresence"
#define SER_GAMEPADMOUSE "gamepadmouse"
#define SER_DEFAULTVER "defaultver"
#define SER_PACKETSIZE "packetsize"
#define SER_DETECTNETBLOCKING "detectnetblocking"
#define SER_SWAPMOUSEBUTTONS "swapmousebuttons"
#define SER_MUTEONFOCUSLOSS "muteonfocusloss"
#define SER_BACKGROUNDGAMEPAD "backgroundgamepad"
#define SER_REVERSESCROLL "reversescroll"
#define SER_SWAPFACEBUTTONS "swapfacebuttons"
#define SER_CAPTURESYSKEYS "capturesyskeys"
#define CURRENT_DEFAULT_VER 1
@@ -64,7 +70,6 @@ void StreamingPreferences::reload()
quitAppAfter = settings.value(SER_QUITAPPAFTER, false).toBool();
absoluteMouseMode = settings.value(SER_ABSMOUSEMODE, false).toBool();
absoluteTouchMode = settings.value(SER_ABSTOUCHMODE, true).toBool();
startWindowed = settings.value(SER_STARTWINDOWED, true).toBool();
framePacing = settings.value(SER_FRAMEPACING, false).toBool();
connectionWarnings = settings.value(SER_CONNWARNINGS, true).toBool();
richPresence = settings.value(SER_RICHPRESENCE, true).toBool();
@@ -72,6 +77,11 @@ void StreamingPreferences::reload()
detectNetworkBlocking = settings.value(SER_DETECTNETBLOCKING, true).toBool();
packetSize = settings.value(SER_PACKETSIZE, 0).toInt();
swapMouseButtons = settings.value(SER_SWAPMOUSEBUTTONS, false).toBool();
muteOnFocusLoss = settings.value(SER_MUTEONFOCUSLOSS, false).toBool();
backgroundGamepad = settings.value(SER_BACKGROUNDGAMEPAD, false).toBool();
reverseScrollDirection = settings.value(SER_REVERSESCROLL, false).toBool();
swapFaceButtons = settings.value(SER_SWAPFACEBUTTONS, false).toBool();
captureSysKeys = settings.value(SER_CAPTURESYSKEYS, false).toBool();
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
static_cast<int>(AudioConfig::AC_STEREO)).toInt());
videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG,
@@ -82,6 +92,10 @@ void StreamingPreferences::reload()
// Try to load from the old preference value too
static_cast<int>(settings.value(SER_FULLSCREEN, true).toBool() ?
recommendedFullScreenMode : WindowMode::WM_WINDOWED)).toInt());
uiDisplayMode = static_cast<UIDisplayMode>(settings.value(SER_UIDISPLAYMODE,
static_cast<int>(settings.value(SER_STARTWINDOWED, true).toBool() ? UIDisplayMode::UI_WINDOWED
: UIDisplayMode::UI_MAXIMIZED)).toInt());
// Perform default settings updates as required based on last default version
if (defaultVer == 0) {
@@ -111,7 +125,6 @@ void StreamingPreferences::save()
settings.setValue(SER_QUITAPPAFTER, quitAppAfter);
settings.setValue(SER_ABSMOUSEMODE, absoluteMouseMode);
settings.setValue(SER_ABSTOUCHMODE, absoluteTouchMode);
settings.setValue(SER_STARTWINDOWED, startWindowed);
settings.setValue(SER_FRAMEPACING, framePacing);
settings.setValue(SER_CONNWARNINGS, connectionWarnings);
settings.setValue(SER_RICHPRESENCE, richPresence);
@@ -122,8 +135,14 @@ void StreamingPreferences::save()
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection));
settings.setValue(SER_WINDOWMODE, static_cast<int>(windowMode));
settings.setValue(SER_UIDISPLAYMODE, static_cast<int>(uiDisplayMode));
settings.setValue(SER_DEFAULTVER, CURRENT_DEFAULT_VER);
settings.setValue(SER_SWAPMOUSEBUTTONS, swapMouseButtons);
settings.setValue(SER_MUTEONFOCUSLOSS, muteOnFocusLoss);
settings.setValue(SER_BACKGROUNDGAMEPAD, backgroundGamepad);
settings.setValue(SER_REVERSESCROLL, reverseScrollDirection);
settings.setValue(SER_SWAPFACEBUTTONS, swapFaceButtons);
settings.setValue(SER_CAPTURESYSKEYS, captureSysKeys);
}
int StreamingPreferences::getDefaultBitrate(int width, int height, int fps)
@@ -133,8 +152,14 @@ int StreamingPreferences::getDefaultBitrate(int width, int height, int fps)
// we don't want to bump those 16:10 resolutions up to the
// next 16:9 slot.
if (width * height <= 640 * 360) {
return static_cast<int>(1000 * (fps / 30.0));
}
else if (width * height <= 854 * 480) {
return static_cast<int>(1500 * (fps / 30.0));
}
// This covers 1280x720 and 1280x800 too
if (width * height <= 1366 * 768) {
else if (width * height <= 1366 * 768) {
return static_cast<int>(5000 * (fps / 30.0));
}
else if (width * height <= 1920 * 1200) {
+26 -3
View File
@@ -50,6 +50,14 @@ public:
};
Q_ENUM(WindowMode)
enum UIDisplayMode
{
UI_WINDOWED,
UI_MAXIMIZED,
UI_FULLSCREEN
};
Q_ENUM(UIDisplayMode)
Q_PROPERTY(int width MEMBER width NOTIFY displayModeChanged)
Q_PROPERTY(int height MEMBER height NOTIFY displayModeChanged)
Q_PROPERTY(int fps MEMBER fps NOTIFY displayModeChanged)
@@ -63,7 +71,6 @@ public:
Q_PROPERTY(bool quitAppAfter MEMBER quitAppAfter NOTIFY quitAppAfterChanged)
Q_PROPERTY(bool absoluteMouseMode MEMBER absoluteMouseMode NOTIFY absoluteMouseModeChanged)
Q_PROPERTY(bool absoluteTouchMode MEMBER absoluteTouchMode NOTIFY absoluteTouchModeChanged)
Q_PROPERTY(bool startWindowed MEMBER startWindowed NOTIFY startWindowedChanged)
Q_PROPERTY(bool framePacing MEMBER framePacing NOTIFY framePacingChanged)
Q_PROPERTY(bool connectionWarnings MEMBER connectionWarnings NOTIFY connectionWarningsChanged)
Q_PROPERTY(bool richPresence MEMBER richPresence NOTIFY richPresenceChanged)
@@ -74,7 +81,13 @@ public:
Q_PROPERTY(VideoDecoderSelection videoDecoderSelection MEMBER videoDecoderSelection NOTIFY videoDecoderSelectionChanged)
Q_PROPERTY(WindowMode windowMode MEMBER windowMode NOTIFY windowModeChanged)
Q_PROPERTY(WindowMode recommendedFullScreenMode MEMBER recommendedFullScreenMode CONSTANT)
Q_PROPERTY(UIDisplayMode uiDisplayMode MEMBER uiDisplayMode NOTIFY uiDisplayModeChanged)
Q_PROPERTY(bool swapMouseButtons MEMBER swapMouseButtons NOTIFY mouseButtonsChanged)
Q_PROPERTY(bool muteOnFocusLoss MEMBER muteOnFocusLoss NOTIFY muteOnFocusLossChanged)
Q_PROPERTY(bool backgroundGamepad MEMBER backgroundGamepad NOTIFY backgroundGamepadChanged)
Q_PROPERTY(bool reverseScrollDirection MEMBER reverseScrollDirection NOTIFY reverseScrollDirectionChanged)
Q_PROPERTY(bool swapFaceButtons MEMBER swapFaceButtons NOTIFY swapFaceButtonsChanged)
Q_PROPERTY(bool captureSysKeys MEMBER captureSysKeys NOTIFY captureSysKeysChanged)
// Directly accessible members for preferences
int width;
@@ -90,19 +103,24 @@ public:
bool quitAppAfter;
bool absoluteMouseMode;
bool absoluteTouchMode;
bool startWindowed;
bool framePacing;
bool connectionWarnings;
bool richPresence;
bool gamepadMouse;
bool detectNetworkBlocking;
bool swapMouseButtons;
bool muteOnFocusLoss;
bool backgroundGamepad;
bool reverseScrollDirection;
bool swapFaceButtons;
bool captureSysKeys;
int packetSize;
AudioConfig audioConfig;
VideoCodecConfig videoCodecConfig;
VideoDecoderSelection videoDecoderSelection;
WindowMode windowMode;
WindowMode recommendedFullScreenMode;
UIDisplayMode uiDisplayMode;
signals:
void displayModeChanged();
@@ -119,13 +137,18 @@ signals:
void audioConfigChanged();
void videoCodecConfigChanged();
void videoDecoderSelectionChanged();
void uiDisplayModeChanged();
void windowModeChanged();
void startWindowedChanged();
void framePacingChanged();
void connectionWarningsChanged();
void richPresenceChanged();
void gamepadMouseChanged();
void detectNetworkBlockingChanged();
void mouseButtonsChanged();
void muteOnFocusLossChanged();
void backgroundGamepadChanged();
void reverseScrollDirectionChanged();
void swapFaceButtonsChanged();
void captureSysKeysChanged();
};
+11
View File
@@ -0,0 +1,11 @@
precision mediump float;
uniform sampler2D uTexture;
varying vec2 vTexCoord;
void main() {
vec4 abgr = texture2D(uTexture, vTexCoord);
gl_FragColor = abgr;
gl_FragColor.r = abgr.b;
gl_FragColor.b = abgr.r;
}
+8
View File
@@ -0,0 +1,8 @@
attribute vec2 aPosition; // 2D: X,Y
attribute vec2 aTexCoord;
varying vec2 vTexCoord;
void main() {
vTexCoord = aTexCoord;
gl_Position = vec4(aPosition, 0, 1);
}
+5
View File
@@ -197,6 +197,11 @@ void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength)
s_ActiveSession->m_AudioSampleCount++;
// If audio is muted, don't decode or play the audio
if (s_ActiveSession->m_AudioMuted) {
return;
}
if (s_ActiveSession->m_AudioRenderer != nullptr) {
int desiredSize = sizeof(short) * s_ActiveSession->m_AudioConfig.samplesPerFrame * s_ActiveSession->m_AudioConfig.channelCount;
void* buffer = s_ActiveSession->m_AudioRenderer->getAudioBuffer(&desiredSize);
+2 -33
View File
@@ -3,43 +3,12 @@
#include <Limelight.h>
#include <SDL.h>
#include <QtGlobal>
#include <QFile>
#include <QTextStream>
SdlAudioRenderer::SdlAudioRenderer()
: m_AudioDevice(0),
m_AudioBuffer(nullptr)
{
SDL_assert(!SDL_WasInit(SDL_INIT_AUDIO));
#ifdef HAVE_MMAL
// HACK: PulseAudio on Raspberry Pi suffers from horrible underruns,
// so switch to ALSA if we detect that we're on a Pi. We need to
// actually set a bogus PULSE_SERVER so it doesn't try to get smart on us
// and find PA anyway. SDL_AUDIODRIVER=pulseaudio can override this logic.
if (qgetenv("SDL_AUDIODRIVER").toLower() != "pulseaudio") {
QFile file("/proc/cpuinfo");
if (file.open(QIODevice::ReadOnly | QFile::Text)) {
QTextStream textStream(&file);
if (textStream.readAll().contains("Raspberry Pi")) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Avoiding PulseAudio on Raspberry Pi");
qputenv("PULSE_SERVER", "");
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"ALSA failed; falling back to default");
qunsetenv("PULSE_SERVER");
}
else {
SDL_QuitSubSystem(SDL_INIT_AUDIO);
}
}
}
}
#endif
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_InitSubSystem(SDL_INIT_AUDIO) failed: %s",
@@ -73,7 +42,7 @@ bool SdlAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION*
return false;
}
m_AudioBuffer = malloc(m_FrameSize);
m_AudioBuffer = SDL_malloc(m_FrameSize);
if (m_AudioBuffer == nullptr) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Failed to allocate audio buffer");
@@ -105,7 +74,7 @@ SdlAudioRenderer::~SdlAudioRenderer()
}
if (m_AudioBuffer != nullptr) {
free(m_AudioBuffer);
SDL_free(m_AudioBuffer);
}
SDL_QuitSubSystem(SDL_INIT_AUDIO);
+17
View File
@@ -167,6 +167,23 @@ void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* eve
return;
}
if (m_SwapFaceButtons) {
switch (event->button) {
case SDL_CONTROLLER_BUTTON_A:
event->button = SDL_CONTROLLER_BUTTON_B;
break;
case SDL_CONTROLLER_BUTTON_B:
event->button = SDL_CONTROLLER_BUTTON_A;
break;
case SDL_CONTROLLER_BUTTON_X:
event->button = SDL_CONTROLLER_BUTTON_Y;
break;
case SDL_CONTROLLER_BUTTON_Y:
event->button = SDL_CONTROLLER_BUTTON_X;
break;
}
}
if (event->state == SDL_PRESSED) {
state->buttons |= k_ButtonMap[event->button];
+217 -17
View File
@@ -3,21 +3,29 @@
#include "streaming/session.h"
#include "settings/mappingmanager.h"
#include "path.h"
#include "utils.h"
#include <QtGlobal>
#include <QDir>
#define MOUSE_POLLING_INTERVAL 5
#ifdef Q_OS_WIN32
HHOOK g_KeyboardHook;
#endif
SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int streamWidth, int streamHeight)
: m_MultiController(prefs.multiController),
m_GamepadMouse(prefs.gamepadMouse),
m_SwapMouseButtons(prefs.swapMouseButtons),
m_ReverseScrollDirection(prefs.reverseScrollDirection),
m_SwapFaceButtons(prefs.swapFaceButtons),
m_MouseMoveTimer(0),
m_MousePositionLock(0),
m_MouseWasInVideoRegion(false),
m_PendingMouseButtonsAllUpOnVideoRegionLeave(false),
m_FakeCaptureActive(false),
m_CaptureSystemKeysEnabled(prefs.captureSysKeys || !WMUtils::isRunningWindowManager()),
m_LongPressTimer(0),
m_StreamWidth(streamWidth),
m_StreamHeight(streamHeight),
@@ -30,8 +38,8 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s
m_DragButton(0),
m_NumFingersDown(0)
{
// Allow gamepad input when the app doesn't have focus
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
// Allow gamepad input when the app doesn't have focus if requested
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, prefs.backgroundGamepad ? "1" : "0");
// If absolute mouse mode is enabled, use relative mode warp (which
// is via normal motion events that are influenced by mouse acceleration).
@@ -41,28 +49,23 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s
prefs.absoluteMouseMode ? "1" : "0",
SDL_HINT_OVERRIDE);
// If we're grabbing system keys, enable the X11 keyboard grab in SDL
SDL_SetHintWithPriority(SDL_HINT_GRAB_KEYBOARD,
m_CaptureSystemKeysEnabled ? "1" : "0",
SDL_HINT_OVERRIDE);
// Allow clicks to pass through to us when focusing the window. If we're in
// absolute mouse mode, this will avoid the user having to click twice to
// trigger a click on the host if the Moonlight window is not focused. In
// relative mode, the click event will trigger the mouse to be recaptured.
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
#if defined(Q_OS_DARWIN) && !SDL_VERSION_ATLEAST(2, 0, 10)
// SDL 2.0.9 on macOS has a broken HIDAPI mapping for the older Xbox One S
// firmware, so we have to disable HIDAPI for Xbox gamepads on macOS until
// SDL 2.0.10 where the bug is fixed.
// https://github.com/moonlight-stream/moonlight-qt/issues/133
// https://bugzilla.libsdl.org/show_bug.cgi?id=4395
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_XBOX, "0");
#endif
#if SDL_VERSION_ATLEAST(2, 0, 9)
// Enabling extended input reports allows rumble to function on Bluetooth PS4
// Enabling extended input reports allows rumble to function on Bluetooth PS4/PS5
// controllers, but breaks DirectInput applications. We will enable it because
// it's likely that working rumble is what the user is expecting. If they don't
// want this behavior, they can override it with the environment variable.
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
#endif
SDL_SetHint("SDL_JOYSTICK_HIDAPI_PS4_RUMBLE", "1");
SDL_SetHint("SDL_JOYSTICK_HIDAPI_PS5_RUMBLE", "1");
m_OldIgnoreDevices = SDL_GetHint(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES);
m_OldIgnoreDevicesExcept = SDL_GetHint(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT);
@@ -146,10 +149,38 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s
}
m_MouseMoveTimer = SDL_AddTimer(pollingInterval, SdlInputHandler::mouseMoveTimerCallback, this);
#ifdef Q_OS_WIN32
if (m_CaptureSystemKeysEnabled) {
// If system key capture is enabled, install the window hook required to intercept
// these key presses and block them from the OS itself.
g_KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, SdlInputHandler::keyboardHookProc, GetModuleHandle(NULL), 0);
}
#endif
}
SdlInputHandler::~SdlInputHandler()
{
#ifdef Q_OS_WIN32
if (g_KeyboardHook != nullptr) {
UnhookWindowsHookEx(g_KeyboardHook);
g_KeyboardHook = nullptr;
// If we're terminating because of the user pressing the quit combo,
// we won't have a chance to inform SDL as the modifier keys raise.
// This will leave stale modifier flags in the SDL_Keyboard global
// inside SDL which will show up on our next key event if the user
// streams again. Avoid this by explicitly zeroing mod state when
// ending the stream.
//
// This is only needed for the case where we're hooking the keyboard
// because we're generating synthetic SDL_KEYDOWN/SDL_KEYUP events
// which don't properly maintain SDL's internal keyboard state,
// so we're forced to invoke SDL_SetModState() ourselves to set mods.
SDL_SetModState(KMOD_NONE);
}
#endif
for (int i = 0; i < MAX_GAMEPADS; i++) {
if (m_GamepadState[i].mouseEmulationTimer != 0) {
Session::get()->notifyMouseEmulationMode(false);
@@ -203,6 +234,157 @@ void SdlInputHandler::setWindow(SDL_Window *window)
m_Window = window;
}
#ifdef Q_OS_WIN32
LRESULT CALLBACK SdlInputHandler::keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode < 0 || nCode != HC_ACTION) {
return CallNextHookEx(g_KeyboardHook, nCode, wParam, lParam);
}
bool keyCaptureActive;
SDL_Event event = {};
KBDLLHOOKSTRUCT* hookData = (KBDLLHOOKSTRUCT*)lParam;
switch (hookData->vkCode) {
case VK_LWIN:
event.key.keysym.sym = SDLK_LGUI;
event.key.keysym.scancode = SDL_SCANCODE_LGUI;
break;
case VK_RWIN:
event.key.keysym.sym = SDLK_RGUI;
event.key.keysym.scancode = SDL_SCANCODE_RGUI;
break;
case VK_LMENU:
event.key.keysym.sym = SDLK_LALT;
event.key.keysym.scancode = SDL_SCANCODE_LALT;
break;
case VK_RMENU:
event.key.keysym.sym = SDLK_RALT;
event.key.keysym.scancode = SDL_SCANCODE_RALT;
break;
case VK_LCONTROL:
event.key.keysym.sym = SDLK_LCTRL;
event.key.keysym.scancode = SDL_SCANCODE_LCTRL;
break;
case VK_RCONTROL:
event.key.keysym.sym = SDLK_RCTRL;
event.key.keysym.scancode = SDL_SCANCODE_RCTRL;
break;
default:
// Bail quickly if it's not a key we care about
goto NextHook;
}
// Make sure we're in a state where we actually want to steal this event (and it is safe to do so)
Session* session = Session::get();
if (session == nullptr || session->m_InputHandler == nullptr) {
goto NextHook;
}
keyCaptureActive = session->m_InputHandler->isSystemKeyCaptureActive();
// If this is a key we're going to intercept, create the synthetic SDL event.
// This is necessary because we are also hiding this key event from ourselves too.
if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) {
event.type = SDL_KEYDOWN;
event.key.state = SDL_PRESSED;
}
else {
event.type = SDL_KEYUP;
event.key.state = SDL_RELEASED;
}
// Drop the event if it's a key down and capture is not active.
// For key up, we'll need to do a little more work to determine if we need to send this
// event to SDL in order to keep its internal keyboard modifier state consistent.
if (event.type == SDL_KEYDOWN && !keyCaptureActive) {
goto NextHook;
}
event.key.keysym.mod = SDL_GetModState();
switch (hookData->vkCode) {
case VK_LWIN:
if (event.key.state == SDL_PRESSED) {
event.key.keysym.mod |= KMOD_LGUI;
}
else {
event.key.keysym.mod &= ~KMOD_LGUI;
}
break;
case VK_RWIN:
if (event.key.state == SDL_PRESSED) {
event.key.keysym.mod |= KMOD_RGUI;
}
else {
event.key.keysym.mod &= ~KMOD_RGUI;
}
break;
case VK_LMENU:
if (event.key.state == SDL_PRESSED) {
event.key.keysym.mod |= KMOD_LALT;
}
else {
event.key.keysym.mod &= ~KMOD_LALT;
}
break;
case VK_RMENU:
if (event.key.state == SDL_PRESSED) {
event.key.keysym.mod |= KMOD_RALT;
}
else {
event.key.keysym.mod &= ~KMOD_RALT;
}
break;
case VK_LCONTROL:
if (event.key.state == SDL_PRESSED) {
event.key.keysym.mod |= KMOD_LCTRL;
}
else {
event.key.keysym.mod &= ~KMOD_LCTRL;
}
break;
case VK_RCONTROL:
if (event.key.state == SDL_PRESSED) {
event.key.keysym.mod |= KMOD_RCTRL;
}
else {
event.key.keysym.mod &= ~KMOD_RCTRL;
}
break;
}
// If the modifier state is unchanged and we're not capturing system keys,
// drop the event. If the modifier state is changed, we need to send the
// event to update SDL's state even if system key capture is now inactive
// (due to focus loss, mouse capture toggled off, etc.) otherwise SDL won't
// know that the modifier key has been lifted.
if (event.key.keysym.mod == SDL_GetModState() && !keyCaptureActive) {
goto NextHook;
}
event.key.timestamp = SDL_GetTicks();
event.key.windowID = SDL_GetWindowID(session->m_Window);
// NOTE: event.key.repeat is not populated in this path!
SDL_PushEvent(&event);
// Synchronize SDL's modifier state with the current state.
// SDL won't do this on its own because it will never see the
// WM_KEYUP/WM_KEYDOWN events.
SDL_SetModState((SDL_Keymod)event.key.keysym.mod);
// Eat the event only if key capture is active.
// If capture is not active and we're just resyncing SDL's modifier state,
// we need to ensure the key event is still delivered normally to the
// window in focus.
if (keyCaptureActive) {
return 1;
}
NextHook:
return CallNextHookEx(g_KeyboardHook, nCode, wParam, lParam);
}
#endif
void SdlInputHandler::raiseAllKeys()
{
if (m_KeysDown.isEmpty()) {
@@ -211,7 +393,7 @@ void SdlInputHandler::raiseAllKeys()
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Raising %d keys",
m_KeysDown.count());
(int)m_KeysDown.count());
for (auto keyDown : m_KeysDown) {
LiSendKeyboardEvent(keyDown, KEY_ACTION_UP, 0);
@@ -263,11 +445,29 @@ bool SdlInputHandler::isCaptureActive()
return m_FakeCaptureActive;
}
bool SdlInputHandler::isSystemKeyCaptureActive()
{
if (!m_CaptureSystemKeysEnabled) {
return false;
}
if (m_Window == nullptr) {
return false;
}
Uint32 windowFlags = SDL_GetWindowFlags(m_Window);
return (windowFlags & SDL_WINDOW_INPUT_FOCUS) &&
(windowFlags & SDL_WINDOW_INPUT_GRABBED) &&
(windowFlags & SDL_WINDOW_FULLSCREEN_DESKTOP);
}
void SdlInputHandler::setCaptureActive(bool active)
{
if (active) {
// If we're in full-screen exclusive mode, grab the cursor so it can't accidentally leave our window.
if ((SDL_GetWindowFlags(m_Window) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN) {
// If we're in full-screen desktop mode but system key capture is enabled, also grab the cursor (will grab the keyboard too on X11).
if (((SDL_GetWindowFlags(m_Window) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0 && m_CaptureSystemKeysEnabled) ||
(SDL_GetWindowFlags(m_Window) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN) {
SDL_SetWindowGrab(m_Window, SDL_TRUE);
}
+15
View File
@@ -5,6 +5,11 @@
#include <SDL.h>
#ifdef Q_OS_WIN32
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#endif
#define SDL_CODE_HIDE_CURSOR 1
#define SDL_CODE_SHOW_CURSOR 2
@@ -78,6 +83,8 @@ public:
bool isCaptureActive();
bool isSystemKeyCaptureActive();
void setCaptureActive(bool active);
bool isMouseInVideoRegion(int mouseX, int mouseY, int windowWidth = -1, int windowHeight = -1);
@@ -117,10 +124,17 @@ private:
static
Uint32 dragTimerCallback(Uint32 interval, void* param);
#ifdef Q_OS_WIN32
static
LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam);
#endif
SDL_Window* m_Window;
bool m_MultiController;
bool m_GamepadMouse;
bool m_SwapMouseButtons;
bool m_ReverseScrollDirection;
bool m_SwapFaceButtons;
SDL_TimerID m_MouseMoveTimer;
SDL_atomic_t m_MouseDeltaX;
SDL_atomic_t m_MouseDeltaY;
@@ -140,6 +154,7 @@ private:
bool m_FakeCaptureActive;
QString m_OldIgnoreDevices;
QString m_OldIgnoreDevicesExcept;
bool m_CaptureSystemKeysEnabled;
SDL_TouchFingerEvent m_LastTouchDownEvent;
SDL_TouchFingerEvent m_LastTouchUpEvent;
+38 -10
View File
@@ -5,10 +5,6 @@
#include <QGuiApplication>
// Until we can fully capture these on all platforms (without conflicting with
// OS-provided shortcuts), we should avoid passing them through to the host.
//#define ENABLE_META
#define VK_0 0x30
#define VK_A 0x41
@@ -104,6 +100,20 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
raiseAllKeys();
return;
}
// Check for mouse show combo (Ctrl+Alt+Shift+C)
else if (event->keysym.sym == SDLK_c) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Detected show mouse combo (SDLK)");
if (!SDL_GetRelativeMouseMode()) {
SDL_ShowCursor(!SDL_ShowCursor(SDL_QUERY));
}
else {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Cursor can only be shown in remote desktop mouse mode");
}
return;
}
// Check for quit combo (Ctrl+Alt+Shift+Q)
else if (event->keysym.scancode == SDL_SCANCODE_Q) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
@@ -168,6 +178,20 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
raiseAllKeys();
return;
}
// Check for mouse show combo (Ctrl+Alt+Shift+C)
else if (event->keysym.sym == SDL_SCANCODE_C) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Detected show mouse combo (scancode)");
if (!SDL_GetRelativeMouseMode()) {
SDL_ShowCursor(!SDL_ShowCursor(SDL_QUERY));
}
else {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Cursor can only be shown in remote desktop mouse mode");
}
return;
}
}
if (event->repeat) {
@@ -187,11 +211,11 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
if (event->keysym.mod & KMOD_SHIFT) {
modifiers |= MODIFIER_SHIFT;
}
#ifdef ENABLE_META
if (event->keysym.mod & KMOD_GUI) {
modifiers |= MODIFIER_META;
if (isSystemKeyCaptureActive()) {
modifiers |= MODIFIER_META;
}
}
#endif
// Set keycode. We explicitly use scancode here because GFE will try to correct
// for AZERTY layouts on the host but it depends on receiving VK_ values matching
@@ -332,14 +356,18 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
case SDL_SCANCODE_RALT:
keyCode = 0xA5;
break;
#ifdef ENABLE_META
case SDL_SCANCODE_LGUI:
if (!isSystemKeyCaptureActive()) {
return;
}
keyCode = 0x5B;
break;
case SDL_SCANCODE_RGUI:
if (!isSystemKeyCaptureActive()) {
return;
}
keyCode = 0x5C;
break;
#endif
case SDL_SCANCODE_AC_BACK:
keyCode = 0xA6;
break;
@@ -413,7 +441,7 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
m_KeysDown.remove(keyCode);
}
LiSendKeyboardEvent(keyCode,
LiSendKeyboardEvent(0x8000 | keyCode,
event->state == SDL_PRESSED ?
KEY_ACTION_DOWN : KEY_ACTION_UP,
modifiers);
+5
View File
@@ -204,6 +204,11 @@ void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event)
}
if (event->y != 0) {
// Invert the scroll direction if needed
if (m_ReverseScrollDirection) {
event->y = -event->y;
}
LiSendScrollEvent((signed char)event->y);
}
}
+115 -40
View File
@@ -22,6 +22,8 @@
#define ICON_SIZE 64
#endif
#define SDL_CODE_FLUSH_WINDOW_EVENT_BARRIER 100
#include <openssl/rand.h>
#include <QtEndian>
@@ -73,9 +75,12 @@ void Session::clStageStarting(int stage)
void Session::clStageFailed(int stage, int errorCode)
{
// Perform the port test now, while we're on the async connection thread and not blocking the UI.
s_ActiveSession->m_PortTestResults = LiTestClientConnectivity(CONN_TEST_SERVER, 443, LiGetPortFlagsFromStage(stage));
unsigned int portFlags = LiGetPortFlagsFromStage(stage);
s_ActiveSession->m_PortTestResults = LiTestClientConnectivity(CONN_TEST_SERVER, 443, portFlags);
emit s_ActiveSession->stageFailed(QString::fromLocal8Bit(LiGetStageName(stage)), errorCode);
char failingPorts[128];
LiStringifyPortFlags(portFlags, ", ", failingPorts, sizeof(failingPorts));
emit s_ActiveSession->stageFailed(QString::fromLocal8Bit(LiGetStageName(stage)), errorCode, QString(failingPorts));
#ifndef USE_ASYNC_CONNECT_THREAD
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
@@ -85,7 +90,8 @@ void Session::clStageFailed(int stage, int errorCode)
void Session::clConnectionTerminated(int errorCode)
{
s_ActiveSession->m_PortTestResults = LiTestClientConnectivity(CONN_TEST_SERVER, 443, LiGetPortFlagsFromTerminationErrorCode(errorCode));
unsigned int portFlags = LiGetPortFlagsFromTerminationErrorCode(errorCode);
s_ActiveSession->m_PortTestResults = LiTestClientConnectivity(CONN_TEST_SERVER, 443, portFlags);
// Display the termination dialog if this was not intended
switch (errorCode) {
@@ -94,17 +100,29 @@ void Session::clConnectionTerminated(int errorCode)
case ML_ERROR_NO_VIDEO_TRAFFIC:
s_ActiveSession->m_UnexpectedTermination = true;
emit s_ActiveSession->displayLaunchError("No video received from host. Check the host PC's firewall and port forwarding rules.");
char ports[128];
SDL_assert(portFlags != 0);
LiStringifyPortFlags(portFlags, ", ", ports, sizeof(ports));
emit s_ActiveSession->displayLaunchError(tr("No video received from host.") + "\n\n"+
tr("Check your firewall and port forwarding rules for port(s): %1").arg(ports));
break;
case ML_ERROR_NO_VIDEO_FRAME:
s_ActiveSession->m_UnexpectedTermination = true;
emit s_ActiveSession->displayLaunchError("Your network connection isn't performing well. Reduce your video bitrate setting or try a faster connection.");
emit s_ActiveSession->displayLaunchError(tr("Your network connection isn't performing well. Reduce your video bitrate setting or try a faster connection."));
break;
case ML_ERROR_UNEXPECTED_EARLY_TERMINATION:
s_ActiveSession->m_UnexpectedTermination = true;
emit s_ActiveSession->displayLaunchError(tr("Something went wrong on your host PC when starting the stream.") + "\n\n" +
tr("Make sure you don't have any DRM-protected content open on your host PC. You can also try restarting your host PC.") + "\n\n" +
tr("If the issue persists, try reinstalling your GPU drivers and GeForce Experience."));
break;
default:
s_ActiveSession->m_UnexpectedTermination = true;
emit s_ActiveSession->displayLaunchError("Connection terminated");
emit s_ActiveSession->displayLaunchError(tr("Connection terminated"));
break;
}
@@ -354,6 +372,7 @@ Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *prefere
m_DecoderLock(0),
m_NeedsIdr(false),
m_AudioDisabled(false),
m_AudioMuted(false),
m_DisplayOriginX(0),
m_DisplayOriginY(0),
m_PendingWindowedTransition(false),
@@ -361,6 +380,7 @@ Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *prefere
m_InputHandler(nullptr),
m_InputHandlerLock(0),
m_MouseEmulationRefCount(0),
m_FlushingWindowEventsRef(0),
m_AsyncConnectionSuccess(false),
m_PortTestResults(0),
m_OpusDecoder(nullptr),
@@ -511,6 +531,15 @@ bool Session::initialize()
break;
}
#ifdef Q_OS_DARWIN
// macOS behaves as if we're capturing system keys when
// we enter "real" full-screen mode, so use standard
// full-screen as our full-screen flag when capturing keys.
if (m_Preferences->captureSysKeys) {
m_FullScreenFlag = SDL_WINDOW_FULLSCREEN;
}
#endif
#if !SDL_VERSION_ATLEAST(2, 0, 11)
// HACK: Using a full-screen window breaks mouse capture on the Pi's LXDE
// GUI environment. Force the session to use windowed mode (which won't
@@ -564,24 +593,24 @@ bool Session::validateLaunch(SDL_Window* testWindow)
QStringList warningList;
if (m_Preferences->absoluteMouseMode && !m_App.isAppCollectorGame) {
emitLaunchWarning("Your selection to enable remote desktop mouse mode may cause problems in games.");
emitLaunchWarning(tr("Your selection to enable remote desktop mouse mode may cause problems in games."));
}
if (m_Preferences->videoDecoderSelection == StreamingPreferences::VDS_FORCE_SOFTWARE) {
if (m_Preferences->videoCodecConfig == StreamingPreferences::VCC_FORCE_HEVC_HDR) {
emitLaunchWarning("HDR is not supported with software decoding.");
emitLaunchWarning(tr("HDR is not supported with software decoding."));
m_StreamConfig.enableHdr = false;
}
else {
emitLaunchWarning("Your settings selection to force software decoding may cause poor streaming performance.");
emitLaunchWarning(tr("Your settings selection to force software decoding may cause poor streaming performance."));
}
}
if (m_Preferences->unsupportedFps && m_StreamConfig.fps > 60) {
emitLaunchWarning("Using unsupported FPS options may cause stuttering or lag.");
emitLaunchWarning(tr("Using unsupported FPS options may cause stuttering or lag."));
if (m_Preferences->enableVsync) {
emitLaunchWarning("V-sync will be disabled when streaming at a higher frame rate than the display.");
emitLaunchWarning(tr("V-sync will be disabled when streaming at a higher frame rate than the display."));
}
}
@@ -598,18 +627,18 @@ bool Session::validateLaunch(SDL_Window* testWindow)
m_StreamConfig.height,
m_StreamConfig.fps)) {
if (hevcForced) {
emitLaunchWarning("Using software decoding due to your selection to force HEVC without GPU support. This may cause poor streaming performance.");
emitLaunchWarning(tr("Using software decoding due to your selection to force HEVC without GPU support. This may cause poor streaming performance."));
}
else {
emitLaunchWarning("This PC's GPU doesn't support HEVC decoding.");
emitLaunchWarning(tr("This PC's GPU doesn't support HEVC decoding."));
m_StreamConfig.supportsHevc = false;
}
}
if (hevcForced) {
if (m_Computer->maxLumaPixelsHEVC == 0) {
emitLaunchWarning("Your host PC GPU doesn't support HEVC. "
"A GeForce GTX 900-series (Maxwell) or later GPU is required for HEVC streaming.");
emitLaunchWarning(tr("Your host PC GPU doesn't support HEVC. "
"A GeForce GTX 900-series (Maxwell) or later GPU is required for HEVC streaming."));
// Moonlight-common-c will handle this case already, but we want
// to set this explicitly here so we can do our hardware acceleration
@@ -625,12 +654,12 @@ bool Session::validateLaunch(SDL_Window* testWindow)
// Check that the app supports HDR
if (!m_App.hdrSupported) {
emitLaunchWarning(m_App.name + " doesn't support HDR10.");
emitLaunchWarning(tr("%1 doesn't support HDR10.").arg(m_App.name));
}
// Check that the server GPU supports HDR
else if (!(m_Computer->serverCodecModeSupport & 0x200)) {
emitLaunchWarning("Your host PC GPU doesn't support HDR streaming. "
"A GeForce GTX 1000-series (Pascal) or later GPU is required for HDR streaming.");
emitLaunchWarning(tr("Your host PC GPU doesn't support HDR streaming. "
"A GeForce GTX 1000-series (Pascal) or later GPU is required for HDR streaming."));
}
else if (!isHardwareDecodeAvailable(testWindow,
m_Preferences->videoDecoderSelection,
@@ -638,7 +667,7 @@ bool Session::validateLaunch(SDL_Window* testWindow)
m_StreamConfig.width,
m_StreamConfig.height,
m_StreamConfig.fps)) {
emitLaunchWarning("This PC's GPU doesn't support HEVC Main10 decoding for HDR streaming.");
emitLaunchWarning(tr("This PC's GPU doesn't support HEVC Main10 decoding for HDR streaming."));
}
else {
// TODO: Also validate display capabilites
@@ -651,7 +680,7 @@ bool Session::validateLaunch(SDL_Window* testWindow)
if (m_StreamConfig.width >= 3840) {
// Only allow 4K on GFE 3.x+
if (m_Computer->gfeVersion.isEmpty() || m_Computer->gfeVersion.startsWith("2.")) {
emitLaunchWarning("GeForce Experience 3.0 or higher is required for 4K streaming.");
emitLaunchWarning(tr("GeForce Experience 3.0 or higher is required for 4K streaming."));
m_StreamConfig.width = 1920;
m_StreamConfig.height = 1080;
@@ -666,29 +695,31 @@ bool Session::validateLaunch(SDL_Window* testWindow)
audioTestPassed = testAudio(AUDIO_CONFIGURATION_STEREO);
if (audioTestPassed) {
m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_STEREO;
emitLaunchWarning("Your selected surround sound setting is not supported by the current audio device.");
emitLaunchWarning(tr("Your selected surround sound setting is not supported by the current audio device."));
}
}
// If nothing worked, warn the user that audio will not work
m_AudioDisabled = !audioTestPassed;
if (m_AudioDisabled) {
emitLaunchWarning("Failed to open audio device. Audio will be unavailable during this session.");
emitLaunchWarning(tr("Failed to open audio device. Audio will be unavailable during this session."));
}
// Check for unmapped gamepads
if (!SdlInputHandler::getUnmappedGamepads().isEmpty()) {
emitLaunchWarning("An attached gamepad has no mapping and won't be usable. Visit the Moonlight help to resolve this.");
emitLaunchWarning(tr("An attached gamepad has no mapping and won't be usable. Visit the Moonlight help to resolve this."));
}
// NVENC will fail to initialize when using dimensions over 4096 and H.264.
if (m_StreamConfig.width > 4096 || m_StreamConfig.height > 4096) {
if (m_Computer->maxLumaPixelsHEVC == 0) {
emit displayLaunchError("Your host PC's GPU doesn't support streaming video resolutions over 4K.");
// Pascal added support for 8K HEVC encoding support. Maxwell 2 could encode HEVC but only up to 4K.
// We can't directly identify Pascal, but we can look for HEVC Main10 which was added in the same generation.
if (m_Computer->maxLumaPixelsHEVC == 0 || !(m_Computer->serverCodecModeSupport & 0x200)) {
emit displayLaunchError(tr("Your host PC's GPU doesn't support streaming video resolutions over 4K."));
return false;
}
else if (!m_StreamConfig.supportsHevc) {
emit displayLaunchError("Video resolutions over 4K are only supported by the HEVC codec.");
emit displayLaunchError(tr("Video resolutions over 4K are only supported by the HEVC codec."));
return false;
}
}
@@ -702,10 +733,10 @@ bool Session::validateLaunch(SDL_Window* testWindow)
m_StreamConfig.height,
m_StreamConfig.fps)) {
if (m_Preferences->videoCodecConfig == StreamingPreferences::VCC_AUTO) {
emit displayLaunchError("Your selection to force hardware decoding cannot be satisfied due to missing hardware decoding support on this PC's GPU.");
emit displayLaunchError(tr("Your selection to force hardware decoding cannot be satisfied due to missing hardware decoding support on this PC's GPU."));
}
else {
emit displayLaunchError("Your codec selection and force hardware decoding setting are not compatible. This PC's GPU lacks support for decoding your chosen codec.");
emit displayLaunchError(tr("Your codec selection and force hardware decoding setting are not compatible. This PC's GPU lacks support for decoding your chosen codec."));
}
// Fail the launch, because we won't manage to get a decoder for the actual stream
@@ -913,8 +944,10 @@ void Session::toggleFullscreen()
bool fullScreen = !(SDL_GetWindowFlags(m_Window) & m_FullScreenFlag);
if (fullScreen) {
if (m_FullScreenFlag == SDL_WINDOW_FULLSCREEN && m_InputHandler->isCaptureActive()) {
// Confine the cursor to the window if we're capturing input
if ((m_FullScreenFlag == SDL_WINDOW_FULLSCREEN || m_Preferences->captureSysKeys) && m_InputHandler->isCaptureActive()) {
// Confine the cursor to the window if we're capturing input while transitioning to full screen.
// We also need to grab if we're capturing system keys, because SDL requires window grab to
// capture the keyboard on X11.
SDL_SetWindowGrab(m_Window, SDL_TRUE);
}
@@ -1013,7 +1046,7 @@ bool Session::startConnectionAsync()
m_InputHandler->getAttachedGamepadMask());
}
} catch (const GfeHttpResponseException& e) {
emit displayLaunchError("GeForce Experience returned error: " + e.toQString());
emit displayLaunchError(tr("GeForce Experience returned error: %1").arg(e.toQString()));
return false;
} catch (const QtNetworkReplyException& e) {
emit displayLaunchError(e.toQString());
@@ -1074,6 +1107,23 @@ bool Session::startConnectionAsync()
return true;
}
void Session::flushWindowEvents()
{
// Pump events to ensure all pending OS events are posted
SDL_PumpEvents();
// Insert a barrier to discard any additional window events.
// We don't use SDL_FlushEvent() here because it could cause
// important events to be lost.
m_FlushingWindowEventsRef++;
// This event will cause us to set m_FlushingWindowEvents back to false.
SDL_Event flushEvent = {};
flushEvent.type = SDL_USEREVENT;
flushEvent.user.code = SDL_CODE_FLUSH_WINDOW_EVENT_BARRIER;
SDL_PushEvent(&flushEvent);
}
void Session::exec(int displayOriginX, int displayOriginY)
{
m_DisplayOriginX = displayOriginX;
@@ -1294,17 +1344,31 @@ void Session::exec(int displayOriginX, int displayOriginY)
case SDL_CODE_SHOW_CURSOR:
SDL_ShowCursor(SDL_ENABLE);
break;
case SDL_CODE_FLUSH_WINDOW_EVENT_BARRIER:
m_FlushingWindowEventsRef--;
break;
default:
SDL_assert(false);
}
break;
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
// Early handling of some events
switch (event.window.event) {
case SDL_WINDOWEVENT_FOCUS_LOST:
if (m_Preferences->muteOnFocusLoss) {
m_AudioMuted = true;
}
m_InputHandler->notifyFocusLost();
}
else if (event.window.event == SDL_WINDOWEVENT_LEAVE) {
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
if (m_Preferences->muteOnFocusLoss) {
m_AudioMuted = false;
}
break;
case SDL_WINDOWEVENT_LEAVE:
m_InputHandler->notifyMouseLeave();
break;
}
// Capture the mouse on SDL_WINDOWEVENT_ENTER if needed
@@ -1339,6 +1403,16 @@ void Session::exec(int displayOriginX, int displayOriginY)
SDL_SetWindowPosition(m_Window, x, y);
}
if (m_FlushingWindowEventsRef > 0) {
// Ignore window events for renderer reset if flushing
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Dropping window event during flush: %d (%d %d)",
event.window.event,
event.window.data1,
event.window.data2);
break;
}
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Recreating renderer for window event: %d (%d %d)",
event.window.event,
@@ -1354,10 +1428,11 @@ void Session::exec(int displayOriginX, int displayOriginY)
// Destroy the old decoder
delete m_VideoDecoder;
// Flush any other pending window events that could
// send us back here immediately
SDL_PumpEvents();
SDL_FlushEvent(SDL_WINDOWEVENT);
// Insert a barrier to discard any additional window events
// that could cause the renderer to be and recreated again.
// We don't use SDL_FlushEvent() here because it could cause
// important events to be lost.
flushWindowEvents();
// Update the window display mode based on our current monitor
currentDisplayIndex = SDL_GetWindowDisplayIndex(m_Window);
@@ -1394,7 +1469,7 @@ void Session::exec(int displayOriginX, int displayOriginY)
SDL_AtomicUnlock(&m_DecoderLock);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Failed to recreate decoder after reset");
emit displayLaunchError("Unable to initialize video decoder. Please check your streaming settings and try again.");
emit displayLaunchError(tr("Unable to initialize video decoder. Please check your streaming settings and try again."));
goto DispatchDeferredCleanup;
}
@@ -1403,7 +1478,7 @@ void Session::exec(int displayOriginX, int displayOriginY)
// is set up, this ensures the window re-creation is already done.
if (needsPostDecoderCreationCapture) {
m_InputHandler->setCaptureActive(true);
needsFirstEnterCapture = false;
needsPostDecoderCreationCapture = false;
}
}
+5 -1
View File
@@ -39,10 +39,12 @@ public:
return m_OverlayManager;
}
void flushWindowEvents();
signals:
void stageStarting(QString stage);
void stageFailed(QString stage, int errorCode);
void stageFailed(QString stage, int errorCode, QString failingPorts);
void connectionStarted();
@@ -141,6 +143,7 @@ private:
SDL_SpinLock m_DecoderLock;
bool m_NeedsIdr;
bool m_AudioDisabled;
bool m_AudioMuted;
Uint32 m_FullScreenFlag;
int m_DisplayOriginX;
int m_DisplayOriginY;
@@ -149,6 +152,7 @@ private:
SdlInputHandler* m_InputHandler;
SDL_SpinLock m_InputHandlerLock;
int m_MouseEmulationRefCount;
int m_FlushingWindowEventsRef;
bool m_AsyncConnectionSuccess;
int m_PortTestResults;
+252 -86
View File
@@ -1,3 +1,7 @@
// minwindef.h defines min() and max() macros that conflict with
// std::numeric_limits, which Qt uses in some of its headers.
#define NOMINMAX
#include <initguid.h>
#include "dxva2.h"
#include "../ffmpeg.h"
@@ -17,23 +21,31 @@ DEFINE_GUID(DXVADDI_Intel_ModeH264_E, 0x604F8E68,0x4951,0x4C54,0x88,0xFE,0xAB,0x
#define SAFE_COM_RELEASE(x) if (x) { (x)->Release(); }
typedef struct _VERTEX
{
float x, y, z, rhw;
float tu, tv;
} VERTEX, *PVERTEX;
DXVA2Renderer::DXVA2Renderer() :
m_DecService(nullptr),
m_Decoder(nullptr),
m_SurfacesUsed(0),
m_Pool(nullptr),
m_OverlayLock(0),
m_Device(nullptr),
m_RenderTarget(nullptr),
m_ProcService(nullptr),
m_Processor(nullptr),
m_FrameIndex(0),
m_DebugOverlayFont(nullptr),
m_StatusOverlayFont(nullptr),
m_BlockingPresent(false)
{
RtlZeroMemory(m_DecSurfaces, sizeof(m_DecSurfaces));
RtlZeroMemory(&m_DXVAContext, sizeof(m_DXVAContext));
RtlZeroMemory(m_OverlayVertexBuffers, sizeof(m_OverlayVertexBuffers));
RtlZeroMemory(m_OverlayTextures, sizeof(m_OverlayTextures));
// Use MMCSS scheduling for lower scheduling latency while we're streaming
DwmEnableMMCSS(TRUE);
}
@@ -48,8 +60,14 @@ DXVA2Renderer::~DXVA2Renderer()
SAFE_COM_RELEASE(m_RenderTarget);
SAFE_COM_RELEASE(m_ProcService);
SAFE_COM_RELEASE(m_Processor);
SAFE_COM_RELEASE(m_DebugOverlayFont);
SAFE_COM_RELEASE(m_StatusOverlayFont);
for (int i = 0; i < ARRAYSIZE(m_OverlayVertexBuffers); i++) {
SAFE_COM_RELEASE(m_OverlayVertexBuffers[i]);
}
for (int i = 0; i < ARRAYSIZE(m_OverlayTextures); i++) {
SAFE_COM_RELEASE(m_OverlayTextures[i]);
}
for (int i = 0; i < ARRAYSIZE(m_DecSurfaces); i++) {
SAFE_COM_RELEASE(m_DecSurfaces[i]);
@@ -323,6 +341,23 @@ bool DXVA2Renderer::initializeRenderer()
}
}
m_Device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
m_Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
m_Device->SetRenderState(D3DRS_LIGHTING, FALSE);
m_Device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
m_Device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_Device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
m_Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
m_Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
m_Device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
m_Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
m_Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
m_Device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
return true;
}
@@ -347,15 +382,28 @@ bool DXVA2Renderer::isDXVideoProcessorAPIBlacklisted()
D3DADAPTER_IDENTIFIER9 id;
hr = d3d9->GetAdapterIdentifier(caps.AdapterOrdinal, 0, &id);
if (SUCCEEDED(hr) && id.VendorId == 0x8086) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Avoiding IDirectXVideoProcessor API on Intel GPU");
if (SUCCEEDED(hr)) {
if (id.VendorId == 0x8086) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Avoiding IDirectXVideoProcessor API on Intel GPU");
// On Intel GPUs, we can get unwanted video "enhancements" due to post-processing
// effects that the GPU driver forces on us. In many cases, this makes the video
// actually look worse. We can avoid these by using StretchRect() instead on these
// platforms.
result = true;
// On Intel GPUs, we can get unwanted video "enhancements" due to post-processing
// effects that the GPU driver forces on us. In many cases, this makes the video
// actually look worse. We can avoid these by using StretchRect() instead on these
// platforms.
result = true;
}
else if (id.VendorId == 0x4d4f4351) { // QCOM in ASCII
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Avoiding IDirectXVideoProcessor API on Qualcomm GPU");
// On Qualcomm GPUs (all D3D9on12 GPUs?), the scaling quality of VideoProcessBlt()
// is absolutely horrible. StretchRect() is much much better.
result = true;
}
else {
result = false;
}
}
else {
result = false;
@@ -742,64 +790,201 @@ void DXVA2Renderer::notifyOverlayUpdated(Overlay::OverlayType type)
{
HRESULT hr;
switch (type)
{
case Overlay::OverlayDebug:
if (m_DebugOverlayFont == nullptr) {
hr = D3DXCreateFontA(m_Device,
Session::get()->getOverlayManager().getOverlayFontSize(Overlay::OverlayDebug),
0,
FW_HEAVY,
1,
false,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE,
"",
&m_DebugOverlayFont);
if (FAILED(hr)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"D3DXCreateFontA() failed: %x",
hr);
m_DebugOverlayFont = nullptr;
}
}
break;
case Overlay::OverlayStatusUpdate:
if (m_StatusOverlayFont == nullptr) {
hr = D3DXCreateFontA(m_Device,
Session::get()->getOverlayManager().getOverlayFontSize(Overlay::OverlayStatusUpdate),
0,
FW_HEAVY,
1,
false,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE,
"",
&m_StatusOverlayFont);
if (FAILED(hr)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"D3DXCreateFontA() failed: %x",
hr);
m_StatusOverlayFont = nullptr;
}
}
break;
default:
SDL_assert(false);
break;
SDL_Surface* newSurface = Session::get()->getOverlayManager().getUpdatedOverlaySurface(type);
if (newSurface == nullptr && Session::get()->getOverlayManager().isOverlayEnabled(type)) {
// The overlay is enabled and there is no new surface. Leave the old texture alone.
return;
}
SDL_AtomicLock(&m_OverlayLock);
IDirect3DTexture9* oldTexture = m_OverlayTextures[type];
m_OverlayTextures[type] = nullptr;
IDirect3DVertexBuffer9* oldVertexBuffer = m_OverlayVertexBuffers[type];
m_OverlayVertexBuffers[type] = nullptr;
SDL_AtomicUnlock(&m_OverlayLock);
SAFE_COM_RELEASE(oldTexture);
SAFE_COM_RELEASE(oldVertexBuffer);
// If the overlay is disabled, we're done
if (!Session::get()->getOverlayManager().isOverlayEnabled(type)) {
SDL_FreeSurface(newSurface);
return;
}
// Create a dynamic texture to populate with our pixel data
SDL_assert(!SDL_MUSTLOCK(newSurface));
IDirect3DTexture9* newTexture = nullptr;
hr = m_Device->CreateTexture(newSurface->w,
newSurface->h,
1,
D3DUSAGE_DYNAMIC,
D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT,
&newTexture,
nullptr);
if (FAILED(hr)) {
SDL_FreeSurface(newSurface);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"CreateTexture() failed: %x",
hr);
return;
}
D3DLOCKED_RECT lockedRect;
hr = newTexture->LockRect(0, &lockedRect, nullptr, D3DLOCK_DISCARD);
if (FAILED(hr)) {
SDL_FreeSurface(newSurface);
SAFE_COM_RELEASE(newTexture);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"IDirect3DTexture9::LockRect() failed: %x",
hr);
return;
}
if (newSurface->pitch == lockedRect.Pitch) {
// If the pitch matches, we can take the fast path and use a single copy to transfer the pixels
RtlCopyMemory(lockedRect.pBits, newSurface->pixels, newSurface->pitch * newSurface->h);
}
else {
// If the pitch doesn't match, we'll need to copy each row separately
int pitch = SDL_min(newSurface->pitch, lockedRect.Pitch);
for (int i = 0; i < newSurface->h; i++) {
RtlCopyMemory(((PUCHAR)lockedRect.pBits) + (lockedRect.Pitch * i),
((PUCHAR)newSurface->pixels) + (newSurface->pitch * i),
pitch);
}
}
newTexture->UnlockRect(0);
SDL_FRect renderRect = {};
if (type == Overlay::OverlayStatusUpdate) {
// Bottom Left
renderRect.x = 0;
renderRect.y = m_DisplayHeight - newSurface->h;
}
else if (type == Overlay::OverlayDebug) {
// Top left
renderRect.x = 0;
renderRect.y = 0;
}
renderRect.w = newSurface->w;
renderRect.h = newSurface->h;
// The surface is no longer required
SDL_FreeSurface(newSurface);
newSurface = nullptr;
VERTEX verts[] =
{
{renderRect.x, renderRect.y, 0, 1, 0, 0},
{renderRect.x, renderRect.y+renderRect.h, 0, 1, 0, 1},
{renderRect.x+renderRect.w, renderRect.y+renderRect.h, 0, 1, 1, 1},
{renderRect.x+renderRect.w, renderRect.y, 0, 1, 1, 0}
};
IDirect3DVertexBuffer9* newVertexBuffer = nullptr;
hr = m_Device->CreateVertexBuffer(sizeof(verts),
D3DUSAGE_WRITEONLY,
D3DFVF_XYZRHW | D3DFVF_TEX1,
D3DPOOL_DEFAULT,
&newVertexBuffer,
nullptr);
if (FAILED(hr)) {
SAFE_COM_RELEASE(newTexture);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"CreateVertexBuffer() failed: %x",
hr);
return;
}
PVOID targetVertexBuffer = nullptr;
hr = newVertexBuffer->Lock(0, 0, &targetVertexBuffer, 0);
if (FAILED(hr)) {
SAFE_COM_RELEASE(newTexture);
SAFE_COM_RELEASE(newVertexBuffer);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"IDirect3DVertexBuffer9::Lock() failed: %x",
hr);
return;
}
RtlCopyMemory(targetVertexBuffer, verts, sizeof(verts));
newVertexBuffer->Unlock();
SDL_AtomicLock(&m_OverlayLock);
m_OverlayVertexBuffers[type] = newVertexBuffer;
m_OverlayTextures[type] = newTexture;
SDL_AtomicUnlock(&m_OverlayLock);
}
void DXVA2Renderer::renderOverlay(Overlay::OverlayType type)
{
HRESULT hr;
if (!Session::get()->getOverlayManager().isOverlayEnabled(type)) {
return;
}
// If the overlay is being updated, just skip rendering it this frame
if (!SDL_AtomicTryLock(&m_OverlayLock)) {
return;
}
IDirect3DTexture9* overlayTexture = m_OverlayTextures[type];
IDirect3DVertexBuffer9* overlayVertexBuffer = m_OverlayVertexBuffers[type];
if (overlayTexture == nullptr) {
SDL_AtomicUnlock(&m_OverlayLock);
return;
}
// Reference these objects so they don't immediately go away if the
// overlay update thread tries to release them.
SDL_assert(overlayVertexBuffer != nullptr);
overlayTexture->AddRef();
overlayVertexBuffer->AddRef();
SDL_AtomicUnlock(&m_OverlayLock);
hr = m_Device->SetTexture(0, overlayTexture);
if (FAILED(hr)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SetTexture() failed: %x",
hr);
goto Exit;
}
hr = m_Device->SetStreamSource(0, overlayVertexBuffer, 0, sizeof(VERTEX));
if (FAILED(hr)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SetStreamSource() failed: %x",
hr);
goto Exit;
}
hr = m_Device->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
if (FAILED(hr)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"DrawPrimitive() failed: %x",
hr);
goto Exit;
}
Exit:
overlayTexture->Release();
overlayVertexBuffer->Release();
}
int DXVA2Renderer::getDecoderColorspace()
{
if (isDXVideoProcessorAPIBlacklisted()) {
// StretchRect() assumes Rec 601 on Intel GPUs
// StretchRect() assumes Rec 601 on Intel and Qualcomm GPUs.
return COLORSPACE_REC_601;
}
else {
@@ -998,28 +1183,9 @@ void DXVA2Renderer::renderFrame(AVFrame *frame)
}
}
if (m_DebugOverlayFont != nullptr) {
if (Session::get()->getOverlayManager().isOverlayEnabled(Overlay::OverlayDebug)) {
SDL_Color color = Session::get()->getOverlayManager().getOverlayColor(Overlay::OverlayDebug);
m_DebugOverlayFont->DrawTextA(nullptr,
Session::get()->getOverlayManager().getOverlayText(Overlay::OverlayDebug),
-1,
&sample.DstRect,
DT_LEFT | DT_NOCLIP,
D3DCOLOR_ARGB(color.a, color.r, color.g, color.b));
}
}
if (m_StatusOverlayFont != nullptr) {
if (Session::get()->getOverlayManager().isOverlayEnabled(Overlay::OverlayStatusUpdate)) {
SDL_Color color = Session::get()->getOverlayManager().getOverlayColor(Overlay::OverlayStatusUpdate);
m_StatusOverlayFont->DrawTextA(nullptr,
Session::get()->getOverlayManager().getOverlayText(Overlay::OverlayStatusUpdate),
-1,
&sample.DstRect,
DT_RIGHT | DT_NOCLIP,
D3DCOLOR_ARGB(color.a, color.r, color.g, color.b));
}
// Render overlays on top of the video stream
for (int i = 0; i < Overlay::OverlayMax; i++) {
renderOverlay((Overlay::OverlayType)i);
}
hr = m_Device->EndScene();
+6 -4
View File
@@ -4,7 +4,6 @@
#include "pacer/pacer.h"
#include <d3d9.h>
#include <d3dx9.h>
#include <dxva2api.h>
extern "C" {
@@ -19,7 +18,7 @@ public:
virtual bool initialize(PDECODER_PARAMETERS params) override;
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
virtual void renderFrame(AVFrame* frame) override;
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
virtual void notifyOverlayUpdated(Overlay::OverlayType type) override;
virtual int getDecoderColorspace() override;
private:
@@ -28,6 +27,7 @@ private:
bool initializeDevice(SDL_Window* window, bool enableVsync);
bool isDecoderBlacklisted();
bool isDXVideoProcessorAPIBlacklisted();
void renderOverlay(Overlay::OverlayType type);
static
AVBufferRef* ffPoolAlloc(void* opaque, int size);
@@ -53,6 +53,10 @@ private:
int m_SurfacesUsed;
AVBufferPool* m_Pool;
SDL_SpinLock m_OverlayLock;
IDirect3DVertexBuffer9* m_OverlayVertexBuffers[Overlay::OverlayMax];
IDirect3DTexture9* m_OverlayTextures[Overlay::OverlayMax];
IDirect3DDevice9Ex* m_Device;
IDirect3DSurface9* m_RenderTarget;
IDirectXVideoProcessorService* m_ProcService;
@@ -63,7 +67,5 @@ private:
DXVA2_ValueRange m_SaturationRange;
DXVA2_VideoDesc m_Desc;
REFERENCE_TIME m_FrameIndex;
LPD3DXFONT m_DebugOverlayFont;
LPD3DXFONT m_StatusOverlayFont;
bool m_BlockingPresent;
};
+204 -45
View File
@@ -35,6 +35,12 @@ typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platf
#define EGL_PLATFORM_X11_KHR 0x31D5
#endif
typedef struct _OVERLAY_VERTEX
{
float x, y;
float u, v;
} OVERLAY_VERTEX, *POVERLAY_VERTEX;
/* TODO:
* - handle more pixel formats
* - handle software decoding
@@ -65,7 +71,11 @@ EGLRenderer::EGLRenderer(IFFmpegRenderer *backendRenderer)
m_SwPixelFormat(AV_PIX_FMT_NONE),
m_EGLDisplay(EGL_NO_DISPLAY),
m_Textures{0},
m_OverlayTextures{0},
m_OverlayVbos{0},
m_OverlayHasValidData{},
m_ShaderProgram(0),
m_OverlayShaderProgram(0),
m_Context(0),
m_Window(nullptr),
m_Backend(backendRenderer),
@@ -96,10 +106,26 @@ EGLRenderer::~EGLRenderer()
if (m_ShaderProgram) {
glDeleteProgram(m_ShaderProgram);
}
if (m_OverlayShaderProgram) {
glDeleteProgram(m_OverlayShaderProgram);
}
if (m_VAO) {
SDL_assert(m_glDeleteVertexArraysOES != nullptr);
m_glDeleteVertexArraysOES(1, &m_VAO);
}
for (int i = 0; i < EGL_MAX_PLANES; i++) {
if (m_Textures[i] != 0) {
glDeleteTextures(1, &m_Textures[i]);
}
}
for (int i = 0; i < Overlay::OverlayMax; i++) {
if (m_OverlayTextures[i] != 0) {
glDeleteTextures(1, &m_OverlayTextures[i]);
}
if (m_OverlayVbos[i] != 0) {
glDeleteBuffers(1, &m_OverlayVbos[i]);
}
}
SDL_GL_DeleteContext(m_Context);
}
@@ -123,9 +149,17 @@ bool EGLRenderer::prepareDecoderContext(AVCodecContext*, AVDictionary**)
return true;
}
void EGLRenderer::notifyOverlayUpdated(Overlay::OverlayType)
void EGLRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
{
// TODO: FIXME
// We handle uploading the updated overlay texture in renderOverlay().
// notifyOverlayUpdated() is called on an arbitrary thread, which may
// not be have the OpenGL context current on it.
if (!Session::get()->getOverlayManager().isOverlayEnabled(type)) {
// If the overlay has been disabled, mark the data as invalid/stale.
SDL_AtomicSet(&m_OverlayHasValidData[type], 0);
return;
}
}
bool EGLRenderer::isPixelFormatSupported(int, AVPixelFormat pixelFormat)
@@ -140,6 +174,91 @@ bool EGLRenderer::isPixelFormatSupported(int, AVPixelFormat pixelFormat)
}
}
void EGLRenderer::renderOverlay(Overlay::OverlayType type)
{
// Do nothing if this overlay is disabled
if (!Session::get()->getOverlayManager().isOverlayEnabled(type)) {
return;
}
// Upload a new overlay texture if needed
SDL_Surface* newSurface = Session::get()->getOverlayManager().getUpdatedOverlaySurface(type);
if (newSurface != nullptr) {
SDL_assert(!SDL_MUSTLOCK(newSurface));
glBindTexture(GL_TEXTURE_2D, m_OverlayTextures[type]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, newSurface->w, newSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, newSurface->pixels);
// SDL_FRect wasn't added until 2.0.10
struct {
float x;
float y;
float w;
float h;
} overlayRect;
// These overlay positions differ from the other renderers because OpenGL
// places the origin in the lower-left corner instead of the upper-left.
if (type == Overlay::OverlayStatusUpdate) {
// Bottom Left
overlayRect.x = 0;
overlayRect.y = 0;
}
else if (type == Overlay::OverlayDebug) {
// Top left
overlayRect.x = 0;
overlayRect.y = m_ViewportHeight - newSurface->h;
}
overlayRect.w = newSurface->w;
overlayRect.h = newSurface->h;
SDL_FreeSurface(newSurface);
// Convert screen space to normalized device coordinates
overlayRect.x /= m_ViewportWidth / 2;
overlayRect.w /= m_ViewportWidth / 2;
overlayRect.y /= m_ViewportHeight / 2;
overlayRect.h /= m_ViewportHeight / 2;
overlayRect.x -= 1.0f;
overlayRect.y -= 1.0f;
OVERLAY_VERTEX verts[] =
{
{overlayRect.x + overlayRect.w, overlayRect.y + overlayRect.h, 1.0f, 0.0f},
{overlayRect.x, overlayRect.y + overlayRect.h, 0.0f, 0.0f},
{overlayRect.x, overlayRect.y, 0.0f, 1.0f},
{overlayRect.x, overlayRect.y, 0.0f, 1.0f},
{overlayRect.x + overlayRect.w, overlayRect.y, 1.0f, 1.0f},
{overlayRect.x + overlayRect.w, overlayRect.y + overlayRect.h, 1.0f, 0.0f}
};
glBindBuffer(GL_ARRAY_BUFFER, m_OverlayVbos[type]);
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
SDL_AtomicSet(&m_OverlayHasValidData[type], 1);
}
if (!SDL_AtomicGet(&m_OverlayHasValidData[type])) {
// If the overlay is not populated yet or is stale, don't render it.
return;
}
glUseProgram(m_OverlayShaderProgram);
glBindBuffer(GL_ARRAY_BUFFER, m_OverlayVbos[type]);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(OVERLAY_VERTEX), (void*)offsetof(OVERLAY_VERTEX, x));
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(OVERLAY_VERTEX), (void*)offsetof(OVERLAY_VERTEX, u));
glEnableVertexAttribArray(1);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_OverlayTextures[type]);
glUniform1i(m_OverlayShaderProgramParams[PARAM_TEXTURE], 0);
glDrawArrays(GL_TRIANGLES, 0, 6);
}
int EGLRenderer::loadAndBuildShader(int shaderType,
const char *file) {
GLuint shader = glCreateShader(shaderType);
@@ -214,49 +333,70 @@ bool EGLRenderer::openDisplay(unsigned int platform, void* nativeDisplay)
return m_EGLDisplay != EGL_NO_DISPLAY;
}
bool EGLRenderer::compileShader() {
SDL_assert(!m_ShaderProgram);
SDL_assert(m_SwPixelFormat != AV_PIX_FMT_NONE);
unsigned EGLRenderer::compileShader(const char* vertexShaderSrc, const char* fragmentShaderSrc) {
unsigned shader = 0;
// XXX: TODO: other formats
SDL_assert(m_SwPixelFormat == AV_PIX_FMT_NV12);
bool ret = false;
GLuint vertexShader = loadAndBuildShader(GL_VERTEX_SHADER, "egl.vert");
GLuint vertexShader = loadAndBuildShader(GL_VERTEX_SHADER, vertexShaderSrc);
if (!vertexShader)
return false;
GLuint fragmentShader = loadAndBuildShader(GL_FRAGMENT_SHADER, "egl.frag");
GLuint fragmentShader = loadAndBuildShader(GL_FRAGMENT_SHADER, fragmentShaderSrc);
if (!fragmentShader)
goto fragError;
m_ShaderProgram = glCreateProgram();
if (!m_ShaderProgram) {
shader = glCreateProgram();
if (!shader) {
EGL_LOG(Error, "Cannot create shader program");
goto progFailCreate;
}
glAttachShader(m_ShaderProgram, vertexShader);
glAttachShader(m_ShaderProgram, fragmentShader);
glLinkProgram(m_ShaderProgram);
glAttachShader(shader, vertexShader);
glAttachShader(shader, fragmentShader);
glLinkProgram(shader);
int status;
glGetProgramiv(m_ShaderProgram, GL_LINK_STATUS, &status);
if (status) {
ret = true;
} else {
glGetProgramiv(shader, GL_LINK_STATUS, &status);
if (!status) {
char shader_log[512];
glGetProgramInfoLog(m_ShaderProgram, sizeof (shader_log), nullptr, shader_log);
glGetProgramInfoLog(shader, sizeof (shader_log), nullptr, shader_log);
EGL_LOG(Error, "Cannot link shader program: %s", shader_log);
glDeleteProgram(m_ShaderProgram);
m_ShaderProgram = 0;
glDeleteProgram(shader);
shader = 0;
}
progFailCreate:
glDeleteShader(fragmentShader);
fragError:
glDeleteShader(vertexShader);
return ret;
return shader;
}
bool EGLRenderer::compileShaders() {
SDL_assert(!m_ShaderProgram);
SDL_assert(!m_OverlayShaderProgram);
SDL_assert(m_SwPixelFormat != AV_PIX_FMT_NONE);
// XXX: TODO: other formats
SDL_assert(m_SwPixelFormat == AV_PIX_FMT_NV12);
m_ShaderProgram = compileShader("egl.vert", "egl.frag");
if (!m_ShaderProgram) {
return false;
}
m_ShaderProgramParams[PARAM_YUVMAT] = glGetUniformLocation(m_ShaderProgram, "yuvmat");
m_ShaderProgramParams[PARAM_OFFSET] = glGetUniformLocation(m_ShaderProgram, "offset");
m_ShaderProgramParams[PARAM_PLANE1] = glGetUniformLocation(m_ShaderProgram, "plane1");
m_ShaderProgramParams[PARAM_PLANE2] = glGetUniformLocation(m_ShaderProgram, "plane2");
m_OverlayShaderProgram = compileShader("egl_overlay.vert", "egl_overlay.frag");
if (!m_OverlayShaderProgram) {
return false;
}
m_OverlayShaderProgramParams[PARAM_TEXTURE] = glGetUniformLocation(m_OverlayShaderProgram, "uTexture");
return true;
}
bool EGLRenderer::initialize(PDECODER_PARAMETERS params)
@@ -409,6 +549,9 @@ bool EGLRenderer::initialize(PDECODER_PARAMETERS params)
glViewport(dst.x, dst.y, dst.w, dst.h);
m_ViewportWidth = dst.w;
m_ViewportHeight = dst.h;
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
@@ -430,6 +573,19 @@ bool EGLRenderer::initialize(PDECODER_PARAMETERS params)
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
glGenBuffers(Overlay::OverlayMax, m_OverlayVbos);
glGenTextures(Overlay::OverlayMax, m_OverlayTextures);
for (size_t i = 0; i < Overlay::OverlayMax; ++i) {
glBindTexture(GL_TEXTURE_2D, m_OverlayTextures[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GLenum err = glGetError();
if (err != GL_NO_ERROR)
EGL_LOG(Error, "OpenGL error: %d", err);
@@ -440,6 +596,13 @@ bool EGLRenderer::initialize(PDECODER_PARAMETERS params)
return err == GL_NO_ERROR;
}
const float *EGLRenderer::getColorOffsets() {
static const float limitedOffsets[] = { 16.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f };
static const float fullOffsets[] = { 0.0f, 128.0f / 255.0f, 128.0f / 255.0f };
return m_ColorFull ? fullOffsets : limitedOffsets;
}
const float *EGLRenderer::getColorMatrix() {
/* The conversion matrices are shamelessly stolen from linux:
* drivers/media/platform/imx-pxp.c:pxp_setup_csc
@@ -478,18 +641,16 @@ const float *EGLRenderer::getColorMatrix() {
switch (m_ColorSpace) {
case AVCOL_SPC_SMPTE170M:
case AVCOL_SPC_BT470BG:
EGL_LOG(Info, "BT-601 pixels");
return m_ColorFull ? bt601Full : bt601Lim;
case AVCOL_SPC_BT709:
EGL_LOG(Info, "BT-709 pixels");
return m_ColorFull ? bt709Full : bt709Lim;
case AVCOL_SPC_BT2020_NCL:
case AVCOL_SPC_BT2020_CL:
EGL_LOG(Info, "BT-2020 pixels");
return m_ColorFull ? bt2020Full : bt2020Lim;
default:
SDL_assert(false);
};
EGL_LOG(Warn, "unknown color space: %d, falling back to BT-601",
m_ColorSpace);
return bt601Lim;
}
@@ -499,7 +660,7 @@ bool EGLRenderer::specialize() {
// Attach our GL context to the render thread
SDL_GL_MakeCurrent(m_Window, m_Context);
if (!compileShader())
if (!compileShaders())
return false;
// The viewport should have the aspect ratio of the video stream
@@ -539,20 +700,6 @@ bool EGLRenderer::specialize() {
glBindBuffer(GL_ARRAY_BUFFER, 0);
m_glBindVertexArrayOES(0);
int yuvmatLocation = glGetUniformLocation(m_ShaderProgram, "yuvmat");
glUniformMatrix3fv(yuvmatLocation, 1, GL_FALSE, getColorMatrix());
static const float limitedOffsets[] = { 16.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f };
static const float fullOffsets[] = { 0.0f, 128.0f / 255.0f, 128.0f / 255.0f };
int offLocation = glGetUniformLocation(m_ShaderProgram, "offset");
glUniform3fv(offLocation, 1, m_ColorFull ? fullOffsets : limitedOffsets);
int colorPlane = glGetUniformLocation(m_ShaderProgram, "plane1");
glUniform1i(colorPlane, 0);
colorPlane = glGetUniformLocation(m_ShaderProgram, "plane2");
glUniform1i(colorPlane, 1);
glDeleteBuffers(1, &VBO);
glDeleteBuffers(1, &EBO);
@@ -612,8 +759,20 @@ void EGLRenderer::renderFrame(AVFrame* frame)
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(m_ShaderProgram);
m_glBindVertexArrayOES(m_VAO);
glUniformMatrix3fv(m_ShaderProgramParams[PARAM_YUVMAT], 1, GL_FALSE, getColorMatrix());
glUniform3fv(m_ShaderProgramParams[PARAM_OFFSET], 1, getColorOffsets());
glUniform1i(m_ShaderProgramParams[PARAM_PLANE1], 0);
glUniform1i(m_ShaderProgramParams[PARAM_PLANE2], 1);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
m_glBindVertexArrayOES(0);
for (int i = 0; i < Overlay::OverlayMax; i++) {
renderOverlay((Overlay::OverlayType)i);
}
SDL_GL_SwapWindow(m_Window);
if (m_BlockingSwapBuffers) {
+20 -1
View File
@@ -17,16 +17,26 @@ public:
private:
bool compileShader();
void renderOverlay(Overlay::OverlayType type);
unsigned compileShader(const char* vertexShaderSrc, const char* fragmentShaderSrc);
bool compileShaders();
bool specialize();
const float *getColorOffsets();
const float *getColorMatrix();
static int loadAndBuildShader(int shaderType, const char *filename);
bool openDisplay(unsigned int platform, void* nativeDisplay);
int m_ViewportWidth;
int m_ViewportHeight;
int m_SwPixelFormat;
void *m_EGLDisplay;
unsigned m_Textures[EGL_MAX_PLANES];
unsigned m_OverlayTextures[Overlay::OverlayMax];
unsigned m_OverlayVbos[Overlay::OverlayMax];
SDL_atomic_t m_OverlayHasValidData[Overlay::OverlayMax];
unsigned m_ShaderProgram;
unsigned m_OverlayShaderProgram;
SDL_GLContext m_Context;
SDL_Window *m_Window;
IFFmpegRenderer *m_Backend;
@@ -39,6 +49,15 @@ private:
PFNGLBINDVERTEXARRAYOESPROC m_glBindVertexArrayOES;
PFNGLDELETEVERTEXARRAYSOESPROC m_glDeleteVertexArraysOES;
#define PARAM_YUVMAT 0
#define PARAM_OFFSET 1
#define PARAM_PLANE1 2
#define PARAM_PLANE2 3
int m_ShaderProgramParams[4];
#define PARAM_TEXTURE 0
int m_OverlayShaderProgramParams[1];
int m_OldContextProfileMask;
int m_OldContextMajorVersion;
int m_OldContextMinorVersion;
+63 -9
View File
@@ -5,9 +5,12 @@
#include <Limelight.h>
#include <SDL_syswm.h>
MmalRenderer::MmalRenderer()
: m_Renderer(nullptr),
m_InputPort(nullptr)
m_InputPort(nullptr),
m_BackgroundRenderer(nullptr)
{
}
@@ -20,6 +23,10 @@ MmalRenderer::~MmalRenderer()
if (m_Renderer != nullptr) {
mmal_component_destroy(m_Renderer);
}
if (m_BackgroundRenderer != nullptr) {
SDL_DestroyRenderer(m_BackgroundRenderer);
}
}
bool MmalRenderer::prepareDecoderContext(AVCodecContext* context, AVDictionary** options)
@@ -43,6 +50,9 @@ bool MmalRenderer::initialize(PDECODER_PARAMETERS params)
{
MMAL_STATUS_T status;
// Clear the background if possible
setupBackground(params);
status = mmal_component_create(MMAL_COMPONENT_DEFAULT_VIDEO_RENDERER, &m_Renderer);
if (status != MMAL_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
@@ -77,19 +87,25 @@ bool MmalRenderer::initialize(PDECODER_PARAMETERS params)
}
{
MMAL_DISPLAYREGION_T dr;
MMAL_DISPLAYREGION_T dr = {};
dr.hdr.id = MMAL_PARAMETER_DISPLAYREGION;
dr.hdr.size = sizeof(MMAL_DISPLAYREGION_T);
dr.set = MMAL_DISPLAY_SET_LAYER;
dr.layer = 128;
dr.set |= MMAL_DISPLAY_SET_ALPHA;
dr.alpha = 255;
dr.set |= MMAL_DISPLAY_SET_FULLSCREEN;
dr.fullscreen = true;
dr.fullscreen = MMAL_FALSE;
dr.set |= MMAL_DISPLAY_SET_MODE;
dr.mode = MMAL_DISPLAY_MODE_LETTERBOX;
dr.set |= MMAL_DISPLAY_SET_NOASPECT;
dr.noaspect = MMAL_TRUE;
dr.set |= MMAL_DISPLAY_SET_SRC_RECT;
dr.src_rect.x = 0;
dr.src_rect.y = 0;
dr.src_rect.width = params->width;
dr.src_rect.height = params->height;
{
SDL_Rect src, dst;
@@ -107,6 +123,14 @@ bool MmalRenderer::initialize(PDECODER_PARAMETERS params)
dr.dest_rect.width = dst.w;
dr.dest_rect.height = dst.h;
}
status = mmal_port_parameter_set(m_InputPort, &dr.hdr);
if (status != MMAL_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"mmal_port_parameter_set() failed: %x (%s)",
status, mmal_status_to_string(status));
return false;
}
}
status = mmal_port_enable(m_InputPort, InputPortCallback);
@@ -120,6 +144,36 @@ bool MmalRenderer::initialize(PDECODER_PARAMETERS params)
return true;
}
void MmalRenderer::setupBackground(PDECODER_PARAMETERS params)
{
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (!SDL_GetWindowWMInfo(params->window, &info)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_GetWindowWMInfo() failed: %s",
SDL_GetError());
return;
}
// On X11, we can safely create a renderer and draw a black background.
// Due to conflicts with Qt, it's unsafe to do this for KMSDRM.
if (info.subsystem == SDL_SYSWM_X11) {
m_BackgroundRenderer = SDL_CreateRenderer(params->window, -1, SDL_RENDERER_SOFTWARE);
if (m_BackgroundRenderer == nullptr) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_CreateRenderer() failed: %s",
SDL_GetError());
return;
}
SDL_SetRenderDrawColor(m_BackgroundRenderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
SDL_RenderClear(m_BackgroundRenderer);
SDL_RenderPresent(m_BackgroundRenderer);
}
}
void MmalRenderer::InputPortCallback(MMAL_PORT_T*, MMAL_BUFFER_HEADER_T* buffer)
{
mmal_buffer_header_release(buffer);
@@ -21,7 +21,11 @@ public:
private:
static void InputPortCallback(MMAL_PORT_T* port, MMAL_BUFFER_HEADER_T* buffer);
void setupBackground(PDECODER_PARAMETERS params);
MMAL_COMPONENT_T* m_Renderer;
MMAL_PORT_T* m_InputPort;
SDL_Renderer* m_BackgroundRenderer;
};
+49 -97
View File
@@ -2,54 +2,25 @@
#include "streaming/session.h"
#include "streaming/streamutils.h"
#include "path.h"
#include <QDir>
#include <Limelight.h>
SdlRenderer::SdlRenderer()
: m_Renderer(nullptr),
m_Texture(nullptr),
m_SwPixelFormat(AV_PIX_FMT_NONE),
m_FontData(Path::readDataFile("ModeSeven.ttf"))
m_SwPixelFormat(AV_PIX_FMT_NONE)
{
SDL_assert(TTF_WasInit() == 0);
if (TTF_Init() != 0) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"TTF_Init() failed: %s",
TTF_GetError());
return;
}
SDL_zero(m_OverlayFonts);
SDL_zero(m_OverlaySurfaces);
SDL_zero(m_OverlayTextures);
}
SdlRenderer::~SdlRenderer()
{
for (int i = 0; i < Overlay::OverlayMax; i++) {
if (m_OverlayFonts[i] != nullptr) {
TTF_CloseFont(m_OverlayFonts[i]);
}
}
TTF_Quit();
SDL_assert(TTF_WasInit() == 0);
for (int i = 0; i < Overlay::OverlayMax; i++) {
if (m_OverlayTextures[i] != nullptr) {
SDL_DestroyTexture(m_OverlayTextures[i]);
}
}
for (int i = 0; i < Overlay::OverlayMax; i++) {
if (m_OverlaySurfaces[i] != nullptr) {
SDL_FreeSurface(m_OverlaySurfaces[i]);
}
}
if (m_Texture != nullptr) {
SDL_DestroyTexture(m_Texture);
}
@@ -69,47 +40,6 @@ bool SdlRenderer::prepareDecoderContext(AVCodecContext*, AVDictionary**)
return true;
}
void SdlRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
{
// Construct the required font to render the overlay
if (m_OverlayFonts[type] == nullptr) {
if (m_FontData.isEmpty()) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL overlay font failed to load");
return;
}
// m_FontData must stay around until the font is closed
m_OverlayFonts[type] = TTF_OpenFontRW(SDL_RWFromConstMem(m_FontData.constData(), m_FontData.size()),
1,
Session::get()->getOverlayManager().getOverlayFontSize(type));
if (m_OverlayFonts[type] == nullptr) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"TTF_OpenFont() failed: %s",
TTF_GetError());
// Can't proceed without a font
return;
}
}
SDL_Surface* oldSurface = (SDL_Surface*)SDL_AtomicGetPtr((void**)&m_OverlaySurfaces[type]);
// Free the old surface
if (oldSurface != nullptr && SDL_AtomicCASPtr((void**)&m_OverlaySurfaces[type], oldSurface, nullptr)) {
SDL_FreeSurface(oldSurface);
}
if (Session::get()->getOverlayManager().isOverlayEnabled(type)) {
// The _Wrapped variant is required for line breaks to work
SDL_Surface* surface = TTF_RenderText_Blended_Wrapped(m_OverlayFonts[type],
Session::get()->getOverlayManager().getOverlayText(type),
Session::get()->getOverlayManager().getOverlayColor(type),
1000);
SDL_AtomicSetPtr((void**)&m_OverlaySurfaces[type], surface);
}
}
bool SdlRenderer::isRenderThreadSupported()
{
SDL_RendererInfo info;
@@ -182,8 +112,17 @@ bool SdlRenderer::initialize(PDECODER_PARAMETERS params)
// can get spurious SDL_WINDOWEVENT events that will cause us to (again) recreate our
// renderer. This can lead to an infinite to renderer recreation, so discard all
// SDL_WINDOWEVENT events after SDL_CreateRenderer().
SDL_PumpEvents();
SDL_FlushEvent(SDL_WINDOWEVENT);
Session* session = Session::get();
if (session != nullptr) {
// If we get here during a session, we need to synchronize with the event loop
// to ensure we don't drop any important events.
session->flushWindowEvents();
}
else {
// If we get here prior to the start of a session, just pump and flush ourselves.
SDL_PumpEvents();
SDL_FlushEvent(SDL_WINDOWEVENT);
}
// Calculate the video region size, scaling to fill the output size while
// preserving the aspect ratio of the video stream.
@@ -221,8 +160,8 @@ void SdlRenderer::renderOverlay(Overlay::OverlayType type)
// If a new surface has been created for updated overlay data, convert it into a texture.
// NB: We have to do this conversion at render-time because we can only interact
// with the renderer on a single thread.
SDL_Surface* surface = (SDL_Surface*)SDL_AtomicGetPtr((void**)&m_OverlaySurfaces[type]);
if (surface != nullptr && SDL_AtomicCASPtr((void**)&m_OverlaySurfaces[type], surface, nullptr)) {
SDL_Surface* newSurface = Session::get()->getOverlayManager().getUpdatedOverlaySurface(type);
if (newSurface != nullptr) {
if (m_OverlayTextures[type] != nullptr) {
SDL_DestroyTexture(m_OverlayTextures[type]);
}
@@ -232,7 +171,7 @@ void SdlRenderer::renderOverlay(Overlay::OverlayType type)
SDL_Rect viewportRect;
SDL_RenderGetViewport(m_Renderer, &viewportRect);
m_OverlayRects[type].x = 0;
m_OverlayRects[type].y = viewportRect.h - surface->h;
m_OverlayRects[type].y = viewportRect.h - newSurface->h;
}
else if (type == Overlay::OverlayDebug) {
// Top left
@@ -240,11 +179,11 @@ void SdlRenderer::renderOverlay(Overlay::OverlayType type)
m_OverlayRects[type].y = 0;
}
m_OverlayRects[type].w = surface->w;
m_OverlayRects[type].h = surface->h;
m_OverlayRects[type].w = newSurface->w;
m_OverlayRects[type].h = newSurface->h;
m_OverlayTextures[type] = SDL_CreateTextureFromSurface(m_Renderer, surface);
SDL_FreeSurface(surface);
m_OverlayTextures[type] = SDL_CreateTextureFromSurface(m_Renderer, newSurface);
SDL_FreeSurface(newSurface);
}
// If we have an overlay texture, render it too
@@ -361,25 +300,38 @@ void SdlRenderer::renderFrame(AVFrame* frame)
frame->linesize[2]);
}
else {
char* pixels;
int pitch;
#if SDL_VERSION_ATLEAST(2, 0, 15)
// SDL_UpdateNVTexture is not supported on all renderer backends,
// (notably not DX9), so we must have a fallback in case it's not
// supported and for earlier versions of SDL.
if (SDL_UpdateNVTexture(m_Texture,
nullptr,
frame->data[0],
frame->linesize[0],
frame->data[1],
frame->linesize[1]) != 0)
#endif
{
char* pixels;
int pitch;
err = SDL_LockTexture(m_Texture, nullptr, (void**)&pixels, &pitch);
if (err < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_LockTexture() failed: %s",
SDL_GetError());
goto Exit;
err = SDL_LockTexture(m_Texture, nullptr, (void**)&pixels, &pitch);
if (err < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_LockTexture() failed: %s",
SDL_GetError());
goto Exit;
}
memcpy(pixels,
frame->data[0],
frame->linesize[0] * frame->height);
memcpy(pixels + (frame->linesize[0] * frame->height),
frame->data[1],
frame->linesize[1] * frame->height / 2);
SDL_UnlockTexture(m_Texture);
}
memcpy(pixels,
frame->data[0],
frame->linesize[0] * frame->height);
memcpy(pixels + (frame->linesize[0] * frame->height),
frame->data[1],
frame->linesize[1] * frame->height / 2);
SDL_UnlockTexture(m_Texture);
}
SDL_RenderClear(m_Renderer);
@@ -2,8 +2,6 @@
#include "renderer.h"
#include <SDL_ttf.h>
class SdlRenderer : public IFFmpegRenderer {
public:
SdlRenderer();
@@ -11,7 +9,6 @@ public:
virtual bool initialize(PDECODER_PARAMETERS params) override;
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
virtual void renderFrame(AVFrame* frame) override;
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
virtual bool isRenderThreadSupported() override;
virtual bool isPixelFormatSupported(int videoFormat, enum AVPixelFormat pixelFormat) override;
@@ -21,9 +18,6 @@ private:
SDL_Renderer* m_Renderer;
SDL_Texture* m_Texture;
int m_SwPixelFormat;
QByteArray m_FontData;
TTF_Font* m_OverlayFonts[Overlay::OverlayMax];
SDL_Surface* m_OverlaySurfaces[Overlay::OverlayMax];
SDL_Texture* m_OverlayTextures[Overlay::OverlayMax];
SDL_Rect m_OverlayRects[Overlay::OverlayMax];
};
@@ -1,3 +1,4 @@
#include <streaming/session.h>
#include "vdpau.h"
#include <streaming/streamutils.h>
@@ -27,9 +28,11 @@ VDPAURenderer::VDPAURenderer()
m_PresentationQueueTarget(0),
m_PresentationQueue(0),
m_VideoMixer(0),
m_OverlayMutex(nullptr),
m_NextSurfaceIndex(0)
{
SDL_zero(m_OutputSurface);
SDL_zero(m_OverlaySurface);
}
VDPAURenderer::~VDPAURenderer()
@@ -52,6 +55,16 @@ VDPAURenderer::~VDPAURenderer()
}
}
for (int i = 0; i < Overlay::OverlayMax; i++) {
if (m_OverlaySurface[i] != 0) {
m_VdpBitmapSurfaceDestroy(m_OverlaySurface[i]);
}
}
if (m_OverlayMutex != nullptr) {
SDL_DestroyMutex(m_OverlayMutex);
}
// This must be done last as it frees VDPAU context required to call
// the functions above.
if (m_HwContext != nullptr) {
@@ -136,6 +149,10 @@ bool VDPAURenderer::initialize(PDECODER_PARAMETERS params)
GET_PROC_ADDRESS(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE, &m_VdpOutputSurfaceCreate);
GET_PROC_ADDRESS(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY, &m_VdpOutputSurfaceDestroy);
GET_PROC_ADDRESS(VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES, &m_VdpOutputSurfaceQueryCapabilities);
GET_PROC_ADDRESS(VDP_FUNC_ID_BITMAP_SURFACE_CREATE, &m_VdpBitmapSurfaceCreate);
GET_PROC_ADDRESS(VDP_FUNC_ID_BITMAP_SURFACE_DESTROY, &m_VdpBitmapSurfaceDestroy);
GET_PROC_ADDRESS(VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE, &m_VdpBitmapSurfacePutBitsNative);
GET_PROC_ADDRESS(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE, &m_VdpOutputSurfaceRenderBitmapSurface);
GET_PROC_ADDRESS(VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS, &m_VdpVideoSurfaceGetParameters);
GET_PROC_ADDRESS(VDP_FUNC_ID_GET_INFORMATION_STRING, &m_VdpGetInformationString);
@@ -263,6 +280,24 @@ bool VDPAURenderer::initialize(PDECODER_PARAMETERS params)
VdpColor color = {0.0, 0.0, 0.0, 1.0};
m_VdpPresentationQueueSetBackgroundColor(m_PresentationQueue, &color);
// Populate blend state for overlays
m_OverlayBlendState.struct_version = VDP_OUTPUT_SURFACE_RENDER_BLEND_STATE_VERSION;
m_OverlayBlendState.blend_factor_destination_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
m_OverlayBlendState.blend_factor_destination_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
m_OverlayBlendState.blend_factor_source_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_ALPHA;
m_OverlayBlendState.blend_factor_source_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_ALPHA;
m_OverlayBlendState.blend_equation_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD;
m_OverlayBlendState.blend_equation_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD;
m_OverlayBlendState.blend_constant = {};
// Allocate mutex to synchronize overlay updates and rendering
m_OverlayMutex = SDL_CreateMutex();
if (m_OverlayMutex == nullptr) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Failed to create overlay mutex");
return false;
}
return true;
}
@@ -284,6 +319,98 @@ bool VDPAURenderer::prepareDecoderContext(AVCodecContext* context, AVDictionary*
return true;
}
void VDPAURenderer::notifyOverlayUpdated(Overlay::OverlayType type)
{
VdpStatus status;
SDL_Surface* newSurface = Session::get()->getOverlayManager().getUpdatedOverlaySurface(type);
if (newSurface == nullptr && Session::get()->getOverlayManager().isOverlayEnabled(type)) {
// There's no updated surface and the overlay is enabled, so just leave the old surface alone.
return;
}
// Destroy the old surface
// NB: The mutex ensures the surface is not currently being read for rendering.
// NB 2: It is safe to unlock here because this thread is the only surface producer.
SDL_LockMutex(m_OverlayMutex);
VdpBitmapSurface oldBitmapSurface = m_OverlaySurface[type];
m_OverlaySurface[type] = 0;
SDL_UnlockMutex(m_OverlayMutex);
if (oldBitmapSurface != 0) {
status = m_VdpBitmapSurfaceDestroy(oldBitmapSurface);
if (status != VDP_STATUS_OK) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"VdpBitmapSurfaceDestroy() failed: %s",
m_VdpGetErrorString(status));
// This should never happen.
SDL_assert(false);
}
}
if (!Session::get()->getOverlayManager().isOverlayEnabled(type)) {
SDL_FreeSurface(newSurface);
return;
}
if (newSurface != nullptr) {
SDL_assert(!SDL_MUSTLOCK(newSurface));
VdpBitmapSurface newBitmapSurface = 0;
status = m_VdpBitmapSurfaceCreate(m_Device,
VDP_RGBA_FORMAT_B8G8R8A8,
newSurface->w,
newSurface->h,
VDP_TRUE, // Is this correct?
&newBitmapSurface);
if (status != VDP_STATUS_OK) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"VdpBitmapSurfaceCreate() failed: %s",
m_VdpGetErrorString(status));
SDL_FreeSurface(newSurface);
return;
}
status = m_VdpBitmapSurfacePutBitsNative(newBitmapSurface,
&newSurface->pixels,
(const uint32_t*)&newSurface->pitch,
nullptr);
if (status != VDP_STATUS_OK) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"VdpBitmapSurfacePutBitsNative() failed: %s",
m_VdpGetErrorString(status));
m_VdpBitmapSurfaceDestroy(newBitmapSurface);
SDL_FreeSurface(newSurface);
return;
}
VdpRect overlayRect;
if (type == Overlay::OverlayStatusUpdate) {
// Bottom Left
overlayRect.x0 = 0;
overlayRect.y0 = m_DisplayHeight - newSurface->h;
}
else if (type == Overlay::OverlayDebug) {
// Top left
overlayRect.x0 = 0;
overlayRect.y0 = 0;
}
overlayRect.x1 = overlayRect.x0 + newSurface->w;
overlayRect.y1 = overlayRect.y0 + newSurface->h;
// Surface data is no longer needed
SDL_FreeSurface(newSurface);
SDL_LockMutex(m_OverlayMutex);
m_OverlaySurface[type] = newBitmapSurface;
m_OverlayRect[type] = overlayRect;
SDL_UnlockMutex(m_OverlayMutex);
}
}
bool VDPAURenderer::needsTestFrame()
{
// We need a test frame to see if this VDPAU driver
@@ -300,6 +427,44 @@ int VDPAURenderer::getDecoderColorspace()
return COLORSPACE_REC_601;
}
void VDPAURenderer::renderOverlay(VdpOutputSurface destination, Overlay::OverlayType type)
{
VdpStatus status;
// Don't even bother locking the mutex if the overlay is disabled
if (!Session::get()->getOverlayManager().isOverlayEnabled(type)) {
return;
}
if (SDL_TryLockMutex(m_OverlayMutex) != 0) {
// If the overlay is currently being updated, skip rendering it this frame.
return;
}
// Check if there's a surface to render
if (m_OverlaySurface[type] == 0) {
SDL_UnlockMutex(m_OverlayMutex);
return;
}
status = m_VdpOutputSurfaceRenderBitmapSurface(destination,
&m_OverlayRect[type],
m_OverlaySurface[type],
nullptr,
nullptr,
&m_OverlayBlendState,
0);
SDL_UnlockMutex(m_OverlayMutex);
if (status != VDP_STATUS_OK) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"VdpOutputSurfaceRenderBitmapSurface() failed: %s",
m_VdpGetErrorString(status));
return;
}
}
void VDPAURenderer::renderFrame(AVFrame* frame)
{
if (frame == nullptr) {
@@ -400,6 +565,11 @@ void VDPAURenderer::renderFrame(AVFrame* frame)
return;
}
// Render overlays into the output surface before display
for (int i = 0; i < Overlay::OverlayMax; i++) {
renderOverlay(chosenSurface, (Overlay::OverlayType)i);
}
// Queue the frame for display immediately
status = m_VdpPresentationQueueDisplay(m_PresentationQueue, chosenSurface, 0, 0, 0);
if (status != VDP_STATUS_OK) {
@@ -15,11 +15,14 @@ public:
virtual ~VDPAURenderer() override;
virtual bool initialize(PDECODER_PARAMETERS params) override;
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
virtual void notifyOverlayUpdated(Overlay::OverlayType type) override;
virtual void renderFrame(AVFrame* frame) override;
virtual bool needsTestFrame() override;
virtual int getDecoderColorspace() override;
private:
void renderOverlay(VdpOutputSurface destination, Overlay::OverlayType type);
uint32_t m_VideoWidth, m_VideoHeight;
uint32_t m_DisplayWidth, m_DisplayHeight;
AVBufferRef* m_HwContext;
@@ -29,6 +32,15 @@ private:
VdpRGBAFormat m_OutputSurfaceFormat;
VdpDevice m_Device;
// We just have a single mutex to protect all overlay slots.
// This is fine because the majority of time spent in the mutex
// is by the render thread, which cannot contend with itself
// because overlays are rendered sequentially.
SDL_mutex* m_OverlayMutex;
VdpBitmapSurface m_OverlaySurface[Overlay::OverlayMax];
VdpRect m_OverlayRect[Overlay::OverlayMax];
VdpOutputSurfaceRenderBlendState m_OverlayBlendState;
#define OUTPUT_SURFACE_COUNT 3
VdpOutputSurface m_OutputSurface[OUTPUT_SURFACE_COUNT];
int m_NextSurfaceIndex;
@@ -50,6 +62,10 @@ private:
VdpOutputSurfaceCreate* m_VdpOutputSurfaceCreate;
VdpOutputSurfaceDestroy* m_VdpOutputSurfaceDestroy;
VdpOutputSurfaceQueryCapabilities* m_VdpOutputSurfaceQueryCapabilities;
VdpBitmapSurfaceCreate* m_VdpBitmapSurfaceCreate;
VdpBitmapSurfaceDestroy* m_VdpBitmapSurfaceDestroy;
VdpBitmapSurfacePutBitsNative* m_VdpBitmapSurfacePutBitsNative;
VdpOutputSurfaceRenderBitmapSurface* m_VdpOutputSurfaceRenderBitmapSurface;
VdpVideoSurfaceGetParameters* m_VdpVideoSurfaceGetParameters;
VdpGetInformationString* m_VdpGetInformationString;
+1 -1
View File
@@ -444,7 +444,7 @@ public:
return false;
}
if (params->enableVsync) {
if (params->enableFramePacing) {
if (!initializeVsyncCallback(&info)) {
return false;
}
+4 -5
View File
@@ -891,9 +891,7 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
m_Pkt.flags = 0;
}
m_ActiveWndVideoStats.totalReassemblyTime += LiGetMillis() - du->receiveTimeMs;
Uint32 beforeDecode = SDL_GetTicks();
m_ActiveWndVideoStats.totalReassemblyTime += du->enqueueTimeMs - du->receiveTimeMs;
err = avcodec_send_packet(m_VideoDecoderCtx, &m_Pkt);
if (err < 0) {
@@ -945,8 +943,9 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
frame->pkt_dts = SDL_GetTicks();
// Count time in avcodec_send_packet() and avcodec_receive_frame()
// as time spent decoding
m_ActiveWndVideoStats.totalDecodeTime += SDL_GetTicks() - beforeDecode;
// as time spent decoding. Also count time spent in the decode unit
// queue because that's directly caused by decoder latency.
m_ActiveWndVideoStats.totalDecodeTime += LiGetMillis() - du->enqueueTimeMs;
// Also count the frame-to-frame delay if the decoder is delaying frames
// until a subsequent frame is submitted.
+84 -6
View File
@@ -1,9 +1,11 @@
#include "overlaymanager.h"
#include "path.h"
using namespace Overlay;
OverlayManager::OverlayManager() :
m_Renderer(nullptr)
m_Renderer(nullptr),
m_FontData(Path::readDataFile("ModeSeven.ttf"))
{
memset(m_Overlays, 0, sizeof(m_Overlays));
@@ -12,6 +14,29 @@ OverlayManager::OverlayManager() :
m_Overlays[OverlayType::OverlayStatusUpdate].color = {0xCC, 0x00, 0x00, 0xFF};
m_Overlays[OverlayType::OverlayStatusUpdate].fontSize = 36;
SDL_assert(TTF_WasInit() == 0);
if (TTF_Init() != 0) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"TTF_Init() failed: %s",
TTF_GetError());
return;
}
}
OverlayManager::~OverlayManager()
{
for (int i = 0; i < OverlayType::OverlayMax; i++) {
if (m_Overlays[i].surface != nullptr) {
SDL_FreeSurface(m_Overlays[i].surface);
}
if (m_Overlays[i].font != nullptr) {
TTF_CloseFont(m_Overlays[i].font);
}
}
TTF_Quit();
SDL_assert(TTF_WasInit() == 0);
}
bool OverlayManager::isOverlayEnabled(OverlayType type)
@@ -29,12 +54,19 @@ int OverlayManager::getOverlayFontSize(OverlayType type)
return m_Overlays[type].fontSize;
}
SDL_Surface* OverlayManager::getUpdatedOverlaySurface(OverlayType type)
{
// If a new surface is available, return it. If not, return nullptr.
// Caller must free the surface on success.
return (SDL_Surface*)SDL_AtomicSetPtr((void**)&m_Overlays[type].surface, nullptr);
}
void OverlayManager::setOverlayTextUpdated(OverlayType type)
{
// Only update the overlay state if it's enabled. If it's not enabled,
// the renderer has already been notified by setOverlayState().
if (m_Overlays[type].enabled && m_Renderer != nullptr) {
m_Renderer->notifyOverlayUpdated(type);
if (m_Overlays[type].enabled) {
notifyOverlayUpdated(type);
}
}
@@ -50,9 +82,7 @@ void OverlayManager::setOverlayState(OverlayType type, bool enabled)
m_Overlays[type].text[0] = 0;
}
if (m_Renderer != nullptr) {
m_Renderer->notifyOverlayUpdated(type);
}
notifyOverlayUpdated(type);
}
}
@@ -65,3 +95,51 @@ void OverlayManager::setOverlayRenderer(IOverlayRenderer* renderer)
{
m_Renderer = renderer;
}
void OverlayManager::notifyOverlayUpdated(OverlayType type)
{
if (m_Renderer == nullptr) {
return;
}
// Construct the required font to render the overlay
if (m_Overlays[type].font == nullptr) {
if (m_FontData.isEmpty()) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL overlay font failed to load");
return;
}
// m_FontData must stay around until the font is closed
m_Overlays[type].font = TTF_OpenFontRW(SDL_RWFromConstMem(m_FontData.constData(), m_FontData.size()),
1,
m_Overlays[type].fontSize);
if (m_Overlays[type].font == nullptr) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"TTF_OpenFont() failed: %s",
TTF_GetError());
// Can't proceed without a font
return;
}
}
SDL_Surface* oldSurface = (SDL_Surface*)SDL_AtomicSetPtr((void**)&m_Overlays[type].surface, nullptr);
// Free the old surface
if (oldSurface != nullptr) {
SDL_FreeSurface(oldSurface);
}
if (m_Overlays[type].enabled) {
// The _Wrapped variant is required for line breaks to work
SDL_Surface* surface = TTF_RenderText_Blended_Wrapped(m_Overlays[type].font,
m_Overlays[type].text,
m_Overlays[type].color,
1024);
SDL_AtomicSetPtr((void**)&m_Overlays[type].surface, surface);
}
// Notify the renderer
m_Renderer->notifyOverlayUpdated(type);
}
+10
View File
@@ -3,6 +3,7 @@
#include <QString>
#include <SDL.h>
#include <SDL_ttf.h>
namespace Overlay {
@@ -24,6 +25,7 @@ class OverlayManager
{
public:
OverlayManager();
~OverlayManager();
bool isOverlayEnabled(OverlayType type);
char* getOverlayText(OverlayType type);
@@ -31,16 +33,24 @@ public:
void setOverlayState(OverlayType type, bool enabled);
SDL_Color getOverlayColor(OverlayType type);
int getOverlayFontSize(OverlayType type);
SDL_Surface* getUpdatedOverlaySurface(OverlayType type);
void setOverlayRenderer(IOverlayRenderer* renderer);
private:
void notifyOverlayUpdated(OverlayType type);
struct {
bool enabled;
int fontSize;
SDL_Color color;
char text[512];
TTF_Font* font;
SDL_Surface* surface;
} m_Overlays[OverlayMax];
IOverlayRenderer* m_Renderer;
QByteArray m_FontData;
};
}
+1 -1
View File
@@ -1 +1 @@
2.2.0
3.0.0
+14 -13
View File
@@ -5,13 +5,9 @@ clone_depth: 1
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
QTDIR: C:\Qt\5.15\msvc2019_64
ARCH: x64
QTDIR: C:\Qt\5.15
- APPVEYOR_BUILD_WORKER_IMAGE: macOS
BUILD_TARGET: macos
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
QTDIR: C:\Qt\5.15\msvc2019
ARCH: x86
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu1604
BUILD_TARGET: steamlink
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu1604
@@ -28,30 +24,35 @@ install:
- sh: '[ "$BUILD_TARGET" != linux ] || sudo add-apt-repository ppa:beineri/opt-qt-5.14.2-xenial'
- sh: '[ "$BUILD_TARGET" != linux ] || sudo apt update'
- sh: '[ "$BUILD_TARGET" != linux ] || sudo apt install -y qt514base qt514quickcontrols2 qt514svg qt514wayland nasm libgbm-dev libdrm-dev libfreetype6-dev libasound2-dev libdbus-1-dev libegl1-mesa-dev libgl1-mesa-dev libgles2-mesa-dev libglu1-mesa-dev libibus-1.0-dev libpulse-dev libudev-dev libx11-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxkbcommon-dev libxrandr-dev libxss-dev libxt-dev libxv-dev libxxf86vm-dev wayland-protocols libopus-dev libvdpau-dev'
- sh: 'if [[ "$BUILD_TARGET" = linux ]]; then export SDL2_VER=2.0.12 && wget https://www.libsdl.org/release/SDL2-$SDL2_VER.tar.gz && tar -xvf SDL2-$SDL2_VER.tar.gz && cd SDL2-$SDL2_VER && ./configure && make -j$(nproc) && sudo make install && cd ..; fi'
- sh: 'if [[ "$BUILD_TARGET" = linux ]]; then export SDL2_VER=2.0.14 && wget https://www.libsdl.org/release/SDL2-$SDL2_VER.tar.gz && tar -xvf SDL2-$SDL2_VER.tar.gz && cd SDL2-$SDL2_VER && ./configure && make -j$(nproc) && sudo make install && cd ..; fi'
- sh: 'if [[ "$BUILD_TARGET" = linux ]]; then export SDL2_TTF_VER=2.0.15 && wget https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$SDL2_TTF_VER.tar.gz && tar -xvf SDL2_ttf-$SDL2_TTF_VER.tar.gz && cd SDL2_ttf-$SDL2_TTF_VER && ./configure && make -j$(nproc) && sudo make install && cd ..; fi'
- sh: 'if [[ "$BUILD_TARGET" = linux ]]; then export LIBVA_VER=2.8.0 && wget https://github.com/intel/libva/releases/download/$LIBVA_VER/libva-$LIBVA_VER.tar.bz2 && tar -xvf libva-$LIBVA_VER.tar.bz2 && cd libva-$LIBVA_VER && ./configure && make -j$(nproc) && sudo make install && cd ..; fi'
- sh: 'if [[ "$BUILD_TARGET" = linux ]]; then export NVHDR_VER=8.1.24.11 && wget https://github.com/FFmpeg/nv-codec-headers/releases/download/n$NVHDR_VER/nv-codec-headers-$NVHDR_VER.tar.gz && tar -xvf nv-codec-headers-$NVHDR_VER.tar.gz && cd nv-codec-headers-$NVHDR_VER && sudo make install && cd ..; fi'
- sh: 'if [[ "$BUILD_TARGET" = linux ]]; then export LIBVA_VER=2.10.0 && wget https://github.com/intel/libva/releases/download/$LIBVA_VER/libva-$LIBVA_VER.tar.bz2 && tar -xvf libva-$LIBVA_VER.tar.bz2 && cd libva-$LIBVA_VER && ./configure && make -j$(nproc) && sudo make install && cd ..; fi'
- sh: 'if [[ "$BUILD_TARGET" = linux ]]; then export NVHDR_VER=8.1.24.12 && wget https://github.com/FFmpeg/nv-codec-headers/releases/download/n$NVHDR_VER/nv-codec-headers-$NVHDR_VER.tar.gz && tar -xvf nv-codec-headers-$NVHDR_VER.tar.gz && cd nv-codec-headers-$NVHDR_VER && sudo make install && cd ..; fi'
- sh: 'if [[ "$BUILD_TARGET" = linux ]]; then export FFMPEG_VER=4.3.1 && wget https://ffmpeg.org/releases/ffmpeg-$FFMPEG_VER.tar.bz2 && tar -xvf ffmpeg-$FFMPEG_VER.tar.bz2 && cd ffmpeg-$FFMPEG_VER && ./configure $FFMPEG_CONFIGURE_ARGS && make -j$(nproc) && sudo make install && sudo ldconfig && cd ..; fi'
- sh: 'if [[ "$BUILD_TARGET" = linux ]]; then mkdir $HOME/bin && wget -O $HOME/bin/linuxdeployqt https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage && chmod a+x $HOME/bin/linuxdeployqt; fi'
before_build:
- 'git submodule update --init --recursive'
- cmd: 'set PATH=%PATH%;%QTDIR%\bin;%ProgramFiles(x86)%\WiX Toolset v3.11\bin'
- cmd: 'set OLDPATH=%PATH%'
- cmd: 'set /p VERSION=<app\version.txt'
- sh: 'export VERSION=`cat app/version.txt`'
build_script:
- cmd: 'scripts\generate-installers.bat Debug %ARCH%'
- cmd: 'scripts\generate-installers.bat Release %ARCH%'
- cmd: 'set PATH=%OLDPATH%;%QTDIR%\msvc2019_64\bin;%ProgramFiles(x86)%\WiX Toolset v3.11\bin'
- cmd: 'scripts\build-arch.bat Release x64'
- cmd: 'set PATH=%OLDPATH%;%QTDIR%\msvc2019\bin;%ProgramFiles(x86)%\WiX Toolset v3.11\bin'
- cmd: 'scripts\build-arch.bat Release x86'
- cmd: 'scripts\generate-bundle.bat Release'
- sh: '[ "$BUILD_TARGET" != linux ] || source /opt/qt514/bin/qt514-env.sh'
- sh: '[ "$BUILD_TARGET" != linux ] || PATH=$PATH:$HOME/bin scripts/build-appimage.sh'
- sh: '[ "$BUILD_TARGET" != macos ] || scripts/generate-dmg.sh Release'
- sh: '[ "$BUILD_TARGET" != steamlink ] || STEAMLINK_SDK_PATH=$HOME/steamlink-sdk scripts/build-steamlink-app.sh'
after_build:
- cmd: 'appveyor PushArtifact build\installer-%ARCH%-Release\MoonlightPortable-%ARCH%-%VERSION%.zip -FileName MoonlightPortable-%ARCH%-r%APPVEYOR_BUILD_NUMBER%.zip'
- cmd: 'appveyor PushArtifact build\symbols-%ARCH%-Release\MoonlightDebuggingSymbols-%ARCH%-%VERSION%.zip -FileName MoonlightDebuggingSymbols-%ARCH%-r%APPVEYOR_BUILD_NUMBER%.zip'
- cmd: 'appveyor PushArtifact build\installer-x86-Release\MoonlightPortable-x86-%VERSION%.zip -FileName MoonlightPortable-x86-r%APPVEYOR_BUILD_NUMBER%.zip'
- cmd: 'appveyor PushArtifact build\symbols-x86-Release\MoonlightDebuggingSymbols-x86-%VERSION%.zip -FileName MoonlightDebuggingSymbols-x86-r%APPVEYOR_BUILD_NUMBER%.zip'
- cmd: 'appveyor PushArtifact build\installer-x64-Release\MoonlightPortable-x64-%VERSION%.zip -FileName MoonlightPortable-x64-r%APPVEYOR_BUILD_NUMBER%.zip'
- cmd: 'appveyor PushArtifact build\symbols-x64-Release\MoonlightDebuggingSymbols-x64-%VERSION%.zip -FileName MoonlightDebuggingSymbols-x64-r%APPVEYOR_BUILD_NUMBER%.zip'
- sh: '[ "$BUILD_TARGET" != steamlink ] || appveyor PushArtifact build/installer-release/Moonlight-SteamLink-$VERSION.zip -FileName Moonlight-SteamLink-r$APPVEYOR_BUILD_NUMBER.zip'
- sh: '[ "$BUILD_TARGET" != macos ] || appveyor PushArtifact build/installer-Release/Moonlight-$VERSION.dmg -FileName Moonlight-r$APPVEYOR_BUILD_NUMBER.dmg'
- sh: '[ "$BUILD_TARGET" != linux ] || appveyor PushArtifact build/installer-release/Moonlight-$VERSION-x86_64.AppImage -FileName Moonlight-r$APPVEYOR_BUILD_NUMBER-x86_64.AppImage'
@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>19G2021</string>
<string>19H114</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
@@ -27,17 +27,19 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>11E801a</string>
<string>12C33</string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<string>11.1</string>
<key>DTSDKBuild</key>
<string>19G68</string>
<string>20C63</string>
<key>DTSDKName</key>
<string>macosx10.15</string>
<string>macosx11.1</string>
<key>DTXcode</key>
<string>1170</string>
<string>1230</string>
<key>DTXcodeBuild</key>
<string>11E801a</string>
<string>12C33</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
</dict>
@@ -10,7 +10,7 @@
</data>
<key>Resources/Info.plist</key>
<data>
k9vWJij3RA8s13h/WkHnqVv977U=
8Yk54YzUKmLCGTNkmc8LiukTgFM=
</data>
<key>Resources/LICENSE-bsd.txt</key>
<data>
@@ -31,17 +31,6 @@
</dict>
<key>files2</key>
<dict>
<key>Headers/hidapi.h</key>
<dict>
<key>hash</key>
<data>
k64XAQ+3r97nmyIHwE8OT8womds=
</data>
<key>hash2</key>
<data>
lVEZqQL+xakdQRDnxHo2VwkisMieptRP2Im3DPsMMAs=
</data>
</dict>
<key>Resources/AUTHORS.txt</key>
<dict>
<key>hash</key>
@@ -57,11 +46,11 @@
<dict>
<key>hash</key>
<data>
k9vWJij3RA8s13h/WkHnqVv977U=
8Yk54YzUKmLCGTNkmc8LiukTgFM=
</data>
<key>hash2</key>
<data>
WME8EBqUAByTxhCypUOOYXVJiElcUNSkBXR1bxH3n5Q=
g8uVTrv9wFcDsYV6z37oNILYTKi5mgge59ixh4aBoo4=
</data>
</dict>
<key>Resources/LICENSE-bsd.txt</key>
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -60,6 +60,7 @@
#include "SDL_version.h"
#include "SDL_video.h"
#include "SDL_locale.h"
#include "SDL_misc.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -53,8 +53,10 @@ assert can have unique static variables associated with it.
#define SDL_TriggerBreakpoint() __debugbreak()
#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
#elif ( defined(__APPLE__) && defined(__arm64__) ) /* this might work on other ARM targets, but this is a known quantity... */
#elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
#elif defined(__APPLE__) && defined(__arm__)
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" )
#elif defined(__386__) && defined(__WATCOMC__)
#define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -48,10 +48,9 @@ extern "C" {
* \return Index of the most significant bit, or -1 if the value is 0.
*/
#if defined(__WATCOMC__) && defined(__386__)
extern _inline int _SDL_clz_watcom (Uint32);
#pragma aux _SDL_clz_watcom = \
extern _inline int _SDL_bsr_watcom (Uint32);
#pragma aux _SDL_bsr_watcom = \
"bsr eax, eax" \
"xor eax, 31" \
parm [eax] nomemory \
value [eax] \
modify exact [eax] nomemory;
@@ -72,7 +71,13 @@ SDL_MostSignificantBitIndex32(Uint32 x)
if (x == 0) {
return -1;
}
return 31 - _SDL_clz_watcom(x);
return _SDL_bsr_watcom(x);
#elif defined(_MSC_VER)
unsigned long index;
if (_BitScanReverse(&index, x)) {
return index;
}
return -1;
#else
/* Based off of Bit Twiddling Hacks by Sean Eron Anderson
* <seander@cs.stanford.edu>, released in the public domain.
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -115,8 +115,12 @@
#define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1
#define HAVE_LROUND 1
#define HAVE_LROUNDF 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_ROUND 1
#define HAVE_ROUNDF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1
@@ -125,6 +129,8 @@
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE_TRUNC 1
#define HAVE_TRUNCF 1
#define HAVE_SIGACTION 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
@@ -144,6 +150,11 @@
#define SDL_JOYSTICK_VIRTUAL 1
#define SDL_HAPTIC_IOKIT 1
/* The MFI controller support requires ARC Objective C runtime */
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 && !defined(__i386__)
#define SDL_JOYSTICK_MFI 1
#endif
/* Enable the dummy sensor driver */
#define SDL_SENSOR_DUMMY 1
@@ -196,7 +207,7 @@
#endif
/* Metal only supported on 64-bit architectures with 10.11+ */
#if TARGET_CPU_X86_64 && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100)
#if TARGET_RT_64_BIT && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100)
#define SDL_PLATFORM_SUPPORTS_METAL 1
#else
#define SDL_PLATFORM_SUPPORTS_METAL 0
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -271,7 +271,7 @@ extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len);
* \sa SDL_SIMDAlloc
* \sa SDL_SIMDFree
*/
extern DECLSPEC void * SDLCALL SDL_SIMDRealloc(void *mem, size_t len);
extern DECLSPEC void * SDLCALL SDL_SIMDRealloc(void *mem, const size_t len);
/**
* \brief Deallocate memory obtained from SDL_SIMDAlloc
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -30,6 +30,10 @@
#include "SDL_stdinc.h"
#ifdef _MSC_VER
#include <intrin.h>
#endif
/**
* \name The two types of endianness
*/
@@ -45,6 +49,9 @@
#elif defined(__OpenBSD__)
#include <endian.h>
#define SDL_BYTEORDER BYTE_ORDER
#elif defined(__FreeBSD__)
#include <sys/endian.h>
#define SDL_BYTEORDER BYTE_ORDER
#else
#if defined(__hppa__) || \
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
@@ -68,8 +75,11 @@ extern "C" {
/**
* \file SDL_endian.h
*/
#if defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
#if (defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 2))) || \
(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
#define SDL_Swap16(x) __builtin_bswap16(x)
#elif defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x)
{
@@ -92,13 +102,23 @@ SDL_Swap16(Uint16 x)
__asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x));
return (Uint16)result;
}
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
#elif defined(__GNUC__) && defined(__aarch64__)
SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x)
{
__asm__("rev16 %w1, %w0" : "=r"(x) : "r"(x));
return x;
}
#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__))
SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x)
{
__asm__("rorw #8,%0": "=d"(x): "0"(x):"cc");
return x;
}
#elif defined(_MSC_VER)
#pragma intrinsic(_byteswap_ushort)
#define SDL_Swap16(x) _byteswap_ushort(x)
#elif defined(__WATCOMC__) && defined(__386__)
extern _inline Uint16 SDL_Swap16(Uint16);
#pragma aux SDL_Swap16 = \
@@ -113,7 +133,11 @@ SDL_Swap16(Uint16 x)
}
#endif
#if defined(__GNUC__) && defined(__i386__)
#if (defined(__clang__) && (__clang_major__ > 2 || (__clang_major__ == 2 && __clang_minor__ >= 6))) || \
(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
#define SDL_Swap32(x) __builtin_bswap32(x)
#elif defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x)
{
@@ -138,7 +162,14 @@ SDL_Swap32(Uint32 x)
__asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x));
return result;
}
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
#elif defined(__GNUC__) && defined(__aarch64__)
SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x)
{
__asm__("rev %w1, %w0": "=r"(x):"r"(x));
return x;
}
#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__))
SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x)
{
@@ -160,6 +191,9 @@ extern _inline Uint32 SDL_Swap32(Uint32);
parm [eax] \
modify [eax];
#endif
#elif defined(_MSC_VER)
#pragma intrinsic(_byteswap_ulong)
#define SDL_Swap32(x) _byteswap_ulong(x)
#else
SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x)
@@ -169,7 +203,11 @@ SDL_Swap32(Uint32 x)
}
#endif
#if defined(__GNUC__) && defined(__i386__)
#if (defined(__clang__) && (__clang_major__ > 2 || (__clang_major__ == 2 && __clang_minor__ >= 6))) || \
(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
#define SDL_Swap64(x) __builtin_bswap64(x)
#elif defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x)
{
@@ -194,6 +232,9 @@ SDL_Swap64(Uint64 x)
__asm__("bswapq %0": "=r"(x):"0"(x));
return x;
}
#elif defined(_MSC_VER)
#pragma intrinsic(_byteswap_uint64)
#define SDL_Swap64(x) _byteswap_uint64(x)
#else
SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x)
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -125,6 +125,10 @@ typedef enum
SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */
SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */
SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */
SDL_CONTROLLERTOUCHPADDOWN, /**< Game controller touchpad was touched */
SDL_CONTROLLERTOUCHPADMOTION, /**< Game controller touchpad finger was moved */
SDL_CONTROLLERTOUCHPADUP, /**< Game controller touchpad finger was lifted */
SDL_CONTROLLERSENSORUPDATE, /**< Game controller sensor was updated */
/* Touch events */
SDL_FINGERDOWN = 0x700,
@@ -415,6 +419,33 @@ typedef struct SDL_ControllerDeviceEvent
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
} SDL_ControllerDeviceEvent;
/**
* \brief Game controller touchpad event structure (event.ctouchpad.*)
*/
typedef struct SDL_ControllerTouchpadEvent
{
Uint32 type; /**< ::SDL_CONTROLLERTOUCHPADDOWN or ::SDL_CONTROLLERTOUCHPADMOTION or ::SDL_CONTROLLERTOUCHPADUP */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */
Sint32 touchpad; /**< The index of the touchpad */
Sint32 finger; /**< The index of the finger on the touchpad */
float x; /**< Normalized in the range 0...1 with 0 being on the left */
float y; /**< Normalized in the range 0...1 with 0 being at the top */
float pressure; /**< Normalized in the range 0...1 */
} SDL_ControllerTouchpadEvent;
/**
* \brief Game controller sensor event structure (event.csensor.*)
*/
typedef struct SDL_ControllerSensorEvent
{
Uint32 type; /**< ::SDL_CONTROLLERSENSORUPDATE */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */
Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */
float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
} SDL_ControllerSensorEvent;
/**
* \brief Audio device event structure (event.adevice.*)
*/
@@ -559,33 +590,35 @@ typedef struct SDL_SysWMEvent
*/
typedef union SDL_Event
{
Uint32 type; /**< Event type, shared with all events */
SDL_CommonEvent common; /**< Common event data */
SDL_DisplayEvent display; /**< Display event data */
SDL_WindowEvent window; /**< Window event data */
SDL_KeyboardEvent key; /**< Keyboard event data */
SDL_TextEditingEvent edit; /**< Text editing event data */
SDL_TextInputEvent text; /**< Text input event data */
SDL_MouseMotionEvent motion; /**< Mouse motion event data */
SDL_MouseButtonEvent button; /**< Mouse button event data */
SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
SDL_JoyBallEvent jball; /**< Joystick ball event data */
SDL_JoyHatEvent jhat; /**< Joystick hat event data */
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
SDL_AudioDeviceEvent adevice; /**< Audio device event data */
SDL_SensorEvent sensor; /**< Sensor event data */
SDL_QuitEvent quit; /**< Quit request event data */
SDL_UserEvent user; /**< Custom event data */
SDL_SysWMEvent syswm; /**< System dependent window event data */
SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
SDL_MultiGestureEvent mgesture; /**< Gesture event data */
SDL_DollarGestureEvent dgesture; /**< Gesture event data */
SDL_DropEvent drop; /**< Drag and drop event data */
Uint32 type; /**< Event type, shared with all events */
SDL_CommonEvent common; /**< Common event data */
SDL_DisplayEvent display; /**< Display event data */
SDL_WindowEvent window; /**< Window event data */
SDL_KeyboardEvent key; /**< Keyboard event data */
SDL_TextEditingEvent edit; /**< Text editing event data */
SDL_TextInputEvent text; /**< Text input event data */
SDL_MouseMotionEvent motion; /**< Mouse motion event data */
SDL_MouseButtonEvent button; /**< Mouse button event data */
SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
SDL_JoyBallEvent jball; /**< Joystick ball event data */
SDL_JoyHatEvent jhat; /**< Joystick hat event data */
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
SDL_ControllerTouchpadEvent ctouchpad; /**< Game Controller touchpad event data */
SDL_ControllerSensorEvent csensor; /**< Game Controller sensor event data */
SDL_AudioDeviceEvent adevice; /**< Audio device event data */
SDL_SensorEvent sensor; /**< Sensor event data */
SDL_QuitEvent quit; /**< Quit request event data */
SDL_UserEvent user; /**< Custom event data */
SDL_SysWMEvent syswm; /**< System dependent window event data */
SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
SDL_MultiGestureEvent mgesture; /**< Gesture event data */
SDL_DollarGestureEvent dgesture; /**< Gesture event data */
SDL_DropEvent drop; /**< Drag and drop event data */
/* This is necessary for ABI compatibility between Visual C++ and GCC
Visual C++ will respect the push pack pragma and use 52 bytes for
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -31,6 +31,7 @@
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "SDL_rwops.h"
#include "SDL_sensor.h"
#include "SDL_joystick.h"
#include "begin_code.h"
@@ -65,7 +66,8 @@ typedef enum
SDL_CONTROLLER_TYPE_PS3,
SDL_CONTROLLER_TYPE_PS4,
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO,
SDL_CONTROLLER_TYPE_VIRTUAL
SDL_CONTROLLER_TYPE_VIRTUAL,
SDL_CONTROLLER_TYPE_PS5
} SDL_GameControllerType;
typedef enum
@@ -171,7 +173,7 @@ extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID
*
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available
*/
extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController * gamecontroller);
extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController *gamecontroller);
/**
* Is the joystick on this index supported by the game controller interface?
@@ -246,19 +248,26 @@ extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController
* Get the USB vendor ID of an opened controller, if available.
* If the vendor ID isn't available this function returns 0.
*/
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController * gamecontroller);
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller);
/**
* Get the USB product ID of an opened controller, if available.
* If the product ID isn't available this function returns 0.
*/
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController * gamecontroller);
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller);
/**
* Get the product version of an opened controller, if available.
* If the product version isn't available this function returns 0.
*/
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller);
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller);
/**
* Get the serial number of an opened controller, if available.
*
* Returns the serial number of the controller, or NULL if it is not available.
*/
extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller);
/**
* Returns SDL_TRUE if the controller has been opened and currently connected,
@@ -329,6 +338,12 @@ extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
SDL_GameControllerAxis axis);
/**
* Return whether a game controller has a given axis
*/
extern DECLSPEC SDL_bool SDLCALL
SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
/**
* Get the current state of an axis control on a game controller.
*
@@ -338,8 +353,7 @@ SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
* The axis indices start at index 0.
*/
extern DECLSPEC Sint16 SDLCALL
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller,
SDL_GameControllerAxis axis);
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
/**
* The list of buttons available from a controller
@@ -362,6 +376,12 @@ typedef enum
SDL_CONTROLLER_BUTTON_DPAD_DOWN,
SDL_CONTROLLER_BUTTON_DPAD_LEFT,
SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button */
SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 */
SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 */
SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 */
SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 */
SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
SDL_CONTROLLER_BUTTON_MAX
} SDL_GameControllerButton;
@@ -382,6 +402,11 @@ extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
SDL_GameControllerButton button);
/**
* Return whether a game controller has a given button
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController *gamecontroller,
SDL_GameControllerButton button);
/**
* Get the current state of a button on a game controller.
@@ -392,7 +417,68 @@ extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *ga
SDL_GameControllerButton button);
/**
* Trigger a rumble effect
* Get the number of touchpads on a game controller.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller);
/**
* Get the number of supported simultaneous fingers on a touchpad on a game controller.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad);
/**
* Get the current state of a finger on a touchpad on a game controller.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
/**
* Return whether a game controller has a particular sensor.
*
* \param gamecontroller The controller to query
* \param type The type of sensor to query
*
* \return SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type);
/**
* Set whether data reporting for a game controller sensor is enabled
*
* \param gamecontroller The controller to update
* \param type The type of sensor to enable/disable
* \param enabled Whether data reporting should be enabled
*
* \return 0 or -1 if an error occurred.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type, SDL_bool enabled);
/**
* Query whether sensor data reporting is enabled for a game controller
*
* \param gamecontroller The controller to query
* \param type The type of sensor to query
*
* \return SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type);
/**
* Get the current state of a game controller sensor.
*
* The number of values and interpretation of the data is sensor dependent.
* See SDL_sensor.h for the details for each type of sensor.
*
* \param gamecontroller The controller to query
* \param type The type of sensor to query
* \param data A pointer filled with the current sensor state
* \param num_values The number of values to write to data
*
* \return 0 or -1 if an error occurred.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values);
/**
* Start a rumble effect
* Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
*
* \param gamecontroller The controller to vibrate
@@ -400,10 +486,44 @@ extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *ga
* \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
* \param duration_ms The duration of the rumble effect, in milliseconds
*
* \return 0, or -1 if rumble isn't supported on this joystick
* \return 0, or -1 if rumble isn't supported on this controller
*/
extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
/**
* Start a rumble effect in the game controller's triggers
* Each call to this function cancels any previous trigger rumble effect, and calling it with 0 intensity stops any rumbling.
*
* \param gamecontroller The controller to vibrate
* \param left_rumble The intensity of the left trigger rumble motor, from 0 to 0xFFFF
* \param right_rumble The intensity of the right trigger rumble motor, from 0 to 0xFFFF
* \param duration_ms The duration of the rumble effect, in milliseconds
*
* \return 0, or -1 if rumble isn't supported on this controller
*/
extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
/**
* Return whether a controller has an LED
*
* \param gamecontroller The controller to query
*
* \return SDL_TRUE, or SDL_FALSE if this controller does not have a modifiable LED
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *gamecontroller);
/**
* Update a controller's LED color.
*
* \param gamecontroller The controller to update
* \param red The intensity of the red LED
* \param green The intensity of the green LED
* \param blue The intensity of the blue LED
*
* \return 0, or -1 if this controller does not have a modifiable LED
*/
extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue);
/**
* Close a controller previously opened with SDL_GameControllerOpen().
*/
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -493,6 +493,7 @@ extern "C" {
* XboxOne
* PS3
* PS4
* PS5
* SwitchPro
*
* This hint affects what driver is used, and must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER)
@@ -618,6 +619,41 @@ extern "C" {
*/
#define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE "SDL_JOYSTICK_HIDAPI_PS4_RUMBLE"
/**
* \brief A variable controlling whether the HIDAPI driver for PS5 controllers should be used.
*
* This variable can be set to the following values:
* "0" - HIDAPI driver is not used
* "1" - HIDAPI driver is used
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/
#define SDL_HINT_JOYSTICK_HIDAPI_PS5 "SDL_JOYSTICK_HIDAPI_PS5"
/**
* \brief A variable controlling whether extended input reports should be used for PS5 controllers when using the HIDAPI driver.
*
* This variable can be set to the following values:
* "0" - extended reports are not enabled (the default)
* "1" - extended reports
*
* Extended input reports allow rumble on Bluetooth PS5 controllers, but
* break DirectInput handling for applications that don't use SDL.
*
* Once extended reports are enabled, they can not be disabled without
* power cycling the controller.
*/
#define SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE "SDL_JOYSTICK_HIDAPI_PS5_RUMBLE"
/**
* \brief A variable controlling whether the player LEDs should be lit to indicate which player is associated with a PS5 controller.
*
* This variable can be set to the following values:
* "0" - player LEDs are not enabled
* "1" - player LEDs are enabled (the default)
*/
#define SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED "SDL_JOYSTICK_HIDAPI_PS5_PLAYER_LED"
/**
* \brief A variable controlling whether the HIDAPI driver for Steam Controllers should be used.
*
@@ -697,15 +733,23 @@ extern "C" {
#define SDL_HINT_JOYSTICK_RAWINPUT "SDL_JOYSTICK_RAWINPUT"
/**
* \brief A variable controlling whether Linux joysticks adhere their HID-defined deadzones or return unfiltered values.
* This is useful for Wine which implements its own deadzone handler if requested by games, also it enables xinput
* games to receive unfiltered values as required from the API.
* \brief A variable controlling whether a separate thread should be used
* for handling joystick detection and raw input messages on Windows
*
* This variable can be set to the following values:
* "0" - Linux deadzones are not used by SDL
* "1" - Linux deadzones are used by SDL (the default)
* "0" - A separate thread is not used (the default)
* "1" - A separate thread is used for handling raw input messages
*
*/
#define SDL_HINT_JOYSTICK_THREAD "SDL_JOYSTICK_THREAD"
/**
* \brief A variable controlling whether joysticks on Linux adhere to their HID-defined deadzones or return unfiltered values.
*
* This variable can be set to the following values:
* "0" - Return unfiltered joystick axis values (the default)
* "1" - Return axis values with deadzones taken into account
*/
#define SDL_HINT_LINUX_JOYSTICK_DEADZONES "SDL_LINUX_JOYSTICK_DEADZONES"
/**
@@ -787,9 +831,32 @@ extern "C" {
*
* pthread hint values are "current", "other", "fifo" and "rr".
* Currently no other platform hint values are defined but may be in the future.
*
* \note On Linux, the kernel may send SIGKILL to realtime tasks which exceed the distro
* configured execution budget for rtkit. This budget can be queried through RLIMIT_RTTIME
* after calling SDL_SetThreadPriority().
*/
#define SDL_HINT_THREAD_PRIORITY_POLICY "SDL_THREAD_PRIORITY_POLICY"
/**
* \brief Specifies whether SDL_THREAD_PRIORITY_TIME_CRITICAL should be treated as realtime.
*
* On some platforms, like Linux, a realtime priority thread may be subject to restrictions
* that require special handling by the application. This hint exists to let SDL know that
* the app is prepared to handle said restrictions.
*
* On Linux, SDL will apply the following configuration to any thread that becomes realtime:
* * The SCHED_RESET_ON_FORK bit will be set on the scheduling policy,
* * An RLIMIT_RTTIME budget will be configured to the rtkit specified limit.
* * Exceeding this limit will result in the kernel sending SIGKILL to the app,
* * Refer to the man pages for more information.
*
* This variable can be set to the following values:
* "0" - default platform specific behaviour
* "1" - Force SDL_THREAD_PRIORITY_TIME_CRITICAL to a realtime scheduling policy
*/
#define SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL "SDL_THREAD_FORCE_REALTIME_TIME_CRITICAL"
/**
* \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac and iOS)
*/
@@ -1028,6 +1095,18 @@ extern "C" {
*/
#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE"
/**
* \brief A variable to control whether SDL will pause audio in background
* (Requires SDL_ANDROID_BLOCK_ON_PAUSE as "Non blocking")
*
* The variable can be set to the following values:
* "0" - Non paused.
* "1" - Paused. (default)
*
* The value should be set before SDL is initialized.
*/
#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO "SDL_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO"
/**
* \brief A variable to control whether the return key on the soft keyboard
* should hide the soft keyboard on Android and iOS.
@@ -1126,6 +1205,59 @@ extern "C" {
*/
#define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING "SDL_WINDOWS_DISABLE_THREAD_NAMING"
/**
* \brief Force SDL to use Critical Sections for mutexes on Windows.
* On Windows 7 and newer, Slim Reader/Writer Locks are available.
* They offer better performance, allocate no kernel ressources and
* use less memory. SDL will fall back to Critical Sections on older
* OS versions or if forced to by this hint.
* This also affects Condition Variables. When SRW mutexes are used,
* SDL will use Windows Condition Variables as well. Else, a generic
* SDL_cond implementation will be used that works with all mutexes.
*
* This variable can be set to the following values:
* "0" - Use SRW Locks when available. If not, fall back to Critical Sections. (default)
* "1" - Force the use of Critical Sections in all cases.
*
*/
#define SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS "SDL_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS"
/**
* \brief Force SDL to use Kernel Semaphores on Windows.
* Kernel Semaphores are inter-process and require a context
* switch on every interaction. On Windows 8 and newer, the
* WaitOnAddress API is available. Using that and atomics to
* implement semaphores increases performance.
* SDL will fall back to Kernel Objects on older OS versions
* or if forced to by this hint.
*
* This variable can be set to the following values:
* "0" - Use Atomics and WaitOnAddress API when available. If not, fall back to Kernel Objects. (default)
* "1" - Force the use of Kernel Objects in all cases.
*
*/
#define SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL "SDL_WINDOWS_FORCE_SEMAPHORE_KERNEL"
/**
* \brief Use the D3D9Ex API introduced in Windows Vista, instead of normal D3D9.
* Direct3D 9Ex contains changes to state management that can eliminate device
* loss errors during scenarios like Alt+Tab or UAC prompts. D3D9Ex may require
* some changes to your application to cope with the new behavior, so this
* is disabled by default.
*
* This hint must be set before initializing the video subsystem.
*
* For more information on Direct3D 9Ex, see:
* - https://docs.microsoft.com/en-us/windows/win32/direct3darticles/graphics-apis-in-windows-vista#direct3d-9ex
* - https://docs.microsoft.com/en-us/windows/win32/direct3darticles/direct3d-9ex-improvements
*
* This variable can be set to the following values:
* "0" - Use the original Direct3D 9 API (default)
* "1" - Use the Direct3D 9Ex API on Vista and later (and fall back if D3D9Ex is unavailable)
*
*/
#define SDL_HINT_WINDOWS_USE_D3D9EX "SDL_WINDOWS_USE_D3D9EX"
/**
* \brief Tell SDL which Dispmanx layer to use on a Raspberry PI
*
@@ -1247,6 +1379,32 @@ extern "C" {
#define SDL_HINT_RENDER_BATCHING "SDL_RENDER_BATCHING"
/**
* \brief A variable controlling whether SDL updates joystick state when getting input events
*
* This variable can be set to the following values:
*
* "0" - You'll call SDL_JoystickUpdate() manually
* "1" - SDL will automatically call SDL_JoystickUpdate() (default)
*
* This hint can be toggled on and off at runtime.
*/
#define SDL_HINT_AUTO_UPDATE_JOYSTICKS "SDL_AUTO_UPDATE_JOYSTICKS"
/**
* \brief A variable controlling whether SDL updates sensor state when getting input events
*
* This variable can be set to the following values:
*
* "0" - You'll call SDL_SensorUpdate() manually
* "1" - SDL will automatically call SDL_SensorUpdate() (default)
*
* This hint can be toggled on and off at runtime.
*/
#define SDL_HINT_AUTO_UPDATE_SENSORS "SDL_AUTO_UPDATE_SENSORS"
/**
* \brief A variable controlling whether SDL logs all events pushed onto its internal queue.
*
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -105,6 +105,11 @@ typedef enum
SDL_JOYSTICK_POWER_MAX
} SDL_JoystickPowerLevel;
/* Set max recognized G-force from accelerometer
See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
*/
#define SDL_IPHONE_MAX_GFORCE 5.0
/* Function prototypes */
@@ -230,55 +235,62 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index);
*
* Returns 0 on success, -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick * joystick, int axis, Sint16 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick * joystick, int button, Uint8 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick * joystick, int hat, Uint8 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
/**
* Return the name for this currently opened joystick.
* If no name can be found, this function returns NULL.
*/
extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick);
/**
* Get the player index of an opened joystick, or -1 if it's not available
*
* For XInput controllers this returns the XInput user index.
*/
extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick * joystick);
extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick);
/**
* Set the player index of an opened joystick
*/
extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick * joystick, int player_index);
extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index);
/**
* Return the GUID for this opened joystick
*/
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick);
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick *joystick);
/**
* Get the USB vendor ID of an opened joystick, if available.
* If the vendor ID isn't available this function returns 0.
*/
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick * joystick);
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick *joystick);
/**
* Get the USB product ID of an opened joystick, if available.
* If the product ID isn't available this function returns 0.
*/
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick * joystick);
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick *joystick);
/**
* Get the product version of an opened joystick, if available.
* If the product version isn't available this function returns 0.
*/
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick * joystick);
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick *joystick);
/**
* Get the serial number of an opened joystick, if available.
*
* Returns the serial number of the joystick, or NULL if it is not available.
*/
extern DECLSPEC const char * SDLCALL SDL_JoystickGetSerial(SDL_Joystick *joystick);
/**
* Get the type of an opened joystick.
*/
extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick * joystick);
extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick *joystick);
/**
* Return a string representation for this guid. pszGUID must point to at least 33 bytes
@@ -294,17 +306,17 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const cha
/**
* Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick);
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick *joystick);
/**
* Get the instance ID of an opened joystick or -1 if the joystick is invalid.
*/
extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick);
extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joystick);
/**
* Get the number of general axis controls on a joystick.
*/
extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick);
extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick);
/**
* Get the number of trackballs on a joystick.
@@ -312,17 +324,17 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick);
* Joystick trackballs have only relative motion events associated
* with them and their state cannot be polled.
*/
extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick);
extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
/**
* Get the number of POV hats on a joystick.
*/
extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick);
extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick);
/**
* Get the number of buttons on a joystick.
*/
extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick);
extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick);
/**
* Update the current state of the open joysticks.
@@ -352,7 +364,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
*
* The axis indices start at index 0.
*/
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick,
int axis);
/**
@@ -364,7 +376,7 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
*
* \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick * joystick,
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *joystick,
int axis, Sint16 *state);
/**
@@ -398,7 +410,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *
* - ::SDL_HAT_LEFTUP
* - ::SDL_HAT_LEFTDOWN
*/
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick,
int hat);
/**
@@ -408,7 +420,7 @@ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
*
* The ball indices start at index 0.
*/
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick,
int ball, int *dx, int *dy);
/**
@@ -416,11 +428,11 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
*
* The button indices start at index 0.
*/
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick,
int button);
/**
* Trigger a rumble effect
* Start a rumble effect
* Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
*
* \param joystick The joystick to vibrate
@@ -430,17 +442,51 @@ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
*
* \return 0, or -1 if rumble isn't supported on this joystick
*/
extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
/**
* Start a rumble effect in the joystick's triggers
* Each call to this function cancels any previous trigger rumble effect, and calling it with 0 intensity stops any rumbling.
*
* \param joystick The joystick to vibrate
* \param left_rumble The intensity of the left trigger rumble motor, from 0 to 0xFFFF
* \param right_rumble The intensity of the right trigger rumble motor, from 0 to 0xFFFF
* \param duration_ms The duration of the rumble effect, in milliseconds
*
* \return 0, or -1 if trigger rumble isn't supported on this joystick
*/
extern DECLSPEC int SDLCALL SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
/**
* Return whether a joystick has an LED
*
* \param joystick The joystick to query
*
* \return SDL_TRUE, or SDL_FALSE if this joystick does not have a modifiable LED
*/
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick);
/**
* Update a joystick's LED color.
*
* \param joystick The joystick to update
* \param red The intensity of the red LED
* \param green The intensity of the green LED
* \param blue The intensity of the blue LED
*
* \return 0, or -1 if this joystick does not have a modifiable LED
*/
extern DECLSPEC int SDLCALL SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
/**
* Close a joystick previously opened with SDL_JoystickOpen().
*/
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);
/**
* Return the battery level of this joystick
*/
extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick);
extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick *joystick);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -88,9 +88,11 @@ typedef enum
SDLK_GREATER = '>',
SDLK_QUESTION = '?',
SDLK_AT = '@',
/*
Skip uppercase letters
*/
SDLK_LEFTBRACKET = '[',
SDLK_BACKSLASH = '\\',
SDLK_RIGHTBRACKET = ']',
@@ -341,7 +343,7 @@ typedef enum
KMOD_CTRL = KMOD_LCTRL | KMOD_RCTRL,
KMOD_SHIFT = KMOD_LSHIFT | KMOD_RSHIFT,
KMOD_ALT = KMOD_LALT | KMOD_RALT,
KMOD_GUI = KMOD_LGUI | KMOD_RGUI,
KMOD_GUI = KMOD_LGUI | KMOD_RGUI
} SDL_Keymod;
#endif /* SDL_keycode_h_ */

Some files were not shown because too many files have changed in this diff Show More