snegg.ei module

Wrapper module around the libei C library. This is a thin API wrapper with most of the semantics of the underlying C library preserved. See the libei documentation for details on each API.

Warning

Most objects in this module are refcounted and automatically destroy the underlying C object when the Python reference is dropped. This may cause all sub-objects in the underlying C object to be destroyed as well. Care must be taken to preserve the Python object across multiple invocations.

class snegg.ei.ButtonEvent(button: int, is_press: bool)

Bases: object

button: int
is_press: bool
class snegg.ei.Context(cobject)

Bases: CObjectWrapper

Represents a libei context. Use Sender or Receiver to create a context.

Logging of the libei context is hooked into Python’s logging module as the ei logger.

Warning

This context is refcounted and automatically destroys the underlying C object when the reference is dropped. This may cause all sub-objects in the underlying C object to be destroyed.

dispatch() None
property events: Iterator[Event]
property fd: int
property name: str
property now: int
set_fd(fd: IO) Context
set_name(name: str) Context
set_socket(path: Optional[Path]) Context
class snegg.ei.Device(cobj)

Bases: CObjectWrapper

button_button(button: int, is_press: bool) Device
property capabilities: tuple[snegg.ei.DeviceCapability]
close()
property device_type: DeviceType
frame(timestamp: Optional[int] = None) Device
property height: int
keyboard_key(key: int, is_press: bool) Device
property name: str
pointer_motion(x: float, y: float) Device
pointer_motion_absolute(x: float, y: float) Device
property regions: tuple[snegg.ei.Region]
property seat: Seat
start_emulating(sequence: Optional[int] = None) Device
stop_emulating() Device
touch_new() Touch
property width: int
class snegg.ei.DeviceCapability(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntFlag

BUTTON = 32
KEYBOARD = 4
POINTER = 1
POINTER_ABSOLUTE = 2
SCROLL = 16
TOUCH = 8
static all() int
class snegg.ei.DeviceType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntEnum

PHYSICAL = 2
VIRTUAL = 1
exception snegg.ei.Error(message: str, errno: Optional[int] = None)

Bases: Exception

class snegg.ei.Event(cobj)

Bases: CObjectWrapper

property button_event: ButtonEvent
property device: Optional[Device]
property emulating_sequence: int
property event_type: EventType
property key_event: KeyEvent
property keyboard_xkb_modifiers: XkbModifiersEvent
property pointer_absolute_event: PointerAbsoluteEvent
property pointer_event: PointerEvent
property scroll_discrete_event: ScrollDiscreteEvent
property scroll_event: ScrollEvent
property scroll_stop_event: ScrollStopEvent
property seat: Optional[Seat]
property time: int
property touch_event: TouchEvent
class snegg.ei.EventType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntEnum

BUTTON_BUTTON = 500
CONNECT = 1
DEVICE_ADDED = 5
DEVICE_PAUSED = 7
DEVICE_REMOVED = 6
DEVICE_RESUMED = 8
DEVICE_START_EMULATING = 200
DEVICE_STOP_EMULATING = 201
DISCONNECT = 2
FRAME = 100
KEYBOARD_KEY = 700
KEYBOARD_MODIFIERS = 9
POINTER_MOTION = 300
POINTER_MOTION_ABSOLUTE = 400
SCROLL_CANCEL = 602
SCROLL_DELTA = 600
SCROLL_DISCRETE = 603
SCROLL_STOP = 601
SEAT_ADDED = 3
SEAT_REMOVED = 4
TOUCH_DOWN = 800
TOUCH_MOTION = 802
TOUCH_UP = 801
class snegg.ei.KeyEvent(key: int, is_press: bool)

Bases: object

is_press: bool
key: int
class snegg.ei.Keymap(cobj)

Bases: CObjectWrapper

property device: Device
property fd: IO
property keymap_type: KeymapType
property size: int
class snegg.ei.KeymapType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntEnum

XKB = 1
class snegg.ei.PointerAbsoluteEvent(x: float, y: float)

Bases: object

x: float
y: float
class snegg.ei.PointerEvent(dx: float, dy: float)

Bases: object

dx: float
dy: float
class snegg.ei.Receiver

Bases: Context

classmethod create_for_fd(fd: IO, name: Optional[str] = None)
classmethod create_for_socket(path: Optional[Path], name: Optional[str] = None)
class snegg.ei.Region(cobj)

Bases: CObjectWrapper

contains(x: float, y: float) bool
convert(x: float, y: float) bool
property dimension: tuple[int, int]
property physical_scale: float
property position: tuple[int, int]
class snegg.ei.ScrollDiscreteEvent(dx: int, dy: int)

Bases: object

dx: int
dy: int
class snegg.ei.ScrollEvent(dx: float, dy: float)

Bases: object

dx: float
dy: float
class snegg.ei.ScrollStopEvent(x: bool, y: bool)

Bases: object

x: bool
y: bool
class snegg.ei.Seat(cobj)

Bases: CObjectWrapper

bind(capabilities: tuple[snegg.ei.DeviceCapability])
property capabilities: tuple[snegg.ei.DeviceCapability, ...]
property name: str
unbind(capabilities: tuple[snegg.ei.DeviceCapability])
class snegg.ei.Sender

Bases: Context

classmethod create_for_fd(fd: IO, name: Optional[str] = None)
classmethod create_for_socket(path: Optional[Path], name: Optional[str] = None)
class snegg.ei.Touch(cobj)

Bases: CObjectWrapper

property device: Device
down(x: float, y: float) Device
motion(x: float, y: float) Device
up() Device
class snegg.ei.TouchEvent(touchid: int, x: float, y: float)

Bases: object

touchid: int
x: float
y: float
class snegg.ei.XkbModifiersEvent(depressed: int, latched: int, locked: int, group: int)

Bases: object

depressed: int
group: int
latched: int
locked: int