mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-24 18:16:19 +01:00
Add G29 force-feedback doc and a new-lg4ff installer
BeamNG.drive 0.39 native lost G29 FFB because SDL3's HIDAPI lg4ff driver advertises an effect-status query it cannot answer (12,201 failures per session in beamng.log). DOCS-g29-ffb.md records the diagnosis, the narrow SDL_JOYSTICK_HIDAPI_LG4FF=0 hint vs the broad one, and the launch-option %command% bug that had gamemoderun passed as a game argument. install_new_lg4ff.sh swaps the in-tree hid-logitech for new-lg4ff via DKMS (dkms.conf installs it under the same name in updates/dkms/), regenerates initramfs presets that bundle the module, and offers --status/--revert. Passed install/status/revert in vmbox; host run pending. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SS8M5wk88nJTXxDWz61KKk
This commit is contained in:
parent
b47c6a1a96
commit
c81e4a9446
42
docs/superpowers/evidence/g29-ffb-new-lg4ff-2026-09-14.json
Normal file
42
docs/superpowers/evidence/g29-ffb-new-lg4ff-2026-09-14.json
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"intent": "Restore G29 force feedback in BeamNG.drive native Linux and give the wheel an installable/revertible new-lg4ff driver upgrade.",
|
||||||
|
"scope": [
|
||||||
|
"linux_configuration/fixes/install_new_lg4ff.sh (new)",
|
||||||
|
"linux_configuration/docs/DOCS-g29-ffb.md (new), docs/DOCS-g29-shifter.md (cross-link)",
|
||||||
|
"The SDL env var itself lives in steam-backlog-enforcer (_desktop_env.py, commit 0f5d234) and in the BeamNG Steam launch options; not in this repo"
|
||||||
|
],
|
||||||
|
"changes": [
|
||||||
|
"install_new_lg4ff.sh: installs new-lg4ff-dkms-git from AUR, verifies dkms placed hid-logitech under updates/dkms/, regenerates initramfs presets that bundle hid-logitech, reloads the module when the wheel is present; --status and --revert (pacman -Rns + depmod + reload)",
|
||||||
|
"DOCS-g29-ffb.md: the SDL3 hidapi lg4ff diagnosis (12,201 'Failed to get joystick3 FFB effect status' lines), narrow vs broad SDL hint, the missing %command% launch-option bug, new-lg4ff traps"
|
||||||
|
],
|
||||||
|
"verification": [
|
||||||
|
{
|
||||||
|
"command": "grep -c 'FFB effect status' ~/.local/share/BeamNG/BeamNG.drive/current/beamng.log (after relaunch with SDL_JOYSTICK_HIDAPI_LG4FF=0)",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "0 (was 12201); haptic feature line 'Constant' (kernel path); user confirmed force + self-centring in a car"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "python3 /tmp/g29_ff_probe.py (evdev FF_CONSTANT +/-0x7fff, 2 s each)",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "user: 'it moved all the way to the left and to the right' - kernel driver drives the motor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "vmbox lg4ff: makepkg new-lg4ff-dkms-git; install_new_lg4ff.sh; --status; --revert",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "install rc=0 (module file updates/dkms/hid-logitech.ko.zst), status rc=0, revert rc=0 (module file back to kernel/drivers/hid/, package removed). Passed in vmbox only; host run pending"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "shellcheck linux_configuration/fixes/install_new_lg4ff.sh; pre-commit run --files <changed>",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "shellcheck clean; all hooks Passed"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"risks": [
|
||||||
|
"Host initramfs bundles hid-logitech (autodetect); the script regenerates all presets with mkinitcpio -P, which touches /boot",
|
||||||
|
"modprobe -r hid_logitech while a game holds the evdev node drops that handle; run with games closed"
|
||||||
|
],
|
||||||
|
"rollback": [
|
||||||
|
"install_new_lg4ff.sh --revert (pacman -Rns new-lg4ff-dkms-git, depmod, mkinitcpio -P, module reload)",
|
||||||
|
"Validate: --status shows module file under kernel/drivers/hid/ and ff caps 300040000 0"
|
||||||
|
]
|
||||||
|
}
|
||||||
105
linux_configuration/docs/DOCS-g29-ffb.md
Normal file
105
linux_configuration/docs/DOCS-g29-ffb.md
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
# Logitech G29: no force feedback in BeamNG.drive (native Linux)
|
||||||
|
|
||||||
|
Files: `fixes/install_new_lg4ff.sh` (optional driver upgrade),
|
||||||
|
`~/src/steam-backlog-enforcer/steam_backlog_enforcer/_desktop_env.py` (the
|
||||||
|
host-level env var). Shifter companion: `DOCS-g29-shifter.md`.
|
||||||
|
|
||||||
|
## Symptom
|
||||||
|
|
||||||
|
BeamNG.drive 0.39.x, **native Linux build** (not Proton): the G29 steers,
|
||||||
|
pedals and buttons work, but the wheel is limp — no resistance, no
|
||||||
|
self-centring. Other games with FFB are unaffected.
|
||||||
|
|
||||||
|
## Cause (measured 2026-09-14, BeamNG 0.39.4.0, SDL 3.4.12 static)
|
||||||
|
|
||||||
|
`~/.local/share/BeamNG/BeamNG.drive/current/beamng.log`:
|
||||||
|
|
||||||
|
```
|
||||||
|
D|logHapticFeatures| Device joystick3 supports the following ffb features:
|
||||||
|
Constant Sine Triangle SawToothUp SawToothDown Spring Damper Friction Status Query
|
||||||
|
I|inputRegistry| Created ffbid 0, ... on device joystick3 with axis id=0
|
||||||
|
E|updateFrame| Failed to get joystick3 FFB effect status: (x12,201 per session)
|
||||||
|
```
|
||||||
|
|
||||||
|
That feature list is SDL3's **HIDAPI lg4ff** driver (`SDL_hidapi_lg4ff.c`),
|
||||||
|
which talks to the wheel over hidraw and bypasses the kernel `hid-logitech`
|
||||||
|
driver — the kernel driver advertises only constant/gain/autocenter
|
||||||
|
(`capabilities/ff` = `300040000 0`). The hidapi haptic backend advertises a
|
||||||
|
status query it cannot answer; BeamNG polls it every frame, gets an error, and
|
||||||
|
treats the effect as dead. Known regression:
|
||||||
|
<https://www.beamng.com/threads/ffb-not-working-on-linux.110807/>.
|
||||||
|
|
||||||
|
Not involved: the shifter HID-BPF (input direction only), hidraw permissions
|
||||||
|
(SDL had already opened the device), Proton (not used).
|
||||||
|
|
||||||
|
## Fix: make SDL use the kernel driver
|
||||||
|
|
||||||
|
Two env vars exist; they are not interchangeable:
|
||||||
|
|
||||||
|
| var | scope | use |
|
||||||
|
| ----------------------------- | ------------------------------------- | -------------------------------------------------------------------------- |
|
||||||
|
| `SDL_JOYSTICK_HIDAPI_LG4FF=0` | only the Logitech-wheel HIDAPI driver | **host-level**: set for every game, gamepads keep HIDAPI (BT rumble, LEDs) |
|
||||||
|
| `SDL_JOYSTICK_HIDAPI=0` | all of SDL's HIDAPI joystick drivers | forum-proven fallback, per-game only |
|
||||||
|
|
||||||
|
Both names verified against strings in `BinLinux/BeamNG.drive.x64`.
|
||||||
|
|
||||||
|
1. **Per game** — Steam → BeamNG.drive → Properties → Launch Options:
|
||||||
|
|
||||||
|
```
|
||||||
|
SDL_JOYSTICK_HIDAPI_LG4FF=0 LSFG_PROCESS=BeamNG.Drive gamemoderun %command%
|
||||||
|
```
|
||||||
|
|
||||||
|
The previous value had no `%command%`, so Steam appended
|
||||||
|
`LSFG_PROCESS=... gamemoderun ./BinLinux/BeamNG.drive.x64` as _arguments_
|
||||||
|
to the game (visible in `pgrep -a BeamNG.drive.x64`) and neither gamemode
|
||||||
|
nor LSFG was ever applied.
|
||||||
|
|
||||||
|
2. **Host level** — Steam on this machine is started by
|
||||||
|
`steam-backlog-enforcer` through `sudo -u kuhy env <allowlist> steam …`.
|
||||||
|
`sudo`'s `env_reset` makes that list the entire environment Steam and every
|
||||||
|
game sees, so `/etc/environment`, `~/.profile` or `~/.pam_environment`
|
||||||
|
never reach it. The variable lives in `desktop_env_args()` in the
|
||||||
|
enforcer's `_desktop_env.py`. Check it landed:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tr '\0' '\n' < /proc/$(pgrep -x steam)/environ | grep LG4FF
|
||||||
|
```
|
||||||
|
|
||||||
|
A missing line means Steam predates the enforcer change — it takes effect
|
||||||
|
on the next Steam launch (`systemctl restart steam-backlog-enforcer` kills
|
||||||
|
a running game; check `pgrep -f BeamNG.drive.x64` first).
|
||||||
|
|
||||||
|
## Verify
|
||||||
|
|
||||||
|
- Game-independent motor check, BeamNG closed:
|
||||||
|
`fftest /dev/input/by-id/usb-Logitech_G29_Driving_Force_Racing_Wheel-event-joystick`
|
||||||
|
— effects 0 (constant) and 4 (autocenter) must move the wheel.
|
||||||
|
- In a fresh `beamng.log` the haptic feature line becomes the kernel-style
|
||||||
|
list and `grep -c 'FFB effect status' beamng.log` drops to 0. A non-zero
|
||||||
|
count with working force is fine; a zero count with no force is not.
|
||||||
|
- The gate is physical: drive a car, feel resistance and centring.
|
||||||
|
|
||||||
|
## Optional: new-lg4ff instead of the in-tree driver
|
||||||
|
|
||||||
|
`fixes/install_new_lg4ff.sh` installs `new-lg4ff-dkms-git` (AUR). Its
|
||||||
|
`dkms.conf` sets `DEST_MODULE_NAME="hid-logitech"`, so DKMS places it in
|
||||||
|
`updates/dkms/` and it shadows the in-tree module _by name_ — no blacklist,
|
||||||
|
no `modules-load.d`. Once loaded it registers as `hid_logitech_new`. Adds
|
||||||
|
spring/damper/friction/periodic effects and the `spring_level` /
|
||||||
|
`damper_level` / `friction_level` / `gain` / `autocenter` sysfs knobs.
|
||||||
|
|
||||||
|
Traps the script handles:
|
||||||
|
|
||||||
|
- `mkinitcpio`'s `autodetect` hook bundles `hid-logitech` into the initramfs
|
||||||
|
because the wheel is plugged in at build time; a stale in-tree copy there
|
||||||
|
would load first at boot. The script regenerates the presets when an image
|
||||||
|
carries the module.
|
||||||
|
- `dkms status <name>` is a prefix filter that prints _everything_ on a miss;
|
||||||
|
always grep `dkms status` output.
|
||||||
|
- USB interface 1 of the G29 (`0003:046D:C24F.0007`) is unbound by design.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
~/src/testsAndMisc/linux_configuration/fixes/install_new_lg4ff.sh # install (runs yay; needs a TTY)
|
||||||
|
~/src/testsAndMisc/linux_configuration/fixes/install_new_lg4ff.sh --status # which module owns the wheel + ff caps
|
||||||
|
~/src/testsAndMisc/linux_configuration/fixes/install_new_lg4ff.sh --revert # pacman -Rns + reload, no reboot
|
||||||
|
```
|
||||||
209
linux_configuration/fixes/install_new_lg4ff.sh
Executable file
209
linux_configuration/fixes/install_new_lg4ff.sh
Executable file
@ -0,0 +1,209 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# Logitech G29: replace the in-tree hid-logitech FFB driver with new-lg4ff
|
||||||
|
#
|
||||||
|
# new-lg4ff (github.com/berarma/new-lg4ff) adds spring/damper/friction and
|
||||||
|
# periodic effects the in-tree lg4ff lacks (it only has constant force). Its
|
||||||
|
# dkms.conf installs the module AS hid-logitech under updates/dkms/, so it
|
||||||
|
# shadows the in-tree copy by name: no blacklist, no modules-load drop-in.
|
||||||
|
# Why this matters for BeamNG and the SDL env vars: ../docs/DOCS-g29-ffb.md.
|
||||||
|
#
|
||||||
|
# install_new_lg4ff.sh install from AUR, reload, regen initramfs
|
||||||
|
# install_new_lg4ff.sh --status which module owns the wheel + FFB caps
|
||||||
|
# install_new_lg4ff.sh --revert remove the package, back to in-tree
|
||||||
|
#
|
||||||
|
# Run as the desktop user (yay refuses root); sudo is used where needed.
|
||||||
|
# The initramfs regen is required: mkinitcpio's autodetect hook bundles
|
||||||
|
# hid-logitech because the wheel is plugged in at build time, and a stale
|
||||||
|
# in-tree copy in the initramfs would win at boot over the DKMS one.
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_NAME="$(basename "$0")"
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
readonly SCRIPT_NAME SCRIPT_DIR
|
||||||
|
readonly AUR_PKG="new-lg4ff-dkms-git"
|
||||||
|
readonly DKMS_NAME="new-lg4ff"
|
||||||
|
readonly MODULE="hid_logitech"
|
||||||
|
readonly VID_PID="046D:C24F"
|
||||||
|
readonly SHIFTER_FIX="$SCRIPT_DIR/fix_g29_shifter.sh"
|
||||||
|
readonly PACKAGES=(dkms joyutils)
|
||||||
|
|
||||||
|
MODE="install"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
sed -n '4,16p' "$0" | sed 's/^# \{0,3\}//'
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
log() { echo "[$SCRIPT_NAME] $*"; }
|
||||||
|
die() {
|
||||||
|
echo "[$SCRIPT_NAME] ERROR: $*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
install_packages() {
|
||||||
|
local -a missing=()
|
||||||
|
local pkg
|
||||||
|
for pkg in "${PACKAGES[@]}"; do
|
||||||
|
pacman -Q "$pkg" &>/dev/null || missing+=("$pkg")
|
||||||
|
done
|
||||||
|
if ((${#missing[@]})); then
|
||||||
|
log "installing: ${missing[*]}"
|
||||||
|
sudo pacman -S --needed --noconfirm "${missing[@]}"
|
||||||
|
fi
|
||||||
|
# Headers for the RUNNING kernel, or dkms builds for a kernel nobody boots.
|
||||||
|
[[ -d "/usr/lib/modules/$(uname -r)/build" ]] ||
|
||||||
|
die "no headers for $(uname -r): install the matching linux*-headers"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Path of the module modprobe would load: updates/dkms/... means new-lg4ff.
|
||||||
|
module_path() { modinfo -F filename "$MODULE" 2>/dev/null || echo "-"; }
|
||||||
|
|
||||||
|
is_new_lg4ff_active() {
|
||||||
|
# The DKMS module registers itself as hid-logitech-new even though the
|
||||||
|
# file is named hid-logitech; /proc/modules shows the registered name.
|
||||||
|
grep -q '^hid_logitech_new ' /proc/modules
|
||||||
|
}
|
||||||
|
|
||||||
|
wheel_event_dev() {
|
||||||
|
readlink -f /dev/input/by-id/usb-Logitech_G29_Driving_Force_Racing_Wheel-event-joystick 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
|
# Unbind and rebind the wheel so the freshly installed module takes over
|
||||||
|
# without a reboot. hid core rebinds the device on modprobe by itself.
|
||||||
|
reload_module() {
|
||||||
|
log "reloading $MODULE"
|
||||||
|
sudo modprobe -r "$MODULE"
|
||||||
|
sudo modprobe "$MODULE"
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
regen_initramfs() {
|
||||||
|
# Only the images that actually carry the module need rebuilding.
|
||||||
|
local img rebuilt=0
|
||||||
|
for img in /boot/initramfs-*.img; do
|
||||||
|
[[ -f $img ]] || continue
|
||||||
|
if lsinitcpio -l "$img" 2>/dev/null | grep -q 'hid-logitech'; then
|
||||||
|
rebuilt=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if ((rebuilt)); then
|
||||||
|
log "initramfs bundles hid-logitech: regenerating all presets"
|
||||||
|
sudo mkinitcpio -P
|
||||||
|
else
|
||||||
|
log "initramfs does not bundle hid-logitech: nothing to regenerate"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
show_status() {
|
||||||
|
local dev caps
|
||||||
|
log "package: $(pacman -Q "$AUR_PKG" 2>/dev/null || echo 'not installed')"
|
||||||
|
# `dkms status <name>` is a prefix filter that prints everything on a miss.
|
||||||
|
log "dkms: $(dkms status 2>/dev/null | grep "^$DKMS_NAME/" || echo 'none')"
|
||||||
|
log "module file: $(module_path)"
|
||||||
|
if is_new_lg4ff_active; then
|
||||||
|
log "loaded now: hid-logitech-new (new-lg4ff)"
|
||||||
|
elif grep -q '^hid_logitech ' /proc/modules; then
|
||||||
|
log "loaded now: hid_logitech (in-tree)"
|
||||||
|
else
|
||||||
|
log "loaded now: none"
|
||||||
|
fi
|
||||||
|
local d
|
||||||
|
for d in /sys/bus/hid/devices/*"$VID_PID"*; do
|
||||||
|
[[ -e $d ]] || continue
|
||||||
|
# USB interface 1 is unbound by design (hid-lg rejects it); only
|
||||||
|
# interface 0 carries the wheel, so "none" there is normal.
|
||||||
|
if [[ -e $d/driver ]]; then
|
||||||
|
log "$(basename "$d") driver: $(basename "$(readlink -f "$d/driver")")"
|
||||||
|
else
|
||||||
|
log "$(basename "$d") driver: none"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
dev="$(wheel_event_dev)"
|
||||||
|
if [[ -n $dev ]]; then
|
||||||
|
caps="$(cat "/sys/class/input/$(basename "$dev")/device/capabilities/ff")"
|
||||||
|
# In-tree lg4ff: "300040000 0" (constant, gain, autocenter only).
|
||||||
|
log "evdev $dev ff caps: $caps"
|
||||||
|
local sysdev
|
||||||
|
sysdev="$(readlink -f "/sys/class/input/$(basename "$dev")/device/device")"
|
||||||
|
local knob
|
||||||
|
for knob in range gain autocenter spring_level damper_level friction_level; do
|
||||||
|
[[ -f $sysdev/$knob ]] && log " $knob=$(cat "$sysdev/$knob")"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
log "wheel: not plugged in"
|
||||||
|
fi
|
||||||
|
# An `&&` list as the last statement would make the function return 1
|
||||||
|
# when the shifter fix is absent, and set -e would abort on it.
|
||||||
|
if [[ -x $SHIFTER_FIX ]]; then
|
||||||
|
"$SHIFTER_FIX" --status | sed 's/^/ shifter: /'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
do_install() {
|
||||||
|
install_packages
|
||||||
|
if pacman -Q "$AUR_PKG" &>/dev/null; then
|
||||||
|
log "$AUR_PKG already installed"
|
||||||
|
else
|
||||||
|
command -v yay >/dev/null || die "yay not found; install it first"
|
||||||
|
log "installing $AUR_PKG from AUR (builds against $(uname -r))"
|
||||||
|
yay -S --needed --noconfirm "$AUR_PKG"
|
||||||
|
fi
|
||||||
|
dkms status | grep "^$DKMS_NAME/" | grep -q "$(uname -r).*installed" ||
|
||||||
|
die "dkms did not install $DKMS_NAME for $(uname -r): $(dkms status | grep "^$DKMS_NAME/")"
|
||||||
|
[[ "$(module_path)" == */updates/dkms/* ]] ||
|
||||||
|
die "modprobe still resolves $MODULE to $(module_path)"
|
||||||
|
regen_initramfs
|
||||||
|
if [[ -n "$(wheel_event_dev)" ]]; then
|
||||||
|
reload_module
|
||||||
|
is_new_lg4ff_active || die "reload done but hid_logitech_new is not loaded"
|
||||||
|
else
|
||||||
|
log "wheel not plugged in: module swap takes effect on next plug/boot"
|
||||||
|
fi
|
||||||
|
show_status
|
||||||
|
log "done. Feel check: fftest $(wheel_event_dev)"
|
||||||
|
}
|
||||||
|
|
||||||
|
do_revert() {
|
||||||
|
if pacman -Q "$AUR_PKG" &>/dev/null; then
|
||||||
|
# The dkms pacman hook removes the module from updates/dkms/.
|
||||||
|
sudo pacman -Rns --noconfirm "$AUR_PKG"
|
||||||
|
else
|
||||||
|
log "$AUR_PKG not installed"
|
||||||
|
fi
|
||||||
|
sudo depmod -a
|
||||||
|
[[ "$(module_path)" != */updates/dkms/* ]] ||
|
||||||
|
die "in-tree module not restored: $(module_path)"
|
||||||
|
regen_initramfs
|
||||||
|
if [[ -n "$(wheel_event_dev)" ]]; then
|
||||||
|
reload_module
|
||||||
|
! is_new_lg4ff_active || die "reload done but hid_logitech_new still loaded"
|
||||||
|
fi
|
||||||
|
show_status
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
case "$MODE" in
|
||||||
|
install) do_install ;;
|
||||||
|
revert) do_revert ;;
|
||||||
|
status) show_status ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--status) MODE="status" ;;
|
||||||
|
--revert) MODE="revert" ;;
|
||||||
|
-h | --help) usage ;;
|
||||||
|
*)
|
||||||
|
echo "Unknown option: $1" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
main
|
||||||
Loading…
Reference in New Issue
Block a user