+
     i%  c                  s   ^ 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HtHtHt ^ RIHtHtHt ^ RIHt ^ RIHtHt ^ RIHtHtH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( ^ RI)H*t* ^ RI+H,t,H-t- ^ RI.H/t/ ^ RI0H1t1H2t2 ^ RI3H4t4H5t5H6t6H7t7H8t8 ^ RI9H:t:H;t;H<t<H=t= ^ RI>H?t?H@t@ ^ RIAHBtB ]'       d   ^ RICHDtD RR/tE ! R R4      tFR# )i    )annotationsN)partial)
TYPE_CHECKINGOptionalUnionLiteralSequenceDictCallableListAnyTuple)EV_KEYEV_RELEV_ABS)Gtk)InputCombinationInputConfig)MappingData	UIMappingMappingType)	PathUtils)	pydantifyMissingMacroOrKeyErrorMacroButTypeOrCodeSetErrorSymbolAndCodeMismatchErrorMissingOutputAxisErrorWrongMappingTypeForKeyErrorOutputSymbolVariantError)DataManagementError)OutputTypeNames)DataManagerDEFAULT_PRESET_NAME)_)MessageBrokerMessageType)
PresetData
StatusDataCombinationRecordedUserConfirmRequestDoStackSwitch)	CTX_APPLY	CTX_ERRORCTX_WARNINGCTX_MAPPING)InjectorStateInjectorStateMessage)logger)UserInterfaceZtarget_uinputZkeyboardc                  s   ] tR t^VtRtR R ltR R ltR R ltR tR	 t	R
 R lt
R R ltR R ltR R lt]R R l4       t]R R l4       tR R ltR R ltR tR R ltR R ltR R  ltR! R" ltR# R$ ltR% tR& R' ltR( tR) R* ltR+ R, ltR- R. lt]3R/ R0 llt R1 t!R2 R3 lt"R4 t#R5 t$R6 t%R7 R8 lt&R9 t'R: t(R; t)R< t*R= R> lt+R? t,RKRA RB llt-RC RD lt.RE t/RF t0RG t1RH RI lt2RJt3R@# )L
Controllerz$Implements the behaviour of the gui.c               s$    V ^8  d   QhRRRRRR/# )   message_brokerr"   data_managerr   returnNone format   "A/usr/lib/python3.14/site-packages/inputremapper/gui/controller.py__annotate__Controller.__annotate__Y   s(     
! 
!%
! "
! 
	
