mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-19 02:14:22 +01:00
g29 shifter: no notification, no retry loop -- fail visibly and stop
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
Pre-commit checks / pre-commit (push) Has been cancelled
Python tests / test (push) Has been cancelled
Shell tests / shell-tests (push) Has been cancelled
Shell tests / arch-tests (push) Has been cancelled
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
Pre-commit checks / pre-commit (push) Has been cancelled
Python tests / test (push) Has been cancelled
Shell tests / shell-tests (push) Has been cancelled
Shell tests / arch-tests (push) Has been cancelled
kuhy: "I do not want it to work like this, I want it to just work normally." PS4 mode (046D:C260) cannot be supported on this PC (no kernel driver, SDL lg4ff has no c260 either, so FFB is dead there too) and the selector is physical. Keep the mode detection so the journal and --status name PS4 mode instead of "not found"; drop the desktop notification and the 5-minute Restart loop. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NVfC2T6DyvCFqse9A99zef
This commit is contained in:
parent
88b8911e50
commit
cce6e2c048
@ -0,0 +1,35 @@
|
||||
{
|
||||
"intent": "Per kuhy (2026-09-18: 'I do not want it to work like this, I want it to just work normally'): drop the desktop notification and the 5-minute retry loop added earlier today. PS4 mode (046D:C260) cannot be supported on this PC at all (no kernel driver, SDL lg4ff has no c260 either, so FFB is dead too) and the selector is physical; the switch is now on PS3, where the fix attaches by itself at enumeration.",
|
||||
"scope": [
|
||||
"linux_configuration/fixes/g29_wheel_mode.sh: g29_notify_desktop, G29_RUN_USER_DIR and G29_NOTIFY_ID removed; mode detection kept",
|
||||
"linux_configuration/fixes/fix_g29_shifter.sh: --ensure in PS4/compat mode still exits 1 naming the mode, no notification",
|
||||
"linux_configuration/fixes/systemd/g29-shifter-bpf.service: Restart/RestartSec/StartLimitIntervalSec removed",
|
||||
"linux_configuration/tests/test_fix_g29_shifter.bats: notify tests removed (11 remain)",
|
||||
"linux_configuration/docs/DOCS-g29-shifter.md"
|
||||
],
|
||||
"changes": [
|
||||
"The failure in PS4 mode stays visible in the journal and systemctl --failed with the mode named, which is what was missing on the 2026-09-15/17 boots; nothing nags.",
|
||||
"The test notification fired at 10:42 from root never appeared on kuhy's screen anyway; not debugged because the feature is gone."
|
||||
],
|
||||
"verification": [
|
||||
{
|
||||
"command": "bats linux_configuration/tests/test_fix_g29_shifter.bats",
|
||||
"result": "pass",
|
||||
"evidence": "1..11, all ok"
|
||||
},
|
||||
{
|
||||
"command": "linux_configuration/fixes/fix_g29_shifter.sh (install mode, on the host)",
|
||||
"result": "pass",
|
||||
"evidence": "systemctl cat g29-shifter-bpf.service has no Restart/StartLimit lines; --status: wheel mode: native, attached now: yes, safety net: enabled"
|
||||
},
|
||||
{
|
||||
"command": "pre-commit run --files <changed files>",
|
||||
"result": "pass",
|
||||
"evidence": "no Failed hooks"
|
||||
}
|
||||
],
|
||||
"risks": [
|
||||
"A future PS4-mode boot is silent again except for a failed unit in the journal / systemctl --failed / --status"
|
||||
],
|
||||
"rollback": ["git revert, re-run fix_g29_shifter.sh to reinstall the unit"]
|
||||
}
|
||||
@ -1,8 +1,7 @@
|
||||
# Logitech G29 Driving Force Shifter: 1st/3rd not engaging (HID-BPF fix)
|
||||
|
||||
Files: `fixes/g29_shifter.bpf.c` (the fix), `fixes/fix_g29_shifter.sh`
|
||||
(build/attach/install), `fixes/g29_wheel_mode.sh` (PS3/PS4 mode detection +
|
||||
desktop notification), `fixes/g29_shifter_capture.py` (grades a raw capture).
|
||||
(build/attach/install), `fixes/g29_wheel_mode.sh` (PS3/PS4 mode detection), `fixes/g29_shifter_capture.py` (grades a raw capture).
|
||||
Force feedback (a separate problem, SDL-side): `DOCS-g29-ffb.md`.
|
||||
|
||||
## Symptom
|
||||
@ -75,11 +74,10 @@ with the bad decode, which is indistinguishable from "the fix stopped working":
|
||||
2. `g29-shifter-bpf.service` (`systemd/`), enabled at `multi-user.target`, runs
|
||||
`fix_g29_shifter.sh --ensure`: a no-op when attached, re-attaches when not.
|
||||
No wheel → exit 0 (layer 3 re-runs it on plug-in). Wheel present in PS4 or
|
||||
compatibility mode → exit 1 **and a critical desktop notification** to every
|
||||
user with a session bus (`g29_notify_desktop`, via `sudo -u`, because the
|
||||
unit is a root oneshot with no `$DISPLAY`); `Restart=on-failure` +
|
||||
`RestartSec=5min` keeps re-checking and re-notifying (same notification id,
|
||||
so it replaces rather than stacks) until the selector is flipped.
|
||||
compatibility mode → exit 1 with the mode named, so `systemctl --failed`
|
||||
and the journal say _why_ instead of "not found". No notification and no
|
||||
retry loop: kuhy ruled that out (2026-09-18, "I want it to just work") —
|
||||
flipping the selector re-enumerates the wheel, and layer 3 re-runs the unit.
|
||||
3. `/etc/udev/rules.d/99-g29-shifter-ensure.rules` pulls that unit in on every
|
||||
re-enumeration of `C24F` **or `C260`**, so a wheel powered on in the wrong
|
||||
mode is reported at once, and hotplug is covered as well as boot.
|
||||
|
||||
@ -151,11 +151,9 @@ main() {
|
||||
;;
|
||||
*)
|
||||
# The wheel still "works" here -- with the bad 1st/3rd decode this
|
||||
# fix exists to remove -- so say it where it is seen. Exit 1 makes
|
||||
# the unit retry (and re-notify) until the selector is flipped.
|
||||
# fix exists to remove -- so fail visibly (journal, systemctl
|
||||
# --failed) and name the mode instead of "not found".
|
||||
log "$(g29_mode_explanation "$(g29_wheel_mode)")" >&2
|
||||
g29_notify_desktop "G29 shifter fix NOT active" \
|
||||
"$(g29_mode_explanation "$(g29_wheel_mode)")"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ============================================================================
|
||||
# Logitech G29: which mode is the wheel in, and how to tell the desktop.
|
||||
# Logitech G29: which mode is the wheel in.
|
||||
#
|
||||
# Sourced by fix_g29_shifter.sh and tests/test_fix_g29_shifter.bats.
|
||||
#
|
||||
@ -17,13 +17,11 @@
|
||||
[[ -n "${_G29_WHEEL_MODE_LOADED:-}" ]] && return 0
|
||||
_G29_WHEEL_MODE_LOADED=1
|
||||
|
||||
# Overridable so tests can point at a fake sysfs tree / run dir.
|
||||
# Overridable so tests can point at a fake sysfs tree.
|
||||
G29_HID_SYSFS="${G29_HID_SYSFS:-/sys/bus/hid/devices}"
|
||||
G29_RUN_USER_DIR="${G29_RUN_USER_DIR:-/run/user}"
|
||||
readonly G29_PID_NATIVE="0003:046D:C24F"
|
||||
readonly G29_PID_PS4="0003:046D:C260"
|
||||
readonly G29_PID_COMPAT="0003:046D:C294"
|
||||
readonly G29_NOTIFY_ID=29029 # fixed notify-send id: repeats replace, never stack
|
||||
|
||||
# Print the sysfs path of the first $1 device that has a report descriptor
|
||||
# (the wheel exposes two HID interfaces; only the joystick one has one).
|
||||
@ -61,19 +59,3 @@ g29_mode_explanation() {
|
||||
*) echo "unknown G29 mode '$1'" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Critical desktop notification to every user with a session bus. This runs
|
||||
# from a root oneshot at boot/hotplug, so $DISPLAY / $DBUS_SESSION_BUS_ADDRESS
|
||||
# are not set -- it walks /run/user/*/bus instead. Never fails the caller.
|
||||
g29_notify_desktop() {
|
||||
local title="$1" body="$2" bus uid user
|
||||
for bus in "$G29_RUN_USER_DIR"/*/bus; do
|
||||
[[ -e "$bus" ]] || continue
|
||||
uid="${bus#"$G29_RUN_USER_DIR"/}"
|
||||
uid="${uid%/bus}"
|
||||
user="$(id -nu "$uid" 2>/dev/null)" || continue
|
||||
sudo -u "$user" DBUS_SESSION_BUS_ADDRESS="unix:path=$bus" \
|
||||
notify-send -u critical -r "$G29_NOTIFY_ID" -a g29-shifter \
|
||||
"$title" "$body" 2>/dev/null || true
|
||||
done
|
||||
}
|
||||
|
||||
@ -2,20 +2,18 @@
|
||||
# Safety net for the G29 shifter HID-BPF fix (see docs/DOCS-g29-shifter.md).
|
||||
# udev-hid-bpf's own rule attaches the program on "add"; this unit re-checks
|
||||
# after boot and on every hotplug, and re-attaches if that rule ever misses.
|
||||
# It exits 0 with no wheel present, and FAILS when the wheel is present in a
|
||||
# mode the fix cannot attach to (PS4 selector -> 046D:C260); the retry below
|
||||
# keeps re-checking and re-notifying the desktop until the selector is flipped.
|
||||
# It exits 0 with no wheel present, and FAILS (visibly, in the journal and
|
||||
# systemctl --failed) when the wheel is present in a mode the fix cannot
|
||||
# attach to (PS4 selector -> 046D:C260); flipping the selector re-enumerates
|
||||
# the wheel and the udev rule below runs it again.
|
||||
# Installed by fixes/fix_g29_shifter.sh; __SCRIPT__ is substituted there.
|
||||
Description=Ensure the G29 shifter HID-BPF fix is attached
|
||||
After=systemd-udevd.service
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=no
|
||||
ExecStart=__SCRIPT__ --ensure
|
||||
Restart=on-failure
|
||||
RestartSec=5min
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@ -8,21 +8,18 @@
|
||||
# The BPF build/attach itself needs the real wheel and root, so it is not
|
||||
# covered here. What IS covered is the logic that failed silently on the
|
||||
# 2026-09-15 and 2026-09-17 boots: telling "wheel in PS4 mode" apart from
|
||||
# "no wheel", and turning that into an exit code plus a desktop notification.
|
||||
# "no wheel", and turning that into an exit code and a message naming the mode.
|
||||
|
||||
setup() {
|
||||
REPO_DIR="$(cd -- "$(dirname -- "$BATS_TEST_FILENAME")/.." && pwd)"
|
||||
SCRIPT="$REPO_DIR/fixes/fix_g29_shifter.sh"
|
||||
export G29_HID_SYSFS="$BATS_TEST_TMPDIR/hid"
|
||||
export G29_RUN_USER_DIR="$BATS_TEST_TMPDIR/run"
|
||||
mkdir -p "$G29_HID_SYSFS" "$G29_RUN_USER_DIR"
|
||||
# sudo stub: records every invocation, never attached, never fails.
|
||||
STUB_LOG="$BATS_TEST_TMPDIR/sudo.log"
|
||||
export STUB_LOG
|
||||
mkdir -p "$G29_HID_SYSFS"
|
||||
# sudo stub: udev-hid-bpf list-loaded prints nothing, i.e. not attached.
|
||||
mkdir -p "$BATS_TEST_TMPDIR/bin"
|
||||
cat >"$BATS_TEST_TMPDIR/bin/sudo" <<'STUB'
|
||||
#!/bin/bash
|
||||
echo "$*" >>"$STUB_LOG"
|
||||
exit 0
|
||||
STUB
|
||||
chmod +x "$BATS_TEST_TMPDIR/bin/sudo"
|
||||
export PATH="$BATS_TEST_TMPDIR/bin:$PATH"
|
||||
@ -81,37 +78,19 @@ fake_hid() {
|
||||
[[ "$output" == *"PS4 mode"* && "$output" == *"C260"* && "$output" == *"PS3"* ]]
|
||||
}
|
||||
|
||||
# --- g29_notify_desktop ----------------------------------------------------
|
||||
|
||||
@test "notify: reaches every user with a session bus, via sudo -u" {
|
||||
mkdir -p "$G29_RUN_USER_DIR/$(id -u)"
|
||||
: >"$G29_RUN_USER_DIR/$(id -u)/bus"
|
||||
g29_notify_desktop "title" "body"
|
||||
grep -q -- "-u $(id -nu) DBUS_SESSION_BUS_ADDRESS=unix:path=$G29_RUN_USER_DIR/$(id -u)/bus notify-send -u critical -r $G29_NOTIFY_ID" "$STUB_LOG"
|
||||
}
|
||||
|
||||
@test "notify: no session bus means no call and no error" {
|
||||
g29_notify_desktop "title" "body"
|
||||
[ ! -e "$STUB_LOG" ]
|
||||
}
|
||||
|
||||
# --- fix_g29_shifter.sh --ensure / --status --------------------------------
|
||||
|
||||
@test "ensure: no wheel exits 0 without notifying" {
|
||||
@test "ensure: no wheel exits 0" {
|
||||
run "$SCRIPT" --ensure
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"no G29 on the HID bus"* ]]
|
||||
run ! grep -q notify-send "$STUB_LOG"
|
||||
}
|
||||
|
||||
@test "ensure: PS4 mode exits 1 and notifies the desktop" {
|
||||
@test "ensure: PS4 mode exits 1 and names the mode" {
|
||||
fake_hid 0003:046D:C260 0001 desc
|
||||
mkdir -p "$G29_RUN_USER_DIR/$(id -u)"
|
||||
: >"$G29_RUN_USER_DIR/$(id -u)/bus"
|
||||
run "$SCRIPT" --ensure
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"PS4 mode"* ]]
|
||||
grep -q "notify-send -u critical .*G29 shifter fix NOT active" "$STUB_LOG"
|
||||
}
|
||||
|
||||
@test "ensure: already attached is a no-op even in PS4 mode" {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user