metal,config: allow enabling tap-to-click
This commit is contained in:
parent
59445dd875
commit
6cc97ee56e
13 changed files with 293 additions and 4 deletions
|
|
@ -166,3 +166,24 @@ cenum! {
|
|||
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT = 1 << 0,
|
||||
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE = 1 << 1,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
ConfigTapState, LIBINPUT_CONFIG_TAP_STATE;
|
||||
|
||||
LIBINPUT_CONFIG_TAP_DISABLED = 0,
|
||||
LIBINPUT_CONFIG_TAP_ENABLED = 1,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
ConfigDragState, LIBINPUT_CONFIG_DRAG_STATE;
|
||||
|
||||
LIBINPUT_CONFIG_DRAG_DISABLED = 0,
|
||||
LIBINPUT_CONFIG_DRAG_ENABLED = 1,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
ConfigDragLockState, LIBINPUT_CONFIG_DRAG_LOCK_STATE;
|
||||
|
||||
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED = 0,
|
||||
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED = 1,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,21 @@
|
|||
use {
|
||||
crate::libinput::{
|
||||
consts::{AccelProfile, DeviceCapability},
|
||||
consts::{
|
||||
AccelProfile, ConfigDragLockState, ConfigDragState, ConfigTapState, DeviceCapability,
|
||||
LIBINPUT_CONFIG_DRAG_DISABLED, LIBINPUT_CONFIG_DRAG_ENABLED,
|
||||
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED,
|
||||
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_get_name, libinput_device_get_user_data,
|
||||
libinput_device_has_capability, libinput_device_set_user_data, libinput_device_unref,
|
||||
libinput_path_remove_device,
|
||||
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_set_drag_lock_enabled,
|
||||
libinput_device_config_tap_set_enabled, libinput_device_get_name,
|
||||
libinput_device_get_user_data, libinput_device_has_capability,
|
||||
libinput_device_set_user_data, libinput_device_unref, libinput_path_remove_device,
|
||||
},
|
||||
LibInput,
|
||||
},
|
||||
|
|
@ -77,6 +86,66 @@ impl<'a> LibInputDevice<'a> {
|
|||
CStr::from_ptr(name).to_bytes().as_bstr().to_string()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_tap_enabled(&self, enabled: bool) {
|
||||
let enabled = match enabled {
|
||||
true => LIBINPUT_CONFIG_TAP_ENABLED,
|
||||
false => LIBINPUT_CONFIG_TAP_DISABLED,
|
||||
};
|
||||
unsafe {
|
||||
libinput_device_config_tap_set_enabled(self.dev, enabled.raw() as _);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn tap_enabled(&self) -> bool {
|
||||
let enabled = unsafe { ConfigTapState(libinput_device_config_tap_get_enabled(self.dev)) };
|
||||
match enabled {
|
||||
LIBINPUT_CONFIG_TAP_ENABLED => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_drag_enabled(&self, enabled: bool) {
|
||||
let enabled = match enabled {
|
||||
true => LIBINPUT_CONFIG_DRAG_ENABLED,
|
||||
false => LIBINPUT_CONFIG_DRAG_DISABLED,
|
||||
};
|
||||
unsafe {
|
||||
libinput_device_config_tap_set_drag_enabled(self.dev, enabled.raw() as _);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn drag_enabled(&self) -> bool {
|
||||
let enabled =
|
||||
unsafe { ConfigDragState(libinput_device_config_tap_get_drag_enabled(self.dev)) };
|
||||
match enabled {
|
||||
LIBINPUT_CONFIG_DRAG_ENABLED => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_drag_lock_enabled(&self, enabled: bool) {
|
||||
let enabled = match enabled {
|
||||
true => LIBINPUT_CONFIG_DRAG_LOCK_ENABLED,
|
||||
false => LIBINPUT_CONFIG_DRAG_LOCK_DISABLED,
|
||||
};
|
||||
unsafe {
|
||||
libinput_device_config_tap_set_drag_lock_enabled(self.dev, enabled.raw() as _);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn drag_lock_enabled(&self) -> bool {
|
||||
let enabled = unsafe {
|
||||
ConfigDragLockState(libinput_device_config_tap_get_drag_lock_enabled(self.dev))
|
||||
};
|
||||
match enabled {
|
||||
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RegisteredDevice {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,27 @@ extern "C" {
|
|||
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_set_enabled(
|
||||
device: *mut libinput_device,
|
||||
enable: libinput_config_tap_state,
|
||||
) -> libinput_config_status;
|
||||
pub fn libinput_device_config_tap_get_enabled(
|
||||
device: *mut libinput_device,
|
||||
) -> libinput_config_tap_state;
|
||||
pub fn libinput_device_config_tap_set_drag_enabled(
|
||||
device: *mut libinput_device,
|
||||
enable: libinput_config_drag_state,
|
||||
) -> libinput_config_status;
|
||||
pub fn libinput_device_config_tap_get_drag_enabled(
|
||||
device: *mut libinput_device,
|
||||
) -> libinput_config_drag_state;
|
||||
pub fn libinput_device_config_tap_set_drag_lock_enabled(
|
||||
device: *mut libinput_device,
|
||||
enable: libinput_config_drag_lock_state,
|
||||
) -> libinput_config_status;
|
||||
pub fn libinput_device_config_tap_get_drag_lock_enabled(
|
||||
device: *mut libinput_device,
|
||||
) -> libinput_config_drag_lock_state;
|
||||
|
||||
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