!    c                	sZ    Wn         W n        R V n        RV n        V P	                  4        R # )NF)r3   r4   guibutton_left_warn_attach_to_events)selfr3   r4   s   &&&r;   __init__ZController.__init__Y   s+    
 -(,0 % r>   c                   V ^8  d   QhRR/# )r2   r?   r0   r7   r8   r:   r;   r<   r=   e   s      = r>   c                s    Wn         R# )z<Let the Controller know about the user interface singleton..N)r?   )rB   r?      &&r;   set_guiZController.set_guie   s    r>   c               rD   r2   r5   r6   r7   r8   r:   r;   r<   r=   i   s     	
 	
4 	
r>   c                	s   V P                   P                  \        P                  V P                  4       V P                   P                  \        P
                  V P                  4       V P                   P                  \        P                  V P                  4       V P                   P                  \        P
                  V P                  4       V P                   P                  \        P                  V P                  4       R # N)r3   	subscriber#   Zgroups_on_groups_changedZpreset_on_preset_changedZinit_on_init%_publish_mapping_errors_as_status_msgmappingrB      &r;   rA   ZController._attach_to_eventsi   s    %%k&8&8$:Q:QR%%k&8&8$:Q:QR%%k&6&6F%% J J	
 	%%!K!K	
r>   c                sn    V P                   P                  4        V P                   P                  4        R# )z(Initialize the gui and the data_manager.N)r4   Zpublish_groupsZpublish_uinputs)rB   __rE   r;   rL   ZController._on_initt   s(    
 	((*))+r>   c                s    V P                   P                  e   \        P                  ! R4       R# V P	                  4       pVf   \        P                  ! R4       R# V P                  V4       R# )zPLoad the newest group as soon as everyone got notified
about the updated groups.NzA group is already activezCould not find a group)r4   active_groupr/   debugget_a_group
load_group)rB   r!   	group_key   && r;   rJ   ZController._on_groups_changed|   sX     ))5 LL45$$&	LL12	"r>   c               rD   )r2   datar$   r7   r8   r:   r;   r<   r=      s     I Iz Ir>   c                sF   VP                   '       dg   \        VP                   4      pVP                  R R7       V^ ,          P                  pV P	                  V4       V P                  V^ ,          4       R# V P                  P                  \        R/ \        B 4       R# )zELoad a mapping as soon as everyone got notified about the new preset.c                sf    V P                  4       ;'       g    V P                  P                  4       # rH   )format_nameinput_combinationbeautify)rN   rP   r;   <lambda>Z/Controller._on_preset_changed.<locals>.<lambda>   s(    '')QQW-F-F-O-O-QQr>   )keyNr7   )
mappingslistZsortrZ   load_mappingload_input_configr3   publishr   MAPPING_DEFAULTS)rB   rX   r^   combinations   &&  r;   rK   ZController._on_preset_changed   s    ===DMM*HMM  
 #1+77Kk*"";q>2 ''(G6F(GHr>   c               rD   )r2   rX   r&   r7   r8   r:   r;   r<   r=      s     - --@ -r>   c                	s^    V P                  VP                  4      pV P                  V4       R # rH   )_auto_use_as_analogrd   update_combination)rB   rX   rd   rW   r;   _on_combination_recordedZ#Controller._on_combination_recorded   s&    ..t/?/?@,r>   c               rD   )r2   r5   zOptional[Tuple[str, str]]r7   r8   r:   r;   r<   r=      s     ( (6O (r>   c                	s.   V P                   P                  '       g   R # V P                   P                  P                  4       '       d+   V P                  P	                  \        \        4      4       R # \        V P                   P                  4      pV P                   P                  pVe$   VP                  V4       VP                  ^ V4       V F  pVP                  4       '       g   K  VP                  4       pV P                  V4      p\        V4      ^ 8X  d   KN  \        V4      ^8  d7   \        R4      \        V4      V3,          pRRP!                  V4      ,           pMRV RV^ ,           2pV^ ,          pVP#                  RR4      V3u # 	  R # )Nz)%d Mapping errors at "%s", hover for infou   – u   
– "": Z
Z )r4   active_presetZis_validr3   rb   r%   r,   r_   active_mappingremoveZinsertZhas_input_definedrY   _get_ui_error_stringslenr!   ZjoinZreplace)rB   r^   rk   rN   ZpositionZerror_stringsmsgtooltips   &       r;   $_format_status_bar_validation_errorsZ/Controller._format_status_bar_validation_errors   sc     ...**3355''
;(?@))778 **99%OON+OOA~.G,,.. **,H 66w?M=!Q&=!A%CD&H  !8==#??(3}Q'7&89'*;;tS)722-  0 r>   c               rD   rG   r7   r8   r:   r;   r<   r=      s     
 
D 
r>   c                s|    V P                  4       pVf   R# V P                  \        V^ ,          V^,          4       R# )z3Send mapping ValidationErrors to the MessageBroker.N)rq   show_statusr,   )rB   rQ   validation_results   &* r;   rM   Z0Controller._publish_mapping_errors_as_status_msg   s;     EEG$a a 	
r>   c                    V ^8  d   QhRRRR/# )r2   error_messagestrr5   r7   r8   r:   r;   r<   r=      s     8 8 8 8r>   c                s^   \        \        4      V9   g   \        \        4      V9   d(   V P                  P                  '       d   \        R4      # \        \        4      V9   g   \        \        4      V9   d(   V P                  P                  '       g   \        R4      # \        \        4      V9   dw   \        R4      pV P                  e\   V P                   Uu. uF  pVP                  '       g   K  VNK  	  up^ ,          pV\        RVP                  4        R24      ,          pV# \        \        4      V9   dM   \        R\        P                   R24      pV P                  \        \        39   d   V\        R4      ,          pV# \        \        4      V9   d   \        R	4      # V# u upi )
zICheck all the different error messages which are not useful for the user.zSRemove the macro or key from the macro input field when specifying an analog outputzCRemove the Analog Output Axis when specifying a macro or key outputzCThe input specifies an analog axis, but no output axis is selected.zx
If you mean to create a key or macro mapping go to the advanced input configuration and set a "Trigger Threshold" for "rh   z7The input specifies a key, but the output type is not "".zy
If you mean to create an analog axis mapping go to the advanced input configuration and set an input to "Use as Analog".zMissing macro or key)r   r   r   rZ   defines_analog_inputr!   r   output_symboldescriptionr   r   Zkey_or_macrooutput_typer   r   r   )rN   Z
error_typeru   events   &&& r;   format_error_messageZController.format_error_message   s    01Z?34
B''<<<3  01Z?34
B++@@@U  +,
:UM $$0 ")!:!:!:11 E!: 	
  ))+,A/"  ! 01Z?#0015M
 ""vv&66X" 
 ! +,
