+
     iG  c                  s>  a  0 t $ ^ RIHt ^ RIt^ RIHt ^ RIHtHtH	t	H
t
HtHtH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HtHtHt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/H0t0H1t1H2t2H3t3H4t4H5t5H6t6 ^ RI7H8t8 ^ RI9H:t: ^ RI;H<t< ^ RI=H>t> ^ RI?H@t@ ]P                  ! ]B! ]#4      4      ]P                  ! R4      8  tC]8! R4      tDR]ER&   ^<tFR]ER&   ^tGR]ER&   ^xtHR]ER&   ^<tIR]ER&    ! R R]B]P                  4      tK ! R R]B]P                  4      tL]]](](.R3,          ,          tM]
! RRR 7      tN ! R! R"]$4      tO ! R# R$]O4      tP ! R% R]4      tQ ! R& R']Q4      tR ! R( R)]Q4      tSR#   ]% d    ^ RI&HtHtHtHtHtH t H!t!H"t"H#t#H$t$  EL=i ; i)*i    )annotationsN)
namedtuple)OptionalCallableTupleTypeVarUnionAnyDict)EV_KEYEV_ABSEV_REL	REL_WHEEL
REL_HWHEELREL_HWHEEL_HI_RESREL_WHEEL_HI_RES)version)logger)
	BaseModelPositiveIntconfloatconintroot_validator	validatorValidationErrorPositiveFloatVERSION
BaseConfig)InputCombination)keyboard_layoutDISABLE_NAME)
OutputSymbolUnknownErrorSymbolNotAvailableInTargetErrorOnlyOneAnalogInputErrorTriggerPointInRangeErrorOutputSymbolVariantErrorMacroButTypeOrCodeSetErrorSymbolAndCodeMismatchErrorWrongMappingTypeForKeyErrorMissingOutputAxisErrorMissingMacroOrKeyError)_)MessageType)GlobalUInputs)Parser)get_evdev_constant_namez1.7.1zEmpty MappingstrEMPTY_MAPPING_NAMEfloatREL_XY_SCALINGWHEEL_SCALINGWHEEL_HI_RES_SCALINGDEFAULT_REL_RATEc                  s*    ] tR t^jtRtRtRtRtRtRt	R# )KnownUinputzThe default targets.keyboardZmouseZgamepadzkeyboard + mouse N)
__name__
__module____qualname____firstlineno____doc__ZKEYBOARDZMOUSEZGAMEPADZKEYBOARD_MOUSE__static_attributes__r7       B/usr/lib/python3.14/site-packages/inputremapper/configs/mapping.pyr5   r5   j   s    HEG'Nr>   r5   c                  s"    ] tR t^stRtRtRtRtR# )MappingTypez)What kind of output the mapping produces.Z	key_macroZanalogr7   N)r8   r9   r:   r;   r<   	KEY_MACROANALOGr=   r7   r>   r?   r@   r@   s   s    3IFr>   r@   MappingModel	UIMapping)Zboundc                  s,    ] tR t^tRtRtRt]R /tRt	R# )CfgTc                	s"    V P                  4       # N)Zjson_key)Zv   &r?   Z<lambda>ZCfg.<lambda>   s
    r>   r7   N)
r8   r9   r:   r;   Zvalidate_assignmentZuse_enum_valuesZunderscore_attrs_are_privater   Zjson_encodersr=   r7   r>   r?   rE   rE      s    O#' %'=>Mr>   rE   c                  s    ] tR t^tRtRtR# )ImmutableCfgFr7   N)r8   r9   r:   r;   Zallow_mutationr=   r7   r>   r?   rH   rH      s    Nr>   rH   c                  sB  a a ] tR t^t0 o$ Rt]'       d   REt]P                  ! 4       t	R]
R&   RtR]
R&   RtR]
R	&   RtR
]
R&   RtR
]
R&   RtR]
R&   RtR]
R&   RtR]
R&   ^ tR]
R&   RtR]
R&   RtR]
R&   ^ tR]
R&   ^<tR]
R&   ^tR]
R&   R tR!]
R"&   R#tR]
R$&   ]'       g   RtR%]
R&   V 3R& ltR' V 3R( lltR) t]'       d
   R* V 3R+ lltR, R- ltR. R/ lt R0 R1 lt!R2 R3 lt"R4 R5 lt#R6 t$R7 R8 lt%R9 t&R: R; lt'R< R= lt(R> R? lt)R@ RA lt*RB RC lt+],RD 4       t-].t/REt0V ;t1# )FrD   a  Holds all the data for mapping an input action to an output action.

