+
     iJ#  c                   s    ^ RI t ^ RIHtHtHt ^ RIt^ RIHtHtH	t	H
t
HtHt ^ RIHt ^ RIHtHt ^ RIHtHtHtHtHt ^ RIHt ^ RIHt ^ R	IHtHtHt ^ R
I H!t!H"t" ^ RI#H$t$  ! R R]4      t%R# )i    N)TupleDictOptional)EV_ABSEV_REL	REL_WHEEL
REL_HWHEELREL_HWHEEL_HI_RESREL_WHEEL_HI_RES)
exceptions)InputCombinationInputConfig)MappingWHEEL_SCALINGWHEEL_HI_RES_SCALINGREL_XY_SCALINGDEFAULT_REL_RATE)GlobalUInputs)Transformation)MappingHandlerHandlerEnumsInputEventHandler)
InputEventEventActions)loggerc                   s.  a a ] tR t^5t oRtV3R lV 3R lltR tR t]R 4       t	V3R lR lt
R	 tR
 tRV3R lR lltV3R lR ltV3R lR ltV3R lR ltV3R lR ltV3R lR ltV3R lR ltV3R lR ltV3R lR ltV3R ltRtVtV ;t# ) RelToAbsHandlerzHandler which transforms EV_REL to EV_ABS events.

High EV_REL input results in high EV_ABS output.
If no new EV_REL events are seen, the EV_ABS output is set to 0 after
release_timeout.
c                s0   < V ^8  d   QhRS[ RS[RS[RR/# )   combinationmappingglobal_uinputsreturnN)r
   r   r   Zformat__classdict__   "`/usr/lib/python3.14/site-packages/inputremapper/injection/mapping_handlers/rel_to_abs_handler.py__annotate__RelToAbsHandler.__annotate__I   s3     #/ #/%#/ #/ &	#/ 
#/    c           	     s  < \         S	V `  WV4       VP                  \        R 7      ;p'       g   Q hWPn        VP
                  f   Q hVP                  \        8X  g   Q hVP                  VP
                  3V n        VP                  VP                  4      pVf   Q hVP                  RR7      \        ,          p\        V4      VP
                  ,          V n        V P                  4       p\        \!        ^\#        V4      4      ) \!        ^\#        V4      4      VP$                  VP&                  VP(                  R7      V n        \,        P.                  ! 4       V n        RV n        RV n        \6        V n        R# ))Ztype_NT)Zabsinfo)Zmin_max_deadzonegainexpo)Zsuper__init__Zfind_analog_input_configr   	_map_axisZoutput_codeZoutput_typer   _output_axisZ
get_uinputtarget_uinputZcapabilitiesZdict_target_absinfo_get_default_cutoffr   maxintr'   r(   r)   
_transformasyncioEvent_moving_recenter_loop_previous_eventr   _observed_rate)
selfr   r   r   Z_Zmap_axisr-   Zabs_capabilitiesr&   	__class__s
   &&&&,    r"   r*   ZRelToAbsHandler.__init__I   sD    	~> (@@v@NNNON!""...""f,,,$00'2E2EF&11'2G2GH((((55d5CFK#$45g6I6IJ'')(aT##QD	"%%
 }}"#.r%   c                s     R V P                    2# )zRelToAbsHandler for )r+   r9      &r"   __str__ZRelToAbsHandler.__str__n   s    %dnn%566r%   c                sJ    R \        V 4       R\        \        V 4      4       R2# )Z< at Z>)ZstrZhexZidr;   r<   r"   __repr__ZRelToAbsHandler.__repr__q   s#    3t9+T#bh-22r%   c                s    R V P                   P                  4        RV P                   P                  4        RV P                   P                   2# )z	maps to: Z r>   )r   Zget_output_name_constantZget_output_type_coder-   r;   r<   r"   childZRelToAbsHandler.childt   sJ     ==?@||00234||))*,	
