+
     i/E  c                  s   ^ RI Ht ^ RIt^ RIHtHtHtHtHtH	t	H
t
 ^ RIHt ^ RIHt ^ RIHt  ^ RIHtHtHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHtHt ]P@                  ]PB                  ]PD                  ]PF                  ]PH                  ]PJ                  .t&^ct'Rt( ! R R]4      t)]]]]*]]*]+3,          3,          ,          ]]),          3,          t, ! R R]])R3,          4      t-R#   ] d    ^ RIHtHtHt  Li ; i)i    )annotationsN)TupleIterableUnionListDictOptionalHashable)ecodes)	PathUtils)
InputEvent)	BaseModelroot_validator	validator)keyboard_layout)MessageType)logger)get_evdev_constant_name
DeviceHashi  c                  s   ] tR t^:t$ Rt]P                  tR]R&   R]R&   Rt	R]R&   Rt
R]R	&   R
 tR t]R R l4       t]R R l4       t]R R l4       t]R R l4       t]R 4       t]R R l4       tR,R R lltR R ltR R ltR R ltR R  ltR-R! R" lltR# t]! R	4      R$ 4       t]R% 4       t]! R&R'7      R( 4       t  ! R) R*4      t!R+t"R# ).InputConfigzEDescribes a single input within a combination, to configure mappings.inttypecodeNzOptional[DeviceHash]origin_hashOptional[int]analog_thresholdc                	sH    R \        V P                  V P                  4       2# )zInputConfig )r   r   r   self   &G/usr/lib/python3.14/site-packages/inputremapper/configs/input_config.py__str__ZInputConfig.__str__J   s     5diiKLMM    c                	s    R V P                    R\        V P                   !   RV P                   RV P                   R\	        \        V 4      4       R2# )z<InputConfig  , z, at >)type_and_coder   r   r   hexidr   r   r   __repr__ZInputConfig.__repr__M   s]    D../q&(:(:;<B$$%R  !bh-	#	
r   c                   V ^8  d   QhRR/# )   returnr    Zformat   "r   __annotate__InputConfig.__annotate__W   s     6 6( 6r   c                sH    V P                   V P                  V P                  3# )za Hashable object which is intended to match the InputConfig with a
InputEvent.

