Skip to main content

A low-level Python library to read from and write to /dev/input devices

Project description

devinput

devinput is a low-level library to read, write and manage Linux input devices with async IO support.

Overview

Listing devices

devinput.list_devices()
#  -> [<Device 'Logitech Wireless Receiver Mouse' (/dev/input/event16)>, ... 

Listing all devices with a given set of capabilities

devinput.list_capable_devices(devinput.KeyEvent.KEY_A)

# -> [<Device 'AT Translated Set 2 keyboard' (/dev/input/event3)>]

Creating a device

dev = devinput.Device("/dev/input/event6")
# =
dev = devinput.Device.from_event("event6")

Querying device capabilities

Call dev.open() first (or do this inside the with block).

dev.has_cap(devinput.EventType.EV_ABS)
dev.has_cap(devinput.AbsEvent.ABS_X)

List all capabilities of a given type

dev.capabilities.list(devinput.EventType.EV_ABS)

Get all event types supported by the device

dev.capabilities.event_types

Reading events

# ...
with dev:
    event = dev.get_event()

Polling

with dev:
    dev.poll()

Returns whether an event is available immediately or within a given timeout.

with dev:
    dev.wait()

Waits until an event is available.

Sending events

with dev:
    dev.dev.send_event(devinput.Event(devinput.KeyEvent.KEY_A,1))

Grabbing

with (dev, dev.grabbed()):
    # ...

Async

Reading events

with dev:
    await dev.get_event_async()

Polling

with dev:
    await dev.poll_async()
    await dev.wait()

Sending events

with dev:
    await dev.send_event_async(devinput.Event(...))

Examples

Check out the examples on GitHub for more complex usage.

Docs

API docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

devinput-0.0.1.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

devinput-0.0.1-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file devinput-0.0.1.tar.gz.

File metadata

  • Download URL: devinput-0.0.1.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for devinput-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9c58bd7d11b74c84c8d59f26d6210af4bd61cde7c5d763c40ce2272b369852f0
MD5 77c449ed0108863f9db710c0736dff5a
BLAKE2b-256 ae3160ab6b7ffcec9fa15014bb778e0eb9bef1ae0d2f42768f33aac6b819208e

See more details on using hashes here.

File details

Details for the file devinput-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: devinput-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for devinput-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 22fb6adcc7612b7439c9e9be7a96a2ccb4d354f1520c41bb77db2fc943085c39
MD5 52bdc36bf121a357cc2dde10e82459d0
BLAKE2b-256 7eac916e6afc951760e1f8242646f5c47a942cd743be2de0aca2a720a52c2a07

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page