r%   c                    < V ^8  d   QhRS[ /# )r   event)r   r   r!   r"   r#   r$   |   s     % %: %r%   c                sV   V P                   e   VP                  4       V P                   P                  4       ,
          pV^ 8X  d   \        P                  ! R4       R# ^V,          pW0P                  8  d.   \        P
                  ! RV4       W0n        V P                  4        Wn         R# )zEWatch incoming events and remember how many events appear per second.Nz+Observed two events with the same timestampzUpdating rate to %s)r7   Z	timestampr   errorr8   Zdebug_calculate_cutoff)r9   rB   Z
delta_timeZrates   &&  r"   _observe_rateZRelToAbsHandler._observe_rate|   s    +*T-A-A-K-K-MMJQJKz>D )))2D9&*#&&($r%   c                s\   V P                   P                  \        \        39   d"   V P                  P
                  \        ,          # V P                   P                  \        \        39   d"   V P                  P
                  \        ,          # V P                  P
                  \        ,          # )z5Get the cutoff value assuming the default input rate.)r+   Zcoder   r   r   Zrel_to_abs_input_cutoffr   r   r   r   r   r;   r<   r"   r/   Z#RelToAbsHandler._get_default_cutoff   sr    >>9j"99<<77-GG>>#35F"GG<<77:NNN||33nDDr%   c           	     s    V P                  4       pV\        V P                  ,          ,          pV P                  P	                  \        ^\        V4      4      ) \        ^\        V4      4      4       R# )zDCorrect the default cutoff with the observed input rate, and set it.N)r/   r   r8   r2   Z	set_ranger0   r1   )r9   Zcutoffs   & r"   rD   Z!RelToAbsHandler._calculate_cutoff   sU    
 ))+"T%8%888!!3q#f+#6"6As6{8KLr%   c                sF   < V ^8  d   QhRS[ RS[P                  RS[RS[/# )r   rB   sourcesuppressr   )r   evdevZInputDeviceboolr   r!   r"   r#   r$      s9       !! 	
 
r%   c                s   V P                  V4       VP                  V P                  P                  8w  d   R # \        P                  VP
                  9   d?   V P                  '       d   V P                  P                  4        V P                  4        R# V P                  '       d!   V P                  P                  4       '       d*   \        P                  ! V P                  4       4      V n        V P                  P                  4         V P                  V P!                  V P#                  VP$                  4      4      4       R#   \&        P(                  \&        P*                  3 d     R # i ; i)FT)rE   Zinput_match_hashr+   r   ZrecenterZactionsr6   cancel	_recenterZ	cancelledr3   create_task_create_recenter_loopr5   Zset_write_scale_to_targetr2   valuer	   ZUinputNotAvailableZEventNotHandled)r9   rB   rF   rG   s   &&&&r"   notifyZRelToAbsHandler.notify   s    	5!!!T^^%D%DD  EMM1"""##**,NN"""d&9&9&C&C&E&E")"5"5d6P6P6R"SD	KK--dooekk.JKL--z/I/IJ 		s   9E %E0/E0c                   < V ^8  d   QhRR/# r   r   N r   r!   r"   r#   r$      s      t r%   c                s~    V P                   '       d   V P                   P                  4        V P                  4        R # N)r6   rJ   rK   r;   r<   r"   resetZRelToAbsHandler.reset   s*    &&(r%   c                rR   rS   rT   r   r!   r"   r#   r$      s     . .4 .r%   c                sF    V P                  V P                  ^ 4      4       R# )zRecenter the output.N)rN   rO   r;   r<   r"   rK   ZRelToAbsHandler._recenter   s    D))!,-r%   c                rR   rS   rT   r   r!   r"   r#   r$      s      T r%   c                s  "    V P                   P                  4       G Rj  xL
  \        P                  ! \        P                  ! V P                   P                  4       4      3V P                  P
                  R7      G Rj  xL
 ^ ,          '       d   V P                   P                  4        K  V P                  4        K   L LA5i)zCoroutine which waits for the input to start moving,
then waits until the input stops moving, centers the output and repeat.

Runs forever.
N)Ztimeout)r5   Zwaitr3   rL   r   Zrelease_timeoutZclearrK   r;   r<   r"   rM   Z%RelToAbsHandler._create_recenter_loop   s      ,,##%%%ll(():):)<=? LL88    ""$NN &s(   CCA CCC/CCc                s&   < V ^8  d   QhRS[ RS[/# )r   xr   )floatr1   r   r!   r"   r#   r$      s     9 9% 9C 9r%   c                sz   V P                   P                  V P                   P                  ,
          ^,          pV P                   P                  V,           pW!,          V,           pWC8  d*   \        \        V P                   P                  V4      4      # \        \        V P                   P                  V4      4      # )zScales a x value between -1 and 1 to an integer between
target_absinfo.min and target_absinfo.max

input values above 1 or below -1 are clamped to the extreme values
)r.   r0   Zminr1   )r9   rW   ZfactorZoffsetZys   &&   r"   rO   Z RelToAbsHandler._scale_to_target   s     &&**T-A-A-E-EEJ%%))F2J:s4//33Q788s4//33Q788r%   c                $   < V ^8  d   QhRS[ RR/# )r   rP   r   N)r1   r   r!   r"   r#   r$      s     	R 	RC 	RD 	Rr%   c                s     V P                   P                  . V P                  OVN5V P                  P                  4       R#   \
         d)    \        P                  ! R.T P                  OTN5!    R# i ; i)zInject.zOverflowError (%s, %s, %s)N)r   Zwriter,   r   r-   ZOverflowErrorr   rC   )r9   rP      &&r"   rN   ZRelToAbsHandler._write   sl    	R%%+$##+U+**  	RLL5Q8I8IQ5Q	Rs   ?A /A65A6c                rA   r   r   )rI   r   r!   r"   r#   r$      s     + + +r%   c                s2    \        V P                  4      ^8  # )i   )Zleninput_configsr;   r<   r"   needs_wrappingZRelToAbsHandler.needs_wrapping   s    4%%&**r%   c                rY   )r   handlerr   N)r   r   r!   r"   r#   r$      s      '8 T r%   c                s    Q hFrT   )r9   r^   rZ   r"   set_sub_handlerZRelToAbsHandler.set_sub_handler   s    ur%   c                s6   < V ^8  d   QhRS[ S[S[3,          /# r[   )r   r
   r   r   r!   r"   r#   r$      s      4 0, >? r%   c                s|    V P                  4       '       d&   \        V P                  4      \        P                  /# / # rU   )r]   r
   r\   r   Z