InputConfig itself is hashable, but can not be used to match InputEvent's
because its hash includes the analog_threshold
)r   r   r   r   r   r   input_match_hashZInputConfig.input_match_hashV   s     yy$))T%5%555r   c               r'   r(   r)   Zboolr*   r+   r,   r   r-   r.   a   s     ' '$ 'r   c                	s(    V P                   \        8H  # N)r   
EMPTY_TYPEr   r   r   is_emptyZInputConfig.is_empty`   s    yyJ&&r   c               r'   r0   r*   r+   r,   r   r-   r.   e   s     H Hd Hr   c                sn    V P                   '       * ;'       d    V P                  \        P                  8g  # )z%Whether this defines an analog input.)r   r   r   EV_KEYr   r   r   defines_analog_inputZ InputConfig.defines_analog_inputd   s(     (((GGTYY&---GGr   c               r'   )r(   r)   zTuple[int, int]r*   r+   r,   r   r-   r.   j   s     $ $ $r   c                s2    V P                   V P                  3# )zEvent type, code.r   r   r   r   r   r#   ZInputConfig.type_and_codei   s     yy$))##r   c                	sN    V ! \         P                  \         P                  R 7      # )r6   )r   r4   ZBTN_LEFTclsr   r   btn_leftZInputConfig.btn_leftn   s    FOO<<r   c                    V ^8  d   QhRRRR/# )r(   eventr
   r)   r   r*   r+   r,   r   r-   r.   s   s     
 
Z 
K 
r   c                sj    V ! VP                   VP                  VP                  VP                  R7      # )zUcreate an input confing from the given InputEvent, uses the value as
analog thresholdr   r   r   r   )r   r   r   Zvalue)r8   r;      &&r   from_input_eventZInputConfig.from_input_eventr   s/     ))"[[	
 	
r   c               r'   r(   r)   strr*   r+   r,   r   r-   r.   }   s     
 
s 
r   c                s    V P                  4        RV'       g   V P                  4       MR RV'       g   V P                  4       MR 2P                  4       # )z.Get a human-readable description of the event.r     )	_get_name_get_direction_get_threshold_valueZstrip)r   exclude_thresholdZexclude_directions   &&&r   descriptionZInputConfig.description}   sM     ~~ ,=t""$2Fa2Ct((*LNNSeg	
r   c               r'   r(   r)   Optional[str]r*   r+   r,   r   r-   r.      s       r   c                s   V P                   \        P                  8X  d   \        P                  V P                  u;8:  d   \        P
                  8:  d6   M M2\        V P                   V P                  4      pVP                  RR4      # \        P
                  V P                  u;8  d   \        8:  d2   M R# V P                  \        P                  ,
          ^,           pRV 2# R# )zGet a human-readable description of a mouse-button. Only the first 7
mouse buttons are in evdev and they often have misleading names there
(eg it calls buttons 6 & 7 forward/back but usually that's buttons 5 & 4).
Returns None if not a mouse button.BTN_zMouse Button N)	r   r   r4   Z	BTN_MOUSEr   Z
BTN_MIDDLEr   replaceMAX_BTN_MOUSE_ECODE)r   key_nameZbutton_number   &  r   _get_mouse_button_nameZ"InputConfig._get_mouse_button_name   s     99%499A0A0AA 7		499 M''O  ""TYYE2EE  &*YY1A1A%AA%E&}o66r   c               r'   rG   r*   r+   r,   r   r-   r.      s     : := :r   c                s<   V P                   '       d   R# V P                  4       pVR8w  d   V# V P                  \        P                  9  d3   \
        P                  ! RV 4       RV P                  V P                  3 2# V P                  \        P                  V P                  ,          9  d3   \
        P                  ! RV 4       RV P                  V P                  3 2# RpV P                  \        P                  8X  d!   \        P                  ! V P                  4      pVf!   \        V P                  V P                  4      pVP                  RR4      pVP                  RR4      pVP                  R	R
4      pVP                  RR4      pVP                  RR4      pVP                  RR4      pVP                  RR4      pVP                  RR4      pVP                  RR4      pVP                  RR4      pVP                  RR4      pVP                  RR4      pVP                  RR4      pVP                  RR 4      pVP                  R!R 4      pVP                  R"R#4      pVP                  R$R#4      pVP                  R%R&4      pVP                  R'R&4      pV# )(z>Human-readable name (e.g. KEY_A) of the specified input event.NzUnknown type for %szunknown zUnknown code for %sZABS_ZzTrigger LeftZABS_RZzTrigger Right	ABS_HAT0XzDPad-X	ABS_HAT0YzDPad-Y	ABS_HAT1XzDPad-2-X	ABS_HAT1YzDPad-2-Y	ABS_HAT2XzDPad-3-X	ABS_HAT2YzDPad-3-YABS_Xz
Joystick-XABS_Yz
Joystick-YABS_RXzJoystick-RXABS_RYzJoystick-RYrI   zButton ZKEY_rA   ZREL_ZHWHEELZWheelZWHEELZ_r    z  )r3   rN   r   r   Zbytyper   warningr   r4   r   Zget_namer   rJ   )r   Zmouse_button_namerL   rM   r   rB   ZInputConfig._get_name   sN    === ,0+F+F+H$$$99FMM)NN0$7dii234499FMM$))44NN0$7dii2344 99%&//		:H /tyy$))DH##G^<##Ho>##K:##K:##K<##K<##K<##K<##G\:##G\:##Hm<##Hm<##FI6##FB/##FB/##Hg6##GW5##C-##D#.r   c               r'   r?   r*   r+   r,   r   r-   r.      s     %
 %
 %
r   c                s   V P                   \        P                  8X  g   V P                  '       d   R# V P                  \        V P                  4      ,          p/ \        P                  R3Rb\        P                  ^3Rb\        P                  R3Rb\        P                  ^3Rb\        P                  R3Rb\        P                  ^3Rb\        P                  R3Rb\        P                  ^3Rb\        P                  R3Rb\        P                  ^3Rb\        P                  R3Rb\        P                  ^3Rb\        P                  ^3Rb\        P                  R3Rb\        P                  ^3Rb\        P                  R3Rb\        P                  ^3Rb\        P                  R3R\        P                  ^3R\        P                  R3R\        P                   R3R\        P                   ^3R\        P"                  R3R\        P"                  ^3R/CP%                  V P&                  V34      ;'       g    V^ 8  d   R# R# )	z=human-readable direction description for the analog_thresholdrA   ZLeftZRightZUpZDownZ+Z-)r   r   r4   r5   r   absrO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   Z	REL_WHEELZ
REL_HWHEELgetr   )r   Zthreshold_direction   & r   rC   ZInputConfig._get_direction   sj   99%)B)B)B #33s4;P;P7QQ
r"F
 q!7
 r"D	

 q!6
 r"F
 q!7
 r"D
 q!6
 r"F
 q!7
 r"D
 q!6
 \\1w
  \\2!
" \\1v#
$ \\2%
& ]]A'
( ]]B]]A]]Br"Fq!4#V"G7
8 #tyy-.
/9
 
: '*C;	
: 14;	
r   c               r'   r?   r*   r+   r,   r   r-   r.      s      c r   c                s    V P                   f   R# \        P                  \        V P                   4       \        P                  \        V P                   4       R2/P                  V P                  4      ;'       g    R# )z7human-readable value of the analog_threshold e.g. '20%'rA   Z%)r   r   ZEV_RELr[   ZEV_ABSr\   r   r   r   r   rD   Z InputConfig._get_threshold_value   sl      (MMc$"7"789MMc$"7"789;
 #dii.  	r   c          
     s,    V ^8  d   QhRRRRRRRRRR/# )	r(   type_r   r   r   rH   r   r)   r   r*   r+   r,   r   r-   r.     s<     
 

 
 #	

 (
 

r   c                s    \        Ve   TMV P                  Ve   TMV P                  Ve   TMV P                  Ve   VR7      # V P                  R7      # )zReturn a new modified event.r<   )r   r   r   r   r   )r   r^   r   r   r   s   &&&&&r   modifyZInputConfig.modify  s_     +)tyy'2'>DDTDT $/ !	
 		
 **	
 		
r   c                	sp    \        V P                  V P                  V P                  V P                  34      # r1   )Zhashr   r   r   r   r   r   r   __hash__ZInputConfig.__hash__  s*    TYY		4+;+;T=R=RSTTr   c                s     V^ 8X  g   Vf   R# V# )z.ensure the analog threshold is none, not zero.Nr*   )r8   r   r=   r    _ensure_analog_threshold_is_noneZ,InputConfig._ensure_analog_threshold_is_none  s     q $4$<r   c                s\    VP                  R4      pV\        P                  8X  d   RVR&   V# )z3remove the analog threshold if the type is a EV_KEYr   Nr   )r\   r   r4   )r8   valuesr^      && r   &_remove_analog_threshold_for_key_inputZ2InputConfig._remove_analog_threshold_for_key_input$  s.     

6"FMM!)-F%&r   T)Zprec                	s    VP                  R 4      pVf4   VP                  R4      \        8w  d   \        P                  ! RV4       V# VP	                  4       VR &   V# )r   r   zNo origin_hash set for %s)r\   r2   r   rY   Zlower)r8   rb   r   rc   r   validate_origin_hashZ InputConfig.validate_origin_hash,  sU    jj/ zz&!Z/:FCM + 1 1 3}r   c                  s    ] tR tRtRtRtRtR# )InputConfig.Configi:  FTr*   N)__name__
__module____qualname____firstlineno__Zallow_mutationZunderscore_attrs_are_private__static_attributes__r*   r   r   Configrf   :  s    '+$r   rl   r*   )FF)NNNN)#rg   rh   ri   rj   __doc__r   Zselected_eventZmessage_typeZ__annotations__r   r   r   r&   propertyr/   r3   r5   r#   classmethodr9   r>   rF   rN   rB   rC   rD   r_   r`   r   ra   r   rd   re   rl   rk   r*   r   r   r   r   :   s0   O--L
I
I
 )-K%, '+m*N
 6 6 ' ' H H $ $ = = 
 

