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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ jobs:
libwayland-dev \
libx11-xcb-dev \
libxcb-dri3-dev \
libxfixes-dev
libxfixes-dev \
libxtst-dev

- name: Build latest libva
env:
Expand Down
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
[submodule "third-party/glad"]
path = third-party/glad
url = https://github.com/Dav1dde/glad.git
[submodule "third-party/inputtino"]
path = third-party/inputtino
url = https://github.com/games-on-whales/inputtino.git
branch = stable
[submodule "third-party/libdisplaydevice"]
path = third-party/libdisplaydevice
url = https://github.com/LizardByte/libdisplaydevice.git
branch = master
[submodule "third-party/libvirtualhid"]
path = third-party/libvirtualhid
url = https://github.com/LizardByte/libvirtualhid.git
branch = master
[submodule "third-party/lizardbyte-common"]
path = third-party/lizardbyte-common
url = https://github.com/LizardByte/lizardbyte-common.git
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
# `CMAKE_CUDA_ARCHITECTURES` requires 3.18
# `set_source_files_properties` requires 3.18
# `cmake_path(CONVERT ... TO_NATIVE_PATH_LIST ...)` requires 3.20
# `third-party/libvirtualhid` requires 3.24
# todo - set this conditionally

project(Sunshine VERSION 0.0.0
Expand Down
12 changes: 12 additions & 0 deletions cmake/compile_definitions/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ elseif(UNIX)
endif()
endif()

# libvirtualhid
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/libvirtualhid")
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES libvirtualhid::libvirtualhid)
list(APPEND PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/src/platform/virtualhid_input.h"
"${CMAKE_SOURCE_DIR}/src/platform/virtualhid_input.cpp")

# build libevdev before the libvirtualhid target when using the ExternalProject fallback
if(EXTERNAL_PROJECT_LIBEVDEV_USED AND TARGET libvirtualhid)
add_dependencies(libvirtualhid libevdev)
endif()

include_directories(BEFORE SYSTEM "${CMAKE_SOURCE_DIR}/third-party/nv-codec-headers/include")
file(GLOB NVENC_SOURCES CONFIGURE_DEPENDS "src/nvenc/*.cpp" "src/nvenc/*.h")
list(APPEND PLATFORM_TARGET_FILES ${NVENC_SOURCES})
Expand Down
18 changes: 3 additions & 15 deletions cmake/compile_definitions/linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -296,24 +296,12 @@ if(NOT ${CUDA_FOUND}
message(FATAL_ERROR "Couldn't find either cuda, libdrm, libva, kwin, pipewire, portal, wayland or x11")
endif()

# These need to be set before adding the inputtino subdirectory in order for them to be picked up
# These need to be set before common.cmake adds the libvirtualhid subdirectory in order for them to be picked up
set(LIBEVDEV_CUSTOM_INCLUDE_DIR "${EVDEV_INCLUDE_DIR}")
set(LIBEVDEV_CUSTOM_LIBRARY "${EVDEV_LIBRARY}")
if(FREEBSD)
set(USE_UHID OFF)
endif()

add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/inputtino")
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES inputtino::libinputtino)
file(GLOB_RECURSE INPUTTINO_SOURCES
${CMAKE_SOURCE_DIR}/src/platform/linux/input/inputtino*.h
${CMAKE_SOURCE_DIR}/src/platform/linux/input/inputtino*.cpp)
list(APPEND PLATFORM_TARGET_FILES ${INPUTTINO_SOURCES})