:+,,=s   F*3F*c                    V ^8  d   QhRRRR/# )r2   rN   r   r5   z	List[str]r7   r8   r:   r;   r<   r=     s        y  Y  r>   c                sv   V P                  4       pVf   . # . pVP                  4        F  p\        \        4      VR,          9   d   K   RV P	                  4        R2pVR,          pVR,          ^ ,          pVR8w  d   WF R2,          pVP                  \        P                  V VR,          V4      4       K  	  V# )z8Get a human readable error message from a mapping error.typerh   ri   ro   ZlocZ__root__z: )Z	get_errorZerrorsr   r   rY   Zappendr1   r}   )rN   Zvalidation_errorZformatted_errorserrorZerror_stringru   Zerror_locations   &      r;   rm   Z Controller._get_ui_error_strings  s     #,,.#I%,,.E12eFmC w2245S9L!%LM"5\!_N+"2" 55 ##//&M! /,  r>   c               rD   )r2   r5   rv   r7   r8   r:   r;   r<   r=   5  s     : :c :r>   c                s     V P                   P                  4       #   \         d     Mi ; iT P                   P                  T P                   P	                  4       4       T P                   P                  4       # )zZAttempts to get the newest preset in the current group
creates a new preset if that fails.)r4   Zget_newest_preset_nameFileNotFoundErrorcreate_presetget_available_preset_namerO   rP   r;   get_a_presetZController.get_a_preset5  sf    	$$;;==  		''(9(9(S(S(UV  7799    **c               rD   )r2   r5   Optional[str]r7   r8   r:   r;   r<   r=   ?  s     	) 	)] 	)r>   c                s     V P                   P                  4       #   \         d     Mi ; iT P                   P                  4       pT'       d
   T^ ,          # R# )zKAttempts to get the group with the newest preset
returns any if that fails.N)r4   Zget_newest_group_keyr   Zget_group_keys)rB   keys   & r;   rT   ZController.get_a_group?  sU    	$$99;;  		   //1tAw(D(r   c                s`   V P                   P                  P                  p\        P                  ! RV4      pV'       d   VRVP                  4        pV P                   P                  V P                   P                  V R24      4       V P                  P                  \        ^4      4       R# )zBCreate a copy of the active preset and name it `preset_name copy`.z copy *\d*$Nz copy)r4   rj   namereZsearchZstartcopy_presetr   r3   rb   r(   )rB   r   Zmatchs   &  r;   r   ZController.copy_presetJ  s      ..33		-.%++-(D%%774&G	
 	##M!$45r>   c               rt   )r2   rd   r   r5   r7   r8   r:   r;   r<   r=   V  s      /? DT r>   c                s   V P                   P                  f   V# V P                   P                  P                  4       '       g   V# VP                  4       '       d   V# \	        V4       Fe  w  r#VP
                  \        \        39   g   K"  \        P                  ! RV4       \        V4      pVP                  ^ R7      WB&   \        V4      pVu # 	  V# )z;If output is analog, set the first fitting input to analog.zUsing %s as analog inputZanalog_threshold)r4   rk   Zis_analog_outputZfind_analog_input_config	enumerater   r   r   r/   infor_   modifyr   )rB   rd   iinput_configZcombination_listZnew_combinations   &&    r;   re   ZController._auto_use_as_analogV  s    ++3  //@@BB//11(5OA  VV$446E $(#4 &2&9&91&9&M #"23C"D&&  6 r>   c               rD   )r2   rd   r   r7   r8   r:   r;   r<   r=   p  s      .> r>   c                sx   V P                  V4      p V P                  P                  VR7       V P                  4        TP                  4       '       d,   T P                  \        \        R4      \        R4      4       R# R#   \         d-    T P                  \        RTP                  4        R24        R# i ; i)z3Update the input_combination of the active mapping.rZ   rh   z"" already mapped to something elseNz,ctrl, alt and shift may not combine properlyzYour system might reinterpret combinations with those after they are injected, and by doing so break them. Play around with the advanced "Release Input" toggle.)re   r4   update_mappingsaveKeyErrorrr   r,   r[   Zis_problematicr+   r!   rB   rd   rE   r;   rf   ZController.update_combinationp  s    ..{;	,,{,KIIK %%''@A9 (  	K((*++MN 	s   ,B 3B98B9c               r~   )r2   r   r   	directionz%Union[Literal['up'], Literal['down']]r7   r8   r:   r;   r<   r=     s     *- *-!*- 9*-r>   c                s   V P                   P                  '       d/   \        V P                   P                  P                  4      ^8X  d   R# V P                   P                  P                  pVP	                  V4      pV^,           \        V4      8X  d   VR8X  g   V^ 8X  d
   VR8X  d   R# VR8X  dM   \        VRV^,
           4      V.,           W4^,
          ,          .,           \        W4^,           R 4      ,           pMZVR8X  dF   \        VRV 4      W4^,           ,          .,           V.,           \        W4^,           R 4      ,           pM\        RV 24      hV P                  \        V4      4       V P                  V4       R# )zWMove the active_input_config up or down in the input_combination of the
