+
     i  c                  s    R t ^ RIHt ^ RIHt ^ RIHtHtHtH	t	 ^ RI
t
^ RIHt ^ RIHtHt ^ RIHtHt ^ RIHt ^ R	IHt ^ R
IHt  ! R R4      tR# )z*Stores injection-process wide information.)annotations)defaultdict)ListDictSetHashableN)Preset)EventListenerNotifyCallback)MappingParserEventPipelines)
InputEvent)logger)
DeviceHashc                  s    ] tR t^,t$ RtR]R&   R]R&   R]R&   R]R	&   R
]R&   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R# )Contexta  Stores injection-process wide information.

In some ways this is a wrapper for the preset that derives some
information that is specifically important to the injection.

The information in the context does not change during the injection.

One Context exists for each injection process, which is shared
with all coroutines and used objects.

Benefits of the context:
- less redundant passing around of parameters
- easier to add new process wide information without having to adjust
  all function calls in unittests
- makes the injection class shorter and more specific to a certain task,
  which is actually spinning up the injection.

Note, that for the reader_service a ContextDummy is used.

Members
-------
preset : Preset
    The preset holds all Mappings for the injection process
listeners : Set[EventListener]
    A set of callbacks which receive all events
callbacks : Dict[Tuple[int, int], List[NotifyCallback]]
    All entry points to the event pipeline sorted by InputEvent.type_and_code
zSet[EventListener]	listenersz$Dict[Hashable, List[NotifyCallback]]_notify_callbacksr
   	_handlersDict[DeviceHash, evdev.UInput]_forward_devices#Dict[DeviceHash, evdev.InputDevice]_source_devicesc               s(    V ^8  d   QhRRRRRRRR/# )	   presetr   source_devicesr   forward_devicesr   mapping_parserr	    Zformat   "D/usr/lib/python3.14/site-packages/inputremapper/injection/context.py__annotate__Context.__annotate__P   s2     ! !! <! 8	!
 &!    c                	sH   \        V4      ^ 8X  d   \        P                  ! R4       \        V4      ^ 8X  d   \        P                  ! R4       \        4       V n        W n        W0n        \        \        4      V n	        VP                  W4      V n        V P                  4        R# )i    zforward_devices not setzsource_devices not setN)Zlenr   Zwarningsetr   r   r   r   Zlistr   Zparse_mappingsr   _create_callbacks)selfr   r   r   r   s   &&&&&r   __init__ZContext.__init__P   sx     1$NN45~!#NN34- /!,T!2'66vD r!   c                   V ^8  d   QhRR/# r   returnZNoner   r   r   r   r   r    e   s        t  r!   c                sz    V P                   P                  4        F  pV F  pVP                  4        K  	  K  	  R# )z6Call the reset method for each handler in the context.N)r   valuesreset)r$   Zhandlershandler   &  r   r*   ZContext.resete   s,    --/H# $ 0r!   c               r&   r'   r   r   r   r   r   r    k   s      4 r!   c                s    V P                   P                  4        FQ  w  rVP                  p\        P                  ! RV4       V P
                  V,          P                  R V 4       4       KS  	  R# )z;Add the notify method from all _handlers to self.callbacks.zAdding NotifyCallback for %sc              3  s8   "   T F  qP                   x  K  	  R # 5iN)Znotify)Z.0r+   s   & r   Z	<genexpr>Z,Context._create_callbacks.<locals>.<genexpr>p   s      <.:7ls   N)r   Zitemsinput_match_hashr   Zdebugr   Zextend)r$   Zinput_configZhandler_listr.   s   &   r   r#   ZContext._create_callbacksk   s`    *...*>*>*@&L+<<LL79IJ""#34;; <.:<  +Ar!   c                    V ^8  d   QhRRRR/# )r   input_eventr   r(   zList[NotifyCallback]r   r   r   r   r   r    t   s     8 8
 8?S 8r!   c                	s@    VP                   pV P                  V,          # r-   )r.   r   )r$   r0   r.   s   && r   get_notify_callbacksZContext.get_notify_callbackst   s     &77%%&677r!   c               r/   )r   origin_hashr   r(   zevdev.UInputr   r   r   r   r   r    x   s     2 2j 2\ 2r!   c                (    V P                   V,          # )zEGet the "forward" uinput events from the given origin should go into.)r   )r$   r2      &&r   get_forward_uinputZContext.get_forward_uinputx   s    $$[11r!   c               r/   )r   keyr   r(   zevdev.InputDevicer   r   r   r   r   r    |   s     ) )j )-> )r!   c                	r3   r-   )r   )r$   r6   r4   r   
get_sourceZContext.get_source|   s    ##C((r!   c               r&   )r   r(   zSet[int]r   r   r   r   r   r       s      ( r!   c                s    \        4       pV P                  P                  4        F"  pVP                  VP	                  4       4       K$  	  V# )z0Get a set of LED_* ecodes that are currently on.)r"   r   r)   Zupdateleds)r$   r8   Zdevicer,   r   get_ledsZContext.get_leds   s9    u**113FKK& 4r!   )r   r   r   r   r   N)Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__Z__annotations__r%   r*   r#   r1   r5   r7   r9   Z__static_attributes__r   r!   r   r   r   ,   sO    : "!;;4488!* 82) r!   r   )r:   Z
__future__r    Zcollectionsr   Ztypingr   r   r   r   ZevdevZinputremapper.configs.presetr   Z8inputremapper.injection.mapping_handlers.mapping_handlerr   r   Z7inputremapper.injection.mapping_handlers.mapping_parserr	   r
   Zinputremapper.input_eventr   Zinputremapper.logging.loggerr   Zinputremapper.utilsr   r   r   r!   r   <module>r;      s=   * 1 " # , ,  / 1 / *X Xr!   