# build libevdev before the libinputtino target
if(EXTERNAL_PROJECT_LIBEVDEV_USED)
add_dependencies(libinputtino libevdev)
endif()
list(APPEND PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/src/platform/linux/input/virtualhid.cpp")

# AppImage and Flatpak
if (${SUNSHINE_BUILD_APPIMAGE})
Expand Down
5 changes: 0 additions & 5 deletions cmake/compile_definitions/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ set_target_properties(sunshine_rc_object PROPERTIES
INCLUDE_DIRECTORIES ""
)

# ViGEmBus version
set(VIGEMBUS_PACKAGED_V "1.21.442")
set(VIGEMBUS_PACKAGED_V_2 "${VIGEMBUS_PACKAGED_V}.0")
list(APPEND SUNSHINE_DEFINITIONS VIGEMBUS_PACKAGED_VERSION="${VIGEMBUS_PACKAGED_V_2}")

set(PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/src/platform/windows/publish.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/windows/misc.h"
Expand Down
25 changes: 0 additions & 25 deletions cmake/packaging/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@ if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64" AND DEFINED _MINHOOK_DLL)
install(FILES "${_MINHOOK_DLL}" DESTINATION "." COMPONENT application)
endif()

# ViGEmBus installer
set(SUNSHINE_THIRD_PARTY_DIR "third-party")
set(VIGEMBUS_INSTALLER "${CMAKE_BINARY_DIR}/${SUNSHINE_THIRD_PARTY_DIR}/vigembus_installer.exe")
set(VIGEMBUS_DOWNLOAD_URL_1 "https://github.com/nefarius/ViGEmBus/releases/download")
set(VIGEMBUS_DOWNLOAD_URL_2 "v${VIGEMBUS_PACKAGED_V_2}/ViGEmBus_${VIGEMBUS_PACKAGED_V}_x64_x86_arm64.exe")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${SUNSHINE_THIRD_PARTY_DIR}")
file(DOWNLOAD
"${VIGEMBUS_DOWNLOAD_URL_1}/${VIGEMBUS_DOWNLOAD_URL_2}"
${VIGEMBUS_INSTALLER}
SHOW_PROGRESS
EXPECTED_HASH SHA256=155c50f1eec07bdc28d2f61a3e3c2c6c132fee7328412de224695f89143316bc
TIMEOUT 60
)
install(FILES ${VIGEMBUS_INSTALLER}
DESTINATION "${SUNSHINE_THIRD_PARTY_DIR}"
RENAME "vigembus_installer.exe"
COMPONENT gamepad)

# Adding tools
install(TARGETS dxgi-info RUNTIME DESTINATION "tools" COMPONENT dxgi)
install(TARGETS audio-info RUNTIME DESTINATION "tools" COMPONENT audio)
Expand Down Expand Up @@ -80,8 +62,6 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")

# Setting components groups and dependencies
set(CPACK_COMPONENT_GROUP_CORE_EXPANDED true)
set(CPACK_COMPONENT_GROUP_THIRDPARTY_DISPLAY_NAME "Third Party")
set(CPACK_COMPONENT_GROUP_THIRDPARTY_DESCRIPTION "Bundled third-party installers and optional components.")

# sunshine binary
set(CPACK_COMPONENT_APPLICATION_DISPLAY_NAME "${CMAKE_PROJECT_NAME}")
Expand Down Expand Up @@ -116,11 +96,6 @@ set(CPACK_COMPONENT_FIREWALL_DISPLAY_NAME "Add Firewall Exclusions")
set(CPACK_COMPONENT_FIREWALL_DESCRIPTION "Scripts to enable or disable firewall rules.")
set(CPACK_COMPONENT_FIREWALL_GROUP "Scripts")

# gamepad third-party installer
set(CPACK_COMPONENT_GAMEPAD_DISPLAY_NAME "Virtual Gamepad")
set(CPACK_COMPONENT_GAMEPAD_DESCRIPTION "ViGEmBus installer for virtual gamepad support.")
set(CPACK_COMPONENT_GAMEPAD_GROUP "ThirdParty")

# include specific packaging
include(${CMAKE_MODULE_PATH}/packaging/windows_nsis.cmake)
include(${CMAKE_MODULE_PATH}/packaging/windows_wix.cmake)
9 changes: 8 additions & 1 deletion cmake/targets/linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ if(NOT FREEBSD)
# Using newer c++ compilers / features on older distros causes runtime dyn link errors
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
-static-libgcc
-static-libstdc++
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
# GCC 15's static libstdc++ does not provide the out-of-line wait/notify
# symbol used by std::stop_token, so libstdc++ must be a direct DSO input.
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES stdc++)
else()
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES -static-libstdc++)
endif()
endif()
7 changes: 2 additions & 5 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,8 @@ curl -u user:pass -H "X-CSRF-Token: your_token_here" \
## POST /api/restart
@copydoc confighttp::restart()

## GET /api/vigembus/status
@copydoc confighttp::getViGEmBusStatus()

## POST /api/vigembus/install
@copydoc confighttp::installViGEmBus()
## GET /api/virtual-input/status
@copydoc confighttp::getVirtualInputStatus()

<div class="section_buttons">

Expand Down
29 changes: 19 additions & 10 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,30 +332,40 @@ editing the `conf` file in a text editor. Use the examples as reference.
@endcode</td>
</tr>
<tr>
<td rowspan="6">Choices</td>
<td rowspan="7">Choices</td>
<td>generic</td>
<td>Generic HID gamepad
@note{This option applies to FreeBSD, Linux, and Windows.}</td>
</tr>
<tr>
<td>ds4</td>
<td>DualShock 4 controller (PS4)
@note{This option applies to Windows only.}</td>
@note{This option applies to FreeBSD, Linux, and Windows.}</td>
</tr>
<tr>
<td>ds5</td>
<td>DualShock 5 controller (PS5)
@note{This option applies to FreeBSD and Linux only.}</td>
@note{This option applies to FreeBSD, Linux, and Windows.}</td>
</tr>
<tr>
<td>switch</td>
<td>Switch Pro controller
@note{This option applies to FreeBSD and Linux only.}</td>
@note{This option applies to FreeBSD, Linux, and Windows.}</td>
</tr>
<tr>
<td>x360</td>
<td>Xbox 360 controller
@note{This option applies to Windows only.}</td>
@note{This option applies to FreeBSD, Linux, and Windows.}</td>
</tr>
<tr>
<td>xone</td>
<td>Xbox One controller
@note{This option applies to FreeBSD and Linux only.}</td>
@note{This option applies to FreeBSD, Linux, and Windows.}</td>
</tr>
<tr>
<td>xseries</td>
<td>Xbox Series controller
@note{This option applies to FreeBSD, Linux, and Windows.}</td>
</tr>
</table>