active_mapping.NZdownZupzunknown direction: )
r4   rk   rn   rZ   Zindexr_   
ValueErrorrf   r   ra   )rB   r   r   rd   r   s   &&&  r;    move_input_config_in_combinationZ+Controller.move_input_config_in_combination  sk    !!0004$$33EEF!K,,>> 	 l+ES%%V#AvT![1q5)*.!1u%&' {q57+,-  & [!_%1u%&'.! {q57+,-  29+>?? 0 =>|,r>   c               rD   )r2   r   r   r7   r8   r:   r;   r<   r=     s     : :k :r>   c                <    V P                   P                  V4       R# )z>Load an InputConfig form the active mapping input combination.N)r4   ra   )rB   r   rE   r;   ra   ZController.load_input_config  s    ++L9r>   c               rD   )r2   new_input_configr   r7   r8   r:   r;   r<   r=     s     . .K .r>   c                s     V P                   P                  V4       R#   \         d9    T P                   P                  4        T P                   P	                  4         R# i ; i)z&Modify the active input configuration.N)r4   update_input_configr   publish_mappingpublish_event)rB   r   rE   r;   r   ZController.update_input_config  sO    	.112BC 	.--/++-	.s    ?A"!A"c                sJ   V P                   P                  '       d   V P                   P                  '       g   R# \        V P                   P                  P                  4      pVP                  V P                   P                  4        V P                   P                  \        V4      R7       V P                  V^ ,          4       V P                  4        R#   \        \        3 d9    T P                   P                  4        T P                   P                  4         R# i ; i)zGRemove the active InputEvent from the active mapping event combination.Nr   )r4   rk   active_input_configr_   rZ   rl   r   r   ra   r   r   r   r   r   r   r   r;   remove_eventZController.remove_event  s     !!000$$8884,,;;MMN4,,@@A		.,,"2;"? -  "";q>2IIK*% 	.--/++-	.s   
AC AD"!D"c               rD   )r2   analogboolr7   r8   r:   r;   r<   r=     s     * *$ *r>   c                s   V P                   P                  f   Q hV P                   P                  pVP                  \        8w  d   V'       d?    V P                   P	                  VP                  ^ R7      4       V P                  4        R# \        ^R.\        ^
R./pW2P                  ,           F@  p V P                   P	                  VP                  VR7      4       V P                  4         R# 	  V P                   P                  4        V P                   P                  4        R#   \         d     LCi ; i  \         d     K  i ; i)z(Use the active event as an analog input.Nr   ii)r4   r   r   r   r   r   r   r   r   r   r   r   )rB   r   r|   Z
try_valuesvalues   &&   r;   set_event_as_analogZController.set_event_as_analog  s     44@@@!!55::%%99a8 IIK %q"gvCyA
'

33E))==!LL%L@ 		 4 	))+'')#    $ s$   ;D* 4;D;*D87D8;E
	E
