Skip to content

Commit 37edfc6

Browse files
committed
make hhd remove leftover udev rules when starting/exiting
1 parent ea39c05 commit 37edfc6

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "hhd"
3-
version = "0.2.4"
3+
version = "0.2.5"
44
authors = [
55
{ name="Kapenekakis Antheas", email="[email protected]" },
66
]

src/hhd/controller/lib/hide.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,12 @@ def unhide_gamepad(devpath: str):
8585
return reload_children(parent)
8686
except Exception:
8787
return False
88+
89+
90+
def unhide_all():
91+
for rule in os.listdir("/run/udev/rules.d/"):
92+
if rule.startswith("95-hhd-devhide"):
93+
try:
94+
os.remove(os.path.join("/run/udev/rules.d/", rule))
95+
except Exception:
96+
pass

src/hhd/controller/physical/evdev.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import logging
33
import os
44
import re
5-
import select
6-
import stat
75
import subprocess
86
from typing import Mapping, Sequence, TypeVar, cast, Collection
97

@@ -13,7 +11,7 @@
1311
from hhd.controller import Axis, Button, Consumer, Event, Producer, can_read
1412
from hhd.controller.base import Event
1513
from hhd.controller.lib.common import hexify, matches_patterns
16-
from hhd.controller.lib.hide import hide_gamepad, unhide_gamepad
14+
from hhd.controller.lib.hide import hide_gamepad, unhide_gamepad, unhide_all
1715
from hhd.controller.const import AbsAxis, GamepadButton, KeyboardButton
1816

1917
logger = logging.getLogger(__name__)

src/hhd/device/legion_go/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from hhd.controller.base import Multiplexer
1212
from hhd.controller.lib.hid import enumerate_unique
1313
from hhd.controller.physical.evdev import B as EC
14-
from hhd.controller.physical.evdev import GenericGamepadEvdev
14+
from hhd.controller.physical.evdev import GenericGamepadEvdev, unhide_all
1515
from hhd.controller.physical.hidraw import GenericGamepadHidraw
1616
from hhd.controller.physical.imu import AccelImu, GyroImu
1717
from hhd.controller.virtual.ds5 import DualSense5Edge, TouchpadCorrectionType
@@ -51,6 +51,8 @@
5151

5252

5353
def plugin_run(conf: Config, emit: Emitter, context: Context, should_exit: TEvent):
54+
# Remove leftover udev rules
55+
unhide_all()
5456
if (gyro_fix := conf.get("gyro_fix", False)) and conf["gyro"].to(bool):
5557
gyro_fixer = GyroFixer(int(gyro_fix) if int(gyro_fix) > 10 else 100)
5658
else:
@@ -110,6 +112,8 @@ def plugin_run(conf: Config, emit: Emitter, context: Context, should_exit: TEven
110112
finally:
111113
if gyro_fixer:
112114
gyro_fixer.close()
115+
# Remove leftover udev rules
116+
unhide_all()
113117

114118

115119
def controller_loop_rest(mode: str, pid: int, conf: Config, should_exit: TEvent):

0 commit comments

Comments
 (0)