Expand Down Expand Up @@ -440,14 +450,13 @@ editing the `conf` file in a text editor. Use the examples as reference.
</tr>
</table>

### ds5_inputtino_randomize_mac
### virtualhid_randomize_mac

<table>
<tr>
<td>Description</td>
<td colspan="2">
Randomize the MAC-Address for the generated virtual controller.
@hint{Only applies on linux for gamepads created as PS5-style controllers}
Randomize the MAC address for PlayStation-style virtual controllers created by libvirtualhid.
</td>
</tr>
<tr>
Expand All @@ -459,7 +468,7 @@ editing the `conf` file in a text editor. Use the examples as reference.
<tr>
<td>Example</td>
<td colspan="2">@code{}
ds5_inputtino_randomize_mac = enabled
virtualhid_randomize_mac = enabled
@endcode</td>
</tr>
</table>
Expand Down
8 changes: 4 additions & 4 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,11 @@ and enter its device name in the [audio_sink](configuration.md#audio_sink) field
> Gamepads are not currently supported.
### Windows
In order for virtual gamepads to work, you must install ViGEmBus. You can do this from the troubleshooting tab
in the web UI, as long as you are running Sunshine as a service or as an administrator. After installation, it is
recommended to restart your computer.
Sunshine uses libvirtualhid for virtual gamepads on Windows. You must install the libvirtualhid Windows driver
separately for full virtual gamepad support. ViGEmBus is detected only as a limited fallback for Xbox 360 and
DualShock 4 gamepads when libvirtualhid is unavailable.

![ViGEmBus Installation](images/vigembus-installer.png)
After installing or updating virtual input drivers, it is recommended to restart your computer.

## Usage

Expand Down
7 changes: 3 additions & 4 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,9 @@ launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
## Windows

### No gamepad detected
You must install ViGEmBus to use virtual gamepads. You can install this from the troubleshooting tab of the web UI.

Alternatively, you can manually install it from
[ViGEmBus releases](https://github.com/nefarius/ViGEmBus/releases/latest). You must use version 1.17 or newer.
Sunshine uses libvirtualhid for virtual gamepads on Windows. Install the libvirtualhid Windows driver separately
for full virtual gamepad support. ViGEmBus is detected only as a limited fallback for Xbox 360 and DualShock 4
gamepads when libvirtualhid is unavailable. If you use ViGEmBus fallback, you must use version 1.17 or newer.

After installation, it is recommended to restart your computer.

Expand Down
1 change: 0 additions & 1 deletion gh-pages-template/_data/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
Sunshine emulates an Xbox, PlayStation, or Nintendo Switch controller.
Use nearly any controller on your Moonlight client!
<br><small><ul>
<li>Nintendo Switch emulation is only available on Linux.</li>
<li>Gamepad emulation is not currently supported on macOS.</li>
</ul></small>
Expand Down
1 change: 1 addition & 0 deletions packaging/linux/Arch/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fi
depends=(
'avahi'
'curl'
'gcc-libs'
'gtk3'
'hicolor-icon-theme'
'libayatana-appindicator'
Expand Down
4 changes: 2 additions & 2 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ namespace config {
true, // back as touchpad click enabled (manual DS4 only)
true, // client gamepads with motion events are emulated as DS4
true, // client gamepads with touchpads are emulated as DS4
true, // ds5_inputtino_randomize_mac
true, // virtualhid_randomize_mac

true, // keyboard enabled
true, // mouse enabled
Expand Down Expand Up @@ -1690,7 +1690,7 @@ namespace config {
bool_f(vars, "ds4_back_as_touchpad_click", input.ds4_back_as_touchpad_click);
bool_f(vars, "motion_as_ds4", input.motion_as_ds4);
bool_f(vars, "touchpad_as_ds4", input.touchpad_as_ds4);
bool_f(vars, "ds5_inputtino_randomize_mac", input.ds5_inputtino_randomize_mac);
bool_f(vars, "virtualhid_randomize_mac", input.virtualhid_randomize_mac);

bool_f(vars, "mouse", input.mouse);
bool_f(vars, "keyboard", input.keyboard);
Expand Down
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ namespace config {
bool ds4_back_as_touchpad_click; ///< Map the DS4 Back button to a touchpad click.
bool motion_as_ds4; ///< Expose motion controls through the DS4 protocol.
bool touchpad_as_ds4; ///< Expose touchpad input through the DS4 protocol.
bool ds5_inputtino_randomize_mac; ///< Randomize the inputtino DualSense MAC address.
bool virtualhid_randomize_mac; ///< Randomize the libvirtualhid virtual controller MAC address.

bool keyboard; ///< Enable keyboard input from clients.
bool key_rightalt_to_key_win; ///< Map the client Right Alt key to the Windows key.
Expand Down
Loading
Loading