Skip to content

Commit 2e89054

Browse files
committed
add FF and FF_STATUS codes to ecodes
1 parent 9f550df commit 2e89054

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎evdev/ecodes.py‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
66
Exposed constants::
77
8-
KEY, ABS, REL, SW, MSC, LED, BTN, REP, SND, ID, EV, BUS, SYN
8+
KEY, ABS, REL, SW, MSC, LED, BTN, REP, SND, ID, EV, BUS, SYN, FF,
9+
FF_STATUS
910
1011
This module also provides numerous reverse and forward mappings that are best
1112
illustrated by a few examples::
@@ -36,14 +37,19 @@
3637
#: mapping of names to values
3738
ecodes = {}
3839

39-
prefixes = 'KEY ABS REL SW MSC LED BTN REP SND ID EV BUS SYN'
40+
# the order of FF_STATUS and FF is significant
41+
prefixes = 'KEY ABS REL SW MSC LED BTN REP SND ID EV BUS SYN FF_STATUS FF'
4042
g = globals()
4143

4244
for k,v in getmembers(_ecodes):
4345
for i in prefixes.split():
4446
if k.startswith(i):
45-
g.setdefault(i, {})[v] = k
4647
ecodes[k] = v
48+
d = g.setdefault(i, {})
49+
# keep FF_RUMBLE from being named FF_EFFECT_MIN, etc.
50+
if v not in d or d[v].endswith('_MIN') or d[v].endswith('_MAX'):
51+
d[v] = k
52+
break
4753

4854

4955
#: keys are a combination of all BTN and KEY codes
@@ -66,7 +72,9 @@
6672
_ecodes.EV_LED: LED,
6773
_ecodes.EV_REP: REP,
6874
_ecodes.EV_SND: SND,
69-
_ecodes.EV_SYN: SYN, }
75+
_ecodes.EV_SYN: SYN,
76+
_ecodes.EV_FF: FF,
77+
_ecodes.EV_FF_STATUS: FF_STATUS, }
7078

7179
from evdev._ecodes import *
7280

‎evdev/ecodes.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ header=${1:-/usr/include/linux/input.h}
1010

1111
function codes () {
1212
awk '
13-
/#define +(KEY|ABS|REL|SW|MSC|LED|BTN|REP|SND|ID|EV|BUS|SYN)_/ {
13+
/#define +(KEY|ABS|REL|SW|MSC|LED|BTN|REP|SND|ID|EV|BUS|SYN|FF)_/ {
1414
print " PyModule_AddIntMacro(m, "$2");"
1515
}' ${header}
1616
}

0 commit comments

Comments
 (0)