@@ -31,21 +31,46 @@ def __eq__(self, o):
3131 and self .version == o .version
3232
3333
34+ _AbsInfo = namedtuple ('AbsInfo' ,
35+ ['value' , 'min' , 'max' , 'fuzz' , 'flat' , 'resolution' ])
3436
35- _AbsData = namedtuple ('AbsData' ,
36- ['min' , 'max' , 'fuzz' , 'flat' ])
37-
38- class AbsData (_AbsData ):
37+ class AbsInfo (_AbsInfo ):
3938 '''
40- A ``namedtuple`` for storing absolut axis information:
39+ A ``namedtuple`` for storing absolut axis information -
40+ corresponds to the ``input_absinfo`` c struct:
41+
42+ - value
43+ Latest reported value for the axis.
44+
45+ - min
46+ Specifies minimum value for the axis.
47+
48+ - max
49+ Specifies maximum value for the axis.
50+
51+ - fuzz
52+ Specifies fuzz value that is used to filter noise from the
53+ event stream.
4154
42- - min - minimal value for an absolute axis
43- - max - maximum value for an absolute axis
44- - fuzz - noise tolerance (+- value)
45- - flat - size of the center flat position
55+ - flat
56+ Values that are within this value will be discarded by joydev
57+ interface and reported as 0 instead.
58+
59+ - resolution
60+ Specifies resolution for the values reported for the axis.
61+ Resolution for main axes (``ABS_X, ABS_Y, ABS_Z``) is reported
62+ in units per millimeter (units/mm), resolution for rotational
63+ axes (``ABS_RX, ABS_RY, ABS_RZ``) is reported in units per
64+ radian.
65+
66+ .. note: The input core does not clamp reported values to the
67+ ``[minimum, maximum]`` limits, such task is left to userspace.
4668 '''
4769 pass
4870
71+ def __str__ (self ):
72+ return 'val {}, min {}, max {}, fuzz {}, flat {}, res {}' .format (* self )
73+
4974
5075class InputDevice (object ):
5176 '''
@@ -80,15 +105,15 @@ def __init__(self, dev):
80105 #: The raw dictionary of device capabilities - see `:func:capabilities()`
81106 self ._rawcapabilities = info_res [6 ]
82107
83- def _capabilities (self , absdata = True ):
108+ def _capabilities (self , absinfo = True ):
84109 res = {}
85110 for etype , ecodes in self ._rawcapabilities .items ():
86111 for code in ecodes :
87112 l = res .setdefault (etype , [])
88113 if isinstance (code , tuple ):
89- if absdata :
90- a = code [1 ] # (0, 0, 255, 0)
91- i = AbsData ( min = a [ 1 ], max = a [ 2 ], fuzz = a [ 3 ], flat = a [ 4 ] )
114+ if absinfo :
115+ a = code [1 ] # (0, 0, 0, 255, 0 , 0)
116+ i = AbsInfo ( * a )
92117 l .append ((code [0 ], i ))
93118 else :
94119 l .append (code [0 ])
@@ -97,7 +122,7 @@ def _capabilities(self, absdata=True):
97122
98123 return res
99124
100- def capabilities (self , verbose = False , absdata = True ):
125+ def capabilities (self , verbose = False , absinfo = True ):
101126 '''
102127 Returns the event types that this device supports as a a mapping of
103128 supported event types to lists of handled event codes. Example::
@@ -113,24 +138,24 @@ def capabilities(self, verbose=False, absdata=True):
113138
114139 Unknown codes or types will be resolved to '?'.
115140
116- If ``absdata `` is ``True``, the list of capabilities will also
141+ If ``absinfo `` is ``True``, the list of capabilities will also
117142 include absolute axis information (``absmin``, ``absmax``,
118143 ``absfuzz``, ``absflat``) in the following form::
119144
120- { 3 : [ (0, AbsData (min=0, max=255, fuzz=0, flat=0)),
121- (1, AbsData (min=0, max=255, fuzz=0, flat=0)) ]}
145+ { 3 : [ (0, AbsInfo (min=0, max=255, fuzz=0, flat=0)),
146+ (1, AbsInfo (min=0, max=255, fuzz=0, flat=0)) ]}
122147
123148 Combined with ``verbose`` the above becomes::
124149
125- { ('EV_ABS', 3) : [ (('ABS_X', 0), AbsData (min=0, max=255, fuzz=0, flat=0)),
126- (('ABS_Y', 1), AbsData (min=0, max=255, fuzz=0, flat=0)) ]}
150+ { ('EV_ABS', 3) : [ (('ABS_X', 0), AbsInfo (min=0, max=255, fuzz=0, flat=0)),
151+ (('ABS_Y', 1), AbsInfo (min=0, max=255, fuzz=0, flat=0)) ]}
127152
128153 '''
129154
130155 if verbose :
131- return dict (util .resolve_ecodes (self ._capabilities (absdata )))
156+ return dict (util .resolve_ecodes (self ._capabilities (absinfo )))
132157 else :
133- return self ._capabilities (absdata )
158+ return self ._capabilities (absinfo )
134159
135160 def __eq__ (self , o ):
136161 ''' Two devices are considered equal if their :data:`info` attributes are equal. '''
0 commit comments