Ë
     oÞZž,  ã                   óæ   — d dl Z d dlmZ ddlmZ d dlZe G d„ d«      «       Z G d„ de«      Z G d	„ d
e«      Z G d„ de«      Z	dd„Z
d„ Zd„ Ze j                  j                  d«      s e«        yy)é    N)Útotal_orderingé   )ÚLibevdevc                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)ÚEvdevBitaë  
    Base class representing an evdev bit, comprised of a name and a value.
    These two properties are guaranteed to exist on anything describing an
    event code, event type or input property that comes out of libevdev::

        >>> print(libevdev.EV_ABS.name)
        EV_ABS
        >>> print(libevdev.EV_ABS.value)
        3
        >>> print(libevdev.EV_SYN.SYN_REPORT.name)
        SYN_REPORT
        >>> print(libevdev.EV_SYN.SYN_REPORT.value)
        0
        >>> print(libevdev.INPUT_PROP_DIRECT.name)
        INPUT_PROP_DIRECT
        >>> print(libevdev.INPUT_PROP_DIRECT.value)
        1

    .. attribute:: value

        The numeric value of the event code

    .. attribute:: name

        The string name of this event code
    c                 óN   — dj                  | j                  | j                  «      S )Nz{}:{})ÚformatÚnameÚvalue)Úselfs    ú0/usr/lib/python3/dist-packages/libevdev/const.pyÚ__repr__zEvdevBit.__repr__;   s   € Ø�~‰~˜dŸi™i¨¯©Ó4Ð4ó    c                 ó4   — | j                   |j                   k(  S ©N©r   ©r   Úothers     r   Ú__eq__zEvdevBit.__eq__>   s   € Ø�z‰z˜UŸ[™[Ñ(Ð(r   c                 ó4   — | j                   |j                   k  S r   r   r   s     r   Ú__lt__zEvdevBit.__lt__A   s   € Ø�z‰z˜EŸK™KÑ'Ð'r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   © r   r   r   r      s   „ ñò65ò)ó(r   r   c                   ó.   — e Zd ZdZej
                  Zd„ Zy)Ú	EventCodea,  
    .. warning ::

        Do not instantiate an object of this class, all objects you'll ever need
        are already present in the libevdev namespace. Use :func:`evbit()`
        to get an :class:`EventCode` from numerical or string values.

    A class representing an evdev event code, e.g. libevdev.EV_ABS.ABS_X.
    To use a :class:`EventCode`, use the namespaced name directly::

        >>> print(libevdev.EV_ABS.ABS_X)
        ABS_X:0
        >>> print(libevdev.EV_ABS.ABS_Y)
        ABS_X:1
        >>> code = libevdev.EV_REL.REL_X
        >>> print(code.type)
        EV_REL:2

    .. attribute:: value

        The numeric value of the event code

    .. attribute:: name

        The string name of this event code

    .. attribute:: type

        The :class:`EventType` for this event code
    c                 óŒ   — t        |t        «      sy| j                  |j                  k(  xr | j                  |j                  k(  S )NF)Ú
isinstancer   r   Útyper   s     r   r   zEventCode.__eq__f   s4   € Ü˜%¤Ô+Øà�z‰z˜UŸ[™[Ñ(ÒD¨T¯Y©Y¸%¿*¹*Ñ-DÐDr   N©r   r   r   r   ÚsuperÚ__hash__r   r   r   r   r   r   E   s   „ ñð< �~‰~€HóEr   r   c                   ó.   — e Zd ZdZej
                  Zd„ Zy)Ú	EventTypea  
    .. warning ::

        Do not instantiate an object of this class, all objects you'll ever need
        are already present in the libevdev namespace. Use :func:`evbit()`
        to get an :class:`EventType` from numerical or string values.

    A class represending an evdev event type (e.g. EV_ABS). All event codes
    within this type are available as class constants::

        >>> print(libevdev.EV_ABS)
        EV_ABS:3
        >>> print(libevdev.EV_ABS.ABS_X)
        ABS_X:0
        >>> print(libevdev.EV_ABS.max)
        63
        >>> print(libevdev.EV_ABS.ABS_MAX)
        63
        >>> for code in libevdev.EV_ABS.codes[:3]:
        ...     print(code)
        ...
        ABS_X:0
        ABS_Y:1
        ABS_Z:2

    .. attribute:: value

        The numeric value of the event type

    .. attribute:: name

        The string name of this event type

    .. attribute:: codes

        A list of :class:`EventCode` objects for this type

    .. attribute:: max

        The maximum event code permitted in this type as integer
    c                 óX   — t        |t        «      sJ ‚| j                  |j                  k(  S r   )r    r&   r   r   s     r   r   zEventType.__eq__™   s%   € Ü˜%¤Ô+Ð+Ð+Ø�z‰z˜UŸ[™[Ñ(Ð(r   Nr"   r   r   r   r&   r&   m   s   „ ñ(ðR �~‰~€Hó)r   r&   c                   ó.   — e Zd ZdZej
                  Zd„ Zy)ÚInputPropertya  
    .. warning ::

        Do not instantiate an object of this class, all objects you'll ever need
        are already present in the libevdev namespace. Use :func:`propbit()`
        to get an :class:`InputProperty` from numerical or string values.

    A class representing an evdev input property::

        >>> print(libevdev.INPUT_PROP_DIRECT)
        INPUT_PROP_DIRECT:1


    .. attribute:: value

        The numeric value of the property

    .. attribute:: name

        The string name of this property
    c                 óX   — t        |t        «      sJ ‚| j                  |j                  k(  S r   )r    r)   r   r   s     r   r   zInputProperty.__eq__¶   s%   € Ü˜%¤Ô/Ð/Ð/Ø�z‰z˜UŸ[™[Ñ(Ð(r   Nr"   r   r   r   r)   r)   ž   s   „ ñð* �~‰~€Hó)r   r)   c                 ó¨  — d}t         j                  D ]$  }|j                  | k(  s|j                  | k(  sŒ"|} n |€\t	        | t
        «      rL| j                  d«      s;t         j                  D ](  }|j                  D ]  }|j                  | k(  sŒ|c c S  Œ* |�|€|S d}|j                  D ]#  }|j                  |k(  s|j                  |k(  sŒ"|}Œ% |S )a—  
    Takes an event type and an (optional) event code and returns the Enum
    representing that type or code, whichever applies. For example::

        >>> print(libevdev.evbit(0))
        EV_SYN:0

        >>> print(libevdev.evbit(2))
        EV_REL:2

        >>> print(libevdev.evbit(2, 1))
        REL_Y:1

        >>> print(libevdev.evbit(3, 4))
        ABS_RY:4

        >>> print(libevdev.evbit('EV_ABS'))
        EV_ABS:3

        >>> print(libevdev.evbit('EV_ABS', 'ABS_X'))
        ABS_X:0

    A special case is the lookup of an string-based event code without
    the type. Where the string identifier is unique, this will return the
    right value.

        >>> print(libevdev.evbit('ABS_X'))
        ABS_X:0

    The return value can be used in the libevdev API wherever an
    :class:`EventCode` or :class:`EventType` is expected.

    Notable behavior for invalid types or names:

    * If the type does not exist, this function returns None
    * If the type exists but the event code's numeric value does not have a
      symbolic name (and is within the allowed max of the type), this
      function returns a valid event code
    * If the code is outside the allowed maximum for the given type, this
      function returns None
    * If the type name exists but the string value is not a code name, this
      function returns None

    Examples for the above behaviour::

        >>> print(libevdev.evbit(8))
        None
        >>> print(libevdev.evbit('INVALID'))
        None
        >>> print(libevdev.evbit('EV_ABS', 62))
        ABS_3E:62
        >>> print(libevdev.evbit('EV_ABS', 5000))
        None
        >>> print(libevdev.evbit('EV_ABS', 'INVALID'))
        None

    :param evtype: the numeric value or string identifying the event type
    :param evcode: the numeric value or string identifying the event code
    :return: An event code value representing the code
    :rtype: EventCode or EventType
    NÚEV_)ÚlibevdevÚtypesr   r
   r    ÚstrÚ
startswithÚcodes)ÚevtypeÚevcodeÚetypeÚtÚcÚecodes         r   Úevbitr8   »   sÛ   € ð| €EÜ�^‰^ò ˆØ�7‰7�fÒ §¡¨&Ó 0ØˆEÙðð
 €~œ* V¬SÔ1¸&×:KÑ:KÈEÔ:RÜ—‘ò 	ˆAØ—W‘Wò �Ø—6‘6˜VÓ#Ø”Hñð	ð
 €}˜˜Øˆà€EØ�[‰[ò ˆØ�7‰7�fÒ §¡¨&Ó 0Ø‰Eðð €Lr   c                 ó¬   — 	 t         j                  D �cg c]#  }|j                  | k(  s|j                  | k(  sŒ"|‘Œ% c}d   S c c}w # t        $ r Y yw xY w)a'  
    Takes a property value and returns the :class:`InputProperty`
    representing that property::

        >>> print(libevdev.propbit(0))
        INPUT_PROP_POINTER:0
        >>> print(libevdev.propbit('INPUT_PROP_POINTER'))
        INPUT_PROP_POINTER:0
        >>> print(libevdev.propbit(1000))
        None
        >>> print(libevdev.propbit('Invalid'))
        None

    :param prop: the numeric value or string identifying the property
    :return: the converted :class:`InputProperty` or None if it does not exist
    :rtype: InputProperty
    r   N)r-   Úpropsr   r
   Ú
IndexError)ÚpropÚps     r   Úpropbitr>     sK   € ð$Ü#Ÿ>™>ÖO�a¨Q¯W©W¸ª_ÀÇÁÈ$Ã’ÒOÐPQÑRÐRùÒOøÜò Ùðús&   ‚A ”#A¸A¼A ÁA Á	AÁAc            
      óÐ  — t        «        t        j                  d«      } | €J ‚g }t        | dz   «      D �]	  }t        j                  |«      }|€Œt        j                  |«      }t        |t        f|||dœ«      } |«       }t        t        ||«       |j                  |«       |€t        |dg «       Œ€g }t        |dz   «      D ]j  }t        j                  ||«      }	|	€dj                  |dd |«      }	t        |	t        f||	|dœ«      } |«       }
