1414 from evdev .eventio import EventIO
1515
1616
17+
1718class UInputError (Exception ):
1819 pass
1920
@@ -33,7 +34,7 @@ def __init__(self,
3334 events = None ,
3435 name = 'py-evdev-uinput' ,
3536 vendor = 0x1 , product = 0x1 , version = 0x1 , bustype = 0x3 ,
36- devnode = '/dev/uinput' ):
37+ devnode = '/dev/uinput' , phys = 'py-evdev-uinput' ):
3738 '''
3839 Arguments
3940 ---------
@@ -57,6 +58,9 @@ def __init__(self,
5758 bustype
5859 bustype identifier.
5960
61+ phys
62+ physical path.
63+
6064 Note
6165 ----
6266 If you do not specify any events, the uinput device will be able
@@ -68,6 +72,7 @@ def __init__(self,
6872 self .product = product #: Device product identifier.
6973 self .version = version #: Device version identifier.
7074 self .bustype = bustype #: Device bustype - e.g. ``BUS_USB``.
75+ self .phys = phys #: Uinput device physical path.
7176 self .devnode = devnode #: Uinput device node - e.g. ``/dev/uinput/``.
7277
7378 if not events :
@@ -81,6 +86,9 @@ def __init__(self,
8186
8287 #: Write-only, non-blocking file descriptor to the uinput device node.
8388 self .fd = _uinput .open (devnode )
89+
90+ # Set phys name
91+ _uinput .set_phys (self .fd , phys )
8492
8593 # Set device capabilities.
8694 for etype , codes in events .items ():
@@ -113,17 +121,17 @@ def __exit__(self, type, value, tb):
113121 def __repr__ (self ):
114122 # TODO:
115123 v = (repr (getattr (self , i )) for i in
116- ('name' , 'bustype' , 'vendor' , 'product' , 'version' ))
124+ ('name' , 'bustype' , 'vendor' , 'product' , 'version' , 'phys' ))
117125 return '{}({})' .format (self .__class__ .__name__ , ', ' .join (v ))
118126
119127 def __str__ (self ):
120- msg = ('name "{}", bus "{}", vendor "{:04x}", product "{:04x}", version "{:04x}"\n '
128+ msg = ('name "{}", bus "{}", vendor "{:04x}", product "{:04x}", version "{:04x}", phys "{}" \n '
121129 'event types: {}' )
122130
123131 evtypes = [i [0 ] for i in self .capabilities (True ).keys ()]
124132 msg = msg .format (self .name , ecodes .BUS [self .bustype ],
125133 self .vendor , self .product ,
126- self .version , ' ' .join (evtypes ))
134+ self .version , self . phys , ' ' .join (evtypes ))
127135
128136 return msg
129137
0 commit comments