§
    °Êc2  ã                   óÐ   — d Z ddlmZmZmZmZmZmZmZm	Z	m
Z
  G d„ d¦  «        Z G d„ d¦  «        Z G d„ d¦  «        Z G d	„ d
¦  «        Z G d„ d¦  «        Zeeeee	ee
eiZdZdS )aY  
This module provides the :class:`InputEvent` class, which closely
resembles the ``input_event`` struct defined in ``linux/input.h``:

.. code-block:: c

    struct input_event {
        struct timeval time;
        __u16 type;
        __u16 code;
        __s32 value;
    };

This module also defines several :class:`InputEvent` sub-classes that
know more about the different types of events (key, abs, rel etc). The
:data:`event_factory` dictionary maps event types to these classes.

Assuming you use the :func:`evdev.util.categorize()` function to
categorize events according to their type, adding or replacing a class
for a specific event type becomes a matter of modifying
:data:`event_factory`.

All classes in this module have reasonable ``str()`` and ``repr()``
methods::

    >>> print(event)
    event at 1337197425.477827, code 04, type 04, val 458792
    >>> print(repr(event))
    InputEvent(1337197425L, 477827L, 4, 4, 458792L)

    >>> print(key_event)
    key event at 1337197425.477835, 28 (KEY_ENTER), up
    >>> print(repr(key_event))
    KeyEvent(InputEvent(1337197425L, 477835L, 1, 28, 0L))
é    )	ÚkeysÚKEYÚSYNÚRELÚABSÚEV_KEYÚEV_RELÚEV_ABSÚEV_SYNc                   ó.   — e Zd ZdZdZd„ Zd„ Zd„ Zd„ ZdS )Ú
InputEventzA generic input event.©ÚsecÚusecÚtypeÚcodeÚvaluec                 óL   — || _         || _        || _        || _        || _        d S ©Nr   )Úselfr   r   r   r   r   s         ú./usr/lib/python3/dist-packages/evdev/events.pyÚ__init__zInputEvent.__init__2   s1   € àˆŒð ˆŒ	ð ˆŒ	ð ˆŒ	ð ˆŒ
ˆ
ˆ
ó    c                 ó&   — | j         | j        dz  z   S )z"Return event timestamp as a float.g    €„.A)r   r   )r   s    r   Ú	timestampzInputEvent.timestampB   s   € àŒx˜4œ9 yÑ0Ñ1Ð1r   c                 óx   — d}|                      |                      ¦   «         | j        | j        | j        ¦  «        S )Nz3event at {:f}, code {:02d}, type {:02d}, val {:02d})Úformatr   r   r   r   ©ÚsÚmsgs     r   Ú__str__zInputEvent.__str__F   s-   € ØCˆØ�zŠz˜!Ÿ+š+™-œ-¨¬°´¸¼ÑAÔAÐAr   c                 ó€   — d}|                      | j        j        | j        | j        | j        | j        | j        ¦  «        S )Nz {}({!r}, {!r}, {!r}, {!r}, {!r}))r   Ú	__class__Ú__name__r   r   r   r   r   r   s     r   Ú__repr__zInputEvent.__repr__J   s<   € Ø0ˆØ�zŠz˜!œ+Ô.Øœ% ¤¨¬°´¸¼ñBô Bð 	Br   N)	r$   Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r!   r%   © r   r   r   r   -   sc   € € € € € Ø Ð à6€Iðð ð ð 2ð 2ð 2ðBð Bð BðBð Bð Bð Bð Br   r   c                   ó6   — e Zd ZdZdZdZdZdZdd„Zd„ Z	d	„ Z
d
S )ÚKeyEventzCAn event generated by a keyboard, button or other key-like devices.r   é   é   )ÚscancodeÚkeycodeÚkeystateÚeventFc                 óp  — |j         | _        |j        dk    rt          j        | _        n9|j        dk    rt          j        | _        n|j        dk    rt          j        | _        	 t          |j                  | _	        n3# t          $ r& |r d                     |j         ¦  «        | _	        n‚ Y nw xY w|| _        dS )a  
        The ``allow_unknown`` argument determines what to do in the event of an event code
        for which a key code cannot be found. If ``False`` a ``KeyError`` will be raised.
        If ``True`` the keycode will be set to the hex value of the event code.
        r   r.   r-   z0x{:02X}N)r   r/   r   r,   Úkey_upr1   Úkey_holdÚkey_downr   r0   ÚKeyErrorr   r2   )r   r2   Úallow_unknowns      r   r   zKeyEvent.__init__Y   s½   € ð œ
