API Documentation

Device classes

class uhid.UHIDDevice(vid, pid, name, report_descriptor, *, bus=<Bus.USB: 3>, physical_name=None, unique_name=None, version=0, country=0, backend=<class 'uhid.PolledBlockingUHID'>)

UHID device

destroy()
Return type

None

dispatch(stop=None)
Return type

None

initialize()

Initializes the device

Subclasses can overwrite this method. There are several use cases for that, eg. delay initialization, custom initialization, etc.

Return type

None

send_input(data)
Return type

None

single_dispatch()
Return type

None

wait_for_start(delay=0.05)
Return type

None

await wait_for_start_asyncio(delay=0.05)
Return type

None

class uhid.AsyncUHIDDevice(backend, vid, pid, name, report_descriptor, bus=<Bus.USB: 3>, physical_name=None, unique_name=None, version=0, country=0)

UHID device with an async API

await destroy()
Return type

None

await dispatch()
Return type

None

await initialize()

Initializes the device

Subclasses can overwrite this method. There are several use cases for that, eg. delay initialization, custom initialization, etc.

Return type

None

classmethod await new(vid, pid, name, report_descriptor, *, bus=<Bus.USB: 3>, physical_name=None, unique_name=None, version=0, country=0, backend)
Return type

AsyncUHIDDevice

await send_input(data)
Return type

None

await single_dispatch()
Return type

None

await wait_for_start(delay=0.05)
Return type

None

IO backends

class uhid.PolledBlockingUHID

Blocking IO UHID implementation using epoll

dispatch(stop=None)
Return type

None

single_dispatch()
Return type

None

class uhid.AsyncioBlockingUHID(loop=None)

Blocking IO UHID implementation using AsyncIO readers and writers

AsyncIO will watch the UHID file descriptor and schedule read and write tasks when it is ready for those operations.

class uhid.TrioUHID(file)

Trio UHID implementation

await dispatch()
Return type

None

classmethod await new()

Async initializer

Return type

TrioUHID

await send_event(event_type, *args, **kwargs)
Return type

None

await single_dispatch()
Return type

None

Exceptions

class uhid.UHIDException

Bases: Exception

Exception triggered when interfacing with UHID

Data

class uhid.Bus(value)

Bases: enum.Enum

An enumeration.

BLUETOOTH = 5
HIL = 4
ISAPNP = 2
PCI = 1
USB = 3
VIRTUAL = 6