99from evdev .events import InputEvent
1010from evdev .eventio import EventIO
1111
12+
1213class UInputError (Exception ):
1314 pass
1415
@@ -28,7 +29,7 @@ def __init__(self,
2829 events = None ,
2930 name = 'py-evdev-uinput' ,
3031 vendor = 0x1 , product = 0x1 , version = 0x1 , bustype = 0x3 ,
31- devnode = '/dev/uinput' ):
32+ devnode = '/dev/uinput' , phys = 'py-evdev-uinput' ):
3233 '''
3334 Arguments
3435 ---------
@@ -52,6 +53,9 @@ def __init__(self,
5253 bustype
5354 bustype identifier.
5455
56+ phys
57+ physical path.
58+
5559 Note
5660 ----
5761 If you do not specify any events, the uinput device will be able
@@ -63,6 +67,7 @@ def __init__(self,
6367 self .product = product #: Device product identifier.
6468 self .version = version #: Device version identifier.
6569 self .bustype = bustype #: Device bustype - e.g. ``BUS_USB``.
70+ self .phys = phys #: Uinput device physical path.
6671 self .devnode = devnode #: Uinput device node - e.g. ``/dev/uinput/``.
6772
6873 if not events :
@@ -76,6 +81,9 @@ def __init__(self,
7681
7782 #: Write-only, non-blocking file descriptor to the uinput device node.
7883 self .fd = _uinput .open (devnode )
84+
85+ # Set phys name
86+ _uinput .set_phys (self .fd , phys )
7987
8088 # Set device capabilities.
8189 for etype , codes in events .items ():
@@ -108,17 +116,17 @@ def __exit__(self, type, value, tb):
108116 def __repr__ (self ):
109117 # TODO:
110118 v = (repr (getattr (self , i )) for i in
111- ('name' , 'bustype' , 'vendor' , 'product' , 'version' ))
119+ ('name' , 'bustype' , 'vendor' , 'product' , 'version' , 'phys' ))
112120 return '{}({})' .format (self .__class__ .__name__ , ', ' .join (v ))
113121
114122 def __str__ (self ):
115- msg = ('name "{}", bus "{}", vendor "{:04x}", product "{:04x}", version "{:04x}"\n '
123+ msg = ('name "{}", bus "{}", vendor "{:04x}", product "{:04x}", version "{:04x}", phys "{}" \n '
116124 'event types: {}' )
117125
118126 evtypes = [i [0 ] for i in self .capabilities (True ).keys ()]
119127 msg = msg .format (self .name , ecodes .BUS [self .bustype ],
120128 self .vendor , self .product ,
121- self .version , ' ' .join (evtypes ))
129+ self .version , self . phys , ' ' .join (evtypes ))
122130
123131 return msg
124132
0 commit comments