Skip to content

Commit 73f8e15

Browse files
committed
Fix for UI_FF constants missing from generated ecodes.py
1 parent 7916a7b commit 73f8e15

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
lines changed

.github/workflows/test.yml

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
python-version: ${{ matrix.python-version }}
2222

2323
- name: Run pytest tests
24-
# pip install -e . builds _ecodes and such into the evdev directory
2524
# sudo required to write to uinputs
2625
run: |
2726
sudo python -m pip install pytest setuptools

src/evdev/__init__.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@
22
# Gather everything into a single, convenient namespace.
33
# --------------------------------------------------------------------------
44

5-
from . import ecodes as ecodes, ff as ff
5+
# The superfluous "import name as name" syntax is here to satisfy mypy's attrs-defined rule.
6+
# Alternarantively all exported objects can be listed in __all__.
7+
8+
from . import (
9+
ecodes as ecodes,
10+
ff as ff,
11+
)
12+
613
from .device import (
714
AbsInfo as AbsInfo,
815
DeviceInfo as DeviceInfo,
916
EvdevError as EvdevError,
1017
InputDevice as InputDevice,
1118
)
19+
1220
from .events import (
1321
AbsEvent as AbsEvent,
1422
InputEvent as InputEvent,
@@ -17,7 +25,12 @@
1725
SynEvent as SynEvent,
1826
event_factory as event_factory,
1927
)
20-
from .uinput import UInput as UInput, UInputError as UInputError
28+
29+
from .uinput import (
30+
UInput as UInput,
31+
UInputError as UInputError,
32+
)
33+
2134
from .util import (
2235
categorize as categorize,
2336
list_devices as list_devices,

src/evdev/ecodes_runtime.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#: Mapping of names to values.
4747
ecodes = {}
4848

49-
prefixes = "KEY ABS REL SW MSC LED BTN REP SND ID EV BUS SYN FF_STATUS FF INPUT_PROP".split()
49+
prefixes = "KEY ABS REL SW MSC LED BTN REP SND ID EV BUS SYN FF_STATUS FF INPUT_PROP UI_FF".split()
5050
prev_prefix = ""
5151
g = globals()
5252

src/evdev/genecodes_py.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
("BUS", "Dict[int, Union[str, Tuple[str]]]", None),
4141
("SYN", "Dict[int, Union[str, Tuple[str]]]", None),
4242
("FF", "Dict[int, Union[str, Tuple[str]]]", None),
43+
("UI_FF", "Dict[int, Union[str, Tuple[str]]]", None),
4344
("FF_STATUS", "Dict[int, Union[str, Tuple[str]]]", None),
4445
("INPUT_PROP", "Dict[int, Union[str, Tuple[str]]]", None)
4546
]
@@ -50,4 +51,4 @@
5051

5152
print(f"{key}: {annotation} = ", end="")
5253
pprint(getattr(ecodes, key))
53-
print()
54+
print()

tests/test_ecodes.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# encoding: utf-8
2-
31
from evdev import ecodes
2+
from evdev import ecodes_runtime
43

54

6-
prefixes = "KEY ABS REL SW MSC LED BTN REP SND ID EV BUS SYN FF_STATUS FF"
5+
prefixes = "KEY ABS REL SW MSC LED BTN REP SND ID EV BUS SYN FF_STATUS FF UI_FF"
76

87

98
def to_tuples(val):
@@ -29,3 +28,14 @@ def test_overlap():
2928
vals_ff = set(to_tuples(ecodes.FF.values()))
3029
vals_ff_status = set(to_tuples(ecodes.FF_STATUS.values()))
3130
assert bool(vals_ff & vals_ff_status) is False
31+
32+
33+
def test_generated():
34+
e_run = vars(ecodes_runtime)
35+
e_gen = vars(ecodes)
36+
37+
def keys(v):
38+
res = {k for k in v.keys() if not k.startswith("_") and not k[1].islower()}
39+
return res
40+
41+
assert keys(e_run) == keys(e_gen)

0 commit comments

Comments
 (0)