backend: make input device properties readable
This commit is contained in:
parent
8cd28dd3bf
commit
813f87faaa
6 changed files with 232 additions and 58 deletions
|
|
@ -7,13 +7,19 @@ use {
|
|||
LIBINPUT_CONFIG_TAP_DISABLED, LIBINPUT_CONFIG_TAP_ENABLED,
|
||||
},
|
||||
sys::{
|
||||
libinput_device, libinput_device_config_accel_set_profile,
|
||||
libinput_device_config_accel_set_speed, libinput_device_config_left_handed_set,
|
||||
libinput_device, libinput_device_config_accel_get_profile,
|
||||
libinput_device_config_accel_get_speed, libinput_device_config_accel_is_available,
|
||||
libinput_device_config_accel_set_profile, libinput_device_config_accel_set_speed,
|
||||
libinput_device_config_left_handed_get,
|
||||
libinput_device_config_left_handed_is_available,
|
||||
libinput_device_config_left_handed_set,
|
||||
libinput_device_config_scroll_get_natural_scroll_enabled,
|
||||
libinput_device_config_scroll_has_natural_scroll,
|
||||
libinput_device_config_scroll_set_natural_scroll_enabled,
|
||||
libinput_device_config_tap_get_drag_enabled,
|
||||
libinput_device_config_tap_get_drag_lock_enabled,
|
||||
libinput_device_config_tap_get_enabled, libinput_device_config_tap_set_drag_enabled,
|
||||
libinput_device_config_tap_get_enabled, libinput_device_config_tap_get_finger_count,
|
||||
libinput_device_config_tap_set_drag_enabled,
|
||||
libinput_device_config_tap_set_drag_lock_enabled,
|
||||
libinput_device_config_tap_set_enabled, libinput_device_get_name,
|
||||
libinput_device_get_user_data, libinput_device_has_capability,
|
||||
|
|
@ -64,12 +70,32 @@ impl<'a> LibInputDevice<'a> {
|
|||
res != 0
|
||||
}
|
||||
|
||||
pub fn left_handed_available(&self) -> bool {
|
||||
unsafe { libinput_device_config_left_handed_is_available(self.dev) != 0 }
|
||||
}
|
||||
|
||||
pub fn left_handed(&self) -> bool {
|
||||
unsafe { libinput_device_config_left_handed_get(self.dev) != 0 }
|
||||
}
|
||||
|
||||
pub fn set_left_handed(&self, left_handed: bool) {
|
||||
unsafe {
|
||||
libinput_device_config_left_handed_set(self.dev, left_handed as _);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn accel_available(&self) -> bool {
|
||||
unsafe { libinput_device_config_accel_is_available(self.dev) != 0 }
|
||||
}
|
||||
|
||||
pub fn accel_profile(&self) -> AccelProfile {
|
||||
unsafe { AccelProfile(libinput_device_config_accel_get_profile(self.dev)) }
|
||||
}
|
||||
|
||||
pub fn accel_speed(&self) -> f64 {
|
||||
unsafe { libinput_device_config_accel_get_speed(self.dev) }
|
||||
}
|
||||
|
||||
pub fn set_accel_profile(&self, profile: AccelProfile) {
|
||||
unsafe {
|
||||
libinput_device_config_accel_set_profile(self.dev, profile.raw() as _);
|
||||
|
|
@ -99,7 +125,10 @@ impl<'a> LibInputDevice<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn tap_available(&self) -> bool {
|
||||
unsafe { libinput_device_config_tap_get_finger_count(self.dev) != 0 }
|
||||
}
|
||||
|
||||
pub fn tap_enabled(&self) -> bool {
|
||||
let enabled = unsafe { ConfigTapState(libinput_device_config_tap_get_enabled(self.dev)) };
|
||||
match enabled {
|
||||
|
|
@ -158,6 +187,10 @@ impl<'a> LibInputDevice<'a> {
|
|||
pub fn natural_scrolling_enabled(&self) -> bool {
|
||||
unsafe { libinput_device_config_scroll_get_natural_scroll_enabled(self.dev) != 0 }
|
||||
}
|
||||
|
||||
pub fn has_natural_scrolling(&self) -> bool {
|
||||
unsafe { libinput_device_config_scroll_has_natural_scroll(self.dev) != 0 }
|
||||
}
|
||||
}
|
||||
|
||||
impl RegisteredDevice {
|
||||
|
|
|
|||
|
|
@ -41,19 +41,29 @@ extern "C" {
|
|||
device: *mut libinput_device,
|
||||
cap: libinput_device_capability,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_device_config_left_handed_is_available(
|
||||
device: *mut libinput_device,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_device_config_left_handed_get(device: *mut libinput_device) -> 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_is_available(device: *mut libinput_device) -> c::c_int;
|
||||
pub fn libinput_device_config_accel_get_profile(
|
||||
device: *mut libinput_device,
|
||||
) -> libinput_config_accel_profile;
|
||||
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_get_speed(device: *mut libinput_device) -> f64;
|
||||
pub fn libinput_device_config_accel_set_speed(
|
||||
device: *mut libinput_device,
|
||||
speed: f64,
|
||||
) -> libinput_config_status;
|
||||
pub fn libinput_device_get_name(device: *mut libinput_device) -> *const c::c_char;
|
||||
pub fn libinput_device_config_tap_get_finger_count(device: *mut libinput_device) -> c::c_int;
|
||||
pub fn libinput_device_config_tap_set_enabled(
|
||||
device: *mut libinput_device,
|
||||
enable: libinput_config_tap_state,
|
||||
|
|
@ -82,6 +92,9 @@ extern "C" {
|
|||
pub fn libinput_device_config_scroll_get_natural_scroll_enabled(
|
||||
device: *mut libinput_device,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_device_config_scroll_has_natural_scroll(
|
||||
device: *mut libinput_device,
|
||||
) -> c::c_int;
|
||||
|
||||
pub fn libinput_event_destroy(event: *mut libinput_event);
|
||||
pub fn libinput_event_get_type(event: *mut libinput_event) -> libinput_event_type;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue