
    i                         d Z ddlm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y)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))
    )Final   )	ABSEV_ABSEV_KEYEV_RELEV_SYNKEYRELSYNkeysc                   2    e Zd ZdZdZd ZdefdZd Zd Z	y)	
InputEventzA generic input event.secusectypecodevaluec                 J    || _         || _        || _        || _        || _        y Nr   )selfr   r   r   r   r   s         V/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/evdev/events.py__init__zInputEvent.__init__2   s-     	 	 	  
    returnc                 :    | j                   | j                  dz  z   S )z"Return event timestamp as a float.g    .A)r   r   r   s    r   	timestampzInputEvent.timestampB   s    xx499y011r   c                     d}|j                  | j                         | j                  | j                  | j                        S )Nz3event at {:f}, code {:02d}, type {:02d}, val {:02d})formatr   r   r   r   r   msgs     r   __str__zInputEvent.__str__F   s/    Czz$..*DIItyy$**MMr   c                     d}|j                  | 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   sD    0zz$..11488TYY		SWS\S\^b^h^hiir   N)
r'   
__module____qualname____doc__	__slots__r   floatr   r$   r(    r   r   r   r   -   s'     6I  25 2Njr   r   c                   p    e Zd ZU dZdZee   ed<   dZee   ed<   dZ	ee   ed<   dZ
dd	ed
efdZd Zd Zy)KeyEventzCAn event generated by a keyboard, button or other key-like devices.r   key_upr   key_down   key_hold)scancodekeycodekeystateeventr8   allow_unknownc                    |j                   | _        |j                  dk(  rt        j                  | _        nI|j                  dk(  rt        j                  | _        n$|j                  dk(  rt        j                  | _        	 t        |j                      | _	        || _        y# t        $ r. |r!dj                  |j                         | _	        n Y || _        yw xY w)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   r3   r   z0x{:02X}N)r   r5   r   r0   r1   r7   r4   r2   r   r6   KeyErrorr!   r8   )r   r8   r9   s      r   r   zKeyEvent.__init__X   s     #ZZ;;!$OODM[[A$--DM[[A$--DM	

+DL "'
  	)00< 
 "'
	s   B! !-CCc                     	 d| j                      }d}|j                  | j                  j	                         | j
                  | j                  |      S # t        $ r d}Y Ow xY w)N)updownholdunknownzkey event at {:f}, {} ({}), {})r7   
IndexErrorr!   r8   r   r5   r6   )r   ksr#   s      r   r$   zKeyEvent.__str__s   s\    	'6B /zz$**..0$--rRR	  	B	s   A A! A!c                 b    dj                  | j                  j                  | j                        S Nz{}({!r})r!   r&   r'   r8   r   s    r   r(   zKeyEvent.__repr__|   #      !8!8$**EEr   N)F)r'   r)   r*   r+   r1   r   int__annotations__r2   r4   r,   r   boolr   r$   r(   r.   r   r   r0   r0   O   sS    MFE#JHeCjHeCj:I'j ' '6SFr   r0   c                   ,    e Zd ZdZdZdefdZd Zd Zy)RelEventzAA relative axis event (e.g moving the mouse 5 units to the left).r8   c                     || _         y r   r8   r   r8   s     r   r   zRelEvent.__init__   	    !&
r   c                     d}|j                  | j                  j                         t        | j                  j                           S )Nzrelative axis event at {:f}, {})r!   r8   r   r   r   r"   s     r   r$   zRelEvent.__str__   2    /zz$**..0#djjoo2FGGr   c                 b    dj                  | j                  j                  | j                        S rD   rE   r   s    r   r(   zRelEvent.__repr__   rF   r   N	r'   r)   r*   r+   r,   r   r   r$   r(   r.   r   r   rK   rK      s"    KI'j 'HFr   rK   c                   ,    e Zd ZdZdZdefdZd Zd Zy)AbsEventzGAn absolute axis event (e.g the coordinates of a tap on a touchscreen).r8   c                     || _         y r   rM   rN   s     r   r   zAbsEvent.__init__   rO   r   c                     d}|j                  | j                  j                         t        | j                  j                           S )Nzabsolute axis event at {:f}, {})r!   r8   r   r   r   r"   s     r   r$   zAbsEvent.__str__   rQ   r   c                 b    dj                  | j                  j                  | j                        S rD   rE   r   s    r   r(   zAbsEvent.__repr__   rF   r   NrS   r.   r   r   rU   rU      s"    QI'j 'HFr   rU   c                   ,    e Zd ZdZdZdefdZd Zd Zy)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.
    r8   c                     || _         y r   rM   rN   s     r   r   zSynEvent.__init__   rO   r   c                     d}|j                  | j                  j                         t        | j                  j                           S )Nz!synchronization event at {:f}, {})r!   r8   r   r   r   r"   s     r   r$   zSynEvent.__str__   s2    1zz$**..0#djjoo2FGGr   c                 b    dj                  | j                  j                  | j                        S rD   rE   r   s    r   r(   zSynEvent.__repr__   rF   r   NrS   r.   r   r   rZ   rZ      s&    
 I'j 'HFr   rZ   )r   r0   rK   rZ   rU   event_factoryN)r+   typingr   ecodesr   r   r   r   r	   r
   r   r   r   r   r0   rK   rU   rZ   r^   __all__r.   r   r   <module>rb      s|   "P  L L Lj jD.F .FbF F"F F"F F. H
H
H
H	 Zr   