1
0
Fork 0
forked from wry/wry

input: add support for natural scrolling

Closes #69
This commit is contained in:
Julian Orth 2024-02-04 18:50:49 +01:00
parent b4d73064d9
commit 887e2b6cbc
11 changed files with 77 additions and 0 deletions

View file

@ -9,6 +9,8 @@ use {
sys::{
libinput_device, libinput_device_config_accel_set_profile,
libinput_device_config_accel_set_speed, libinput_device_config_left_handed_set,
libinput_device_config_scroll_get_natural_scroll_enabled,
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,
@ -146,6 +148,17 @@ impl<'a> LibInputDevice<'a> {
_ => false,
}
}
pub fn set_natural_scrolling_enabled(&self, enabled: bool) {
unsafe {
libinput_device_config_scroll_set_natural_scroll_enabled(self.dev, enabled as _);
}
}
#[allow(dead_code)]
pub fn natural_scrolling_enabled(&self) -> bool {
unsafe { libinput_device_config_scroll_get_natural_scroll_enabled(self.dev) != 0 }
}
}
impl RegisteredDevice {

View file

@ -75,6 +75,13 @@ extern "C" {
pub fn libinput_device_config_tap_get_drag_lock_enabled(
device: *mut libinput_device,
) -> libinput_config_drag_lock_state;
pub fn libinput_device_config_scroll_set_natural_scroll_enabled(
device: *mut libinput_device,
enable: c::c_int,
) -> libinput_config_status;
pub fn libinput_device_config_scroll_get_natural_scroll_enabled(
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;