§
    °Êcq  ã                   ó€   — d dl Z d dlZd dlZd dlZd dlmZmZmZmZ d dl	m
Z
  G d„ de¦  «        Z G d„ d¦  «        ZdS )é    N)Ú_inputÚ_uinputÚecodesÚutil)Ú
InputEventc                   ó   — e Zd ZdS )Ú
EvdevErrorN)Ú__name__Ú
__module__Ú__qualname__© ó    ú//usr/lib/python3/dist-packages/evdev/eventio.pyr	   r	      s   € € € € € Ø€Dr   r	   c                   óR   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	ed„ ¦   «         Z
d	„ Zd
S )ÚEventIOaÎ  
    Base class for reading and writing input events.

    This class is used by :class:`InputDevice` and :class:`UInput`.

    - On, :class:`InputDevice` it used for reading user-generated events (e.g.
      key presses, mouse movements) and writing feedback events (e.g. leds,
      beeps).

    - On, :class:`UInput` it used for writing user-generated events (e.g.
      key presses, mouse movements) and reading feedback events (e.g. leds,
      beeps).
    c                 ó   — | j         S )zÊ
        Return the file descriptor to the open event device. This makes
        it possible to pass instances directly to :func:`select.select()` and
        :class:`asyncore.file_dispatcher`.
        )Úfd©Úselfs    r   ÚfilenozEventIO.fileno   s   € ð Œwˆr   c              #   ó€   K  — 	 t          j         | j        gg g ¦  «        \  }}}|                      ¦   «         D ]}|V — ŒŒ<)zY
        Enter an endless :func:`select.select()` loop that yields input events.
        )Úselectr   Úread)r   ÚrÚwÚxÚevents        r   Ú	read_loopzEventIO.read_loop'   sO   è è € ð
	Ý”m T¤W I¨r°2Ñ6Ô6‰GˆAˆq�!ØŸš™œð ð �Ø����ð	r   c                 óN   — t          j        | j        ¦  «        }|r	t          |Ž S dS )z¾
        Read and return a single input event as an instance of
        :class:`InputEvent <evdev.events.InputEvent>`.

        Return ``None`` if there are no pending input events.
        N)r   Údevice_readr   r   ©r   r   s     r   Úread_onezEventIO.read_one1   s3   € õ Ô" 4¤7Ñ+Ô+ˆàð 	&Ý˜uÐ%Ð%ð	&ð 	&r   c              #   ó\   K  — t          j        | j        ¦  «        }|D ]}t          |Ž V — ŒdS )zñ
        Read multiple input events from device. Return a generator object that
        yields :class:`InputEvent <evdev.events.InputEvent>` instances. Raises
        `BlockingIOError` if there are no available events at the moment.
        N)r   Údevice_read_manyr   r   )r   Úeventsr   s      r   r   zEventIO.read?   sG   è è € õ Ô(¨¬Ñ1Ô1ˆàð 	%ð 	%ˆEÝ˜eÐ$Ð$Ð$Ð$Ð$ð	%ð 	%r   c                 óF   ‡ — t          j        ‰ ¦  «        ˆ fd„¦   «         }|S )zt
        Decorator that raises :class:`EvdevError` if there is no write access to the
        input device.
        c                  ó¾   •— | d         j         }t          j        |t          j        ¦  «        t          j        z  r ‰| Ž S d| d         j        z  }t          |¦  «        ‚)Nr   zno write access to device "%s")r   ÚfcntlÚF_GETFLÚosÚO_RDWRÚpathr	   )Úargsr   ÚmsgÚfuncs      €r   Úwrapperz#EventIO.need_write.<locals>.wrapperQ   sS   ø€ à�a””ˆBÝŒ{˜2�uœ}Ñ-Ô-µ´	Ñ9ð #Ø�t˜T�{Ð"Ø2°T¸!´W´\ÑAˆCÝ˜S‘/”/Ð!r   )Ú	functoolsÚwraps)r/   r0   s   ` r   Ú
need_writezEventIO.need_writeL   s:   ø€ õ
 
Œ˜Ñ	Ô	ð	"ð 	"ð 	"ð 	"ñ 
Ô	ð	"ð ˆr   c                 ó€   — t          |d¦  «        r|j        }|                      |j        |j        |j        ¦  «         dS )a  
        Inject an input event into the input subsystem. Events are
        queued until a synchronization event is received.

        Arguments
        ---------
        event: InputEvent
          InputEvent instance or an object with an ``event`` attribute
          (:class:`KeyEvent <evdev.events.KeyEvent>`, :class:`RelEvent
          <evdev.events.RelEvent>` etc).

        Example
        -------
        >>> ev = InputEvent(1334414993, 274296, ecodes.EV_KEY, ecodes.KEY_A, 1)
        >>> ui.write_event(ev)
        r   N)Úhasattrr   ÚwriteÚtypeÚcodeÚvaluer!   s     r   Úwrite_eventzEventIO.write_eventZ   s?   € õ$ �5˜'Ñ"Ô"ð 	 Ø”KˆEà�
Š
�5”:˜uœz¨5¬;Ñ7Ô7Ð7Ð7Ð7r   c                 ó>   — t          j        | j        |||¦  «         dS )aö  
        Inject an input event into the input subsystem. Events are
        queued until a synchronization event is received.

        Arguments
        ---------
        etype
          event type (e.g. ``EV_KEY``).

        code
          event code (e.g. ``KEY_A``).

        value
          event value (e.g. 0 1 2 - depends on event type).

        Example
        ---------
        >>> ui.write(e.EV_KEY, e.KEY_A, 1) # key A - down
        >>> ui.write(e.EV_KEY, e.KEY_A, 0) # key A - up
        N)r   r6   r   )r   Úetyper8   r9   s       r   r6   zEventIO.writeq   s"   € õ. 	Œ�d”g˜u d¨EÑ2Ô2Ð2Ð2Ð2r   c                 ó   — d S )Nr   r   s    r   ÚclosezEventIO.closeŠ   s   € Øˆr   N)r
   r   r   Ú__doc__r   r   r"   r   r3   r:   r6   r>   r   r   r   r   r      s¢   € € € € € ðð ðð ð ðð ð ð&ð &ð &ð%ð %ð %ðð ð ð8ð 8ð 8ð. ð3ð 3ñ „Zð3ð0ð ð ð ð r   r   )r*   r(   r   r1   Úevdevr   r   r   r   Úevdev.eventsr   Ú	Exceptionr	   r   r   r   r   ú<module>rC      sÊ   ðð 
€	€	€	Ø €€€Ø €€€Ø Ð Ð Ð à /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ø #Ð #Ð #Ð #Ð #Ð #ð	ð 	ð 	ð 	ð 	�ñ 	ô 	ð 	ð{ð {ð {ð {ð {ñ {ô {ð {ð {ð {r   