c                :    V P                   P                  4        R# )zRefresh the groups.Nr4   refresh_groupsrO   rP   r;   load_groupsZController.load_groups  s    ((*r>   c               rD   )r2   rV   rv   r7   r8   r:   r;   r<   r=     s     . .C .r>   c                sz    V P                   P                  V4       V P                  V P                  4       4       R# )z/Load the group and then a preset of that group.N)r4   rU   load_presetr   )rB   rV   rE   r;   rU   ZController.load_group  s-    $$Y/**,-r>   c               rD   r2   r   rv   r7   r8   r:   r;   r<   r=      s     , , ,r>   c                r   )zLoad the preset.N)r4   r   )rB   r   rE   r;   r   ZController.load_preset   s    %%d+r>   c               rD   )r2   new_namerv   r7   r8   r:   r;   r<   r=     s     2 2c 2r>   c                s2   V P                   P                  '       d-   V'       d%   WP                   P                  P                  8X  d   R# \        P                  ! V4      pV P                   P                  V4      pV P                   P                  V4       R# )zRename the active_preset.N)r4   rj   r   r   Zsanitize_path_componentr   rename_preset)rB   r   rE   r;   r   ZController.rename_preset  sn     !!///,,::???44X>$$>>xH''1r>   c               rD   r   r7   r8   r:   r;   r<   r=     s     I Is Ir>   c                s.   V P                   P                  V4      p V P                   P                  V4       V P                   P                  V4       R#   \         d5   pT P                  \        \        R4      \        T4      4        Rp?R# Rp?ii ; i)zFCreate a new preset called `new preset n`, add it to the active_group.Permission denied!N)	r4   r   r   r   PermissionErrorrr   r*   r!   rv   )rB   r   erW   r;   
add_presetZController.add_preset  sw      ::4@	I++D1))$/ 	IY*>(?QHH	Is   6A B )BBc                s   a  R V 3R llpS P                   P                  '       g   R# \        R4      S P                   P                  P                  ,          pS P                  P                  \        W!4      4       R# )z'Delete the active_preset from the disc.c               rD   r2   answerr   r7   r8   r:   r;   r<   Z.Controller.delete_preset.<locals>.__annotate__  s     	> 	>d 	>r>   c                s   < V '       dj   SP                   P                  4        SP                   P                  SP                  4       4       SP                  P                  \        ^4      4       R# R# )i   N)r4   delete_presetr   r   r3   rb   r(   r   rB      &r;   fZ#Controller.delete_preset.<locals>.f  sS    !!//1!!--d.?.?.AB##++M!,<= r>   Nz0Are you sure you want to delete the preset "%s"?)r4   rj   r!   r   r3   rb   r'   )rB   r   ro   s   f  r;   r   ZController.delete_preset  sh    	> 	>   ...@A--223 	 	##$6s$>?r>   c               rD   )r2   rZ   r   r7   r8   r:   r;   r<   r=   ,  s     5 5.> 5r>   c                sl    V P                   P                  V4       V P                  V^ ,          4       R# )zILoad the mapping with the given input_combination form the active_preset.N)r4   r`   ra   )rB   rZ   rE   r;   r`   ZController.load_mapping,  s+    &&'89034r>   c                s&   RVP                  4       9   dP   V P                  V4      ;p'       g7   V P                  P                  4        V P                  P	                  4        R# V P                  P
                  ! R/ VB  V P                  4        R# )z=Update the active_mapping with the given keywords and values.mapping_typeNr7   )r   _change_mapping_typer4   r   r   r   r   )rB   changess   &,r;   r   ZController.update_mapping1  sm    W\\^+#88AAGA!!113!!//1((373		r>   c                s     V P                   P                  4        T P                   P                  \        P
                  ! 4       R7       T P                   P                  ! R/ \        B  R#   \         d     R# i ; i)z0Create a new empty mapping in the active_preset.N)rd   r7   )r4   create_mappingr   r`   r   Zempty_combinationr   rc   rO   rP   r;   r   ZController.create_mapping=  sh    	,,.
 	&&3C3U3U3W&X((<+;<  		s   A- -A<;A<c                s   a  R V 3R llpS P                   P                  '       g   R# S P                  P                  \	        \        R4      V4      4       R# )z1Remove the active_mapping form the active_preset.c               rD   r   r7   r8   r:   r;   r<   Z/Controller.delete_mapping.<locals>.__annotate__K  s     	 	t 	r>   c                sp   < V '       d-   SP                   P                  4        SP                  4        R # R # rH   )r4   delete_mappingr   r   r   r;   
get_answerZ-Controller.delete_mapping.<locals>.get_answerK  s&    !!002		 r>   Nz-Are you sure you want to delete this mapping?)r4   rk   r3   rb   r'   r!   )rB   r   s   f r;   r   ZController.delete_mappingH  sL    	 	
   ///##AB	
r>   c               rD   )r2   autoloadr   r7   r8   r:   r;   r<   r=   Y  s     8 8T 8r>   c                sp    V P                   P                  V4       V P                   P                  4        R# )z>Set the autoload state for the active_preset and active_group.N)r4   set_autoloadZrefresh_service_config_path)rB   r   rE   r;   r   ZController.set_autoloadY  s(    &&x0557r>   c                s     V P                   P                  4        R#   \         d5   pT P                  \        \        R4      \        T4      4        Rp?R# Rp?ii ; i)zSave all data to the disc.r   N)r4   r   r   rr   r*   r!   rv   )rB   r   r   r;   r   ZController.save^  sK    	I""$ 	IY*>(?QHH	Is    A)AAc                s  a a S P                   P                  4       pV\        P                  8X  g   V\        P                  8X  de   S P                   P                  4        S P                  P                  \        P                  4       S P                  \        \        R4      4       R# \        P                  ! R4       VV 3R loS P                  P!                  4        S P                  P#                  \        P$                  S P&                  4       S P                  P#                  \        P                  S4       S P                   P)                  4        R# )zmRecord the input of the active_group

