mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-10-22 08:07:22 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2283b56b9 | ||
|
|
b515f2a599 | ||
|
|
4354b49496 | ||
|
|
994312c212 | ||
|
|
5f25e0d4e2 | ||
|
|
4bbe571f5f | ||
|
|
c58d21375c | ||
|
|
ed128c558f | ||
|
|
828932d95c | ||
|
|
42ced309d3 | ||
|
|
1fcd306879 | ||
|
|
26c9ad7f06 | ||
|
|
4b7b01ce0a | ||
|
|
6632154906 | ||
|
|
ca67c7ef43 | ||
|
|
c4039a929c | ||
|
|
a1b74e1220 | ||
|
|
01f6188824 | ||
|
|
283f31a734 | ||
|
|
b800ce9ebe | ||
|
|
eb9d54465c | ||
|
|
eb9e1f81d4 | ||
|
|
ddfbd70b55 | ||
|
|
51e9ab83ad | ||
|
|
5ed7e03b2e | ||
|
|
0cb8d5b12f | ||
|
|
b4548c1af2 | ||
|
|
0a396f3112 | ||
|
|
2aa18dc88f | ||
|
|
8d89983eeb | ||
|
|
573c470965 | ||
|
|
daa0c751e2 | ||
|
|
e1babefc80 | ||
|
|
ce99b0e162 | ||
|
|
4c3a23b1bd | ||
|
|
12016af326 | ||
|
|
fc9871b075 | ||
|
|
3cb3c1c6d8 | ||
|
|
8fe3474589 | ||
|
|
dc3c565ec0 | ||
|
|
350c7d7081 | ||
|
|
0428bc8fe3 | ||
|
|
514a8575a2 | ||
|
|
fc11377552 | ||
|
|
fbaa70a2ae | ||
|
|
f30c11ddf4 | ||
|
|
51c4ecc879 | ||
|
|
080421f2fb | ||
|
|
8cc61ca8b8 | ||
|
|
400754c5b3 | ||
|
|
05e82c24f8 | ||
|
|
97c15c7876 | ||
|
|
36e7cc8e89 | ||
|
|
ad2ce4de53 | ||
|
|
2a28f7c4d2 | ||
|
|
0cdbe080a6 | ||
|
|
96fe1a7da1 | ||
|
|
4f73af2920 | ||
|
|
7ca4e49bf5 | ||
|
|
dfa63297fc | ||
|
|
402e8c1897 | ||
|
|
33e814122e | ||
|
|
f28a4df5ee | ||
|
|
417aa2815c | ||
|
|
2fdabe37aa | ||
|
|
d8270dfb6a | ||
|
|
b75f662c41 | ||
|
|
0d9d0845f5 | ||
|
|
5d66a1f298 | ||
|
|
9bf52eb63a | ||
|
|
0c9d72a9a1 | ||
|
|
c2c2bd2df6 | ||
|
|
78fc594d84 | ||
|
|
53b1e7c573 | ||
|
|
c14404a7c1 | ||
|
|
96e6750f9c | ||
|
|
dbafd05a4e | ||
|
|
d7fd578cc3 | ||
|
|
0e8572e1db | ||
|
|
98a997bd8e | ||
|
|
6fbc95cc41 | ||
|
|
1852f74e8b | ||
|
|
55e3e16860 | ||
|
|
7cf2a55b43 | ||
|
|
c41cbbd2da | ||
|
|
7283bb046b | ||
|
|
dd2df6cbcf | ||
|
|
01f1cac811 | ||
|
|
aaa112c3f3 | ||
|
|
dc0fa9c64d | ||
|
|
f749b38aa2 | ||
|
|
43d79673e1 | ||
|
|
fc841f572c | ||
|
|
df9f117a08 | ||
|
|
bedc46a1be | ||
|
|
a7c6095be5 | ||
|
|
f2d5cf785e | ||
|
|
f926ad9b5e | ||
|
|
68acf969f2 | ||
|
|
65d53e800b | ||
|
|
e44d8ac7e9 | ||
|
|
d1823dd6e1 | ||
|
|
80bfd3b8e9 | ||
|
|
07128cc7fe | ||
|
|
0892f0b0bb | ||
|
|
8cf7f3ac08 | ||
|
|
ab2bb51879 | ||
|
|
8cb98b5365 | ||
|
|
782c5f8a34 | ||
|
|
d6b5c5f63e | ||
|
|
ef6dfa6d91 | ||
|
|
3840ee8ee7 | ||
|
|
f47e40fa2a | ||
|
|
49a4a61876 | ||
|
|
669c1a6f0d | ||
|
|
15342190fa | ||
|
|
c98ef6e8a9 | ||
|
|
d36d5936da | ||
|
|
70de75ae3d | ||
|
|
ea62e33e51 | ||
|
|
524e92c81a | ||
|
|
d5a26b1d70 | ||
|
|
cd7649a666 | ||
|
|
847cc0a38a | ||
|
|
3588eb9bf8 | ||
|
|
296e22d3ca | ||
|
|
923e590da1 | ||
|
|
e56329d05a | ||
|
|
2452e80e57 | ||
|
|
b9019831a9 | ||
|
|
b3b49b440e | ||
|
|
cbedf0f74f | ||
|
|
6c980eba68 | ||
|
|
e9f766904e | ||
|
|
62d76c006d | ||
|
|
615b78a612 | ||
|
|
aaf0340d6c | ||
|
|
93ea437760 | ||
|
|
fe6a1244ed | ||
|
|
953858b0e7 | ||
|
|
f3da46833f | ||
|
|
ba2488b6e2 | ||
|
|
4e7e0d67e5 | ||
|
|
faa16b207c | ||
|
|
2d9f62761c | ||
|
|
60689f531d | ||
|
|
3f97692311 | ||
|
|
81221336f4 | ||
|
|
ecfc758ce4 | ||
|
|
2cb3a132c6 | ||
|
|
519473e498 | ||
|
|
9b271d918a | ||
|
|
5b4d874851 | ||
|
|
9dc1dbc002 | ||
|
|
7ee323f0d5 | ||
|
|
4bb6f711b9 | ||
|
|
816cec8f5c | ||
|
|
2394dfe88a | ||
|
|
dfc0d2303b | ||
|
|
598a48ec50 | ||
|
|
9f41e98e3f | ||
|
|
489891ff3c | ||
|
|
a44ed0b047 | ||
|
|
1aaa97b91d | ||
|
|
13d68e789f | ||
|
|
10dae7482c | ||
|
|
979de190dc | ||
|
|
46bcbda972 | ||
|
|
43bdc353fb | ||
|
|
6314676b9c | ||
|
|
9f77f3d968 | ||
|
|
f4733dbbe8 | ||
|
|
61fc0e4893 | ||
|
|
652ad86cad | ||
|
|
60f308bd76 | ||
|
|
b2113ff95b | ||
|
|
b8188a46a9 | ||
|
|
e790b0761e | ||
|
|
fa3317f6cd | ||
|
|
b080f7a81c | ||
|
|
57a1c5eb76 | ||
|
|
5b7e2521cc | ||
|
|
fced653c1c | ||
|
|
9253e6ac5e | ||
|
|
aff2ed22b9 | ||
|
|
5520a52379 | ||
|
|
505050e936 | ||
|
|
0437835bde | ||
|
|
77386f8dfc | ||
|
|
529fdf0341 | ||
|
|
fa74700ad9 | ||
|
|
caca491943 | ||
|
|
4794f44a6d | ||
|
|
f0119b1231 | ||
|
|
4c579aa826 | ||
|
|
b9463b3c0e | ||
|
|
cede6ce8a9 | ||
|
|
956e6e3638 | ||
|
|
b282c7d815 | ||
|
|
5b6142e2d9 | ||
|
|
58313ad8fc | ||
|
|
7aff148e9f | ||
|
|
ee5c61fb74 | ||
|
|
91be6c8028 | ||
|
|
2e0bd2ec28 | ||
|
|
a0151fbc04 | ||
|
|
d853782fea | ||
|
|
c6638a7154 | ||
|
|
4abebe3aec | ||
|
|
5aed8f928a | ||
|
|
afe6cfc383 | ||
|
|
174983ce1e | ||
|
|
1313c7b3bf | ||
|
|
bee622bcad | ||
|
|
8cefdeae49 | ||
|
|
7cf70b9607 | ||
|
|
add4b582b5 | ||
|
|
b419d21940 |
No files matched your search
@@ -1,10 +1,10 @@
|
|||||||
---
|
---
|
||||||
name: Bug report
|
name: Bug report
|
||||||
about: Create a report to help us address issues in Moonlight
|
about: Ask for help on Discord before reporting a bug
|
||||||
|
|
||||||
---
|
---
|
||||||
**READ ME FIRST!**
|
**READ ME FIRST!**
|
||||||
This issue tracker is not the right place to ask for troubleshooting help if you're not able to connect or stream at all. For those requests, please use the #pc-help channel on our Discord server where there are many more people who can help (or direct you back here if it looks like a Moonlight bug after all). https://discord.gg/MySTSdq
|
This issue tracker is not the right place to ask for troubleshooting help if you're not able to connect or stream at all. For those requests, please use the #pc-help channel on our Discord server where there are many more people who can help (or direct you back here if it looks like a Moonlight bug after all). https://moonlight-stream.org/discord
|
||||||
|
|
||||||
**Describe the bug**
|
**Describe the bug**
|
||||||
A clear and concise description of what the bug is.
|
A clear and concise description of what the bug is.
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
issuesOpened: >
|
issuesOpened: >
|
||||||
If this is a question about Moonlight or you need help troubleshooting a streaming problem, please use the help channels on our [Discord server](https://discord.gg/MySTSdq) instead of GitHub issues. There are many more people available on Discord to help you and answer your questions.<br /><br />
|
If this is a question about Moonlight or you need help troubleshooting a streaming problem, please use the help channels on our [Discord server](https://moonlight-stream.org/discord) instead of GitHub issues. There are many more people available on Discord to help you and answer your questions.<br /><br />
|
||||||
This issue tracker should only be used for specific bugs or feature requests.<br /><br />
|
This issue tracker should only be used for specific bugs or feature requests.<br /><br />
|
||||||
Thank you, and happy streaming!
|
Thank you, and happy streaming!
|
||||||
-72
@@ -1,72 +0,0 @@
|
|||||||
language: cpp
|
|
||||||
|
|
||||||
git:
|
|
||||||
depth: 1
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: osx
|
|
||||||
osx_image: xcode10.2
|
|
||||||
compiler: clang
|
|
||||||
env: TRAVIS_TARGET=osx
|
|
||||||
addons:
|
|
||||||
homebrew:
|
|
||||||
packages:
|
|
||||||
- qt
|
|
||||||
- os: linux
|
|
||||||
sudo: required
|
|
||||||
dist: xenial
|
|
||||||
compiler: gcc
|
|
||||||
env: TRAVIS_TARGET=steamlink
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libc6:i386
|
|
||||||
- libstdc++6:i386
|
|
||||||
- os: linux
|
|
||||||
sudo: required
|
|
||||||
dist: bionic
|
|
||||||
compiler: gcc
|
|
||||||
env: TRAVIS_TARGET=linux
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- sourceline: 'ppa:savoury1/multimedia'
|
|
||||||
- sourceline: 'ppa:savoury1/ffmpeg4'
|
|
||||||
packages:
|
|
||||||
- qt5-default
|
|
||||||
- qtbase5-dev
|
|
||||||
- qtquickcontrols2-5-dev
|
|
||||||
- libqt5svg5-dev
|
|
||||||
- libgl1-mesa-dev
|
|
||||||
- libegl1-mesa-dev
|
|
||||||
- libxkbcommon-dev
|
|
||||||
- wayland-protocols
|
|
||||||
- libopus-dev
|
|
||||||
- libva-dev
|
|
||||||
- libvdpau-dev
|
|
||||||
- libsdl2-dev
|
|
||||||
- qtdeclarative5-dev
|
|
||||||
- libssl-dev
|
|
||||||
- libsdl2-ttf-dev
|
|
||||||
- libavcodec-dev
|
|
||||||
- libavutil-dev
|
|
||||||
|
|
||||||
install:
|
|
||||||
- '[ "$TRAVIS_TARGET" != osx ] || brew link --force qt'
|
|
||||||
- if [[ "$TRAVIS_TARGET" = "osx" ]]; then nvm use node && npm install --global create-dmg; fi
|
|
||||||
- if [[ "$TRAVIS_TARGET" = "steamlink" ]]; then git clone --depth=1 https://github.com/ValveSoftware/steamlink-sdk.git $HOME/steamlink-sdk; fi
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- '[ "$TRAVIS_TARGET" = "steamlink" ] || qmake -v'
|
|
||||||
- '[[ "$TRAVIS_TARGET" != linux || "$CXX" != clang++ ]] || export QMAKESPEC=linux-clang'
|
|
||||||
- '[[ "$TRAVIS_TARGET" != linux || "$CXX" != g++ ]] || export QMAKESPEC=linux-g++'
|
|
||||||
- '[ "$TRAVIS_TARGET" != osx ] || export QMAKESPEC=macx-clang'
|
|
||||||
- '[ "$TRAVIS_TARGET" != "steamlink" ] || export STEAMLINK_SDK_PATH=$HOME/steamlink-sdk'
|
|
||||||
|
|
||||||
script:
|
|
||||||
- '[ "$TRAVIS_TARGET" != "linux" ] || qmake moonlight-qt.pro -spec $QMAKESPEC'
|
|
||||||
- '[ "$TRAVIS_TARGET" != "linux" ] || make -j$(nproc) debug'
|
|
||||||
- '[ "$TRAVIS_TARGET" != "linux" ] || make -j$(nproc) release'
|
|
||||||
- '[ "$TRAVIS_TARGET" != "osx" ] || scripts/generate-dmg.sh Release'
|
|
||||||
- '[ "$TRAVIS_TARGET" != "steamlink" ] || scripts/build-steamlink-app.sh'
|
|
||||||
@@ -131,17 +131,22 @@ private:
|
|||||||
static LoadLibraryExWFunc s_RealLoadLibraryExW;
|
static LoadLibraryExWFunc s_RealLoadLibraryExW;
|
||||||
|
|
||||||
static constexpr LPCWSTR k_BlacklistedDlls[] = {
|
static constexpr LPCWSTR k_BlacklistedDlls[] = {
|
||||||
// This DLL shipped with ASUS Sonic Radar 3 improperly handles
|
// These A-Volute DLLs shipped with various audio driver packages improperly handle
|
||||||
// D3D9 exclusive fullscreen in a way that causes CreateDeviceEx()
|
// D3D9 exclusive fullscreen in a way that causes CreateDeviceEx() to deadlock.
|
||||||
// to deadlock. https://github.com/moonlight-stream/moonlight-qt/issues/102
|
// https://github.com/moonlight-stream/moonlight-qt/issues/102
|
||||||
L"NahimicOSD.dll",
|
L"NahimicOSD.dll", // ASUS Sonic Radar 3
|
||||||
|
L"SSAudioOSD.dll", // SteelSeries headsets
|
||||||
|
L"SS2OSD.dll", // ASUS Sonic Studio 2
|
||||||
|
L"Nahimic2OSD.dll",
|
||||||
|
L"NahimicMSIOSD.dll",
|
||||||
|
L"nhAsusPhoebusOSD.dll" // ASUS Phoebus
|
||||||
|
|
||||||
// This DLL has been seen in several crash reports. Some Googling
|
// This DLL has been seen in several crash reports. Some Googling
|
||||||
// suggests it's highly unstable and causes issues in many games.
|
// suggests it's highly unstable and causes issues in many games.
|
||||||
L"EZFRD32.dll",
|
L"EZFRD32.dll",
|
||||||
L"EZFRD64.dll",
|
L"EZFRD64.dll",
|
||||||
|
|
||||||
// These are the dList DLLs for Optimus hybrid graphics DDI.
|
// These are the newer dList DLLs for Optimus hybrid graphics DDI.
|
||||||
// https://docs.microsoft.com/en-us/windows-hardware/drivers/display/hybrid-system-ddi
|
// https://docs.microsoft.com/en-us/windows-hardware/drivers/display/hybrid-system-ddi
|
||||||
//
|
//
|
||||||
// We forcefully block them from loading because Optimus has a bug that
|
// We forcefully block them from loading because Optimus has a bug that
|
||||||
@@ -152,6 +157,33 @@ private:
|
|||||||
L"nvdlist.dll",
|
L"nvdlist.dll",
|
||||||
L"nvdlistx.dll",
|
L"nvdlistx.dll",
|
||||||
|
|
||||||
|
// These are the older dList/AppInit DLLs for Optimus hybrid graphics DDI.
|
||||||
|
// https://docs.microsoft.com/en-us/windows-hardware/drivers/display/hybrid-system-ddi
|
||||||
|
//
|
||||||
|
// These seem to cause a crash in PresentEx() in full-screen exclusive mode.
|
||||||
|
// This block will prevent Optimus from ever using the dGPU even if the user has requested it.
|
||||||
|
// https://github.com/moonlight-stream/moonlight-qt/issues/386
|
||||||
|
//
|
||||||
|
// d3d9!CSwapChain::BltToHybridPrimary+0x200:
|
||||||
|
// 00007ffa`23f37e58 488b01 mov rax,qword ptr [rcx] ds:00000000`00000038=????????????????
|
||||||
|
// 00 0000004e`496ff4e0 00007ffa`23f39e2c d3d9!CSwapChain::BltToHybridPrimary+0x200
|
||||||
|
// 01 0000004e`496ff880 00007ffa`23ee39ce d3d9!CSwapChain::FlipToSurface+0x15c
|
||||||
|
// 02 0000004e`496ff900 00007ffa`23f4dd75 d3d9!CSwapChain::PresentMain+0x3e13e
|
||||||
|
// 03 0000004e`496ffab0 00007ffa`23f4dccd d3d9!CBaseDevice::PresentMain+0x9d
|
||||||
|
// 04 0000004e`496ffb00 00007ff7`8e31016f d3d9!CBaseDevice::PresentEx+0xbd
|
||||||
|
// 05 0000004e`496ffb50 00007ff7`8e30df1e Moonlight!DXVA2Renderer::renderFrame+0x61f [C:\moonlight-qt\app\streaming\video\ffmpeg-renderers\dxva2.cpp @ 1035]
|
||||||
|
// 06 0000004e`496ffd50 00007ff7`8e30e46a Moonlight!Pacer::renderFrame+0x3e [C:\moonlight-qt\app\streaming\video\ffmpeg-renderers\pacer\pacer.cpp @ 265]
|
||||||
|
// 07 (Inline Function) --------`-------- Moonlight!Pacer::renderLastFrameAndUnlock+0x197 [C:\moonlight-qt\app\streaming\video\ffmpeg-renderers\pacer\pacer.cpp @ 156]
|
||||||
|
// 08 0000004e`496ffda0 00007ffa`14476978 Moonlight!Pacer::renderThread+0x1ca [C:\moonlight-qt\app\streaming\video\ffmpeg-renderers\pacer\pacer.cpp @ 88]
|
||||||
|
// 09 0000004e`496ffde0 00007ffa`14476ee2 SDL2!SDL_RunThread+0x38 [C:\Users\camer\SDL\src\thread\SDL_thread.c @ 276]
|
||||||
|
// 0a 0000004e`496ffe10 00007ffa`2aae0e82 SDL2!RunThread+0x12 [C:\Users\camer\SDL\src\thread\windows\SDL_systhread.c @ 83]
|
||||||
|
// 0b 0000004e`496ffe40 00007ffa`2d627bd4 ucrtbase!thread_start<unsigned int (__cdecl*)(void *),1>+0x42
|
||||||
|
// 0c 0000004e`496ffe70 00007ffa`2da4ce51 kernel32!BaseThreadInitThunk+0x14
|
||||||
|
// 0d 0000004e`496ffea0 00000000`00000000 ntdll!RtlUserThreadStart+0x21
|
||||||
|
//
|
||||||
|
L"nvinit.dll",
|
||||||
|
L"nvinitx.dll",
|
||||||
|
|
||||||
// In some unknown circumstances, RTSS tries to hook in the middle of an instruction, leaving garbage
|
// In some unknown circumstances, RTSS tries to hook in the middle of an instruction, leaving garbage
|
||||||
// code inside d3d9.dll that causes a crash when executed:
|
// code inside d3d9.dll that causes a crash when executed:
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -4,31 +4,33 @@
|
|||||||
|
|
||||||
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://discord.gg/6ERtzFY).
|
You can follow development on our [Discord server](https://moonlight-stream.org/discord).
|
||||||
|
|
||||||
[](https://ci.appveyor.com/project/cgutman/moonlight-qt/branch/master)
|
[](https://ci.appveyor.com/project/cgutman/moonlight-qt/branch/master)
|
||||||
[](https://travis-ci.org/moonlight-stream/moonlight-qt)
|
|
||||||
[](https://github.com/moonlight-stream/moonlight-qt/releases)
|
[](https://github.com/moonlight-stream/moonlight-qt/releases)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Hardware accelerated video decoding on Windows, Mac, and Linux
|
- Hardware accelerated video decoding on Windows, Mac, and Linux
|
||||||
- Supports streaming at up to 120 FPS (high refresh rate monitor recommended)
|
- Supports streaming at up to 120 FPS (high refresh rate monitor recommended)
|
||||||
- Supports streaming at 720p, 1080p, 1440p, 4K, and the client PC's native screen resolution
|
- Supports streaming at 720p, 1080p, 1440p, 4K, and the client PC's native screen resolution
|
||||||
- 5.1 surround sound audio
|
- 7.1 surround sound audio support
|
||||||
|
- Support for both pointer capture (for games) and direct mouse control (for remote desktop)
|
||||||
|
- Direct touchscreen mouse control
|
||||||
- HEVC support for better image quality at reduced bandwidth
|
- HEVC support for better image quality at reduced bandwidth
|
||||||
- Keyboard and mouse support
|
|
||||||
- Gamepad support with force feedback for up to 4 players
|
- Gamepad support with force feedback for up to 4 players
|
||||||
|
|
||||||
## Downloads
|
## Downloads
|
||||||
- [Windows, macOS, and Steam Link](https://github.com/moonlight-stream/moonlight-qt/releases)
|
- [Windows, macOS, and Steam Link](https://github.com/moonlight-stream/moonlight-qt/releases)
|
||||||
- [Snap (for Ubuntu-based Linux distros)](https://snapcraft.io/moonlight)
|
- [Snap (for Ubuntu-based Linux distros)](https://snapcraft.io/moonlight)
|
||||||
- [Flatpak (for other Linux distros)](https://flathub.org/apps/details/com.moonlight_stream.Moonlight)
|
- [Flatpak (for other Linux distros)](https://flathub.org/apps/details/com.moonlight_stream.Moonlight)
|
||||||
|
- [AppImage](https://github.com/moonlight-stream/moonlight-qt/releases)
|
||||||
|
- [Raspberry Pi 4](https://github.com/moonlight-stream/moonlight-docs/wiki/Installing-Moonlight-Qt-on-Raspberry-Pi-4)
|
||||||
|
- [NVIDIA Jetson and Nintendo Switch (Ubuntu L4T)](https://github.com/moonlight-stream/moonlight-docs/wiki/Installing-Moonlight-Qt-on-Linux4Tegra-(L4T)-Ubuntu)
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
### General Build Requirements
|
|
||||||
* Qt 5.9 SDK or later
|
|
||||||
|
|
||||||
### Windows-specific Build Requirements
|
### Windows Build Requirements
|
||||||
|
* Qt 5.12.4 SDK or later
|
||||||
* Windows 7 or later
|
* Windows 7 or later
|
||||||
* [Visual Studio](https://visualstudio.microsoft.com/downloads/) 2017 (Community edition is fine)
|
* [Visual Studio](https://visualstudio.microsoft.com/downloads/) 2017 (Community edition is fine)
|
||||||
* Select MSVC Desktop toolchain during Qt installation
|
* Select MSVC Desktop toolchain during Qt installation
|
||||||
@@ -36,17 +38,19 @@ You can follow development on our [Discord server](https://discord.gg/6ERtzFY).
|
|||||||
* [7-Zip](https://www.7-zip.org/) (only if building installers for non-development PCs)
|
* [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](http://wixtoolset.org/releases/) v3.11 or later (only if building installers for non-development PCs)
|
||||||
|
|
||||||
### Mac-specific Build Requirements
|
### macOS Build Requirements
|
||||||
* macOS Sierra (10.12) or later
|
* Qt 5.14 SDK or later
|
||||||
* Xcode 10
|
* 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)
|
* [create-dmg](https://github.com/sindresorhus/create-dmg) (only if building DMGs for use on non-development Macs)
|
||||||
|
|
||||||
### Linux-specific Build Requirements
|
### Linux/Unix Build Requirements
|
||||||
|
* Qt 5.9 SDK or later
|
||||||
* GCC or Clang
|
* 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`
|
* 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/
|
* 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/
|
||||||
|
|
||||||
### Steam Link-specific Build Requirements
|
### Steam Link Build Requirements
|
||||||
* [Steam Link SDK](https://github.com/ValveSoftware/steamlink-sdk) cloned on your build system
|
* [Steam Link SDK](https://github.com/ValveSoftware/steamlink-sdk) cloned on your build system
|
||||||
* STEAMLINK_SDK_PATH environment variable set to the Steam Link SDK path
|
* STEAMLINK_SDK_PATH environment variable set to the Steam Link SDK path
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule app/SDL_GameControllerDB updated: aeebc86f9f...64dbb2ae89.
+36
-5
@@ -46,7 +46,7 @@ win32 {
|
|||||||
LIBS += -L$$(DXSDK_DIR)/Lib/x64
|
LIBS += -L$$(DXSDK_DIR)/Lib/x64
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBS += ws2_32.lib winmm.lib dxva2.lib ole32.lib gdi32.lib user32.lib d3d9.lib dwmapi.lib dbghelp.lib
|
LIBS += ws2_32.lib winmm.lib dxva2.lib ole32.lib gdi32.lib user32.lib d3d9.lib dwmapi.lib dbghelp.lib qwave.lib
|
||||||
}
|
}
|
||||||
macx {
|
macx {
|
||||||
INCLUDEPATH += $$PWD/../libs/mac/include
|
INCLUDEPATH += $$PWD/../libs/mac/include
|
||||||
@@ -104,6 +104,16 @@ unix:!macx {
|
|||||||
CONFIG += libdrm
|
CONFIG += libdrm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packagesExist(wayland-client) {
|
||||||
|
DEFINES += HAS_WAYLAND
|
||||||
|
PKGCONFIG += wayland-client
|
||||||
|
}
|
||||||
|
|
||||||
|
packagesExist(x11) {
|
||||||
|
DEFINES += HAS_X11
|
||||||
|
PKGCONFIG += x11
|
||||||
|
}
|
||||||
}
|
}
|
||||||
win32 {
|
win32 {
|
||||||
LIBS += -llibssl -llibcrypto -lSDL2 -lSDL2_ttf -lavcodec -lavutil -lopus -ld3dx9
|
LIBS += -llibssl -llibcrypto -lSDL2 -lSDL2_ttf -lavcodec -lavutil -lopus -ld3dx9
|
||||||
@@ -123,6 +133,7 @@ macx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
backend/nvapp.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
backend/computerseeker.cpp \
|
backend/computerseeker.cpp \
|
||||||
backend/identitymanager.cpp \
|
backend/identitymanager.cpp \
|
||||||
@@ -136,7 +147,12 @@ SOURCES += \
|
|||||||
cli/quitstream.cpp \
|
cli/quitstream.cpp \
|
||||||
cli/startstream.cpp \
|
cli/startstream.cpp \
|
||||||
settings/streamingpreferences.cpp \
|
settings/streamingpreferences.cpp \
|
||||||
streaming/input.cpp \
|
streaming/input/abstouch.cpp \
|
||||||
|
streaming/input/gamepad.cpp \
|
||||||
|
streaming/input/input.cpp \
|
||||||
|
streaming/input/keyboard.cpp \
|
||||||
|
streaming/input/mouse.cpp \
|
||||||
|
streaming/input/reltouch.cpp \
|
||||||
streaming/session.cpp \
|
streaming/session.cpp \
|
||||||
streaming/audio/audio.cpp \
|
streaming/audio/audio.cpp \
|
||||||
streaming/audio/renderers/sdlaud.cpp \
|
streaming/audio/renderers/sdlaud.cpp \
|
||||||
@@ -148,9 +164,11 @@ SOURCES += \
|
|||||||
settings/mappingmanager.cpp \
|
settings/mappingmanager.cpp \
|
||||||
gui/sdlgamepadkeynavigation.cpp \
|
gui/sdlgamepadkeynavigation.cpp \
|
||||||
streaming/video/overlaymanager.cpp \
|
streaming/video/overlaymanager.cpp \
|
||||||
backend/systemproperties.cpp
|
backend/systemproperties.cpp \
|
||||||
|
wm.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
backend/nvapp.h \
|
||||||
utils.h \
|
utils.h \
|
||||||
backend/computerseeker.h \
|
backend/computerseeker.h \
|
||||||
backend/identitymanager.h \
|
backend/identitymanager.h \
|
||||||
@@ -164,7 +182,7 @@ HEADERS += \
|
|||||||
cli/quitstream.h \
|
cli/quitstream.h \
|
||||||
cli/startstream.h \
|
cli/startstream.h \
|
||||||
settings/streamingpreferences.h \
|
settings/streamingpreferences.h \
|
||||||
streaming/input.h \
|
streaming/input/input.h \
|
||||||
streaming/session.h \
|
streaming/session.h \
|
||||||
streaming/audio/renderers/renderer.h \
|
streaming/audio/renderers/renderer.h \
|
||||||
streaming/audio/renderers/sdl.h \
|
streaming/audio/renderers/sdl.h \
|
||||||
@@ -246,6 +264,16 @@ libdrm {
|
|||||||
SOURCES += streaming/video/ffmpeg-renderers/drm.cpp
|
SOURCES += streaming/video/ffmpeg-renderers/drm.cpp
|
||||||
HEADERS += streaming/video/ffmpeg-renderers/drm.h
|
HEADERS += streaming/video/ffmpeg-renderers/drm.h
|
||||||
}
|
}
|
||||||
|
config_EGL {
|
||||||
|
message(EGL renderer selected)
|
||||||
|
|
||||||
|
CONFIG += egl
|
||||||
|
DEFINES += HAVE_EGL
|
||||||
|
SOURCES += \
|
||||||
|
streaming/video/ffmpeg-renderers/eglvid.cpp \
|
||||||
|
streaming/video/ffmpeg-renderers/egl_extensions.cpp
|
||||||
|
HEADERS += streaming/video/ffmpeg-renderers/eglvid.h
|
||||||
|
}
|
||||||
config_SL {
|
config_SL {
|
||||||
message(Steam Link build configuration selected)
|
message(Steam Link build configuration selected)
|
||||||
|
|
||||||
@@ -387,7 +415,10 @@ macx {
|
|||||||
APP_BUNDLE_FRAMEWORKS.files = $$files(../libs/mac/Frameworks/*.framework, true) $$files(../libs/mac/lib/*.dylib, true)
|
APP_BUNDLE_FRAMEWORKS.files = $$files(../libs/mac/Frameworks/*.framework, true) $$files(../libs/mac/lib/*.dylib, true)
|
||||||
APP_BUNDLE_FRAMEWORKS.path = Contents/Frameworks
|
APP_BUNDLE_FRAMEWORKS.path = Contents/Frameworks
|
||||||
|
|
||||||
QMAKE_BUNDLE_DATA += APP_BUNDLE_RESOURCES APP_BUNDLE_FRAMEWORKS
|
APP_BUNDLE_PLIST.files = $$OUT_PWD/Info.plist
|
||||||
|
APP_BUNDLE_PLIST.path = Contents
|
||||||
|
|
||||||
|
QMAKE_BUNDLE_DATA += APP_BUNDLE_RESOURCES APP_BUNDLE_FRAMEWORKS APP_BUNDLE_PLIST
|
||||||
|
|
||||||
QMAKE_RPATHDIR += @executable_path/../Frameworks
|
QMAKE_RPATHDIR += @executable_path/../Frameworks
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,17 @@ AutoUpdateChecker::AutoUpdateChecker(QObject *parent) :
|
|||||||
|
|
||||||
void AutoUpdateChecker::start()
|
void AutoUpdateChecker::start()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN32) || defined(Q_OS_DARWIN) || defined(STEAM_LINK) // Only run update checker on platforms without auto-update
|
#if defined(Q_OS_WIN32) || defined(Q_OS_DARWIN) || defined(STEAM_LINK) || defined(APP_IMAGE) // Only run update checker on platforms without auto-update
|
||||||
// HACK: Set network accessibility to work around QTBUG-80947
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) && !defined(QT_NO_BEARERMANAGEMENT)
|
||||||
|
// HACK: Set network accessibility to work around QTBUG-80947.
|
||||||
|
// Even though it was fixed in 5.14.2, it still breaks for users attempting to
|
||||||
|
// directly connect their computers without a router using APIPA and in some cases
|
||||||
|
// using OpenVPN with IPv6 enabled. https://github.com/moonlight-stream/moonlight-qt/issues/375
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_DEPRECATED
|
||||||
m_Nam.setNetworkAccessible(QNetworkAccessManager::Accessible);
|
m_Nam.setNetworkAccessible(QNetworkAccessManager::Accessible);
|
||||||
|
QT_WARNING_POP
|
||||||
|
#endif
|
||||||
|
|
||||||
// We'll get a callback when this is finished
|
// We'll get a callback when this is finished
|
||||||
QUrl url("https://moonlight-stream.org/updates/qt.json");
|
QUrl url("https://moonlight-stream.org/updates/qt.json");
|
||||||
@@ -48,8 +56,10 @@ void AutoUpdateChecker::parseStringToVersionQuad(QString& string, QVector<int>&
|
|||||||
|
|
||||||
QString AutoUpdateChecker::getPlatform()
|
QString AutoUpdateChecker::getPlatform()
|
||||||
{
|
{
|
||||||
#ifdef STEAM_LINK
|
#if defined(STEAM_LINK)
|
||||||
return QStringLiteral("steamlink");
|
return QStringLiteral("steamlink");
|
||||||
|
#elif defined(APP_IMAGE)
|
||||||
|
return QStringLiteral("appimage");
|
||||||
#else
|
#else
|
||||||
return QSysInfo::productType();
|
return QSysInfo::productType();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -71,10 +71,10 @@ private:
|
|||||||
|
|
||||||
QUrl BoxArtManager::loadBoxArt(NvComputer* computer, NvApp& app)
|
QUrl BoxArtManager::loadBoxArt(NvComputer* computer, NvApp& app)
|
||||||
{
|
{
|
||||||
// Try to open the cached file
|
// Try to open the cached file if it exists and contains data
|
||||||
QString cacheFilePath = getFilePathForBoxArt(computer, app.id);
|
QFile cacheFile(getFilePathForBoxArt(computer, app.id));
|
||||||
if (QFile::exists(cacheFilePath)) {
|
if (cacheFile.exists() && cacheFile.size() > 0) {
|
||||||
return QUrl::fromLocalFile(cacheFilePath);
|
return QUrl::fromLocalFile(cacheFile.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get here, we need to fetch asynchronously.
|
// If we get here, we need to fetch asynchronously.
|
||||||
@@ -109,6 +109,10 @@ QUrl BoxArtManager::loadBoxArtFromNetwork(NvComputer* computer, int appId)
|
|||||||
if (image.save(cachePath)) {
|
if (image.save(cachePath)) {
|
||||||
return QUrl::fromLocalFile(cachePath);
|
return QUrl::fromLocalFile(cachePath);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// A failed save() may leave a zero byte file. Make sure that's removed.
|
||||||
|
QFile(cachePath).remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QUrl();
|
return QUrl();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ private:
|
|||||||
|
|
||||||
QString serverInfo;
|
QString serverInfo;
|
||||||
try {
|
try {
|
||||||
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::NVLL_NONE);
|
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::NVLL_NONE, true);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ private:
|
|||||||
bool stateChanged = false;
|
bool stateChanged = false;
|
||||||
bool online = false;
|
bool online = false;
|
||||||
bool wasOnline = m_Computer->state == NvComputer::CS_ONLINE;
|
bool wasOnline = m_Computer->state == NvComputer::CS_ONLINE;
|
||||||
for (int i = 0; i < TRIES_BEFORE_OFFLINING && !online; i++) {
|
for (int i = 0; i < (wasOnline ? TRIES_BEFORE_OFFLINING : 1) && !online; i++) {
|
||||||
for (auto& address : m_Computer->uniqueAddresses()) {
|
for (auto& address : m_Computer->uniqueAddresses()) {
|
||||||
if (isInterruptionRequested()) {
|
if (isInterruptionRequested()) {
|
||||||
return;
|
return;
|
||||||
@@ -209,9 +209,10 @@ void ComputerManager::saveHosts()
|
|||||||
|
|
||||||
settings.remove(SER_HOSTS);
|
settings.remove(SER_HOSTS);
|
||||||
settings.beginWriteArray(SER_HOSTS);
|
settings.beginWriteArray(SER_HOSTS);
|
||||||
for (int i = 0; i < m_KnownHosts.count(); i++) {
|
int i = 0;
|
||||||
settings.setArrayIndex(i);
|
for (const NvComputer* computer : m_KnownHosts) {
|
||||||
m_KnownHosts.value(m_KnownHosts.keys()[i])->serialize(settings);
|
settings.setArrayIndex(i++);
|
||||||
|
computer->serialize(settings);
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
@@ -415,6 +416,19 @@ void ComputerManager::deleteHost(NvComputer* computer)
|
|||||||
QThreadPool::globalInstance()->start(new DeferredHostDeletionTask(this, computer));
|
QThreadPool::globalInstance()->start(new DeferredHostDeletionTask(this, computer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComputerManager::renameHost(NvComputer* computer, QString name)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
QWriteLocker(&computer->lock);
|
||||||
|
|
||||||
|
computer->name = name;
|
||||||
|
computer->hasCustomName = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notify the UI of the state change
|
||||||
|
handleComputerStateChanged(computer);
|
||||||
|
}
|
||||||
|
|
||||||
void ComputerManager::handleAboutToQuit()
|
void ComputerManager::handleAboutToQuit()
|
||||||
{
|
{
|
||||||
QWriteLocker lock(&m_Lock);
|
QWriteLocker lock(&m_Lock);
|
||||||
|
|||||||
@@ -179,6 +179,8 @@ public:
|
|||||||
// computer is deleted inside this call
|
// computer is deleted inside this call
|
||||||
void deleteHost(NvComputer* computer);
|
void deleteHost(NvComputer* computer);
|
||||||
|
|
||||||
|
void renameHost(NvComputer* computer, QString name);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void computerStateChanged(NvComputer* computer);
|
void computerStateChanged(NvComputer* computer);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#include "nvapp.h"
|
||||||
|
|
||||||
|
#define SER_APPNAME "name"
|
||||||
|
#define SER_APPID "id"
|
||||||
|
#define SER_APPHDR "hdr"
|
||||||
|
#define SER_APPCOLLECTOR "appcollector"
|
||||||
|
|
||||||
|
NvApp::NvApp(QSettings& settings)
|
||||||
|
{
|
||||||
|
name = settings.value(SER_APPNAME).toString();
|
||||||
|
id = settings.value(SER_APPID).toInt();
|
||||||
|
hdrSupported = settings.value(SER_APPHDR).toBool();
|
||||||
|
isAppCollectorGame = settings.value(SER_APPCOLLECTOR).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NvApp::serialize(QSettings& settings) const
|
||||||
|
{
|
||||||
|
settings.setValue(SER_APPNAME, name);
|
||||||
|
settings.setValue(SER_APPID, id);
|
||||||
|
settings.setValue(SER_APPHDR, hdrSupported);
|
||||||
|
settings.setValue(SER_APPCOLLECTOR, isAppCollectorGame);
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
class NvApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NvApp() {}
|
||||||
|
explicit NvApp(QSettings& settings);
|
||||||
|
|
||||||
|
bool operator==(const NvApp& other) const
|
||||||
|
{
|
||||||
|
return id == other.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isInitialized()
|
||||||
|
{
|
||||||
|
return id != 0 && !name.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
serialize(QSettings& settings) const;
|
||||||
|
|
||||||
|
int id = 0;
|
||||||
|
QString name;
|
||||||
|
bool hdrSupported = false;
|
||||||
|
bool isAppCollectorGame = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(NvApp)
|
||||||
+13
-17
@@ -1,4 +1,5 @@
|
|||||||
#include "nvcomputer.h"
|
#include "nvcomputer.h"
|
||||||
|
#include "nvapp.h"
|
||||||
|
|
||||||
#include <QUdpSocket>
|
#include <QUdpSocket>
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
@@ -14,15 +15,13 @@
|
|||||||
#define SER_IPV6ADDR "ipv6address"
|
#define SER_IPV6ADDR "ipv6address"
|
||||||
#define SER_APPLIST "apps"
|
#define SER_APPLIST "apps"
|
||||||
#define SER_SRVCERT "srvcert"
|
#define SER_SRVCERT "srvcert"
|
||||||
|
#define SER_CUSTOMNAME "customname"
|
||||||
#define SER_APPNAME "name"
|
|
||||||
#define SER_APPID "id"
|
|
||||||
#define SER_APPHDR "hdr"
|
|
||||||
|
|
||||||
NvComputer::NvComputer(QSettings& settings)
|
NvComputer::NvComputer(QSettings& settings)
|
||||||
{
|
{
|
||||||
this->name = settings.value(SER_NAME).toString();
|
this->name = settings.value(SER_NAME).toString();
|
||||||
this->uuid = settings.value(SER_UUID).toString();
|
this->uuid = settings.value(SER_UUID).toString();
|
||||||
|
this->hasCustomName = settings.value(SER_CUSTOMNAME).toBool();
|
||||||
this->macAddress = settings.value(SER_MAC).toByteArray();
|
this->macAddress = settings.value(SER_MAC).toByteArray();
|
||||||
this->localAddress = settings.value(SER_LOCALADDR).toString();
|
this->localAddress = settings.value(SER_LOCALADDR).toString();
|
||||||
this->remoteAddress = settings.value(SER_REMOTEADDR).toString();
|
this->remoteAddress = settings.value(SER_REMOTEADDR).toString();
|
||||||
@@ -32,14 +31,9 @@ NvComputer::NvComputer(QSettings& settings)
|
|||||||
|
|
||||||
int appCount = settings.beginReadArray(SER_APPLIST);
|
int appCount = settings.beginReadArray(SER_APPLIST);
|
||||||
for (int i = 0; i < appCount; i++) {
|
for (int i = 0; i < appCount; i++) {
|
||||||
NvApp app;
|
|
||||||
|
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
|
|
||||||
app.name = settings.value(SER_APPNAME).toString();
|
NvApp app(settings);
|
||||||
app.id = settings.value(SER_APPID).toInt();
|
|
||||||
app.hdrSupported = settings.value(SER_APPHDR).toBool();
|
|
||||||
|
|
||||||
this->appList.append(app);
|
this->appList.append(app);
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
@@ -57,11 +51,12 @@ NvComputer::NvComputer(QSettings& settings)
|
|||||||
this->gpuModel = nullptr;
|
this->gpuModel = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NvComputer::serialize(QSettings& settings)
|
void NvComputer::serialize(QSettings& settings) const
|
||||||
{
|
{
|
||||||
QReadLocker lock(&this->lock);
|
QReadLocker lock(&this->lock);
|
||||||
|
|
||||||
settings.setValue(SER_NAME, name);
|
settings.setValue(SER_NAME, name);
|
||||||
|
settings.setValue(SER_CUSTOMNAME, hasCustomName);
|
||||||
settings.setValue(SER_UUID, uuid);
|
settings.setValue(SER_UUID, uuid);
|
||||||
settings.setValue(SER_MAC, macAddress);
|
settings.setValue(SER_MAC, macAddress);
|
||||||
settings.setValue(SER_LOCALADDR, localAddress);
|
settings.setValue(SER_LOCALADDR, localAddress);
|
||||||
@@ -76,10 +71,7 @@ void NvComputer::serialize(QSettings& settings)
|
|||||||
settings.beginWriteArray(SER_APPLIST);
|
settings.beginWriteArray(SER_APPLIST);
|
||||||
for (int i = 0; i < appList.count(); i++) {
|
for (int i = 0; i < appList.count(); i++) {
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
|
appList[i].serialize(settings);
|
||||||
settings.setValue(SER_APPNAME, appList[i].name);
|
|
||||||
settings.setValue(SER_APPID, appList[i].id);
|
|
||||||
settings.setValue(SER_APPHDR, appList[i].hdrSupported);
|
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
@@ -96,6 +88,7 @@ NvComputer::NvComputer(QString address, QString serverInfo, QSslCertificate serv
|
|||||||
{
|
{
|
||||||
this->serverCert = serverCert;
|
this->serverCert = serverCert;
|
||||||
|
|
||||||
|
this->hasCustomName = false;
|
||||||
this->name = NvHTTP::getXmlString(serverInfo, "hostname");
|
this->name = NvHTTP::getXmlString(serverInfo, "hostname");
|
||||||
if (this->name.isEmpty()) {
|
if (this->name.isEmpty()) {
|
||||||
this->name = "UNKNOWN";
|
this->name = "UNKNOWN";
|
||||||
@@ -313,7 +306,7 @@ bool NvComputer::isReachableOverVpn()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QString> NvComputer::uniqueAddresses()
|
QVector<QString> NvComputer::uniqueAddresses() const
|
||||||
{
|
{
|
||||||
QVector<QString> uniqueAddressList;
|
QVector<QString> uniqueAddressList;
|
||||||
|
|
||||||
@@ -377,7 +370,10 @@ bool NvComputer::update(NvComputer& that)
|
|||||||
changed = true; \
|
changed = true; \
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIGN_IF_CHANGED(name);
|
if (!hasCustomName) {
|
||||||
|
// Only overwrite the name if it's not custom
|
||||||
|
ASSIGN_IF_CHANGED(name);
|
||||||
|
}
|
||||||
ASSIGN_IF_CHANGED_AND_NONEMPTY(macAddress);
|
ASSIGN_IF_CHANGED_AND_NONEMPTY(macAddress);
|
||||||
ASSIGN_IF_CHANGED_AND_NONEMPTY(localAddress);
|
ASSIGN_IF_CHANGED_AND_NONEMPTY(localAddress);
|
||||||
ASSIGN_IF_CHANGED_AND_NONEMPTY(remoteAddress);
|
ASSIGN_IF_CHANGED_AND_NONEMPTY(remoteAddress);
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ public:
|
|||||||
isReachableOverVpn();
|
isReachableOverVpn();
|
||||||
|
|
||||||
QVector<QString>
|
QVector<QString>
|
||||||
uniqueAddresses();
|
uniqueAddresses() const;
|
||||||
|
|
||||||
void
|
void
|
||||||
serialize(QSettings& settings);
|
serialize(QSettings& settings) const;
|
||||||
|
|
||||||
enum PairState
|
enum PairState
|
||||||
{
|
{
|
||||||
@@ -71,10 +71,11 @@ public:
|
|||||||
QString manualAddress;
|
QString manualAddress;
|
||||||
QByteArray macAddress;
|
QByteArray macAddress;
|
||||||
QString name;
|
QString name;
|
||||||
|
bool hasCustomName;
|
||||||
QString uuid;
|
QString uuid;
|
||||||
QSslCertificate serverCert;
|
QSslCertificate serverCert;
|
||||||
QVector<NvApp> appList;
|
QVector<NvApp> appList;
|
||||||
|
|
||||||
// Synchronization
|
// Synchronization
|
||||||
QReadWriteLock lock;
|
mutable QReadWriteLock lock;
|
||||||
};
|
};
|
||||||
+38
-44
@@ -12,6 +12,7 @@
|
|||||||
#include <QtEndian>
|
#include <QtEndian>
|
||||||
#include <QNetworkProxy>
|
#include <QNetworkProxy>
|
||||||
|
|
||||||
|
#define FAST_FAIL_TIMEOUT_MS 2000
|
||||||
#define REQUEST_TIMEOUT_MS 5000
|
#define REQUEST_TIMEOUT_MS 5000
|
||||||
#define LAUNCH_TIMEOUT_MS 120000
|
#define LAUNCH_TIMEOUT_MS 120000
|
||||||
#define RESUME_TIMEOUT_MS 30000
|
#define RESUME_TIMEOUT_MS 30000
|
||||||
@@ -92,7 +93,7 @@ NvHTTP::getCurrentGame(QString serverInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
NvHTTP::getServerInfo(NvLogLevel logLevel)
|
NvHTTP::getServerInfo(NvLogLevel logLevel, bool fastFail)
|
||||||
{
|
{
|
||||||
QString serverInfo;
|
QString serverInfo;
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ NvHTTP::getServerInfo(NvLogLevel logLevel)
|
|||||||
serverInfo = openConnectionToString(m_BaseUrlHttps,
|
serverInfo = openConnectionToString(m_BaseUrlHttps,
|
||||||
"serverinfo",
|
"serverinfo",
|
||||||
nullptr,
|
nullptr,
|
||||||
REQUEST_TIMEOUT_MS,
|
fastFail ? FAST_FAIL_TIMEOUT_MS : REQUEST_TIMEOUT_MS,
|
||||||
logLevel);
|
logLevel);
|
||||||
// Throws if the request failed
|
// Throws if the request failed
|
||||||
verifyResponseStatus(serverInfo);
|
verifyResponseStatus(serverInfo);
|
||||||
@@ -119,7 +120,7 @@ NvHTTP::getServerInfo(NvLogLevel logLevel)
|
|||||||
serverInfo = openConnectionToString(m_BaseUrlHttp,
|
serverInfo = openConnectionToString(m_BaseUrlHttp,
|
||||||
"serverinfo",
|
"serverinfo",
|
||||||
nullptr,
|
nullptr,
|
||||||
REQUEST_TIMEOUT_MS,
|
fastFail ? FAST_FAIL_TIMEOUT_MS : REQUEST_TIMEOUT_MS,
|
||||||
logLevel);
|
logLevel);
|
||||||
verifyResponseStatus(serverInfo);
|
verifyResponseStatus(serverInfo);
|
||||||
}
|
}
|
||||||
@@ -136,7 +137,7 @@ NvHTTP::getServerInfo(NvLogLevel logLevel)
|
|||||||
serverInfo = openConnectionToString(m_BaseUrlHttp,
|
serverInfo = openConnectionToString(m_BaseUrlHttp,
|
||||||
"serverinfo",
|
"serverinfo",
|
||||||
nullptr,
|
nullptr,
|
||||||
REQUEST_TIMEOUT_MS,
|
fastFail ? FAST_FAIL_TIMEOUT_MS : REQUEST_TIMEOUT_MS,
|
||||||
logLevel);
|
logLevel);
|
||||||
verifyResponseStatus(serverInfo);
|
verifyResponseStatus(serverInfo);
|
||||||
}
|
}
|
||||||
@@ -144,30 +145,6 @@ NvHTTP::getServerInfo(NvLogLevel logLevel)
|
|||||||
return serverInfo;
|
return serverInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString
|
|
||||||
getSurroundAudioInfoString(int audioConfig)
|
|
||||||
{
|
|
||||||
int channelMask;
|
|
||||||
int channelCount;
|
|
||||||
|
|
||||||
switch (audioConfig)
|
|
||||||
{
|
|
||||||
case AUDIO_CONFIGURATION_STEREO:
|
|
||||||
channelCount = 2;
|
|
||||||
channelMask = 0x3;
|
|
||||||
break;
|
|
||||||
case AUDIO_CONFIGURATION_51_SURROUND:
|
|
||||||
channelCount = 6;
|
|
||||||
channelMask = 0xFC;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Q_ASSERT(false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString::number(channelMask << 16 | channelCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NvHTTP::launchApp(int appId,
|
NvHTTP::launchApp(int appId,
|
||||||
PSTREAM_CONFIGURATION streamConfig,
|
PSTREAM_CONFIGURATION streamConfig,
|
||||||
@@ -186,10 +163,7 @@ NvHTTP::launchApp(int appId,
|
|||||||
"appid="+QString::number(appId)+
|
"appid="+QString::number(appId)+
|
||||||
"&mode="+QString::number(streamConfig->width)+"x"+
|
"&mode="+QString::number(streamConfig->width)+"x"+
|
||||||
QString::number(streamConfig->height)+"x"+
|
QString::number(streamConfig->height)+"x"+
|
||||||
// Using an FPS value over 60 causes SOPS to default to 720p60,
|
QString::number(streamConfig->fps)+
|
||||||
// so force it to 60 when starting. This won't impact our ability
|
|
||||||
// to get > 60 FPS while actually streaming though.
|
|
||||||
QString::number(streamConfig->fps > 60 ? 60 : streamConfig->fps)+
|
|
||||||
"&additionalStates=1&sops="+QString::number(sops ? 1 : 0)+
|
"&additionalStates=1&sops="+QString::number(sops ? 1 : 0)+
|
||||||
"&rikey="+QByteArray(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey)).toHex()+
|
"&rikey="+QByteArray(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey)).toHex()+
|
||||||
"&rikeyid="+QString::number(riKeyId)+
|
"&rikeyid="+QString::number(riKeyId)+
|
||||||
@@ -197,7 +171,7 @@ NvHTTP::launchApp(int appId,
|
|||||||
"&hdrMode=1&clientHdrCapVersion=0&clientHdrCapSupportedFlagsInUint32=0&clientHdrCapMetaDataId=NV_STATIC_METADATA_TYPE_1&clientHdrCapDisplayData=0x0x0x0x0x0x0x0x0x0x0" :
|
"&hdrMode=1&clientHdrCapVersion=0&clientHdrCapSupportedFlagsInUint32=0&clientHdrCapMetaDataId=NV_STATIC_METADATA_TYPE_1&clientHdrCapDisplayData=0x0x0x0x0x0x0x0x0x0x0" :
|
||||||
"")+
|
"")+
|
||||||
"&localAudioPlayMode="+QString::number(localAudio ? 1 : 0)+
|
"&localAudioPlayMode="+QString::number(localAudio ? 1 : 0)+
|
||||||
"&surroundAudioInfo="+getSurroundAudioInfoString(streamConfig->audioConfiguration)+
|
"&surroundAudioInfo="+QString::number(SURROUNDAUDIOINFO_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration))+
|
||||||
"&remoteControllersBitmap="+QString::number(gamepadMask)+
|
"&remoteControllersBitmap="+QString::number(gamepadMask)+
|
||||||
"&gcmap="+QString::number(gamepadMask),
|
"&gcmap="+QString::number(gamepadMask),
|
||||||
LAUNCH_TIMEOUT_MS);
|
LAUNCH_TIMEOUT_MS);
|
||||||
@@ -219,7 +193,7 @@ NvHTTP::resumeApp(PSTREAM_CONFIGURATION streamConfig)
|
|||||||
"resume",
|
"resume",
|
||||||
"rikey="+QString(QByteArray(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey)).toHex())+
|
"rikey="+QString(QByteArray(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey)).toHex())+
|
||||||
"&rikeyid="+QString::number(riKeyId)+
|
"&rikeyid="+QString::number(riKeyId)+
|
||||||
"&surroundAudioInfo="+getSurroundAudioInfoString(streamConfig->audioConfiguration),
|
"&surroundAudioInfo="+QString::number(SURROUNDAUDIOINFO_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration)),
|
||||||
RESUME_TIMEOUT_MS);
|
RESUME_TIMEOUT_MS);
|
||||||
|
|
||||||
// Throws if the request failed
|
// Throws if the request failed
|
||||||
@@ -256,16 +230,16 @@ NvHTTP::getDisplayModeList(QString serverInfo)
|
|||||||
while (!xmlReader.atEnd()) {
|
while (!xmlReader.atEnd()) {
|
||||||
while (xmlReader.readNextStartElement()) {
|
while (xmlReader.readNextStartElement()) {
|
||||||
QStringRef name = xmlReader.name();
|
QStringRef name = xmlReader.name();
|
||||||
if (xmlReader.name() == "DisplayMode") {
|
if (name == "DisplayMode") {
|
||||||
modes.append(NvDisplayMode());
|
modes.append(NvDisplayMode());
|
||||||
}
|
}
|
||||||
else if (xmlReader.name() == "Width") {
|
else if (name == "Width") {
|
||||||
modes.last().width = xmlReader.readElementText().toInt();
|
modes.last().width = xmlReader.readElementText().toInt();
|
||||||
}
|
}
|
||||||
else if (xmlReader.name() == "Height") {
|
else if (name == "Height") {
|
||||||
modes.last().height = xmlReader.readElementText().toInt();
|
modes.last().height = xmlReader.readElementText().toInt();
|
||||||
}
|
}
|
||||||
else if (xmlReader.name() == "RefreshRate") {
|
else if (name == "RefreshRate") {
|
||||||
modes.last().refreshRate = xmlReader.readElementText().toInt();
|
modes.last().refreshRate = xmlReader.readElementText().toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,7 +263,7 @@ NvHTTP::getAppList()
|
|||||||
while (!xmlReader.atEnd()) {
|
while (!xmlReader.atEnd()) {
|
||||||
while (xmlReader.readNextStartElement()) {
|
while (xmlReader.readNextStartElement()) {
|
||||||
QStringRef name = xmlReader.name();
|
QStringRef name = xmlReader.name();
|
||||||
if (xmlReader.name() == "App") {
|
if (name == "App") {
|
||||||
// We must have a valid app before advancing to the next one
|
// We must have a valid app before advancing to the next one
|
||||||
if (!apps.isEmpty() && !apps.last().isInitialized()) {
|
if (!apps.isEmpty() && !apps.last().isInitialized()) {
|
||||||
qWarning() << "Invalid applist XML";
|
qWarning() << "Invalid applist XML";
|
||||||
@@ -298,15 +272,18 @@ NvHTTP::getAppList()
|
|||||||
}
|
}
|
||||||
apps.append(NvApp());
|
apps.append(NvApp());
|
||||||
}
|
}
|
||||||
else if (xmlReader.name() == "AppTitle") {
|
else if (name == "AppTitle") {
|
||||||
apps.last().name = xmlReader.readElementText();
|
apps.last().name = xmlReader.readElementText();
|
||||||
}
|
}
|
||||||
else if (xmlReader.name() == "ID") {
|
else if (name == "ID") {
|
||||||
apps.last().id = xmlReader.readElementText().toInt();
|
apps.last().id = xmlReader.readElementText().toInt();
|
||||||
}
|
}
|
||||||
else if (xmlReader.name() == "IsHdrSupported") {
|
else if (name == "IsHdrSupported") {
|
||||||
apps.last().hdrSupported = xmlReader.readElementText() == "1";
|
apps.last().hdrSupported = xmlReader.readElementText() == "1";
|
||||||
}
|
}
|
||||||
|
else if (name == "IsAppCollectorGame") {
|
||||||
|
apps.last().isAppCollectorGame = xmlReader.readElementText() == "1";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +299,10 @@ NvHTTP::verifyResponseStatus(QString xml)
|
|||||||
{
|
{
|
||||||
if (xmlReader.name() == "root")
|
if (xmlReader.name() == "root")
|
||||||
{
|
{
|
||||||
int statusCode = xmlReader.attributes().value("status_code").toInt();
|
// 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()
|
||||||
|
// and cast the result to an int instead.
|
||||||
|
int statusCode = (int)xmlReader.attributes().value("status_code").toUInt();
|
||||||
if (statusCode == 200)
|
if (statusCode == 200)
|
||||||
{
|
{
|
||||||
// Successful
|
// Successful
|
||||||
@@ -335,6 +315,12 @@ NvHTTP::verifyResponseStatus(QString xml)
|
|||||||
// 401 is expected for unpaired PCs when we fetch serverinfo over HTTPS
|
// 401 is expected for unpaired PCs when we fetch serverinfo over HTTPS
|
||||||
qWarning() << "Request failed:" << statusCode << statusMessage;
|
qWarning() << "Request failed:" << statusCode << statusMessage;
|
||||||
}
|
}
|
||||||
|
if (statusCode == -1 && statusMessage == "Invalid") {
|
||||||
|
// 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.";
|
||||||
|
}
|
||||||
throw GfeHttpResponseException(statusCode, statusMessage);
|
throw GfeHttpResponseException(statusCode, statusMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -454,8 +440,16 @@ NvHTTP::openConnection(QUrl baseUrl,
|
|||||||
// Add our client certificate
|
// Add our client certificate
|
||||||
request.setSslConfiguration(IdentityManager::get()->getSslConfig());
|
request.setSslConfiguration(IdentityManager::get()->getSslConfig());
|
||||||
|
|
||||||
// HACK: Set reachability to work around QTBUG-80947
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) && !defined(QT_NO_BEARERMANAGEMENT)
|
||||||
|
// HACK: Set network accessibility to work around QTBUG-80947.
|
||||||
|
// Even though it was fixed in 5.14.2, it still breaks for users attempting to
|
||||||
|
// directly connect their computers without a router using APIPA and in some cases
|
||||||
|
// using OpenVPN with IPv6 enabled. https://github.com/moonlight-stream/moonlight-qt/issues/375
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_DEPRECATED
|
||||||
m_Nam.setNetworkAccessible(QNetworkAccessManager::Accessible);
|
m_Nam.setNetworkAccessible(QNetworkAccessManager::Accessible);
|
||||||
|
QT_WARNING_POP
|
||||||
|
#endif
|
||||||
|
|
||||||
QNetworkReply* reply = m_Nam.get(request);
|
QNetworkReply* reply = m_Nam.get(request);
|
||||||
|
|
||||||
|
|||||||
+2
-21
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "identitymanager.h"
|
#include "identitymanager.h"
|
||||||
|
#include "nvapp.h"
|
||||||
|
|
||||||
#include <Limelight.h>
|
#include <Limelight.h>
|
||||||
|
|
||||||
@@ -8,26 +9,6 @@
|
|||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
class NvApp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool operator==(const NvApp& other) const
|
|
||||||
{
|
|
||||||
return id == other.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isInitialized()
|
|
||||||
{
|
|
||||||
return id != 0 && !name.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
int id;
|
|
||||||
QString name;
|
|
||||||
bool hdrSupported;
|
|
||||||
};
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(NvApp)
|
|
||||||
|
|
||||||
class NvDisplayMode
|
class NvDisplayMode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -131,7 +112,7 @@ public:
|
|||||||
getCurrentGame(QString serverInfo);
|
getCurrentGame(QString serverInfo);
|
||||||
|
|
||||||
QString
|
QString
|
||||||
getServerInfo(NvLogLevel logLevel);
|
getServerInfo(NvLogLevel logLevel, bool fastFail = false);
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ RichPresenceManager::RichPresenceManager(StreamingPreferences& prefs, QString ga
|
|||||||
discordPresence.largeImageKey = "icon";
|
discordPresence.largeImageKey = "icon";
|
||||||
Discord_UpdatePresence(&discordPresence);
|
Discord_UpdatePresence(&discordPresence);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
Q_UNUSED(prefs)
|
||||||
|
Q_UNUSED(gameName)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "systemproperties.h"
|
#include "systemproperties.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
|
||||||
@@ -7,8 +8,10 @@
|
|||||||
|
|
||||||
SystemProperties::SystemProperties()
|
SystemProperties::SystemProperties()
|
||||||
{
|
{
|
||||||
isRunningWayland = qgetenv("XDG_SESSION_TYPE") == "wayland";
|
versionString = QString(VERSION_STR);
|
||||||
isRunningXWayland = qgetenv("XDG_SESSION_TYPE") == "wayland" && QGuiApplication::platformName() == "xcb";
|
hasWindowManager = WMUtils::isRunningWindowManager();
|
||||||
|
isRunningWayland = WMUtils::isRunningWayland();
|
||||||
|
isRunningXWayland = isRunningWayland && QGuiApplication::platformName() == "xcb";
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
isWow64 = QSysInfo::currentCpuArchitecture() != QSysInfo::buildCpuArchitecture();
|
isWow64 = QSysInfo::currentCpuArchitecture() != QSysInfo::buildCpuArchitecture();
|
||||||
@@ -17,7 +20,8 @@ SystemProperties::SystemProperties()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef STEAM_LINK
|
#ifndef STEAM_LINK
|
||||||
hasBrowser = true;
|
// Assume we can probably launch a browser if we're in a GUI environment
|
||||||
|
hasBrowser = hasWindowManager;
|
||||||
#else
|
#else
|
||||||
hasBrowser = false;
|
hasBrowser = false;
|
||||||
#endif
|
#endif
|
||||||
@@ -74,7 +78,14 @@ void SystemProperties::querySdlVideoInfo()
|
|||||||
|
|
||||||
err = SDL_GetDesktopDisplayMode(displayIndex, &desktopMode);
|
err = SDL_GetDesktopDisplayMode(displayIndex, &desktopMode);
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
monitorDesktopResolutions.insert(displayIndex, QRect(0, 0, desktopMode.w, desktopMode.h));
|
if (desktopMode.w <= 8192 && desktopMode.h <= 8192) {
|
||||||
|
monitorDesktopResolutions.insert(displayIndex, QRect(0, 0, desktopMode.w, desktopMode.h));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Skipping resolution over 8K: %dx%d",
|
||||||
|
desktopMode.w, desktopMode.h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
@@ -83,7 +94,14 @@ void SystemProperties::querySdlVideoInfo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (StreamUtils::getRealDesktopMode(displayIndex, &desktopMode)) {
|
if (StreamUtils::getRealDesktopMode(displayIndex, &desktopMode)) {
|
||||||
monitorNativeResolutions.insert(displayIndex, QRect(0, 0, desktopMode.w, desktopMode.h));
|
if (desktopMode.w <= 8192 && desktopMode.h <= 8192) {
|
||||||
|
monitorNativeResolutions.insert(displayIndex, QRect(0, 0, desktopMode.w, desktopMode.h));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Skipping resolution over 8K: %dx%d",
|
||||||
|
desktopMode.w, desktopMode.h);
|
||||||
|
}
|
||||||
|
|
||||||
// Start at desktop mode and work our way up
|
// Start at desktop mode and work our way up
|
||||||
bestMode = desktopMode;
|
bestMode = desktopMode;
|
||||||
@@ -111,11 +129,7 @@ void SystemProperties::querySdlVideoInfo()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasHardwareAcceleration =
|
Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen, maximumResolution);
|
||||||
Session::isHardwareDecodeAvailable(testWindow,
|
|
||||||
StreamingPreferences::VDS_AUTO,
|
|
||||||
VIDEO_FORMAT_H264,
|
|
||||||
1920, 1080, 60);
|
|
||||||
|
|
||||||
SDL_DestroyWindow(testWindow);
|
SDL_DestroyWindow(testWindow);
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,17 @@ public:
|
|||||||
SystemProperties();
|
SystemProperties();
|
||||||
|
|
||||||
Q_PROPERTY(bool hasHardwareAcceleration MEMBER hasHardwareAcceleration CONSTANT)
|
Q_PROPERTY(bool hasHardwareAcceleration MEMBER hasHardwareAcceleration CONSTANT)
|
||||||
|
Q_PROPERTY(bool rendererAlwaysFullScreen MEMBER rendererAlwaysFullScreen CONSTANT)
|
||||||
Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT)
|
Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT)
|
||||||
Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT)
|
Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT)
|
||||||
Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT)
|
Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT)
|
||||||
|
Q_PROPERTY(bool hasWindowManager MEMBER hasWindowManager CONSTANT)
|
||||||
Q_PROPERTY(bool hasBrowser MEMBER hasBrowser CONSTANT)
|
Q_PROPERTY(bool hasBrowser MEMBER hasBrowser CONSTANT)
|
||||||
Q_PROPERTY(bool hasDiscordIntegration MEMBER hasDiscordIntegration CONSTANT)
|
Q_PROPERTY(bool hasDiscordIntegration MEMBER hasDiscordIntegration CONSTANT)
|
||||||
Q_PROPERTY(QString unmappedGamepads MEMBER unmappedGamepads NOTIFY unmappedGamepadsChanged)
|
Q_PROPERTY(QString unmappedGamepads MEMBER unmappedGamepads NOTIFY unmappedGamepadsChanged)
|
||||||
Q_PROPERTY(int maximumStreamingFrameRate MEMBER maximumStreamingFrameRate CONSTANT)
|
Q_PROPERTY(int maximumStreamingFrameRate MEMBER maximumStreamingFrameRate CONSTANT)
|
||||||
|
Q_PROPERTY(QSize maximumResolution MEMBER maximumResolution CONSTANT)
|
||||||
|
Q_PROPERTY(QString versionString MEMBER versionString CONSTANT)
|
||||||
|
|
||||||
Q_INVOKABLE QRect getDesktopResolution(int displayIndex);
|
Q_INVOKABLE QRect getDesktopResolution(int displayIndex);
|
||||||
Q_INVOKABLE QRect getNativeResolution(int displayIndex);
|
Q_INVOKABLE QRect getNativeResolution(int displayIndex);
|
||||||
@@ -29,14 +33,18 @@ private:
|
|||||||
void querySdlVideoInfo();
|
void querySdlVideoInfo();
|
||||||
|
|
||||||
bool hasHardwareAcceleration;
|
bool hasHardwareAcceleration;
|
||||||
|
bool rendererAlwaysFullScreen;
|
||||||
bool isRunningWayland;
|
bool isRunningWayland;
|
||||||
bool isRunningXWayland;
|
bool isRunningXWayland;
|
||||||
bool isWow64;
|
bool isWow64;
|
||||||
|
bool hasWindowManager;
|
||||||
bool hasBrowser;
|
bool hasBrowser;
|
||||||
bool hasDiscordIntegration;
|
bool hasDiscordIntegration;
|
||||||
QString unmappedGamepads;
|
QString unmappedGamepads;
|
||||||
int maximumStreamingFrameRate;
|
int maximumStreamingFrameRate;
|
||||||
|
QSize maximumResolution;
|
||||||
QList<QRect> monitorDesktopResolutions;
|
QList<QRect> monitorDesktopResolutions;
|
||||||
QList<QRect> monitorNativeResolutions;
|
QList<QRect> monitorNativeResolutions;
|
||||||
|
QString versionString;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -172,20 +172,31 @@ GlobalCommandLineParser::ParseResult GlobalCommandLineParser::parse(const QStrin
|
|||||||
parser.addPositionalArgument("action", "Action to execute", "<action>");
|
parser.addPositionalArgument("action", "Action to execute", "<action>");
|
||||||
parser.parse(args);
|
parser.parse(args);
|
||||||
auto posArgs = parser.positionalArguments();
|
auto posArgs = parser.positionalArguments();
|
||||||
QString action = posArgs.isEmpty() ? QString() : posArgs.first().toLower();
|
|
||||||
|
|
||||||
if (action == "") {
|
if (posArgs.isEmpty()) {
|
||||||
// This method will not return and terminates the process if --version
|
// This method will not return and terminates the process if --version
|
||||||
// or --help is specified
|
// or --help is specified
|
||||||
parser.handleHelpAndVersionOptions();
|
parser.handleHelpAndVersionOptions();
|
||||||
parser.handleUnknownOptions();
|
parser.handleUnknownOptions();
|
||||||
return NormalStartRequested;
|
return NormalStartRequested;
|
||||||
} else if (action == "quit") {
|
}
|
||||||
return QuitRequested;
|
else {
|
||||||
} else if (action == "stream") {
|
// If users supply arguments that accept values prior to the "quit"
|
||||||
return StreamRequested;
|
// or "stream" positional arguments, we will not be able to correctly
|
||||||
} else {
|
// parse the value out of the input because this QCommandLineParser
|
||||||
parser.showError(QString("Invalid action: %1").arg(action));
|
// doesn't know about all of the options that "quit" and "stream"
|
||||||
|
// commands can accept. To work around this issue, we just look
|
||||||
|
// for "quit" or "stream" positional arguments anywhere.
|
||||||
|
for (int i = 0; i < posArgs.size(); i++) {
|
||||||
|
QString action = posArgs.at(i).toLower();
|
||||||
|
if (action == "quit") {
|
||||||
|
return QuitRequested;
|
||||||
|
} else if (action == "stream") {
|
||||||
|
return StreamRequested;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parser.showError(QString("Invalid action"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,6 +252,7 @@ StreamCommandLineParser::StreamCommandLineParser()
|
|||||||
m_AudioConfigMap = {
|
m_AudioConfigMap = {
|
||||||
{"stereo", StreamingPreferences::AC_STEREO},
|
{"stereo", StreamingPreferences::AC_STEREO},
|
||||||
{"5.1-surround", StreamingPreferences::AC_51_SURROUND},
|
{"5.1-surround", StreamingPreferences::AC_51_SURROUND},
|
||||||
|
{"7.1-surround", StreamingPreferences::AC_71_SURROUND},
|
||||||
};
|
};
|
||||||
m_VideoCodecMap = {
|
m_VideoCodecMap = {
|
||||||
{"auto", StreamingPreferences::VCC_AUTO},
|
{"auto", StreamingPreferences::VCC_AUTO},
|
||||||
@@ -249,8 +261,8 @@ StreamCommandLineParser::StreamCommandLineParser()
|
|||||||
};
|
};
|
||||||
m_VideoDecoderMap = {
|
m_VideoDecoderMap = {
|
||||||
{"auto", StreamingPreferences::VDS_AUTO},
|
{"auto", StreamingPreferences::VDS_AUTO},
|
||||||
{"software", StreamingPreferences::VDS_FORCE_HARDWARE},
|
{"software", StreamingPreferences::VDS_FORCE_SOFTWARE},
|
||||||
{"hardware", StreamingPreferences::VDS_FORCE_SOFTWARE},
|
{"hardware", StreamingPreferences::VDS_FORCE_HARDWARE},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,11 +292,13 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
|
|||||||
parser.addToggleOption("vsync", "V-Sync");
|
parser.addToggleOption("vsync", "V-Sync");
|
||||||
parser.addValueOption("fps", "FPS");
|
parser.addValueOption("fps", "FPS");
|
||||||
parser.addValueOption("bitrate", "bitrate in Kbps");
|
parser.addValueOption("bitrate", "bitrate in Kbps");
|
||||||
|
parser.addValueOption("packet-size", "video packet size");
|
||||||
parser.addChoiceOption("display-mode", "display mode", m_WindowModeMap.keys());
|
parser.addChoiceOption("display-mode", "display mode", m_WindowModeMap.keys());
|
||||||
parser.addChoiceOption("audio-config", "audio config", m_AudioConfigMap.keys());
|
parser.addChoiceOption("audio-config", "audio config", m_AudioConfigMap.keys());
|
||||||
parser.addToggleOption("multi-controller", "multiple controller support");
|
parser.addToggleOption("multi-controller", "multiple controller support");
|
||||||
parser.addToggleOption("quit-after", "quit app after session");
|
parser.addToggleOption("quit-after", "quit app after session");
|
||||||
parser.addToggleOption("mouse-acceleration", "mouse acceleration");
|
parser.addToggleOption("absolute-mouse", "remote desktop optimized mouse control");
|
||||||
|
parser.addToggleOption("touchscreen-trackpad", "touchscreen in trackpad mode");
|
||||||
parser.addToggleOption("game-optimization", "game optimizations");
|
parser.addToggleOption("game-optimization", "game optimizations");
|
||||||
parser.addToggleOption("audio-on-host", "audio on host PC");
|
parser.addToggleOption("audio-on-host", "audio on host PC");
|
||||||
parser.addToggleOption("frame-pacing", "frame pacing");
|
parser.addToggleOption("frame-pacing", "frame pacing");
|
||||||
@@ -345,6 +359,14 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
|
|||||||
preferences->width, preferences->height, preferences->fps);
|
preferences->width, preferences->height, preferences->fps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resolve --packet-size option
|
||||||
|
if (parser.isSet("packet-size")) {
|
||||||
|
preferences->packetSize = parser.getIntOption("packet-size");
|
||||||
|
if (preferences->packetSize < 1024) {
|
||||||
|
parser.showError("Packet size must be greater than 1024 bytes");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Resolve --display option
|
// Resolve --display option
|
||||||
if (parser.isSet("display-mode")) {
|
if (parser.isSet("display-mode")) {
|
||||||
preferences->windowMode = mapValue(m_WindowModeMap, parser.getChoiceOptionValue("display-mode"));
|
preferences->windowMode = mapValue(m_WindowModeMap, parser.getChoiceOptionValue("display-mode"));
|
||||||
@@ -364,8 +386,11 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
|
|||||||
// Resolve --quit-after and --no-quit-after options
|
// Resolve --quit-after and --no-quit-after options
|
||||||
preferences->quitAppAfter = parser.getToggleOptionValue("quit-after", preferences->quitAppAfter);
|
preferences->quitAppAfter = parser.getToggleOptionValue("quit-after", preferences->quitAppAfter);
|
||||||
|
|
||||||
// Resolve --mouse-acceleration and --no-mouse-acceleration options
|
// Resolve --absolute-mouse and --no-absolute-mouse options
|
||||||
preferences->mouseAcceleration = parser.getToggleOptionValue("mouse-acceleration", preferences->mouseAcceleration);
|
preferences->absoluteMouseMode = parser.getToggleOptionValue("absolute-mouse", preferences->absoluteMouseMode);
|
||||||
|
|
||||||
|
// Resolve --touchscreen-trackpad and --no-touchscreen-trackpad options
|
||||||
|
preferences->absoluteTouchMode = !parser.getToggleOptionValue("touchscreen-trackpad", !preferences->absoluteTouchMode);
|
||||||
|
|
||||||
// Resolve --game-optimization and --no-game-optimization options
|
// Resolve --game-optimization and --no-game-optimization options
|
||||||
preferences->gameOptimizations = parser.getToggleOptionValue("game-optimization", preferences->gameOptimizations);
|
preferences->gameOptimizations = parser.getToggleOptionValue("game-optimization", preferences->gameOptimizations);
|
||||||
|
|||||||
@@ -13,7 +13,9 @@
|
|||||||
<li>Streaming at up to 4K resolution</li>
|
<li>Streaming at up to 4K resolution</li>
|
||||||
<li>Support for up to 120 FPS streaming (high refresh rate monitor recommended)</li>
|
<li>Support for up to 120 FPS streaming (high refresh rate monitor recommended)</li>
|
||||||
<li>Hardware accelerated video decoding with VAAPI, VDPAU, and NVDEC support</li>
|
<li>Hardware accelerated video decoding with VAAPI, VDPAU, and NVDEC support</li>
|
||||||
<li>5.1 surround sound audio 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>Direct touchscreen mouse control</li>
|
||||||
<li>HEVC support for better video compression efficiency</li>
|
<li>HEVC support for better video compression efficiency</li>
|
||||||
<li>Gamepad support with force feedback for up to 4 players</li>
|
<li>Gamepad support with force feedback for up to 4 players</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -33,6 +35,50 @@
|
|||||||
</screenshots>
|
</screenshots>
|
||||||
|
|
||||||
<releases>
|
<releases>
|
||||||
|
<release version="2.1.0" date="2020-05-17">
|
||||||
|
<description>
|
||||||
|
<p>New features:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Remote desktop mode now allows interaction with the host without having to click to focus the Moonlight window first</li>
|
||||||
|
<li>Added a new EGL renderer for improved performance on Wayland and XWayland</li>
|
||||||
|
<li>Added the option to toggle between direct touchscreen mode and the old trackpad mode</li>
|
||||||
|
<li>Added the option to rename host PCs</li>
|
||||||
|
<li>Added the ability to scroll the settings page with the right analog stick</li>
|
||||||
|
<li>Various UI improvements</li>
|
||||||
|
</ul>
|
||||||
|
<p>Bugfixes:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Fixed unreliable mouse capture when the stream begins</li>
|
||||||
|
<li>Fixed cursor being trapped in full-screen mode even when the mouse wasn't captured</li>
|
||||||
|
<li>Fixed key presses not being sent to the host if the Super/Meta/Windows key is pressed</li>
|
||||||
|
<li>Updated included gamepad mappings</li>
|
||||||
|
</ul>
|
||||||
|
</description>
|
||||||
|
</release>
|
||||||
|
<release version="2.0.0" date="2020-04-28">
|
||||||
|
<description>
|
||||||
|
<p>New features:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Remote desktop-optimized mouse mode which doesn't require capturing the mouse cursor</li>
|
||||||
|
<li>Touchscreen input now directly controls the mouse cursor</li>
|
||||||
|
<li>7.1 surround sound support</li>
|
||||||
|
</ul>
|
||||||
|
<p>Bugfixes:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Improved performance on some lossy networks</li>
|
||||||
|
<li>Fixed disconnect delay when streaming from GeForce Experience 3.20.3.63</li>
|
||||||
|
<li>Fixed frame rate not exceeding 60 when streaming from GeForce Experience 3.20.3.63</li>
|
||||||
|
<li>Fixed parsing of command-line options when passing flags prior to the action</li>
|
||||||
|
<li>Fixed an issue that may cause excessive mDNS network traffic while Moonlight is running</li>
|
||||||
|
<li>Fixed hardware decoding on Intel GPUs running Mesa 20.0 and/or the Iris driver</li>
|
||||||
|
<li>Fixed hardware decoding on Comet Lake and later Intel GPUs using the iHD VA-API driver</li>
|
||||||
|
<li>Fixed hardware decoding on AMD Radeon GPUs with XWayland</li>
|
||||||
|
<li>Fixed a crash when using the iHD VA-API driver on Wayland</li>
|
||||||
|
<li>Fixed delay after exiting the stream on Wayland</li>
|
||||||
|
<li>Updated included gamepad mappings</li>
|
||||||
|
</ul>
|
||||||
|
</description>
|
||||||
|
</release>
|
||||||
<release version="1.2.0" date="2019-12-17">
|
<release version="1.2.0" date="2019-12-17">
|
||||||
<description>
|
<description>
|
||||||
<p>Bugfixes:</p>
|
<p>Bugfixes:</p>
|
||||||
|
|||||||
@@ -5,9 +5,19 @@
|
|||||||
# pairing data will be lost each reboot.
|
# pairing data will be lost each reboot.
|
||||||
HOME=/usr/local/moonlight
|
HOME=/usr/local/moonlight
|
||||||
|
|
||||||
|
# For a seamless transition across the Qt 5.9 -> Qt 5.14 boundary,
|
||||||
|
# we bundle binaries built with both Qt 5.9 and Qt 5.14 and pick
|
||||||
|
# the correct one at runtime.
|
||||||
|
if [ -d "/usr/local/Qt-5.14.1" ]; then
|
||||||
|
BIN="moonlight"
|
||||||
|
else
|
||||||
|
BIN="moonlight59"
|
||||||
|
fi
|
||||||
|
|
||||||
# Renice PE_Single_CPU which seems to host A/V stuff
|
# Renice PE_Single_CPU which seems to host A/V stuff
|
||||||
renice -10 -p $(pidof PE_Single_CPU)
|
renice -10 -p $(pidof PE_Single_CPU)
|
||||||
|
|
||||||
# Renice Moonlight itself to avoid preemption by background tasks
|
# Renice Moonlight itself to avoid preemption by background tasks
|
||||||
# Write output to a logfile in /tmp
|
# Write output to a logfile in /tmp
|
||||||
exec nice -n -10 ./bin/moonlight > /tmp/moonlight.log
|
echo Launching $BIN
|
||||||
|
exec nice -n -10 ./bin/$BIN > /tmp/moonlight.log
|
||||||
+1
-14
@@ -263,18 +263,5 @@ CenteredGridView {
|
|||||||
onAccepted: quitApp()
|
onAccepted: quitApp()
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
ScrollBar.vertical: ScrollBar {}
|
||||||
// Manually hide the scrollbar to prevent it from being drawn on top
|
|
||||||
// of the StreamSegue during the transition. It can sometimes get stuck
|
|
||||||
// there since we're not consistently pumping the event loop while
|
|
||||||
// starting the stream.
|
|
||||||
visible: activated
|
|
||||||
|
|
||||||
parent: appGrid.parent
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
right: parent.right
|
|
||||||
bottom: parent.bottom
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,10 @@ import SdlGamepadKeyNavigation 1.0
|
|||||||
// https://stackoverflow.com/questions/45029968/how-do-i-set-the-combobox-width-to-fit-the-largest-item
|
// https://stackoverflow.com/questions/45029968/how-do-i-set-the-combobox-width-to-fit-the-largest-item
|
||||||
ComboBox {
|
ComboBox {
|
||||||
property int textWidth
|
property int textWidth
|
||||||
|
property int desiredWidth : leftPadding + textWidth + indicator.width + rightPadding
|
||||||
|
property int maximumWidth : parent.width
|
||||||
|
|
||||||
implicitWidth: leftPadding + textWidth + indicator.width + rightPadding
|
implicitWidth: desiredWidth < maximumWidth ? desiredWidth : maximumWidth
|
||||||
|
|
||||||
TextMetrics {
|
TextMetrics {
|
||||||
id: popupMetrics
|
id: popupMetrics
|
||||||
|
|||||||
@@ -38,4 +38,6 @@ GridView {
|
|||||||
|
|
||||||
updateMargins()
|
updateMargins()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boundsBehavior: Flickable.OvershootBounds
|
||||||
}
|
}
|
||||||
+51
-6
@@ -1,5 +1,6 @@
|
|||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
import ComputerModel 1.0
|
import ComputerModel 1.0
|
||||||
|
|
||||||
@@ -159,6 +160,15 @@ CenteredGridView {
|
|||||||
deletePcDialog.open()
|
deletePcDialog.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
NavigableMenuItem {
|
||||||
|
parentMenu: pcContextMenu
|
||||||
|
text: "Rename PC"
|
||||||
|
onTriggered: {
|
||||||
|
renamePcDialog.pcIndex = index
|
||||||
|
renamePcDialog.originalName = model.name
|
||||||
|
renamePcDialog.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
NavigableMenuItem {
|
NavigableMenuItem {
|
||||||
parentMenu: pcContextMenu
|
parentMenu: pcContextMenu
|
||||||
text: "Wake PC"
|
text: "Wake PC"
|
||||||
@@ -265,12 +275,47 @@ CenteredGridView {
|
|||||||
onAccepted: deletePc()
|
onAccepted: deletePc()
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
NavigableDialog {
|
||||||
parent: pcGrid.parent
|
id: renamePcDialog
|
||||||
anchors {
|
property string label: "Enter the new name for this PC:"
|
||||||
top: parent.top
|
property string originalName
|
||||||
right: parent.right
|
property int pcIndex : -1;
|
||||||
bottom: parent.bottom
|
|
||||||
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||||
|
|
||||||
|
onOpened: {
|
||||||
|
// Force keyboard focus on the textbox so keyboard navigation works
|
||||||
|
editText.forceActiveFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
onClosed: {
|
||||||
|
editText.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
onAccepted: {
|
||||||
|
if (editText.text) {
|
||||||
|
computerModel.renameComputer(pcIndex, editText.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
Label {
|
||||||
|
text: renamePcDialog.label
|
||||||
|
font.bold: true
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: editText
|
||||||
|
placeholderText: renamePcDialog.originalName
|
||||||
|
Layout.fillWidth: true
|
||||||
|
focus: true
|
||||||
|
|
||||||
|
Keys.onReturnPressed: {
|
||||||
|
renamePcDialog.accept()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScrollBar.vertical: ScrollBar {}
|
||||||
}
|
}
|
||||||
+93
-36
@@ -10,16 +10,14 @@ Flickable {
|
|||||||
id: settingsPage
|
id: settingsPage
|
||||||
objectName: "Settings"
|
objectName: "Settings"
|
||||||
|
|
||||||
|
boundsBehavior: Flickable.OvershootBounds
|
||||||
|
|
||||||
contentWidth: settingsColumn1.width > settingsColumn2.width ? settingsColumn1.width : settingsColumn2.width
|
contentWidth: settingsColumn1.width > settingsColumn2.width ? settingsColumn1.width : settingsColumn2.width
|
||||||
contentHeight: settingsColumn1.height > settingsColumn2.height ? settingsColumn1.height : settingsColumn2.height
|
contentHeight: settingsColumn1.height > settingsColumn2.height ? settingsColumn1.height : settingsColumn2.height
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
ScrollBar.vertical: ScrollBar {
|
||||||
parent: settingsPage.parent
|
|
||||||
anchors {
|
anchors {
|
||||||
top: settingsPage.top
|
left: parent.right
|
||||||
left: settingsPage.right
|
|
||||||
bottom: settingsPage.bottom
|
|
||||||
|
|
||||||
leftMargin: -10
|
leftMargin: -10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,11 +43,12 @@ Flickable {
|
|||||||
Column {
|
Column {
|
||||||
padding: 10
|
padding: 10
|
||||||
id: settingsColumn1
|
id: settingsColumn1
|
||||||
width: settingsPage.width / 2 - padding
|
width: settingsPage.width / 2
|
||||||
|
spacing: 15
|
||||||
|
|
||||||
GroupBox {
|
GroupBox {
|
||||||
id: basicSettingsGroupBox
|
id: basicSettingsGroupBox
|
||||||
width: (parent.width - 2 * parent.padding)
|
width: (parent.width - (parent.leftPadding + parent.rightPadding))
|
||||||
padding: 12
|
padding: 12
|
||||||
title: "<font color=\"skyblue\">Basic Settings</font>"
|
title: "<font color=\"skyblue\">Basic Settings</font>"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
@@ -76,6 +75,7 @@ Flickable {
|
|||||||
|
|
||||||
Row {
|
Row {
|
||||||
spacing: 5
|
spacing: 5
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
AutoResizingComboBox {
|
AutoResizingComboBox {
|
||||||
// ignore setting the index at first, and actually set it when the component is loaded
|
// ignore setting the index at first, and actually set it when the component is loaded
|
||||||
@@ -88,7 +88,7 @@ Flickable {
|
|||||||
|
|
||||||
// Some platforms have different desktop resolutions
|
// Some platforms have different desktop resolutions
|
||||||
// and native resolutions (like macOS with Retina displays)
|
// and native resolutions (like macOS with Retina displays)
|
||||||
if (displayResIndex == 0) {
|
if (displayResIndex === 0) {
|
||||||
screenRect = SystemProperties.getDesktopResolution(displayIndex)
|
screenRect = SystemProperties.getDesktopResolution(displayIndex)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -129,6 +129,20 @@ Flickable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prune resolutions that are over the decoder's maximum
|
||||||
|
var max_pixels = SystemProperties.maximumResolution.width * SystemProperties.maximumResolution.height;
|
||||||
|
if (max_pixels > 0) {
|
||||||
|
for (var j = 0; j < resolutionComboBox.count; j++) {
|
||||||
|
var existing_width = parseInt(resolutionListModel.get(j).video_width);
|
||||||
|
var existing_height = parseInt(resolutionListModel.get(j).video_height);
|
||||||
|
|
||||||
|
if (existing_width * existing_height > max_pixels) {
|
||||||
|
resolutionListModel.remove(j)
|
||||||
|
j--
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// load the saved width/height, and iterate through the ComboBox until a match is found
|
// load the saved width/height, and iterate through the ComboBox until a match is found
|
||||||
// and set it to that index.
|
// and set it to that index.
|
||||||
var saved_width = StreamingPreferences.width
|
var saved_width = StreamingPreferences.width
|
||||||
@@ -149,6 +163,7 @@ Flickable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
id: resolutionComboBox
|
id: resolutionComboBox
|
||||||
|
maximumWidth: parent.width / 2
|
||||||
textRole: "text"
|
textRole: "text"
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
id: resolutionListModel
|
id: resolutionListModel
|
||||||
@@ -265,6 +280,7 @@ Flickable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
id: fpsComboBox
|
id: fpsComboBox
|
||||||
|
maximumWidth: parent.width / 2
|
||||||
textRole: "text"
|
textRole: "text"
|
||||||
// ::onActivated must be used, as it only listens for when the index is changed by a human
|
// ::onActivated must be used, as it only listens for when the index is changed by a human
|
||||||
onActivated : {
|
onActivated : {
|
||||||
@@ -338,19 +354,24 @@ Flickable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var savedWm = StreamingPreferences.windowMode
|
|
||||||
currentIndex = 0
|
currentIndex = 0
|
||||||
for (var i = 0; i < windowModeListModel.count; i++) {
|
|
||||||
var thisWm = windowModeListModel.get(i).val;
|
if (SystemProperties.hasWindowManager && !SystemProperties.rendererAlwaysFullScreen) {
|
||||||
if (savedWm === thisWm) {
|
var savedWm = StreamingPreferences.windowMode
|
||||||
currentIndex = i
|
for (var i = 0; i < windowModeListModel.count; i++) {
|
||||||
break
|
var thisWm = windowModeListModel.get(i).val;
|
||||||
}
|
if (savedWm === thisWm) {
|
||||||
|
currentIndex = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activated(currentIndex)
|
activated(currentIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
id: windowModeComboBox
|
id: windowModeComboBox
|
||||||
|
enabled: SystemProperties.hasWindowManager && !SystemProperties.rendererAlwaysFullScreen
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
textRole: "text"
|
textRole: "text"
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
@@ -380,6 +401,7 @@ Flickable {
|
|||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: vsyncCheck
|
id: vsyncCheck
|
||||||
|
width: parent.width
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
text: "V-Sync"
|
text: "V-Sync"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
@@ -396,6 +418,7 @@ Flickable {
|
|||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: framePacingCheck
|
id: framePacingCheck
|
||||||
|
width: parent.width
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
text: "Frame pacing"
|
text: "Frame pacing"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
@@ -415,7 +438,7 @@ Flickable {
|
|||||||
GroupBox {
|
GroupBox {
|
||||||
|
|
||||||
id: audioSettingsGroupBox
|
id: audioSettingsGroupBox
|
||||||
width: (parent.width - 2 * parent.padding)
|
width: (parent.width - (parent.leftPadding + parent.rightPadding))
|
||||||
padding: 12
|
padding: 12
|
||||||
title: "<font color=\"skyblue\">Audio Settings</font>"
|
title: "<font color=\"skyblue\">Audio Settings</font>"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
@@ -459,6 +482,10 @@ Flickable {
|
|||||||
text: "5.1 surround sound"
|
text: "5.1 surround sound"
|
||||||
val: StreamingPreferences.AC_51_SURROUND
|
val: StreamingPreferences.AC_51_SURROUND
|
||||||
}
|
}
|
||||||
|
ListElement {
|
||||||
|
text: "7.1 surround sound"
|
||||||
|
val: StreamingPreferences.AC_71_SURROUND
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ::onActivated must be used, as it only listens for when the index is changed by a human
|
// ::onActivated must be used, as it only listens for when the index is changed by a human
|
||||||
onActivated : {
|
onActivated : {
|
||||||
@@ -471,7 +498,7 @@ Flickable {
|
|||||||
|
|
||||||
GroupBox {
|
GroupBox {
|
||||||
id: uiSettingsGroupBox
|
id: uiSettingsGroupBox
|
||||||
width: (parent.width - 2 * parent.padding)
|
width: (parent.width - (parent.leftPadding + parent.rightPadding))
|
||||||
padding: 12
|
padding: 12
|
||||||
title: "<font color=\"skyblue\">UI Settings</font>"
|
title: "<font color=\"skyblue\">UI Settings</font>"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
@@ -482,9 +509,11 @@ Flickable {
|
|||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: startMaximizedCheck
|
id: startMaximizedCheck
|
||||||
|
width: parent.width
|
||||||
text: "Maximize Moonlight window on startup"
|
text: "Maximize Moonlight window on startup"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: !StreamingPreferences.startWindowed
|
enabled: SystemProperties.hasWindowManager
|
||||||
|
checked: !StreamingPreferences.startWindowed || !SystemProperties.hasWindowManager
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
StreamingPreferences.startWindowed = !checked
|
StreamingPreferences.startWindowed = !checked
|
||||||
}
|
}
|
||||||
@@ -492,6 +521,7 @@ Flickable {
|
|||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: connectionWarningsCheck
|
id: connectionWarningsCheck
|
||||||
|
width: parent.width
|
||||||
text: "Show connection quality warnings"
|
text: "Show connection quality warnings"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: StreamingPreferences.connectionWarnings
|
checked: StreamingPreferences.connectionWarnings
|
||||||
@@ -503,6 +533,7 @@ Flickable {
|
|||||||
CheckBox {
|
CheckBox {
|
||||||
visible: SystemProperties.hasDiscordIntegration
|
visible: SystemProperties.hasDiscordIntegration
|
||||||
id: discordPresenceCheck
|
id: discordPresenceCheck
|
||||||
|
width: parent.width
|
||||||
text: "Discord Rich Presence integration"
|
text: "Discord Rich Presence integration"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: StreamingPreferences.richPresence
|
checked: StreamingPreferences.richPresence
|
||||||
@@ -521,13 +552,15 @@ Flickable {
|
|||||||
|
|
||||||
Column {
|
Column {
|
||||||
padding: 10
|
padding: 10
|
||||||
|
rightPadding: 20
|
||||||
anchors.left: settingsColumn1.right
|
anchors.left: settingsColumn1.right
|
||||||
id: settingsColumn2
|
id: settingsColumn2
|
||||||
width: settingsPage.width / 2 - padding
|
width: settingsPage.width / 2
|
||||||
|
spacing: 15
|
||||||
|
|
||||||
GroupBox {
|
GroupBox {
|
||||||
id: gamepadSettingsGroupBox
|
id: gamepadSettingsGroupBox
|
||||||
width: (parent.width - parent.padding)
|
width: (parent.width - (parent.leftPadding + parent.rightPadding))
|
||||||
padding: 12
|
padding: 12
|
||||||
title: "<font color=\"skyblue\">Input Settings</font>"
|
title: "<font color=\"skyblue\">Input Settings</font>"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
@@ -538,6 +571,7 @@ Flickable {
|
|||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: singleControllerCheck
|
id: singleControllerCheck
|
||||||
|
width: parent.width
|
||||||
text: "Force gamepad #1 always present"
|
text: "Force gamepad #1 always present"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: !StreamingPreferences.multiController
|
checked: !StreamingPreferences.multiController
|
||||||
@@ -553,24 +587,45 @@ Flickable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: rawInputCheck
|
id: absoluteMouseCheck
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
text: "Raw mouse input"
|
width: parent.width
|
||||||
|
text: "Optimize mouse for remote desktop instead of games"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: !StreamingPreferences.mouseAcceleration
|
enabled: SystemProperties.hasWindowManager
|
||||||
|
checked: StreamingPreferences.absoluteMouseMode && SystemProperties.hasWindowManager
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
StreamingPreferences.mouseAcceleration = !checked
|
StreamingPreferences.absoluteMouseMode = checked
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolTip.delay: 1000
|
ToolTip.delay: 1000
|
||||||
ToolTip.timeout: 3000
|
ToolTip.timeout: 5000
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.text: "When checked, mouse input is not accelerated or scaled by the OS before passing to Moonlight"
|
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."
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: absoluteTouchCheck
|
||||||
|
hoverEnabled: true
|
||||||
|
width: parent.width
|
||||||
|
text: "Use touchscreen as a trackpad"
|
||||||
|
font.pointSize: 12
|
||||||
|
checked: !StreamingPreferences.absoluteTouchMode
|
||||||
|
onCheckedChanged: {
|
||||||
|
StreamingPreferences.absoluteTouchMode = !checked
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
CheckBox {
|
||||||
id: gamepadMouseCheck
|
id: gamepadMouseCheck
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
width: parent.width
|
||||||
text: "Gamepad mouse mode support"
|
text: "Gamepad mouse mode support"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: StreamingPreferences.gamepadMouse
|
checked: StreamingPreferences.gamepadMouse
|
||||||
@@ -588,7 +643,7 @@ Flickable {
|
|||||||
|
|
||||||
GroupBox {
|
GroupBox {
|
||||||
id: hostSettingsGroupBox
|
id: hostSettingsGroupBox
|
||||||
width: (parent.width - parent.padding)
|
width: (parent.width - (parent.leftPadding + parent.rightPadding))
|
||||||
padding: 12
|
padding: 12
|
||||||
title: "<font color=\"skyblue\">Host Settings</font>"
|
title: "<font color=\"skyblue\">Host Settings</font>"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
@@ -599,6 +654,7 @@ Flickable {
|
|||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: optimizeGameSettingsCheck
|
id: optimizeGameSettingsCheck
|
||||||
|
width: parent.width
|
||||||
text: "Optimize game settings"
|
text: "Optimize game settings"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: StreamingPreferences.gameOptimizations
|
checked: StreamingPreferences.gameOptimizations
|
||||||
@@ -609,6 +665,7 @@ Flickable {
|
|||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: audioPcCheck
|
id: audioPcCheck
|
||||||
|
width: parent.width
|
||||||
text: "Play audio on host PC"
|
text: "Play audio on host PC"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: StreamingPreferences.playAudioOnHost
|
checked: StreamingPreferences.playAudioOnHost
|
||||||
@@ -621,7 +678,7 @@ Flickable {
|
|||||||
|
|
||||||
GroupBox {
|
GroupBox {
|
||||||
id: advancedSettingsGroupBox
|
id: advancedSettingsGroupBox
|
||||||
width: (parent.width - parent.padding)
|
width: (parent.width - (parent.leftPadding + parent.rightPadding))
|
||||||
padding: 12
|
padding: 12
|
||||||
title: "<font color=\"skyblue\">Advanced Settings</font>"
|
title: "<font color=\"skyblue\">Advanced Settings</font>"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
@@ -708,20 +765,17 @@ Flickable {
|
|||||||
val: StreamingPreferences.VCC_AUTO
|
val: StreamingPreferences.VCC_AUTO
|
||||||
}
|
}
|
||||||
ListElement {
|
ListElement {
|
||||||
text: "Force H.264"
|
text: "H.264"
|
||||||
val: StreamingPreferences.VCC_FORCE_H264
|
val: StreamingPreferences.VCC_FORCE_H264
|
||||||
}
|
}
|
||||||
ListElement {
|
ListElement {
|
||||||
text: "Force HEVC"
|
text: "HEVC (H.265)"
|
||||||
val: StreamingPreferences.VCC_FORCE_HEVC
|
val: StreamingPreferences.VCC_FORCE_HEVC
|
||||||
}
|
}
|
||||||
// HDR seems to be broken in GFE 3.14.1, and even when that's fixed
|
ListElement {
|
||||||
// we'll probably need to gate this feature on OS support in our
|
text: "HEVC HDR (Experimental)"
|
||||||
// renderers.
|
|
||||||
/* ListElement {
|
|
||||||
text: "Force HEVC HDR"
|
|
||||||
val: StreamingPreferences.VCC_FORCE_HEVC_HDR
|
val: StreamingPreferences.VCC_FORCE_HEVC_HDR
|
||||||
} */
|
}
|
||||||
}
|
}
|
||||||
// ::onActivated must be used, as it only listens for when the index is changed by a human
|
// ::onActivated must be used, as it only listens for when the index is changed by a human
|
||||||
onActivated : {
|
onActivated : {
|
||||||
@@ -731,6 +785,7 @@ Flickable {
|
|||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: unlockUnsupportedFps
|
id: unlockUnsupportedFps
|
||||||
|
width: parent.width
|
||||||
text: "Unlock unsupported FPS options"
|
text: "Unlock unsupported FPS options"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: StreamingPreferences.unsupportedFps
|
checked: StreamingPreferences.unsupportedFps
|
||||||
@@ -749,6 +804,7 @@ Flickable {
|
|||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: enableMdns
|
id: enableMdns
|
||||||
|
width: parent.width
|
||||||
text: "Automatically find PCs on the local network (Recommended)"
|
text: "Automatically find PCs on the local network (Recommended)"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: StreamingPreferences.enableMdns
|
checked: StreamingPreferences.enableMdns
|
||||||
@@ -773,6 +829,7 @@ Flickable {
|
|||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: quitAppAfter
|
id: quitAppAfter
|
||||||
|
width: parent.width
|
||||||
text: "Quit app after quitting session"
|
text: "Quit app after quitting session"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: StreamingPreferences.quitAppAfter
|
checked: StreamingPreferences.quitAppAfter
|
||||||
|
|||||||
@@ -117,9 +117,22 @@ Item {
|
|||||||
session.sessionFinished.connect(sessionFinished)
|
session.sessionFinished.connect(sessionFinished)
|
||||||
|
|
||||||
// Kick off the stream
|
// Kick off the stream
|
||||||
|
spinnerTimer.start()
|
||||||
streamLoader.active = true
|
streamLoader.active = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: spinnerTimer
|
||||||
|
|
||||||
|
// Display the spinner appearance a bit to allow us to reach
|
||||||
|
// the code in Session.exec() that pumps the event loop.
|
||||||
|
// If we display it immediately, it will briefly hang in the
|
||||||
|
// middle of the animation on Windows, which looks very
|
||||||
|
// obviously broken.
|
||||||
|
interval: 100
|
||||||
|
onTriggered: stageSpinner.running = true
|
||||||
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: streamLoader
|
id: streamLoader
|
||||||
active: false
|
active: false
|
||||||
@@ -150,6 +163,7 @@ Item {
|
|||||||
|
|
||||||
BusyIndicator {
|
BusyIndicator {
|
||||||
id: stageSpinner
|
id: stageSpinner
|
||||||
|
running: false
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
|||||||
@@ -128,6 +128,13 @@ void ComputerModel::wakeComputer(int computerIndex)
|
|||||||
QThreadPool::globalInstance()->start(wakeTask);
|
QThreadPool::globalInstance()->start(wakeTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComputerModel::renameComputer(int computerIndex, QString name)
|
||||||
|
{
|
||||||
|
Q_ASSERT(computerIndex < m_Computers.count());
|
||||||
|
|
||||||
|
m_ComputerManager->renameHost(m_Computers[computerIndex], name);
|
||||||
|
}
|
||||||
|
|
||||||
void ComputerModel::pairComputer(int computerIndex, QString pin)
|
void ComputerModel::pairComputer(int computerIndex, QString pin)
|
||||||
{
|
{
|
||||||
Q_ASSERT(computerIndex < m_Computers.count());
|
Q_ASSERT(computerIndex < m_Computers.count());
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE void wakeComputer(int computerIndex);
|
Q_INVOKABLE void wakeComputer(int computerIndex);
|
||||||
|
|
||||||
|
Q_INVOKABLE void renameComputer(int computerIndex, QString name);
|
||||||
|
|
||||||
Q_INVOKABLE Session* createSessionForCurrentGame(int computerIndex);
|
Q_INVOKABLE Session* createSessionForCurrentGame(int computerIndex);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
+34
-4
@@ -17,7 +17,7 @@ ApplicationWindow {
|
|||||||
width: 1280
|
width: 1280
|
||||||
height: 600
|
height: 600
|
||||||
|
|
||||||
visibility: StreamingPreferences.startWindowed ? "Windowed" : "Maximized"
|
visibility: (SystemProperties.hasWindowManager && StreamingPreferences.startWindowed) ? "Windowed" : "Maximized"
|
||||||
|
|
||||||
StackView {
|
StackView {
|
||||||
id: stackView
|
id: stackView
|
||||||
@@ -175,6 +175,17 @@ ApplicationWindow {
|
|||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
anchors.bottomMargin: 5
|
anchors.bottomMargin: 5
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: titleLabel
|
||||||
|
visible: toolBar.width > 700
|
||||||
|
anchors.fill: parent
|
||||||
|
text: stackView.currentItem.objectName
|
||||||
|
font.pointSize: 20
|
||||||
|
elide: Label.ElideRight
|
||||||
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
spacing: 20
|
spacing: 20
|
||||||
anchors.leftMargin: 10
|
anchors.leftMargin: 10
|
||||||
@@ -194,14 +205,29 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This label will appear when the window gets too small and
|
||||||
|
// we need to ensure the toolbar controls don't collide
|
||||||
Label {
|
Label {
|
||||||
id: titleLabel
|
id: titleRowLabel
|
||||||
text: stackView.currentItem.objectName
|
font.pointSize: titleLabel.font.pointSize
|
||||||
font.pointSize: 15
|
|
||||||
elide: Label.ElideRight
|
elide: Label.ElideRight
|
||||||
horizontalAlignment: Qt.AlignHCenter
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
verticalAlignment: Qt.AlignVCenter
|
verticalAlignment: Qt.AlignVCenter
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
// We need this label to always be visible so it can occupy
|
||||||
|
// the remaining space in the RowLayout. To "hide" it, we
|
||||||
|
// just set the text to empty string.
|
||||||
|
text: !titleLabel.visible ? stackView.currentItem.objectName : ""
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: versionLabel
|
||||||
|
visible: stackView.currentItem.objectName === "Settings"
|
||||||
|
text: "Version " + SystemProperties.versionString
|
||||||
|
font.pointSize: 12
|
||||||
|
horizontalAlignment: Qt.AlignRight
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigableToolButton {
|
NavigableToolButton {
|
||||||
@@ -413,6 +439,10 @@ ApplicationWindow {
|
|||||||
editText.forceActiveFocus()
|
editText.forceActiveFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClosed: {
|
||||||
|
editText.clear()
|
||||||
|
}
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if (editText.text) {
|
if (editText.text) {
|
||||||
ComputerManager.addNewHost(editText.text, false)
|
ComputerManager.addNewHost(editText.text, false)
|
||||||
|
|||||||
@@ -205,6 +205,31 @@ void SdlGamepadKeyNavigation::onPollingTimerFired()
|
|||||||
sendKey(QEvent::Type::KeyRelease, Qt::Key_Right);
|
sendKey(QEvent::Type::KeyRelease, Qt::Key_Right);
|
||||||
m_LastAxisNavigationEventTime = SDL_GetTicks();
|
m_LastAxisNavigationEventTime = SDL_GetTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In UI navigation mode (settings page), use the right stick to scroll
|
||||||
|
if (m_UiNavMode) {
|
||||||
|
short rightX = SDL_GameControllerGetAxis(gc, SDL_CONTROLLER_AXIS_RIGHTX);
|
||||||
|
short rightY = SDL_GameControllerGetAxis(gc, SDL_CONTROLLER_AXIS_RIGHTY);
|
||||||
|
|
||||||
|
QPoint wheelDelta;
|
||||||
|
if (rightX > 30000) {
|
||||||
|
wheelDelta.setX(30);
|
||||||
|
}
|
||||||
|
else if (rightX < -30000) {
|
||||||
|
wheelDelta.setX(-30);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rightY > 30000) {
|
||||||
|
wheelDelta.setY(-30);
|
||||||
|
}
|
||||||
|
else if (rightY < -30000) {
|
||||||
|
wheelDelta.setY(30);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wheelDelta.isNull()) {
|
||||||
|
sendWheel(wheelDelta);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,6 +243,22 @@ void SdlGamepadKeyNavigation::sendKey(QEvent::Type type, Qt::Key key, Qt::Keyboa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SdlGamepadKeyNavigation::sendWheel(QPoint& angleDelta)
|
||||||
|
{
|
||||||
|
QGuiApplication* app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||||
|
QWindow* focusWindow = app->focusWindow();
|
||||||
|
if (focusWindow != nullptr) {
|
||||||
|
QPoint mousePos(focusWindow->width() / 2, focusWindow->height() / 2);
|
||||||
|
QPoint globalPos(focusWindow->mapToGlobal(mousePos));
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
|
||||||
|
QWheelEvent wheelEvent(mousePos, globalPos, QPoint(), angleDelta, Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false, Qt::MouseEventSynthesizedByApplication);
|
||||||
|
#else
|
||||||
|
QWheelEvent wheelEvent(mousePos, globalPos, QPoint(), angleDelta, angleDelta.y(), Qt::Vertical, Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, Qt::MouseEventSynthesizedByApplication, false);
|
||||||
|
#endif
|
||||||
|
app->sendEvent(focusWindow, &wheelEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SdlGamepadKeyNavigation::setUiNavMode(bool uiNavMode)
|
void SdlGamepadKeyNavigation::setUiNavMode(bool uiNavMode)
|
||||||
{
|
{
|
||||||
m_UiNavMode = uiNavMode;
|
m_UiNavMode = uiNavMode;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void sendKey(QEvent::Type type, Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
void sendKey(QEvent::Type type, Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
||||||
|
void sendWheel(QPoint& angleDelta);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onPollingTimerFired();
|
void onPollingTimerFired();
|
||||||
|
|||||||
+68
-9
@@ -10,6 +10,7 @@
|
|||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
// Don't let SDL hook our main function, since Qt is already
|
// Don't let SDL hook our main function, since Qt is already
|
||||||
// doing the same thing. This needs to be before any headers
|
// doing the same thing. This needs to be before any headers
|
||||||
@@ -21,14 +22,17 @@
|
|||||||
#include "streaming/video/ffmpeg.h"
|
#include "streaming/video/ffmpeg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#if defined(Q_OS_WIN32)
|
||||||
#include "antihookingprotection.h"
|
#include "antihookingprotection.h"
|
||||||
|
#elif defined(Q_OS_LINUX)
|
||||||
|
#include <openssl/ssl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "cli/quitstream.h"
|
#include "cli/quitstream.h"
|
||||||
#include "cli/startstream.h"
|
#include "cli/startstream.h"
|
||||||
#include "cli/commandlineparser.h"
|
#include "cli/commandlineparser.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "utils.h"
|
||||||
#include "gui/computermodel.h"
|
#include "gui/computermodel.h"
|
||||||
#include "gui/appmodel.h"
|
#include "gui/appmodel.h"
|
||||||
#include "backend/autoupdatechecker.h"
|
#include "backend/autoupdatechecker.h"
|
||||||
@@ -72,7 +76,12 @@ void logToLoggerStream(QString& message)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (s_LogLinesWritten == MAX_LOG_LINES) {
|
else if (s_LogLinesWritten == MAX_LOG_LINES) {
|
||||||
s_LoggerStream << "Log size limit reached!" << endl;
|
s_LoggerStream << "Log size limit reached!";
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
s_LoggerStream << Qt::endl;
|
||||||
|
#else
|
||||||
|
s_LoggerStream << endl;
|
||||||
|
#endif
|
||||||
s_LogLimitReached = true;
|
s_LogLimitReached = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -279,19 +288,44 @@ int main(int argc, char *argv[])
|
|||||||
SetUnhandledExceptionFilter(UnhandledExceptionHandler);
|
SetUnhandledExceptionFilter(UnhandledExceptionHandler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#if defined(Q_OS_WIN32)
|
||||||
// Force AntiHooking.dll to be statically imported and loaded
|
// Force AntiHooking.dll to be statically imported and loaded
|
||||||
// by ntdll by calling a dummy function.
|
// by ntdll by calling a dummy function.
|
||||||
AntiHookingDummyImport();
|
AntiHookingDummyImport();
|
||||||
|
#elif defined(Q_OS_LINUX)
|
||||||
|
// Force libssl.so to be directly linked to our binary, so
|
||||||
|
// linuxdeployqt can find it and include it in our AppImage.
|
||||||
|
// QtNetwork will pull it in via dlopen().
|
||||||
|
SSL_free(nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enable High DPI support
|
// Avoid using High DPI on EGLFS. It breaks font rendering.
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
// https://bugreports.qt.io/browse/QTBUG-64377
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
// Enable fractional High DPI scaling on Qt 5.14 and later
|
// Enable fractional High DPI scaling on Qt 5.14 and later
|
||||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#ifndef STEAM_LINK
|
||||||
|
if (!qEnvironmentVariableIsSet("QT_QPA_PLATFORM")) {
|
||||||
|
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 (!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.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// This avoids using the default keychain for SSL, which may cause
|
// This avoids using the default keychain for SSL, which may cause
|
||||||
// password prompts on macOS.
|
// password prompts on macOS.
|
||||||
@@ -333,6 +367,12 @@ int main(int argc, char *argv[])
|
|||||||
// initializing the SDL video subsystem to have any effect.
|
// initializing the SDL video subsystem to have any effect.
|
||||||
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
|
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
|
||||||
|
|
||||||
|
// For SDL backends that support it, use double buffering instead of triple buffering
|
||||||
|
// to save a frame of latency. This doesn't matter for MMAL or DRM renderers since they
|
||||||
|
// are drawing directly to the screen without involving SDL, but it may matter for other
|
||||||
|
// future KMSDRM platforms that use SDL for rendering.
|
||||||
|
SDL_SetHint(SDL_HINT_VIDEO_DOUBLE_BUFFER, "1");
|
||||||
|
|
||||||
if (SDL_InitSubSystem(SDL_INIT_TIMER) != 0) {
|
if (SDL_InitSubSystem(SDL_INIT_TIMER) != 0) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"SDL_InitSubSystem(SDL_INIT_TIMER) failed: %s",
|
"SDL_InitSubSystem(SDL_INIT_TIMER) failed: %s",
|
||||||
@@ -363,6 +403,11 @@ int main(int argc, char *argv[])
|
|||||||
// Disable minimize on focus loss by default. Users seem to want this off by default.
|
// Disable minimize on focus loss by default. Users seem to want this off by default.
|
||||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
||||||
|
|
||||||
|
// SDL 2.0.12 changes the default behavior to use the button label rather than the button
|
||||||
|
// position as most other software does. Set this back to 0 to stay consistent with prior
|
||||||
|
// releases of Moonlight.
|
||||||
|
SDL_SetHint("SDL_GAMECONTROLLER_USE_BUTTON_LABELS", "0");
|
||||||
|
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
// Allow thread naming using exceptions on debug builds. SDL doesn't use SEH
|
// 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
|
// when throwing the exceptions, so we don't enable it for release builds out
|
||||||
@@ -374,12 +419,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// After the QGuiApplication is created, the platform stuff will be initialized
|
// After the QGuiApplication is created, the platform stuff will be initialized
|
||||||
// and we can set the SDL video driver to match Qt.
|
// and we can set the SDL video driver to match Qt.
|
||||||
if (qgetenv("XDG_SESSION_TYPE") == "wayland" && QGuiApplication::platformName() == "xcb") {
|
if (WMUtils::isRunningWayland() && QGuiApplication::platformName() == "xcb") {
|
||||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Detected XWayland. This will probably break hardware decoding! Try running with QT_QPA_PLATFORM=wayland or switch to X11.");
|
"Detected XWayland. This will probably break hardware decoding! Try running with QT_QPA_PLATFORM=wayland or switch to X11.");
|
||||||
}
|
}
|
||||||
else if (QGuiApplication::platformName().startsWith("wayland")) {
|
else if (QGuiApplication::platformName().startsWith("wayland")) {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Detected Wayland. Performance may be worse than X11.");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Detected Wayland");
|
||||||
qputenv("SDL_VIDEODRIVER", "wayland");
|
qputenv("SDL_VIDEODRIVER", "wayland");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,6 +442,17 @@ int main(int argc, char *argv[])
|
|||||||
// Move the mouse to the bottom right so it's invisible when using
|
// Move the mouse to the bottom right so it's invisible when using
|
||||||
// gamepad-only navigation.
|
// gamepad-only navigation.
|
||||||
QCursor().setPos(0xFFFF, 0xFFFF);
|
QCursor().setPos(0xFFFF, 0xFFFF);
|
||||||
|
#elif !SDL_VERSION_ATLEAST(2, 0, 11) && defined(Q_OS_LINUX) && (defined(__arm__) || defined(__aarch64__))
|
||||||
|
if (qgetenv("SDL_VIDEO_GL_DRIVER").isEmpty() && QGuiApplication::platformName() == "eglfs") {
|
||||||
|
// Look for Raspberry Pi GLES libraries. SDL 2.0.10 and earlier needs some help finding
|
||||||
|
// the correct libraries for the KMSDRM backend if not compiled with the RPI backend enabled.
|
||||||
|
if (SDL_LoadObject("libbrcmGLESv2.so") != nullptr) {
|
||||||
|
qputenv("SDL_VIDEO_GL_DRIVER", "libbrcmGLESv2.so");
|
||||||
|
}
|
||||||
|
else if (SDL_LoadObject("/opt/vc/lib/libbrcmGLESv2.so") != nullptr) {
|
||||||
|
qputenv("SDL_VIDEO_GL_DRIVER", "/opt/vc/lib/libbrcmGLESv2.so");
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
app.setWindowIcon(QIcon(":/res/moonlight.svg"));
|
app.setWindowIcon(QIcon(":/res/moonlight.svg"));
|
||||||
@@ -431,6 +487,9 @@ int main(int argc, char *argv[])
|
|||||||
return new StreamingPreferences();
|
return new StreamingPreferences();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Create the identity manager on the main thread
|
||||||
|
IdentityManager::get();
|
||||||
|
|
||||||
#ifndef Q_OS_WINRT
|
#ifndef Q_OS_WINRT
|
||||||
// Use the dense material dark theme by default
|
// Use the dense material dark theme by default
|
||||||
if (!qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_STYLE")) {
|
if (!qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_STYLE")) {
|
||||||
|
|||||||
@@ -19,5 +19,7 @@
|
|||||||
<qresource prefix="/data">
|
<qresource prefix="/data">
|
||||||
<file alias="gamecontrollerdb.txt">SDL_GameControllerDB/gamecontrollerdb.txt</file>
|
<file alias="gamecontrollerdb.txt">SDL_GameControllerDB/gamecontrollerdb.txt</file>
|
||||||
<file alias="ModeSeven.ttf">ModeSeven.ttf</file>
|
<file alias="ModeSeven.ttf">ModeSeven.ttf</file>
|
||||||
|
<file alias="egl.frag">shaders/egl.frag</file>
|
||||||
|
<file alias="egl.vert">shaders/egl.vert</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
@@ -26,7 +26,13 @@ MappingManager::MappingManager()
|
|||||||
settings.endArray();
|
settings.endArray();
|
||||||
|
|
||||||
// Finally load mappings from SDL_HINT_GAMECONTROLLERCONFIG
|
// Finally load mappings from SDL_HINT_GAMECONTROLLERCONFIG
|
||||||
QStringList sdlMappings = QString::fromLocal8Bit(SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG)).split('\n', QString::SkipEmptyParts);
|
QStringList sdlMappings =
|
||||||
|
QString::fromLocal8Bit(SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG))
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
.split('\n', Qt::SkipEmptyParts);
|
||||||
|
#else
|
||||||
|
.split('\n', QString::SkipEmptyParts);
|
||||||
|
#endif
|
||||||
for (QString sdlMapping : sdlMappings) {
|
for (QString sdlMapping : sdlMappings) {
|
||||||
SdlGamepadMapping mapping(sdlMapping);
|
SdlGamepadMapping mapping(sdlMapping);
|
||||||
addMapping(mapping);
|
addMapping(mapping);
|
||||||
|
|||||||
@@ -19,13 +19,15 @@
|
|||||||
#define SER_UNSUPPORTEDFPS "unsupportedfps"
|
#define SER_UNSUPPORTEDFPS "unsupportedfps"
|
||||||
#define SER_MDNS "mdns"
|
#define SER_MDNS "mdns"
|
||||||
#define SER_QUITAPPAFTER "quitAppAfter"
|
#define SER_QUITAPPAFTER "quitAppAfter"
|
||||||
#define SER_MOUSEACCELERATION "mouseacceleration"
|
#define SER_ABSMOUSEMODE "mouseacceleration"
|
||||||
|
#define SER_ABSTOUCHMODE "abstouchmode"
|
||||||
#define SER_STARTWINDOWED "startwindowed"
|
#define SER_STARTWINDOWED "startwindowed"
|
||||||
#define SER_FRAMEPACING "framepacing"
|
#define SER_FRAMEPACING "framepacing"
|
||||||
#define SER_CONNWARNINGS "connwarnings"
|
#define SER_CONNWARNINGS "connwarnings"
|
||||||
#define SER_RICHPRESENCE "richpresence"
|
#define SER_RICHPRESENCE "richpresence"
|
||||||
#define SER_GAMEPADMOUSE "gamepadmouse"
|
#define SER_GAMEPADMOUSE "gamepadmouse"
|
||||||
#define SER_DEFAULTVER "defaultver"
|
#define SER_DEFAULTVER "defaultver"
|
||||||
|
#define SER_PACKETSIZE "packetsize"
|
||||||
|
|
||||||
#define CURRENT_DEFAULT_VER 1
|
#define CURRENT_DEFAULT_VER 1
|
||||||
|
|
||||||
@@ -58,12 +60,14 @@ void StreamingPreferences::reload()
|
|||||||
unsupportedFps = settings.value(SER_UNSUPPORTEDFPS, false).toBool();
|
unsupportedFps = settings.value(SER_UNSUPPORTEDFPS, false).toBool();
|
||||||
enableMdns = settings.value(SER_MDNS, true).toBool();
|
enableMdns = settings.value(SER_MDNS, true).toBool();
|
||||||
quitAppAfter = settings.value(SER_QUITAPPAFTER, false).toBool();
|
quitAppAfter = settings.value(SER_QUITAPPAFTER, false).toBool();
|
||||||
mouseAcceleration = settings.value(SER_MOUSEACCELERATION, false).toBool();
|
absoluteMouseMode = settings.value(SER_ABSMOUSEMODE, false).toBool();
|
||||||
startWindowed = settings.value(SER_STARTWINDOWED, false).toBool();
|
absoluteTouchMode = settings.value(SER_ABSTOUCHMODE, true).toBool();
|
||||||
|
startWindowed = settings.value(SER_STARTWINDOWED, true).toBool();
|
||||||
framePacing = settings.value(SER_FRAMEPACING, false).toBool();
|
framePacing = settings.value(SER_FRAMEPACING, false).toBool();
|
||||||
connectionWarnings = settings.value(SER_CONNWARNINGS, true).toBool();
|
connectionWarnings = settings.value(SER_CONNWARNINGS, true).toBool();
|
||||||
richPresence = settings.value(SER_RICHPRESENCE, true).toBool();
|
richPresence = settings.value(SER_RICHPRESENCE, true).toBool();
|
||||||
gamepadMouse = settings.value(SER_GAMEPADMOUSE, true).toBool();
|
gamepadMouse = settings.value(SER_GAMEPADMOUSE, true).toBool();
|
||||||
|
packetSize = settings.value(SER_PACKETSIZE, 0).toInt();
|
||||||
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
|
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
|
||||||
static_cast<int>(AudioConfig::AC_STEREO)).toInt());
|
static_cast<int>(AudioConfig::AC_STEREO)).toInt());
|
||||||
videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG,
|
videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG,
|
||||||
@@ -101,12 +105,14 @@ void StreamingPreferences::save()
|
|||||||
settings.setValue(SER_UNSUPPORTEDFPS, unsupportedFps);
|
settings.setValue(SER_UNSUPPORTEDFPS, unsupportedFps);
|
||||||
settings.setValue(SER_MDNS, enableMdns);
|
settings.setValue(SER_MDNS, enableMdns);
|
||||||
settings.setValue(SER_QUITAPPAFTER, quitAppAfter);
|
settings.setValue(SER_QUITAPPAFTER, quitAppAfter);
|
||||||
settings.setValue(SER_MOUSEACCELERATION, mouseAcceleration);
|
settings.setValue(SER_ABSMOUSEMODE, absoluteMouseMode);
|
||||||
|
settings.setValue(SER_ABSTOUCHMODE, absoluteTouchMode);
|
||||||
settings.setValue(SER_STARTWINDOWED, startWindowed);
|
settings.setValue(SER_STARTWINDOWED, startWindowed);
|
||||||
settings.setValue(SER_FRAMEPACING, framePacing);
|
settings.setValue(SER_FRAMEPACING, framePacing);
|
||||||
settings.setValue(SER_CONNWARNINGS, connectionWarnings);
|
settings.setValue(SER_CONNWARNINGS, connectionWarnings);
|
||||||
settings.setValue(SER_RICHPRESENCE, richPresence);
|
settings.setValue(SER_RICHPRESENCE, richPresence);
|
||||||
settings.setValue(SER_GAMEPADMOUSE, gamepadMouse);
|
settings.setValue(SER_GAMEPADMOUSE, gamepadMouse);
|
||||||
|
settings.setValue(SER_PACKETSIZE, packetSize);
|
||||||
settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig));
|
settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig));
|
||||||
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
|
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
|
||||||
settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection));
|
settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection));
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ public:
|
|||||||
enum AudioConfig
|
enum AudioConfig
|
||||||
{
|
{
|
||||||
AC_STEREO,
|
AC_STEREO,
|
||||||
AC_51_SURROUND
|
AC_51_SURROUND,
|
||||||
|
AC_71_SURROUND
|
||||||
};
|
};
|
||||||
Q_ENUM(AudioConfig)
|
Q_ENUM(AudioConfig)
|
||||||
|
|
||||||
@@ -60,7 +61,8 @@ public:
|
|||||||
Q_PROPERTY(bool unsupportedFps MEMBER unsupportedFps NOTIFY unsupportedFpsChanged)
|
Q_PROPERTY(bool unsupportedFps MEMBER unsupportedFps NOTIFY unsupportedFpsChanged)
|
||||||
Q_PROPERTY(bool enableMdns MEMBER enableMdns NOTIFY enableMdnsChanged)
|
Q_PROPERTY(bool enableMdns MEMBER enableMdns NOTIFY enableMdnsChanged)
|
||||||
Q_PROPERTY(bool quitAppAfter MEMBER quitAppAfter NOTIFY quitAppAfterChanged)
|
Q_PROPERTY(bool quitAppAfter MEMBER quitAppAfter NOTIFY quitAppAfterChanged)
|
||||||
Q_PROPERTY(bool mouseAcceleration MEMBER mouseAcceleration NOTIFY mouseAccelerationChanged)
|
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 startWindowed MEMBER startWindowed NOTIFY startWindowedChanged)
|
||||||
Q_PROPERTY(bool framePacing MEMBER framePacing NOTIFY framePacingChanged)
|
Q_PROPERTY(bool framePacing MEMBER framePacing NOTIFY framePacingChanged)
|
||||||
Q_PROPERTY(bool connectionWarnings MEMBER connectionWarnings NOTIFY connectionWarningsChanged)
|
Q_PROPERTY(bool connectionWarnings MEMBER connectionWarnings NOTIFY connectionWarningsChanged)
|
||||||
@@ -84,12 +86,14 @@ public:
|
|||||||
bool unsupportedFps;
|
bool unsupportedFps;
|
||||||
bool enableMdns;
|
bool enableMdns;
|
||||||
bool quitAppAfter;
|
bool quitAppAfter;
|
||||||
bool mouseAcceleration;
|
bool absoluteMouseMode;
|
||||||
|
bool absoluteTouchMode;
|
||||||
bool startWindowed;
|
bool startWindowed;
|
||||||
bool framePacing;
|
bool framePacing;
|
||||||
bool connectionWarnings;
|
bool connectionWarnings;
|
||||||
bool richPresence;
|
bool richPresence;
|
||||||
bool gamepadMouse;
|
bool gamepadMouse;
|
||||||
|
int packetSize;
|
||||||
AudioConfig audioConfig;
|
AudioConfig audioConfig;
|
||||||
VideoCodecConfig videoCodecConfig;
|
VideoCodecConfig videoCodecConfig;
|
||||||
VideoDecoderSelection videoDecoderSelection;
|
VideoDecoderSelection videoDecoderSelection;
|
||||||
@@ -106,7 +110,8 @@ signals:
|
|||||||
void unsupportedFpsChanged();
|
void unsupportedFpsChanged();
|
||||||
void enableMdnsChanged();
|
void enableMdnsChanged();
|
||||||
void quitAppAfterChanged();
|
void quitAppAfterChanged();
|
||||||
void mouseAccelerationChanged();
|
void absoluteMouseModeChanged();
|
||||||
|
void absoluteTouchModeChanged();
|
||||||
void audioConfigChanged();
|
void audioConfigChanged();
|
||||||
void videoCodecConfigChanged();
|
void videoCodecConfigChanged();
|
||||||
void videoDecoderSelectionChanged();
|
void videoDecoderSelectionChanged();
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#version 300 es
|
||||||
|
#extension GL_OES_EGL_image_external : require
|
||||||
|
precision mediump float;
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
in vec2 vTextCoord;
|
||||||
|
|
||||||
|
uniform mat3 yuvmat;
|
||||||
|
uniform vec3 offset;
|
||||||
|
uniform samplerExternalOES plane1;
|
||||||
|
uniform samplerExternalOES plane2;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 YCbCr = vec3(
|
||||||
|
texture2D(plane1, vTextCoord)[0],
|
||||||
|
texture2D(plane2, vTextCoord).xy
|
||||||
|
);
|
||||||
|
|
||||||
|
YCbCr -= offset;
|
||||||
|
FragColor = vec4(clamp(yuvmat * YCbCr, 0.0, 1.0), 1.0f);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#version 300 es
|
||||||
|
|
||||||
|
layout (location = 0) in vec2 aPosition; // 2D: X,Y
|
||||||
|
layout (location = 1) in vec2 aTexCoord;
|
||||||
|
out vec2 vTextCoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vTextCoord = aTexCoord;
|
||||||
|
gl_Position = vec4(aPosition, 0, 1);
|
||||||
|
}
|
||||||
@@ -80,19 +80,7 @@ int Session::getAudioRendererCapabilities(int audioConfiguration)
|
|||||||
OPUS_MULTISTREAM_CONFIGURATION opusConfig = {};
|
OPUS_MULTISTREAM_CONFIGURATION opusConfig = {};
|
||||||
opusConfig.sampleRate = 48000;
|
opusConfig.sampleRate = 48000;
|
||||||
opusConfig.samplesPerFrame = 240;
|
opusConfig.samplesPerFrame = 240;
|
||||||
|
opusConfig.channelCount = CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(audioConfiguration);
|
||||||
switch (audioConfiguration)
|
|
||||||
{
|
|
||||||
case AUDIO_CONFIGURATION_STEREO:
|
|
||||||
opusConfig.channelCount = 2;
|
|
||||||
break;
|
|
||||||
case AUDIO_CONFIGURATION_51_SURROUND:
|
|
||||||
opusConfig.channelCount = 6;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SDL_assert(false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
IAudioRenderer* audioRenderer = createAudioRenderer(&opusConfig);
|
IAudioRenderer* audioRenderer = createAudioRenderer(&opusConfig);
|
||||||
if (audioRenderer == nullptr) {
|
if (audioRenderer == nullptr) {
|
||||||
@@ -113,19 +101,7 @@ bool Session::testAudio(int audioConfiguration)
|
|||||||
OPUS_MULTISTREAM_CONFIGURATION opusConfig = {};
|
OPUS_MULTISTREAM_CONFIGURATION opusConfig = {};
|
||||||
opusConfig.sampleRate = 48000;
|
opusConfig.sampleRate = 48000;
|
||||||
opusConfig.samplesPerFrame = 240;
|
opusConfig.samplesPerFrame = 240;
|
||||||
|
opusConfig.channelCount = CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(audioConfiguration);
|
||||||
switch (audioConfiguration)
|
|
||||||
{
|
|
||||||
case AUDIO_CONFIGURATION_STEREO:
|
|
||||||
opusConfig.channelCount = 2;
|
|
||||||
break;
|
|
||||||
case AUDIO_CONFIGURATION_51_SURROUND:
|
|
||||||
opusConfig.channelCount = 6;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SDL_assert(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IAudioRenderer* audioRenderer = createAudioRenderer(&opusConfig);
|
IAudioRenderer* audioRenderer = createAudioRenderer(&opusConfig);
|
||||||
if (audioRenderer == nullptr) {
|
if (audioRenderer == nullptr) {
|
||||||
@@ -237,7 +213,7 @@ void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength)
|
|||||||
|
|
||||||
// Update desiredSize with the number of bytes actually populated by the decoding operation
|
// Update desiredSize with the number of bytes actually populated by the decoding operation
|
||||||
if (samplesDecoded > 0) {
|
if (samplesDecoded > 0) {
|
||||||
SDL_assert(desiredSize >= sizeof(short) * samplesDecoded * s_ActiveSession->m_AudioConfig.channelCount);
|
SDL_assert(desiredSize >= (int)(sizeof(short) * samplesDecoded * s_ActiveSession->m_AudioConfig.channelCount));
|
||||||
desiredSize = sizeof(short) * samplesDecoded * s_ActiveSession->m_AudioConfig.channelCount;
|
desiredSize = sizeof(short) * samplesDecoded * s_ActiveSession->m_AudioConfig.channelCount;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -4,12 +4,42 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
SdlAudioRenderer::SdlAudioRenderer()
|
SdlAudioRenderer::SdlAudioRenderer()
|
||||||
: m_AudioDevice(0),
|
: m_AudioDevice(0),
|
||||||
m_AudioBuffer(nullptr)
|
m_AudioBuffer(nullptr)
|
||||||
{
|
{
|
||||||
SDL_assert(!SDL_WasInit(SDL_INIT_AUDIO));
|
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) {
|
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"SDL_InitSubSystem(SDL_INIT_AUDIO) failed: %s",
|
"SDL_InitSubSystem(SDL_INIT_AUDIO) failed: %s",
|
||||||
@@ -51,9 +81,9 @@ bool SdlAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION*
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Desired audio buffer: %u samples (%lu bytes)",
|
"Desired audio buffer: %u samples (%u bytes)",
|
||||||
want.samples,
|
want.samples,
|
||||||
want.samples * sizeof(short) * want.channels);
|
want.samples * (Uint32)sizeof(short) * want.channels);
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Obtained audio buffer: %u samples (%u bytes)",
|
"Obtained audio buffer: %u samples (%u bytes)",
|
||||||
|
|||||||
@@ -42,26 +42,26 @@ bool SLAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* o
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SWAP_CHANNEL(i, j) \
|
|
||||||
tmp = opusConfig->mapping[i]; \
|
|
||||||
opusConfig->mapping[i] = opusConfig->mapping[j]; \
|
|
||||||
opusConfig->mapping[j] = tmp
|
|
||||||
|
|
||||||
void SLAudioRenderer::remapChannels(POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
|
void SLAudioRenderer::remapChannels(POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
|
||||||
unsigned char tmp;
|
OPUS_MULTISTREAM_CONFIGURATION originalConfig = *opusConfig;
|
||||||
|
|
||||||
if (opusConfig->channelCount == 6) {
|
// The Moonlight's default channel order is FL,FR,C,LFE,RL,RR,SL,SR
|
||||||
// The Moonlight's default channel order is FL,FR,C,LFE,RL,RR
|
// SLAudio expects FL,C,FR,RL,RR,(SL,SR),LFE for 5.1/7.1 so we swap the channels around to match
|
||||||
// SLAudio expects FL,C,FR,RL,RR,LFE so we swap the channels around to match
|
|
||||||
|
|
||||||
// Swap FR and C - now FL,C,FR,LFE,RL,RR
|
if (opusConfig->channelCount == 3 || opusConfig->channelCount >= 6) {
|
||||||
SWAP_CHANNEL(1, 2);
|
// Swap FR and C
|
||||||
|
opusConfig->mapping[1] = originalConfig.mapping[2];
|
||||||
|
opusConfig->mapping[2] = originalConfig.mapping[1];
|
||||||
|
}
|
||||||
|
|
||||||
// Swap LFE and RR - now FL,C,FR,RR,RL,LFE
|
if (opusConfig->channelCount >= 6) {
|
||||||
SWAP_CHANNEL(3, 5);
|
// SLAudio expects the LFE channel at the end
|
||||||
|
opusConfig->mapping[opusConfig->channelCount - 1] = originalConfig.mapping[3];
|
||||||
|
|
||||||
// Swap RR and RL - now FL,C,FR,RL,RR,LFE
|
// Slide the other channels down
|
||||||
SWAP_CHANNEL(3, 4);
|
memcpy(&opusConfig->mapping[3],
|
||||||
|
&originalConfig.mapping[4],
|
||||||
|
opusConfig->channelCount - 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,11 +72,17 @@ int SoundIoAudioRenderer::scoreChannelLayout(const struct SoundIoChannelLayout*
|
|||||||
score++;
|
score++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Score layouts using the back L/R as higher
|
|
||||||
// value than those using side L/R.
|
|
||||||
case SoundIoChannelIdBackLeft:
|
case SoundIoChannelIdBackLeft:
|
||||||
case SoundIoChannelIdBackRight:
|
case SoundIoChannelIdBackRight:
|
||||||
score += 2;
|
if (opusConfig->channelCount == 6) {
|
||||||
|
// Score back channels higher in 5.1 mode to
|
||||||
|
// discourage selection of side channel layouts.
|
||||||
|
score += 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Score back channels normally for 7.1 mode
|
||||||
|
score++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -211,13 +217,25 @@ bool SoundIoAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATI
|
|||||||
|
|
||||||
m_EffectiveLayout = m_OutputStream->layout;
|
m_EffectiveLayout = m_OutputStream->layout;
|
||||||
for (int i = 0; i < m_EffectiveLayout.channel_count; i++) {
|
for (int i = 0; i < m_EffectiveLayout.channel_count; i++) {
|
||||||
// Fixup the layout to use back L/R so our channel position
|
if (opusConfig->channelCount == 6) {
|
||||||
// logic in sioWriteCallback() works.
|
// For 5.1, replace side L/R with back L/R so our channel position
|
||||||
if (m_EffectiveLayout.channels[i] == SoundIoChannelIdSideLeft) {
|
// logic in sioWriteCallback() works.
|
||||||
m_EffectiveLayout.channels[i] = SoundIoChannelIdBackLeft;
|
if (m_EffectiveLayout.channels[i] == SoundIoChannelIdSideLeft) {
|
||||||
|
m_EffectiveLayout.channels[i] = SoundIoChannelIdBackLeft;
|
||||||
|
}
|
||||||
|
if (m_EffectiveLayout.channels[i] == SoundIoChannelIdSideRight) {
|
||||||
|
m_EffectiveLayout.channels[i] = SoundIoChannelIdBackRight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (m_EffectiveLayout.channels[i] == SoundIoChannelIdSideRight) {
|
else if (opusConfig->channelCount == 8) {
|
||||||
m_EffectiveLayout.channels[i] = SoundIoChannelIdBackRight;
|
// For 5.1, replace side L/R with LOC/ROC so our channel position
|
||||||
|
// logic in sioWriteCallback() works.
|
||||||
|
if (m_EffectiveLayout.channels[i] == SoundIoChannelIdSideLeft) {
|
||||||
|
m_EffectiveLayout.channels[i] = SoundIoChannelIdFrontLeftCenter;
|
||||||
|
}
|
||||||
|
if (m_EffectiveLayout.channels[i] == SoundIoChannelIdSideRight) {
|
||||||
|
m_EffectiveLayout.channels[i] = SoundIoChannelIdFrontRightCenter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,9 +429,8 @@ void SoundIoAudioRenderer::sioWriteCallback(SoundIoOutStream* stream, int frameC
|
|||||||
|
|
||||||
for (int frame = 0; frame < frameCount; frame++) {
|
for (int frame = 0; frame < frameCount; frame++) {
|
||||||
for (int ch = 0; ch < me->m_EffectiveLayout.channel_count; ch++) {
|
for (int ch = 0; ch < me->m_EffectiveLayout.channel_count; ch++) {
|
||||||
// SoundIoChannelId - 1 happens to match Moonlight's channel layout.
|
// SoundIoChannelId - 1 happens to match Moonlight's channel layout
|
||||||
// For side L/R, this logic depends on us fixing those up
|
// after we've applied our fixups to m_EffectiveLayout for 5.1 and 7.1.
|
||||||
// in m_EffectiveLayout to back L/R.
|
|
||||||
int readPtrChannel = me->m_EffectiveLayout.channels[ch] - 1;
|
int readPtrChannel = me->m_EffectiveLayout.channels[ch] - 1;
|
||||||
|
|
||||||
if (frame >= framesLeft || readPtrChannel >= me->m_OpusChannelCount) {
|
if (frame >= framesLeft || readPtrChannel >= me->m_OpusChannelCount) {
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,107 @@
|
|||||||
|
#include "input.h"
|
||||||
|
|
||||||
|
#include <Limelight.h>
|
||||||
|
#include <SDL.h>
|
||||||
|
#include "streaming/streamutils.h"
|
||||||
|
|
||||||
|
#include <QtMath>
|
||||||
|
|
||||||
|
// How long the fingers must be stationary to start a right click
|
||||||
|
#define LONG_PRESS_ACTIVATION_DELAY 650
|
||||||
|
|
||||||
|
// How far the finger can move before it cancels a right click
|
||||||
|
#define LONG_PRESS_ACTIVATION_DELTA 0.01f
|
||||||
|
|
||||||
|
// How long the double tap deadzone stays in effect between touch up and touch down
|
||||||
|
#define DOUBLE_TAP_DEAD_ZONE_DELAY 250
|
||||||
|
|
||||||
|
// How far the finger can move before it can override the double tap deadzone
|
||||||
|
#define DOUBLE_TAP_DEAD_ZONE_DELTA 0.025f
|
||||||
|
|
||||||
|
Uint32 SdlInputHandler::longPressTimerCallback(Uint32, void*)
|
||||||
|
{
|
||||||
|
// Raise the left click and start a right click
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::handleAbsoluteFingerEvent(SDL_TouchFingerEvent* event)
|
||||||
|
{
|
||||||
|
// Observations on Windows 10: x and y appear to be relative to 0,0 of the window client area.
|
||||||
|
// Although SDL documentation states they are 0.0 - 1.0 float values, they can actually be higher
|
||||||
|
// or lower than those values as touch events continue for touches started within the client area that
|
||||||
|
// leave the client area during a drag motion.
|
||||||
|
// dx and dy are deltas from the last touch event, not the first touch down.
|
||||||
|
|
||||||
|
// Ignore touch down events with more than one finger
|
||||||
|
if (event->type == SDL_FINGERDOWN && SDL_GetNumTouchFingers(event->touchId) > 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore touch move and touch up events from the non-primary finger
|
||||||
|
if (event->type != SDL_FINGERDOWN && event->fingerId != m_LastTouchDownEvent.fingerId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Rect src, dst;
|
||||||
|
int windowWidth, windowHeight;
|
||||||
|
|
||||||
|
SDL_GetWindowSize(m_Window, &windowWidth, &windowHeight);
|
||||||
|
|
||||||
|
src.x = src.y = 0;
|
||||||
|
src.w = m_StreamWidth;
|
||||||
|
src.h = m_StreamHeight;
|
||||||
|
|
||||||
|
dst.x = dst.y = 0;
|
||||||
|
dst.w = windowWidth;
|
||||||
|
dst.h = windowHeight;
|
||||||
|
|
||||||
|
// Use the stream and window sizes to determine the video region
|
||||||
|
StreamUtils::scaleSourceToDestinationSurface(&src, &dst);
|
||||||
|
|
||||||
|
if (qSqrt(qPow(event->x - m_LastTouchDownEvent.x, 2) + qPow(event->y - m_LastTouchDownEvent.y, 2)) > LONG_PRESS_ACTIVATION_DELTA) {
|
||||||
|
// Moved too far since touch down. Cancel the long press timer.
|
||||||
|
SDL_RemoveTimer(m_LongPressTimer);
|
||||||
|
m_LongPressTimer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't reposition for finger down events within the deadzone. This makes double-clicking easier.
|
||||||
|
if (event->type != SDL_FINGERDOWN ||
|
||||||
|
event->timestamp - m_LastTouchUpEvent.timestamp > DOUBLE_TAP_DEAD_ZONE_DELAY ||
|
||||||
|
qSqrt(qPow(event->x - m_LastTouchUpEvent.x, 2) + qPow(event->y - m_LastTouchUpEvent.y, 2)) > DOUBLE_TAP_DEAD_ZONE_DELTA) {
|
||||||
|
// Scale window-relative events to be video-relative and clamp to video region
|
||||||
|
short x = qMin(qMax((int)(event->x * windowWidth), dst.x), dst.x + dst.w);
|
||||||
|
short y = qMin(qMax((int)(event->y * windowHeight), dst.y), dst.y + dst.h);
|
||||||
|
|
||||||
|
// Update the cursor position relative to the video region
|
||||||
|
LiSendMousePositionEvent(x - dst.x, y - dst.y, dst.w, dst.h);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event->type == SDL_FINGERDOWN) {
|
||||||
|
m_LastTouchDownEvent = *event;
|
||||||
|
|
||||||
|
// Start/restart the long press timer
|
||||||
|
SDL_RemoveTimer(m_LongPressTimer);
|
||||||
|
m_LongPressTimer = SDL_AddTimer(LONG_PRESS_ACTIVATION_DELAY,
|
||||||
|
longPressTimerCallback,
|
||||||
|
nullptr);
|
||||||
|
|
||||||
|
// Left button down on finger down
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||||
|
}
|
||||||
|
else if (event->type == SDL_FINGERUP) {
|
||||||
|
m_LastTouchUpEvent = *event;
|
||||||
|
|
||||||
|
// Cancel the long press timer
|
||||||
|
SDL_RemoveTimer(m_LongPressTimer);
|
||||||
|
m_LongPressTimer = 0;
|
||||||
|
|
||||||
|
// Left button up on finger up
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||||
|
|
||||||
|
// Raise right button too in case we triggered a long press gesture
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,595 @@
|
|||||||
|
#include "streaming/session.h"
|
||||||
|
|
||||||
|
#include <Limelight.h>
|
||||||
|
#include <SDL.h>
|
||||||
|
#include "settings/mappingmanager.h"
|
||||||
|
|
||||||
|
#include <QtMath>
|
||||||
|
|
||||||
|
// How long the Start button must be pressed to toggle mouse emulation
|
||||||
|
#define MOUSE_EMULATION_LONG_PRESS_TIME 750
|
||||||
|
|
||||||
|
// How long between polling the gamepad to send virtual mouse input
|
||||||
|
#define MOUSE_EMULATION_POLLING_INTERVAL 50
|
||||||
|
|
||||||
|
// Determines how fast the mouse will move each interval
|
||||||
|
#define MOUSE_EMULATION_MOTION_MULTIPLIER 4
|
||||||
|
|
||||||
|
// Determines the maximum motion amount before allowing movement
|
||||||
|
#define MOUSE_EMULATION_DEADZONE 2
|
||||||
|
|
||||||
|
// Haptic capabilities (in addition to those from SDL_HapticQuery())
|
||||||
|
#define ML_HAPTIC_GC_RUMBLE (1U << 16)
|
||||||
|
#define ML_HAPTIC_SIMPLE_RUMBLE (1U << 17)
|
||||||
|
|
||||||
|
const int SdlInputHandler::k_ButtonMap[] = {
|
||||||
|
A_FLAG, B_FLAG, X_FLAG, Y_FLAG,
|
||||||
|
BACK_FLAG, SPECIAL_FLAG, PLAY_FLAG,
|
||||||
|
LS_CLK_FLAG, RS_CLK_FLAG,
|
||||||
|
LB_FLAG, RB_FLAG,
|
||||||
|
UP_FLAG, DOWN_FLAG, LEFT_FLAG, RIGHT_FLAG
|
||||||
|
};
|
||||||
|
|
||||||
|
GamepadState*
|
||||||
|
SdlInputHandler::findStateForGamepad(SDL_JoystickID id)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_GAMEPADS; i++) {
|
||||||
|
if (m_GamepadState[i].jsId == id) {
|
||||||
|
SDL_assert(!m_MultiController || m_GamepadState[i].index == i);
|
||||||
|
return &m_GamepadState[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This should only happen with > 4 gamepads
|
||||||
|
SDL_assert(SDL_NumJoysticks() > 4);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::sendGamepadState(GamepadState* state)
|
||||||
|
{
|
||||||
|
SDL_assert(m_GamepadMask == 0x1 || m_MultiController);
|
||||||
|
LiSendMultiControllerEvent(state->index,
|
||||||
|
m_GamepadMask,
|
||||||
|
state->buttons,
|
||||||
|
state->lt,
|
||||||
|
state->rt,
|
||||||
|
state->lsX,
|
||||||
|
state->lsY,
|
||||||
|
state->rsX,
|
||||||
|
state->rsY);
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint32 SdlInputHandler::mouseEmulationTimerCallback(Uint32 interval, void *param)
|
||||||
|
{
|
||||||
|
auto gamepad = reinterpret_cast<GamepadState*>(param);
|
||||||
|
|
||||||
|
short rawX;
|
||||||
|
short rawY;
|
||||||
|
|
||||||
|
// Determine which analog stick is currently receiving the strongest input
|
||||||
|
if ((uint32_t)qAbs(gamepad->lsX) + qAbs(gamepad->lsY) > (uint32_t)qAbs(gamepad->rsX) + qAbs(gamepad->rsY)) {
|
||||||
|
rawX = gamepad->lsX;
|
||||||
|
rawY = -gamepad->lsY;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rawX = gamepad->rsX;
|
||||||
|
rawY = -gamepad->rsY;
|
||||||
|
}
|
||||||
|
|
||||||
|
float deltaX;
|
||||||
|
float deltaY;
|
||||||
|
|
||||||
|
// Produce a base vector for mouse movement with increased speed as we deviate further from center
|
||||||
|
deltaX = qPow(rawX / 32766.0f * MOUSE_EMULATION_MOTION_MULTIPLIER, 3);
|
||||||
|
deltaY = qPow(rawY / 32766.0f * MOUSE_EMULATION_MOTION_MULTIPLIER, 3);
|
||||||
|
|
||||||
|
// Enforce deadzones
|
||||||
|
deltaX = qAbs(deltaX) > MOUSE_EMULATION_DEADZONE ? deltaX - MOUSE_EMULATION_DEADZONE : 0;
|
||||||
|
deltaY = qAbs(deltaY) > MOUSE_EMULATION_DEADZONE ? deltaY - MOUSE_EMULATION_DEADZONE : 0;
|
||||||
|
|
||||||
|
if (deltaX != 0 || deltaY != 0) {
|
||||||
|
LiSendMouseMoveEvent((short)deltaX, (short)deltaY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::handleControllerAxisEvent(SDL_ControllerAxisEvent* event)
|
||||||
|
{
|
||||||
|
SDL_JoystickID gameControllerId = event->which;
|
||||||
|
GamepadState* state = findStateForGamepad(gameControllerId);
|
||||||
|
if (state == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Batch all pending axis motion events for this gamepad to save CPU time
|
||||||
|
SDL_Event nextEvent;
|
||||||
|
for (;;) {
|
||||||
|
switch (event->axis)
|
||||||
|
{
|
||||||
|
case SDL_CONTROLLER_AXIS_LEFTX:
|
||||||
|
state->lsX = event->value;
|
||||||
|
break;
|
||||||
|
case SDL_CONTROLLER_AXIS_LEFTY:
|
||||||
|
// Signed values have one more negative value than
|
||||||
|
// positive value, so inverting the sign on -32768
|
||||||
|
// could actually cause the value to overflow and
|
||||||
|
// wrap around to be negative again. Avoid that by
|
||||||
|
// capping the value at 32767.
|
||||||
|
state->lsY = -qMax(event->value, (short)-32767);
|
||||||
|
break;
|
||||||
|
case SDL_CONTROLLER_AXIS_RIGHTX:
|
||||||
|
state->rsX = event->value;
|
||||||
|
break;
|
||||||
|
case SDL_CONTROLLER_AXIS_RIGHTY:
|
||||||
|
state->rsY = -qMax(event->value, (short)-32767);
|
||||||
|
break;
|
||||||
|
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
|
||||||
|
state->lt = (unsigned char)(event->value * 255UL / 32767);
|
||||||
|
break;
|
||||||
|
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
|
||||||
|
state->rt = (unsigned char)(event->value * 255UL / 32767);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unhandled controller axis: %d",
|
||||||
|
event->axis);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for another event to batch with
|
||||||
|
if (SDL_PeepEvents(&nextEvent, 1, SDL_PEEKEVENT, SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERAXISMOTION) <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
event = &nextEvent.caxis;
|
||||||
|
if (event->which != gameControllerId) {
|
||||||
|
// Stop batching if a different gamepad interrupts us
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the next event to batch
|
||||||
|
SDL_PeepEvents(&nextEvent, 1, SDL_GETEVENT, SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERAXISMOTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only send the gamepad state to the host if it's not in mouse emulation mode
|
||||||
|
if (state->mouseEmulationTimer == 0) {
|
||||||
|
sendGamepadState(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* event)
|
||||||
|
{
|
||||||
|
GamepadState* state = findStateForGamepad(event->which);
|
||||||
|
if (state == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event->state == SDL_PRESSED) {
|
||||||
|
state->buttons |= k_ButtonMap[event->button];
|
||||||
|
|
||||||
|
if (event->button == SDL_CONTROLLER_BUTTON_START) {
|
||||||
|
state->lastStartDownTime = SDL_GetTicks();
|
||||||
|
}
|
||||||
|
else if (state->mouseEmulationTimer != 0) {
|
||||||
|
if (event->button == SDL_CONTROLLER_BUTTON_A) {
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||||
|
}
|
||||||
|
else if (event->button == SDL_CONTROLLER_BUTTON_B) {
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
|
||||||
|
}
|
||||||
|
else if (event->button == SDL_CONTROLLER_BUTTON_X) {
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_MIDDLE);
|
||||||
|
}
|
||||||
|
else if (event->button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) {
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X1);
|
||||||
|
}
|
||||||
|
else if (event->button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) {
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X2);
|
||||||
|
}
|
||||||
|
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_UP) {
|
||||||
|
LiSendScrollEvent(1);
|
||||||
|
}
|
||||||
|
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_DOWN) {
|
||||||
|
LiSendScrollEvent(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
state->buttons &= ~k_ButtonMap[event->button];
|
||||||
|
|
||||||
|
if (event->button == SDL_CONTROLLER_BUTTON_START) {
|
||||||
|
if (SDL_GetTicks() - state->lastStartDownTime > MOUSE_EMULATION_LONG_PRESS_TIME) {
|
||||||
|
if (state->mouseEmulationTimer != 0) {
|
||||||
|
SDL_RemoveTimer(state->mouseEmulationTimer);
|
||||||
|
state->mouseEmulationTimer = 0;
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Mouse emulation deactivated");
|
||||||
|
Session::get()->notifyMouseEmulationMode(false);
|
||||||
|
}
|
||||||
|
else if (m_GamepadMouse) {
|
||||||
|
// Send the start button up event to the host, since we won't do it below
|
||||||
|
sendGamepadState(state);
|
||||||
|
|
||||||
|
state->mouseEmulationTimer = SDL_AddTimer(MOUSE_EMULATION_POLLING_INTERVAL, SdlInputHandler::mouseEmulationTimerCallback, state);
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Mouse emulation active");
|
||||||
|
Session::get()->notifyMouseEmulationMode(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (state->mouseEmulationTimer != 0) {
|
||||||
|
if (event->button == SDL_CONTROLLER_BUTTON_A) {
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||||
|
}
|
||||||
|
else if (event->button == SDL_CONTROLLER_BUTTON_B) {
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
|
||||||
|
}
|
||||||
|
else if (event->button == SDL_CONTROLLER_BUTTON_X) {
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_MIDDLE);
|
||||||
|
}
|
||||||
|
else if (event->button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) {
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X1);
|
||||||
|
}
|
||||||
|
else if (event->button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) {
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle Start+Select+L1+R1 as a gamepad quit combo
|
||||||
|
if (state->buttons == (PLAY_FLAG | BACK_FLAG | LB_FLAG | RB_FLAG)) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected quit gamepad button combo");
|
||||||
|
|
||||||
|
// Push a quit event to the main loop
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_QUIT;
|
||||||
|
event.quit.timestamp = SDL_GetTicks();
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
|
||||||
|
// Clear buttons down on this gameapd
|
||||||
|
LiSendMultiControllerEvent(state->index, m_GamepadMask,
|
||||||
|
0, 0, 0, 0, 0, 0, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only send the gamepad state to the host if it's not in mouse emulation mode
|
||||||
|
if (state->mouseEmulationTimer == 0) {
|
||||||
|
sendGamepadState(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* event)
|
||||||
|
{
|
||||||
|
GamepadState* state;
|
||||||
|
|
||||||
|
if (event->type == SDL_CONTROLLERDEVICEADDED) {
|
||||||
|
int i;
|
||||||
|
const char* name;
|
||||||
|
SDL_GameController* controller;
|
||||||
|
const char* mapping;
|
||||||
|
char guidStr[33];
|
||||||
|
uint32_t hapticCaps;
|
||||||
|
|
||||||
|
controller = SDL_GameControllerOpen(event->which);
|
||||||
|
if (controller == NULL) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Failed to open gamepad: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We used to use SDL_GameControllerGetPlayerIndex() here but that
|
||||||
|
// can lead to strange issues due to bugs in Windows where an Xbox
|
||||||
|
// controller will join as player 2, even though no player 1 controller
|
||||||
|
// is connected at all. This pretty much screws any attempt to use
|
||||||
|
// the gamepad in single player games, so just assign them in order from 0.
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
for (; i < MAX_GAMEPADS; i++) {
|
||||||
|
SDL_assert(m_GamepadState[i].controller != controller);
|
||||||
|
if (m_GamepadState[i].controller == NULL) {
|
||||||
|
// Found an empty slot
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == MAX_GAMEPADS) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"No open gamepad slots found!");
|
||||||
|
SDL_GameControllerClose(controller);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = &m_GamepadState[i];
|
||||||
|
if (m_MultiController) {
|
||||||
|
state->index = i;
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 12)
|
||||||
|
// This will change indicators on the controller to show the assigned
|
||||||
|
// player index. For Xbox 360 controllers, that means updating the LED
|
||||||
|
// ring to light up the corresponding quadrant for this player.
|
||||||
|
SDL_GameControllerSetPlayerIndex(controller, state->index);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Always player 1 in single controller mode
|
||||||
|
state->index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
state->controller = controller;
|
||||||
|
state->jsId = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(state->controller));
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 9)
|
||||||
|
// Perform a tiny rumble to see if haptics are supported.
|
||||||
|
// NB: We cannot use zeros for rumble intensity or SDL will not actually call the JS driver
|
||||||
|
// and we'll get a (potentially false) success value returned.
|
||||||
|
hapticCaps = SDL_GameControllerRumble(controller, 1, 1, 1) == 0 ?
|
||||||
|
ML_HAPTIC_GC_RUMBLE : 0;
|
||||||
|
#else
|
||||||
|
state->haptic = SDL_HapticOpenFromJoystick(SDL_GameControllerGetJoystick(state->controller));
|
||||||
|
state->hapticEffectId = -1;
|
||||||
|
state->hapticMethod = GAMEPAD_HAPTIC_METHOD_NONE;
|
||||||
|
if (state->haptic != nullptr) {
|
||||||
|
// Query for supported haptic effects
|
||||||
|
hapticCaps = SDL_HapticQuery(state->haptic);
|
||||||
|
hapticCaps |= SDL_HapticRumbleSupported(state->haptic) ?
|
||||||
|
ML_HAPTIC_SIMPLE_RUMBLE : 0;
|
||||||
|
|
||||||
|
if ((SDL_HapticQuery(state->haptic) & SDL_HAPTIC_LEFTRIGHT) == 0) {
|
||||||
|
if (SDL_HapticRumbleSupported(state->haptic)) {
|
||||||
|
if (SDL_HapticRumbleInit(state->haptic) == 0) {
|
||||||
|
state->hapticMethod = GAMEPAD_HAPTIC_METHOD_SIMPLERUMBLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state->hapticMethod == GAMEPAD_HAPTIC_METHOD_NONE) {
|
||||||
|
SDL_HapticClose(state->haptic);
|
||||||
|
state->haptic = nullptr;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
state->hapticMethod = GAMEPAD_HAPTIC_METHOD_LEFTRIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hapticCaps = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(SDL_GameControllerGetJoystick(state->controller)),
|
||||||
|
guidStr, sizeof(guidStr));
|
||||||
|
mapping = SDL_GameControllerMapping(state->controller);
|
||||||
|
name = SDL_GameControllerName(state->controller);
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Gamepad %d (player %d) is: %s (haptic capabilities: 0x%x) (mapping: %s -> %s)",
|
||||||
|
i,
|
||||||
|
state->index,
|
||||||
|
name != nullptr ? name : "<null>",
|
||||||
|
hapticCaps,
|
||||||
|
guidStr,
|
||||||
|
mapping != nullptr ? mapping : "<null>");
|
||||||
|
if (mapping != nullptr) {
|
||||||
|
SDL_free((void*)mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add this gamepad to the gamepad mask
|
||||||
|
if (m_MultiController) {
|
||||||
|
// NB: Don't assert that it's unset here because we will already
|
||||||
|
// have the mask set for initially attached gamepads to avoid confusing
|
||||||
|
// apps running on the host.
|
||||||
|
m_GamepadMask |= (1 << state->index);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_assert(m_GamepadMask == 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send an empty event to tell the PC we've arrived
|
||||||
|
sendGamepadState(state);
|
||||||
|
}
|
||||||
|
else if (event->type == SDL_CONTROLLERDEVICEREMOVED) {
|
||||||
|
state = findStateForGamepad(event->which);
|
||||||
|
if (state != NULL) {
|
||||||
|
if (state->mouseEmulationTimer != 0) {
|
||||||
|
Session::get()->notifyMouseEmulationMode(false);
|
||||||
|
SDL_RemoveTimer(state->mouseEmulationTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_GameControllerClose(state->controller);
|
||||||
|
|
||||||
|
#if !SDL_VERSION_ATLEAST(2, 0, 9)
|
||||||
|
if (state->haptic != nullptr) {
|
||||||
|
SDL_HapticClose(state->haptic);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Remove this from the gamepad mask in MC-mode
|
||||||
|
if (m_MultiController) {
|
||||||
|
SDL_assert(m_GamepadMask & (1 << state->index));
|
||||||
|
m_GamepadMask &= ~(1 << state->index);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_assert(m_GamepadMask == 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Gamepad %d is gone",
|
||||||
|
state->index);
|
||||||
|
|
||||||
|
// Send a final event to let the PC know this gamepad is gone
|
||||||
|
LiSendMultiControllerEvent(state->index, m_GamepadMask,
|
||||||
|
0, 0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
// Clear all remaining state from this slot
|
||||||
|
SDL_memset(state, 0, sizeof(*state));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::handleJoystickArrivalEvent(SDL_JoyDeviceEvent* event)
|
||||||
|
{
|
||||||
|
SDL_assert(event->type == SDL_JOYDEVICEADDED);
|
||||||
|
|
||||||
|
if (!SDL_IsGameController(event->which)) {
|
||||||
|
char guidStr[33];
|
||||||
|
SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(event->which),
|
||||||
|
guidStr, sizeof(guidStr));
|
||||||
|
const char* name = SDL_JoystickNameForIndex(event->which);
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Joystick discovered with no mapping: %s %s",
|
||||||
|
name ? name : "<UNKNOWN>",
|
||||||
|
guidStr);
|
||||||
|
SDL_Joystick* joy = SDL_JoystickOpen(event->which);
|
||||||
|
if (joy != nullptr) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Number of axes: %d | Number of buttons: %d | Number of hats: %d",
|
||||||
|
SDL_JoystickNumAxes(joy), SDL_JoystickNumButtons(joy),
|
||||||
|
SDL_JoystickNumHats(joy));
|
||||||
|
SDL_JoystickClose(joy);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unable to open joystick for query: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::rumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsigned short highFreqMotor)
|
||||||
|
{
|
||||||
|
// Make sure the controller number is within our supported count
|
||||||
|
if (controllerNumber >= MAX_GAMEPADS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 9)
|
||||||
|
if (m_GamepadState[controllerNumber].controller != nullptr) {
|
||||||
|
SDL_GameControllerRumble(m_GamepadState[controllerNumber].controller, lowFreqMotor, highFreqMotor, 30000);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// Check if the controller supports haptics (and if the controller exists at all)
|
||||||
|
SDL_Haptic* haptic = m_GamepadState[controllerNumber].haptic;
|
||||||
|
if (haptic == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop the last effect we played
|
||||||
|
if (m_GamepadState[controllerNumber].hapticMethod == GAMEPAD_HAPTIC_METHOD_LEFTRIGHT) {
|
||||||
|
if (m_GamepadState[controllerNumber].hapticEffectId >= 0) {
|
||||||
|
SDL_HapticDestroyEffect(haptic, m_GamepadState[controllerNumber].hapticEffectId);
|
||||||
|
}
|
||||||
|
} else if (m_GamepadState[controllerNumber].hapticMethod == GAMEPAD_HAPTIC_METHOD_SIMPLERUMBLE) {
|
||||||
|
SDL_HapticRumbleStop(haptic);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this callback is telling us to stop both motors, don't bother queuing a new effect
|
||||||
|
if (lowFreqMotor == 0 && highFreqMotor == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_GamepadState[controllerNumber].hapticMethod == GAMEPAD_HAPTIC_METHOD_LEFTRIGHT) {
|
||||||
|
SDL_HapticEffect effect;
|
||||||
|
SDL_memset(&effect, 0, sizeof(effect));
|
||||||
|
effect.type = SDL_HAPTIC_LEFTRIGHT;
|
||||||
|
|
||||||
|
// The effect should last until we are instructed to stop or change it
|
||||||
|
effect.leftright.length = SDL_HAPTIC_INFINITY;
|
||||||
|
|
||||||
|
// SDL haptics range from 0-32767 but XInput uses 0-65535, so divide by 2 to correct for SDL's scaling
|
||||||
|
effect.leftright.large_magnitude = lowFreqMotor / 2;
|
||||||
|
effect.leftright.small_magnitude = highFreqMotor / 2;
|
||||||
|
|
||||||
|
// Play the new effect
|
||||||
|
m_GamepadState[controllerNumber].hapticEffectId = SDL_HapticNewEffect(haptic, &effect);
|
||||||
|
if (m_GamepadState[controllerNumber].hapticEffectId >= 0) {
|
||||||
|
SDL_HapticRunEffect(haptic, m_GamepadState[controllerNumber].hapticEffectId, 1);
|
||||||
|
}
|
||||||
|
} else if (m_GamepadState[controllerNumber].hapticMethod == GAMEPAD_HAPTIC_METHOD_SIMPLERUMBLE) {
|
||||||
|
SDL_HapticRumblePlay(haptic,
|
||||||
|
std::min(1.0, (GAMEPAD_HAPTIC_SIMPLE_HIFREQ_MOTOR_WEIGHT*highFreqMotor +
|
||||||
|
GAMEPAD_HAPTIC_SIMPLE_LOWFREQ_MOTOR_WEIGHT*lowFreqMotor) / 65535.0),
|
||||||
|
SDL_HAPTIC_INFINITY);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SdlInputHandler::getUnmappedGamepads()
|
||||||
|
{
|
||||||
|
QString ret;
|
||||||
|
|
||||||
|
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) != 0) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) failed: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
|
MappingManager mappingManager;
|
||||||
|
mappingManager.applyMappings();
|
||||||
|
|
||||||
|
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||||
|
if (!SDL_IsGameController(i)) {
|
||||||
|
char guidStr[33];
|
||||||
|
SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(i),
|
||||||
|
guidStr, sizeof(guidStr));
|
||||||
|
const char* name = SDL_JoystickNameForIndex(i);
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unmapped joystick: %s %s",
|
||||||
|
name ? name : "<UNKNOWN>",
|
||||||
|
guidStr);
|
||||||
|
SDL_Joystick* joy = SDL_JoystickOpen(i);
|
||||||
|
if (joy != nullptr) {
|
||||||
|
int numButtons = SDL_JoystickNumButtons(joy);
|
||||||
|
int numHats = SDL_JoystickNumHats(joy);
|
||||||
|
int numAxes = SDL_JoystickNumAxes(joy);
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Number of axes: %d | Number of buttons: %d | Number of hats: %d",
|
||||||
|
numAxes, numButtons, numHats);
|
||||||
|
|
||||||
|
if ((numAxes >= 4 && numAxes <= 8) && numButtons >= 8 && numHats <= 1) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Joystick likely to be an unmapped game controller");
|
||||||
|
if (!ret.isEmpty()) {
|
||||||
|
ret += ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
ret += name;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_JoystickClose(joy);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unable to open joystick for query: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SdlInputHandler::getAttachedGamepadMask()
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
int mask;
|
||||||
|
|
||||||
|
if (!m_MultiController) {
|
||||||
|
// Player 1 is always present in non-MC mode
|
||||||
|
return 0x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
count = mask = 0;
|
||||||
|
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||||
|
if (SDL_IsGameController(i)) {
|
||||||
|
mask |= (1 << count++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
#include <Limelight.h>
|
||||||
|
#include <SDL.h>
|
||||||
|
#include "streaming/session.h"
|
||||||
|
#include "settings/mappingmanager.h"
|
||||||
|
#include "path.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#define MOUSE_POLLING_INTERVAL 5
|
||||||
|
|
||||||
|
SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int streamWidth, int streamHeight)
|
||||||
|
: m_MultiController(prefs.multiController),
|
||||||
|
m_GamepadMouse(prefs.gamepadMouse),
|
||||||
|
m_MouseMoveTimer(0),
|
||||||
|
m_FakeCaptureActive(false),
|
||||||
|
m_LongPressTimer(0),
|
||||||
|
m_StreamWidth(streamWidth),
|
||||||
|
m_StreamHeight(streamHeight),
|
||||||
|
m_AbsoluteMouseMode(prefs.absoluteMouseMode),
|
||||||
|
m_AbsoluteTouchMode(prefs.absoluteTouchMode),
|
||||||
|
m_PendingMouseLeaveButtonUp(0),
|
||||||
|
m_LeftButtonReleaseTimer(0),
|
||||||
|
m_RightButtonReleaseTimer(0),
|
||||||
|
m_DragTimer(0),
|
||||||
|
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");
|
||||||
|
|
||||||
|
// If absolute mouse mode is enabled, use relative mode warp (which
|
||||||
|
// is via normal motion events that are influenced by mouse acceleration).
|
||||||
|
// Otherwise, we'll use raw input capture which is straight from the device
|
||||||
|
// without modification by the OS.
|
||||||
|
SDL_SetHintWithPriority(SDL_HINT_MOUSE_RELATIVE_MODE_WARP,
|
||||||
|
prefs.absoluteMouseMode ? "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
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// We must initialize joystick explicitly before gamecontroller in order
|
||||||
|
// to ensure we receive gamecontroller attach events for gamepads where
|
||||||
|
// SDL doesn't have a built-in mapping. By starting joystick first, we
|
||||||
|
// can allow mapping manager to update the mappings before GC attach
|
||||||
|
// events are generated.
|
||||||
|
SDL_assert(!SDL_WasInit(SDL_INIT_JOYSTICK));
|
||||||
|
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != 0) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"SDL_InitSubSystem(SDL_INIT_JOYSTICK) failed: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
|
MappingManager mappingManager;
|
||||||
|
mappingManager.applyMappings();
|
||||||
|
|
||||||
|
// Flush gamepad arrival and departure events which may be queued before
|
||||||
|
// starting the gamecontroller subsystem again. This prevents us from
|
||||||
|
// receiving duplicate arrival and departure events for the same gamepad.
|
||||||
|
SDL_FlushEvent(SDL_CONTROLLERDEVICEADDED);
|
||||||
|
SDL_FlushEvent(SDL_CONTROLLERDEVICEREMOVED);
|
||||||
|
|
||||||
|
// We need to reinit this each time, since you only get
|
||||||
|
// an initial set of gamepad arrival events once per init.
|
||||||
|
SDL_assert(!SDL_WasInit(SDL_INIT_GAMECONTROLLER));
|
||||||
|
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) != 0) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) failed: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !SDL_VERSION_ATLEAST(2, 0, 9)
|
||||||
|
SDL_assert(!SDL_WasInit(SDL_INIT_HAPTIC));
|
||||||
|
if (SDL_InitSubSystem(SDL_INIT_HAPTIC) != 0) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"SDL_InitSubSystem(SDL_INIT_HAPTIC) failed: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Initialize the gamepad mask with currently attached gamepads to avoid
|
||||||
|
// causing gamepads to unexpectedly disappear and reappear on the host
|
||||||
|
// during stream startup as we detect currently attached gamepads one at a time.
|
||||||
|
m_GamepadMask = getAttachedGamepadMask();
|
||||||
|
|
||||||
|
SDL_zero(m_GamepadState);
|
||||||
|
SDL_zero(m_LastTouchDownEvent);
|
||||||
|
SDL_zero(m_LastTouchUpEvent);
|
||||||
|
SDL_zero(m_TouchDownEvent);
|
||||||
|
|
||||||
|
SDL_AtomicSet(&m_MouseDeltaX, 0);
|
||||||
|
SDL_AtomicSet(&m_MouseDeltaY, 0);
|
||||||
|
|
||||||
|
Uint32 pollingInterval = QString(qgetenv("MOUSE_POLLING_INTERVAL")).toUInt();
|
||||||
|
if (pollingInterval == 0) {
|
||||||
|
pollingInterval = MOUSE_POLLING_INTERVAL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Using custom mouse polling interval: %u ms",
|
||||||
|
pollingInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_MouseMoveTimer = SDL_AddTimer(pollingInterval, SdlInputHandler::mouseMoveTimerCallback, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
SdlInputHandler::~SdlInputHandler()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < MAX_GAMEPADS; i++) {
|
||||||
|
if (m_GamepadState[i].mouseEmulationTimer != 0) {
|
||||||
|
Session::get()->notifyMouseEmulationMode(false);
|
||||||
|
SDL_RemoveTimer(m_GamepadState[i].mouseEmulationTimer);
|
||||||
|
}
|
||||||
|
#if !SDL_VERSION_ATLEAST(2, 0, 9)
|
||||||
|
if (m_GamepadState[i].haptic != nullptr) {
|
||||||
|
SDL_HapticClose(m_GamepadState[i].haptic);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (m_GamepadState[i].controller != nullptr) {
|
||||||
|
SDL_GameControllerClose(m_GamepadState[i].controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_RemoveTimer(m_MouseMoveTimer);
|
||||||
|
SDL_RemoveTimer(m_LongPressTimer);
|
||||||
|
SDL_RemoveTimer(m_LeftButtonReleaseTimer);
|
||||||
|
SDL_RemoveTimer(m_RightButtonReleaseTimer);
|
||||||
|
SDL_RemoveTimer(m_DragTimer);
|
||||||
|
|
||||||
|
#if !SDL_VERSION_ATLEAST(2, 0, 9)
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_HAPTIC);
|
||||||
|
SDL_assert(!SDL_WasInit(SDL_INIT_HAPTIC));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||||
|
SDL_assert(!SDL_WasInit(SDL_INIT_GAMECONTROLLER));
|
||||||
|
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||||
|
SDL_assert(!SDL_WasInit(SDL_INIT_JOYSTICK));
|
||||||
|
|
||||||
|
// Return background event handling to off
|
||||||
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
|
||||||
|
|
||||||
|
#ifdef STEAM_LINK
|
||||||
|
// Hide SDL's cursor on Steam Link after quitting the stream.
|
||||||
|
// FIXME: We should also do this for other situations where SDL
|
||||||
|
// and Qt will draw their own mouse cursors like KMSDRM or RPi
|
||||||
|
// video backends.
|
||||||
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::setWindow(SDL_Window *window)
|
||||||
|
{
|
||||||
|
m_Window = window;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::raiseAllKeys()
|
||||||
|
{
|
||||||
|
if (m_KeysDown.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Raising %d keys",
|
||||||
|
m_KeysDown.count());
|
||||||
|
|
||||||
|
for (auto keyDown : m_KeysDown) {
|
||||||
|
LiSendKeyboardEvent(keyDown, KEY_ACTION_UP, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_KeysDown.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::notifyMouseLeave()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
// SDL on Windows doesn't send the mouse button up until the mouse re-enters the window
|
||||||
|
// after leaving it. This breaks some of the Aero snap gestures, so we'll fake it here.
|
||||||
|
if (m_AbsoluteMouseMode && isCaptureActive()) {
|
||||||
|
// NB: Not using SDL_GetGlobalMouseState() because we want our state not the system's
|
||||||
|
Uint32 mouseState = SDL_GetMouseState(nullptr, nullptr);
|
||||||
|
for (Uint32 button = SDL_BUTTON_LEFT; button <= SDL_BUTTON_X2; button++) {
|
||||||
|
if (mouseState & SDL_BUTTON(button)) {
|
||||||
|
m_PendingMouseLeaveButtonUp = button;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::notifyFocusLost()
|
||||||
|
{
|
||||||
|
// Release mouse cursor when another window is activated (e.g. by using ALT+TAB).
|
||||||
|
// This lets user to interact with our window's title bar and with the buttons in it.
|
||||||
|
// Doing this while the window is full-screen breaks the transition out of FS
|
||||||
|
// (desktop and exclusive), so we must check for that before releasing mouse capture.
|
||||||
|
if (!(SDL_GetWindowFlags(m_Window) & SDL_WINDOW_FULLSCREEN) && !m_AbsoluteMouseMode) {
|
||||||
|
setCaptureActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Raise all keys that are currently pressed. If we don't do this, certain keys
|
||||||
|
// used in shortcuts that cause focus loss (such as Alt+Tab) may get stuck down.
|
||||||
|
raiseAllKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SdlInputHandler::isCaptureActive()
|
||||||
|
{
|
||||||
|
if (SDL_GetRelativeMouseMode()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some platforms don't support SDL_SetRelativeMouseMode
|
||||||
|
return m_FakeCaptureActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
SDL_SetWindowGrab(m_Window, SDL_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_AbsoluteMouseMode) {
|
||||||
|
// If our window is occluded when mouse is captured, the mouse may
|
||||||
|
// get stuck on top of the occluding window and not be properly
|
||||||
|
// captured. We can avoid this by raising our window before we
|
||||||
|
// capture the mouse.
|
||||||
|
SDL_RaiseWindow(m_Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're in relative mode, try to activate SDL's relative mouse mode
|
||||||
|
if (m_AbsoluteMouseMode || SDL_SetRelativeMouseMode(SDL_TRUE) < 0) {
|
||||||
|
// Relative mouse mode didn't work or was disabled, so we'll just hide the cursor
|
||||||
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
m_FakeCaptureActive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (m_FakeCaptureActive) {
|
||||||
|
// Display the cursor again
|
||||||
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
|
m_FakeCaptureActive = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow the cursor to leave the bounds of our window again.
|
||||||
|
SDL_SetWindowGrab(m_Window, SDL_FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::handleTouchFingerEvent(SDL_TouchFingerEvent* event)
|
||||||
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 10)
|
||||||
|
if (SDL_GetTouchDeviceType(event->touchId) != SDL_TOUCH_DEVICE_DIRECT) {
|
||||||
|
// Ignore anything that isn't a touchscreen. We may get callbacks
|
||||||
|
// for trackpads, but we want to handle those in the mouse path.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#elif defined(Q_OS_DARWIN)
|
||||||
|
// SDL2 sends touch events from trackpads by default on
|
||||||
|
// macOS. This totally screws our actual mouse handling,
|
||||||
|
// so we must explicitly ignore touch events on macOS
|
||||||
|
// until SDL 2.0.10 where we have SDL_GetTouchDeviceType()
|
||||||
|
// to tell them apart.
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (m_AbsoluteTouchMode) {
|
||||||
|
handleAbsoluteFingerEvent(event);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
handleRelativeFingerEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,6 +43,8 @@ public:
|
|||||||
|
|
||||||
~SdlInputHandler();
|
~SdlInputHandler();
|
||||||
|
|
||||||
|
void setWindow(SDL_Window* window);
|
||||||
|
|
||||||
void handleKeyEvent(SDL_KeyboardEvent* event);
|
void handleKeyEvent(SDL_KeyboardEvent* event);
|
||||||
|
|
||||||
void handleMouseButtonEvent(SDL_MouseButtonEvent* event);
|
void handleMouseButtonEvent(SDL_MouseButtonEvent* event);
|
||||||
@@ -67,6 +69,10 @@ public:
|
|||||||
|
|
||||||
void raiseAllKeys();
|
void raiseAllKeys();
|
||||||
|
|
||||||
|
void notifyMouseLeave();
|
||||||
|
|
||||||
|
void notifyFocusLost();
|
||||||
|
|
||||||
bool isCaptureActive();
|
bool isCaptureActive();
|
||||||
|
|
||||||
void setCaptureActive(bool active);
|
void setCaptureActive(bool active);
|
||||||
@@ -80,6 +86,19 @@ private:
|
|||||||
|
|
||||||
void sendGamepadState(GamepadState* state);
|
void sendGamepadState(GamepadState* state);
|
||||||
|
|
||||||
|
void handleAbsoluteFingerEvent(SDL_TouchFingerEvent* event);
|
||||||
|
|
||||||
|
void handleRelativeFingerEvent(SDL_TouchFingerEvent* event);
|
||||||
|
|
||||||
|
static
|
||||||
|
Uint32 longPressTimerCallback(Uint32 interval, void* param);
|
||||||
|
|
||||||
|
static
|
||||||
|
Uint32 mouseMoveTimerCallback(Uint32 interval, void* param);
|
||||||
|
|
||||||
|
static
|
||||||
|
Uint32 mouseEmulationTimerCallback(Uint32 interval, void* param);
|
||||||
|
|
||||||
static
|
static
|
||||||
Uint32 releaseLeftButtonTimerCallback(Uint32 interval, void* param);
|
Uint32 releaseLeftButtonTimerCallback(Uint32 interval, void* param);
|
||||||
|
|
||||||
@@ -89,12 +108,7 @@ private:
|
|||||||
static
|
static
|
||||||
Uint32 dragTimerCallback(Uint32 interval, void* param);
|
Uint32 dragTimerCallback(Uint32 interval, void* param);
|
||||||
|
|
||||||
static
|
SDL_Window* m_Window;
|
||||||
Uint32 mouseMoveTimerCallback(Uint32 interval, void* param);
|
|
||||||
|
|
||||||
static
|
|
||||||
Uint32 mouseEmulationTimerCallback(Uint32 interval, void* param);
|
|
||||||
|
|
||||||
bool m_MultiController;
|
bool m_MultiController;
|
||||||
bool m_GamepadMouse;
|
bool m_GamepadMouse;
|
||||||
SDL_TimerID m_MouseMoveTimer;
|
SDL_TimerID m_MouseMoveTimer;
|
||||||
@@ -105,15 +119,21 @@ private:
|
|||||||
QSet<short> m_KeysDown;
|
QSet<short> m_KeysDown;
|
||||||
bool m_FakeCaptureActive;
|
bool m_FakeCaptureActive;
|
||||||
|
|
||||||
|
SDL_TouchFingerEvent m_LastTouchDownEvent;
|
||||||
|
SDL_TouchFingerEvent m_LastTouchUpEvent;
|
||||||
|
SDL_TimerID m_LongPressTimer;
|
||||||
|
int m_StreamWidth;
|
||||||
|
int m_StreamHeight;
|
||||||
|
bool m_AbsoluteMouseMode;
|
||||||
|
bool m_AbsoluteTouchMode;
|
||||||
|
Uint32 m_PendingMouseLeaveButtonUp;
|
||||||
|
|
||||||
SDL_TouchFingerEvent m_TouchDownEvent[MAX_FINGERS];
|
SDL_TouchFingerEvent m_TouchDownEvent[MAX_FINGERS];
|
||||||
float m_CumulativeDelta[MAX_FINGERS];
|
|
||||||
SDL_TimerID m_LeftButtonReleaseTimer;
|
SDL_TimerID m_LeftButtonReleaseTimer;
|
||||||
SDL_TimerID m_RightButtonReleaseTimer;
|
SDL_TimerID m_RightButtonReleaseTimer;
|
||||||
SDL_TimerID m_DragTimer;
|
SDL_TimerID m_DragTimer;
|
||||||
char m_DragButton;
|
char m_DragButton;
|
||||||
int m_NumFingersDown;
|
int m_NumFingersDown;
|
||||||
int m_StreamWidth;
|
|
||||||
int m_StreamHeight;
|
|
||||||
|
|
||||||
static const int k_ButtonMap[];
|
static const int k_ButtonMap[];
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,420 @@
|
|||||||
|
#include "streaming/session.h"
|
||||||
|
|
||||||
|
#include <Limelight.h>
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
// These are real Windows VK_* codes
|
||||||
|
#ifndef VK_F1
|
||||||
|
#define VK_F1 0x70
|
||||||
|
#define VK_F13 0x7C
|
||||||
|
#define VK_NUMPAD0 0x60
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
|
||||||
|
{
|
||||||
|
short keyCode;
|
||||||
|
char modifiers;
|
||||||
|
|
||||||
|
// Check for our special key combos
|
||||||
|
if ((event->state == SDL_PRESSED) &&
|
||||||
|
(event->keysym.mod & KMOD_CTRL) &&
|
||||||
|
(event->keysym.mod & KMOD_ALT) &&
|
||||||
|
(event->keysym.mod & KMOD_SHIFT)) {
|
||||||
|
// First we test the SDLK combos for matches,
|
||||||
|
// that way we ensure that latin keyboard users
|
||||||
|
// can match to the key they see on their keyboards.
|
||||||
|
// If nothing matches that, we'll then go on to
|
||||||
|
// checking scancodes so non-latin keyboard users
|
||||||
|
// can have working hotkeys (though possibly in
|
||||||
|
// odd positions). We must do all SDLK tests before
|
||||||
|
// any scancode tests to avoid issues in cases
|
||||||
|
// where the SDLK for one shortcut collides with
|
||||||
|
// the scancode of another.
|
||||||
|
|
||||||
|
// Check for quit combo (Ctrl+Alt+Shift+Q)
|
||||||
|
if (event->keysym.sym == SDLK_q) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected quit key combo (SDLK)");
|
||||||
|
|
||||||
|
// Push a quit event to the main loop
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_QUIT;
|
||||||
|
event.quit.timestamp = SDL_GetTicks();
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check for the unbind combo (Ctrl+Alt+Shift+Z) unless on EGLFS which has no window manager
|
||||||
|
else if (event->keysym.sym == SDLK_z && QGuiApplication::platformName() != "eglfs") {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected mouse capture toggle combo (SDLK)");
|
||||||
|
|
||||||
|
// Stop handling future input
|
||||||
|
setCaptureActive(!isCaptureActive());
|
||||||
|
|
||||||
|
// Force raise all keys to ensure they aren't stuck,
|
||||||
|
// since we won't get their key up events.
|
||||||
|
raiseAllKeys();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check for the mouse mode combo (Ctrl+Alt+Shift+M) unless on EGLFS which has no window manager
|
||||||
|
else if (event->keysym.sym == SDLK_m && QGuiApplication::platformName() != "eglfs") {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected mouse mode toggle combo (SDLK)");
|
||||||
|
|
||||||
|
// Uncapture input
|
||||||
|
setCaptureActive(false);
|
||||||
|
|
||||||
|
// Toggle mouse mode
|
||||||
|
m_AbsoluteMouseMode = !m_AbsoluteMouseMode;
|
||||||
|
|
||||||
|
// Recapture input
|
||||||
|
setCaptureActive(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (event->keysym.sym == SDLK_x && QGuiApplication::platformName() != "eglfs") {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected full-screen toggle combo (SDLK)");
|
||||||
|
Session::s_ActiveSession->toggleFullscreen();
|
||||||
|
|
||||||
|
// Force raise all keys just be safe across this full-screen/windowed
|
||||||
|
// transition just in case key events get lost.
|
||||||
|
raiseAllKeys();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check for overlay combo (Ctrl+Alt+Shift+S)
|
||||||
|
else if (event->keysym.sym == SDLK_s) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected stats toggle combo (SDLK)");
|
||||||
|
|
||||||
|
// Toggle the stats overlay
|
||||||
|
Session::get()->getOverlayManager().setOverlayState(Overlay::OverlayDebug,
|
||||||
|
!Session::get()->getOverlayManager().isOverlayEnabled(Overlay::OverlayDebug));
|
||||||
|
|
||||||
|
// Force raise all keys just be safe across this full-screen/windowed
|
||||||
|
// transition just in case key events get lost.
|
||||||
|
raiseAllKeys();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check for quit combo (Ctrl+Alt+Shift+Q)
|
||||||
|
else if (event->keysym.scancode == SDL_SCANCODE_Q) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected quit key combo (scancode)");
|
||||||
|
|
||||||
|
// Push a quit event to the main loop
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_QUIT;
|
||||||
|
event.quit.timestamp = SDL_GetTicks();
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check for the unbind combo (Ctrl+Alt+Shift+Z)
|
||||||
|
else if (event->keysym.scancode == SDL_SCANCODE_Z && QGuiApplication::platformName() != "eglfs") {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected mouse capture toggle combo (scancode)");
|
||||||
|
|
||||||
|
// Stop handling future input
|
||||||
|
setCaptureActive(!isCaptureActive());
|
||||||
|
|
||||||
|
// Force raise all keys to ensure they aren't stuck,
|
||||||
|
// since we won't get their key up events.
|
||||||
|
raiseAllKeys();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check for the full-screen combo (Ctrl+Alt+Shift+X) unless on EGLFS which has no window manager
|
||||||
|
else if (event->keysym.scancode == SDL_SCANCODE_X && QGuiApplication::platformName() != "eglfs") {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected full-screen toggle combo (scancode)");
|
||||||
|
Session::s_ActiveSession->toggleFullscreen();
|
||||||
|
|
||||||
|
// Force raise all keys just be safe across this full-screen/windowed
|
||||||
|
// transition just in case key events get lost.
|
||||||
|
raiseAllKeys();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check for the mouse mode toggle combo (Ctrl+Alt+Shift+M) unless on EGLFS which has no window manager
|
||||||
|
else if (event->keysym.scancode == SDL_SCANCODE_M && QGuiApplication::platformName() != "eglfs") {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected mouse mode toggle combo (scancode)");
|
||||||
|
|
||||||
|
// Uncapture input
|
||||||
|
setCaptureActive(false);
|
||||||
|
|
||||||
|
// Toggle mouse mode
|
||||||
|
m_AbsoluteMouseMode = !m_AbsoluteMouseMode;
|
||||||
|
|
||||||
|
// Recapture input
|
||||||
|
setCaptureActive(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (event->keysym.scancode == SDL_SCANCODE_S) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Detected stats toggle combo (scancode)");
|
||||||
|
|
||||||
|
// Toggle the stats overlay
|
||||||
|
Session::get()->getOverlayManager().setOverlayState(Overlay::OverlayDebug,
|
||||||
|
!Session::get()->getOverlayManager().isOverlayEnabled(Overlay::OverlayDebug));
|
||||||
|
|
||||||
|
// Force raise all keys just be safe across this full-screen/windowed
|
||||||
|
// transition just in case key events get lost.
|
||||||
|
raiseAllKeys();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event->repeat) {
|
||||||
|
// Ignore repeat key down events
|
||||||
|
SDL_assert(event->state == SDL_PRESSED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set modifier flags
|
||||||
|
modifiers = 0;
|
||||||
|
if (event->keysym.mod & KMOD_CTRL) {
|
||||||
|
modifiers |= MODIFIER_CTRL;
|
||||||
|
}
|
||||||
|
if (event->keysym.mod & KMOD_ALT) {
|
||||||
|
modifiers |= MODIFIER_ALT;
|
||||||
|
}
|
||||||
|
if (event->keysym.mod & KMOD_SHIFT) {
|
||||||
|
modifiers |= MODIFIER_SHIFT;
|
||||||
|
}
|
||||||
|
#ifdef ENABLE_META
|
||||||
|
if (event->keysym.mod & KMOD_GUI) {
|
||||||
|
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
|
||||||
|
// a QWERTY layout to work.
|
||||||
|
if (event->keysym.scancode >= SDL_SCANCODE_1 && event->keysym.scancode <= SDL_SCANCODE_9) {
|
||||||
|
// SDL defines SDL_SCANCODE_0 > SDL_SCANCODE_9, so we need to handle that manually
|
||||||
|
keyCode = (event->keysym.scancode - SDL_SCANCODE_1) + VK_0 + 1;
|
||||||
|
}
|
||||||
|
else if (event->keysym.scancode >= SDL_SCANCODE_A && event->keysym.scancode <= SDL_SCANCODE_Z) {
|
||||||
|
keyCode = (event->keysym.scancode - SDL_SCANCODE_A) + VK_A;
|
||||||
|
}
|
||||||
|
else if (event->keysym.scancode >= SDL_SCANCODE_F1 && event->keysym.scancode <= SDL_SCANCODE_F12) {
|
||||||
|
keyCode = (event->keysym.scancode - SDL_SCANCODE_F1) + VK_F1;
|
||||||
|
}
|
||||||
|
else if (event->keysym.scancode >= SDL_SCANCODE_F13 && event->keysym.scancode <= SDL_SCANCODE_F24) {
|
||||||
|
keyCode = (event->keysym.scancode - SDL_SCANCODE_F13) + VK_F13;
|
||||||
|
}
|
||||||
|
else if (event->keysym.scancode >= SDL_SCANCODE_KP_1 && event->keysym.scancode <= SDL_SCANCODE_KP_9) {
|
||||||
|
// SDL defines SDL_SCANCODE_KP_0 > SDL_SCANCODE_KP_9, so we need to handle that manually
|
||||||
|
keyCode = (event->keysym.scancode - SDL_SCANCODE_KP_1) + VK_NUMPAD0 + 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
switch (event->keysym.scancode) {
|
||||||
|
case SDL_SCANCODE_BACKSPACE:
|
||||||
|
keyCode = 0x08;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_TAB:
|
||||||
|
keyCode = 0x09;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_CLEAR:
|
||||||
|
keyCode = 0x0C;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_KP_ENTER: // FIXME: Is this correct?
|
||||||
|
case SDL_SCANCODE_RETURN:
|
||||||
|
keyCode = 0x0D;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_PAUSE:
|
||||||
|
keyCode = 0x13;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_CAPSLOCK:
|
||||||
|
keyCode = 0x14;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_ESCAPE:
|
||||||
|
keyCode = 0x1B;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_SPACE:
|
||||||
|
keyCode = 0x20;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_PAGEUP:
|
||||||
|
keyCode = 0x21;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_PAGEDOWN:
|
||||||
|
keyCode = 0x22;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_END:
|
||||||
|
keyCode = 0x23;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_HOME:
|
||||||
|
keyCode = 0x24;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_LEFT:
|
||||||
|
keyCode = 0x25;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_UP:
|
||||||
|
keyCode = 0x26;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_RIGHT:
|
||||||
|
keyCode = 0x27;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_DOWN:
|
||||||
|
keyCode = 0x28;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_SELECT:
|
||||||
|
keyCode = 0x29;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_EXECUTE:
|
||||||
|
keyCode = 0x2B;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_PRINTSCREEN:
|
||||||
|
keyCode = 0x2C;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_INSERT:
|
||||||
|
keyCode = 0x2D;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_DELETE:
|
||||||
|
keyCode = 0x2E;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_HELP:
|
||||||
|
keyCode = 0x2F;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_KP_0:
|
||||||
|
// See comment above about why we only handle SDL_SCANCODE_KP_0 here
|
||||||
|
keyCode = VK_NUMPAD0;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_0:
|
||||||
|
// See comment above about why we only handle SDL_SCANCODE_0 here
|
||||||
|
keyCode = VK_0;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_KP_MULTIPLY:
|
||||||
|
keyCode = 0x6A;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_KP_PLUS:
|
||||||
|
keyCode = 0x6B;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_KP_COMMA:
|
||||||
|
keyCode = 0x6C;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_KP_MINUS:
|
||||||
|
keyCode = 0x6D;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_KP_PERIOD:
|
||||||
|
keyCode = 0x6E;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_KP_DIVIDE:
|
||||||
|
keyCode = 0x6F;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_NUMLOCKCLEAR:
|
||||||
|
keyCode = 0x90;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_SCROLLLOCK:
|
||||||
|
keyCode = 0x91;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_LSHIFT:
|
||||||
|
keyCode = 0xA0;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_RSHIFT:
|
||||||
|
keyCode = 0xA1;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_LCTRL:
|
||||||
|
keyCode = 0xA2;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_RCTRL:
|
||||||
|
keyCode = 0xA3;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_LALT:
|
||||||
|
keyCode = 0xA4;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_RALT:
|
||||||
|
keyCode = 0xA5;
|
||||||
|
break;
|
||||||
|
#ifdef ENABLE_META
|
||||||
|
case SDL_SCANCODE_LGUI:
|
||||||
|
keyCode = 0x5B;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_RGUI:
|
||||||
|
keyCode = 0x5C;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case SDL_SCANCODE_AC_BACK:
|
||||||
|
keyCode = 0xA6;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_AC_FORWARD:
|
||||||
|
keyCode = 0xA7;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_AC_REFRESH:
|
||||||
|
keyCode = 0xA8;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_AC_STOP:
|
||||||
|
keyCode = 0xA9;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_AC_SEARCH:
|
||||||
|
keyCode = 0xAA;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_AC_BOOKMARKS:
|
||||||
|
keyCode = 0xAB;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_AC_HOME:
|
||||||
|
keyCode = 0xAC;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_SEMICOLON:
|
||||||
|
keyCode = 0xBA;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_EQUALS:
|
||||||
|
keyCode = 0xBB;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_COMMA:
|
||||||
|
keyCode = 0xBC;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_MINUS:
|
||||||
|
keyCode = 0xBD;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_PERIOD:
|
||||||
|
keyCode = 0xBE;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_SLASH:
|
||||||
|
keyCode = 0xBF;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_GRAVE:
|
||||||
|
keyCode = 0xC0;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_LEFTBRACKET:
|
||||||
|
keyCode = 0xDB;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_BACKSLASH:
|
||||||
|
keyCode = 0xDC;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_RIGHTBRACKET:
|
||||||
|
keyCode = 0xDD;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_APOSTROPHE:
|
||||||
|
keyCode = 0xDE;
|
||||||
|
break;
|
||||||
|
case SDL_SCANCODE_NONUSBACKSLASH:
|
||||||
|
keyCode = 0xE2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unhandled button event: %d",
|
||||||
|
event->keysym.scancode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track the key state so we always know which keys are down
|
||||||
|
if (event->state == SDL_PRESSED) {
|
||||||
|
m_KeysDown.insert(keyCode);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_KeysDown.remove(keyCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
LiSendKeyboardEvent(keyCode,
|
||||||
|
event->state == SDL_PRESSED ?
|
||||||
|
KEY_ACTION_DOWN : KEY_ACTION_UP,
|
||||||
|
modifiers);
|
||||||
|
}
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
#include "input.h"
|
||||||
|
|
||||||
|
#include <Limelight.h>
|
||||||
|
#include <SDL.h>
|
||||||
|
#include "streaming/streamutils.h"
|
||||||
|
|
||||||
|
void SdlInputHandler::handleMouseButtonEvent(SDL_MouseButtonEvent* event)
|
||||||
|
{
|
||||||
|
int button;
|
||||||
|
|
||||||
|
if (event->which == SDL_TOUCH_MOUSEID) {
|
||||||
|
// Ignore synthetic mouse events
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!isCaptureActive()) {
|
||||||
|
if (event->button == SDL_BUTTON_LEFT && event->state == SDL_RELEASED) {
|
||||||
|
// Capture the mouse again if clicked when unbound.
|
||||||
|
// We start capture on left button released instead of
|
||||||
|
// pressed to avoid sending an errant mouse button released
|
||||||
|
// event to the host when clicking into our window (since
|
||||||
|
// the pressed event was consumed by this code).
|
||||||
|
setCaptureActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not capturing
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (event->button)
|
||||||
|
{
|
||||||
|
case SDL_BUTTON_LEFT:
|
||||||
|
button = BUTTON_LEFT;
|
||||||
|
break;
|
||||||
|
case SDL_BUTTON_MIDDLE:
|
||||||
|
button = BUTTON_MIDDLE;
|
||||||
|
break;
|
||||||
|
case SDL_BUTTON_RIGHT:
|
||||||
|
button = BUTTON_RIGHT;
|
||||||
|
break;
|
||||||
|
case SDL_BUTTON_X1:
|
||||||
|
button = BUTTON_X1;
|
||||||
|
break;
|
||||||
|
case SDL_BUTTON_X2:
|
||||||
|
button = BUTTON_X2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unhandled button event: %d",
|
||||||
|
event->button);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LiSendMouseButtonEvent(event->state == SDL_PRESSED ?
|
||||||
|
BUTTON_ACTION_PRESS :
|
||||||
|
BUTTON_ACTION_RELEASE,
|
||||||
|
button);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::handleMouseMotionEvent(SDL_MouseMotionEvent* event)
|
||||||
|
{
|
||||||
|
if (!isCaptureActive()) {
|
||||||
|
// Not capturing
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (event->which == SDL_TOUCH_MOUSEID) {
|
||||||
|
// Ignore synthetic mouse events
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_AbsoluteMouseMode) {
|
||||||
|
SDL_Rect src, dst;
|
||||||
|
|
||||||
|
src.x = src.y = 0;
|
||||||
|
src.w = m_StreamWidth;
|
||||||
|
src.h = m_StreamHeight;
|
||||||
|
|
||||||
|
dst.x = dst.y = 0;
|
||||||
|
SDL_GetWindowSize(m_Window, &dst.w, &dst.h);
|
||||||
|
|
||||||
|
// Use the stream and window sizes to determine the video region
|
||||||
|
StreamUtils::scaleSourceToDestinationSurface(&src, &dst);
|
||||||
|
|
||||||
|
// Clamp motion to the video region
|
||||||
|
short x = qMin(qMax(event->x - dst.x, 0), dst.w);
|
||||||
|
short y = qMin(qMax(event->y - dst.y, 0), dst.h);
|
||||||
|
|
||||||
|
// Send the mouse position update
|
||||||
|
LiSendMousePositionEvent(x, y, dst.w, dst.h);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Batch until the next mouse polling window or we'll get awful
|
||||||
|
// input lag everything except GFE 3.14 and 3.15.
|
||||||
|
SDL_AtomicAdd(&m_MouseDeltaX, event->xrel);
|
||||||
|
SDL_AtomicAdd(&m_MouseDeltaY, event->yrel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event)
|
||||||
|
{
|
||||||
|
if (!isCaptureActive()) {
|
||||||
|
// Not capturing
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (event->which == SDL_TOUCH_MOUSEID) {
|
||||||
|
// Ignore synthetic mouse events
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event->y != 0) {
|
||||||
|
LiSendScrollEvent((signed char)event->y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint32 SdlInputHandler::mouseMoveTimerCallback(Uint32 interval, void *param)
|
||||||
|
{
|
||||||
|
auto me = reinterpret_cast<SdlInputHandler*>(param);
|
||||||
|
|
||||||
|
short deltaX = (short)SDL_AtomicSet(&me->m_MouseDeltaX, 0);
|
||||||
|
short deltaY = (short)SDL_AtomicSet(&me->m_MouseDeltaY, 0);
|
||||||
|
|
||||||
|
if (deltaX != 0 || deltaY != 0) {
|
||||||
|
LiSendMouseMoveEvent(deltaX, deltaY);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
// See comment in SdlInputHandler::notifyMouseLeave()
|
||||||
|
if (me->m_AbsoluteMouseMode && me->m_PendingMouseLeaveButtonUp != 0 && me->isCaptureActive()) {
|
||||||
|
int mouseX, mouseY;
|
||||||
|
int windowX, windowY;
|
||||||
|
Uint32 mouseState = SDL_GetGlobalMouseState(&mouseX, &mouseY);
|
||||||
|
SDL_GetWindowPosition(me->m_Window, &windowX, &windowY);
|
||||||
|
|
||||||
|
// If the button is now up, send the synthetic mouse up event
|
||||||
|
if ((mouseState & SDL_BUTTON(me->m_PendingMouseLeaveButtonUp)) == 0) {
|
||||||
|
SDL_Event event;
|
||||||
|
|
||||||
|
event.button.type = SDL_MOUSEBUTTONUP;
|
||||||
|
event.button.timestamp = SDL_GetTicks();
|
||||||
|
event.button.windowID = SDL_GetWindowID(me->m_Window);
|
||||||
|
event.button.which = 0;
|
||||||
|
event.button.button = me->m_PendingMouseLeaveButtonUp;
|
||||||
|
event.button.state = SDL_RELEASED;
|
||||||
|
event.button.clicks = 1;
|
||||||
|
event.button.x = mouseX - windowX;
|
||||||
|
event.button.y = mouseY - windowY;
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
|
||||||
|
me->m_PendingMouseLeaveButtonUp = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
#include "input.h"
|
||||||
|
|
||||||
|
#include <Limelight.h>
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include <QtMath>
|
||||||
|
|
||||||
|
// How long the mouse button will be pressed for a tap to click gesture
|
||||||
|
#define TAP_BUTTON_RELEASE_DELAY 100
|
||||||
|
|
||||||
|
// How long the fingers must be stationary to start a drag
|
||||||
|
#define DRAG_ACTIVATION_DELAY 650
|
||||||
|
|
||||||
|
// How far the finger can move before it cancels a drag or tap
|
||||||
|
#define DEAD_ZONE_DELTA 0.01f
|
||||||
|
|
||||||
|
Uint32 SdlInputHandler::releaseLeftButtonTimerCallback(Uint32, void*)
|
||||||
|
{
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint32 SdlInputHandler::releaseRightButtonTimerCallback(Uint32, void*)
|
||||||
|
{
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint32 SdlInputHandler::dragTimerCallback(Uint32, void *param)
|
||||||
|
{
|
||||||
|
auto me = reinterpret_cast<SdlInputHandler*>(param);
|
||||||
|
|
||||||
|
// Check how many fingers are down now to decide
|
||||||
|
// which button to hold down
|
||||||
|
if (me->m_NumFingersDown == 2) {
|
||||||
|
me->m_DragButton = BUTTON_RIGHT;
|
||||||
|
}
|
||||||
|
else if (me->m_NumFingersDown == 1) {
|
||||||
|
me->m_DragButton = BUTTON_LEFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, me->m_DragButton);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdlInputHandler::handleRelativeFingerEvent(SDL_TouchFingerEvent* event)
|
||||||
|
{
|
||||||
|
int fingerIndex = -1;
|
||||||
|
|
||||||
|
// Observations on Windows 10: x and y appear to be relative to 0,0 of the window client area.
|
||||||
|
// Although SDL documentation states they are 0.0 - 1.0 float values, they can actually be higher
|
||||||
|
// or lower than those values as touch events continue for touches started within the client area that
|
||||||
|
// leave the client area during a drag motion.
|
||||||
|
// dx and dy are deltas from the last touch event, not the first touch down.
|
||||||
|
|
||||||
|
// Determine the index of this finger using our list
|
||||||
|
// of fingers that are currently active on screen.
|
||||||
|
// This is also required to handle finger up which
|
||||||
|
// where the finger will not be in SDL_GetTouchFinger()
|
||||||
|
// anymore.
|
||||||
|
if (event->type != SDL_FINGERDOWN) {
|
||||||
|
for (int i = 0; i < MAX_FINGERS; i++) {
|
||||||
|
if (event->fingerId == m_TouchDownEvent[i].fingerId) {
|
||||||
|
fingerIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Resolve the new finger by determining the ID of each
|
||||||
|
// finger on the display.
|
||||||
|
int numTouchFingers = SDL_GetNumTouchFingers(event->touchId);
|
||||||
|
for (int i = 0; i < numTouchFingers; i++) {
|
||||||
|
SDL_Finger* finger = SDL_GetTouchFinger(event->touchId, i);
|
||||||
|
SDL_assert(finger != nullptr);
|
||||||
|
if (finger != nullptr) {
|
||||||
|
if (finger->id == event->fingerId) {
|
||||||
|
fingerIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fingerIndex < 0 || fingerIndex >= MAX_FINGERS) {
|
||||||
|
// Too many fingers
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle cursor motion based on the position of the
|
||||||
|
// primary finger on screen
|
||||||
|
if (fingerIndex == 0) {
|
||||||
|
// The event x and y values are relative to our window width
|
||||||
|
// and height. However, we want to scale them to be relative
|
||||||
|
// to the host resolution. Fortunately this is easy since we
|
||||||
|
// already have normalized values. We'll just multiply them
|
||||||
|
// by the stream dimensions to get real X and Y values rather
|
||||||
|
// than the client window dimensions.
|
||||||
|
short deltaX = static_cast<short>(event->dx * m_StreamWidth);
|
||||||
|
short deltaY = static_cast<short>(event->dy * m_StreamHeight);
|
||||||
|
if (deltaX != 0 || deltaY != 0) {
|
||||||
|
LiSendMouseMoveEvent(deltaX, deltaY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start a drag timer when primary or secondary
|
||||||
|
// fingers go down
|
||||||
|
if (event->type == SDL_FINGERDOWN &&
|
||||||
|
(fingerIndex == 0 || fingerIndex == 1)) {
|
||||||
|
SDL_RemoveTimer(m_DragTimer);
|
||||||
|
m_DragTimer = SDL_AddTimer(DRAG_ACTIVATION_DELAY,
|
||||||
|
dragTimerCallback,
|
||||||
|
this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event->type == SDL_FINGERMOTION) {
|
||||||
|
// If it's outside the deadzone delta, cancel drags and taps
|
||||||
|
if (qSqrt(qPow(event->x - m_TouchDownEvent[fingerIndex].x, 2) +
|
||||||
|
qPow(event->y - m_TouchDownEvent[fingerIndex].y, 2)) > DEAD_ZONE_DELTA) {
|
||||||
|
SDL_RemoveTimer(m_DragTimer);
|
||||||
|
m_DragTimer = 0;
|
||||||
|
|
||||||
|
// This effectively cancels the tap logic below
|
||||||
|
m_TouchDownEvent[fingerIndex].timestamp = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event->type == SDL_FINGERUP) {
|
||||||
|
// Cancel the drag timer on finger up
|
||||||
|
SDL_RemoveTimer(m_DragTimer);
|
||||||
|
m_DragTimer = 0;
|
||||||
|
|
||||||
|
// Release any drag
|
||||||
|
if (m_DragButton != 0) {
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, m_DragButton);
|
||||||
|
m_DragButton = 0;
|
||||||
|
}
|
||||||
|
// 2 finger tap
|
||||||
|
else if (event->timestamp - m_TouchDownEvent[1].timestamp < 250) {
|
||||||
|
// Zero timestamp of the primary finger to ensure we won't
|
||||||
|
// generate a left click if the primary finger comes up soon.
|
||||||
|
m_TouchDownEvent[0].timestamp = 0;
|
||||||
|
|
||||||
|
// Press down the right mouse button
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
|
||||||
|
|
||||||
|
// Queue a timer to release it in 100 ms
|
||||||
|
SDL_RemoveTimer(m_RightButtonReleaseTimer);
|
||||||
|
m_RightButtonReleaseTimer = SDL_AddTimer(TAP_BUTTON_RELEASE_DELAY,
|
||||||
|
releaseRightButtonTimerCallback,
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
|
// 1 finger tap
|
||||||
|
else if (event->timestamp - m_TouchDownEvent[0].timestamp < 250) {
|
||||||
|
// Press down the left mouse button
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||||
|
|
||||||
|
// Queue a timer to release it in 100 ms
|
||||||
|
SDL_RemoveTimer(m_LeftButtonReleaseTimer);
|
||||||
|
m_LeftButtonReleaseTimer = SDL_AddTimer(TAP_BUTTON_RELEASE_DELAY,
|
||||||
|
releaseLeftButtonTimerCallback,
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_NumFingersDown = SDL_GetNumTouchFingers(event->touchId);
|
||||||
|
|
||||||
|
if (event->type == SDL_FINGERDOWN) {
|
||||||
|
m_TouchDownEvent[fingerIndex] = *event;
|
||||||
|
}
|
||||||
|
else if (event->type == SDL_FINGERUP) {
|
||||||
|
m_TouchDownEvent[fingerIndex] = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
+174
-86
@@ -30,6 +30,8 @@
|
|||||||
#include <QSvgRenderer>
|
#include <QSvgRenderer>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QCursor>
|
||||||
|
|
||||||
CONNECTION_LISTENER_CALLBACKS Session::k_ConnCallbacks = {
|
CONNECTION_LISTENER_CALLBACKS Session::k_ConnCallbacks = {
|
||||||
Session::clStageStarting,
|
Session::clStageStarting,
|
||||||
@@ -37,8 +39,6 @@ CONNECTION_LISTENER_CALLBACKS Session::k_ConnCallbacks = {
|
|||||||
Session::clStageFailed,
|
Session::clStageFailed,
|
||||||
nullptr,
|
nullptr,
|
||||||
Session::clConnectionTerminated,
|
Session::clConnectionTerminated,
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
Session::clLogMessage,
|
Session::clLogMessage,
|
||||||
Session::clRumble,
|
Session::clRumble,
|
||||||
Session::clConnectionStatusUpdate
|
Session::clConnectionStatusUpdate
|
||||||
@@ -56,7 +56,7 @@ void Session::clStageStarting(int stage)
|
|||||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::clStageFailed(int stage, long errorCode)
|
void Session::clStageFailed(int stage, int errorCode)
|
||||||
{
|
{
|
||||||
// We know this is called on the same thread as LiStartConnection()
|
// We know this is called on the same thread as LiStartConnection()
|
||||||
// which happens to be the main thread, so it's cool to interact
|
// which happens to be the main thread, so it's cool to interact
|
||||||
@@ -65,16 +65,26 @@ void Session::clStageFailed(int stage, long errorCode)
|
|||||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::clConnectionTerminated(long errorCode)
|
void Session::clConnectionTerminated(int errorCode)
|
||||||
{
|
{
|
||||||
// Display the termination dialog if this was not intended
|
// Display the termination dialog if this was not intended
|
||||||
if (errorCode != 0) {
|
switch (errorCode) {
|
||||||
|
case ML_ERROR_GRACEFUL_TERMINATION:
|
||||||
|
break;
|
||||||
|
|
||||||
|
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.");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
s_ActiveSession->m_UnexpectedTermination = true;
|
s_ActiveSession->m_UnexpectedTermination = true;
|
||||||
emit s_ActiveSession->displayLaunchError("Connection terminated");
|
emit s_ActiveSession->displayLaunchError("Connection terminated");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Connection terminated: %ld",
|
"Connection terminated: %d",
|
||||||
errorCode);
|
errorCode);
|
||||||
|
|
||||||
// Push a quit event to the main loop
|
// Push a quit event to the main loop
|
||||||
@@ -250,6 +260,25 @@ int Session::drSubmitDecodeUnit(PDECODE_UNIT du)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::getDecoderInfo(SDL_Window* window,
|
||||||
|
bool& isHardwareAccelerated, bool& isFullScreenOnly, QSize& maxResolution)
|
||||||
|
{
|
||||||
|
IVideoDecoder* decoder;
|
||||||
|
|
||||||
|
if (!chooseDecoder(StreamingPreferences::VDS_AUTO,
|
||||||
|
window, VIDEO_FORMAT_H264, 1920, 1080, 60,
|
||||||
|
true, false, true, decoder)) {
|
||||||
|
isHardwareAccelerated = isFullScreenOnly = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isHardwareAccelerated = decoder->isHardwareAccelerated();
|
||||||
|
isFullScreenOnly = decoder->isAlwaysFullScreen();
|
||||||
|
maxResolution = decoder->getDecoderMaxResolution();
|
||||||
|
|
||||||
|
delete decoder;
|
||||||
|
}
|
||||||
|
|
||||||
bool Session::isHardwareDecodeAvailable(SDL_Window* window,
|
bool Session::isHardwareDecodeAvailable(SDL_Window* window,
|
||||||
StreamingPreferences::VideoDecoderSelection vds,
|
StreamingPreferences::VideoDecoderSelection vds,
|
||||||
int videoFormat, int width, int height, int frameRate)
|
int videoFormat, int width, int height, int frameRate)
|
||||||
@@ -375,6 +404,9 @@ bool Session::initialize()
|
|||||||
case StreamingPreferences::AC_51_SURROUND:
|
case StreamingPreferences::AC_51_SURROUND:
|
||||||
m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_51_SURROUND;
|
m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_51_SURROUND;
|
||||||
break;
|
break;
|
||||||
|
case StreamingPreferences::AC_71_SURROUND:
|
||||||
|
m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_71_SURROUND;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LiInitializeAudioCallbacks(&m_AudioCallbacks);
|
LiInitializeAudioCallbacks(&m_AudioCallbacks);
|
||||||
@@ -384,8 +416,11 @@ bool Session::initialize()
|
|||||||
m_AudioCallbacks.capabilities = getAudioRendererCapabilities(m_StreamConfig.audioConfiguration);
|
m_AudioCallbacks.capabilities = getAudioRendererCapabilities(m_StreamConfig.audioConfiguration);
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Audio configuration: %d",
|
"Audio channel count: %d",
|
||||||
m_StreamConfig.audioConfiguration);
|
CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(m_StreamConfig.audioConfiguration));
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Audio channel mask: %X",
|
||||||
|
CHANNEL_MASK_FROM_AUDIO_CONFIGURATION(m_StreamConfig.audioConfiguration));
|
||||||
|
|
||||||
switch (m_Preferences->videoCodecConfig)
|
switch (m_Preferences->videoCodecConfig)
|
||||||
{
|
{
|
||||||
@@ -441,6 +476,17 @@ bool Session::initialize()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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
|
||||||
|
// really matter anyway because the MMAL renderer always draws full-screen).
|
||||||
|
if (qgetenv("DESKTOP_SESSION") == "LXDE-pi") {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Forcing windowed mode on LXDE-Pi");
|
||||||
|
m_FullScreenFlag = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check for validation errors/warnings and emit
|
// Check for validation errors/warnings and emit
|
||||||
// signals for them, if appropriate
|
// signals for them, if appropriate
|
||||||
bool ret = validateLaunch(testWindow);
|
bool ret = validateLaunch(testWindow);
|
||||||
@@ -481,8 +527,18 @@ bool Session::validateLaunch(SDL_Window* testWindow)
|
|||||||
{
|
{
|
||||||
QStringList warningList;
|
QStringList warningList;
|
||||||
|
|
||||||
|
if (m_Preferences->absoluteMouseMode && !m_App.isAppCollectorGame) {
|
||||||
|
emitLaunchWarning("Your selection to enable remote desktop mouse mode may cause problems in games.");
|
||||||
|
}
|
||||||
|
|
||||||
if (m_Preferences->videoDecoderSelection == StreamingPreferences::VDS_FORCE_SOFTWARE) {
|
if (m_Preferences->videoDecoderSelection == StreamingPreferences::VDS_FORCE_SOFTWARE) {
|
||||||
emitLaunchWarning("Your settings selection to force software decoding may cause poor streaming performance.");
|
if (m_Preferences->videoCodecConfig == StreamingPreferences::VCC_FORCE_HEVC_HDR) {
|
||||||
|
emitLaunchWarning("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.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Preferences->unsupportedFps && m_StreamConfig.fps > 60) {
|
if (m_Preferences->unsupportedFps && m_StreamConfig.fps > 60) {
|
||||||
@@ -569,12 +625,12 @@ bool Session::validateLaunch(SDL_Window* testWindow)
|
|||||||
// Test if audio works at the specified audio configuration
|
// Test if audio works at the specified audio configuration
|
||||||
bool audioTestPassed = testAudio(m_StreamConfig.audioConfiguration);
|
bool audioTestPassed = testAudio(m_StreamConfig.audioConfiguration);
|
||||||
|
|
||||||
// Gracefully degrade to stereo if 5.1 doesn't work
|
// Gracefully degrade to stereo if surround sound doesn't work
|
||||||
if (!audioTestPassed && m_StreamConfig.audioConfiguration == AUDIO_CONFIGURATION_51_SURROUND) {
|
if (!audioTestPassed && CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(m_StreamConfig.audioConfiguration) > 2) {
|
||||||
audioTestPassed = testAudio(AUDIO_CONFIGURATION_STEREO);
|
audioTestPassed = testAudio(AUDIO_CONFIGURATION_STEREO);
|
||||||
if (audioTestPassed) {
|
if (audioTestPassed) {
|
||||||
m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_STEREO;
|
m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_STEREO;
|
||||||
emitLaunchWarning("5.1 surround sound is not supported by the current audio device.");
|
emitLaunchWarning("Your selected surround sound setting is not supported by the current audio device.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,6 +645,18 @@ bool Session::validateLaunch(SDL_Window* testWindow)
|
|||||||
emitLaunchWarning("An attached gamepad has no mapping and won't be usable. Visit the Moonlight help to resolve this.");
|
emitLaunchWarning("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.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!m_StreamConfig.supportsHevc) {
|
||||||
|
emit displayLaunchError("Video resolutions over 4K are only supported by the HEVC codec.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_Preferences->videoDecoderSelection == StreamingPreferences::VDS_FORCE_HARDWARE &&
|
if (m_Preferences->videoDecoderSelection == StreamingPreferences::VDS_FORCE_HARDWARE &&
|
||||||
!m_StreamConfig.enableHdr && // HEVC Main10 was already checked for hardware decode support above
|
!m_StreamConfig.enableHdr && // HEVC Main10 was already checked for hardware decode support above
|
||||||
!isHardwareDecodeAvailable(testWindow,
|
!isHardwareDecodeAvailable(testWindow,
|
||||||
@@ -809,10 +877,18 @@ void Session::toggleFullscreen()
|
|||||||
bool fullScreen = !(SDL_GetWindowFlags(m_Window) & m_FullScreenFlag);
|
bool fullScreen = !(SDL_GetWindowFlags(m_Window) & m_FullScreenFlag);
|
||||||
|
|
||||||
if (fullScreen) {
|
if (fullScreen) {
|
||||||
|
if (m_FullScreenFlag == SDL_WINDOW_FULLSCREEN && m_InputHandler->isCaptureActive()) {
|
||||||
|
// Confine the cursor to the window if we're capturing input
|
||||||
|
SDL_SetWindowGrab(m_Window, SDL_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_SetWindowResizable(m_Window, SDL_FALSE);
|
SDL_SetWindowResizable(m_Window, SDL_FALSE);
|
||||||
SDL_SetWindowFullscreen(m_Window, m_FullScreenFlag);
|
SDL_SetWindowFullscreen(m_Window, m_FullScreenFlag);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Unconfine the cursor
|
||||||
|
SDL_SetWindowGrab(m_Window, SDL_FALSE);
|
||||||
|
|
||||||
SDL_SetWindowFullscreen(m_Window, 0);
|
SDL_SetWindowFullscreen(m_Window, 0);
|
||||||
SDL_SetWindowResizable(m_Window, SDL_TRUE);
|
SDL_SetWindowResizable(m_Window, SDL_TRUE);
|
||||||
|
|
||||||
@@ -891,6 +967,18 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prefs.fps > 60) {
|
||||||
|
// Using SOPS with FPS values over 60 causes GFE to fall back
|
||||||
|
// to 720p60. On previous GFE versions, we could avoid this by
|
||||||
|
// forcing the FPS value to 60 when launching the stream, but
|
||||||
|
// now on GFE 3.20.3 that seems to trigger some sort of
|
||||||
|
// frame rate limiter that locks the game to 60 FPS.
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Disabling SOPS for %d FPS stream",
|
||||||
|
prefs.fps);
|
||||||
|
enableGameOptimizations = false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
NvHTTP http(m_Computer->activeAddress, m_Computer->serverCert);
|
NvHTTP http(m_Computer->activeAddress, m_Computer->serverCert);
|
||||||
if (m_Computer->currentGameId != 0) {
|
if (m_Computer->currentGameId != 0) {
|
||||||
@@ -934,17 +1022,28 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
|||||||
hostInfo.serverInfoGfeVersion = siGfeVersion.data();
|
hostInfo.serverInfoGfeVersion = siGfeVersion.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// isReachableOverVpn() does network I/O, so we only attempt to check
|
if (m_Preferences->packetSize != 0) {
|
||||||
// VPN reachability if we've already contacted the PC successfully
|
// Override default packet size and remote streaming detection
|
||||||
if (m_Computer->isReachableOverVpn()) {
|
// NB: Using STREAM_CFG_AUTO will cap our packet size at 1024 for remote hosts.
|
||||||
// It looks like our route to this PC is over a VPN.
|
m_StreamConfig.streamingRemotely = STREAM_CFG_LOCAL;
|
||||||
// Treat it as remote even if the target address is in RFC 1918 address space.
|
m_StreamConfig.packetSize = m_Preferences->packetSize;
|
||||||
m_StreamConfig.streamingRemotely = STREAM_CFG_REMOTE;
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
m_StreamConfig.packetSize = 1024;
|
"Using custom packet size: %d bytes",
|
||||||
|
m_Preferences->packetSize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_StreamConfig.streamingRemotely = STREAM_CFG_AUTO;
|
// isReachableOverVpn() does network I/O, so we only attempt to check
|
||||||
m_StreamConfig.packetSize = 1392;
|
// VPN reachability if we've already contacted the PC successfully
|
||||||
|
if (m_Computer->isReachableOverVpn()) {
|
||||||
|
// It looks like our route to this PC is over a VPN.
|
||||||
|
// Treat it as remote even if the target address is in RFC 1918 address space.
|
||||||
|
m_StreamConfig.streamingRemotely = STREAM_CFG_REMOTE;
|
||||||
|
m_StreamConfig.packetSize = 1024;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_StreamConfig.streamingRemotely = STREAM_CFG_AUTO;
|
||||||
|
m_StreamConfig.packetSize = 1392;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int err = LiStartConnection(&hostInfo, &m_StreamConfig, &k_ConnCallbacks,
|
int err = LiStartConnection(&hostInfo, &m_StreamConfig, &k_ConnCallbacks,
|
||||||
@@ -968,6 +1067,13 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
|||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
getWindowDimensions(x, y, width, height);
|
getWindowDimensions(x, y, width, height);
|
||||||
|
|
||||||
|
#ifdef STEAM_LINK
|
||||||
|
// We need a little delay before creating the window or we will trigger some kind
|
||||||
|
// of graphics driver bug on Steam Link that causes a jagged overlay to appear in
|
||||||
|
// the top right corner randomly.
|
||||||
|
SDL_Delay(500);
|
||||||
|
#endif
|
||||||
|
|
||||||
m_Window = SDL_CreateWindow("Moonlight",
|
m_Window = SDL_CreateWindow("Moonlight",
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
@@ -985,6 +1091,8 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_InputHandler->setWindow(m_Window);
|
||||||
|
|
||||||
QSvgRenderer svgIconRenderer(QString(":/res/moonlight.svg"));
|
QSvgRenderer svgIconRenderer(QString(":/res/moonlight.svg"));
|
||||||
QImage svgImage(ICON_SIZE, ICON_SIZE, QImage::Format_RGBA8888);
|
QImage svgImage(ICON_SIZE, ICON_SIZE, QImage::Format_RGBA8888);
|
||||||
svgImage.fill(0);
|
svgImage.fill(0);
|
||||||
@@ -1029,18 +1137,21 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
|||||||
SDL_SetWindowFullscreen(m_Window, m_FullScreenFlag);
|
SDL_SetWindowFullscreen(m_Window, m_FullScreenFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_DEBUG
|
bool needsFirstEnterCapture = false;
|
||||||
// Capture the mouse by default on release builds only.
|
bool needsPostDecoderCreationCapture = false;
|
||||||
// This prevents the mouse from becoming trapped inside
|
|
||||||
// Moonlight when it's halted at a debug break.
|
// HACK: For Wayland, we wait until we get the first SDL_WINDOWEVENT_ENTER
|
||||||
if (m_Preferences->windowMode != StreamingPreferences::WM_WINDOWED) {
|
// event where it seems to work consistently on GNOME. For other platforms,
|
||||||
// HACK: This doesn't work on Wayland until we render a frame, so
|
// especially where SDL may call SDL_RecreateWindow(), we must only capture
|
||||||
// just don't do it for now.
|
// after the decoder is created.
|
||||||
if (strcmp(SDL_GetCurrentVideoDriver(), "wayland") != 0) {
|
if (strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) {
|
||||||
m_InputHandler->setCaptureActive(true);
|
// Native Wayland: Capture on SDL_WINDOWEVENT_ENTER
|
||||||
}
|
needsFirstEnterCapture = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// X11/XWayland: Capture after decoder creation
|
||||||
|
needsPostDecoderCreationCapture = true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Stop text input. SDL enables it by default
|
// Stop text input. SDL enables it by default
|
||||||
// when we initialize the video subsystem, but this
|
// when we initialize the video subsystem, but this
|
||||||
@@ -1051,6 +1162,11 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
|||||||
// Disable the screen saver
|
// Disable the screen saver
|
||||||
SDL_DisableScreenSaver();
|
SDL_DisableScreenSaver();
|
||||||
|
|
||||||
|
// Hide Qt's fake mouse cursor on EGLFS systems
|
||||||
|
if (QGuiApplication::platformName() == "eglfs") {
|
||||||
|
QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
|
||||||
|
}
|
||||||
|
|
||||||
// Set timer resolution to 1 ms on Windows for greater
|
// Set timer resolution to 1 ms on Windows for greater
|
||||||
// sleep precision and more accurate callback timing.
|
// sleep precision and more accurate callback timing.
|
||||||
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "1");
|
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "1");
|
||||||
@@ -1096,43 +1212,17 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
// Capture mouse cursor when user actives the window by clicking on
|
|
||||||
// window's client area (borders and title bar excluded).
|
|
||||||
// Without this you would have to click the window twice (once to
|
|
||||||
// activate it, second time to enable capture). With this you need to
|
|
||||||
// click it only once.
|
|
||||||
// On Linux, the button press event is delivered after the focus gain
|
|
||||||
// so this is not neccessary (and leads to a click sent to the host
|
|
||||||
// when focusing the window by clicking).
|
|
||||||
// By excluding window's borders and title bar out, lets user still
|
|
||||||
// interact with them without mouse capture kicking in.
|
|
||||||
#if defined(Q_OS_WIN32) || defined(Q_OS_DARWIN)
|
|
||||||
if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) {
|
|
||||||
int mouseX, mouseY;
|
|
||||||
Uint32 mouseState = SDL_GetGlobalMouseState(&mouseX, &mouseY);
|
|
||||||
if (mouseState & SDL_BUTTON(SDL_BUTTON_LEFT)) {
|
|
||||||
int x, y, width, height;
|
|
||||||
SDL_GetWindowPosition(m_Window, &x, &y);
|
|
||||||
SDL_GetWindowSize(m_Window, &width, &height);
|
|
||||||
if (mouseX > x && mouseX < x+width && mouseY > y && mouseY < y+height) {
|
|
||||||
m_InputHandler->setCaptureActive(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
|
if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
|
||||||
// Release mouse cursor when another window is activated (e.g. by using ALT+TAB).
|
m_InputHandler->notifyFocusLost();
|
||||||
// This lets user to interact with our window's title bar and with the buttons in it.
|
}
|
||||||
// Doing this while the window is full-screen breaks the transition out of FS
|
else if (event.window.event == SDL_WINDOWEVENT_LEAVE) {
|
||||||
// (desktop and exclusive), so we must check for that before releasing mouse capture.
|
m_InputHandler->notifyMouseLeave();
|
||||||
if (!(SDL_GetWindowFlags(m_Window) & SDL_WINDOW_FULLSCREEN)) {
|
}
|
||||||
m_InputHandler->setCaptureActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Raise all keys that are currently pressed. If we don't do this, certain keys
|
// Capture the mouse on SDL_WINDOWEVENT_ENTER if needed
|
||||||
// used in shortcuts that cause focus loss (such as Alt+Tab) may get stuck down.
|
if (needsFirstEnterCapture && event.window.event == SDL_WINDOWEVENT_ENTER) {
|
||||||
m_InputHandler->raiseAllKeys();
|
m_InputHandler->setCaptureActive(true);
|
||||||
|
needsFirstEnterCapture = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to recreate the decoder for resizes (full-screen toggles) and the initial shown event.
|
// We want to recreate the decoder for resizes (full-screen toggles) and the initial shown event.
|
||||||
@@ -1161,6 +1251,12 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
|||||||
SDL_SetWindowPosition(m_Window, x, y);
|
SDL_SetWindowPosition(m_Window, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Recreating renderer for window event: %d (%d %d)",
|
||||||
|
event.window.event,
|
||||||
|
event.window.data1,
|
||||||
|
event.window.data2);
|
||||||
|
|
||||||
// Fall through
|
// Fall through
|
||||||
case SDL_RENDER_DEVICE_RESET:
|
case SDL_RENDER_DEVICE_RESET:
|
||||||
case SDL_RENDER_TARGETS_RESET:
|
case SDL_RENDER_TARGETS_RESET:
|
||||||
@@ -1213,6 +1309,14 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
|||||||
emit displayLaunchError("Unable to initialize video decoder. Please check your streaming settings and try again.");
|
emit displayLaunchError("Unable to initialize video decoder. Please check your streaming settings and try again.");
|
||||||
goto DispatchDeferredCleanup;
|
goto DispatchDeferredCleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As of SDL 2.0.12, SDL_RecreateWindow() doesn't carry over mouse capture
|
||||||
|
// or mouse hiding state to the new window. By capturing after the decoder
|
||||||
|
// is set up, this ensures the window re-creation is already done.
|
||||||
|
if (needsPostDecoderCreationCapture) {
|
||||||
|
m_InputHandler->setCaptureActive(true);
|
||||||
|
needsFirstEnterCapture = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request an IDR frame to complete the reset
|
// Request an IDR frame to complete the reset
|
||||||
@@ -1263,6 +1367,9 @@ DispatchDeferredCleanup:
|
|||||||
m_InputHandler->setCaptureActive(false);
|
m_InputHandler->setCaptureActive(false);
|
||||||
SDL_EnableScreenSaver();
|
SDL_EnableScreenSaver();
|
||||||
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0");
|
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0");
|
||||||
|
if (QGuiApplication::platformName() == "eglfs") {
|
||||||
|
QGuiApplication::restoreOverrideCursor();
|
||||||
|
}
|
||||||
|
|
||||||
// Raise any keys that are still down
|
// Raise any keys that are still down
|
||||||
m_InputHandler->raiseAllKeys();
|
m_InputHandler->raiseAllKeys();
|
||||||
@@ -1282,25 +1389,6 @@ DispatchDeferredCleanup:
|
|||||||
m_VideoDecoder = nullptr;
|
m_VideoDecoder = nullptr;
|
||||||
SDL_AtomicUnlock(&m_DecoderLock);
|
SDL_AtomicUnlock(&m_DecoderLock);
|
||||||
|
|
||||||
if (strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) {
|
|
||||||
// HACK: SDL (as of 2.0.10) has a bug that causes Mutter not to destroy the window
|
|
||||||
// surface when in full-screen unless we render more frames after we request
|
|
||||||
// to exit full-screen. The amount of frames required is variable but 500 ms
|
|
||||||
// of frames seems sufficient in my testing.
|
|
||||||
SDL_SetWindowFullscreen(m_Window, 0);
|
|
||||||
SDL_Renderer* renderer = SDL_CreateRenderer(m_Window, -1, SDL_RENDERER_PRESENTVSYNC);
|
|
||||||
if (renderer != nullptr) {
|
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
|
||||||
for (int i = 0; i < 10; i++)
|
|
||||||
{
|
|
||||||
SDL_RenderClear(renderer);
|
|
||||||
SDL_RenderPresent(renderer);
|
|
||||||
SDL_Delay(50);
|
|
||||||
}
|
|
||||||
SDL_DestroyRenderer(renderer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This must be called after the decoder is deleted, because
|
// This must be called after the decoder is deleted, because
|
||||||
// the renderer may want to interact with the window
|
// the renderer may want to interact with the window
|
||||||
SDL_DestroyWindow(m_Window);
|
SDL_DestroyWindow(m_Window);
|
||||||
|
|||||||
+11
-7
@@ -5,7 +5,7 @@
|
|||||||
#include <Limelight.h>
|
#include <Limelight.h>
|
||||||
#include <opus_multistream.h>
|
#include <opus_multistream.h>
|
||||||
#include "settings/streamingpreferences.h"
|
#include "settings/streamingpreferences.h"
|
||||||
#include "input.h"
|
#include "input/input.h"
|
||||||
#include "video/decoder.h"
|
#include "video/decoder.h"
|
||||||
#include "audio/renderers/renderer.h"
|
#include "audio/renderers/renderer.h"
|
||||||
#include "video/overlaymanager.h"
|
#include "video/overlaymanager.h"
|
||||||
@@ -25,9 +25,8 @@ public:
|
|||||||
Q_INVOKABLE void exec(int displayOriginX, int displayOriginY);
|
Q_INVOKABLE void exec(int displayOriginX, int displayOriginY);
|
||||||
|
|
||||||
static
|
static
|
||||||
bool isHardwareDecodeAvailable(SDL_Window* window,
|
void getDecoderInfo(SDL_Window* window,
|
||||||
StreamingPreferences::VideoDecoderSelection vds,
|
bool& isHardwareAccelerated, bool& isFullScreenOnly, QSize& maxResolution);
|
||||||
int videoFormat, int width, int height, int frameRate);
|
|
||||||
|
|
||||||
static Session* get()
|
static Session* get()
|
||||||
{
|
{
|
||||||
@@ -42,7 +41,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void stageStarting(QString stage);
|
void stageStarting(QString stage);
|
||||||
|
|
||||||
void stageFailed(QString stage, long errorCode);
|
void stageFailed(QString stage, int errorCode);
|
||||||
|
|
||||||
void connectionStarted();
|
void connectionStarted();
|
||||||
|
|
||||||
@@ -78,6 +77,11 @@ private:
|
|||||||
|
|
||||||
void updateOptimalWindowDisplayMode();
|
void updateOptimalWindowDisplayMode();
|
||||||
|
|
||||||
|
static
|
||||||
|
bool isHardwareDecodeAvailable(SDL_Window* window,
|
||||||
|
StreamingPreferences::VideoDecoderSelection vds,
|
||||||
|
int videoFormat, int width, int height, int frameRate);
|
||||||
|
|
||||||
static
|
static
|
||||||
bool chooseDecoder(StreamingPreferences::VideoDecoderSelection vds,
|
bool chooseDecoder(StreamingPreferences::VideoDecoderSelection vds,
|
||||||
SDL_Window* window, int videoFormat, int width, int height,
|
SDL_Window* window, int videoFormat, int width, int height,
|
||||||
@@ -89,10 +93,10 @@ private:
|
|||||||
void clStageStarting(int stage);
|
void clStageStarting(int stage);
|
||||||
|
|
||||||
static
|
static
|
||||||
void clStageFailed(int stage, long errorCode);
|
void clStageFailed(int stage, int errorCode);
|
||||||
|
|
||||||
static
|
static
|
||||||
void clConnectionTerminated(long errorCode);
|
void clConnectionTerminated(int errorCode);
|
||||||
|
|
||||||
static
|
static
|
||||||
void clLogMessage(const char* format, ...);
|
void clLogMessage(const char* format, ...);
|
||||||
|
|||||||
@@ -12,14 +12,12 @@ void StreamUtils::scaleSourceToDestinationSurface(SDL_Rect* src, SDL_Rect* dst)
|
|||||||
int dstW = dst->h * src->w / src->h;
|
int dstW = dst->h * src->w / src->h;
|
||||||
|
|
||||||
if (dstH > dst->h) {
|
if (dstH > dst->h) {
|
||||||
dst->y = 0;
|
dst->x += (dst->w - dstW) / 2;
|
||||||
dst->x = (dst->w - dstW) / 2;
|
|
||||||
dst->w = dstW;
|
dst->w = dstW;
|
||||||
SDL_assert(dst->w * src->h / src->w <= dst->h);
|
SDL_assert(dst->w * src->h / src->w <= dst->h);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dst->x = 0;
|
dst->y += (dst->h - dstH) / 2;
|
||||||
dst->y = (dst->h - dstH) / 2;
|
|
||||||
dst->h = dstH;
|
dst->h = dstH;
|
||||||
SDL_assert(dst->h * src->w / src->h <= dst->w);
|
SDL_assert(dst->h * src->w / src->h <= dst->w);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,10 @@ public:
|
|||||||
virtual ~IVideoDecoder() {}
|
virtual ~IVideoDecoder() {}
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
||||||
virtual bool isHardwareAccelerated() = 0;
|
virtual bool isHardwareAccelerated() = 0;
|
||||||
|
virtual bool isAlwaysFullScreen() = 0;
|
||||||
virtual int getDecoderCapabilities() = 0;
|
virtual int getDecoderCapabilities() = 0;
|
||||||
virtual int getDecoderColorspace() = 0;
|
virtual int getDecoderColorspace() = 0;
|
||||||
|
virtual QSize getDecoderMaxResolution() = 0;
|
||||||
virtual int submitDecodeUnit(PDECODE_UNIT du) = 0;
|
virtual int submitDecodeUnit(PDECODE_UNIT du) = 0;
|
||||||
virtual void renderFrameOnMainThread() = 0;
|
virtual void renderFrameOnMainThread() = 0;
|
||||||
};
|
};
|
||||||
@@ -28,7 +28,7 @@ bool CUDARenderer::initialize(PDECODER_PARAMETERS)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUDARenderer::prepareDecoderContext(AVCodecContext* context)
|
bool CUDARenderer::prepareDecoderContext(AVCodecContext* context, AVDictionary**)
|
||||||
{
|
{
|
||||||
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public:
|
|||||||
CUDARenderer();
|
CUDARenderer();
|
||||||
virtual ~CUDARenderer() override;
|
virtual ~CUDARenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS) override;
|
virtual bool initialize(PDECODER_PARAMETERS) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual bool needsTestFrame() override;
|
virtual bool needsTestFrame() override;
|
||||||
virtual bool isDirectRenderingSupported() override;
|
virtual bool isDirectRenderingSupported() override;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ DrmRenderer::~DrmRenderer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrmRenderer::prepareDecoderContext(AVCodecContext*)
|
bool DrmRenderer::prepareDecoderContext(AVCodecContext*, AVDictionary**)
|
||||||
{
|
{
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
|
|
||||||
@@ -194,8 +194,19 @@ enum AVPixelFormat DrmRenderer::getPreferredPixelFormat(int)
|
|||||||
return AV_PIX_FMT_DRM_PRIME;
|
return AV_PIX_FMT_DRM_PRIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DrmRenderer::getRendererAttributes()
|
||||||
|
{
|
||||||
|
// This renderer can only draw in full-screen
|
||||||
|
return RENDERER_ATTRIBUTE_FULLSCREEN_ONLY;
|
||||||
|
}
|
||||||
|
|
||||||
void DrmRenderer::renderFrame(AVFrame* frame)
|
void DrmRenderer::renderFrame(AVFrame* frame)
|
||||||
{
|
{
|
||||||
|
if (frame == nullptr) {
|
||||||
|
// End of stream - nothing to do for us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AVDRMFrameDescriptor* drmFrame = (AVDRMFrameDescriptor*)frame->data[0];
|
AVDRMFrameDescriptor* drmFrame = (AVDRMFrameDescriptor*)frame->data[0];
|
||||||
int err;
|
int err;
|
||||||
uint32_t primeHandle;
|
uint32_t primeHandle;
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ public:
|
|||||||
DrmRenderer();
|
DrmRenderer();
|
||||||
virtual ~DrmRenderer() override;
|
virtual ~DrmRenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
|
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
|
||||||
|
virtual int getRendererAttributes() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_DrmFd;
|
int m_DrmFd;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ AVBufferRef* DXVA2Renderer::ffPoolAlloc(void* opaque, int)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DXVA2Renderer::prepareDecoderContext(AVCodecContext* context)
|
bool DXVA2Renderer::prepareDecoderContext(AVCodecContext* context, AVDictionary**)
|
||||||
{
|
{
|
||||||
// m_DXVAContext.workaround and report_id already initialized elsewhere
|
// m_DXVAContext.workaround and report_id already initialized elsewhere
|
||||||
m_DXVAContext.decoder = m_Decoder;
|
m_DXVAContext.decoder = m_Decoder;
|
||||||
@@ -546,14 +546,34 @@ bool DXVA2Renderer::initializeDevice(SDL_Window* window, bool enableVsync)
|
|||||||
d3dpp.hDeviceWindow = info.info.win.window;
|
d3dpp.hDeviceWindow = info.info.win.window;
|
||||||
d3dpp.Flags = D3DPRESENTFLAG_VIDEO;
|
d3dpp.Flags = D3DPRESENTFLAG_VIDEO;
|
||||||
|
|
||||||
|
if (m_VideoFormat == VIDEO_FORMAT_H265_MAIN10) {
|
||||||
|
// Verify 10-bit A2R10G10B10 color support. This is only available
|
||||||
|
// as a display format in full-screen exclusive mode on DX9.
|
||||||
|
hr = d3d9ex->CheckDeviceType(adapterIndex,
|
||||||
|
D3DDEVTYPE_HAL,
|
||||||
|
D3DFMT_A2R10G10B10,
|
||||||
|
D3DFMT_A2R10G10B10,
|
||||||
|
FALSE);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"GPU/driver doesn't support A2R10G10B10");
|
||||||
|
d3d9ex->Release();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((windowFlags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN) {
|
if ((windowFlags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN) {
|
||||||
d3dpp.Windowed = false;
|
d3dpp.Windowed = false;
|
||||||
d3dpp.BackBufferWidth = currentMode.Width;
|
d3dpp.BackBufferWidth = currentMode.Width;
|
||||||
d3dpp.BackBufferHeight = currentMode.Height;
|
d3dpp.BackBufferHeight = currentMode.Height;
|
||||||
d3dpp.FullScreen_RefreshRateInHz = currentMode.RefreshRate;
|
d3dpp.FullScreen_RefreshRateInHz = currentMode.RefreshRate;
|
||||||
|
|
||||||
// TODO: Need to select 10-bit color format for HDR
|
if (m_VideoFormat == VIDEO_FORMAT_H265_MAIN10) {
|
||||||
d3dpp.BackBufferFormat = currentMode.Format;
|
d3dpp.BackBufferFormat = currentMode.Format = D3DFMT_A2R10G10B10;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
d3dpp.BackBufferFormat = currentMode.Format;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
d3dpp.Windowed = true;
|
d3dpp.Windowed = true;
|
||||||
@@ -792,6 +812,11 @@ int DXVA2Renderer::getDecoderColorspace()
|
|||||||
|
|
||||||
void DXVA2Renderer::renderFrame(AVFrame *frame)
|
void DXVA2Renderer::renderFrame(AVFrame *frame)
|
||||||
{
|
{
|
||||||
|
if (frame == nullptr) {
|
||||||
|
// End of stream - nothing to do for us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
IDirect3DSurface9* surface = reinterpret_cast<IDirect3DSurface9*>(frame->data[3]);
|
IDirect3DSurface9* surface = reinterpret_cast<IDirect3DSurface9*>(frame->data[3]);
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
DXVA2Renderer();
|
DXVA2Renderer();
|
||||||
virtual ~DXVA2Renderer() override;
|
virtual ~DXVA2Renderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
||||||
virtual int getDecoderColorspace() override;
|
virtual int getDecoderColorspace() override;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// vim: noai:ts=4:sw=4:softtabstop=4:expandtab
|
||||||
|
#include "renderer.h"
|
||||||
|
|
||||||
|
#include <SDL_egl.h>
|
||||||
|
|
||||||
|
static QStringList egl_get_extensions(EGLDisplay dpy) {
|
||||||
|
const auto EGLExtensionsStr = eglQueryString(dpy, EGL_EXTENSIONS);
|
||||||
|
if (!EGLExtensionsStr) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Unable to get EGL extensions");
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
return QString(EGLExtensionsStr).split(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLExtensions::EGLExtensions(EGLDisplay dpy) :
|
||||||
|
m_Extensions(egl_get_extensions(dpy))
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool EGLExtensions::isSupported(const QString &extension) const {
|
||||||
|
return m_Extensions.contains(extension);
|
||||||
|
}
|
||||||
@@ -0,0 +1,627 @@
|
|||||||
|
// vim: noai:ts=4:sw=4:softtabstop=4:expandtab
|
||||||
|
#include "eglvid.h"
|
||||||
|
|
||||||
|
#include "path.h"
|
||||||
|
#include "streaming/session.h"
|
||||||
|
#include "streaming/streamutils.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include <Limelight.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <SDL_egl.h>
|
||||||
|
#include <SDL_opengles2.h>
|
||||||
|
#include <SDL_render.h>
|
||||||
|
#include <SDL_syswm.h>
|
||||||
|
|
||||||
|
#ifndef EGL_VERSION_1_5
|
||||||
|
typedef intptr_t EGLAttrib;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(EGL_VERSION_1_5) || !defined(EGL_EGL_PROTOTYPES)
|
||||||
|
typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYPROC) (EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EGL_EXT_platform_base
|
||||||
|
typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// These are EGL extensions, so some platform headers may not provide them
|
||||||
|
#ifndef EGL_PLATFORM_WAYLAND_KHR
|
||||||
|
#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
|
||||||
|
#endif
|
||||||
|
#ifndef EGL_PLATFORM_X11_KHR
|
||||||
|
#define EGL_PLATFORM_X11_KHR 0x31D5
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* TODO:
|
||||||
|
* - handle more pixel formats
|
||||||
|
* - handle software decoding
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* DOC/misc:
|
||||||
|
* - https://kernel-recipes.org/en/2016/talks/video-and-colorspaces/
|
||||||
|
* - http://www.brucelindbloom.com/
|
||||||
|
* - https://learnopengl.com/Getting-started/Shaders
|
||||||
|
* - https://github.com/stunpix/yuvit
|
||||||
|
* - https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion
|
||||||
|
* - https://www.renesas.com/eu/en/www/doc/application-note/an9717.pdf
|
||||||
|
* - https://www.xilinx.com/support/documentation/application_notes/xapp283.pdf
|
||||||
|
* - https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.709-6-201506-I!!PDF-E.pdf
|
||||||
|
* - https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external.txt
|
||||||
|
* - https://gist.github.com/rexguo/6696123
|
||||||
|
* - https://wiki.libsdl.org/CategoryVideo
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define EGL_LOG(Category, ...) SDL_Log ## Category(\
|
||||||
|
SDL_LOG_CATEGORY_APPLICATION, \
|
||||||
|
"EGLRenderer: " __VA_ARGS__)
|
||||||
|
|
||||||
|
EGLRenderer::EGLRenderer(IFFmpegRenderer *backendRenderer)
|
||||||
|
:
|
||||||
|
m_SwPixelFormat(AV_PIX_FMT_NONE),
|
||||||
|
m_EGLDisplay(EGL_NO_DISPLAY),
|
||||||
|
m_Textures{0},
|
||||||
|
m_ShaderProgram(0),
|
||||||
|
m_Context(0),
|
||||||
|
m_Window(nullptr),
|
||||||
|
m_Backend(backendRenderer),
|
||||||
|
m_VAO(0),
|
||||||
|
m_ColorSpace(AVCOL_SPC_NB),
|
||||||
|
m_ColorFull(false),
|
||||||
|
m_BlockingSwapBuffers(false),
|
||||||
|
m_glEGLImageTargetTexture2DOES(nullptr),
|
||||||
|
m_glGenVertexArraysOES(nullptr),
|
||||||
|
m_glBindVertexArrayOES(nullptr),
|
||||||
|
m_glDeleteVertexArraysOES(nullptr),
|
||||||
|
m_DummyRenderer(nullptr)
|
||||||
|
{
|
||||||
|
SDL_assert(backendRenderer);
|
||||||
|
SDL_assert(backendRenderer->canExportEGL());
|
||||||
|
|
||||||
|
// Save these global parameters so we can restore them in our destructor
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &m_OldContextProfileMask);
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &m_OldContextMajorVersion);
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &m_OldContextMinorVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLRenderer::~EGLRenderer()
|
||||||
|
{
|
||||||
|
if (m_Context) {
|
||||||
|
// Reattach the GL context to the main thread for destruction
|
||||||
|
SDL_GL_MakeCurrent(m_Window, m_Context);
|
||||||
|
if (m_ShaderProgram) {
|
||||||
|
glDeleteProgram(m_ShaderProgram);
|
||||||
|
}
|
||||||
|
if (m_VAO) {
|
||||||
|
SDL_assert(m_glDeleteVertexArraysOES != nullptr);
|
||||||
|
m_glDeleteVertexArraysOES(1, &m_VAO);
|
||||||
|
}
|
||||||
|
if (m_DummyRenderer) {
|
||||||
|
SDL_DestroyRenderer(m_DummyRenderer);
|
||||||
|
}
|
||||||
|
SDL_GL_DeleteContext(m_Context);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset the global properties back to what they were before
|
||||||
|
SDL_SetHint(SDL_HINT_OPENGL_ES_DRIVER, "0");
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, m_OldContextProfileMask);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, m_OldContextMajorVersion);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, m_OldContextMinorVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EGLRenderer::prepareDecoderContext(AVCodecContext*, AVDictionary**)
|
||||||
|
{
|
||||||
|
/* Nothing to do */
|
||||||
|
|
||||||
|
EGL_LOG(Info, "Using EGL renderer");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EGLRenderer::notifyOverlayUpdated(Overlay::OverlayType)
|
||||||
|
{
|
||||||
|
// TODO: FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EGLRenderer::isPixelFormatSupported(int, AVPixelFormat pixelFormat)
|
||||||
|
{
|
||||||
|
// Remember to keep this in sync with EGLRenderer::renderFrame()!
|
||||||
|
switch (pixelFormat)
|
||||||
|
{
|
||||||
|
case AV_PIX_FMT_NV12:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int EGLRenderer::loadAndBuildShader(int shaderType,
|
||||||
|
const char *file) {
|
||||||
|
GLuint shader = glCreateShader(shaderType);
|
||||||
|
if (!shader || shader == GL_INVALID_ENUM) {
|
||||||
|
EGL_LOG(Error, "Can't create shader: %d", glGetError());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto sourceData = Path::readDataFile(file);
|
||||||
|
GLint len = sourceData.size();
|
||||||
|
const char *buf = sourceData.data();
|
||||||
|
|
||||||
|
glShaderSource(shader, 1, &buf, &len);
|
||||||
|
glCompileShader(shader);
|
||||||
|
GLint status;
|
||||||
|
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
|
||||||
|
if (!status) {
|
||||||
|
char shaderLog[512];
|
||||||
|
glGetShaderInfoLog(shader, sizeof (shaderLog), nullptr, shaderLog);
|
||||||
|
EGL_LOG(Error, "Cannot load shader \"%s\": %s", file, shaderLog);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return shader;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EGLRenderer::openDisplay(unsigned int platform, void* nativeDisplay)
|
||||||
|
{
|
||||||
|
PFNEGLGETPLATFORMDISPLAYPROC eglGetPlatformDisplayProc;
|
||||||
|
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXTProc;
|
||||||
|
|
||||||
|
m_EGLDisplay = EGL_NO_DISPLAY;
|
||||||
|
|
||||||
|
// NB: eglGetPlatformDisplay() and eglGetPlatformDisplayEXT() have slightly different definitions
|
||||||
|
eglGetPlatformDisplayProc = (typeof(eglGetPlatformDisplayProc))eglGetProcAddress("eglGetPlatformDisplay");
|
||||||
|
eglGetPlatformDisplayEXTProc = (typeof(eglGetPlatformDisplayEXTProc))eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||||
|
|
||||||
|
if (m_EGLDisplay == EGL_NO_DISPLAY) {
|
||||||
|
// eglGetPlatformDisplay() is part of the EGL 1.5 core specification
|
||||||
|
if (eglGetPlatformDisplayProc != nullptr) {
|
||||||
|
m_EGLDisplay = eglGetPlatformDisplayProc(platform, nativeDisplay, nullptr);
|
||||||
|
if (m_EGLDisplay == EGL_NO_DISPLAY) {
|
||||||
|
EGL_LOG(Warn, "eglGetPlatformDisplay() failed: %d", eglGetError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_EGLDisplay == EGL_NO_DISPLAY) {
|
||||||
|
// eglGetPlatformDisplayEXT() is an extension for EGL 1.4
|
||||||
|
const EGLExtensions eglExtensions(EGL_NO_DISPLAY);
|
||||||
|
if (eglExtensions.isSupported("EGL_EXT_platform_base")) {
|
||||||
|
if (eglGetPlatformDisplayEXTProc != nullptr) {
|
||||||
|
m_EGLDisplay = eglGetPlatformDisplayEXTProc(platform, nativeDisplay, nullptr);
|
||||||
|
if (m_EGLDisplay == EGL_NO_DISPLAY) {
|
||||||
|
EGL_LOG(Warn, "eglGetPlatformDisplayEXT() failed: %d", eglGetError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
EGL_LOG(Warn, "EGL_EXT_platform_base supported but no eglGetPlatformDisplayEXT() export!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_EGLDisplay == EGL_NO_DISPLAY) {
|
||||||
|
// Finally, if all else fails, use eglGetDisplay()
|
||||||
|
m_EGLDisplay = eglGetDisplay((EGLNativeDisplayType)nativeDisplay);
|
||||||
|
if (m_EGLDisplay == EGL_NO_DISPLAY) {
|
||||||
|
EGL_LOG(Error, "eglGetDisplay() failed: %d", eglGetError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_EGLDisplay != EGL_NO_DISPLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EGLRenderer::compileShader() {
|
||||||
|
SDL_assert(!m_ShaderProgram);
|
||||||
|
SDL_assert(m_SwPixelFormat != AV_PIX_FMT_NONE);
|
||||||
|
|
||||||
|
// XXX: TODO: other formats
|
||||||
|
SDL_assert(m_SwPixelFormat == AV_PIX_FMT_NV12);
|
||||||
|
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
|
GLuint vertexShader = loadAndBuildShader(GL_VERTEX_SHADER, "egl.vert");
|
||||||
|
if (!vertexShader)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GLuint fragmentShader = loadAndBuildShader(GL_FRAGMENT_SHADER, "egl.frag");
|
||||||
|
if (!fragmentShader)
|
||||||
|
goto fragError;
|
||||||
|
|
||||||
|
m_ShaderProgram = glCreateProgram();
|
||||||
|
if (!m_ShaderProgram) {
|
||||||
|
EGL_LOG(Error, "Cannot create shader program");
|
||||||
|
goto progFailCreate;
|
||||||
|
}
|
||||||
|
|
||||||
|
glAttachShader(m_ShaderProgram, vertexShader);
|
||||||
|
glAttachShader(m_ShaderProgram, fragmentShader);
|
||||||
|
glLinkProgram(m_ShaderProgram);
|
||||||
|
int status;
|
||||||
|
glGetProgramiv(m_ShaderProgram, GL_LINK_STATUS, &status);
|
||||||
|
if (status) {
|
||||||
|
ret = true;
|
||||||
|
} else {
|
||||||
|
char shader_log[512];
|
||||||
|
glGetProgramInfoLog(m_ShaderProgram, sizeof (shader_log), nullptr, shader_log);
|
||||||
|
EGL_LOG(Error, "Cannot link shader program: %s", shader_log);
|
||||||
|
glDeleteProgram(m_ShaderProgram);
|
||||||
|
m_ShaderProgram = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
progFailCreate:
|
||||||
|
glDeleteShader(fragmentShader);
|
||||||
|
fragError:
|
||||||
|
glDeleteShader(vertexShader);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EGLRenderer::initialize(PDECODER_PARAMETERS params)
|
||||||
|
{
|
||||||
|
m_Window = params->window;
|
||||||
|
|
||||||
|
if (params->videoFormat == VIDEO_FORMAT_H265_MAIN10) {
|
||||||
|
// EGL doesn't support rendering YUV 10-bit textures yet
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's not safe to attempt to opportunistically create a GLES2
|
||||||
|
// renderer prior to 2.0.10. If GLES2 isn't available, SDL will
|
||||||
|
// attempt to dereference a null pointer and crash Moonlight.
|
||||||
|
// https://bugzilla.libsdl.org/show_bug.cgi?id=4350
|
||||||
|
// https://hg.libsdl.org/SDL/rev/84618d571795
|
||||||
|
if (!SDL_VERSION_ATLEAST(2, 0, 10)) {
|
||||||
|
EGL_LOG(Error, "Not supported until SDL 2.0.10");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a dummy renderer in order to craft an accelerated SDL Window.
|
||||||
|
* Request opengl ES 3.0 context, otherwise it will SIGSEGV
|
||||||
|
* https://gitlab.freedesktop.org/mesa/mesa/issues/1011
|
||||||
|
*/
|
||||||
|
SDL_SetHint(SDL_HINT_OPENGL_ES_DRIVER, "1");
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
|
|
||||||
|
int renderIndex;
|
||||||
|
int maxRenderers = SDL_GetNumRenderDrivers();
|
||||||
|
SDL_assert(maxRenderers >= 0);
|
||||||
|
|
||||||
|
SDL_RendererInfo renderInfo;
|
||||||
|
for (renderIndex = 0; renderIndex < maxRenderers; ++renderIndex) {
|
||||||
|
if (SDL_GetRenderDriverInfo(renderIndex, &renderInfo))
|
||||||
|
continue;
|
||||||
|
if (!strcmp(renderInfo.name, "opengles2")) {
|
||||||
|
SDL_assert(renderInfo.flags & SDL_RENDERER_ACCELERATED);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (renderIndex == maxRenderers) {
|
||||||
|
EGL_LOG(Error, "Could not find a suitable SDL_Renderer");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(m_DummyRenderer = SDL_CreateRenderer(m_Window, renderIndex, SDL_RENDERER_ACCELERATED))) {
|
||||||
|
EGL_LOG(Error, "SDL_CreateRenderer() failed: %s", SDL_GetError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
if (!SDL_GetWindowWMInfo(params->window, &info)) {
|
||||||
|
EGL_LOG(Error, "SDL_GetWindowWMInfo() failed: %s", SDL_GetError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (info.subsystem) {
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_WAYLAND
|
||||||
|
case SDL_SYSWM_WAYLAND:
|
||||||
|
if (!openDisplay(EGL_PLATFORM_WAYLAND_KHR, info.info.wl.display)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_X11
|
||||||
|
case SDL_SYSWM_X11:
|
||||||
|
if (!openDisplay(EGL_PLATFORM_X11_KHR, info.info.x11.display)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
EGL_LOG(Error, "not compatible with SYSWM");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_EGLDisplay == EGL_NO_DISPLAY) {
|
||||||
|
EGL_LOG(Error, "Cannot get EGL display: %d", eglGetError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(m_Context = SDL_GL_CreateContext(params->window))) {
|
||||||
|
EGL_LOG(Error, "Cannot create OpenGL context: %s", SDL_GetError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (SDL_GL_MakeCurrent(params->window, m_Context)) {
|
||||||
|
EGL_LOG(Error, "Cannot use created EGL context: %s", SDL_GetError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const EGLExtensions eglExtensions(m_EGLDisplay);
|
||||||
|
if (!eglExtensions.isSupported("EGL_KHR_image_base") &&
|
||||||
|
!eglExtensions.isSupported("EGL_KHR_image")) {
|
||||||
|
EGL_LOG(Error, "EGL_KHR_image unsupported");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!SDL_GL_ExtensionSupported("GL_OES_EGL_image")) {
|
||||||
|
EGL_LOG(Error, "GL_OES_EGL_image unsupported");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_Backend->initializeEGL(m_EGLDisplay, eglExtensions))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(m_glEGLImageTargetTexture2DOES = (typeof(m_glEGLImageTargetTexture2DOES))eglGetProcAddress("glEGLImageTargetTexture2DOES"))) {
|
||||||
|
EGL_LOG(Error,
|
||||||
|
"EGL: cannot retrieve `glEGLImageTargetTexture2DOES` address");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vertex arrays are an extension on OpenGL ES 2.0
|
||||||
|
if (SDL_GL_ExtensionSupported("GL_OES_vertex_array_object")) {
|
||||||
|
m_glGenVertexArraysOES = (typeof(m_glGenVertexArraysOES))eglGetProcAddress("glGenVertexArraysOES");
|
||||||
|
m_glBindVertexArrayOES = (typeof(m_glBindVertexArrayOES))eglGetProcAddress("glBindVertexArrayOES");
|
||||||
|
m_glDeleteVertexArraysOES = (typeof(m_glDeleteVertexArraysOES))eglGetProcAddress("glDeleteVertexArraysOES");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// They are included in OpenGL ES 3.0 as part of the standard
|
||||||
|
m_glGenVertexArraysOES = (typeof(m_glGenVertexArraysOES))eglGetProcAddress("glGenVertexArrays");
|
||||||
|
m_glBindVertexArrayOES = (typeof(m_glBindVertexArrayOES))eglGetProcAddress("glBindVertexArray");
|
||||||
|
m_glDeleteVertexArraysOES = (typeof(m_glDeleteVertexArraysOES))eglGetProcAddress("glDeleteVertexArrays");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_glGenVertexArraysOES || !m_glBindVertexArrayOES || !m_glDeleteVertexArraysOES) {
|
||||||
|
EGL_LOG(Error, "Failed to find VAO functions");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compute the video region size in order to keep the aspect ratio of the
|
||||||
|
* video stream.
|
||||||
|
*/
|
||||||
|
SDL_Rect src, dst;
|
||||||
|
src.x = src.y = dst.x = dst.y = 0;
|
||||||
|
src.w = params->width;
|
||||||
|
src.h = params->height;
|
||||||
|
SDL_GetWindowSize(m_Window, &dst.w, &dst.h);
|
||||||
|
StreamUtils::scaleSourceToDestinationSurface(&src, &dst);
|
||||||
|
|
||||||
|
glViewport(dst.x, dst.y, dst.w, dst.h);
|
||||||
|
|
||||||
|
glClearColor(0, 0, 0, 1);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
if (params->enableVsync) {
|
||||||
|
// Try to use adaptive VSYNC unless we're using frame pacing.
|
||||||
|
// Frame pacing relies on us blocking in renderFrame() to
|
||||||
|
// match the display refresh rate.
|
||||||
|
if (params->enableFramePacing || SDL_GL_SetSwapInterval(-1)) {
|
||||||
|
SDL_GL_SetSwapInterval(1);
|
||||||
|
m_BlockingSwapBuffers = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SDL_GL_SetSwapInterval(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_GL_SwapWindow(params->window);
|
||||||
|
|
||||||
|
glGenTextures(EGL_MAX_PLANES, m_Textures);
|
||||||
|
for (size_t i = 0; i < EGL_MAX_PLANES; ++i) {
|
||||||
|
glBindTexture(GL_TEXTURE_EXTERNAL_OES, m_Textures[i]);
|
||||||
|
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLenum err = glGetError();
|
||||||
|
if (err != GL_NO_ERROR)
|
||||||
|
EGL_LOG(Error, "OpenGL error: %d", err);
|
||||||
|
|
||||||
|
// Detach the context from this thread, so the render thread can attach it
|
||||||
|
SDL_GL_MakeCurrent(m_Window, nullptr);
|
||||||
|
|
||||||
|
return err == GL_NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float *EGLRenderer::getColorMatrix() {
|
||||||
|
/* The conversion matrices are shamelessly stolen from linux:
|
||||||
|
* drivers/media/platform/imx-pxp.c:pxp_setup_csc
|
||||||
|
*/
|
||||||
|
static const float bt601Lim[] = {
|
||||||
|
1.1644f, 1.1644f, 1.1644f,
|
||||||
|
0.0f, -0.3917f, 2.0172f,
|
||||||
|
1.5960f, -0.8129f, 0.0f
|
||||||
|
};
|
||||||
|
static const float bt601Full[] = {
|
||||||
|
1.0f, 1.0f, 1.0f,
|
||||||
|
0.0f, -0.3441f, 1.7720f,
|
||||||
|
1.4020f, -0.7141f, 0.0f
|
||||||
|
};
|
||||||
|
static const float bt709Lim[] = {
|
||||||
|
1.1644f, 1.1644f, 1.1644f,
|
||||||
|
0.0f, -0.2132f, 2.1124f,
|
||||||
|
1.7927f, -0.5329f, 0.0f
|
||||||
|
};
|
||||||
|
static const float bt709Full[] = {
|
||||||
|
1.0f, 1.0f, 1.0f,
|
||||||
|
0.0f, -0.1873f, 1.8556f,
|
||||||
|
1.5748f, -0.4681f, 0.0f
|
||||||
|
};
|
||||||
|
static const float bt2020Lim[] = {
|
||||||
|
1.1644f, 1.1644f, 1.1644f,
|
||||||
|
0.0f, -0.1874f, 2.1418f,
|
||||||
|
1.6781f, -0.6505f, 0.0f
|
||||||
|
};
|
||||||
|
static const float bt2020Full[] = {
|
||||||
|
1.0f, 1.0f, 1.0f,
|
||||||
|
0.0f, -0.1646f, 1.8814f,
|
||||||
|
1.4746f, -0.5714f, 0.0f
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
EGL_LOG(Warn, "unknown color space: %d, falling back to BT-601",
|
||||||
|
m_ColorSpace);
|
||||||
|
return bt601Lim;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EGLRenderer::specialize() {
|
||||||
|
SDL_assert(!m_VAO);
|
||||||
|
|
||||||
|
// Attach our GL context to the render thread
|
||||||
|
SDL_GL_MakeCurrent(m_Window, m_Context);
|
||||||
|
|
||||||
|
if (!compileShader())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// The viewport should have the aspect ratio of the video stream
|
||||||
|
static const float vertices[] = {
|
||||||
|
// pos .... // tex coords
|
||||||
|
1.0f, 1.0f, 1.0f, 0.0f,
|
||||||
|
1.0f, -1.0f, 1.0f, 1.0f,
|
||||||
|
-1.0f, -1.0f, 0.0f, 1.0f,
|
||||||
|
-1.0f, 1.0f, 0.0f, 0.0f,
|
||||||
|
|
||||||
|
};
|
||||||
|
static const unsigned int indices[] = {
|
||||||
|
0, 1, 3,
|
||||||
|
1, 2, 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
glUseProgram(m_ShaderProgram);
|
||||||
|
|
||||||
|
unsigned int VBO, EBO;
|
||||||
|
m_glGenVertexArraysOES(1, &m_VAO);
|
||||||
|
glGenBuffers(1, &VBO);
|
||||||
|
glGenBuffers(1, &EBO);
|
||||||
|
|
||||||
|
m_glBindVertexArrayOES(m_VAO);
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, sizeof (vertices), vertices, GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
|
||||||
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices, GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)0);
|
||||||
|
glEnableVertexAttribArray(0);
|
||||||
|
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2 * sizeof (float)));
|
||||||
|
glEnableVertexAttribArray(1);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
GLenum err = glGetError();
|
||||||
|
if (err != GL_NO_ERROR) {
|
||||||
|
EGL_LOG(Error, "OpenGL error: %d", err);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err == GL_NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EGLRenderer::renderFrame(AVFrame* frame)
|
||||||
|
{
|
||||||
|
EGLImage imgs[EGL_MAX_PLANES];
|
||||||
|
|
||||||
|
if (frame == nullptr) {
|
||||||
|
// End of stream - unbind the GL context
|
||||||
|
SDL_GL_MakeCurrent(m_Window, nullptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frame->hw_frames_ctx != nullptr) {
|
||||||
|
// Find the native read-back format and load the shader
|
||||||
|
if (m_SwPixelFormat == AV_PIX_FMT_NONE) {
|
||||||
|
auto hwFrameCtx = (AVHWFramesContext*)frame->hw_frames_ctx->data;
|
||||||
|
|
||||||
|
m_SwPixelFormat = hwFrameCtx->sw_format;
|
||||||
|
SDL_assert(m_SwPixelFormat != AV_PIX_FMT_NONE);
|
||||||
|
|
||||||
|
EGL_LOG(Info, "Selected read-back format: %d", m_SwPixelFormat);
|
||||||
|
|
||||||
|
// XXX: TODO: Handle other pixel formats
|
||||||
|
SDL_assert(m_SwPixelFormat == AV_PIX_FMT_NV12);
|
||||||
|
m_ColorSpace = frame->colorspace;
|
||||||
|
m_ColorFull = frame->color_range == AVCOL_RANGE_JPEG;
|
||||||
|
|
||||||
|
if (!specialize()) {
|
||||||
|
m_SwPixelFormat = AV_PIX_FMT_NONE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t plane_count = m_Backend->exportEGLImages(frame, m_EGLDisplay, imgs);
|
||||||
|
if (plane_count < 0)
|
||||||
|
return;
|
||||||
|
for (ssize_t i = 0; i < plane_count; ++i) {
|
||||||
|
glActiveTexture(GL_TEXTURE0 + i);
|
||||||
|
glBindTexture(GL_TEXTURE_EXTERNAL_OES, m_Textures[i]);
|
||||||
|
m_glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, imgs[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// TODO: load texture for SW decoding ?
|
||||||
|
EGL_LOG(Error, "EGL rendering only supports hw frames");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
glUseProgram(m_ShaderProgram);
|
||||||
|
m_glBindVertexArrayOES(m_VAO);
|
||||||
|
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||||
|
|
||||||
|
SDL_GL_SwapWindow(m_Window);
|
||||||
|
|
||||||
|
if (m_BlockingSwapBuffers) {
|
||||||
|
// This glClear() forces us to block until the buffer swap is
|
||||||
|
// complete to continue rendering. Mesa won't actually wait
|
||||||
|
// for the swap with just glFinish() alone. Waiting here keeps us
|
||||||
|
// in lock step with the display refresh rate. If we don't wait
|
||||||
|
// here, we'll stall on the first GL call next frame. Doing the
|
||||||
|
// wait here instead allows more time for a newer frame to arrive
|
||||||
|
// for next renderFrame() call.
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
glFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frame->hw_frames_ctx != nullptr)
|
||||||
|
m_Backend->freeEGLImages(m_EGLDisplay, imgs);
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "renderer.h"
|
||||||
|
|
||||||
|
#include <SDL_opengles2.h>
|
||||||
|
#include <SDL_opengles2_gl2ext.h>
|
||||||
|
|
||||||
|
class EGLRenderer : public IFFmpegRenderer {
|
||||||
|
public:
|
||||||
|
EGLRenderer(IFFmpegRenderer *backendRenderer);
|
||||||
|
virtual ~EGLRenderer() override;
|
||||||
|
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 isPixelFormatSupported(int videoFormat, enum AVPixelFormat pixelFormat) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool compileShader();
|
||||||
|
bool specialize();
|
||||||
|
const float *getColorMatrix();
|
||||||
|
static int loadAndBuildShader(int shaderType, const char *filename);
|
||||||
|
bool openDisplay(unsigned int platform, void* nativeDisplay);
|
||||||
|
|
||||||
|
int m_SwPixelFormat;
|
||||||
|
void *m_EGLDisplay;
|
||||||
|
unsigned m_Textures[EGL_MAX_PLANES];
|
||||||
|
unsigned m_ShaderProgram;
|
||||||
|
SDL_GLContext m_Context;
|
||||||
|
SDL_Window *m_Window;
|
||||||
|
IFFmpegRenderer *m_Backend;
|
||||||
|
unsigned int m_VAO;
|
||||||
|
int m_ColorSpace;
|
||||||
|
bool m_ColorFull;
|
||||||
|
bool m_BlockingSwapBuffers;
|
||||||
|
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_glEGLImageTargetTexture2DOES;
|
||||||
|
PFNGLGENVERTEXARRAYSOESPROC m_glGenVertexArraysOES;
|
||||||
|
PFNGLBINDVERTEXARRAYOESPROC m_glBindVertexArrayOES;
|
||||||
|
PFNGLDELETEVERTEXARRAYSOESPROC m_glDeleteVertexArraysOES;
|
||||||
|
|
||||||
|
int m_OldContextProfileMask;
|
||||||
|
int m_OldContextMajorVersion;
|
||||||
|
int m_OldContextMinorVersion;
|
||||||
|
|
||||||
|
SDL_Renderer *m_DummyRenderer;
|
||||||
|
};
|
||||||
@@ -22,9 +22,16 @@ MmalRenderer::~MmalRenderer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MmalRenderer::prepareDecoderContext(AVCodecContext*)
|
bool MmalRenderer::prepareDecoderContext(AVCodecContext* context, AVDictionary** options)
|
||||||
{
|
{
|
||||||
/* Nothing to do */
|
// FFmpeg defaults this to 10 which is too large to fit in the default 64 MB VRAM split.
|
||||||
|
// Reducing to 2 seems to work fine for our bitstreams (max of 1 buffered frame needed).
|
||||||
|
av_dict_set_int(options, "extra_buffers", 2, 0);
|
||||||
|
|
||||||
|
// MMAL seems to dislike certain initial width and height values, but it seems okay
|
||||||
|
// with getting zero for the width and height. We'll zero them all the time to be safe.
|
||||||
|
context->width = 0;
|
||||||
|
context->height = 0;
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Using MMAL renderer");
|
"Using MMAL renderer");
|
||||||
@@ -82,7 +89,7 @@ bool MmalRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
dr.alpha = 255;
|
dr.alpha = 255;
|
||||||
|
|
||||||
dr.set |= MMAL_DISPLAY_SET_FULLSCREEN;
|
dr.set |= MMAL_DISPLAY_SET_FULLSCREEN;
|
||||||
dr.fullscreen = (SDL_GetWindowFlags(params->window) & SDL_WINDOW_FULLSCREEN) != 0;
|
dr.fullscreen = true;
|
||||||
|
|
||||||
{
|
{
|
||||||
SDL_Rect src, dst;
|
SDL_Rect src, dst;
|
||||||
@@ -125,6 +132,12 @@ enum AVPixelFormat MmalRenderer::getPreferredPixelFormat(int videoFormat)
|
|||||||
return AV_PIX_FMT_MMAL;
|
return AV_PIX_FMT_MMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MmalRenderer::getRendererAttributes()
|
||||||
|
{
|
||||||
|
// This renderer can only draw in full-screen and maxes out at 1080p
|
||||||
|
return RENDERER_ATTRIBUTE_FULLSCREEN_ONLY | RENDERER_ATTRIBUTE_1080P_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
bool MmalRenderer::needsTestFrame()
|
bool MmalRenderer::needsTestFrame()
|
||||||
{
|
{
|
||||||
// We won't be able to decode if the GPU memory is 64 MB or lower,
|
// We won't be able to decode if the GPU memory is 64 MB or lower,
|
||||||
@@ -134,6 +147,11 @@ bool MmalRenderer::needsTestFrame()
|
|||||||
|
|
||||||
void MmalRenderer::renderFrame(AVFrame* frame)
|
void MmalRenderer::renderFrame(AVFrame* frame)
|
||||||
{
|
{
|
||||||
|
if (frame == nullptr) {
|
||||||
|
// End of stream - nothing to do for us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MMAL_BUFFER_HEADER_T* buffer = (MMAL_BUFFER_HEADER_T*)frame->data[3];
|
MMAL_BUFFER_HEADER_T* buffer = (MMAL_BUFFER_HEADER_T*)frame->data[3];
|
||||||
MMAL_STATUS_T status;
|
MMAL_STATUS_T status;
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ public:
|
|||||||
MmalRenderer();
|
MmalRenderer();
|
||||||
virtual ~MmalRenderer() override;
|
virtual ~MmalRenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
|
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
|
||||||
virtual bool needsTestFrame() override;
|
virtual bool needsTestFrame() override;
|
||||||
|
virtual int getRendererAttributes() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void InputPortCallback(MMAL_PORT_T* port, MMAL_BUFFER_HEADER_T* buffer);
|
static void InputPortCallback(MMAL_PORT_T* port, MMAL_BUFFER_HEADER_T* buffer);
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ Pacer::~Pacer()
|
|||||||
m_RenderQueueNotEmpty.wakeAll();
|
m_RenderQueueNotEmpty.wakeAll();
|
||||||
SDL_WaitThread(m_RenderThread, nullptr);
|
SDL_WaitThread(m_RenderThread, nullptr);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Send a null AVFrame to indicate end of stream on the main thread
|
||||||
|
m_VsyncRenderer->renderFrame(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
// Delete any remaining unconsumed frames
|
// Delete any remaining unconsumed frames
|
||||||
while (!m_RenderQueue.isEmpty()) {
|
while (!m_RenderQueue.isEmpty()) {
|
||||||
@@ -106,6 +110,9 @@ int Pacer::renderThread(void* context)
|
|||||||
me->renderLastFrameAndUnlock();
|
me->renderLastFrameAndUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send a null AVFrame to indicate end of stream on the render thread
|
||||||
|
me->m_VsyncRenderer->renderFrame(nullptr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,30 @@ extern "C" {
|
|||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_EGL
|
||||||
|
// SDL_egl.h have too many conflicts, we will do without
|
||||||
|
typedef void *EGLDisplay;
|
||||||
|
typedef void *EGLImage;
|
||||||
|
#define EGL_MAX_PLANES 4
|
||||||
|
|
||||||
|
class EGLExtensions {
|
||||||
|
public:
|
||||||
|
EGLExtensions(EGLDisplay dpy);
|
||||||
|
~EGLExtensions() {}
|
||||||
|
bool isSupported(const QString &extension) const;
|
||||||
|
private:
|
||||||
|
const QStringList m_Extensions;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RENDERER_ATTRIBUTE_FULLSCREEN_ONLY 0x01
|
||||||
|
#define RENDERER_ATTRIBUTE_1080P_MAX 0x02
|
||||||
|
|
||||||
class IFFmpegRenderer : public Overlay::IOverlayRenderer {
|
class IFFmpegRenderer : public Overlay::IOverlayRenderer {
|
||||||
public:
|
public:
|
||||||
enum FramePacingConstraint {
|
|
||||||
PACING_FORCE_OFF,
|
|
||||||
PACING_FORCE_ON,
|
|
||||||
PACING_ANY
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) = 0;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) = 0;
|
||||||
virtual void renderFrame(AVFrame* frame) = 0;
|
virtual void renderFrame(AVFrame* frame) = 0;
|
||||||
|
|
||||||
virtual bool needsTestFrame() {
|
virtual bool needsTestFrame() {
|
||||||
@@ -31,16 +45,16 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual int getRendererAttributes() {
|
||||||
|
// No special attributes by default
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
virtual int getDecoderColorspace() {
|
virtual int getDecoderColorspace() {
|
||||||
// Rec 601 is default
|
// Rec 601 is default
|
||||||
return COLORSPACE_REC_601;
|
return COLORSPACE_REC_601;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual FramePacingConstraint getFramePacingConstraint() {
|
|
||||||
// No pacing preference
|
|
||||||
return PACING_ANY;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool isRenderThreadSupported() {
|
virtual bool isRenderThreadSupported() {
|
||||||
// Render thread is supported by default
|
// Render thread is supported by default
|
||||||
return true;
|
return true;
|
||||||
@@ -62,8 +76,34 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool isPixelFormatSupported(int videoFormat, enum AVPixelFormat pixelFormat) {
|
||||||
|
// By default, we only support the preferred pixel format
|
||||||
|
return getPreferredPixelFormat(videoFormat) == pixelFormat;
|
||||||
|
}
|
||||||
|
|
||||||
// IOverlayRenderer
|
// IOverlayRenderer
|
||||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override {
|
virtual void notifyOverlayUpdated(Overlay::OverlayType) override {
|
||||||
// Nothing
|
// Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_EGL
|
||||||
|
// By default we can't do EGL
|
||||||
|
virtual bool canExportEGL() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool initializeEGL(EGLDisplay,
|
||||||
|
const EGLExtensions &) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ssize_t exportEGLImages(AVFrame *,
|
||||||
|
EGLDisplay,
|
||||||
|
EGLImage[EGL_MAX_PLANES]) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Free the ressources allocated during the last `exportEGLImages` call
|
||||||
|
virtual void freeEGLImages(EGLDisplay, EGLImage[EGL_MAX_PLANES]) {}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "sdlvid.h"
|
#include "sdlvid.h"
|
||||||
|
|
||||||
#include "streaming/session.h"
|
#include "streaming/session.h"
|
||||||
|
#include "streaming/streamutils.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -58,7 +59,7 @@ SdlRenderer::~SdlRenderer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SdlRenderer::prepareDecoderContext(AVCodecContext*)
|
bool SdlRenderer::prepareDecoderContext(AVCodecContext*, AVDictionary**)
|
||||||
{
|
{
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
|
|
||||||
@@ -127,14 +128,19 @@ bool SdlRenderer::isRenderThreadSupported()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SdlRenderer::getDecoderCapabilities()
|
bool SdlRenderer::isPixelFormatSupported(int, AVPixelFormat pixelFormat)
|
||||||
{
|
{
|
||||||
// Slice up to 4 times for parallel decode, once slice per core
|
// Remember to keep this in sync with SdlRenderer::renderFrame()!
|
||||||
int slices = qMin(MAX_SLICES, SDL_GetCPUCount());
|
switch (pixelFormat)
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
{
|
||||||
"Encoder configured for %d slices per frame",
|
case AV_PIX_FMT_YUV420P:
|
||||||
slices);
|
case AV_PIX_FMT_NV12:
|
||||||
return CAPABILITY_SLICES_PER_FRAME(slices);
|
case AV_PIX_FMT_NV21:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SdlRenderer::initialize(PDECODER_PARAMETERS params)
|
bool SdlRenderer::initialize(PDECODER_PARAMETERS params)
|
||||||
@@ -171,9 +177,26 @@ bool SdlRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The window may be smaller than the stream size, so ensure our
|
// SDL_CreateRenderer() can end up having to recreate our window (SDL_RecreateWindow())
|
||||||
// logical rendering surface size is equal to the stream size
|
// to ensure it's compatible with the renderer's OpenGL context. If that happens, we
|
||||||
SDL_RenderSetLogicalSize(m_Renderer, params->width, params->height);
|
// 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);
|
||||||
|
|
||||||
|
// Calculate the video region size, scaling to fill the output size while
|
||||||
|
// preserving the aspect ratio of the video stream.
|
||||||
|
SDL_Rect src, dst;
|
||||||
|
src.x = src.y = 0;
|
||||||
|
src.w = params->width;
|
||||||
|
src.h = params->height;
|
||||||
|
dst.x = dst.y = 0;
|
||||||
|
SDL_GetRendererOutputSize(m_Renderer, &dst.w, &dst.h);
|
||||||
|
StreamUtils::scaleSourceToDestinationSurface(&src, &dst);
|
||||||
|
|
||||||
|
// Ensure the viewport is set to the desired video region
|
||||||
|
SDL_RenderSetViewport(m_Renderer, &dst);
|
||||||
|
|
||||||
// Draw a black frame until the video stream starts rendering
|
// Draw a black frame until the video stream starts rendering
|
||||||
SDL_SetRenderDrawColor(m_Renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
SDL_SetRenderDrawColor(m_Renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
||||||
@@ -206,10 +229,10 @@ void SdlRenderer::renderOverlay(Overlay::OverlayType type)
|
|||||||
|
|
||||||
if (type == Overlay::OverlayStatusUpdate) {
|
if (type == Overlay::OverlayStatusUpdate) {
|
||||||
// Bottom Left
|
// Bottom Left
|
||||||
int unused;
|
SDL_Rect viewportRect;
|
||||||
SDL_RenderGetLogicalSize(m_Renderer, &unused, &m_OverlayRects[type].y);
|
SDL_RenderGetViewport(m_Renderer, &viewportRect);
|
||||||
m_OverlayRects[type].x = 0;
|
m_OverlayRects[type].x = 0;
|
||||||
m_OverlayRects[type].y -= surface->h;
|
m_OverlayRects[type].y = viewportRect.h - surface->h;
|
||||||
}
|
}
|
||||||
else if (type == Overlay::OverlayDebug) {
|
else if (type == Overlay::OverlayDebug) {
|
||||||
// Top left
|
// Top left
|
||||||
@@ -236,6 +259,11 @@ void SdlRenderer::renderFrame(AVFrame* frame)
|
|||||||
int err;
|
int err;
|
||||||
AVFrame* swFrame = nullptr;
|
AVFrame* swFrame = nullptr;
|
||||||
|
|
||||||
|
if (frame == nullptr) {
|
||||||
|
// End of stream - nothing to do for us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (frame->hw_frames_ctx != nullptr) {
|
if (frame->hw_frames_ctx != nullptr) {
|
||||||
// If we are acting as the frontend for a hardware
|
// If we are acting as the frontend for a hardware
|
||||||
// accelerated decoder, we'll need to read the frame
|
// accelerated decoder, we'll need to read the frame
|
||||||
@@ -281,6 +309,7 @@ void SdlRenderer::renderFrame(AVFrame* frame)
|
|||||||
if (m_Texture == nullptr) {
|
if (m_Texture == nullptr) {
|
||||||
Uint32 sdlFormat;
|
Uint32 sdlFormat;
|
||||||
|
|
||||||
|
// Remember to keep this in sync with SdlRenderer::isPixelFormatSupported()!
|
||||||
switch (frame->format)
|
switch (frame->format)
|
||||||
{
|
{
|
||||||
case AV_PIX_FMT_YUV420P:
|
case AV_PIX_FMT_YUV420P:
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ public:
|
|||||||
SdlRenderer();
|
SdlRenderer();
|
||||||
virtual ~SdlRenderer() override;
|
virtual ~SdlRenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
||||||
virtual bool isRenderThreadSupported() override;
|
virtual bool isRenderThreadSupported() override;
|
||||||
virtual int getDecoderCapabilities() override;
|
virtual bool isPixelFormatSupported(int videoFormat, enum AVPixelFormat pixelFormat) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void renderOverlay(Overlay::OverlayType type);
|
void renderOverlay(Overlay::OverlayType type);
|
||||||
|
|||||||
@@ -1,18 +1,27 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "vaapi.h"
|
#include "vaapi.h"
|
||||||
|
#include "utils.h"
|
||||||
#include <streaming/streamutils.h>
|
#include <streaming/streamutils.h>
|
||||||
|
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
|
#ifdef HAVE_EGL
|
||||||
|
#include <SDL_egl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
VAAPIRenderer::VAAPIRenderer()
|
VAAPIRenderer::VAAPIRenderer()
|
||||||
: m_HwContext(nullptr),
|
: m_HwContext(nullptr),
|
||||||
m_DrmFd(-1)
|
m_DrmFd(-1),
|
||||||
|
m_BlacklistedForDirectRendering(false)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_EGL
|
||||||
|
m_PrimeDescriptor.num_layers = 0;
|
||||||
|
m_PrimeDescriptor.num_objects = 0;
|
||||||
|
m_EGLExtDmaBuf = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
VAAPIRenderer::~VAAPIRenderer()
|
VAAPIRenderer::~VAAPIRenderer()
|
||||||
@@ -36,26 +45,106 @@ VAAPIRenderer::~VAAPIRenderer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VADisplay
|
||||||
|
VAAPIRenderer::openDisplay(SDL_Window* window)
|
||||||
|
{
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
VADisplay display;
|
||||||
|
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
|
||||||
|
if (!SDL_GetWindowWMInfo(window, &info)) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"SDL_GetWindowWMInfo() failed: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_WindowSystem = info.subsystem;
|
||||||
|
if (info.subsystem == SDL_SYSWM_X11) {
|
||||||
|
m_XWindow = info.info.x11.window;
|
||||||
|
#ifdef HAVE_LIBVA_X11
|
||||||
|
display = vaGetDisplay(info.info.x11.display);
|
||||||
|
if (display == nullptr) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unable to open X11 display for VAAPI");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Moonlight not compiled with VAAPI X11 support!");
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (info.subsystem == SDL_SYSWM_WAYLAND) {
|
||||||
|
#ifdef HAVE_LIBVA_WAYLAND
|
||||||
|
display = vaGetDisplayWl(info.info.wl.display);
|
||||||
|
if (display == nullptr) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unable to open Wayland display for VAAPI");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Moonlight not compiled with VAAPI Wayland support!");
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
// TODO: Upstream a better solution for SDL_GetWindowWMInfo on KMSDRM
|
||||||
|
else if (strcmp(SDL_GetCurrentVideoDriver(), "KMSDRM") == 0) {
|
||||||
|
#ifdef HAVE_LIBVA_DRM
|
||||||
|
if (m_DrmFd < 0) {
|
||||||
|
const char* device = SDL_getenv("DRM_DEV");
|
||||||
|
|
||||||
|
if (device == nullptr) {
|
||||||
|
device = "/dev/dri/card0";
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Opening DRM device: %s",
|
||||||
|
device);
|
||||||
|
|
||||||
|
m_DrmFd = open(device, O_RDWR | O_CLOEXEC);
|
||||||
|
if (m_DrmFd < 0) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Failed to open DRM device: %d",
|
||||||
|
errno);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
display = vaGetDisplayDRM(m_DrmFd);
|
||||||
|
if (display == nullptr) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unable to open DRM display for VAAPI");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Moonlight not compiled with VAAPI DRM support!");
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unsupported VAAPI rendering subsystem: %d",
|
||||||
|
info.subsystem);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
SDL_SysWMinfo info;
|
|
||||||
|
|
||||||
m_VideoWidth = params->width;
|
m_VideoWidth = params->width;
|
||||||
m_VideoHeight = params->height;
|
m_VideoHeight = params->height;
|
||||||
|
|
||||||
SDL_GetWindowSize(params->window, &m_DisplayWidth, &m_DisplayHeight);
|
SDL_GetWindowSize(params->window, &m_DisplayWidth, &m_DisplayHeight);
|
||||||
|
|
||||||
SDL_VERSION(&info.version);
|
|
||||||
|
|
||||||
if (!SDL_GetWindowWMInfo(params->window, &info)) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"SDL_GetWindowWMInfo() failed: %s",
|
|
||||||
SDL_GetError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_HwContext = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VAAPI);
|
m_HwContext = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VAAPI);
|
||||||
if (!m_HwContext) {
|
if (!m_HwContext) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
@@ -66,79 +155,93 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
AVHWDeviceContext* deviceContext = (AVHWDeviceContext*)m_HwContext->data;
|
AVHWDeviceContext* deviceContext = (AVHWDeviceContext*)m_HwContext->data;
|
||||||
AVVAAPIDeviceContext* vaDeviceContext = (AVVAAPIDeviceContext*)deviceContext->hwctx;
|
AVVAAPIDeviceContext* vaDeviceContext = (AVVAAPIDeviceContext*)deviceContext->hwctx;
|
||||||
|
|
||||||
m_WindowSystem = info.subsystem;
|
vaDeviceContext->display = openDisplay(params->window);
|
||||||
if (info.subsystem == SDL_SYSWM_X11) {
|
if (vaDeviceContext->display == nullptr) {
|
||||||
#ifdef HAVE_LIBVA_X11
|
// openDisplay() logs the error
|
||||||
m_XWindow = info.info.x11.window;
|
|
||||||
vaDeviceContext->display = vaGetDisplay(info.info.x11.display);
|
|
||||||
if (!vaDeviceContext->display) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Unable to open X11 display for VAAPI");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Moonlight not compiled with VAAPI X11 support!");
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (info.subsystem == SDL_SYSWM_WAYLAND) {
|
|
||||||
#ifdef HAVE_LIBVA_WAYLAND
|
|
||||||
vaDeviceContext->display = vaGetDisplayWl(info.info.wl.display);
|
|
||||||
if (!vaDeviceContext->display) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Unable to open Wayland display for VAAPI");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Moonlight not compiled with VAAPI Wayland support!");
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
// TODO: Upstream a better solution for SDL_GetWindowWMInfo on KMSDRM
|
|
||||||
else if (strcmp(SDL_GetCurrentVideoDriver(), "KMSDRM") == 0) {
|
|
||||||
#ifdef HAVE_LIBVA_DRM
|
|
||||||
const char* device = SDL_getenv("DRM_DEV");
|
|
||||||
|
|
||||||
if (device == nullptr) {
|
|
||||||
device = "/dev/dri/card0";
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Opening DRM device: %s",
|
|
||||||
device);
|
|
||||||
|
|
||||||
m_DrmFd = open(device, O_RDWR | O_CLOEXEC);
|
|
||||||
if (m_DrmFd < 0) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Failed to open DRM device: %d",
|
|
||||||
errno);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
vaDeviceContext->display = vaGetDisplayDRM(m_DrmFd);
|
|
||||||
if (!vaDeviceContext->display) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Unable to open DRM display for VAAPI");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Moonlight not compiled with VAAPI DRM support!");
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Unsupported VAAPI rendering subsystem: %d",
|
|
||||||
info.subsystem);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int major, minor;
|
int major, minor;
|
||||||
VAStatus status;
|
VAStatus status;
|
||||||
status = vaInitialize(vaDeviceContext->display, &major, &minor);
|
bool setPathVar = false;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
status = vaInitialize(vaDeviceContext->display, &major, &minor);
|
||||||
|
if (status != VA_STATUS_SUCCESS && qEnvironmentVariableIsEmpty("LIBVA_DRIVER_NAME")) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Trying fallback VAAPI driver names");
|
||||||
|
|
||||||
|
// It would be nice to use vaSetDriverName() here, but there's no way to unset
|
||||||
|
// it and get back to the default driver selection logic once we've overridden
|
||||||
|
// the driver name using that API. As a result, we must use LIBVA_DRIVER_NAME.
|
||||||
|
|
||||||
|
if (status != VA_STATUS_SUCCESS) {
|
||||||
|
// The iHD driver supports newer hardware like Ice Lake and Comet Lake.
|
||||||
|
// It should be picked by default on those platforms, but that doesn't
|
||||||
|
// always seem to be the case for some reason.
|
||||||
|
qputenv("LIBVA_DRIVER_NAME", "iHD");
|
||||||
|
status = vaInitialize(vaDeviceContext->display, &major, &minor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status != VA_STATUS_SUCCESS) {
|
||||||
|
// The Iris driver in Mesa 20.0 returns a bogus VA driver (iris_drv_video.so)
|
||||||
|
// even though the correct driver is still i965. If we hit this path, we'll
|
||||||
|
// explicitly try i965 to handle this case.
|
||||||
|
qputenv("LIBVA_DRIVER_NAME", "i965");
|
||||||
|
status = vaInitialize(vaDeviceContext->display, &major, &minor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status != VA_STATUS_SUCCESS) {
|
||||||
|
// The RadeonSI driver is compatible with XWayland but can't be detected by libva
|
||||||
|
// so try it too if all else fails.
|
||||||
|
qputenv("LIBVA_DRIVER_NAME", "radeonsi");
|
||||||
|
status = vaInitialize(vaDeviceContext->display, &major, &minor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status != VA_STATUS_SUCCESS) {
|
||||||
|
// Unset LIBVA_DRIVER_NAME if none of the drivers we tried worked. This ensures
|
||||||
|
// we will get a fresh start using the default driver selection behavior after
|
||||||
|
// setting LIBVA_DRIVERS_PATH in the code below.
|
||||||
|
qunsetenv("LIBVA_DRIVER_NAME");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == VA_STATUS_SUCCESS) {
|
||||||
|
// Success!
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qEnvironmentVariableIsEmpty("LIBVA_DRIVERS_PATH")) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Trying fallback VAAPI driver paths");
|
||||||
|
|
||||||
|
qputenv("LIBVA_DRIVERS_PATH",
|
||||||
|
#if Q_PROCESSOR_WORDSIZE == 8
|
||||||
|
"/usr/lib64/dri:" // Fedora x86_64
|
||||||
|
"/usr/lib64/va/drivers:" // Gentoo x86_64
|
||||||
|
#endif
|
||||||
|
"/usr/lib/dri:" // Arch i386 & x86_64, Fedora i386
|
||||||
|
"/usr/lib/va/drivers:" // Gentoo i386
|
||||||
|
#if defined(Q_PROCESSOR_X86_64)
|
||||||
|
"/usr/lib/x86_64-linux-gnu/dri:" // Ubuntu/Debian x86_64
|
||||||
|
#elif defined(Q_PROCESSOR_X86_32)
|
||||||
|
"/usr/lib/i386-linux-gnu/dri:" // Ubuntu/Debian i386
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
setPathVar = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (setPathVar) {
|
||||||
|
// Unset LIBVA_DRIVERS_PATH if we set it ourselves
|
||||||
|
// and we didn't find any working VAAPI drivers.
|
||||||
|
qunsetenv("LIBVA_DRIVERS_PATH");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Give up
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (status != VA_STATUS_SUCCESS) {
|
if (status != VA_STATUS_SUCCESS) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Failed to initialize VAAPI: %d",
|
"Failed to initialize VAAPI: %d",
|
||||||
@@ -151,6 +254,7 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
major, minor);
|
major, minor);
|
||||||
|
|
||||||
const char* vendorString = vaQueryVendorString(vaDeviceContext->display);
|
const char* vendorString = vaQueryVendorString(vaDeviceContext->display);
|
||||||
|
QString vendorStr(vendorString);
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Driver: %s",
|
"Driver: %s",
|
||||||
vendorString ? vendorString : "<unknown>");
|
vendorString ? vendorString : "<unknown>");
|
||||||
@@ -159,9 +263,8 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
// to be leaked for each submitted frame. The Flatpak runtime has a VDPAU
|
// to be leaked for each submitted frame. The Flatpak runtime has a VDPAU
|
||||||
// driver in place that works well, so use that instead on AMD systems. If
|
// driver in place that works well, so use that instead on AMD systems. If
|
||||||
// we're using Wayland, we have no choice but to use VAAPI because VDPAU
|
// we're using Wayland, we have no choice but to use VAAPI because VDPAU
|
||||||
// is only supported under X11.
|
// is only supported under X11 or XWayland.
|
||||||
if (vendorString && qgetenv("FORCE_VAAPI") != "1" && m_WindowSystem == SDL_SYSWM_X11) {
|
if (qgetenv("FORCE_VAAPI") != "1" && !WMUtils::isRunningWayland()) {
|
||||||
QString vendorStr(vendorString);
|
|
||||||
if (vendorStr.contains("AMD", Qt::CaseInsensitive) ||
|
if (vendorStr.contains("AMD", Qt::CaseInsensitive) ||
|
||||||
vendorStr.contains("Radeon", Qt::CaseInsensitive)) {
|
vendorStr.contains("Radeon", Qt::CaseInsensitive)) {
|
||||||
// Fail and let VDPAU pick this up
|
// Fail and let VDPAU pick this up
|
||||||
@@ -171,6 +274,12 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (WMUtils::isRunningWayland()) {
|
||||||
|
// The iHD VAAPI driver can initialize on XWayland but it crashes in
|
||||||
|
// vaPutSurface() so we must also not directly render on XWayland.
|
||||||
|
m_BlacklistedForDirectRendering = vendorStr.contains("iHD");
|
||||||
|
}
|
||||||
|
|
||||||
// This will populate the driver_quirks
|
// This will populate the driver_quirks
|
||||||
err = av_hwdevice_ctx_init(m_HwContext);
|
err = av_hwdevice_ctx_init(m_HwContext);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
@@ -192,7 +301,7 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
VAAPIRenderer::prepareDecoderContext(AVCodecContext* context)
|
VAAPIRenderer::prepareDecoderContext(AVCodecContext* context, AVDictionary**)
|
||||||
{
|
{
|
||||||
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
||||||
|
|
||||||
@@ -214,9 +323,43 @@ VAAPIRenderer::needsTestFrame()
|
|||||||
bool
|
bool
|
||||||
VAAPIRenderer::isDirectRenderingSupported()
|
VAAPIRenderer::isDirectRenderingSupported()
|
||||||
{
|
{
|
||||||
// Many Wayland renderers don't support YUV surfaces, so use
|
if (qgetenv("VAAPI_FORCE_DIRECT") == "1") {
|
||||||
// another frontend renderer to draw our frames.
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
return m_WindowSystem == SDL_SYSWM_X11;
|
"Using direct rendering due to environment variable");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (qgetenv("VAAPI_FORCE_INDIRECT") == "1") {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Using indirect rendering due to environment variable");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We only support direct rendering on X11 with VAEntrypointVideoProc support
|
||||||
|
if (m_WindowSystem != SDL_SYSWM_X11 || m_BlacklistedForDirectRendering) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Using indirect rendering due to WM or blacklist");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AVHWDeviceContext* deviceContext = (AVHWDeviceContext*)m_HwContext->data;
|
||||||
|
AVVAAPIDeviceContext* vaDeviceContext = (AVVAAPIDeviceContext*)deviceContext->hwctx;
|
||||||
|
VAEntrypoint entrypoints[vaMaxNumEntrypoints(vaDeviceContext->display)];
|
||||||
|
int entrypointCount;
|
||||||
|
VAStatus status = vaQueryConfigEntrypoints(vaDeviceContext->display, VAProfileNone, entrypoints, &entrypointCount);
|
||||||
|
if (status == VA_STATUS_SUCCESS) {
|
||||||
|
for (int i = 0; i < entrypointCount; i++) {
|
||||||
|
// Without VAEntrypointVideoProc support, the driver will crash inside vaPutSurface()
|
||||||
|
if (entrypoints[i] == VAEntrypointVideoProc) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Using direct rendering with VAEntrypointVideoProc");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Using indirect rendering due to lack of VAEntrypointVideoProc");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VAAPIRenderer::getDecoderColorspace()
|
int VAAPIRenderer::getDecoderColorspace()
|
||||||
@@ -229,6 +372,11 @@ int VAAPIRenderer::getDecoderColorspace()
|
|||||||
void
|
void
|
||||||
VAAPIRenderer::renderFrame(AVFrame* frame)
|
VAAPIRenderer::renderFrame(AVFrame* frame)
|
||||||
{
|
{
|
||||||
|
if (frame == nullptr) {
|
||||||
|
// End of stream - nothing to do for us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VASurfaceID surface = (VASurfaceID)(uintptr_t)frame->data[3];
|
VASurfaceID surface = (VASurfaceID)(uintptr_t)frame->data[3];
|
||||||
AVHWDeviceContext* deviceContext = (AVHWDeviceContext*)m_HwContext->data;
|
AVHWDeviceContext* deviceContext = (AVHWDeviceContext*)m_HwContext->data;
|
||||||
AVVAAPIDeviceContext* vaDeviceContext = (AVVAAPIDeviceContext*)deviceContext->hwctx;
|
AVVAAPIDeviceContext* vaDeviceContext = (AVVAAPIDeviceContext*)deviceContext->hwctx;
|
||||||
@@ -287,3 +435,167 @@ VAAPIRenderer::renderFrame(AVFrame* frame)
|
|||||||
SDL_assert(false);
|
SDL_assert(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_EGL
|
||||||
|
|
||||||
|
// Ensure that vaExportSurfaceHandle() is supported by the VA-API driver
|
||||||
|
bool
|
||||||
|
VAAPIRenderer::canExportEGL() {
|
||||||
|
AVHWDeviceContext* deviceContext = (AVHWDeviceContext*)m_HwContext->data;
|
||||||
|
AVVAAPIDeviceContext* vaDeviceContext = (AVVAAPIDeviceContext*)deviceContext->hwctx;
|
||||||
|
VASurfaceID surfaceId;
|
||||||
|
VAStatus st;
|
||||||
|
VADRMPRIMESurfaceDescriptor descriptor;
|
||||||
|
VASurfaceAttrib attrs[2];
|
||||||
|
int attributeCount = 0;
|
||||||
|
|
||||||
|
// FFmpeg handles setting these quirk flags for us
|
||||||
|
if (!(vaDeviceContext->driver_quirks & AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE)) {
|
||||||
|
attrs[attributeCount].type = VASurfaceAttribMemoryType;
|
||||||
|
attrs[attributeCount].flags = VA_SURFACE_ATTRIB_SETTABLE;
|
||||||
|
attrs[attributeCount].value.type = VAGenericValueTypeInteger;
|
||||||
|
attrs[attributeCount].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA;
|
||||||
|
attributeCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// These attributes are required for i965 to create a surface that can
|
||||||
|
// be successfully exported via vaExportSurfaceHandle(). iHD doesn't
|
||||||
|
// need these, but it doesn't seem to hurt either.
|
||||||
|
attrs[attributeCount].type = VASurfaceAttribPixelFormat;
|
||||||
|
attrs[attributeCount].flags = VA_SURFACE_ATTRIB_SETTABLE;
|
||||||
|
attrs[attributeCount].value.type = VAGenericValueTypeInteger;
|
||||||
|
attrs[attributeCount].value.value.i = VA_FOURCC_NV12;
|
||||||
|
attributeCount++;
|
||||||
|
|
||||||
|
st = vaCreateSurfaces(vaDeviceContext->display,
|
||||||
|
VA_RT_FORMAT_YUV420,
|
||||||
|
1280,
|
||||||
|
720,
|
||||||
|
&surfaceId,
|
||||||
|
1,
|
||||||
|
attrs,
|
||||||
|
attributeCount);
|
||||||
|
if (st != VA_STATUS_SUCCESS) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"vaCreateSurfaces() failed: %d", st);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
st = vaExportSurfaceHandle(vaDeviceContext->display,
|
||||||
|
surfaceId,
|
||||||
|
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
|
||||||
|
VA_EXPORT_SURFACE_READ_ONLY | VA_EXPORT_SURFACE_SEPARATE_LAYERS,
|
||||||
|
&descriptor);
|
||||||
|
|
||||||
|
vaDestroySurfaces(vaDeviceContext->display, &surfaceId, 1);
|
||||||
|
|
||||||
|
if (st != VA_STATUS_SUCCESS) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"vaExportSurfaceHandle() failed: %d", st);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < descriptor.num_objects; ++i) {
|
||||||
|
close(descriptor.objects[i].fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"VAAPI driver supports exporting DRM PRIME surface handles");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
VAAPIRenderer::initializeEGL(EGLDisplay,
|
||||||
|
const EGLExtensions &ext) {
|
||||||
|
if (!ext.isSupported("EGL_EXT_image_dma_buf_import")) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"VAAPI-EGL: DMABUF unsupported");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_EGLExtDmaBuf = ext.isSupported("EGL_EXT_image_dma_buf_import_modifiers");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
VAAPIRenderer::exportEGLImages(AVFrame *frame, EGLDisplay dpy,
|
||||||
|
EGLImage images[EGL_MAX_PLANES]) {
|
||||||
|
ssize_t count = 0;
|
||||||
|
auto hwFrameCtx = (AVHWFramesContext*)frame->hw_frames_ctx->data;
|
||||||
|
AVVAAPIDeviceContext* vaDeviceContext = (AVVAAPIDeviceContext*)hwFrameCtx->device_ctx->hwctx;
|
||||||
|
|
||||||
|
VASurfaceID surface_id = (VASurfaceID)(uintptr_t)frame->data[3];
|
||||||
|
VAStatus st = vaExportSurfaceHandle(vaDeviceContext->display,
|
||||||
|
surface_id,
|
||||||
|
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
|
||||||
|
VA_EXPORT_SURFACE_READ_ONLY | VA_EXPORT_SURFACE_SEPARATE_LAYERS,
|
||||||
|
&m_PrimeDescriptor);
|
||||||
|
if (st != VA_STATUS_SUCCESS) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"vaExportSurfaceHandle failed: %d", st);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_assert(m_PrimeDescriptor.num_layers <= EGL_MAX_PLANES);
|
||||||
|
|
||||||
|
st = vaSyncSurface(vaDeviceContext->display, surface_id);
|
||||||
|
if (st != VA_STATUS_SUCCESS) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"vaSyncSurface failed: %d", st);
|
||||||
|
goto sync_fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < m_PrimeDescriptor.num_layers; ++i) {
|
||||||
|
const auto &layer = m_PrimeDescriptor.layers[i];
|
||||||
|
const auto &object = m_PrimeDescriptor.objects[layer.object_index[0]];
|
||||||
|
|
||||||
|
EGLAttrib attribs[17] = {
|
||||||
|
EGL_LINUX_DRM_FOURCC_EXT, (EGLint)layer.drm_format,
|
||||||
|
EGL_WIDTH, i == 0 ? frame->width : frame->width / 2,
|
||||||
|
EGL_HEIGHT, i == 0 ? frame->height : frame->height / 2,
|
||||||
|
EGL_DMA_BUF_PLANE0_FD_EXT, object.fd,
|
||||||
|
EGL_DMA_BUF_PLANE0_OFFSET_EXT, (EGLint)layer.offset[0],
|
||||||
|
EGL_DMA_BUF_PLANE0_PITCH_EXT, (EGLint)layer.pitch[0],
|
||||||
|
EGL_NONE,
|
||||||
|
};
|
||||||
|
if (m_EGLExtDmaBuf) {
|
||||||
|
const EGLAttrib extra[] = {
|
||||||
|
EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT,
|
||||||
|
(EGLint)object.drm_format_modifier,
|
||||||
|
EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT,
|
||||||
|
(EGLint)(object.drm_format_modifier >> 32),
|
||||||
|
EGL_NONE,
|
||||||
|
};
|
||||||
|
memcpy((void *)(&attribs[12]), (void *)extra, sizeof (extra));
|
||||||
|
}
|
||||||
|
images[i] = eglCreateImage(dpy, EGL_NO_CONTEXT,
|
||||||
|
EGL_LINUX_DMA_BUF_EXT,
|
||||||
|
nullptr, attribs);
|
||||||
|
if (!images[i]) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"eglCreateImage() Failed: %d", eglGetError());
|
||||||
|
goto create_image_fail;
|
||||||
|
}
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
|
||||||
|
create_image_fail:
|
||||||
|
m_PrimeDescriptor.num_layers = count;
|
||||||
|
sync_fail:
|
||||||
|
freeEGLImages(dpy, images);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
VAAPIRenderer::freeEGLImages(EGLDisplay dpy, EGLImage images[EGL_MAX_PLANES]) {
|
||||||
|
for (size_t i = 0; i < m_PrimeDescriptor.num_layers; ++i) {
|
||||||
|
eglDestroyImage(dpy, images[i]);
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < m_PrimeDescriptor.num_objects; ++i) {
|
||||||
|
close(m_PrimeDescriptor.objects[i].fd);
|
||||||
|
}
|
||||||
|
m_PrimeDescriptor.num_layers = 0;
|
||||||
|
m_PrimeDescriptor.num_objects = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -26,6 +26,9 @@ extern "C" {
|
|||||||
#include <va/va_drm.h>
|
#include <va/va_drm.h>
|
||||||
#endif
|
#endif
|
||||||
#include <libavutil/hwcontext_vaapi.h>
|
#include <libavutil/hwcontext_vaapi.h>
|
||||||
|
#ifdef HAVE_EGL
|
||||||
|
#include <va/va_drmcommon.h>
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
class VAAPIRenderer : public IFFmpegRenderer
|
class VAAPIRenderer : public IFFmpegRenderer
|
||||||
@@ -34,16 +37,25 @@ public:
|
|||||||
VAAPIRenderer();
|
VAAPIRenderer();
|
||||||
virtual ~VAAPIRenderer() override;
|
virtual ~VAAPIRenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual bool needsTestFrame() override;
|
virtual bool needsTestFrame() override;
|
||||||
virtual bool isDirectRenderingSupported() override;
|
virtual bool isDirectRenderingSupported() override;
|
||||||
virtual int getDecoderColorspace() override;
|
virtual int getDecoderColorspace() override;
|
||||||
|
#ifdef HAVE_EGL
|
||||||
|
virtual bool canExportEGL() override;
|
||||||
|
virtual bool initializeEGL(EGLDisplay dpy, const EGLExtensions &ext) override;
|
||||||
|
virtual ssize_t exportEGLImages(AVFrame *frame, EGLDisplay dpy, EGLImage images[EGL_MAX_PLANES]) override;
|
||||||
|
virtual void freeEGLImages(EGLDisplay dpy, EGLImage[EGL_MAX_PLANES]) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
VADisplay openDisplay(SDL_Window* window);
|
||||||
|
|
||||||
int m_WindowSystem;
|
int m_WindowSystem;
|
||||||
AVBufferRef* m_HwContext;
|
AVBufferRef* m_HwContext;
|
||||||
int m_DrmFd;
|
int m_DrmFd;
|
||||||
|
bool m_BlacklistedForDirectRendering;
|
||||||
|
|
||||||
#ifdef HAVE_LIBVA_X11
|
#ifdef HAVE_LIBVA_X11
|
||||||
Window m_XWindow;
|
Window m_XWindow;
|
||||||
@@ -53,4 +65,9 @@ private:
|
|||||||
int m_VideoHeight;
|
int m_VideoHeight;
|
||||||
int m_DisplayWidth;
|
int m_DisplayWidth;
|
||||||
int m_DisplayHeight;
|
int m_DisplayHeight;
|
||||||
|
|
||||||
|
#ifdef HAVE_EGL
|
||||||
|
VADRMPRIMESurfaceDescriptor m_PrimeDescriptor;
|
||||||
|
bool m_EGLExtDmaBuf;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
@@ -64,6 +64,21 @@ bool VDPAURenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
int err;
|
int err;
|
||||||
VdpStatus status;
|
VdpStatus status;
|
||||||
SDL_SysWMinfo info;
|
SDL_SysWMinfo info;
|
||||||
|
static const char* driverPathsToTry[] = {
|
||||||
|
#if Q_PROCESSOR_WORDSIZE == 8
|
||||||
|
"/usr/lib64",
|
||||||
|
"/usr/lib64/vdpau", // Fedora x86_64
|
||||||
|
#endif
|
||||||
|
"/usr/lib",
|
||||||
|
"/usr/lib/vdpau", // Fedora i386
|
||||||
|
#if defined(Q_PROCESSOR_X86_64)
|
||||||
|
"/usr/lib/x86_64-linux-gnu",
|
||||||
|
"/usr/lib/x86_64-linux-gnu/vdpau", // Ubuntu/Debian x86_64
|
||||||
|
#elif defined(Q_PROCESSOR_X86_32)
|
||||||
|
"/usr/lib/i386-linux-gnu",
|
||||||
|
"/usr/lib/i386-linux-gnu/vdpau", // Ubuntu/Debian i386
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
m_VideoWidth = params->width;
|
m_VideoWidth = params->width;
|
||||||
m_VideoHeight = params->height;
|
m_VideoHeight = params->height;
|
||||||
@@ -71,6 +86,32 @@ bool VDPAURenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
err = av_hwdevice_ctx_create(&m_HwContext,
|
err = av_hwdevice_ctx_create(&m_HwContext,
|
||||||
AV_HWDEVICE_TYPE_VDPAU,
|
AV_HWDEVICE_TYPE_VDPAU,
|
||||||
nullptr, nullptr, 0);
|
nullptr, nullptr, 0);
|
||||||
|
|
||||||
|
if (err < 0 && qEnvironmentVariableIsEmpty("VDPAU_DRIVER_PATH")) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Trying fallback VDPAU driver paths");
|
||||||
|
|
||||||
|
// Unlike libva, libvdpau doesn't support multiple paths in
|
||||||
|
// their VDPAU_DRIVER_PATH variable, so we must try them all
|
||||||
|
// one at a time.
|
||||||
|
for (auto& driverPath : driverPathsToTry) {
|
||||||
|
qputenv("VDPAU_DRIVER_PATH", driverPath);
|
||||||
|
err = av_hwdevice_ctx_create(&m_HwContext,
|
||||||
|
AV_HWDEVICE_TYPE_VDPAU,
|
||||||
|
nullptr, nullptr, 0);
|
||||||
|
if (err == 0) {
|
||||||
|
// Success!
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err < 0) {
|
||||||
|
// Unset VDPAU_DRIVER_PATH if we set it ourselves
|
||||||
|
// and we didn't find any working VDPAU drivers.
|
||||||
|
qunsetenv("VDPAU_DRIVER_PATH");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Failed to create VDPAU context: %d",
|
"Failed to create VDPAU context: %d",
|
||||||
@@ -225,7 +266,7 @@ bool VDPAURenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VDPAURenderer::prepareDecoderContext(AVCodecContext* context)
|
bool VDPAURenderer::prepareDecoderContext(AVCodecContext* context, AVDictionary**)
|
||||||
{
|
{
|
||||||
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
||||||
|
|
||||||
@@ -261,6 +302,11 @@ int VDPAURenderer::getDecoderColorspace()
|
|||||||
|
|
||||||
void VDPAURenderer::renderFrame(AVFrame* frame)
|
void VDPAURenderer::renderFrame(AVFrame* frame)
|
||||||
{
|
{
|
||||||
|
if (frame == nullptr) {
|
||||||
|
// End of stream - nothing to do for us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VdpStatus status;
|
VdpStatus status;
|
||||||
VdpVideoSurface videoSurface = (VdpVideoSurface)(uintptr_t)frame->data[3];
|
VdpVideoSurface videoSurface = (VdpVideoSurface)(uintptr_t)frame->data[3];
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public:
|
|||||||
VDPAURenderer();
|
VDPAURenderer();
|
||||||
virtual ~VDPAURenderer() override;
|
virtual ~VDPAURenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual bool needsTestFrame() override;
|
virtual bool needsTestFrame() override;
|
||||||
virtual int getDecoderColorspace() override;
|
virtual int getDecoderColorspace() override;
|
||||||
|
|||||||
@@ -16,6 +16,19 @@
|
|||||||
#import <dispatch/dispatch.h>
|
#import <dispatch/dispatch.h>
|
||||||
#import <Metal/Metal.h>
|
#import <Metal/Metal.h>
|
||||||
|
|
||||||
|
@interface VTView : NSView
|
||||||
|
- (NSView *)hitTest:(NSPoint)point;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation VTView
|
||||||
|
|
||||||
|
- (NSView *)hitTest:(NSPoint)point {
|
||||||
|
Q_UNUSED(point);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
class VTRenderer : public IFFmpegRenderer
|
class VTRenderer : public IFFmpegRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -25,6 +38,7 @@ public:
|
|||||||
m_FormatDesc(nullptr),
|
m_FormatDesc(nullptr),
|
||||||
m_StreamView(nullptr),
|
m_StreamView(nullptr),
|
||||||
m_DisplayLink(nullptr),
|
m_DisplayLink(nullptr),
|
||||||
|
m_ColorSpace(nullptr),
|
||||||
m_VsyncMutex(nullptr),
|
m_VsyncMutex(nullptr),
|
||||||
m_VsyncPassed(nullptr)
|
m_VsyncPassed(nullptr)
|
||||||
{
|
{
|
||||||
@@ -54,6 +68,10 @@ public:
|
|||||||
CFRelease(m_FormatDesc);
|
CFRelease(m_FormatDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_ColorSpace != nullptr) {
|
||||||
|
CGColorSpaceRelease(m_ColorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < Overlay::OverlayMax; i++) {
|
for (int i = 0; i < Overlay::OverlayMax; i++) {
|
||||||
if (m_OverlayTextFields[i] != nullptr) {
|
if (m_OverlayTextFields[i] != nullptr) {
|
||||||
[m_OverlayTextFields[i] removeFromSuperview];
|
[m_OverlayTextFields[i] removeFromSuperview];
|
||||||
@@ -140,6 +158,11 @@ public:
|
|||||||
// Caller frees frame after we return
|
// Caller frees frame after we return
|
||||||
virtual void renderFrame(AVFrame* frame) override
|
virtual void renderFrame(AVFrame* frame) override
|
||||||
{
|
{
|
||||||
|
if (frame == nullptr) {
|
||||||
|
// End of stream - nothing to do for us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
OSStatus status;
|
OSStatus status;
|
||||||
CVPixelBufferRef pixBuf = reinterpret_cast<CVPixelBufferRef>(frame->data[3]);
|
CVPixelBufferRef pixBuf = reinterpret_cast<CVPixelBufferRef>(frame->data[3]);
|
||||||
|
|
||||||
@@ -154,6 +177,91 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Strip the attachments added by VT. They are likely wrong.
|
||||||
|
CVBufferRemoveAllAttachments(pixBuf);
|
||||||
|
|
||||||
|
CVBufferSetAttachment(pixBuf,
|
||||||
|
kCVImageBufferChromaSubsamplingKey,
|
||||||
|
kCVImageBufferChromaSubsampling_420,
|
||||||
|
kCVAttachmentMode_ShouldPropagate);
|
||||||
|
|
||||||
|
switch (frame->color_primaries) {
|
||||||
|
case AVCOL_PRI_BT709:
|
||||||
|
CVBufferSetAttachment(pixBuf,
|
||||||
|
kCVImageBufferColorPrimariesKey,
|
||||||
|
kCVImageBufferColorPrimaries_ITU_R_709_2,
|
||||||
|
kCVAttachmentMode_ShouldPropagate);
|
||||||
|
break;
|
||||||
|
case AVCOL_PRI_SMPTE170M:
|
||||||
|
CVBufferSetAttachment(pixBuf,
|
||||||
|
kCVImageBufferColorPrimariesKey,
|
||||||
|
kCVImageBufferColorPrimaries_SMPTE_C,
|
||||||
|
kCVAttachmentMode_ShouldPropagate);
|
||||||
|
break;
|
||||||
|
case AVCOL_PRI_BT2020:
|
||||||
|
CVBufferSetAttachment(pixBuf,
|
||||||
|
kCVImageBufferColorPrimariesKey,
|
||||||
|
kCVImageBufferColorPrimaries_ITU_R_2020,
|
||||||
|
kCVAttachmentMode_ShouldPropagate);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (frame->color_trc) {
|
||||||
|
case AVCOL_TRC_BT709:
|
||||||
|
case AVCOL_TRC_SMPTE170M:
|
||||||
|
CVBufferSetAttachment(pixBuf,
|
||||||
|
kCVImageBufferTransferFunctionKey,
|
||||||
|
kCVImageBufferTransferFunction_ITU_R_709_2,
|
||||||
|
kCVAttachmentMode_ShouldPropagate);
|
||||||
|
break;
|
||||||
|
case AVCOL_TRC_BT2020_10:
|
||||||
|
CVBufferSetAttachment(pixBuf,
|
||||||
|
kCVImageBufferTransferFunctionKey,
|
||||||
|
kCVImageBufferTransferFunction_ITU_R_2020,
|
||||||
|
kCVAttachmentMode_ShouldPropagate);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (frame->colorspace) {
|
||||||
|
case AVCOL_SPC_BT709:
|
||||||
|
if (m_ColorSpace == nullptr) {
|
||||||
|
m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_709);
|
||||||
|
}
|
||||||
|
CVBufferSetAttachment(pixBuf,
|
||||||
|
kCVImageBufferYCbCrMatrixKey,
|
||||||
|
kCVImageBufferYCbCrMatrix_ITU_R_709_2,
|
||||||
|
kCVAttachmentMode_ShouldPropagate);
|
||||||
|
break;
|
||||||
|
case AVCOL_SPC_BT2020_NCL:
|
||||||
|
if (m_ColorSpace == nullptr) {
|
||||||
|
m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020);
|
||||||
|
}
|
||||||
|
CVBufferSetAttachment(pixBuf,
|
||||||
|
kCVImageBufferYCbCrMatrixKey,
|
||||||
|
kCVImageBufferYCbCrMatrix_ITU_R_2020,
|
||||||
|
kCVAttachmentMode_ShouldPropagate);
|
||||||
|
break;
|
||||||
|
case AVCOL_SPC_SMPTE170M:
|
||||||
|
if (m_ColorSpace == nullptr) {
|
||||||
|
m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
|
||||||
|
}
|
||||||
|
CVBufferSetAttachment(pixBuf,
|
||||||
|
kCVImageBufferYCbCrMatrixKey,
|
||||||
|
kCVImageBufferYCbCrMatrix_ITU_R_601_4,
|
||||||
|
kCVAttachmentMode_ShouldPropagate);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ColorSpace != nullptr) {
|
||||||
|
CVBufferSetAttachment(pixBuf, kCVImageBufferCGColorSpaceKey, m_ColorSpace, kCVAttachmentMode_ShouldPropagate);
|
||||||
|
}
|
||||||
|
|
||||||
// If the format has changed or doesn't exist yet, construct it with the
|
// If the format has changed or doesn't exist yet, construct it with the
|
||||||
// pixel buffer data
|
// pixel buffer data
|
||||||
if (!m_FormatDesc || !CMVideoFormatDescriptionMatchesImageBuffer(m_FormatDesc, pixBuf)) {
|
if (!m_FormatDesc || !CMVideoFormatDescriptionMatchesImageBuffer(m_FormatDesc, pixBuf)) {
|
||||||
@@ -308,7 +416,7 @@ public:
|
|||||||
// SDL adds its own content view to listen for events.
|
// SDL adds its own content view to listen for events.
|
||||||
// We need to add a subview for our display layer.
|
// We need to add a subview for our display layer.
|
||||||
NSView* contentView = info.info.cocoa.window.contentView;
|
NSView* contentView = info.info.cocoa.window.contentView;
|
||||||
m_StreamView = [[NSView alloc] initWithFrame:contentView.bounds];
|
m_StreamView = [[VTView alloc] initWithFrame:contentView.bounds];
|
||||||
|
|
||||||
m_DisplayLayer = [[AVSampleBufferDisplayLayer alloc] init];
|
m_DisplayLayer = [[AVSampleBufferDisplayLayer alloc] init];
|
||||||
m_DisplayLayer.bounds = m_StreamView.bounds;
|
m_DisplayLayer.bounds = m_StreamView.bounds;
|
||||||
@@ -357,10 +465,10 @@ public:
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Overlay::OverlayDebug:
|
case Overlay::OverlayDebug:
|
||||||
[m_OverlayTextFields[type] setAlignment:NSLeftTextAlignment];
|
[m_OverlayTextFields[type] setAlignment:NSTextAlignmentLeft];
|
||||||
break;
|
break;
|
||||||
case Overlay::OverlayStatusUpdate:
|
case Overlay::OverlayStatusUpdate:
|
||||||
[m_OverlayTextFields[type] setAlignment:NSRightTextAlignment];
|
[m_OverlayTextFields[type] setAlignment:NSTextAlignmentRight];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -410,7 +518,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary**) override
|
||||||
{
|
{
|
||||||
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
||||||
|
|
||||||
@@ -429,6 +537,12 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getDecoderColorspace() override
|
||||||
|
{
|
||||||
|
// macOS seems to handle Rec 601 best
|
||||||
|
return COLORSPACE_REC_601;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AVBufferRef* m_HwContext;
|
AVBufferRef* m_HwContext;
|
||||||
AVSampleBufferDisplayLayer* m_DisplayLayer;
|
AVSampleBufferDisplayLayer* m_DisplayLayer;
|
||||||
@@ -436,6 +550,7 @@ private:
|
|||||||
NSView* m_StreamView;
|
NSView* m_StreamView;
|
||||||
NSTextField* m_OverlayTextFields[Overlay::OverlayMax];
|
NSTextField* m_OverlayTextFields[Overlay::OverlayMax];
|
||||||
CVDisplayLinkRef m_DisplayLink;
|
CVDisplayLinkRef m_DisplayLink;
|
||||||
|
CGColorSpaceRef m_ColorSpace;
|
||||||
SDL_mutex* m_VsyncMutex;
|
SDL_mutex* m_VsyncMutex;
|
||||||
SDL_cond* m_VsyncPassed;
|
SDL_cond* m_VsyncPassed;
|
||||||
};
|
};
|
||||||
|
|||||||
+205
-34
@@ -32,6 +32,10 @@
|
|||||||
#include "ffmpeg-renderers/drm.h"
|
#include "ffmpeg-renderers/drm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_EGL
|
||||||
|
#include "ffmpeg-renderers/eglvid.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// This is gross but it allows us to use sizeof()
|
// This is gross but it allows us to use sizeof()
|
||||||
#include "ffmpeg_videosamples.cpp"
|
#include "ffmpeg_videosamples.cpp"
|
||||||
|
|
||||||
@@ -45,9 +49,25 @@ bool FFmpegVideoDecoder::isHardwareAccelerated()
|
|||||||
(m_VideoDecoderCtx->codec->capabilities & AV_CODEC_CAP_HARDWARE) != 0;
|
(m_VideoDecoderCtx->codec->capabilities & AV_CODEC_CAP_HARDWARE) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FFmpegVideoDecoder::isAlwaysFullScreen()
|
||||||
|
{
|
||||||
|
return m_BackendRenderer->getRendererAttributes() & RENDERER_ATTRIBUTE_FULLSCREEN_ONLY;
|
||||||
|
}
|
||||||
|
|
||||||
int FFmpegVideoDecoder::getDecoderCapabilities()
|
int FFmpegVideoDecoder::getDecoderCapabilities()
|
||||||
{
|
{
|
||||||
return m_BackendRenderer->getDecoderCapabilities();
|
int capabilities = m_BackendRenderer->getDecoderCapabilities();
|
||||||
|
|
||||||
|
if (!isHardwareAccelerated()) {
|
||||||
|
// Slice up to 4 times for parallel CPU decoding, once slice per core
|
||||||
|
int slices = qMin(MAX_SLICES, SDL_GetCPUCount());
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Encoder configured for %d slices per frame",
|
||||||
|
slices);
|
||||||
|
capabilities |= CAPABILITY_SLICES_PER_FRAME(slices);
|
||||||
|
}
|
||||||
|
|
||||||
|
return capabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FFmpegVideoDecoder::getDecoderColorspace()
|
int FFmpegVideoDecoder::getDecoderColorspace()
|
||||||
@@ -55,6 +75,17 @@ int FFmpegVideoDecoder::getDecoderColorspace()
|
|||||||
return m_FrontendRenderer->getDecoderColorspace();
|
return m_FrontendRenderer->getDecoderColorspace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize FFmpegVideoDecoder::getDecoderMaxResolution()
|
||||||
|
{
|
||||||
|
if (m_BackendRenderer->getRendererAttributes() & RENDERER_ATTRIBUTE_1080P_MAX) {
|
||||||
|
return QSize(1920, 1080);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// No known maximum
|
||||||
|
return QSize(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum AVPixelFormat FFmpegVideoDecoder::ffGetFormat(AVCodecContext* context,
|
enum AVPixelFormat FFmpegVideoDecoder::ffGetFormat(AVCodecContext* context,
|
||||||
const enum AVPixelFormat* pixFmts)
|
const enum AVPixelFormat* pixFmts)
|
||||||
{
|
{
|
||||||
@@ -62,7 +93,7 @@ enum AVPixelFormat FFmpegVideoDecoder::ffGetFormat(AVCodecContext* context,
|
|||||||
const enum AVPixelFormat *p;
|
const enum AVPixelFormat *p;
|
||||||
|
|
||||||
for (p = pixFmts; *p != -1; p++) {
|
for (p = pixFmts; *p != -1; p++) {
|
||||||
// Only match our hardware decoding codec or SW pixel
|
// Only match our hardware decoding codec or preferred SW pixel
|
||||||
// format (if not using hardware decoding). It's crucial
|
// format (if not using hardware decoding). It's crucial
|
||||||
// to override the default get_format() which will try
|
// to override the default get_format() which will try
|
||||||
// to gracefully fall back to software decode and break us.
|
// to gracefully fall back to software decode and break us.
|
||||||
@@ -73,6 +104,15 @@ enum AVPixelFormat FFmpegVideoDecoder::ffGetFormat(AVCodecContext* context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Failed to match the preferred pixel formats. Try non-preferred options for non-hwaccel decoders.
|
||||||
|
if (decoder->m_HwDecodeCfg == nullptr) {
|
||||||
|
for (p = pixFmts; *p != -1; p++) {
|
||||||
|
if (decoder->m_FrontendRenderer->isPixelFormatSupported(decoder->m_VideoFormat, *p)) {
|
||||||
|
return *p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return AV_PIX_FMT_NONE;
|
return AV_PIX_FMT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,8 +124,11 @@ FFmpegVideoDecoder::FFmpegVideoDecoder(bool testOnly)
|
|||||||
m_FrontendRenderer(nullptr),
|
m_FrontendRenderer(nullptr),
|
||||||
m_ConsecutiveFailedDecodes(0),
|
m_ConsecutiveFailedDecodes(0),
|
||||||
m_Pacer(nullptr),
|
m_Pacer(nullptr),
|
||||||
|
m_FramesIn(0),
|
||||||
|
m_FramesOut(0),
|
||||||
m_LastFrameNumber(0),
|
m_LastFrameNumber(0),
|
||||||
m_StreamFps(0),
|
m_StreamFps(0),
|
||||||
|
m_VideoFormat(0),
|
||||||
m_NeedsSpsFixup(false),
|
m_NeedsSpsFixup(false),
|
||||||
m_TestOnly(testOnly)
|
m_TestOnly(testOnly)
|
||||||
{
|
{
|
||||||
@@ -156,6 +199,15 @@ bool FFmpegVideoDecoder::createFrontendRenderer(PDECODER_PARAMETERS params)
|
|||||||
m_FrontendRenderer = m_BackendRenderer;
|
m_FrontendRenderer = m_BackendRenderer;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#ifdef HAVE_EGL
|
||||||
|
if (m_BackendRenderer->canExportEGL()) {
|
||||||
|
m_FrontendRenderer = new EGLRenderer(m_BackendRenderer);
|
||||||
|
if (m_FrontendRenderer->initialize(params)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
delete m_FrontendRenderer;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// The backend renderer cannot directly render to the display, so
|
// The backend renderer cannot directly render to the display, so
|
||||||
// we will create an SDL renderer to draw the frames.
|
// we will create an SDL renderer to draw the frames.
|
||||||
m_FrontendRenderer = new SdlRenderer();
|
m_FrontendRenderer = new SdlRenderer();
|
||||||
@@ -164,23 +216,6 @@ bool FFmpegVideoDecoder::createFrontendRenderer(PDECODER_PARAMETERS params)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether the frontend renderer prefers frame pacing
|
|
||||||
auto vsyncConstraint = m_FrontendRenderer->getFramePacingConstraint();
|
|
||||||
if (vsyncConstraint == IFFmpegRenderer::PACING_FORCE_OFF && params->enableFramePacing) {
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Frame pacing is forcefully disabled by the frontend renderer");
|
|
||||||
params->enableFramePacing = false;
|
|
||||||
}
|
|
||||||
else if (vsyncConstraint == IFFmpegRenderer::PACING_FORCE_ON && !params->enableFramePacing) {
|
|
||||||
// FIXME: This duplicates logic in Session.cpp
|
|
||||||
int displayHz = StreamUtils::getDisplayRefreshRate(params->window);
|
|
||||||
if (displayHz + 5 >= params->frameRate) {
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Frame pacing is forcefully enabled by the frontend renderer");
|
|
||||||
params->enableFramePacing = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +230,7 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, PDECODER_PARAM
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_StreamFps = params->frameRate;
|
m_StreamFps = params->frameRate;
|
||||||
|
m_VideoFormat = params->videoFormat;
|
||||||
|
|
||||||
// Don't bother initializing Pacer if we're not actually going to render
|
// Don't bother initializing Pacer if we're not actually going to render
|
||||||
if (!testFrame) {
|
if (!testFrame) {
|
||||||
@@ -243,8 +279,10 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, PDECODER_PARAM
|
|||||||
m_VideoDecoderCtx->pix_fmt = m_FrontendRenderer->getPreferredPixelFormat(params->videoFormat);
|
m_VideoDecoderCtx->pix_fmt = m_FrontendRenderer->getPreferredPixelFormat(params->videoFormat);
|
||||||
m_VideoDecoderCtx->get_format = ffGetFormat;
|
m_VideoDecoderCtx->get_format = ffGetFormat;
|
||||||
|
|
||||||
|
AVDictionary* options = nullptr;
|
||||||
|
|
||||||
// Allow the backend renderer to attach data to this decoder
|
// Allow the backend renderer to attach data to this decoder
|
||||||
if (!m_BackendRenderer->prepareDecoderContext(m_VideoDecoderCtx)) {
|
if (!m_BackendRenderer->prepareDecoderContext(m_VideoDecoderCtx, &options)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +293,8 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, PDECODER_PARAM
|
|||||||
SDL_assert(m_VideoDecoderCtx->opaque == nullptr);
|
SDL_assert(m_VideoDecoderCtx->opaque == nullptr);
|
||||||
m_VideoDecoderCtx->opaque = this;
|
m_VideoDecoderCtx->opaque = this;
|
||||||
|
|
||||||
int err = avcodec_open2(m_VideoDecoderCtx, decoder, nullptr);
|
int err = avcodec_open2(m_VideoDecoderCtx, decoder, &options);
|
||||||
|
av_dict_free(&options);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Unable to open decoder for format: %x",
|
"Unable to open decoder for format: %x",
|
||||||
@@ -289,7 +328,42 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, PDECODER_PARAM
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = avcodec_send_packet(m_VideoDecoderCtx, &m_Pkt);
|
AVFrame* frame = av_frame_alloc();
|
||||||
|
if (!frame) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Failed to allocate frame");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some decoders won't output on the first frame, so we'll submit
|
||||||
|
// a few test frames if we get an EAGAIN error.
|
||||||
|
for (int retries = 0; retries < 5; retries++) {
|
||||||
|
// Most FFmpeg decoders process input using a "push" model.
|
||||||
|
// We'll see those fail here if the format is not supported.
|
||||||
|
err = avcodec_send_packet(m_VideoDecoderCtx, &m_Pkt);
|
||||||
|
if (err < 0) {
|
||||||
|
av_frame_free(&frame);
|
||||||
|
char errorstring[512];
|
||||||
|
av_strerror(err, errorstring, sizeof(errorstring));
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Test decode failed: %s", errorstring);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A few FFmpeg decoders (h264_mmal) process here using a "pull" model.
|
||||||
|
// Those decoders will fail here if the format is not supported.
|
||||||
|
err = avcodec_receive_frame(m_VideoDecoderCtx, frame);
|
||||||
|
if (err == AVERROR(EAGAIN)) {
|
||||||
|
// Wait a little while to let the hardware work
|
||||||
|
SDL_Delay(100);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Done!
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
av_frame_free(&frame);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
char errorstring[512];
|
char errorstring[512];
|
||||||
av_strerror(err, errorstring, sizeof(errorstring));
|
av_strerror(err, errorstring, sizeof(errorstring));
|
||||||
@@ -488,11 +562,61 @@ bool FFmpegVideoDecoder::tryInitializeRenderer(AVCodec* decoder,
|
|||||||
|
|
||||||
bool FFmpegVideoDecoder::initialize(PDECODER_PARAMETERS params)
|
bool FFmpegVideoDecoder::initialize(PDECODER_PARAMETERS params)
|
||||||
{
|
{
|
||||||
AVCodec* decoder;
|
|
||||||
|
|
||||||
// Increase log level until the first frame is decoded
|
// Increase log level until the first frame is decoded
|
||||||
av_log_set_level(AV_LOG_DEBUG);
|
av_log_set_level(AV_LOG_DEBUG);
|
||||||
|
|
||||||
|
// First try decoders that the user has manually specified via environment variables.
|
||||||
|
// These must output surfaces in one of the formats that the SDL renderer supports,
|
||||||
|
// which is currently:
|
||||||
|
// - AV_PIX_FMT_YUV420P (preferred)
|
||||||
|
// - AV_PIX_FMT_NV12
|
||||||
|
// - AV_PIX_FMT_NV21
|
||||||
|
// These formats should cover most/all decoders that output in a standard YUV format.
|
||||||
|
{
|
||||||
|
QString h264DecoderHint = qgetenv("H264_DECODER_HINT");
|
||||||
|
if (!h264DecoderHint.isEmpty() && (params->videoFormat & VIDEO_FORMAT_MASK_H264)) {
|
||||||
|
QByteArray decoderString = h264DecoderHint.toLocal8Bit();
|
||||||
|
AVCodec* customAvcDecoder = avcodec_find_decoder_by_name(decoderString.constData());
|
||||||
|
|
||||||
|
if (customAvcDecoder != nullptr &&
|
||||||
|
tryInitializeRenderer(customAvcDecoder, params, nullptr,
|
||||||
|
[]() -> IFFmpegRenderer* { return new SdlRenderer(); })) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Using custom H.264 decoder (H264_DECODER_HINT): %s",
|
||||||
|
decoderString.constData());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Custom H.264 decoder (H264_DECODER_HINT) failed to load: %s",
|
||||||
|
decoderString.constData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QString hevcDecoderHint = qgetenv("HEVC_DECODER_HINT");
|
||||||
|
if (!hevcDecoderHint.isEmpty() && (params->videoFormat & VIDEO_FORMAT_MASK_H265)) {
|
||||||
|
QByteArray decoderString = hevcDecoderHint.toLocal8Bit();
|
||||||
|
AVCodec* customHevcDecoder = avcodec_find_decoder_by_name(decoderString.constData());
|
||||||
|
|
||||||
|
if (customHevcDecoder != nullptr &&
|
||||||
|
tryInitializeRenderer(customHevcDecoder, params, nullptr,
|
||||||
|
[]() -> IFFmpegRenderer* { return new SdlRenderer(); })) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Using custom HEVC decoder (HEVC_DECODER_HINT): %s",
|
||||||
|
decoderString.constData());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Custom HEVC decoder (HEVC_DECODER_HINT) failed to load: %s",
|
||||||
|
decoderString.constData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AVCodec* decoder;
|
||||||
|
|
||||||
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||||
decoder = avcodec_find_decoder(AV_CODEC_ID_H264);
|
decoder = avcodec_find_decoder(AV_CODEC_ID_H264);
|
||||||
}
|
}
|
||||||
@@ -543,20 +667,58 @@ bool FFmpegVideoDecoder::initialize(PDECODER_PARAMETERS params)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DRM
|
#ifdef HAVE_DRM
|
||||||
// RKMPP is a hardware accelerated decoder that outputs DRI PRIME buffers
|
{
|
||||||
AVCodec* rkmppDecoder;
|
// RKMPP is a hardware accelerated decoder that outputs DRI PRIME buffers
|
||||||
|
AVCodec* rkmppDecoder;
|
||||||
|
|
||||||
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||||
rkmppDecoder = avcodec_find_decoder_by_name("h264_rkmpp");
|
rkmppDecoder = avcodec_find_decoder_by_name("h264_rkmpp");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rkmppDecoder = avcodec_find_decoder_by_name("hevc_rkmpp");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rkmppDecoder != nullptr &&
|
||||||
|
tryInitializeRenderer(rkmppDecoder, params, nullptr,
|
||||||
|
[]() -> IFFmpegRenderer* { return new DrmRenderer(); })) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
rkmppDecoder = avcodec_find_decoder_by_name("hevc_rkmpp");
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
{
|
||||||
|
AVCodec* nvmpiDecoder;
|
||||||
|
|
||||||
|
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||||
|
nvmpiDecoder = avcodec_find_decoder_by_name("h264_nvmpi");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nvmpiDecoder = avcodec_find_decoder_by_name("hevc_nvmpi");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nvmpiDecoder != nullptr &&
|
||||||
|
tryInitializeRenderer(nvmpiDecoder, params, nullptr,
|
||||||
|
[]() -> IFFmpegRenderer* { return new SdlRenderer(); })) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rkmppDecoder != nullptr &&
|
{
|
||||||
tryInitializeRenderer(rkmppDecoder, params, nullptr,
|
AVCodec* v4l2Decoder;
|
||||||
[]() -> IFFmpegRenderer* { return new DrmRenderer(); })) {
|
|
||||||
return true;
|
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||||
|
v4l2Decoder = avcodec_find_decoder_by_name("h264_v4l2m2m");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
v4l2Decoder = avcodec_find_decoder_by_name("hevc_v4l2m2m");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v4l2Decoder != nullptr &&
|
||||||
|
tryInitializeRenderer(v4l2Decoder, params, nullptr,
|
||||||
|
[]() -> IFFmpegRenderer* { return new SdlRenderer(); })) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -719,6 +881,8 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
|||||||
return DR_NEED_IDR;
|
return DR_NEED_IDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_FramesIn++;
|
||||||
|
|
||||||
AVFrame* frame = av_frame_alloc();
|
AVFrame* frame = av_frame_alloc();
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
// Failed to allocate a frame but we did submit,
|
// Failed to allocate a frame but we did submit,
|
||||||
@@ -730,6 +894,8 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
|||||||
|
|
||||||
err = avcodec_receive_frame(m_VideoDecoderCtx, frame);
|
err = avcodec_receive_frame(m_VideoDecoderCtx, frame);
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
|
m_FramesOut++;
|
||||||
|
|
||||||
// Reset failed decodes count if we reached this far
|
// Reset failed decodes count if we reached this far
|
||||||
m_ConsecutiveFailedDecodes = 0;
|
m_ConsecutiveFailedDecodes = 0;
|
||||||
|
|
||||||
@@ -745,6 +911,11 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
|||||||
// Count time in avcodec_send_packet() and avcodec_receive_frame()
|
// Count time in avcodec_send_packet() and avcodec_receive_frame()
|
||||||
// as time spent decoding
|
// as time spent decoding
|
||||||
m_ActiveWndVideoStats.totalDecodeTime += SDL_GetTicks() - beforeDecode;
|
m_ActiveWndVideoStats.totalDecodeTime += SDL_GetTicks() - beforeDecode;
|
||||||
|
|
||||||
|
// Also count the frame-to-frame delay if the decoder is delaying frames
|
||||||
|
// until a subsequent frame is submitted.
|
||||||
|
m_ActiveWndVideoStats.totalDecodeTime += (m_FramesIn - m_FramesOut) * (1000 / m_StreamFps);
|
||||||
|
|
||||||
m_ActiveWndVideoStats.decodedFrames++;
|
m_ActiveWndVideoStats.decodedFrames++;
|
||||||
|
|
||||||
// Queue the frame for rendering (or render now if pacer is disabled)
|
// Queue the frame for rendering (or render now if pacer is disabled)
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ public:
|
|||||||
virtual ~FFmpegVideoDecoder() override;
|
virtual ~FFmpegVideoDecoder() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool isHardwareAccelerated() override;
|
virtual bool isHardwareAccelerated() override;
|
||||||
|
virtual bool isAlwaysFullScreen() override;
|
||||||
virtual int getDecoderCapabilities() override;
|
virtual int getDecoderCapabilities() override;
|
||||||
virtual int getDecoderColorspace() override;
|
virtual int getDecoderColorspace() override;
|
||||||
|
virtual QSize getDecoderMaxResolution() override;
|
||||||
virtual int submitDecodeUnit(PDECODE_UNIT du) override;
|
virtual int submitDecodeUnit(PDECODE_UNIT du) override;
|
||||||
virtual void renderFrameOnMainThread() override;
|
virtual void renderFrameOnMainThread() override;
|
||||||
|
|
||||||
@@ -61,8 +63,12 @@ private:
|
|||||||
VIDEO_STATS m_LastWndVideoStats;
|
VIDEO_STATS m_LastWndVideoStats;
|
||||||
VIDEO_STATS m_GlobalVideoStats;
|
VIDEO_STATS m_GlobalVideoStats;
|
||||||
|
|
||||||
|
int m_FramesIn;
|
||||||
|
int m_FramesOut;
|
||||||
|
|
||||||
int m_LastFrameNumber;
|
int m_LastFrameNumber;
|
||||||
int m_StreamFps;
|
int m_StreamFps;
|
||||||
|
int m_VideoFormat;
|
||||||
bool m_NeedsSpsFixup;
|
bool m_NeedsSpsFixup;
|
||||||
bool m_TestOnly;
|
bool m_TestOnly;
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ SLVideoDecoder::isHardwareAccelerated()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SLVideoDecoder::isAlwaysFullScreen()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SLVideoDecoder::getDecoderCapabilities()
|
SLVideoDecoder::getDecoderCapabilities()
|
||||||
{
|
{
|
||||||
@@ -37,6 +42,11 @@ SLVideoDecoder::getDecoderColorspace()
|
|||||||
return COLORSPACE_REC_709;
|
return COLORSPACE_REC_709;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize SLVideoDecoder::getDecoderMaxResolution()
|
||||||
|
{
|
||||||
|
return QSize(1920, 1080);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SLVideoDecoder::initialize(PDECODER_PARAMETERS params)
|
SLVideoDecoder::initialize(PDECODER_PARAMETERS params)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ public:
|
|||||||
virtual ~SLVideoDecoder();
|
virtual ~SLVideoDecoder();
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params);
|
virtual bool initialize(PDECODER_PARAMETERS params);
|
||||||
virtual bool isHardwareAccelerated();
|
virtual bool isHardwareAccelerated();
|
||||||
|
virtual bool isAlwaysFullScreen();
|
||||||
virtual int getDecoderCapabilities();
|
virtual int getDecoderCapabilities();
|
||||||
virtual int getDecoderColorspace();
|
virtual int getDecoderColorspace();
|
||||||
|
virtual QSize getDecoderMaxResolution();
|
||||||
virtual int submitDecodeUnit(PDECODE_UNIT du);
|
virtual int submitDecodeUnit(PDECODE_UNIT du);
|
||||||
|
|
||||||
// Unused since rendering is done directly from the decode thread
|
// Unused since rendering is done directly from the decode thread
|
||||||
|
|||||||
@@ -3,3 +3,8 @@
|
|||||||
#define THROW_BAD_ALLOC_IF_NULL(x) \
|
#define THROW_BAD_ALLOC_IF_NULL(x) \
|
||||||
if ((x) == nullptr) throw std::bad_alloc()
|
if ((x) == nullptr) throw std::bad_alloc()
|
||||||
|
|
||||||
|
namespace WMUtils {
|
||||||
|
bool isRunningX11();
|
||||||
|
bool isRunningWayland();
|
||||||
|
bool isRunningWindowManager();
|
||||||
|
}
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
1.2.1
|
2.1.0
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
#ifdef HAS_X11
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_WAYLAND
|
||||||
|
#include <wayland-client.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool WMUtils::isRunningX11()
|
||||||
|
{
|
||||||
|
#ifdef HAS_X11
|
||||||
|
Display* display = XOpenDisplay(nullptr);
|
||||||
|
if (display != nullptr) {
|
||||||
|
XCloseDisplay(display);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WMUtils::isRunningWayland()
|
||||||
|
{
|
||||||
|
#ifdef HAS_WAYLAND
|
||||||
|
struct wl_display* display = wl_display_connect(nullptr);
|
||||||
|
if (display != nullptr) {
|
||||||
|
wl_display_disconnect(display);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WMUtils::isRunningWindowManager()
|
||||||
|
{
|
||||||
|
#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN)
|
||||||
|
// Windows and macOS are always running a window manager
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
// On Unix OSes, look for Wayland or X
|
||||||
|
return WMUtils::isRunningWayland() || WMUtils::isRunningX11();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
version: 0.0.0.{build}
|
||||||
|
|
||||||
|
clone_depth: 1
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
|
QTDIR: C:\Qt\5.14\msvc2017_64
|
||||||
|
ARCH: x64
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: macOS
|
||||||
|
BUILD_TARGET: macos
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
|
QTDIR: C:\Qt\5.14\msvc2017
|
||||||
|
ARCH: x86
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu1604
|
||||||
|
BUILD_TARGET: steamlink
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu1604
|
||||||
|
BUILD_TARGET: linux
|
||||||
|
FFMPEG_CONFIGURE_ARGS: --enable-pic --disable-static --enable-shared --disable-all --enable-avcodec --enable-decoder=h264 --enable-decoder=hevc --enable-nvdec --enable-hwaccel=h264_nvdec --enable-hwaccel=hevc_nvdec --enable-hwaccel=h264_vaapi --enable-hwaccel=hevc_vaapi --enable-hwaccel=h264_vdpau --enable-hwaccel=hevc_vdpau
|
||||||
|
|
||||||
|
install:
|
||||||
|
- sh: '[ "$BUILD_TARGET" != macos ] || nvm use node'
|
||||||
|
- sh: '[ "$BUILD_TARGET" != macos ] || npm install --global create-dmg'
|
||||||
|
- sh: '[ "$BUILD_TARGET" != steamlink ] || sudo apt install -y libc6:i386 libstdc++6:i386'
|
||||||
|
- sh: '[ "$BUILD_TARGET" != steamlink ] || git clone --depth=1 https://github.com/ValveSoftware/steamlink-sdk.git $HOME/steamlink-sdk'
|
||||||
|
- 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_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.7.1 && 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 FFMPEG_VER=4.2.2 && 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 /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%'
|
||||||
|
- 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'
|
||||||
|
- 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'
|
||||||
|
|
||||||
|
deploy: off
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
SOURCES = main.cpp
|
||||||
|
|
||||||
|
CONFIG += link_pkgconfig
|
||||||
|
|
||||||
|
# This adds /opt/vc/include to the include path which
|
||||||
|
# pulls in the BRCM GLES and EGL libraries. If we don't
|
||||||
|
# add this, we'll get the system's headers which expose
|
||||||
|
# functionality the runtime GL implementation won't have.
|
||||||
|
packagesExist(mmal) {
|
||||||
|
PKGCONFIG += mmal
|
||||||
|
}
|
||||||
|
|
||||||
|
PKGCONFIG += sdl2 egl libavcodec libavutil
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#include <SDL_egl.h>
|
||||||
|
#include <SDL_opengles2.h>
|
||||||
|
|
||||||
|
#ifndef EGL_VERSION_1_4
|
||||||
|
#error EGLRenderer requires EGL 1.4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GL_ES_VERSION_2_0
|
||||||
|
#error EGLRenderer requires OpenGL ES 2.0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
+6
-2
@@ -9,5 +9,9 @@ CONFIG(release, debug|release) {
|
|||||||
DEFINES += NDEBUG
|
DEFINES += NDEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
# Enable ASan if desired
|
# Enable ASan for Linux or macOS
|
||||||
#CONFIG += sanitizer sanitize_address
|
#CONFIG += sanitizer sanitize_address
|
||||||
|
|
||||||
|
# Enable ASan for Windows
|
||||||
|
#QMAKE_CFLAGS += /fsanitize=address /MD
|
||||||
|
#LIBS += clang_rt.asan_dynamic-i386.lib clang_rt.asan_dynamic_runtime_thunk-i386.lib
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
Versions/Current/Resources
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
HIDAPI Authors:
|
||||||
|
|
||||||
|
Alan Ott <alan@signal11.us>:
|
||||||
|
Original Author and Maintainer
|
||||||
|
Linux, Windows, and Mac implementations
|
||||||
|
|
||||||
|
Ludovic Rousseau <rousseau@debian.org>:
|
||||||
|
Formatting for Doxygen documentation
|
||||||
|
Bug fixes
|
||||||
|
Correctness fixes
|
||||||
|
|
||||||
|
|
||||||
|
For a comprehensive list of contributions, see the commit list at github:
|
||||||
|
https://github.com/libusb/hidapi/commits/master
|
||||||
|
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>BuildMachineOSBuild</key>
|
||||||
|
<string>19E287</string>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>hidapi</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>org.libsdl.hidapi</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>hidapi</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>FMWK</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleSupportedPlatforms</key>
|
||||||
|
<array>
|
||||||
|
<string>MacOSX</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>DTCompiler</key>
|
||||||
|
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||||
|
<key>DTPlatformBuild</key>
|
||||||
|
<string>11C505</string>
|
||||||
|
<key>DTPlatformVersion</key>
|
||||||
|
<string>GM</string>
|
||||||
|
<key>DTSDKBuild</key>
|
||||||
|
<string>19B90</string>
|
||||||
|
<key>DTSDKName</key>
|
||||||
|
<string>macosx10.15</string>
|
||||||
|
<key>DTXcode</key>
|
||||||
|
<string>1130</string>
|
||||||
|
<key>DTXcodeBuild</key>
|
||||||
|
<string>11C505</string>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>10.6</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
Copyright (c) 2010, Alan Ott, Signal 11 Software
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of Signal 11 Software nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
+674
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
HIDAPI - Multi-Platform library for
|
||||||
|
communication with HID devices.
|
||||||
|
|
||||||
|
Copyright 2009, Alan Ott, Signal 11 Software.
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
This software may be used by anyone for any reason so
|
||||||
|
long as the copyright notice in the source files
|
||||||
|
remains intact.
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
HIDAPI can be used under one of three licenses.
|
||||||
|
|
||||||
|
1. The GNU General Public License, version 3.0, in LICENSE-gpl3.txt
|
||||||
|
2. A BSD-Style License, in LICENSE-bsd.txt.
|
||||||
|
3. The more liberal original HIDAPI license. LICENSE-orig.txt
|
||||||
|
|
||||||
|
The license chosen is at the discretion of the user of HIDAPI. For example:
|
||||||
|
1. An author of GPL software would likely use HIDAPI under the terms of the
|
||||||
|
GPL.
|
||||||
|
|
||||||
|
2. An author of commercial closed-source software would likely use HIDAPI
|
||||||
|
under the terms of the BSD-style license or the original HIDAPI license.
|
||||||
|
|
||||||
+218
@@ -0,0 +1,218 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>files</key>
|
||||||
|
<dict>
|
||||||
|
<key>Resources/AUTHORS.txt</key>
|
||||||
|
<data>
|
||||||
|
MKG+c/Ng8ZXbj7p1G5WReTJm06Y=
|
||||||
|
</data>
|
||||||
|
<key>Resources/Info.plist</key>
|
||||||
|
<data>
|
||||||
|
xIjchI5RXIIqR9iBwzwdhWVeJmQ=
|
||||||
|
</data>
|
||||||
|
<key>Resources/LICENSE-bsd.txt</key>
|
||||||
|
<data>
|
||||||
|
fd5CtMb9r65yLY0HVWttnbpNKWM=
|
||||||
|
</data>
|
||||||
|
<key>Resources/LICENSE-gpl3.txt</key>
|
||||||
|
<data>
|
||||||
|
hiS82uVbru8AzRHV38+mD2hxCgI=
|
||||||
|
</data>
|
||||||
|
<key>Resources/LICENSE-orig.txt</key>
|
||||||
|
<data>
|
||||||
|
ZgR9vPP9aJyZRyJm9a0UHFPW8sY=
|
||||||
|
</data>
|
||||||
|
<key>Resources/LICENSE.txt</key>
|
||||||
|
<data>
|
||||||
|
9VS7iq5RUyXd9/XSbbwcYpQMum4=
|
||||||
|
</data>
|
||||||
|
</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>
|
||||||
|
<data>
|
||||||
|
MKG+c/Ng8ZXbj7p1G5WReTJm06Y=
|
||||||
|
</data>
|
||||||
|
<key>hash2</key>
|
||||||
|
<data>
|
||||||
|
syens6RZflkCVW7D6EB8vdHiiKvUYjt7S1bRTUnoTss=
|
||||||
|
</data>
|
||||||
|
</dict>
|
||||||
|
<key>Resources/Info.plist</key>
|
||||||
|
<dict>
|
||||||
|
<key>hash</key>
|
||||||
|
<data>
|
||||||
|
xIjchI5RXIIqR9iBwzwdhWVeJmQ=
|
||||||
|
</data>
|
||||||
|
<key>hash2</key>
|
||||||
|
<data>
|
||||||
|
8Rqw3j5YT+AoPOKV4JE3RuVPPDb4jHtT4tpmG0phLYc=
|
||||||
|
</data>
|
||||||
|
</dict>
|
||||||
|
<key>Resources/LICENSE-bsd.txt</key>
|
||||||
|
<dict>
|
||||||
|
<key>hash</key>
|
||||||
|
<data>
|
||||||
|
fd5CtMb9r65yLY0HVWttnbpNKWM=
|
||||||
|
</data>
|
||||||
|
<key>hash2</key>
|
||||||
|
<data>
|
||||||
|
MOsb7ym0b4unq4tBYDXb2TywNKRUgd2XgVuUQoRYLNI=
|
||||||
|
</data>
|
||||||
|
</dict>
|
||||||
|
<key>Resources/LICENSE-gpl3.txt</key>
|
||||||
|
<dict>
|
||||||
|
<key>hash</key>
|
||||||
|
<data>
|
||||||
|
hiS82uVbru8AzRHV38+mD2hxCgI=
|
||||||
|
</data>
|
||||||
|
<key>hash2</key>
|
||||||
|
<data>
|
||||||
|
jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM=
|
||||||
|
</data>
|
||||||
|
</dict>
|
||||||
|
<key>Resources/LICENSE-orig.txt</key>
|
||||||
|
<dict>
|
||||||
|
<key>hash</key>
|
||||||
|
<data>
|
||||||
|
ZgR9vPP9aJyZRyJm9a0UHFPW8sY=
|
||||||
|
</data>
|
||||||
|
<key>hash2</key>
|
||||||
|
<data>
|
||||||
|
+1Q2qmPRtxqN+/dOyvGltOHsTff4AHTRH+yZKE9pyl8=
|
||||||
|
</data>
|
||||||
|
</dict>
|
||||||
|
<key>Resources/LICENSE.txt</key>
|
||||||
|
<dict>
|
||||||
|
<key>hash</key>
|
||||||
|
<data>
|
||||||
|
9VS7iq5RUyXd9/XSbbwcYpQMum4=
|
||||||
|
</data>
|
||||||
|
<key>hash2</key>
|
||||||
|
<data>
|
||||||
|
fTsIfDTzXU1TjjvN3R/49m6S+e8zaIGZlIKADd+ECRM=
|
||||||
|
</data>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>rules</key>
|
||||||
|
<dict>
|
||||||
|
<key>^Resources/</key>
|
||||||
|
<true/>
|
||||||
|
<key>^Resources/.*\.lproj/</key>
|
||||||
|
<dict>
|
||||||
|
<key>optional</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1000</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
||||||
|
<dict>
|
||||||
|
<key>omit</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1100</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/Base\.lproj/</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1010</real>
|
||||||
|
</dict>
|
||||||
|
<key>^version.plist$</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>rules2</key>
|
||||||
|
<dict>
|
||||||
|
<key>.*\.dSYM($|/)</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>11</real>
|
||||||
|
</dict>
|
||||||
|
<key>^(.*/)?\.DS_Store$</key>
|
||||||
|
<dict>
|
||||||
|
<key>omit</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>2000</real>
|
||||||
|
</dict>
|
||||||
|
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
|
||||||
|
<dict>
|
||||||
|
<key>nested</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>10</real>
|
||||||
|
</dict>
|
||||||
|
<key>^.*</key>
|
||||||
|
<true/>
|
||||||
|
<key>^Info\.plist$</key>
|
||||||
|
<dict>
|
||||||
|
<key>omit</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>20</real>
|
||||||
|
</dict>
|
||||||
|
<key>^PkgInfo$</key>
|
||||||
|
<dict>
|
||||||
|
<key>omit</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>20</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>20</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/.*\.lproj/</key>
|
||||||
|
<dict>
|
||||||
|
<key>optional</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1000</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
||||||
|
<dict>
|
||||||
|
<key>omit</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1100</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/Base\.lproj/</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1010</real>
|
||||||
|
</dict>
|
||||||
|
<key>^[^/]+$</key>
|
||||||
|
<dict>
|
||||||
|
<key>nested</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>10</real>
|
||||||
|
</dict>
|
||||||
|
<key>^embedded\.provisionprofile$</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>20</real>
|
||||||
|
</dict>
|
||||||
|
<key>^version\.plist$</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>20</real>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
Executable
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
|||||||
|
A
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
Versions/Current/hidapi
|
||||||
Loaded 100 of 297 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user