Skip to content

Commit

Permalink
Merge pull request #72 from games-on-whales/input-upgrade
Browse files Browse the repository at this point in the history
Add PS5 joypad emulation to unprivileged containers
  • Loading branch information
ABeltramo committed Jun 27, 2024
2 parents 3afdfea + 8e798fc commit 64ce420
Show file tree
Hide file tree
Showing 40 changed files with 1,329 additions and 750 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: DoozyX/[email protected]
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# Set derived configuration variables:
# - images: images to build (docker and/or github)
Expand Down Expand Up @@ -109,9 +109,9 @@ jobs:
file: docker/gstreamer.Dockerfile
push: true
build-args: |
GSTREAMER_VERSION=1.22.7
GSTREAMER_VERSION=1.24.5
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/gpu-drivers:2023.11
tags: ghcr.io/${{ github.repository_owner }}/gstreamer:1.22.7,gameonwhales/gstreamer:1.22.7 # TODO: set gstreamer version as param
tags: ghcr.io/${{ github.repository_owner }}/gstreamer:1.24.5,gameonwhales/gstreamer:1.24.5 # TODO: set gstreamer version as param
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/gstreamer:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/gstreamer:buildcache,mode=max
Expand All @@ -126,7 +126,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/gstreamer:1.22.7
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/gstreamer:1.24.5
IMAGE_SOURCE=${{ steps.prep.outputs.github_server_url }}/${{ github.repository }}
cache-from: ${{ steps.prep.outputs.cache_from }}
cache-to: ${{ steps.prep.outputs.cache_to }}
108 changes: 84 additions & 24 deletions .github/workflows/linux-build-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Adapted from https://github.com/catchorg/Catch2/blob/devel/.github/workflows/linux-simple-builds.yml
name: Linux build and test

