autocommit 2022-03-30 22:27:19 CEST
This commit is contained in:
parent
a8136ed88c
commit
ab4ac883ee
19 changed files with 434 additions and 76 deletions
|
|
@ -150,3 +150,19 @@ cenum! {
|
|||
LIBINPUT_EVENT_GESTURE_HOLD_END = 807,
|
||||
LIBINPUT_EVENT_SWITCH_TOGGLE = 900,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
ConfigStatus, LIBINPUT_CONFIG_STATUS;
|
||||
|
||||
LIBINPUT_CONFIG_STATUS_SUCCESS = 0,
|
||||
LIBINPUT_CONFIG_STATUS_UNSUPPORTED = 1,
|
||||
LIBINPUT_CONFIG_STATUS_INVALID = 2,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
AccelProfile, LIBINPUT_CONFIG_ACCEL_PROFILE;
|
||||
|
||||
LIBINPUT_CONFIG_ACCEL_PROFILE_NONE = 0,
|
||||
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT = 1 << 0,
|
||||
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE = 1 << 1,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
use crate::libinput::sys::{libinput_device, libinput_device_get_user_data, libinput_device_has_capability, libinput_device_set_user_data, libinput_device_unref, libinput_path_remove_device};
|
||||
use crate::libinput::consts::{AccelProfile, DeviceCapability};
|
||||
use crate::libinput::sys::{
|
||||
libinput_device, libinput_device_config_accel_set_profile,
|
||||
libinput_device_config_accel_set_speed, libinput_device_config_left_handed_set,
|
||||
libinput_device_get_user_data, libinput_device_has_capability, libinput_device_set_user_data,
|
||||
libinput_device_unref, libinput_path_remove_device,
|
||||
};
|
||||
use crate::libinput::LibInput;
|
||||
use std::marker::PhantomData;
|
||||
use std::rc::Rc;
|
||||
use crate::libinput::consts::{DeviceCapability};
|
||||
|
||||
pub struct LibInputDevice<'a> {
|
||||
pub(super) dev: *mut libinput_device,
|
||||
|
|
@ -42,6 +47,24 @@ impl<'a> LibInputDevice<'a> {
|
|||
let res = unsafe { libinput_device_has_capability(self.dev, cap.raw() as _) };
|
||||
res != 0
|
||||
}
|
||||
|
||||
pub fn set_left_handed(&self, left_handed: bool) {
|
||||
unsafe {
|
||||
libinput_device_config_left_handed_set(self.dev, left_handed as _);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_accel_profile(&self, profile: AccelProfile) {
|
||||
unsafe {
|
||||
libinput_device_config_accel_set_profile(self.dev, profile.raw() as _);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_accel_speed(&self, speed: f64) {
|
||||
unsafe {
|
||||
libinput_device_config_accel_set_speed(self.dev, speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RegisteredDevice {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::libinput::sys::{
|
|||
libinput_event_pointer, libinput_event_pointer_get_button,
|
||||
libinput_event_pointer_get_button_state, libinput_event_pointer_get_dx,
|
||||
libinput_event_pointer_get_dy, libinput_event_pointer_get_scroll_value_v120,
|
||||
libinput_event_pointer_get_time_usec,
|
||||
libinput_event_pointer_get_time_usec, libinput_event_pointer_has_axis,
|
||||
};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
|
|
@ -108,6 +108,10 @@ impl<'a> LibInputEventPointer<'a> {
|
|||
unsafe { libinput_event_pointer_get_scroll_value_v120(self.event, axis.raw() as _) }
|
||||
}
|
||||
|
||||
pub fn has_axis(&self, axis: PointerAxis) -> bool {
|
||||
unsafe { libinput_event_pointer_has_axis(self.event, axis.raw() as _) != 0 }
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn time_usec(&self) -> u64 {
|
||||
unsafe { libinput_event_pointer_get_time_usec(self.event) }
|
||||
|
|
|
|||
|
|
@ -38,7 +38,22 @@ extern "C" {
|
|||
path: *const c::c_char,
|
||||
) -> *mut libinput_device;
|
||||
pub fn libinput_path_remove_device(device: *mut libinput_device);
|
||||
pub fn libinput_device_has_capability(device: *mut libinput_device, cap: libinput_device_capability) -> c::c_int;
|
||||
pub fn libinput_device_has_capability(
|
||||
device: *mut libinput_device,
|
||||
cap: libinput_device_capability,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_device_config_left_handed_set(
|
||||
device: *mut libinput_device,
|
||||
left_handed: c::c_int,
|
||||
) -> libinput_config_status;
|
||||
pub fn libinput_device_config_accel_set_profile(
|
||||
device: *mut libinput_device,
|
||||
profile: libinput_config_accel_profile,
|
||||
) -> libinput_config_status;
|
||||
pub fn libinput_device_config_accel_set_speed(
|
||||
device: *mut libinput_device,
|
||||
speed: f64,
|
||||
) -> libinput_config_status;
|
||||
|
||||
pub fn libinput_event_destroy(event: *mut libinput_event);
|
||||
pub fn libinput_event_get_type(event: *mut libinput_event) -> libinput_event_type;
|
||||
|
|
@ -67,6 +82,10 @@ extern "C" {
|
|||
event: *mut libinput_event_pointer,
|
||||
axis: libinput_pointer_axis,
|
||||
) -> f64;
|
||||
pub fn libinput_event_pointer_has_axis(
|
||||
event: *mut libinput_event_pointer,
|
||||
axis: libinput_pointer_axis,
|
||||
) -> c::c_int;
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue