Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joystick Interposer Fixes for SDL, Wine, Retroarch and RPCS3 #173

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ sudo chmod 777 /dev/input/js*
if [ -e "/usr/lib/x86_64-linux-gnu/selkies_joystick_interposer.so" ]; then
export SELKIES_INTERPOSER='/usr/$LIB/selkies_joystick_interposer.so'
export LD_PRELOAD="${SELKIES_INTERPOSER}${LD_PRELOAD:+:${LD_PRELOAD}}"
export SDL_JOYSTICK_DEVICE=/dev/input/js0
fi

# Start desktop environment
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/build_and_publish_all_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ jobs:
strategy:
matrix:
include:
- name: conda
build_args: |
PACKAGE_VERSION=0.0.0.dev0
PKG_VERSION=0.0.0
context: addons/conda
# - name: conda
# build_args: |
# PACKAGE_VERSION=0.0.0.dev0
# PKG_VERSION=0.0.0
# context: addons/conda

- name: coturn
context: addons/coturn
Expand Down Expand Up @@ -208,9 +208,9 @@ jobs:
strategy:
matrix:
include:
- name: conda
source: /opt/selkies-gstreamer-conda.tar.gz
target: selkies-gstreamer-portable.tar.gz
# - name: conda
# source: /opt/selkies-gstreamer-conda.tar.gz
# target: selkies-gstreamer-portable.tar.gz

- name: gst-web
source: /opt/gst-web.tar.gz
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/build_and_publish_changed_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ jobs:
strategy:
matrix:
include:
- name: conda
build_args: |
PACKAGE_VERSION=0.0.0.dev0
PKG_VERSION=0.0.0
context: addons/conda
# - name: conda
# build_args: |
# PACKAGE_VERSION=0.0.0.dev0
# PKG_VERSION=0.0.0
# context: addons/conda

- name: coturn
context: addons/coturn
Expand Down Expand Up @@ -237,9 +237,9 @@ jobs:
strategy:
matrix:
include:
- name: conda
source: /opt/selkies-gstreamer-conda.tar.gz
target: selkies-gstreamer-portable.tar.gz
# - name: conda
# source: /opt/selkies-gstreamer-conda.tar.gz
# target: selkies-gstreamer-portable.tar.gz

- name: gst-web
source: /opt/gst-web.tar.gz
Expand Down
4 changes: 2 additions & 2 deletions addons/example/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ until [ -d "${XDG_RUNTIME_DIR}" ]; do sleep 0.5; done
# Configure joystick interposer
export SELKIES_INTERPOSER='/usr/$LIB/selkies_joystick_interposer.so'
export LD_PRELOAD="${SELKIES_INTERPOSER}${LD_PRELOAD:+:${LD_PRELOAD}}"
export SDL_JOYSTICK_DEVICE=/dev/input/js0
mkdir -pm1777 /dev/input || sudo-root mkdir -pm1777 /dev/input || echo 'Failed to create joystick interposer directory'
touch /dev/input/js0 /dev/input/js1 /dev/input/js2 /dev/input/js3 || sudo-root touch /dev/input/js0 /dev/input/js1 /dev/input/js2 /dev/input/js3 || echo 'Failed to create joystick interposer devices'
chmod 777 /dev/input/js* || sudo-root chmod 777 /dev/input/js* || echo 'Failed to change permission for joystick interposer devices'
touch /dev/input/event1000 /dev/input/event1001 /dev/input/event1002 /dev/input/event1003 || sudo-root touch /dev/input/event1000 /dev/input/event1001 /dev/input/event1002 /dev/input/event1003 || echo 'Failed to create joystick interposer devices'
chmod 777 /dev/input/js* /dev/input/event* || sudo-root chmod 777 /dev/input/js* /dev/input/event* || echo 'Failed to change permission for joystick interposer devices'