The Preset contains multiple UIMappings.

This mapping does not validate the structure of the mapping or macros, only basic
values. It is meant to be used in the GUI where invalid mappings are expected.
_combination_changedr   input_combinationNz!Optional[Union[str, KnownUinput]]target_uinputzOptional[str]output_symbolzOptional[int]output_typeoutput_codenamezOptional[MappingType]mapping_typeTboolrelease_combination_keyszconint(ge=0)macro_key_sleep_msg?zconfloat(ge=0, le=1)deadzoneg      ?r0   gainzconfloat(ge=-1, le=1)expor   rel_raterel_to_abs_input_cutoffg?r   release_timeoutFforce_release_timeoutz$Optional[CombinationChangedCallback]c                	sr   < \         SV `  ! R/ VB  \        '       d   \        P	                  V R R4       R# R# )rI   Nr7   )super__init__needs_workaroundobject__setattr__)selfkwargs	__class__s   &,r?   r\   ZUIMapping.__init__   s1    "6"t%;TB r>   c               s     V ^8  d   QhRRRR/# )   keyr.   valuer   r7   Zformat   "r?   __annotate__UIMapping.__annotate__   s     < <s <3 <r>   c                s  < VR8w  g   V P                   f>   VR8X  d&   \        '       d   \        P                  V RV4       R# \        SV `  W4       R#  \
        P                  ! V4      pY0P                  8X  d   R# T P                  Y0P                  4       \        ST `  RT4       R#   \        \        3 d   p\        RT R2\        4      ThRp?ii ; i)zVCall the combination changed callback
if we are about to update the input_combination
rJ   NrI   zfailed to Validate z as InputCombination)rI   r]   r^   r_   r[   r   ZvalidateZ
ValueErrorZ	TypeErrorr   rD   rJ   )r`   rd   re   Z	new_combi	exceptionrb   s   &&&  r?   r_   ZUIMapping.__setattr__   s     %%)B)B)J,,1A1A""4)?GG+	(11%8I ... 	!!)-C-CD/; I& 	!%eW,@A9	s   B* *C;CCc                	s>    \        V P                  R RR0R7      4      # )TrJ   rK   )exclude_defaultsZincluder.   dictr`   rG   r?   __str__ZUIMapping.__str__   s+    II!%0C_/U  
 	
r>   c                    V ^8  d   QhRRRR/# )rc   r`   rC   returnr7   rf   rg   r?   rh   ri      s     	 	| 	 	r>   c                	st   < R VR&   \         SV `  ! V/ VB p\        P                  VRV P                  4       V# )TZdeeprI   )r[   copyr^   r_   rI   )r`   argsra   rr   rb      &*, r?   rr   ZUIMapping.copy   s=    !F6N7<00Dt%;T=V=VWKr>   c                   V ^8  d   QhRR/# rc   rq   r.   r7   rf   rg   r?   rh   ri      s     1 1S 1r>   c                s    V P                   '       d   V P                   # V P                  \        P                  ! 4       8X  g   V P                  f   \        # V P                  P                  4       # )zDGet the custom-name or a readable representation of the combination.)rO   rJ   r   empty_combinationr/   Zbeautifyrn   rG   r?   format_nameZUIMapping.format_name   sV    99999 ""&6&H&H&JJ%%-%%%%..00r>   c               ru   rc   rq   rQ   r7   rf   rg   r?   rh   ri     s     N N4 Nr>   c                sF    V P                   \        P                  ! 4       8g  # )z,Whether this mapping defines an event-input.)rJ   r   rw   rn   rG   r?   has_input_definedZUIMapping.has_input_defined  s    %%)9)K)K)MMMr>   c               ru   ry   r7   rf   rg   r?   rh   ri   	  s     4 4 4r>   c                4    V P                   \        \        39   # )z.Whether this mapping specifies an output axis.)rM   r
   r   rn   rG   r?   is_axis_mappingZUIMapping.is_axis_mapping	  s    FF#333r>   c               ru   ry   r7   rf   rg   r?   rh   ri     s     
 
 
