+
     i*  c                  s    ^ RI Ht ^ RIHtHtHtHt ^ RIt^ RI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 ]'       d   ^ RIHt  ! R R]4      tR# )i    )annotations)TYPE_CHECKINGDictHashableTupleN)EV_ABSEV_REL)InputCombination)Mapping)GlobalUInputs)MappingHandlerInputEventHandlerHandlerEnums)
InputEvent)logger)Contextc                  s"  a  ] tR t^*t$ RtR]R&   R]R&   R]R&   R]R	&   R
]R&   R V 3R lltR tR t]	R 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 ltR R ltR R  ltR! R" ltR# R$ ltR% R& ltR' R( ltR) R* ltR+tV ;t# )-CombinationHandlerz8Keeps track of a combination and notifies a sub handler.zDict[Hashable, bool]_pressed_keysbool_output_previously_activer   _sub_handlerzlist[Hashable]_handled_input_hasheszDict[Tuple[int, int], bool]_requires_a_releasec          
     s,    V ^8  d   QhRRRRRRRRR	R
/# )   combinationr   mappingr   contextr   global_uinputsr	   returnNone Zformat   "a/usr/lib/python3.14/site-packages/inputremapper/injection/mapping_handlers/combination_handler.py__annotate__CombinationHandler.__annotate__6   s<     + +%+ + 	+
 &+ 