*:x%
N
&U !"  #     , ,r   r   c                  s   a  ] tR tRtRtR V 3R lltR tR t]R 4       t	]R R	 l4       t
R
 R lt]R R l4       t]R 4       tR R lt]R R l4       tRR R lltR R ltR R ltRtV ;t# )InputCombinationiE  z3One or more InputConfigs used to trigger a mapping.c               r:   )r(   configsInputCombinationInitr)   rp   r*   r+   r,   r   r-   InputCombination.__annotate__J  s      7  72  77G  7r   c                s  < \        V\        4      '       g   \        R4      h\        V\        4      '       d   \        R4      h. pV F  p\        V\        4      '       d   \        R4      h\        V\        4      '       d   VP                  V4       KM  \        V\        4      '       d   VP                  \        R/ VB 4       K  \        RV R24      h	  \        V4      ^ 8X  d   \        RV: 24      h\        SV `)  W4      # )zCreate a new InputCombination.

Examples
--------
    InputCombination([InputConfig, ...])
    InputCombination([{type: ..., code: ..., value: ...}, ...])
z1InputCombination requires a list of InputConfigs.z3InputCombinations require InputConfigs, not Events.zCan't handle "Z"z1failed to create InputCombination with configs = r*   )
isinstancer   	TypeErrorr   r
   appenddictlenZ