Updates the active_mapping.input_combination with the recorded events.
z!Use "Stop" to stop before editingNzRecording Keysc                s   < SP                   P                  S4       SP                   P                  SP                  4       SP                  P	                  4        R # rH   )r3   unsubscriberg   r?   Zconnect_shortcuts)r!   on_recording_finishedrB      &r;   r   Z=Controller.start_key_recording.<locals>.on_recording_finisheds  sB    ++,AB++D,I,IJHH&&(r>   )r4   Z	get_stater-   RUNNINGZSTARTINGstop_combination_recordingr3   signalr#   Zrecording_finishedrr   r*   r!   r/   rS   r?   Zdisconnect_shortcutsrI   Zcombination_recordedrg   Zstart_combination_recording)rB   stater   s   f @r;   start_key_recordingZController.start_key_recordinge  s    
 !!++-M)))Um6L6L-L88:&&{'E'EFY*M(NO%&	)
 	%%'%%,,))	
 	%%**,A	
 	557r>   c                sf    \         P                  ! R4       V P                  P                  4        R# )zStop recording the input.zStopping Recording KeysN)r/   rS   r4   r   rO   rP   r;   stop_key_recordingZController.stop_key_recording  s!    ./446r>   c                sP   \        V P                  P                  4      ^ 8X  dA   \        P                  ! \        R4      4       V P                  \        \        R4      4       R# V P                  '       gK   V P                  P                  P                  4       '       d!   V P                  \        RR4       RV n        R# RV n        V P                  P                  \        P                  V P                  4       V P                  \        \        R4      4       V P                  P!                  4       '       gl   V P                  P#                  V P                  4       V P                  \        \        R	4      V P                  P                  P$                  ,          4       R# R# )
z.Inject the active_preset for the active_group.zCannot apply empty preset filezYou need to add mappings firstNz$This would disable your click buttonzUMap a button to BTN_LEFT to avoid this.
To overwrite this warning, press apply again.TFzStarting injection...Failed to apply preset "%s")rn   r4   rj   r/   r   r!   rr   r*   r@   dangerously_mapped_btn_leftr3   rI   r#   injector_stateshow_injector_resultr)   start_injectingr   r   rO   rP   r;   r   ZController.start_injecting  sA   t  ../14LL;<=Y*J(KL$$$  ..JJLL  :D )-% !&%%&&%%	
 	A&=$>?  0022++D,E,EF/043D3D3R3R3W3WW 3r>   c               r~   )r2   ro   r.   r5   r6   r7   r8   r:   r;   r<   r=     s     4! 4!(< 4! 4!r>   c                s:  a  S P                   P                  S P                  4       VP                  pR V 3R llpR V 3R llpS P                  P
                  '       g   Q h\        P                  V\        P                  \        S P                  \        \        R4      S P                  P
                  P                  ,          4      \        P                  V\        P                  \        S P                  \        RR4      /pW%9   d   WR,          ! 4        R# R# )	z/Show if the injection was successfully started.c               rD   rG   r7   r8   r:   r;   r<   5Controller.show_injector_result.<locals>.__annotate__  s     	 	 	r>   c                 s  < SP                   P                  f   Q h\        R4      SP                   P                  P                  ,          p SP                   P                  P	                  4       '       d   V \        R4      ,          p SP                  \        V 4       \        P                  ! RSP                   P                  P                  4       R # )NzApplied preset "%s"z, CTRL + DEL to stopzGroup "%s" is currently mapped)r4   rj   r!   r   r   rr   r)   r/   r   rR   r]   )ro   rB   s    r;   runningZ0Controller.show_injector_result.<locals>.running  s    $$22>>>)*T->->-L-L-Q-QQC  ..JJLLq/00Y,KK0$2C2C2P2P2T2Tr>   c               rD   rG   r7   r8   r:   r;   r<   r     s     	6 	6 	6r>   c                 s"  < SP                   P                  f   Q h\        R4      SP                   P                  P                  ,          p RpSP	                  4       pVe   V  RV^ ,           2p V^,          pSP                  \        W4       R # )Nr   znMaybe your preset doesn't contain anything that is sent by the device or another device is already grabbing itz. )r4   rj   r!   r   rq   rr   r*   )ro   rp   rs   rB   s      r;   no_grabZ0Controller.show_injector_result.<locals>.no_grab  s    $$22>>>/043D3D3R3R3W3WW B  !% I I K ,R 1! 456+A.Y5r>   zError applying preset "%s"zUpgrade python-evdevz%Your python-evdev version is too old.N)r3   r   r   r   r4   rj   r-   r   ZERRORr   rr   r*   r!   r   ZNO_GRABZUPGRADE_EVDEV)rB   ro   r   r   r   Zstate_callss   f&    r;   r   ZController.show_injector_result  s    ''(A(AB			 		6 	6&   .....!!7  ./$2C2C2Q2Q2V2VV"
 !!7''  &7	*6
     r>   c                s  a a R V V3R llo S P                   P                  \        P                  S4       S P                  P                  4        R#   \         d     S P                   P                  S4        R# i ; i)z/Stop injecting any preset for the active_group.c               rD   )r2   ro   r.   r7   r8   r:   r;   r<   Z/Controller.stop_injecting.<locals>.__annotate__  s     	D 	D1 	Dr>   c                s   < SP                   P                  S4       V P                  4       '       g$   \        P                  ! R V P
                  4       R# SP                  \        \        R4      4       R# )z;Expected the injection to eventually stop, but got state %sNzStopped the injection)	r3   r   Zinactiver/   r   r   rr   r)   r!   )ro   rB   show_resultr   r;   r   Z.Controller.stop_injecting.<locals>.show_result  sU    ++K8<<>> QII Y*A(BCr>   N)r3   rI   r#   r   r4   stop_injectingr   r   )rB   r   s   f@r;   r   ZController.stop_injecting  se    	D 	D	9))+*D*DkR,,." 	9++K8	9s   AA &A>=A>Nc               s$    V ^8  d   QhRRRRRR/# )r2   ctx_idZintro   r   rp   r7   r8   r:   r;   r<   r=     s-     F FF F 	Fr>   c                sP    V P                   P                  \        WV4      4       R# )z=Send a status message to the ui to show it in the status-bar.N)r3   rb   r%   )rB   r   ro   rp   s   &&&&r;   rr   ZController.show_status  s     	##JvG$DEr>   c               rD   )r2   r5   r   r7   r8   r:   r;   r<   r=     s     
 
$ 
r>   c                s    V P                   P                  \        R/ \        B 8H  ;'       g    V P                   P                  RJ # )z%Check if the active_mapping is empty.Nr7   )r4   rk   r   rc   rO   rP   r;   is_empty_mappingZController.is_empty_mapping  sD     ,,	0M<L0MM 8 8  //47	
r>   c                r   )zVReload the connected devices and send them as a groups message.

