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



O†bUFã@s€ddlZddlZddlZddlmZddlmZmZmZGdd„deƒZ    Gdd„de
ƒZdS)éN)Ú_uinput)ÚecodesÚutilÚdevicec@seZdZdS)ÚUInputErrorN)Ú__name__Ú
__module__Ú__qualname__©r
r
ú./usr/lib/python3/dist-packages/evdev/uinput.pyrsrc    @sÇeZdZdZd*Zddd
d
d
dddd„Zdd„Zdd„Zdd„Zdd„Z    dd„Z
dd„Zdd„Zd d!„Z
d"d#d$d%„Zd&d'„Zd(d)„ZdS)+ÚUInputzf
    A userland input device and that can inject input events into the
    linux input subsystem.
    ÚnameÚvendorÚproductÚversionÚbustypeÚeventsÚdevnodeÚfdrNzpy-evdev-uinputééz/dev/uinputc
Cs<||_||_||_||_||_||_|sTtjtjjƒi}g}|j    ƒt
j|ƒ|_xŽ|j
ƒD]€\}    }
xq|
D]i}t|tttjfƒré|dg}||d7}|j|ƒ|d}t
j|j|    |ƒq–WqƒWt
j|j||||||ƒ|jƒ|_dS)a­
        :param events: the event types and codes that the uinput
                       device will be able to inject - defaults to all
                       key codes.

        :type events: dictionary of event types mapping to lists of
                      event codes.

        :param name:    the name of the input device.
        :param vendor:  vendor identifier.
        :param product: product identifier.
        :param version: version identifier.
        :param bustype: bustype identifier.

        .. note:: If you do not specify any events, the uinput device
                  will be able to inject only ``KEY_*`` and ``BTN_*``
                  event codes.
        rrN)r
rrrrrrZEV_KEYÚkeysÚ_verifyrÚopenrÚitemsÚ
isinstanceÚtupleÚlistrZAbsInfoÚappendÚenableZcreateÚ_find_device)
Úselfrr
rrrrrÚabsinfoÚetypeZcodesÚcodeÚfr
r
rÚ__init__s*                        




"zUInput.__init__cCs|S)Nr
)r!r
r
rÚ    __enter__ZszUInput.__enter__cCst|dƒr|jƒdS)Nr)ÚhasattrÚclose)r!ÚtypeÚvalueÚtbr
r
rÚ__exit__]szUInput.__exit__cs8‡fdd†d
Dƒ}djˆjjd    j|ƒƒS)Nc3s$|]}ttˆ|ƒƒVqdS)N)ÚreprÚgetattr)Ú.0Úi)r!r
rú    <genexpr>csz"UInput.__repr__.<locals>.<genexpr>r
rrrrz{}({})z, )r
rrrr)ÚformatÚ    __class__rÚjoin)r!Úvr
)r!rÚ__repr__as
zUInput.__repr__cCsid}dd„|jdƒjƒDƒ}|j|jtj|j|j|j|j    dj
|ƒƒ}|S)NzXname "{}", bus "{}", vendor "{:04x}", product "{:04x}", version "{:04x}"
event types: {}cSsg|]}|d‘qS)rr
)r0r1r
r
rú
<listcomp>ks    z"UInput.__str__.<locals>.<listcomp>Tú )Úcapabilitiesrr3r
rZBUSrrrrr5)r!ÚmsgZevtypesr
r
rÚ__str__gs"zUInput.__str__cCsH|jdk    r|jjƒ|jdkrDtj|jƒd|_dS)Nréÿÿÿÿr=)rr)rr)r!r
r
rr)rs

zUInput.closecCs8t|dƒr|j}|j|j|j|jƒdS)aû
        Inject an input event into the input subsystem. Events are
        queued until a synchronization event is received.

        :param event: 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)
        ÚeventN)r(r>Úwriter*r$r+)r!r>r
r
rÚwrite_event|s    zUInput.write_eventcCstj|j|||ƒdS)a¹
        Inject an input event into the input subsystem. Events are
        queued until a synchronization event is received.

        :param etype: event type (eg. ``EV_KEY``).
        :param code:  event code (eg. ``KEY_A``).
        :param value: event value (eg. 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)rr?r)r!r#r$r+r
r
rr?‘szUInput.writecCs#tj|jtjtjdƒdS)zÄ
        Inject a ``SYN_REPORT`` event into the input subsystem. Events
        queued by :func:`write()` will be fired. If possible, events
        will be merged into an 'atomic' event.
        rN)rr?rrZEV_SYNZ
SYN_REPORT)r!r
r
rÚsyn¢sz
UInput.synFTcCs.|jdkrtdƒ‚|jj||ƒS)zASee :func:`capabilities <evdev.device.InputDevice.capabilities>`.Nz1input device not opened - cannot read capabilites)rrr:)r!Úverboser"r
r
rr:«szUInput.capabilitiescCsØy/tj|jƒtj}tj|ƒs.‚Wn6ttfk
rgd}t|j|jƒƒ‚YnXtj    |jtj
ƒsžd}t|j|jƒƒ‚t|jƒt
jkrÔd}t|jt
jƒƒ‚dS)zr
        Verify that an uinput device exists and is readable and writable
        by the current process.
        z_"{}" does not exist or is not a character device file - verify that the uinput module is loadedz!"{}" cannot be opened for writingz8uinput device name must not be longer than {} charactersN)ÚosÚstatrÚST_MODEÚS_ISCHRÚ
IndexErrorÚOSErrorrr3ÚaccessÚW_OKÚlenr
rZ
maxnamelen)r!Úmr;r
r
rr²szUInput._verifycCsPtjdƒx<tjdƒD]+}tj|ƒ}|j|jkr|SqWdS)Ngš™™™™™¹?z/dev/input/)ÚtimeZsleeprZlist_devicesrZInputDevicer
)r!ÚfnÚdr
r
rr És

zUInput._find_device)    r
rrrrrrrr)rrr    Ú__doc__Ú    __slots__r&r'r-r7r<r)r@r?rAr:rr r
r
r
rrs$<
    r)rCrDrMZevdevrrrrÚ    ExceptionrÚobjectrr
r
r
rÚ<module>s