ValueErrorZsuper__new__)r8   rq   Zvalidated_configsZconfig	__class__s   &&  r   ry   ZInputCombination.__new__J  s     '8,,OPPg{++OPPF':.. UVV&+..!((0FD))!(()>v)>?/& ;<<   !Q&QwlSTT ws66r   c                	s:    R RP                  R V  4       4       R2# )zCombination ( + c              3  8   "   T F  p\        V4      x  K  	  R # 5ir1   )r@   .0r;   r]   r   	<genexpr>Z+InputCombination.__str__.<locals>.<genexpr>m  s     )G$#e**$   Z))joinr   r   r   r   ZInputCombination.__str__l  s!    uzz)G$)GGHJJr   c                	sh    R P                  R V  4       4      pRV R\        \        V 4      4       R2# )r!   c              3  r|   r1   )Zreprr}   r]   r   r   Z,InputCombination.__repr__.<locals>.<genexpr>p  s     >Ur   z<InputCombination (z) at r"   )r   r$   r%   )r   Zcombinationr]   r   r&   ZInputCombination.__repr__o  s3    ii>>>$[Ms2d8}oQGGr   c              #  s*   "   V P                   x  R# 5i)z4Used by pydantic to create InputCombination objects.N)validater7   r   r   __get_validators__Z#InputCombination.__get_validators__s  s      lls   c               r'   r(   r)   rp   r*   r+   r,   r   r-   rs   y  s      #3 r   c                sB    \        V\        4      '       d   V# V ! V4      # )z$The only valid option is from_config)rt   rp   )r8   Zinit_argr=   r   r   ZInputCombination.validatex  s!     h 011O8}r   c               r'   )r(   r)   zTuple[Dict[str, int], ...]r*   r+   r,   r   r-   rs     s     X X5 Xr   c                sZ    \         ;QJ d    . R V  4       F  NK  	  5# ! R V  4       4      # )z&Turn the object into a tuple of dicts.c              3  D   "   T F  qP                  R R7      x  K  	  R# 5i)T)Zexclude_defaultsN)rw   )r~   input_configr]   r   r   Z-InputCombination.to_config.<locals>.<genexpr>  s!     WRV,&&&==RV    Ztupler   r   r   	to_configZInputCombination.to_config  s&    uWRVWuWuWRVWWWr   c               r'   r   r*   r+   r,   r   r-   rs     s     O O"2 Or   c                s(    V ! R\         R^cR^c/.4      # )zzA combination that has default invalid (to evdev) values.