r>   c                r{   )z#Check if this maps to wheel output.)rN   r   r   rn   rG   r?   is_wheel_outputZUIMapping.is_wheel_output  s     $
 
 	
r>   c               ru   ry   r7   rf   rg   r?   rh   ri     s     
 
$ 
r>   c                r{   )z,Check if this maps to high-res wheel output.)rN   r   r   rn   rG   r?   is_high_res_wheel_outputZ"UIMapping.is_high_res_wheel_output  s     $
 
 	
r>   c                	s<    V P                   \        P                  8H  # rF   )rP   r@   rB   rn   rG   r?   is_analog_outputZUIMapping.is_analog_output  s      K$6$666r>   c               ru   )rc   callbackCombinationChangedCallbackr7   rf   rg   r?   rh   ri     s     - -9S -r>   c                	s    Wn         R # rF   rI   )r`   r   s   &&r?    set_combination_changed_callbackZ*UIMapping.set_combination_changed_callback  s    $,!r>   c                	s    R V n         R # rF   r   rn   rG   r?   #remove_combination_changed_callbackZ-UIMapping.remove_combination_changed_callback!  s
    $(!r>   c               ru   )rc   rq   zOptional[Tuple[int, int]]r7   rf   rg   r?   rh   ri   $  s      &? r>   c                s*   V P                   e'   V P                  e   V P                  V P                   3# V P                  '       dM   \        P                  ! V P                  4      '       g'   \
        \        P                  ! V P                  4      3# R# )zReturns the output_type and output_code if set,
otherwise looks the output_symbol up in the keyboard_layout
return None for unknown symbols and macros
N)rN   rM   rL   r,   is_this_a_macror	   r   getrn   rG   r?   get_output_type_codeZUIMapping.get_output_type_code$  ss    
 'D,<,<,H##T%5%555f&<&<T=O=O&P&P?..t/A/ABBBr>   c               ru   rv   r7   rf   rg   r?   rh   ri   1  s     K K# Kr>   c                sB    \        V P                  V P                  4      # )z*Get the evdev name costant for the output.)r-   rM   rN   rn   rG   r?   get_output_name_constantZ"UIMapping.get_output_name_constant1  s    &t'7'79I9IJJr>   c               ru   ry   r7   rf   rg   r?   rh   ri   5  s     $ $$ $r>   c                s,    V P                  4       '       * # )If the mapping is valid.)	get_errorrn   rG   r?   is_validZUIMapping.is_valid5  s    >>###r>   c               ru   )rc   rq   zOptional[ValidationError]r7   rf   rg   r?   rh   ri   9  s      4 r>   c                sn     \        R/ V P                  4       B  R#   \         d   pTu Rp?# Rp?ii ; i)zThe validation error or None.Nr7   )Mappingrm   r   )r`   rj   s   & r?   r   ZUIMapping.get_error9  s5    	"diik"   		s    4/44c               ru   )rc   rq   MappingDatar7   rf   rg   r?   rh   ri   A  s     * * *r>   c                s4    \        R/ V P                  4       B # )z7Return an immutable copy for use in the message broker.r7   )r   rm   rn   rG   r?   get_bus_messageZUIMapping.get_bus_messageA  s    )TYY[))r>   c                s   VP                  R4      pVP                  R4      pVP                  R4      pVe   Ve   \        P                  ! R4       V\        8w  d*   Ve&   V'       g   \        P
                  P                  VR&   Vf*   Vf&   V'       d   \        P                  P                  VR&   V\        8X  d   \        P                  P                  VR&   V# )zAOverrides the mapping type if the output mapping type is obvious.rM   rN   rL   z*Both output_type and output_symbol are setrP   )r   r   Zdebugr	   r@   rB   re   rA   )clsvaluesrM   rN   rL      &&   r?   validate_mapping_typeZUIMapping.validate_mapping_typeE  s     jj/jj/

