+
    i34  c                   s    ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
HtHtHt ^RIHtHtHtHt ^RIHtHt ^RIHt  ^ RIHt  ! R R	]4      t ! R
 R]4      tR#   ] d
    ^ RIHt  L'i ; i)i    N)defaultdict)UnionTupleDictSequenceOptional)_uinputecodesffutil)InputDeviceAbsInfo)
InputEvent)EventIOc                   s    ] tR t^tRtR# )UInputError N)__name__
__module____qualname____firstlineno____static_attributes__r       3/usr/lib64/python3.14/site-packages/evdev/uinput.pyr   r      s    r   r   c                   sd  a  ] tR t^t o RtRt]R]P                  ]P                  3/V 3R lR ll4       t
RR^^^^RRR]P                  P                  R^`4      3
V 3R	 lR
 lltR tR tR tR tR tR tR V 3R lR lltR tR tR tR tR tV 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )!UInputzZ
A userland input device and that can inject input events into the
linux input subsystem.
filtered_typesc                sz   < V ^8  d   QhRS[ S[S[ S[S[S[P
                  3,          3,          RS[S[,          /# )   devicesr   )r   r
   strZbytesosZPathLiker   intformat__classdict__   "r   __annotate__UInput.__annotate__+   s=     *6 *6U3r{{+B%CCD*6 c
*6r   c               s   . pV F>  p\        V\        4      '       g   \        \        V4      4      pVP                  V4       K@  	  \	        \
        4      pRV9  d(   \        V Uu. uF  qUP                  NK  	  up4      VR&   V FA  pVP                  4       P                  4        F  w  rxWg,          P                  V4       K  	  KC  	  V F  p	W9   g   K  Wi K  	  V ! RRV/VB # u upi )aw  
Create an UInput device with the capabilities of one or more input
devices.

Arguments
---------
devices : InputDevice|str
  Varargs of InputDevice instances or paths to input devices.

filtered_types : Tuple[event type codes]
  Event types to exclude from the capabilities of the uinput device.

**kwargs
  Keyword arguments to UInput constructor (i.e. name, vendor etc.).
max_effectseventsr   )
isinstancer
   r   appendr    ZsetZminZff_effects_countcapabilitiesitemsZupdate)
Zclsr   r   ZkwargsZdevice_instancesZdevZall_capabilitiesZev_typeZev_codesZevtypes
   &$*,      r   from_deviceZUInput.from_device*   s    . Cc;//!#c(+##C( 
 's+&$'IY(ZIY#)=)=IY(Z$[F=! $C%(%5%5%7%=%=%?! )00: &@ $ %F)$, % 5*5f55 )[s   &C(Nzpy-evdev-uinputz/dev/uinputZFF_MAX_EFFECTSc                s   < V ^8  d   QhRS[ S[S[S[S[,          3,          ,          RS[RS[RS[RS[RS[RS[RS[/# )	r   r%   namevendorproductversionbustypedevnodephys)r   r   r   r   r   r   r!   r   r"   r#   W   sx     `> `>c8C=012`> `> 	`>
 `> `> `> `> `>r   c           
     s   W n         W0n        W@n        WPn        W`n        Wn        Wpn        V'       g/   \        P                  \        P                  P                  4       /pV P                  4        \        P                  ! V4      V n        V P                  V4      w  r\        P                  ! V P                  V4       T	;'       g    . p	V	 F$  p\        P                   ! V P                  V4       K&  	  V F&  w  r\        P"                  ! V P                  W4       K(  	  \        P$                  ! V P                  W#WEWkV