Useful for the UI to indicate that this combination is not set
r   r   r   )r2   r7   r   r   empty_combinationZ"InputCombination.empty_combination  s      VZ5GLMNNr   c           
     s   . pV Fz  p\        V4      ^8X  d/   VP                  RV^ ,          RV^,          RV^,          /4       KA  \        V4      ^8X  d&   VP                  RV^ ,          RV^,          /4       Kv  \        h	  V ! V4      # )zIConstruct an InputCombination from (type, code, analog_threshold) tuples.r   r   r   )rx   rv   ru   )r8   ZtuplesZdictsZtuple_s   &*  r   from_tuplesZInputCombination.from_tuples  s     F6{aq	q	*F1I V!q	q	  # & 5zr   c               r'   r0   r*   r+   r,   r   r-   rs     s       r   c                s    \        V 4      ^8:  d   R# V  F<  pVP                  \        P                  8w  d   K$  VP                  \
        9   g   K;   R# 	  R# )z:Is this combination going to work properly on all systems?FT)rx   r   r   r4   r   DIFFICULT_COMBINATIONS)r   r   r]   r   is_problematicZInputCombination.is_problematic  sF    t9> L  FMM1  $:: ! r   c               r'   r0   r*   r+   r,   r   r-   rs     s     C Cd Cr   c                sd    R\         ;QJ d    . R V  4       F  NK  	  59   # ! R V  4       4      9   # )z+Check if there is any analog input in self.Tc              3  s8   "   T F  qP                   x  K  	  R # 5ir1   )r5   )r~   Zir]   r   r   Z8InputCombination.defines_analog_input.<locals>.<genexpr>  s     BT33Tr   r   r   r   r   r5   Z%InputCombination.defines_analog_input  s.     uuBTBuBBuBTBBBBr   c               r:   )r(   r^   r   r)   zOptional[InputConfig]r*   r+   r,   r   r-   rs     s     	 	"			r   c                sr    V  F0  pVP                   '       g   K  Ve   VP                  V8X  g   K.  Vu # 	  R# )z4Return the first event that defines an analog input.N)r5   r   )r   r^   r   rc   r   find_analog_input_configZ)InputCombination.find_analog_input_config  s7     !L000!2!2e!;##	 !
 r   c               r'   )r(   r)   zList[InputCombination]r*   r+   r,   r   r-   rs     s      "8 r   c                sD   \        V 4      ^8:  d   V .# \        V 4      ^8  d5   \        P                  ! R\        V 4      \        P                  ! 4       4       . p\
        P                  ! V RR 4       F)  pVP                  \        . VOV R,          N54      4       K+  	  V# )zGet a list of EventCombinations representing all possible permutations.

combining a + b + c should have the same result as b + a + c.
Only the last combination remains the same in the returned result.
zYour input combination has a length of %d. Long combinations might freeze the process. Edit the configuration files in "%s" to fix it.NrZ   )	rx   r   rY   r	   Zget_config_path	itertoolspermutationsrv   rp   )r   r   ZpermutationrM   r   get_permutationsZ!InputCombination.get_permutations  s     t9>6Mt9q=NNVD	))+	 $11$s)<K 01I;1IR1I JK = r   c               r'   r?   r*   r+   r,   r   r-   rs     s     W W# Wr   c                sh    V \         P                  4       8X  d   R# RP                  R V  4       4      # )z+Get a human-readable string representation.r   r{   c              3  r   )T)rE   N)rF   r}   r]   r   r   Z,InputCombination.beautify.<locals>.<genexpr>  s!     VQU++d+CCQUr   )rp   r   r   r   r   r   beautifyZInputCombination.beautify  s-    #5577&zzVQUVVVr   r*   r1   )rg   rh   ri   rj   rm   ry   r   r&   ro   r   r   r   r   r   r   rn   r5   r   r   r   rk   Z__classcell__)rz   s   @r   rp   rp   E  s    = 7  7DKH    X O O  0 C C	.W Wr   rp   .).Z
__future__r    r   Ztypingr   r   r   r   r   r   r   Zevdevr   Zinputremapper.configs.pathsr	   Zinputremapper.input_eventr
   Zpydantic.v1r   r   r   ZImportErrorZpydanticZ%inputremapper.configs.keyboard_layoutr   Z(inputremapper.gui.messages.message_typesr   Zinputremapper.logging.loggerr   Zinputremapper.utilsr   r   ZKEY_LEFTSHIFTZKEY_RIGHTSHIFTZKEY_LEFTCTRLZKEY_RIGHTCTRLZKEY_LEFTALTZKEY_RIGHTALTr   r2   rK   r   r@   r   rr   rp   r*   r   r   <module>r      s   ( #  I I I  1 0>@@ B @ / C
 




  

  B,) B,J T#uS#X&'([ XWu[#-. XWM	  >==>s   
C( (C<;C<