-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b810fa6
Showing
8 changed files
with
758 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
Language: Cpp | ||
ColumnLimit: 120 | ||
BreakBeforeBraces: Linux | ||
AlwaysBreakAfterReturnType: TopLevel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build/ | ||
.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
Oops, something went wrong.