# Set default display
export DISPLAY="${DISPLAY:-:20}"
Expand Down
1 change: 0 additions & 1 deletion addons/example/selkies-gstreamer-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ until [ -d "${XDG_RUNTIME_DIR}" ]; do sleep 0.5; done
# Configure joystick interposer
export SELKIES_INTERPOSER='/usr/$LIB/selkies_joystick_interposer.so'
export LD_PRELOAD="${SELKIES_INTERPOSER}${LD_PRELOAD:+:${LD_PRELOAD}}"
export SDL_JOYSTICK_DEVICE=/dev/input/js0

# Set default display
export DISPLAY="${DISPLAY:-:20}"
Expand Down
3 changes: 2 additions & 1 deletion addons/js-interposer/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.so
*.so
sdl_joystick_reader
44 changes: 40 additions & 4 deletions addons/js-interposer/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
PREFIX ?= /usr

all:
gcc -shared -fPIC -o selkies_joystick_interposer.so joystick_interposer.c -ldl
all: build build32

install: all
deps:
@sudo apt-get update
@sudo apt-get install -y build-essential evtest strace joystick libsdl2-dev gcc-multilib libevdev-dev

build:
gcc -shared -fPIC -o selkies_joystick_interposer.so joystick_interposer.c -ldl -Wall

build32:
gcc -m32 -shared -fPIC -o selkies_joystick_interposer_i386.so joystick_interposer.c -ldl -Wall

install: build
mkdir -p $(PREFIX)/lib/$(gcc -print-multiarch | sed -e 's/i.*86/i386/')
cp *.so $(PREFIX)/lib/$(gcc -print-multiarch | sed -e 's/i.*86/i386/')/
clean:
rm -f *.so
rm -f *.so
sudo rm -f /dev/input/js0 /dev/input/event1000

fake-devices:
@sudo touch /dev/input/js0 && sudo chmod 777 /dev/input/js0
@sudo touch /dev/input/event1000 && sudo chmod 777 /dev/input/event1000

py-js-test:
python3 js-interposer-test.py /tmp/selkies_js0.sock

py-ev-test:
python3 js-interposer-test.py /tmp/selkies_event1000.sock

jstest: build
LD_PRELOAD=$(PWD)/selkies_joystick_interposer.so jstest /dev/input/js0

evtest: build fake-devices
LD_PRELOAD=$(PWD)/selkies_joystick_interposer.so evtest /dev/input/event1000

sdltest: build fake-devices
gcc -o sdl_joystick_reader sdl-js-test.c -lSDL2
LD_PRELOAD=$(PWD)/selkies_joystick_interposer.so ./sdl_joystick_reader

winetest: build build32 fake-devices
LD_PRELOAD=$(PWD)/selkies_joystick_interposer.so wine control

xvfbtest: build
LD_PRELOAD=$(PWD)/selkies_joystick_interposer.so Xvfb
5 changes: 2 additions & 3 deletions addons/js-interposer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ If using Wine with `x86_64`, both `/usr/lib/x86_64-linux-gnu/selkies_joystick_in
```bash
sudo mkdir -pm1777 /dev/input
sudo touch /dev/input/js0 /dev/input/js1 /dev/input/js2 /dev/input/js3
sudo chmod 777 /dev/input/js*
sudo touch /dev/input/event1000 /dev/input/event1001 /dev/input/event1002 /dev/input/event1003
sudo chmod 777 /dev/input/js* /dev/input/event*
```

3. Use the below command before running your target application as well as Selkies-GStreamer for the interposer library to intercept joystick/gamepad events (the single quotes are required in the first line).

```bash
export SELKIES_INTERPOSER='/usr/$LIB/selkies_joystick_interposer.so'
export LD_PRELOAD="${SELKIES_INTERPOSER}${LD_PRELOAD:+:${LD_PRELOAD}}"
export SDL_JOYSTICK_DEVICE=/dev/input/js0
```

Otherwise, if you only need one architecture, the below is an equivalent command.

```bash
export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/selkies_joystick_interposer.so${LD_PRELOAD:+:${LD_PRELOAD}}"
export SDL_JOYSTICK_DEVICE=/dev/input/js0
```

You can replace `/usr/$LIB/selkies_joystick_interposer.so` with any non-root path of your choice if using the `.tar.gz` tarball. Make sure the correct `selkies_joystick_interposer.so` is installed in that path.
Expand Down
Loading