legoEv3/evdev/__pycache__/device.cpython-35.pyc



ObU'@sddlZddlmZddlmZddlmZmZmZmZddl    m
Z
edddd    d
ddgZed
ddgZedddddgZ
GdddeZGdd
d
eZGddde
ZGdddeZdS)N)select)
namedtuple)_input_uinputecodesutil)
InputEventAbsInfovalueminmaxZfuzzZflatZ
resolutionKbdInforepeatZdelay
DeviceInfoZbustypeZvendorproductversionc@s"eZdZdZddZdS)r    a
    A ``namedtuple`` for storing absolut axis information -
    corresponds to the ``input_absinfo`` struct:

     **value**
        Latest reported value for the axis.

     **min**
        Specifies minimum value for the axis.

     **max**
        Specifies maximum value for the axis.

     **fuzz**
        Specifies fuzz value that is used to filter noise from the
        event stream.

     **flat**
        Values that are within this value will be discarded by joydev
        interface and reported as 0 instead.

     **resolution**
        Specifies resolution for the values reported for the axis.
        Resolution for main axes (``ABS_X, ABS_Y, ABS_Z``) is reported
        in units per millimeter (units/mm), resolution for rotational
        axes (``ABS_RX, ABS_RY, ABS_RZ``) is reported in units per
        radian.

    .. note: The input core does not clamp reported values to the
       ``[minimum, maximum]`` limits, such task is left to userspace.
    cCs
dj|S)Nz0val {}, min {}, max {}, fuzz {}, flat {}, res {})format)selfr./usr/lib/python3/dist-packages/evdev/device.py__str__2szAbsInfo.__str__N)__name__
__module____qualname____doc__rrrrrr    sc@s"eZdZdZddZdS)r
z
    Keyboard repeat rate:

    **repeat**
       Keyboard repeat rate in characters per second.

    **delay**
       Amount of time that a key must be depressed before it will start
       to repeat (in milliseconds).
    cCs
dj|S)Nzrepeat {}, delay {})r)rrrrrBszKbdInfo.__str__N)rrrrrrrrrr
6s
c@seZdZddZdS)rcCsd}|j|S)Nz:bus: {:04x}, vendor {:04x}, product {:04x}, version {:04x})r)rmsgrrrrGszDeviceInfo.__str__N)rrrrrrrrrFsc@s6eZdZdZd6Zd
dZdd
ZdddZddddZdddZ    ddZ
ddZddZddZ
ddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zed0d1Zejd2d1Zdd3d4Zd5S)7InputDevicezC
    A linux input device from which input events can be read.
    fnfdinfonamephys_rawcapabilitiesrff_effects_countcCs||_tj|tjtjB|_tj|j}t|dd|_    |d|_
|d|_tj|j|_
tj|j|_tj|j|_dS)z2
        :param dev: path to input device
        N)rosopenO_RDWR
O_NONBLOCKrrZ
ioctl_devinforrr r!Zioctl_EVIOCGVERSIONrZioctl_capabilitiesr"Zioctl_EVIOCGEFFECTSr#)rZdevZinfo_resrrr__init__Ts    

zInputDevice.__init__cCsEt|drA|jdk    rAy|jWntk
r@YnXdS)Nr)hasattrrcloseOSError)rrrr__del__ts

zInputDevice.__del__Tc    Csi}x|jjD]\}}x|D]~}|j|g}t|tr|r|d}t|}|j|d|fq|j|dq)|j|q)WqW|S)Nr)r"items
setdefault
isinstancetupler    append)    rabsinforesetypercodelairrr
_capabilities{s

zInputDevice._capabilitiesFcCs3|r"ttj|j|S|j|SdS)a
        Return the event types that this device supports as a mapping of
        supported event types to lists of handled event codes. Example::

          { 1: [272, 273, 274],
            2: [0, 1, 6, 8] }

        If ``verbose`` is ``True``, event codes and types will be resolved
        to their names. Example::

          { ('EV_KEY', 1): [('BTN_MOUSE', 272),
                            ('BTN_RIGHT', 273),
                            ('BTN_MIDDLE', 273)],
            ('EV_REL', 2): [('REL_X', 0),
                            ('REL_Y', 1),
                            ('REL_HWHEEL', 6),
                            ('REL_WHEEL', 8)] }

        Unknown codes or types will be resolved to ``'?'``.

        If ``absinfo`` is ``True``, the list of capabilities will also
        include absolute axis information in the form of
        :class:`AbsInfo` instances::

          { 3: [ (0, AbsInfo(min=0, max=255, fuzz=0, flat=0)),
                 (1, AbsInfo(min=0, max=255, fuzz=0, flat=0)) ]}

        Combined with ``verbose`` the above becomes::

          { ('EV_ABS', 3): [ (('ABS_X', 0), AbsInfo(min=0, max=255, fuzz=0, flat=0)),
                             (('ABS_Y', 1), AbsInfo(min=0, max=255, fuzz=0, flat=0)) ]}

        N)dictrZresolve_ecodesr<)rverboser5rrrcapabilitiess#zInputDevice.capabilitiescCs3tj|jtj}|r/dd|DS|S)a3
        Return currently set LED keys. For example::

          [0, 1, 8, 9]

        If ``verbose`` is ``True``, event codes are resolved to their
        names. Unknown codes are resolved to ``'?'``. For example::

          [('LED_NUML', 0), ('LED_CAPSL', 1), ('LED_MISC', 8), ('LED_MAIL', 9)]

        cSs8g|].}|tjkr(tj|nd|fqS)?)rZLED).0r9rrr