?3"}'@ LLEF& [%<]%0%7%7%=%=F>";#6=%0%:%:%@%@F>"& %0%:%:%@%@F>"r>   r   )2r8   r9   r:   r;   r<   r]   Z	__slots__r   rw   rJ   __annotations__rK   rL   rM   rN   rO   rP   rR   rS   rT   rU   rV   rW   rX   rY   rZ   rI   r\   r_   ro   rr   rx   rz   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   rE   Configr=   __classcell__)rb   __conditional_annotations__s   @@r?   rD   rD      sl     -	 +;*L*L*N'N7;M4; $(M='!%K%!%K%D-*.L'. &*d) ()( &)H"(D%"#D
# Hk
 ,-[, &*O]) #(4' EIBIC
< <4
 	 	1N4

7-)K$*  . Fr>   c                  s    ] tR tRt$ RtR]R&   R]R&   ]RR l4       tR	 R
 lt]	! RR7      R 4       t
]! R4      R R l4       t]! R4      R R l4       t]	R 4       t]	R 4       t]	R R l4       tRtR# )r   i`  z}Holds all the data for mapping an input action to an output action.

This implements the missing validations from UIMapping.
r   rJ   r5   rK   Nc                s:    V'       g
   R^cR^cR^c/.pV ! VVVR7      # )z+Convenient function to get a valid mapping.typecodeanalog_threshold)rJ   rK   rL   r7   )r   rJ   rK   rL   s   &&&&r?   from_combinationZMapping.from_combinationj  s4     !"("fb:Lb!Q R/''
 	
r>   c               ru   ry   r7   rf   rg   r?   rh   Mapping.__annotate__{  s      $ r>   c                s    R# )r   Tr7   rn   rG   r?   r   ZMapping.is_valid{  s    r>   T)Zprec                s   VP                  R4      pVR8X  d   RVR&   V# Vf   V# VP                  4       pW!R&   V\        8X  d   V# \        P                  ! V4      '       d;   \        RVP                  4       4      ! R/ VB p\        P                  ! W#RR7       V# \        P                   ! V4      pVf   \        V4      hVP                  R4      pVe.   \        P                  ! V\        V4      '       g   \        W%4      hV# )	z)Parse a macro to check for syntax errors.rL   Z Nr   F)mappingZverboserK   r7   )r   Zstripr   r,   r   r   Zkeysparser   r   r+   Zcan_default_uinput_emitr	   r    )r   r   symbolZmapping_mockr   Ztargets   &&    r?   validate_symbolZMapping.validate_symbol  s     O,R<&*F?#M>M"(\!M!!&))%i?I&ILLLuEM""6*<*622O,m&K&KFD'
 '
 2&AAr>   c               ru   )rc   rq   r   r7   rf   rg   r?   rh   r     s      3C r>   c                s    V Uu. uF  q"P                   '       g   K  VNK  	  pp\        V4      ^8  d   \        V4      hV# u upi )zUCheck that the input_combination specifies a maximum of one
analog to analog mapping
)defines_analog_inputZlenr!   )r   combinationZeventZanalog_eventss   &&  r?   only_one_analog_inputZMapping.only_one_analog_input  sD    
 -8VK5;U;UKV}!)-88	 Ws
   AAc               rp   )rc   r   r   rq   r7   rf   rg   r?   rh   r     s     	 	1A 	FV 	r>   c                s    V FS  pVP                   \        8X  g   K  VP                  '       g   K.  \        VP                  4      ^d8  g   KJ  \	        V4      h	  V# )zGCheck if the trigger point for mapping analog axis to buttons is valid.)r   r
   r   Zabsr"   )r   r   Zinput_configs   && r?   trigger_point_in_rangeZMapping.trigger_point_in_range  sN     (L!!V+ 111556#=.|<< ( r>   c                s    VP                  R4      pVP                  R4      pVP                  R4      pVf   Ve   Vf   \        4       hV# )zDValidate that either type and code or symbol are set for key output.rL   rM   rN   )r   r#   )r   r   Zo_symbolZo_typeZo_coder   r?   validate_output_symbol_variantZ&Mapping.validate_output_symbol_variant  sJ     ::o.M*M*6>*,,r>   c                sR   VP                  R4      pVP                  R4      pVP                  R4      pVf   V# Vf   Vf   V# \        P                  ! V4      '       d   Vf   Ve   \        4       hVe   V\        P                   ! V4      8w  g   V\
        8w  d   \        W$4      hV# )z&Validate the output key configuration.rL   rM   rN   )r   r,   r   r$   r   r	   r%   )r   r   r   Ztype_r   r   r?   validate_output_integrityZ!Mapping.validate_output_integrity  s     O,