on:
Expand All @@ -16,7 +15,7 @@ jobs:
timeout-minutes: 30
runs-on: [ self-hosted, ARM64 ] # self-hosted, using Oracle free tier instance
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Prepare environment
run: |
Expand Down Expand Up @@ -47,6 +46,16 @@ jobs:
cargo install cargo-c
cargo cinstall -p c-bindings --prefix=/usr/local
- name: Archive libgstwaylanddisplay-aarch64
uses: actions/upload-artifact@v4
with:
name: libgstwaylanddisplay-aarch64
path: |
/usr/local/lib/aarch64-linux-gnu/liblibgstwaylanddisplay*
/usr/local/lib/aarch64-linux-gnu/pkgconfig/
/usr/local/include/libgstwaylanddisplay/*
if-no-files-found: error

- name: Configure build
working-directory: ${{runner.workspace}}
run: |
Expand All @@ -56,26 +65,70 @@ jobs:
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_CXX_STANDARD=17 \
-DTEST_VIRTUAL_INPUT=OFF \
-DTEST_LIBINPUT=OFF \
-DTEST_DOCKER=ON \
-DLINK_RUST_WAYLAND=ON \
-DTEST_RUST_WAYLAND=OFF \
-DTEST_RUST_WAYLAND=ON \
-DTEST_NVIDIA=OFF \
-DTEST_EXCEPTIONS=OFF \
-DTEST_SDL=OFF \
-DCARGO_TARGET_BUILD=aarch64-unknown-linux-gnu \
-DTEST_UHID=OFF \
-G Ninja
- name: Build tests + lib
working-directory: ${{runner.workspace}}/build
run: ninja -j 4 wolftests
run: ninja -j $(nproc) wolftests

- name: Run tests
working-directory: ${{runner.workspace}}/build/tests
run: ./wolftests
env:
RUST_BACKTRACE: FULL
RUST_LOG: FATAL
XDG_RUNTIME_DIR: /tmp
run: ./wolftests --reporter JUnit::out=${{runner.workspace}}/report.xml --reporter console::out=-::colour-mode=ansi

- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: aarch64
path: ${{runner.workspace}}/report.xml
reporter: java-junit

# First build the common dependencies: Rust-based libgstwaylanddisplay
build-gst-wayland:
runs-on: ubuntu-22.04
steps:
- name: Prepare environment
# ubuntu-latest breaks without libunwind-dev,
# see: https://github.com/actions/runner-images/issues/6399#issuecomment-1286050292
run: |
sudo apt-get update -y
sudo apt-get install -y libunwind-dev
sudo apt-get install -y \
libwayland-dev libwayland-server0 libinput-dev libxkbcommon-dev libgbm-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: Setup gst-wayland-display
run: |
git clone https://github.com/games-on-whales/gst-wayland-display
cd gst-wayland-display
cargo install cargo-c
cargo cinstall -p c-bindings --prefix=/usr/local --destdir=${{runner.workspace}}
- name: Archive libgstwaylanddisplay-x86_64
uses: actions/upload-artifact@v4
with:
name: libgstwaylanddisplay-x86_64
path: |
${{runner.workspace}}/usr/local/lib/x86_64-linux-gnu/liblibgstwaylanddisplay*
${{runner.workspace}}/usr/local/lib/x86_64-linux-gnu/pkgconfig/
${{runner.workspace}}/usr/local/include/libgstwaylanddisplay/*
if-no-files-found: error

test:
runs-on: ubuntu-22.04
needs: build-gst-wayland
strategy:
fail-fast: false
matrix:
Expand All @@ -99,7 +152,18 @@ jobs:


steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Download pre-built libgstwaylanddisplay-x86_64
uses: actions/download-artifact@v4
with:
name: libgstwaylanddisplay-x86_64
path: ${{runner.workspace}}/libgstwaylanddisplay

- name: Move the library in the right place
run: |
ls -R ${{runner.workspace}}/libgstwaylanddisplay
sudo cp -rn ${{runner.workspace}}/libgstwaylanddisplay/* /usr/local/
- name: Prepare environment
# ubuntu-latest breaks without libunwind-dev,
Expand All @@ -122,17 +186,6 @@ jobs:
libunwind-dev \
${{ join(matrix.other_pkgs, ' ') }}
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: Setup gst-wayland-display
run: |
git clone https://github.com/games-on-whales/gst-wayland-display
cd gst-wayland-display
cargo install cargo-c
cargo cinstall -p c-bindings --prefix=/usr/local --destdir=temp
sudo cp -r temp/usr/local/* /usr/local/
- name: Configure build
working-directory: ${{runner.workspace}}
env:
Expand All @@ -149,7 +202,6 @@ jobs:
-DBUILD_SHARED_LIBS=${{ matrix.shared }} \
-DCATCH_DEVELOPMENT_BUILD=ON \
-DTEST_VIRTUAL_INPUT=OFF \
-DTEST_LIBINPUT=OFF \
-DTEST_DOCKER=OFF \
-DLINK_RUST_WAYLAND=ON \
-DTEST_RUST_WAYLAND=OFF \
Expand All @@ -159,8 +211,16 @@ jobs:
- name: Build tests + lib
working-directory: ${{runner.workspace}}/build
run: ninja -j 2 wolftests
run: ninja -j $(nproc) wolftests

- name: Run tests
working-directory: ${{runner.workspace}}/build/tests
run: ./wolftests
run: ./wolftests --reporter JUnit::out=${{runner.workspace}}/report.xml --reporter console::out=-::colour-mode=ansi

- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: ${{matrix.cxx}} - STD ${{ matrix.std }} - Shared ${{ matrix.shared }}
path: ${{runner.workspace}}/report.xml
reporter: java-junit
2 changes: 1 addition & 1 deletion .github/workflows/mirror-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
codeberg:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pixta-dev/repository-mirroring-action@v1
Expand Down
2 changes: 1 addition & 1 deletion docker/gstreamer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ENV DEBIAN_FRONTEND=noninteractive
ENV BUILD_ARCHITECTURE=amd64
ENV DEB_BUILD_OPTIONS=noddebs

ARG GSTREAMER_VERSION=1.22.7
ARG GSTREAMER_VERSION=1.24.5
ENV GSTREAMER_VERSION=$GSTREAMER_VERSION

ENV SOURCE_PATH=/sources/
Expand Down
4 changes: 2 additions & 2 deletions docker/wolf.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=ghcr.io/games-on-whales/gstreamer:1.22.7
ARG BASE_IMAGE=ghcr.io/games-on-whales/gstreamer:1.24.5
########################################################
FROM $BASE_IMAGE AS wolf-builder

Expand Down Expand Up @@ -39,7 +39,7 @@ RUN <<_GST_WAYLAND_DISPLAY
cd gst-wayland-display
git checkout 6c7d8cb
cargo install cargo-c
cargo cinstall -p c-bindings --prefix=/usr/local
cargo cinstall -p c-bindings --prefix=/usr/local --libdir=/usr/local/lib/
_GST_WAYLAND_DISPLAY

COPY . /wolf/
Expand Down
20 changes: 20 additions & 0 deletions docs/modules/user/pages/configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,26 @@ source = "audiotestsrc wave=ticks is-live=true"

See more examples in the xref:gstreamer.adoc[] page.

=== Override the default joypad mapping

By default, Wolf will try to match the joypad type that Moonlight sends with the correct mapping.
It is possible to override this behaviour by setting the `joypad_mapping` property in the `apps` entry; example:

[source,toml]
....
[[apps]]
title = "Test ball"
joypad_type = "xbox" # Force the joypad to always be xbox
....

The available joypad types are:

* `auto` (default)
* `xbox`
* `nintendo`
* `ps`


[#_app_runner]
==== App Runner

Expand Down
19 changes: 11 additions & 8 deletions docs/modules/user/pages/quickstart.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ docker run \
-v /var/run/docker.sock:/var/run/docker.sock:rw \
--device /dev/dri/ \
--device /dev/uinput \
-v /dev/shm:/dev/shm:rw \
-v /dev/input:/dev/input:rw \
--device /dev/uhid \
-v /dev/:/dev/:rw \
-v /run/udev:/run/udev:rw \
--device-cgroup-rule "c 13:* rmw" \
ghcr.io/games-on-whales/wolf:stable
Expand All @@ -46,14 +46,14 @@ services:
- /etc/wolf/:/etc/wolf
- /tmp/sockets:/tmp/sockets:rw
- /var/run/docker.sock:/var/run/docker.sock:rw
- /dev/shm:/dev/shm:rw
- /dev/input:/dev/input:rw
- /dev/:/dev/:rw
- /run/udev:/run/udev:rw
device_cgroup_rules:
- 'c 13:* rmw'
devices:
- /dev/dri
- /dev/uinput
- /dev/uhid
network_mode: host
restart: unless-stopped
....
Expand Down Expand Up @@ -142,8 +142,8 @@ docker run \
--device /dev/nvidia0 \
--device /dev/nvidia-modeset \
--device /dev/uinput \
-v /dev/shm:/dev/shm:rw \
-v /dev/input:/dev/input:rw \
--device /dev/uhid \
-v /dev/:/dev/:rw \
-v /run/udev:/run/udev:rw \
--device-cgroup-rule "c 13:* rmw" \
ghcr.io/games-on-whales/wolf:stable
Expand All @@ -165,13 +165,13 @@ services:
- /etc/wolf/:/etc/wolf:rw
- /tmp/sockets:/tmp/sockets:rw
- /var/run/docker.sock:/var/run/docker.sock:rw
- /dev/shm:/dev/shm:rw
- /dev/input:/dev/input:rw
- /dev/:/dev/:rw
- /run/udev:/run/udev:rw
- nvidia-driver-vol:/usr/nvidia:rw
devices:
- /dev/dri
- /dev/uinput
- /dev/uhid
- /dev/nvidia-uvm
- /dev/nvidia-uvm-tools
- /dev/nvidia-caps/nvidia-cap1
Expand Down Expand Up @@ -296,6 +296,9 @@ sudo usermod -a -G input $USER
# Allows Wolf to acces /dev/uinput
KERNEL=="uinput", SUBSYSTEM=="misc", MODE="0660", GROUP="input", OPTIONS+="static_node=uinput"
# Allows Wolf to access /dev/uhid
KERNEL=="uhid", TAG+="uaccess"
# Move virtual keyboard and mouse into a different seat
SUBSYSTEMS=="input", ATTRS{id/vendor}=="ab00", MODE="0660", GROUP="input", ENV{ID_SEAT}="seat9"
Expand Down
15 changes: 10 additions & 5 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ if (UNIX AND NOT APPLE)
add_subdirectory(src/platforms/linux/pulseaudio)
target_link_libraries(wolf_core PUBLIC wolf::audio)

FetchContent_Declare(
inputtino
GIT_REPOSITORY https://github.com/games-on-whales/inputtino.git
GIT_TAG 753a639)
FetchContent_MakeAvailable(inputtino)
option(WOLF_CUSTOM_INPUTTINO_SRC "Use custom inputtino source" OFF)
if(WOLF_CUSTOM_INPUTTINO_SRC)
add_subdirectory(${WOLF_CUSTOM_INPUTTINO_SRC} ${CMAKE_CURRENT_BINARY_DIR}/inputtino EXCLUDE_FROM_ALL)
else()
FetchContent_Declare(
inputtino
GIT_REPOSITORY https://github.com/games-on-whales/inputtino.git
GIT_TAG f8f5a81)
FetchContent_MakeAvailable(inputtino)
endif ()

add_subdirectory(src/platforms/linux/uinput)
target_link_libraries(wolf_core PUBLIC wolf::uinput)
Expand Down
Loading

0 comments on commit 64ce420

Please sign in to comment.