<listcomp>s    z$InputDevice.leds.<locals>.<listcomp>)rZget_sw_led_sndrrEV_LED)rr>ledsrrrrDszInputDevice.ledscCs tj|jtj||dS)z}
        Set the state of the selected LED. For example::

           device.set_led(ecodes.LED_NUML, 1)

        ..
        N)rwriterrrC)rZled_numr
rrrset_ledszInputDevice.set_ledcCs|j|jkS)zATwo devices are equal if their :data:`info` attributes are equal.)r)rotherrrr__eq__szInputDevice.__eq__cCs"d}|j|j|j|jS)Nzdevice {}, name "{}", phys "{}")rrr r!)rrrrrrszInputDevice.__str__cCs"|jj|jf}dj|S)Nz{}({!r}))    __class__rrr)rrrrr__repr__szInputDevice.__repr__cCs4|jdkr0ztj|jWdd|_XdS)Nr/rK)rr&r,)rrrrr,szInputDevice.closecCs|jS)z
        Return the file descriptor to the open event device. This
        makes it possible to pass pass ``InputDevice`` instances
        directly to :func:`select.select()` and
        :class:`asyncore.file_dispatcher`.)r)rrrrfilenoszInputDevice.filenocCs&tj|j}|r"t|SdS)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)rZdevice_readrr)reventrrrread_ones    zInputDevice.read_oneccsHxAt|jggg\}}}x|jD]}|Vq1WqWdS)z<Enter an endless ``select()`` loop that yields input events.N)rrread)rrwxrMrrr    read_loops!zInputDevice.read_loopccs2tj|j}x|D]}t|VqWdS)z
        Read multiple input events from device. Return a generator
        object that yields :class:`InputEvent
        <evdev.events.InputEvent>` instances.
        N)rZdevice_read_manyrr)rZeventsr;rrrrOs
zInputDevice.readcCstj|jddS)a2
        Grab input device using ``EVIOCGRAB`` - other applications will
        be unable to receive events until the device is released. Only
        one process can hold a ``EVIOCGRAB`` on a device.

        .. warning:: Grabbing an already grabbed device will raise an
                     ``IOError``.r/N)rioctl_EVIOCGRABr)rrrrgrabs    zInputDevice.grabcCstj|jddS)zRelease device if it has been already grabbed (uses
        `EVIOCGRAB`).

        .. warning:: Releasing an already released device will raise an
                     ``IOError('Invalid argument')``.rN)rrTr)rrrrungrabszInputDevice.ungrabcCs5tt|dd}tj|j|}|S)z:Upload a force feedback effect to a force feedback device.N)bytesbufferr
upload_effectr)rZeffectdataff_idrrrrY#szInputDevice.upload_effectcCstj|j|dS)zVErase a force effect from a force feedback device. This
        also stops the effect.N)rerase_effectr)rr[rrrr\*szInputDevice.erase_effectcCsttj|jS)zcGet or set the keyboard repeat rate (in characters per
        minute) and delay (in milliseconds).)r
rZioctl_EVIOCGREPr)rrrrr0szInputDevice.repeatcCstj|j|S)N)rZioctl_EVIOCSREPr)rr
rrrr7scCs-tj|j}|r)dd|DS|S)a
        Return currently active keys. Example::

          [1, 42]

        If ``verbose`` is ``True``, key codes are resolved to their
        verbose names. Unknown codes are resolved to ``'?'``. For
        example::

          [('KEY_ESC', 1), ('KEY_LEFTSHIFT', 42)]

        cSs8g|].}|tjkr(tj|nd|fqS)r@)rZKEY)rAkrrrrBJs    z+InputDevice.active_keys.<locals>.<listcomp>)rZioctl_EVIOCGKEYr)rr>active_keysrrrr^;s
zInputDevice.active_keysN)rrrr r!r"rr#)rrrr    __slots__r*r.r<r?rDrFrHrrJr,rLrNrSrOrUrVrYr\propertyrsetterr^rrrrrLs0 (
    
    r)r&rcollectionsrZevdevrrrrZevdev.eventsrZ_AbsInfoZ_KbdInfoZ_DeviceInfor    r
robjectrrrrr<module>s"!%