+    c                	s*  < \         P                  ! \        V4      4       \        SV `  WV4       / V n        R V n        W0n        / V n        V F  pR V P
                  VP                  &   K  	  V Uu. uF  qfP                  NK  	  upV n
        R# u upi FN)r   debugstrZsuper__init__r   r   _contextr   input_match_hashr   )selfr   r   r   r   Z_input_config	__class__s   &&&&&, r!   r(   ZCombinationHandler.__init__6   s     	S\"~>).&#%  (L@ED|<<= (
 ?J&
>Il))k&
" &
s   2Bc                	s   R \        V P                  P                  4       R\        ;QJ d.    . R V P                  P                  4        4       F  NK  	  5 2# ! R V P                  P                  4        4       4       2# )CombinationHandler for "" c              3  $   "   T F  qx  K  	  R # 5iNr   Z.0Zt   & r!   	<genexpr>Z-CombinationHandler.__str__.<locals>.<genexpr>S        : 91Q 9   )r'   r   input_combinationtupler   keysr+      &r!   __str__ZCombinationHandler.__str__P   sp    &s4<<+I+I'J&K2u: 2 2 7 7 9:u;=	
: 2 2 7 7 9::;=	
r$   c                	s6   R \        V P                  P                  4       R\        ;QJ d,    . R V P                  P                  4        4       F  NK  	  5M%! R V P                  P                  4        4       4       2pRV R\        \        V 4      4       R2# )r.   r/   c              3  r0   r1   r   r2   r3   r!   r4   Z.CombinationHandler.__repr__.<locals>.<genexpr>Y   r5   r6   Z<z at Z>)reprr   r7   r8   r   r9   ZhexZid)r+   Zdescriptionr3   r!   __repr__ZCombinationHandler.__repr__V   s    &tDLL,J,J'K&LBu: 2 2 7 7 9:uu: 2 2 7 7 9::;= 	 ;-tC4M?!44r$   c                	s    V P                   # r1   )r   r:   r;   r!   childZCombinationHandler.child]   s        r$   c               s(    V ^8  d   QhRRRRRRRR/# )r   eventr   sourceevdev.InputDevicesuppressr   r   r   r   r    r!   r"   r#   b   s2     = == "= 	=
 
=r$   c                	s~   VP                   V P                  9  d   R # VP                  ^8H  pW@P                  VP                   &   V P	                  4       V P
                  8g  pV'       d,   V'       d   V P                  W1V4      # V P                  W4      # V'       d   V P                  V4      # V P                  V4      # F)
r*   r   valuer   _is_activatedr   _handle_freshly_activated_handle_freshly_deactivated_handle_no_change_press_handle_no_change_release)r+   r@   rA   rC   Z
is_pressedZchangeds   &&&&  r!   notifyZCombinationHandler.notifyb   s     !!)C)CC
 [[A%
5?5112$$&$*H*HH55hvNN77FF33E::55e<<r$   c                    V ^8  d   QhRRRR/# r   r@   r   r   r   r   r   r    r!   r"   r#      s     . .Z .D .r$   c                s\    V P                  V P                  '       * V4       V P                  # )zA key was pressed, but this doesn't change the combinations activation state.
Can only happen if either the combination wasn't already active, or a duplicate
key-down event arrived (EV_ABS?)
)_require_release_laterr   r+   r@      &&r!   rI   Z*CombinationHandler._handle_no_change_press   s+     	##(F(F$FN ---r$   c               rL   rM   r   r   r    r!   r"   r#      s     5 5z 5d 5r$   c                s.    V P                  V4      '       * # )zWOne of the combinations keys was released, but it didn't untrigger the
combination yet.)_should_release_eventrO   rP   r!   rJ   Z,CombinationHandler._handle_no_change_release   s     --e444r$   c               s(    V ^8  d   QhRRRRRRRR/# )r   rC   r   r@   r   rA   rB   r   r   r   r    r!   r"   r#      s2     " "" " "	"
 
"r$   c                s<   V'       d   R# V P                  4        \        P                  ! R\        V4      \        V P                  4      4       \        VP                  4      V n        V P                  P                  W#V4      pV P                  V'       * V4       V# )z6The combination was deactivated, but is activated now.FSending %s to sub-handler %s)
_forward_releaser   r&   r=   r   r   rE   r   rK   rN   )r+   rC   r@   rA   Zsub_handler_results   &&&& r!   rG   Z,CombinationHandler._handle_freshly_activated   s      	*K""#	

 *.ekk):&!..55eXN 	##(:$:EB!!r$   c               $    V ^8  d   QhRRRRRR/# )r   r@   r   rA   rB   r   r   r   r   r    r!   r"   r#      s(     5 55 "5 
	5r$   c                s   \         P                  ! R\        V4      \        V P                  4      4       \	        VP
                  4      V n        V P                  P                  WRR7       V P                  V4      '       * # )z6The combination was activated, but is deactivated now.rR   F)rC   )	r   r&   r=   r   r   rE   r   rK   rQ   )r+   r@   rA      &&&r!   rH   Z.CombinationHandler._handle_freshly_deactivated   sj     	*K""#	

 *.ekk):&   ? --e444r$   c               rL   rM   r   r   r    r!   r"   r#      s     H H: H$ Hr$   c                sN    V P                   P                  VP                  R4      # )a$  Check if the key-up event should be forwarded by the event-reader.

After this, the release event needs to be injected by someone, otherwise the
dictionary was modified erroneously. If there is no entry, we assume that there
was no key-down event to release. Maybe a duplicate event arrived.
F)r   Zpoptype_and_coderO   rP   r!   rQ   Z(CombinationHandler._should_release_event   s#     ''++E,?,?GGr$   c               rT   )r   requirer   r@   r   r   r   r   r   r    r!   r"   r#      s&     @ @d @: @$ @r$   c                s6    WP                   VP                  &   R# )zCRemember if this key-down event will need a release event later on.N)r   rV   )r+   rW   r@   rU   r!   rN   Z)CombinationHandler._require_release_later   s     9@  !4!45r$   c                   V ^8  d   QhRR/# r   r   r   r   r   r    r!   r"   r#      s     / /t /r$   c                	s    V P                   P                  4        V P                   F  pR V P                  V&   K  	  / V n        R V n        R# r%   )r   resetr   r   r   )r+   Zkeyr3   r!   rZ   ZCombinationHandler.reset   sD    !%%C&+Ds# &#% ).&r$   c               rX   r   r   r   r   r   r    r!   r"   r#      s     8 8t 8r$   c                s<    RV P                   P                  4       9  # )z1Return if all keys in the keymap are set to True.F)r   Zvaluesr:   r;   r!   rF   Z CombinationHandler._is_activated   s    D..55777r$   c               rX   rY   r   r   r    r!   r"   r#      s      E  E$  Er$   c                s  a  \        S P                  4      ^8X  g   S P                  P                  '       g   R# \	        V 3R lS P                  P
                  4      p\        P                  ! RS P                  P
                  4       V F  pS P                  P                  VP                  4      '       g   K0  VP                  pVf%   \        P                  ! R\        V4       24       Kd  S P                  P                  V4      p\        P                   ! W$4       VP                   ! . VP                  O^ N5!   VP#                  4        S P                  VP                   K  	  R# )zForward a button release for all keys if this is a combination.

This might cause duplicate key-up events but those are ignored by evdev anyway
Nc                sN   < SP                   P                  V P                  4      # r1   )r   getr*   )Zcfgr+   s   &r!   Z<lambda>Z5CombinationHandler._forward_release.<locals>.<lambda>   s    **..s/C/CDr$   zForwarding release for %sz,Can't forward due to missing origin_hash in )Zlenr   r   Zrelease_combination_keysZfilterr7   r   r&   r   r\   rV   origin_hashZerrorr=   r)   Zget_forward_uinputZwriteZsyn)r+   Zkeys_to_releaser,   r]   Z
forward_tos   f    r!   rS   Z#CombinationHandler._forward_release   s   
 t!!"a't||/T/T/T DLL**

 	0$,,2P2PQ+L++//0J0JKK&22K"B4CUBVW 99+FJLL2<l88<!<NN (()C)CD# ,r$   c               rX   r[   r   r   r    r!   r"   r#     s     ( (t (r$   c                	s,    \        V P                  4      # r1   )r   input_configsr:   r;   r!   needs_rankingZ CombinationHandler.needs_ranking  s    D&&''r$   c               rX   )r   r   r   r   r   r    r!   r"   r#     s     
 
) 
r$   c                	s|    \        V P                   Uu. uF  qP                  '       d   K  VNK  	  up4      # u upi r1   )r   r^   defines_analog_inputrO   r3   r!   rank_byZCombinationHandler.rank_by  s4     $ 2 2U 2u:T:TUU 2U
 	
Us   99c               rX   )r   r   z$Dict[InputCombination, HandlerEnums]r   r   r    r!   r"   r#     s     	 	? 	r$   c                	sH   / pV P                    F  pVP                  \        8X  d0   VP                  '       g   \        P
                  V\        V.4      &   VP                  \        8X  g   K^  VP                  '       d   Kr  \        P                  V\        V.4      &   K  	  V# r1   )	r^   Ztyper   r`   r   Zabs2btnr   r   Zrel2btn)r+   Zreturn_dictZconfigs   &  r!   	wrap_withZCombinationHandler.wrap_with  s}    ((F{{f$V-H-H-H:F:N:N,fX67{{f$V-H-H-H:F:N:N,fX67 ) r$   )r)   r   r   r   r   rD   )Z__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__Z__annotations__r(   r<   r>   Zpropertyr?   rK   rI   rJ   rG   rH   rQ   rN   rZ   rF   rS   r_   ra   rb   Z__static_attributes__Z__classcell__)r-   s   @r!   r   r   *   s    B ('  $###))44+ +4
5 ! !=:.5"45,H"@
/8 ED(

	 	r$   r   )Z
__future__r    Ztypingr   r   r   r   ZevdevZevdev.ecodesr   r   Z"inputremapper.configs.input_configr   Zinputremapper.configs.mappingr   Z&inputremapper.injection.global_uinputsr	   Z8inputremapper.injection.mapping_handlers.mapping_handlerr
   r   r   Zinputremapper.input_eventr   Zinputremapper.logging.loggerr   Zinputremapper.injection.contextr   r   r   r$   r!   <module>rc      sE   ( # 7 7  ' ? 1 @ 
 1 /7l lr$   