Runs asynchronously.
Nr   rO   rP   r;   r   ZController.refresh_groups  s    
 	((*r>   c                s    \         P                  ! R4       V P                  4        V P                  P	                  \
        P                  4       \         P                  ! R4       \        P                  ! 4        R# )zSafely close the application.zClosing ApplicationZQuittingN)	r/   rS   r   r3   r   r#   Z	terminater   Z	main_quitrO   rP   r;   closeZController.close  sG    *+		"";#8#89Z r>   c                sP    V P                   P                  P                  V4       R# )zFocus the given component.N)r?   Zwindow	set_focus)rB   Z	componentrE   r;   r   ZController.set_focus  s    !!),r>   c               rD   )r2   r   zDict[str, Any]r7   r8   r:   r;   r<   r=     s     S SN Sr>   c                sJ  a	 V P                   P                  pVf   V# VR,          VP                  8X  d   V# VR,          \        P                  P
                  8X  Ed}   \        R4      pVP                  '       d,   V\        R4      P                  VP                  4      ,          pVP                   Uu. uF  pVP                  '       g   K  VNK  	  up'       g   \        VP                  4      p\        V4       Fs  w  rdVP                  \        \        39   g   K"  VP!                  ^ R7      WV&   \#        V4      VR&   V\        R4      P                  VP%                  4       4      ,          p M)	  V\        R4      ,          pMVP                  '       g   V# Ro	R	 V	3R
 llpV P&                  P)                  \+        W74      4       S	'       d   RVR&   V# R# VR,          \        P,                  P
                  8X  d    \/        \1        R VP                  4      4      ^ ,          pRo	R T	3R llpT P&                  P)                  \+        RTP%                  4        R2T4      4       S	'       d   RTR&   RTR&   T# R# V# u upi   \2         d    RTR&   RTR&   Tu # i ; i)zIQuery the user to update the mapping in order to change the mapping type.Nr   z.You are about to change the mapping to analog.z+