ˆŒàŒ;˜!ÒÐÝ$œOˆDŒMˆMØŒ[˜AÒÐÝ$Ô-ˆDŒMˆMØŒ[˜AÒÐÝ$Ô-ˆDŒMð	Ý ¤
Ô+ˆDŒLˆLøÝð 	ð 	ð 	Øð Ø)×0Ò0°´Ñ<Ô<�”�àð �ð	øøøð ˆŒ
ˆ
ˆ
s   Á$A< Á<-B,Â+B,c                 óº   — 	 d| j                  }n# t          $ r d}Y nw xY wd}|                     | j                             ¦   «         | j        | j        |¦  «        S )N)ÚupÚdownÚholdÚunknownzkey event at {:f}, {} ({}), {})r1   Ú
IndexErrorr   r2   r   r/   r0   )r   Úksr    s      r   r!   zKeyEvent.__str__t   sq   € ð	Ø'¨¬Ô6ˆBˆBøÝð 	ð 	ð 	ØˆBˆBˆBð	øøøð /ˆØ�zŠz˜$œ*×.Ò.Ñ0Ô0Øœ-¨¬°rñ;ô ;ð 	;s   ‚ �žc                 óL   — d                      | j        j        | j        ¦  «        S ©Nz{}({!r})©r   r#   r$   r2   ©r   s    r   r%   zKeyEvent.__repr__~   ó   € Ø× Ò  ¤Ô!5°q´wÑ?Ô?Ð?r   N)F)r$   r&   r'   r(   r4   r6   r5   r)   r   r!   r%   r*   r   r   r,   r,   P   se   € € € € € ØMÐMà€FØ€HØ€Hà:€Iðð ð ð ð6;ð ;ð ;ð@ð @ð @ð @ð @r   r,   c                   ó(   — e Zd ZdZdZd„ Zd„ Zd„ ZdS )ÚRelEventzAA relative axis event (e.g moving the mouse 5 units to the left).r2   c                 ó   — || _         d S r   ©r2   ©r   r2   s     r   r   zRelEvent.__init__‡   ó   € àˆŒ
ˆ
ˆ
r   c                 óŠ   — d}|                      | j                             ¦   «         t          | j        j                 ¦  «        S )Nzrelative axis event at {:f}, {})r   r2   r   r   r   ©r   r    s     r   r!   zRelEvent.__str__‹   ó2   € Ø/ˆØ�zŠz˜$œ*×.Ò.Ñ0Ô0µ#°d´j´oÔ2FÑGÔGÐGr   c                 óL   — d                      | j        j        | j        ¦  «        S rA   rB   rC   s    r   r%   zRelEvent.__repr__�   rD   r   N©r$   r&   r'   r(   r)   r   r!   r%   r*   r   r   rF   rF   ‚   sT   € € € € € ØKÐKà€Iðð ð ðHð Hð Hð@ð @ð @ð @ð @r   rF   c                   ó(   — e Zd ZdZdZd„ Zd„ Zd„ ZdS )ÚAbsEventzGAn absolute axis event (e.g the coordinates of a tap on a touchscreen).r2   c                 ó   — || _         d S r   rH   rI   s     r   r   zAbsEvent.__init__˜   rJ   r   c                 óŠ   — d}|                      | j                             ¦   «         t          | j        j                 ¦  «        S )Nzabsolute axis event at {:f}, {})r   r2   r   r   r   rL   s     r   r!   zAbsEvent.__str__œ   rM   r   c                 óL   — d                      | j        j        | j        ¦  «        S rA   rB   rC   s    r   r%   zAbsEvent.__repr__    rD   r   NrO   r*   r   r   rQ   rQ   “   sT   € € € € € ØQÐQà€Iðð ð ðHð Hð Hð@ð @ð @ð @ð @r   rQ   c                   ó(   — e Zd ZdZdZd„ Zd„ Zd„ ZdS )ÚSynEventz�
    A synchronization event. Used as markers to separate events. Events may be
    separated in time or in space, such as with the multitouch protocol.
    r2   c                 ó   — || _         d S r   rH   rI   s     r   r   zSynEvent.__init__¬   rJ   r   c                 óŠ   — d}|                      | j                             ¦   «         t          | j        j                 ¦  «        S )Nz!synchronization event at {:f}, {})r   r2   r   r   r   rL   s     r   r!   zSynEvent.__str__°   s2   € Ø1ˆØ�zŠz˜$œ*×.Ò.Ñ0Ô0µ#°d´j´oÔ2FÑGÔGÐGr   c                 óL   — d                      | j        j        | j        ¦  «        S rA   rB   rC   s    r   r%   zSynEvent.__repr__´   rD   r   NrO   r*   r   r   rV   rV   ¤   sZ   € € € € € ðð ð
 €Iðð ð ðHð Hð Hð@ð @ð @ð @ð @r   rV   )r   r,   rF   rV   rQ   Úevent_factoryN)r(   Úevdev.ecodesr   r   r   r   r   r   r	   r
   r   r   r,   rF   rQ   rV   rZ   Ú__all__r*   r   r   ú<module>r]      so  ðð"ð "ðN RÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ Qð Bð  Bð  Bð  Bð  Bñ  Bô  Bð  BðF/@ð /@ð /@ð /@ð /@ñ /@ô /@ð /@ðd@ð @ð @ð @ð @ñ @ô @ð @ð"@ð @ð @ð @ð @ñ @ô @ð @ð"@ð @ð @ð @ð @ñ @ô @ð @ð. ˆHØ
ˆHØ
ˆHØ
ˆHð	€ð(€€€r   