=)zz-(> M=T\M!!&)) D$4022(;(;F(C CuPV,V::r>   c               rp   )rc   r   zDict[str, Any]rq   r7   rf   rg   r?   rh   r     s      . ^ r>   c                s   VR,          pVP                  4       pVRJpVP                  R4      pVP                  R4      pVP                  R4      pVP                  R4      pT;'       g    V\        8H  ;'       d    Tp	Vf   V# V'       g*   V\        P                  P
                  8w  d   \        4       hV'       g   V	'       g   \        4       hV'       d(   V\        \        39  d   V\        8w  d   \        W54      hV# )zQValidate that an output type is an axis if we have an input axis.
And vice versa.rJ   NrM   rN   rP   rL   )Zfind_analog_input_configr   r	   r@   rA   re   r&   r(   r
   r   r   r'   )
r   r   r   Zanalog_input_configr   rM   rN   rP   rL   Zoutput_key_sets
   &&        r?   output_matches_inputZMapping.output_matches_input  s    
 )//B(C)BBD2$>jj/jj/zz.1

?3&QQ;&+@+P+P[M#8M8M8S8S(S-//#N(** !FF#33-()<JJr>   r7   )Nr6   Za)r8   r9   r:   r;   r<   r   Zclassmethodr   r   r   r   r   r   r   r   r   r   r=   r7   r>   r?   r   r   `  s     ('
 
  ! !F "# $ "#	 $	    .  r>   r   c                  sN   a  ] tR tRtRt]t]P                  t	R t
V 3R ltRtV ;t# )r   i  z8Like UIMapping, but can be sent over the message broker.c                	s8    \        V P                  R R7      4      # )T)rk   rl   rn   rG   r?   ro   ZMappingData.__str__  s    499d9344r>   c                s<   < \         SV `  ! V/ VB pRV9   d   VR V# )z"Will not include the message_type.message_type)r[   rm   )r`   rs   ra   Zdict_rb   rt   r?   rm   ZMappingData.dict  s+    d-f-U"n%r>   r7   )r8   r9   r:   r;   r<   rH   r   r*   r   r   ro   rm   r=   r   )rb      @r?   r   r     s%    BF&&L5 r>   r   )Tr   Z
__future__r    ZenumZcollectionsr   Ztypingr   r   r   r   r   r   r   Zevdev.ecodesr	   r
   r   r   r   r   r   Z	packagingr   Zinputremapper.logging.loggerr   Zpydantic.v1r   r   r   r   r   r   r   r   r   r   ZImportErrorZpydanticZ"inputremapper.configs.input_configr   Z%inputremapper.configs.keyboard_layoutr   r   Z'inputremapper.configs.validation_errorsr   r    r!   r"   r#   r$   r%   r&   r'   r(   Zinputremapper.gui.gettextr)   Z(inputremapper.gui.messages.message_typesr*   Z&inputremapper.injection.global_uinputsr+   Z$inputremapper.injection.macros.parser,   Zinputremapper.utilsr-   r   r.   r]   r/   r   r1   r2   r3   r4   ZEnumr5   r@   r   rC   rE   rH   rD   r   r   )r   r   r?   <module>r      s  ( # "  " G G G    /  4 @ O   ( @ @ 7 7
 ==W.w1GG  O, C ,
  u  " e ! % (#tyy (#tyy  & 01478  ~[9?* ?3 R	 Rj\i \~) W     s   E9 9FF