This will remove "{}" from the text input!r   rZ   z-
The input "{}" will be used as analog input.z$
You need to record an analog input.c               rD   r2   answer_r   r7   r8   r:   r;   r<   5Controller._change_mapping_type.<locals>.__annotate__B       ! !D !r>   c                   < V oR # rH   r7   r   r   r   r;   r   3Controller._change_mapping_type.<locals>.get_answerB       r>   ry   c                s    V P                   # rH   )rx   )r   rP   r;   r\   Z1Controller._change_mapping_type.<locals>.<lambda>P  s
    Q%;%;r>   r{   Zoutput_codec               rD   r   r7   r8   r:   r;   r<   r   Y  r   r>   c                r   rH   r7   r   r   r;   r   r   Y  r   r>   zYou are about to change the mapping to a Key or Macro mapping!
Go to the advanced input configuration and set a "Trigger Threshold" for "rw   )r4   rk   r   r   ZANALOGr   r!   ry   r9   rZ   rx   r_   r   r   r   r   r   r   rz   r3   rb   r'   Z	KEY_MACROZtupleZfilterZ
IndexError)
rB   r   rN   ro   r   Zinputsr   r   Zanalog_inputr   s
   &&       @r;   r   ZController._change_mapping_type  s   ##22?N>"g&:&::N>"k&8&8&>&>>DEC$$$qJKRR))  %,$=$=$=L44 $=  -11J1J,K'0'8OA#((VV,<<$0$7$7$7$K	7G7O 34qL  &!9!9!;<=  (9 1DEEC***F! ! ''(:3(KL+/(>"k&;&;&A&AA$;W=V=VW   F! ! ''"00<0H0H0J/K2O 	 )-&)-&EP  )-&)-&s   5JJ'J J"!J")r@   r4   r?   r3   )NN)4Z__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__rC   rF   rA   rL   rJ   rK   rg   rq   rM   Zstaticmethodr}   rm   r   rT   r   re   rf   r   ra   r   r   r   r   rU   r   r   r    r   r   r`   r   r   r   r   r   r   r   r   r   r   rr   r   r   r   r   r   Z__static_attributes__r7   r>   r;   r1   r1   V   s   .
!	
,#"I -(T
 8 8t    B:	)
642*-X:..**@+.
,
2 &9 I@"5

	=
"8
I8:7
B4!l90F
+-S Sr>   r1   )GZ
__future__r    r   Z	functoolsr   Ztypingr   r   r   r   r   r   r   r	   r
   r   Zevdev.ecodesr   r   r   Zgi.repositoryr   Z"inputremapper.configs.input_configr   r   Zinputremapper.configs.mappingr   r   r   Zinputremapper.configs.pathsr   Z'inputremapper.configs.validation_errorsr   r   r   r   r   r   r   Zinputremapper.exceptionsr   Z.inputremapper.gui.components.output_type_namesr   Zinputremapper.gui.data_managerr   r    Zinputremapper.gui.gettextr!   Z)inputremapper.gui.messages.message_brokerr"   r#   Z'inputremapper.gui.messages.message_datar$   r%   r&   r'   r(   Zinputremapper.gui.utilsr)   r*   r+   r,   Z inputremapper.injection.injectorr-   r.   Zinputremapper.logging.loggerr/   Z inputremapper.gui.user_interfacer0   rc   r1   r7   r>   r;   <module>r      s   ( # 	    0 /  L 
 2   9 J K '  S R 0> $Z0 V Vr>   