+
     iE(  c                   sD   R t ^ RIt^ RIHtHtHtHtHt ^ RIt^ RI	H
t
 ^ RIHt ^ RIHt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HtHtHtHtH t  ^ RI!H"t" ^ RI#H$t$ ^ RI%H&t& ^ RI'H(t( ^]PR                  PT                  3.t+]R]$R3,          t, ! R R4      t-R# )z^Talking to the ReaderService that has root permissions.

see gui.reader_service.ReaderService
N)OptionalList	GeneratorDictSet)GLib)InputCombination)_Groups_Group)_)MessageBroker)
GroupsDataCombinationRecorded
StatusData)MessageType)	MSG_EVENT
MSG_GROUPSCMD_TERMINATECMD_REFRESH_GROUPSCMD_STOP_READINGReaderService)	CTX_ERROR
InputEvent)Pipe)loggerc                   s   a  ] tR t^;t o Rt^tV 3R lR ltR tV 3R lR ltR t	R t
R	 tV 3R
 lR ltV 3R lR lt]V 3R lR l4       tV 3R lR ltV 3R lR ltR tR tR tV 3R lR ltV 3R ltRtV tR# )ReaderClienta/  Processes events from the reader-service for the GUI to use.

Does not serve any purpose for the injection service.

When a button was pressed, the newest keycode can be obtained from this object.
GTK has get_key for keyboard keys, but Reader also has knowledge of buttons like
the middle-mouse button.
c                s&   < V ^8  d   QhRS[ RS[/# )   message_brokergroups)r
   r   Zformat__classdict__   "D/usr/lib/python3.14/site-packages/inputremapper/gui/reader_client.py__annotate__ReaderClient.__annotate__H   s     > >} >g >    c                s    W n         Wn        R V n        R V n        V P	                  4       w  V n        V n        V P                  4        \        P                  ! ^V P                  4      V n        R # N)r   r   group_recording_generatorconnect_results_pipe_commands_pipeattach_to_eventsr   Ztimeout_add_read_read_timeout)selfr   r   s   &&&r!   __init__ZReaderClient.__init__H   sW    ,'+
BF!26,,./D/!--b$**=r$   c                s$   \         P                  ! 4       '       d   R # \        P                  ! R4       \         P                  ! 4        Rp\        \        V P                  V,          4      4       FR  pV P                  P                  4       '       d   \        P                  ! R4        R # \        P                  ! V4       KT  	  Rp\        P                  ! V4       V P                  P                  \        \         \#        V4      4      4       R # )Nz-ReaderService not running anymore, restartingg{Gz?zReaderService startedz The reader-service did not start)r   Z
is_runningr   ZinfoZpkexec_reader_serviceZrangeint_timeoutr)   polltimeZsleeperrorr   publishr   r   r	   )r.   Zpolling_periodZ__Zmsg   &   r!   ensure_reader_service_runningZ*ReaderClient.ensure_reader_service_runningU   s    ##%%CD++-
  DMMN:;<B!!&&((34JJ~& = 5CLL''
9af(EFr$   c                    < V ^8  d   QhRS[ /# )r   commandZstrr   r    r!   r"   r#   p   s     * *S *r$   c                s    V\         \        39  d   V P                  4        \        P                  ! RV4       V P
                  P                  V4       R# )z$Send a command to the ReaderService.zSending "%s" to ReaderServiceN)r   r   r7   r   debugr*   send)r.   r9      &&r!   _send_commandZReaderClient._send_commandp   s?    =*:;;..04g>  )r$   c                s    \        \        P                  ! 4       ^ ,          4      p\        \        P                  ! 4       ^,          4      pW3# )zConnect to the reader-service.)r   r   Zget_pipe_paths)r.   Zresults_pipeZcommands_pipe   &  r!   r(   ZReaderClient.connectx   s;    M88:1=>]99;A>?**r$   c                sd   a  S P                   P                  \        P                  V 3R l4       R# )z"Connect listeners to event_reader.c                 s$   < SP                  4       # r%   )	terminate)r	   r.   s   &r!   Z<lambda>Z/ReaderClient.attach_to_events.<locals>.<lambda>   s    dnn&r$   N)r   Z	subscriber   r@   r.   s   fr!   r+   ZReaderClient.attach_to_events~   s#    %%!!&	
r$   c                s(   V P                   P                  4       '       d   V P                   P                  4       p\        P                  ! RV4       VR,          pVR,          pV\
        8X  d   V P                  V4       V\        8X  g   K   V P                  e'   V P                  P                  \        R/ VB 4       K  \        P                  ! R4       K  R#   \         d+    \        P                  ! R4       T P                  4         R# i ; i)z:Read the messages from the reader-service and handle them.zreceived %stypemessagez'Got event, but recorder is not running.zRecorder finished.T )r)   r2   recvr   r;   r   _update_groupsr   r'   r<   r   r4   ZStopIterationstop_recorder)r.   rC   Zmessage_typeZmessage_bodyr6   r!   r,   ZReaderClient._read   s      %%''((--/GLL0"6?L"9-Lz)##L1y(00<1166z7QL7QR %NO  % LL!56&&(s   2C C 1DDc                   < V ^8  d   QhRR/# r   returnNrD   r   r    r!   r"   r#      s     B B Br$   c                sn   V P                   f   \        P                  ! R4       R# \        P                  ! R4       V P	                  V P                   P
                  4       V P                  4       V n        \        V P                  4       V P                  P                  \        P                  4       R# )zRecord user input.NzNo group setzStarting recorder.)r&   r   r4   r;   r>   key	_recorderr'   Znextr   signalr   Zrecording_startedrA      &r!   start_recorderZReaderClient.start_recorder   su    ::LL()*4::>>*$(NN$4!T&&'"";#@#@Ar$   c                rH   rI   rD   r   r    r!   r"   r#      s     C Ct Cr$   c                sB   \         P                  ! R4       V P                  \        4       V P                  '       d#   V P                  P                  4        RV n        M\         P                  ! R4       V P                  P                  \        P                  4       R# )zAStop recording the input.

Will send recording_finished signals.
zStopping recorder.NzNo recording generator existed)
r   r;   r>   r   r'   Zcloser   rM   r   Zrecording_finishedrA   rN   r!   rG   ZReaderClient.stop_recorder   so    
 	)*+,$$$%%++-(,D% LL9:"";#A#ABr$   c                r8   )r   eventr   r   r    r!   r"   r#      s     
 
j 
r$   c                sf    R V P                   RV P                  RV P                  RV P                  /# )rB   codeZanalog_thresholdorigin_hash)rB   rQ   valuerR   )rP   rN   r!   _input_event_to_configZ#ReaderClient._input_event_to_config   s4     EJJEJJ5,,	
 	
r$   c                r8   )r   rJ   )RecordingGeneratorr   r    r!   r"   r#      s     - -- -r$   c           
   #  s  "   \        4       p. p Rx pVP                  \        9   d   K  VP                  ^ 8X  d)    VP	                  VP
                  4       T'       g   R# KU  VP                  VP
                  4       V Uu. uF  qDP
                  NK  	  ppVP
                  V9   dg   W29  da   VP                  VP
                  4      pW2V&   V P                  P                  \        \        \        V P                  V4      4      4      4       W29  g   EK
  VP                  V4       V P                  P                  \        \        \        V P                  V4      4      4      4       EK_    \         d     EKn  i ; iu upi 5i)zGenerator which receives InputEvents.

It accumulates them into EventCombinations and sends those on the
message_broker. It will stop once all keys or inputs are released.
N)ZsetZtype_and_codeBLACKLISTED_EVENTSrS   ZremoveZinput_match_hashZKeyErrorZaddZindexr   r5   r   r   ZmaprT   Zappend)r.   ZactiveZaccumulatorrP   ZeZaccu_input_hashesZis   &      r!   rL   ZReaderClient._recorder   sL     e(* %E""&88{{aMM%"8"89 JJu--.=H I[!3!3[ I%%)::u?W &++E,B,BC!&A##++'(T-H-H+)VW '""5)##++'(T-H-H+)VW3     !JsB   :FE. F #FFA<FAF.E>9F=E>>Fc                s0   < V ^8  d   QhRS[ S[,          /# )r   r&   )r    r   r   r    r!   r"   r#      s      x/ r$   c                s    Wn         R# )z:Set the group for which input events should be read later.N)r&   )r.   r&   r=   r!   	set_groupZReaderClient.set_group   s	     
r$   c                s2   V P                  \        4       V P                  4        V P                  e(   \        P
                  ! V P                  4       RV n        V P                  P                  4       '       d   V P                  P                  4        K<  R# )zStop reading keycodes for good.N)	r>   r   rG   r-   r   Zsource_remover)   r2   rE   rA   rN   r!   r@   ZReaderClient.terminate   sp    =))t112!%D  %%''##% (r$   c                s0    V P                  \        4       R# )z,Ask the ReaderService for new device groups.N)r>   r   rA   rN   r!   refresh_groupsZReaderClient.refresh_groups  s    -.r$   c                s    V P                   P                  RR7       Uu/ uF$  pVP                  VP                  ;'       g    . bK&  	  ppV P                  P                  \        V4      4       R# u upi )zAnnounce all known groups.F)Zinclude_inputremapperN)r   ZfilterrK   Ztypesr   r5   r   )r.   r&   r   r?   r!   publish_groupsZReaderClient.publish_groups  sk     ++%+H(
H IIu{{((b(H 	 (
 	##Jv$67	(
s   "A1A1c                r8   )r   dumpr:   r   r    r!   r"   r#     s      3 r$   c                s    WP                   P                  4       8w  dM   V P                   P                  V4       \        P                  ! R \        V P                   4      4       RV n        V P                  4        R# )zReceived %d devicesTN)r   ZdumpsZloadsr   r;   Zlen_groups_updatedrY   )r.   rZ   r=   r!   rF   ZReaderClient._update_groups  sU    ;;$$&&KKd#LL.DKK0@A#'D  	r$   c                s&   < V ^8  d   Qh/ S[ ;R&   # )r   r1   )r0   r   r    r!   r"   r#   ;   s       r$   )r*   r[   r-   r'   r)   r&   r   r   N)Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r1   r/   r7   r>   r(   r+   r,   rO   rG   ZstaticmethodrT   rL   rW   r@   rX   rY   rF   Z__annotate_func__Z__static_attributes__Z__classdictcell__)r   s   @r!   r   r   ;   s      H> >G6* *+
<B BC C$ 
 
- -^ 
&/8 }  r$   r   ).r\   r3   Ztypingr    r   r   r   r   ZevdevZgi.repositoryr   Z"inputremapper.configs.input_configr   Zinputremapper.groupsr   r   Zinputremapper.gui.gettextr	   Z)inputremapper.gui.messages.message_brokerr
   Z'inputremapper.gui.messages.message_datar   r   r   Z(inputremapper.gui.messages.message_typesr   Z inputremapper.gui.reader_servicer   r   r   r   r   r   Zinputremapper.gui.utilsr   Zinputremapper.input_eventr   Zinputremapper.ipc.piper   Zinputremapper.logging.loggerr   ZecodesZBTN_TOOL_DOUBLETAPrV   rU   r   rD   r$   r!   <module>r]      s   *
  7 7   ? 0 ' C 
 A  . 0 ' /%,,99:; tZ56 f fr$   