Skip to content

Commit 7114784

Browse files
committed
Add new API to modify display devices for Windows
1 parent 8316f44 commit 7114784

54 files changed

Lines changed: 6156 additions & 90 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/CI.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,6 @@ jobs:
729729
mingw-w64-x86_64-cmake
730730
mingw-w64-x86_64-curl
731731
mingw-w64-x86_64-miniupnpc
732-
mingw-w64-x86_64-nlohmann-json
733732
mingw-w64-x86_64-nodejs
734733
mingw-w64-x86_64-nsis
735734
mingw-w64-x86_64-onevpl

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@
4242
path = third-party/wlr-protocols
4343
url = https://gitlab.freedesktop.org/wlroots/wlr-protocols
4444
branch = master
45+
[submodule "third-party/nlohmann_json"]
46+
path = third-party/nlohmann_json
47+
url = https://github.com/nlohmann/json
48+
branch = master

cmake/compile_definitions/common.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ set(SUNSHINE_TARGET_FILES
5656
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/RtspParser.c"
5757
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Video.h"
5858
"${CMAKE_SOURCE_DIR}/third-party/tray/tray.h"
59+
"${CMAKE_SOURCE_DIR}/src/display_device/display_device.h"
60+
"${CMAKE_SOURCE_DIR}/src/display_device/parsed_config.cpp"
61+
"${CMAKE_SOURCE_DIR}/src/display_device/parsed_config.h"
62+
"${CMAKE_SOURCE_DIR}/src/display_device/session.cpp"
63+
"${CMAKE_SOURCE_DIR}/src/display_device/session.h"
64+
"${CMAKE_SOURCE_DIR}/src/display_device/settings.cpp"
65+
"${CMAKE_SOURCE_DIR}/src/display_device/settings.h"
66+
"${CMAKE_SOURCE_DIR}/src/display_device/to_string.cpp"
67+
"${CMAKE_SOURCE_DIR}/src/display_device/to_string.h"
5968
"${CMAKE_SOURCE_DIR}/src/upnp.cpp"
6069
"${CMAKE_SOURCE_DIR}/src/upnp.h"
6170
"${CMAKE_SOURCE_DIR}/src/cbs.cpp"
@@ -152,4 +161,5 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
152161
${Boost_LIBRARIES}
153162
${OPENSSL_LIBRARIES}
154163
${CURL_LIBRARIES}
164+
${JSON_LIBRARIES}
155165
${PLATFORM_LIBRARIES})

cmake/compile_definitions/linux.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ list(APPEND PLATFORM_TARGET_FILES
242242
"${CMAKE_SOURCE_DIR}/src/platform/linux/misc.cpp"
243243
"${CMAKE_SOURCE_DIR}/src/platform/linux/audio.cpp"
244244
"${CMAKE_SOURCE_DIR}/src/platform/linux/input.cpp"
245+
"${CMAKE_SOURCE_DIR}/src/platform/linux/display_device.cpp"
245246
"${CMAKE_SOURCE_DIR}/third-party/glad/src/egl.c"
246247
"${CMAKE_SOURCE_DIR}/third-party/glad/src/gl.c"
247248
"${CMAKE_SOURCE_DIR}/third-party/glad/include/EGL/eglplatform.h"

cmake/compile_definitions/macos.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ set(PLATFORM_TARGET_FILES
3030
"${CMAKE_SOURCE_DIR}/src/platform/macos/av_video.h"
3131
"${CMAKE_SOURCE_DIR}/src/platform/macos/av_video.m"
3232
"${CMAKE_SOURCE_DIR}/src/platform/macos/display.mm"
33+
"${CMAKE_SOURCE_DIR}/src/platform/macos/display_device.cpp"
3334
"${CMAKE_SOURCE_DIR}/src/platform/macos/input.cpp"
3435
"${CMAKE_SOURCE_DIR}/src/platform/macos/microphone.mm"
3536
"${CMAKE_SOURCE_DIR}/src/platform/macos/misc.mm"

cmake/compile_definitions/windows.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ set(PLATFORM_TARGET_FILES
5858
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_vram.cpp"
5959
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_ram.cpp"
6060
"${CMAKE_SOURCE_DIR}/src/platform/windows/audio.cpp"
61+
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_device/device_hdr_states.cpp"
62+
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_device/device_modes.cpp"
63+
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_device/device_topology.cpp"
64+
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_device/general_functions.cpp"
65+
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_device/settings_topology.cpp"
66+
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_device/settings_topology.h"
67+
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_device/settings.cpp"
68+
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_device/windows_utils.h"
69+
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_device/windows_utils.cpp"
6170
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/src/ViGEmClient.cpp"
6271
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Client.h"
6372
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Common.h"
@@ -84,7 +93,6 @@ list(PREPEND PLATFORM_LIBRARIES
8493
avrt
8594
iphlpapi
8695
shlwapi
87-
PkgConfig::NLOHMANN_JSON
8896
${CURL_STATIC_LIBRARIES})
8997

9098
if(SUNSHINE_ENABLE_TRAY)

cmake/dependencies/common.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ pkg_check_modules(CURL REQUIRED libcurl)
1919
pkg_check_modules(MINIUPNP miniupnpc REQUIRED)
2020
include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS})
2121

22+
# nlohmann_json
23+
if(NOT SUNSHINE_SYSTEM_NLOHMANN_JSON)
24+
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/nlohmann_json")
25+
set(JSON_LIBRARIES nlohmann_json::nlohmann_json)
26+
else()
27+
pkg_check_modules(NLOHMANN_JSON nlohmann_json>=3.9.0 REQUIRED IMPORTED_TARGET)
28+
set(JSON_LIBRARIES PkgConfig::NLOHMANN_JSON)
29+
endif()
30+
2231
# ffmpeg pre-compiled binaries
2332
if(WIN32)
2433
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")

cmake/dependencies/windows.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@
22

33
set(Boost_USE_STATIC_LIBS ON) # cmake-lint: disable=C0103
44
find_package(Boost 1.71.0 COMPONENTS locale log filesystem program_options REQUIRED)
5-
6-
# nlohmann_json
7-
pkg_check_modules(NLOHMANN_JSON nlohmann_json REQUIRED IMPORTED_TARGET)

cmake/prep/options.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF)
66
option(SUNSHINE_ENABLE_TRAY "Enable system tray icon. This option will be ignored on macOS." ON)
77
option(SUNSHINE_REQUIRE_TRAY "Require system tray icon. Fail the build if tray requirements are not met." ON)
88