4       \        P&                  ! V P                  4       \(        P*                  ! \        P,                  4      V n        \(        P0                  V P.                  P2                  n        \(        P0                  V P.                  P6                  n        V P9                  V P                  4      V n        R# )ah  
Arguments
---------
events : dict
  Dictionary of event types mapping to lists of event codes. The
  event types and codes that the uinput device will be able to
  inject - defaults to all key codes.

name
  The name of the input device.

vendor
  Vendor identifier.

product
  Product identifier.

version
  Version identifier.

bustype
  Bustype identifier.

phys
  Physical path.

input_props
  Input properties and quirks.

max_effects
  Maximum simultaneous force-feedback effects.

Note
----
If you do not specify any events, the uinput device will be able
to inject only ``KEY_*`` and ``BTN_*`` event codes.
N)r+   r,   r-   r.   r/   r1   r0   r   ZEV_KEYkeys_verifyr   Zopenfd_prepare_eventsZset_physZset_propZenableZsetupZcreatectypesZCDLLZ__file__dllZc_int_uinput_begin_uploadZrestype_uinput_end_upload_find_devicedevice)selfr%   r+   r,   r-   r.   r/   r0   r1   Zinput_propsr$   absinfoprepared_eventsZpropetypecodes   &&&&&&&&&&&     r   __init__ZUInput.__init__W   s`   l 	!###	#mmV[[%5%5%78F ,,w' $(#7#7#?  	$' "''RDTWWd+   +KENN477E0 + 	dggtWwQ\] 	tww;;w//006%%-.4ll##+
 $(#4#4TWW#=r   c           
     s   . . r2VP                  4        F  w  rEV F  p\        V\        \        \        34      '       dm   V^ ,          .pVP                  V^,          4       VP                  ^ .^\        V^,          4      ,
          ,          4       VP                  V4       V^ ,          pVP                  WF34       K  	  K  	  W#3# )z>Prepare events for passing to _uinput.enable and _uinput.setup)r)   r&   ZtupleZlistr   Zextendlenr'   )r<   r%   r=   r>   r?   Zcodesr@   Zfs   &&      r   r5   ZUInput._prepare_events   s    #%r"LLNLEdUD'$:;;a	AHHT!W% HHaSADG$456NN1%7D&&}5  + ''r   c                s    V # Nr   r<      &r   	__enter__ZUInput.__enter__   s    r   c                sN    \        V R 4      '       d   V P                  4        R# R# )r4   N)Zhasattrclose)r<   ZtypeZvalueZtbs   &&&&r   __exit__ZUInput.__exit__   s    4JJL r   c                s   a  V 3R  lR 4       pRP                  S P                  P                  RP                  V4      4      # )c              3   sN   <"   T F  p\        \        SV4      4      x  K  	  R # 5irC   )ZreprZgetattr)Z.0ir<   s   & r   Z	<genexpr>Z"UInput.__repr__.<locals>.<genexpr>   s"     i-hT'$"##-hs   "%z{}({})z, )r+   r/   r,   r-   r.   r1   )r   Z	__class__r   join)r<   Zvs   f r   __repr__ZUInput.__repr__   s1    i-hit~~66		!EEr   c                sj   R pV P                  R4      P                  4        Uu. uF  q"^ ,          NK  	  ppVP                  V P                  \        P
                  V P                  ,          V P                  V P                  V P                  V P                  RP                  V4      4      pV# u upi )zcname "{}", bus "{}", vendor "{:04x}", product "{:04x}", version "{:04x}", phys "{}"
event types: {}TZ )r(   r2   r   r+   r   ZBUSr/   r,   r-   r.   r1   rJ   )r<   msgrI   Zevtypess   &   r   __str__ZUInput.__str__   s    t!%!2!24!8!=!=!?@!?AQ44!?@jjIIvzz$,,/dllDLLZ^ZcZcehememnuev
 
 As   B0c                s    V P                   e   V P                   P                  4        V P                  R8  d*   \        P                  ! V P                  4       RV n        R # R # )Ni)r;   rG   r4   r   rD   rE   r   rG   ZUInput.close   sE    ;;"KK 77R<MM$''"DG r   c                s&   < V ^8  d   QhRS[ RS[ /# )r   verboser=   )Zboolr   r!   r   r"   r#      s     : :D :4 :r   c                sj    V P                   f   \        R4      hV P                   P                  W4      # )zASee :func:`capabilities <evdev.device.InputDevice.capabilities>`.z2input device not opened - cannot read capabilities)r;   r   r(   )r<   rN   r=   s   &&&r   r(   ZUInput.capabilities   s-    ;;RSS{{''99r   c                   \         P                  ! 4       pWn        V P                  P	                  V P
                  \        P                  ! V4      4      pV'       d'   \        R \        P                  ! V4      ,           4      hV# )zFailed to begin uinput upload: )r   ZUInputUpload	effect_idr7   r8   r4   r6   byrefr   r   strerror)r<   rP   uploadret   &&  r   begin_uploadZUInput.begin_upload   sY    "$hh++DGGV\\&5IJ?"++cBRRSSr   c                    V P                   P                  V P                  \        P                  ! V4      4      pV'       d'   \        R \        P                  ! V4      ,           4      hR# )zFailed to end uinput upload: N)r7   r9   r4   r6   rQ   r   r   rR   )r<   rS   rT      && r   
end_uploadZUInput.end_upload   sG    hh))$''6<<3GH=C@PPQQ r   c                rO   )zFailed to begin uinput erase: )r   ZUInputEraserP   r7   Z_uinput_begin_eraser4   r6   rQ   r   r   rR   )r<   rP   eraserT   rU   r   begin_eraseZUInput.begin_erase  sX     #hh**477FLL4GH>SAQQRRr   c                rW   )zFailed to end uinput erase: N)r7   Z_uinput_end_eraser4   r6   rQ   r   r   rR   )r<   rZ   rT   rX   r   	end_eraseZUInput.end_erase
  sG    hh((&,,u2EF<r{{3?OOPP r   c                s    \         P                  ! V P                  4      \        P                  ,          p\        P                  ! V4      '       g   Q h \         P                  ! T P                  \         P                  4      '       g'   Rp\        TP                  T P                  4      4      h\        T P                  4      \        P                  8  d+   Rp\        TP                  \        P                  4      4      hR#   \
        \        \        3 d(    Rp\        TP                  T P                  4      4      hi ; i)zZ
Verify that an uinput device exists and is readable and writable
by the current process.
z_"{}" does not exist or is not a character device file - verify that the uinput module is loadedz!"{}" cannot be opened for writingz8uinput device name must not be longer than {} charactersN)r   statr0   ZST_MODEZS_ISCHRZ
IndexErrorOSErrorZAssertionErrorr   r   ZaccessZW_OKrB   r+   r   Z
maxnamelen)r<   ZmrL   s   &  r   r3   ZUInput._verify  s    
	8%dll3A<<??"?
 yyrww//5Ccjj677tyy>G...LCcjj););<== / G^4 	8sCcjj677	8s   AD D =Ec                &   < V ^8  d   QhRS[ RS[/# )r   r4   return)r   r
   r   r!   r   r"   r#   #  s     , ,s ,{ ,r   c                s    \         P                  ! 4       R8X  d)    \        P                  ! V4      pV P	                  V4      # V P                  4       #   \
         d     T P                  4       # i ; i)zg
Tries to find the device node. Will delegate this task to one of
several platform-specific functions.
ZLinux)platformZsystemr   Zget_sysname_find_device_linuxr^   _find_device_fallback)r<   r4   sysnamerX   r   r:   ZUInput._find_device#  sq    
 ??'!--b1..w77 ))++    ))++s   &A A0/A0c                r_   )r   rd   r`   )r   r
   r   r!   r   r"   r#   5  s     "( "(# "(+ "(r   c                sp   RV 2p\         P                  ! R4      p\        P                  ! V4       F!  pVP	                  V4      '       g   K  RV 2p M	  \        4       h\        ^4       F  p \        V4      u # 	  \        V4      #   \
        \        3 d    \        P                  ! R4        KH  i ; i)z6
Tries to find the device node when running on Linux.
z/sys/devices/virtual/input/zevent[0-9]+/dev/input/皙?)recompiler   Zlistdir	fullmatchZFileNotFoundErrorZranger
   ZPermissionErrortimesleep)r<   rd   ZsyspathregexZentryZdevice_pathZattempts   &&     r   rb   ZUInput._find_device_linux5  s    
 0y9
 

