You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 21, 2024. It is now read-only.
I had a read through the docs in regards to the API and I'll summarise the various comments here, easier than filing a million separate issues :)
The main issue is that, right now, the Python API is a C API in the Python language. That's not the same as a real Python API and there's lot for improvement. Implementation-wise what I did in libevdev-python was have an internal class that matches the C API (like you already have) but have the public API be a hand-written one that wraps the C wrapper.
Anyway, here's a list of comments regarding the current API:
BaseEvent shouldn't be visible if it's not to be used, but ....
Event should be the equiv to what BaseEvent is right now
Event.get_device() should be a read-only device property. This applies to almost all get_... functions in the events, they should be properties.
Event.get_pointer_event() shouldn't exist. The C API does that because we don't have classes and have to work around it this way, but for Python, LibInput.get_event() should just return the right type of object, e.g. PointerEvent.
Logical pairs like dx/dy maybe better returned as tuple?
get_absolute_x_transformed could be a x, y = event.transform_absolute(width, height) or something
get_time vs get_time_usec() - just drop get_time()[edit: make get_time return us]. the only reason it exists in the libinput API is because we realised too late ms isn't enough and we have to be backwards-compatible.
DeviceConfig.config_* is redundant, drop the config_ prefix
config_status_to_str() should just be a __repr__
The config may be worth subclassing, e.g. DeviceConfig.Tap.finger_count or so
libinput.constant.Event -> EventType ?
for the event codes, it may be better relying on evdev directly, but I understand that the python evdev situation isn't great right now
I had a read through the docs in regards to the API and I'll summarise the various comments here, easier than filing a million separate issues :)
The main issue is that, right now, the Python API is a C API in the Python language. That's not the same as a real Python API and there's lot for improvement. Implementation-wise what I did in libevdev-python was have an internal class that matches the C API (like you already have) but have the public API be a hand-written one that wraps the C wrapper.
Anyway, here's a list of comments regarding the current API:
BaseEventshouldn't be visible if it's not to be used, but ....Eventshould be the equiv to whatBaseEventis right nowEvent.get_device()should be a read-onlydeviceproperty. This applies to almost allget_...functions in the events, they should be properties.Event.get_pointer_event()shouldn't exist. The C API does that because we don't have classes and have to work around it this way, but for Python,LibInput.get_event()should just return the right type of object, e.g.PointerEvent.dx/dymaybe better returned as tuple?get_absolute_x_transformedcould be ax, y = event.transform_absolute(width, height)or somethingget_timevsget_time_usec()- just dropget_time()[edit: makeget_timereturn us]. the only reason it exists in the libinput API is because we realised too late ms isn't enough and we have to be backwards-compatible.DeviceConfig.config_*is redundant, drop theconfig_prefixconfig_status_to_str()should just be a__repr__DeviceConfig.Tap.finger_countor solibinput.constant.Event->EventType?