Skip to content

Commit

Permalink
release v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
e2dk4r committed Apr 7, 2024
0 parents commit b810fa6
Show file tree
Hide file tree
Showing 8 changed files with 758 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
Language: Cpp
ColumnLimit: 120
BreakBeforeBraces: Linux
AlwaysBreakAfterReturnType: TopLevel
40 changes: 40 additions & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: compile

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: install packages
run: sudo apt-get install -y --no-install-recommends --no-install-suggests
meson ninja-build
libevdev-dev liburing-dev
libwayland-dev libwayland-client0 wayland-protocols

- name: configure
run: CFLAGS='-O3 -pipe' meson setup build --buildtype release

- name: compile
run: ninja -C build

- name: release
env:
GH_TOKEN: ${{ github.token }}
if: ${{ startsWith(github.event.head_commit.message, 'release:') }}
continue-on-error: true
run: |
strip build/gamepad_idle_inhibit
version=$(echo ${{ github.event.head_commit.message }} | tr ' ' '\n' | tail -n 1)
file=build/gamepad_idle_inhibit
echo **Workflow run**: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID >> notes
gh release create $version --notes-file notes $file
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
.cache/
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# gamepad_idle_inhibit

Prevent idling for 5 minutes (300 seconds) on any gamepad events on wayland.

For this to work your wayland compositor must support "idle-inhibit-unstable-v1".

Forked from https://github.com/e2dk4r/gamepad and adapted to wayland.

# limits

- Simultaneously 10 gamepad connections detected. So if you were able to connect 11 gamepads at same time this would behave unexpectedly.
- Can read events from maximum of 250 gamepads.

# requirements

- 23 + 9 kilobytes of memory
- Wayland compositor that supports [idle-inhibit-unstable-v1](https://wayland.app/protocols/idle-inhibit-unstable-v1#compositor-support)

# libraries

| library | used for |
|----------------|-------------------------------------|
| liburing | event loop and polling |
| libevdev | detecting whether device is gamepad |
| wayland-client | connecting to wayland display |

# build

```
meson setup build
ninja -C build
./build/gamepad
```

# references

- see chapter "5. Event interface" in https://www.kernel.org/doc/Documentation/input/input.txt
- see https://www.kernel.org/doc/Documentation/input/gamepad.txt
- see the key codes included in `/usr/include/linux/input-event-codes.h`
- see https://unixism.net/loti/tutorial/index.html for liburing examples
- if you have libinput on your system, see `man libinput-record(1)` for debugging input events
- see https://wayland-book.com/ for introduction to wayland
35 changes: 35 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
project(
'gamepad_idle_inhibit',
'c',
license: 'MIT',
version: '0.1.0',
default_options: 'c_std=c99'
)

add_project_arguments([
'-funroll-loops',
'-fomit-frame-pointer',
],
language: 'c'
)

libevdev = dependency('libevdev')
liburing = dependency('liburing')
wayland_client = dependency('wayland-client')
wayland_protocols = dependency('wayland-protocols', native: true)

subdir('protocol')

sources = files([
'src/main.c'
])

executable(
'gamepad_idle_inhibit',
sources: sources + wl_protocols_src,
dependencies: [
libevdev,
liburing,
wayland_client,
],
)
28 changes: 28 additions & 0 deletions protocol/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
wl_protocol_dir = wayland_protocols.get_variable('pkgdatadir')

wayland_scanner_dep = dependency('wayland-scanner', native: true)
wayland_scanner = find_program(
wayland_scanner_dep.get_variable('wayland_scanner'),
native: true,
)

protocols = [
wl_protocol_dir / 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'
]

wl_protocols_src = []

foreach xml : protocols
wl_protocols_src += custom_target(
xml.underscorify() + '_c',
input: xml,
output: '@[email protected]',
command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
)
wl_protocols_src += custom_target(
xml.underscorify() + '_client_h',
input: xml,
output: '@[email protected]',
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
)
endforeach
19 changes: 19 additions & 0 deletions script/latest_ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
# https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs-for-a-repository
runs=https://api.github.com/repos/e2dk4r/gamepad_idle_inhibit/actions/runs
props=$(cat <<END
id
name
head_branch
head_sha
display_title
run_number
html_url
status
conclusion
END
)
jq_filter=".workflow_runs[0] | $(echo $props | sed 's/ /,./g' | sed 's/^/./')"

curl -s "$runs" | jq "$jq_filter"

Loading

0 comments on commit b810fa6

Please sign in to comment.