t        ||	|
«       |j                  |
«       Œl t        |d|«       �Œ t        t        d	|«       t        j                  d
«      }|€J ‚g }t        |dz   «      D ]X  }t        j                  |«      }|€Œt        |t        f||dœ«      } |«       }t        t        ||«       |j                  |«       ŒZ t        t        d|«       y)a]  
    Loads all event type, code and property names and makes them available
    as enums in the module. Use as e.g. libevdev.EV_SYN.SYN_REPORT.

    Available are::

    libevdev.types ... an list containing all event types, e.g.
                         libevdev.EV_TYPES.EV_REL

    libevdev.EV_REL ... an enum containing all REL event types, e.g.
                        libevdev.EV_REL.REL_X. The name of each enum value
                        is the string of the code ('REL_X'), the value is the integer
                        value of that code.

    libevdev.EV_ABS ... as above, but for EV_ABS

    libevdev.EV_BITS ... libevdev.EV_FOO as an enum

    Special attributes are (an apply to all EV_foo enums):
        libevdev.EV_REL.type ... the EV_TYPES entry of the event type
        libevdev.EV_REL.max  ... the maximum code in this event type
    ÚEV_MAXNr   )r   r
   Úmaxr1   z	{}_{:02X}é   )r!   r
   r   r.   ÚINPUT_PROP_MAX)r   r
   r:   )r   Úevent_to_valueÚrangeÚevent_to_nameÚtype_maxr!   r&   Úsetattrr-   Úappendr	   r   Úproperty_to_valueÚproperty_to_namer)   )Útmaxr.   r5   ÚtnameÚcmaxÚ	new_classÚtype_objectr1   r6   ÚcnameÚcode_objectÚpmaxr:   r=   ÚpnameÚprop_objects                   r   Ú_load_constsrV   (  s  € ô. „Jä×"Ñ" 8Ó,€DØÐÐÐà€Eä�4˜!‘8‹_ó %-ˆÜ×&Ñ& qÓ)ˆØˆ=Øä× Ñ  Ó#ˆä˜¤ Ø#$Ø"'Ø!%ñ'ó(ˆ	ñ
  “kˆä”˜% Ô-Ø�‰�[Ô!àˆ<Ü�K ¨"Ô-ØàˆÜ�t˜a‘x“ò 	&ˆAÜ×*Ñ*¨1¨aÓ0ˆEð ˆ}Ø#×*Ñ*¨5°°¨9°aÓ8�ä˜U¤Y MØ&1Ø&+Ø'(ñ*ó+ˆIñ $›+ˆKÜ�K ¨Ô4Ø�L‰L˜Õ%ð	&ô 	�˜W eÖ,ðK%-ôP ŒH�g˜uÔ%ä×%Ñ%Ð&6Ó7€DØÐÐÐØ€EÜ�4˜!‘8‹_ò "ˆÜ×)Ñ)¨!Ó,ˆØˆ=Øä˜¤Ð 1Ø#$Ø"'ñ)ó*ˆ	ñ  “kˆä”˜% Ô-Ø�‰�[Õ!ð"ô ŒH�g˜uÕ%r   ÚREADTHEDOCSr   )ÚosÚ	functoolsr   Ú_clibr   r-   r   r   r&   r)   r8   r>   rV   ÚenvironÚgetr   r   r   ú<module>r]      s„   ðó. 
Ý $å Û ð ÷#(ð #(ó ð#(ôL%E�ô %EôP.)�ô .)ôb)�Hô )ó:Ròjò0X&ðv 
‡z�z‡~�~�mÔ$Ù…Nð %r   