axisswitchr;   r<   r"   	wrap_withZRelToAbsHandler.wrap_with   s2      $T%7%78,:Q:QRR	r%   c                s   < V ^8  d   Qh/ S[ ;R&   S[S[S[3,          ;R&   S[;R&   S[P
                  ;R&   S[S[P                  ,          ;R&   S[P                  ;R&   S[S[
,          ;R&   S[;R&   # )	r   r+   r,   r2   r.   r6   r5   r7   r8   )r   r    r1   r   rH   ZAbsInfor   r3   ZTaskr4   r   rX   r   r!   r"   r#   r$   5   s        S/!    ]]"  W\\**  ]] " j))# $ % r%   )r+   r5   r8   r,   r7   r6   r.   r2   r_   )Z__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__r*   r=   r?   Zpropertyr@   rE   r/   rD   rQ   rV   rK   rM   rO   rN   r]   r`   ra   Z__annotate_func__Z__static_attributes__Z__classdictcell__Z__classcell__)r:   r    s   @@r"   r   r   5   s     &#/ #/J73 
 
% %$EM 6 
. . "9 9	R 	R+ +  C  r%   r   )&r3   Ztypingr    r   r   rH   Zevdev.ecodesr   r   r   r   r   r   Zinputremapperr	   Z"inputremapper.configs.input_configr
   r   Zinputremapper.configs.mappingr   r   r   r   r   Z&inputremapper.injection.global_uinputsr   Z7inputremapper.injection.mapping_handlers.axis_transformr   Z8inputremapper.injection.mapping_handlers.mapping_handlerr   r   r   Zinputremapper.input_eventr   r   Zinputremapper.logging.loggerr   r   rT   r%   r"   <module>rb      sX   (  ( (   % L  A R 
 ? /Dn Dr%   