=)ZZ(Eu%% +E73 )
 $%% RyG ";// ! ;'' &7  

3 s   0
B

'B54B5c                s4   < V ^8  d   QhRS[ S[R3,          /# )r   r`   N)r   r
   r   r!   r   r"   r#   Y  s      u[$->'? r   c                s   \         P                  ! R4       . p\        P                  ! R4      p\        P
                  ! R4       FB  pVP                  V4      pV'       g   K  \        V^,          4      pVP                  W534       KD  	  VP                  R RR7       V F/  w  r6\        V4      pVP                  V P                  8X  g   K-  Vu # 	  R# )z
Tries to find the device node when UI_GET_SYSNAME is not available or
we're running on a system sufficiently exotic that we do not know how
to interpret its return value.
rf   z/dev/input/event([0-9]+)re   c                 s    V ^,          # )i   r   )ZpairrE   r   Z<lambda>Z.UInput._find_device_fallback.<locals>.<lambda>r  s    Qr   T)ZkeyZreverseN)rj   rk   rg   rh   r	   Zlist_devicesri   r   r'   Zsortr
   r+   )r<   Zpath_number_pairsrl   ZpathZregex_matchZdevice_numberZ_Zds   &       r   rc   ZUInput._find_device_fallbackY  s     	

3 

56%%m4D//$/KA/M$$d%:; 5 	#7F(GDD!Avv" )r   )
r/   r;   r0   r7   r4   r+   r1   r-   r,   r.   )	r+   r,   r-   r.   r/   r%   r0   r4   r;   )FT)r   r   r   r   Z__doc__Z	__slots__Zclassmethodr   ZEV_SYNZEV_FFr*   ZgetrA   r5   rF   rH   rK   rM   rG   r(   rV   rY   r[   r\   r3   r:   rb   rc   r   Z__classdictcell__)r    s   @r   r   r      s     

I *6 '-mmV\\%B*6 *6 *6\ 6:%$% MM%%&6;`> `>D($F
: :R
Q
>(, ,$"( "(H r   r   )r6   r   ra   rg   r]   rj   Zcollectionsr    Ztypingr   r   r   r   r   Z r   r   r   r	   r;   r
   r   r%   r   Zevdev.eventio_asyncr   ZImportErrorZevdev.eventioZ	Exceptionr   r   r   r   r   <module>rm      sb     	  	   # 9 9 ' ' ( &+
	) 	_W _  &%&s   A& &A65A6