9+
option(SUNSHINE_SYSTEM_NLOHMANN_JSON "Use system installation of nlohmann_json rather than the submodule." OFF)
910
option(SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS "Use system installation of wayland-protocols rather than the submodule." OFF)
1011

1112
option(CUDA_INHERIT_COMPILE_OPTIONS

docs/source/about/advanced_usage.rst

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ keybindings
535535
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
536536

537537
**Description**
538-
Select the display number you want to stream.
538+
Select the display you want to stream.
539539

540540
.. tip:: To find the name of the appropriate values follow these instructions.
541541

@@ -556,9 +556,35 @@ keybindings
556556
.. todo:: macOS
557557

558558
**Windows**
559-
.. code-block:: batch
559+
During Sunshine startup, you should see the list of detected display devices:
560560

561-
tools\dxgi-info.exe
561+
.. code-block:: text
562+
563+
DEVICE ID: {de9bb7e2-186e-505b-9e93-f48793333810}
564+
DISPLAY NAME: \\.\DISPLAY1
565+
FRIENDLY NAME: ROG PG279Q
566+
DEVICE STATE: PRIMARY
567+
HDR STATE: UNKNOWN
568+
-----------------------
569+
DEVICE ID: {3bd008cd-0465-547c-8da5-c28749c041e6}
570+
DISPLAY NAME: NOT AVAILABLE
571+
FRIENDLY NAME: IDD HDR
572+
DEVICE STATE: INACTIVE
573+
HDR STATE: UNKNOWN
574+
-----------------------
575+
DEVICE ID: {77f67f3e-754f-5d31-af64-ee037e18100a}
576+
DISPLAY NAME: NOT AVAILABLE
577+
FRIENDLY NAME: SunshineHDR
578+
DEVICE STATE: INACTIVE
579+
HDR STATE: UNKNOWN
580+
-----------------------
581+
DEVICE ID: {bc172e6d-86eb-5851-aeca-56525ed716e9}
582+
DISPLAY NAME: NOT AVAILABLE
583+
FRIENDLY NAME: ROG PG279Q
584+
DEVICE STATE: INACTIVE
585+
HDR STATE: UNKNOWN
586+
587+
You need to use the ``DEVICE ID`` value.
562588

563589
**Default**
564590
Sunshine will select the default display.
@@ -574,7 +600,7 @@ keybindings
574600
**Windows**
575601
.. code-block:: text
576602
577-
output_name = \\.\DISPLAY1
603+
output_name = {de9bb7e2-186e-505b-9e93-f48793333810}
578604
579605
`resolutions <https://localhost:47990/config/#resolutions>`__
580606
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)