Skip to content

Commit

Permalink
gamepad: hide behind -d shy_gamepad to maintain SDL2 2.0.8+ compati…
Browse files Browse the repository at this point in the history
…bility (#12)
  • Loading branch information
larpon authored Apr 2, 2024
1 parent 20aba9d commit cac0d78
Show file tree
Hide file tree
Showing 4 changed files with 326 additions and 223 deletions.
85 changes: 78 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ jobs:
# shy test-cleancode ~/.vmodules/shy

ubuntu-latest-bootstrap:
runs-on: ubuntu-20.04 # use 20.04 for now (SDL2 compile issue)
runs-on: ubuntu-20.04
timeout-minutes: 20
env:
VFLAGS: -cc tcc -no-retry-compilation
SDL2_VERSION: 2.26.0
SDL2_VERSION: 2.0.9
steps:
- name: Install dependencies
run: |
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
timeout-minutes: 10
env:
VFLAGS: -cc tcc -no-retry-compilation
SDL2_VERSION: 2.26.0
SDL2_VERSION: 2.0.9
steps:
- name: Install dependencies
run: |
Expand Down Expand Up @@ -205,11 +205,11 @@ jobs:
v ~/.vmodules/shy/examples/hello_world
ubuntu-latest-build:
runs-on: ubuntu-latest # use 20.04 for now (SDL2 compile issue)
runs-on: ubuntu-latest
timeout-minutes: 20
env:
VFLAGS: -cc tcc -no-retry-compilation
SDL2_VERSION: 2.26.0
SDL2_VERSION: 2.0.9
steps:
- name: Install dependencies
run: |
Expand Down Expand Up @@ -277,8 +277,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
# sdl-version: [2.0.9, 2.0.10, 2.0.12, 2.0.14, 2.0.16, 2.0.18, 2.0.20, 2.0.22, 2.24.0, 2.26.0, 2.28.0, 2.30.0]
sdl-version: [2.26.0, 2.28.0, 2.30.0] # Gameped support
sdl-version: [2.0.9, 2.0.10, 2.0.12, 2.0.14, 2.0.16, 2.0.18, 2.0.20, 2.0.22, 2.24.0, 2.26.0, 2.28.0, 2.30.0]
timeout-minutes: 20
env:
VFLAGS: -cc tcc -no-retry-compilation
Expand Down Expand Up @@ -344,3 +343,75 @@ jobs:
v -d sdl_no_compile_flags -skip-unused should-compile-all ~/.vmodules/shy/examples
v -d sdl_no_compile_flags -d shy_analyse should-compile-all ~/.vmodules/shy/examples
v -d sdl_no_compile_flags -d shy_vet should-compile-all ~/.vmodules/shy/examples
sdl-d-gamepad-branch-versions:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
sdl-version: [2.26.0, 2.28.0, 2.30.0] # Gamepad support requires SDL2 >= 2.26.0
timeout-minutes: 20
env:
VFLAGS: -cc tcc -no-retry-compilation -d shy_gamepad
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y mesa-common-dev
curl -L https://www.libsdl.org/release/SDL2-${{ matrix.sdl-version }}.tar.gz -o SDL2.tar.gz
tar -zxvf SDL2.tar.gz
- name: Build SDL
run: |
cd SDL2-${{ matrix.sdl-version }}
mkdir build
cd build
../configure
make
sudo make install
- name: Checkout V
uses: actions/checkout@v4
with:
repository: vlang/v

- name: Build local v
run: make && sudo ./v symlink

- name: Checkout SDL ${{ matrix.sdl-version }}
uses: actions/checkout@v4
with:
ref: ${{ matrix.sdl-version }}
repository: vlang/sdl
path: sdl

- name: Simulate "v install sdl"
run: |
mkdir -p ~/.vmodules
mv sdl ~/.vmodules
- name: Checkout shy
uses: actions/checkout@v4
with:
path: shy

- name: Simulate "v install shy"
run: mv shy ~/.vmodules

- name: Build shy
run: v -g ~/.vmodules/shy

- name: Symlink shy
run: sudo ln -s ~/.vmodules/shy/shy /usr/local/bin/shy

- name: Run 'shy --help'
run: shy --help

- name: Run 'shy doctor'
run: shy doctor

- name: Build shy examples
run: |
v -d sdl_no_compile_flags -skip-unused should-compile-all ~/.vmodules/shy/examples
v -d sdl_no_compile_flags -d shy_analyse should-compile-all ~/.vmodules/shy/examples
v -d sdl_no_compile_flags -d shy_vet should-compile-all ~/.vmodules/shy/examples
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,9 @@ sudo ln -s ~/.vmodules/shy/shy /usr/local/bin/shy
## Shell tab completion (optional)
You can install tab completions for your shell by [following the instructions
here](https://github.com/Larpon/shy/blob/fb26741/cmd/complete.v#L11-L38).

# Gamepad / Controller support

To enable game controller support shy needs to be built with
SDL2 version >= 2.26.0 in addition to the compile flag `-d shy_gamepad`.

Loading

0 comments on commit cac0d78

Please sign in to comment.