wayland: implement tablet-v2
This commit is contained in:
parent
86e283d255
commit
7ed499eabd
62 changed files with 5174 additions and 318 deletions
|
|
@ -21,9 +21,19 @@ use {
|
|||
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,
|
||||
libinput_device_set_user_data, libinput_device_unref, libinput_path_remove_device,
|
||||
libinput_device_config_tap_set_enabled, libinput_device_get_device_group,
|
||||
libinput_device_get_id_product, libinput_device_get_id_vendor,
|
||||
libinput_device_get_name, libinput_device_get_user_data, libinput_device_group,
|
||||
libinput_device_group_get_user_data, libinput_device_group_set_user_data,
|
||||
libinput_device_has_capability, libinput_device_set_user_data,
|
||||
libinput_device_tablet_pad_get_mode_group, libinput_device_tablet_pad_get_num_buttons,
|
||||
libinput_device_tablet_pad_get_num_mode_groups,
|
||||
libinput_device_tablet_pad_get_num_rings, libinput_device_tablet_pad_get_num_strips,
|
||||
libinput_device_unref, libinput_path_remove_device, libinput_tablet_pad_mode_group,
|
||||
libinput_tablet_pad_mode_group_get_index, libinput_tablet_pad_mode_group_get_mode,
|
||||
libinput_tablet_pad_mode_group_get_num_modes,
|
||||
libinput_tablet_pad_mode_group_has_button, libinput_tablet_pad_mode_group_has_ring,
|
||||
libinput_tablet_pad_mode_group_has_strip,
|
||||
},
|
||||
LibInput,
|
||||
},
|
||||
|
|
@ -36,6 +46,16 @@ pub struct LibInputDevice<'a> {
|
|||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
pub struct LibInputDeviceGroup<'a> {
|
||||
pub(super) group: *mut libinput_device_group,
|
||||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
pub struct LibInputTabletPadModeGroup<'a> {
|
||||
pub(super) group: *mut libinput_tablet_pad_mode_group,
|
||||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
pub struct RegisteredDevice {
|
||||
pub(super) _li: Rc<LibInput>,
|
||||
pub(super) dev: *mut libinput_device,
|
||||
|
|
@ -191,6 +211,96 @@ impl<'a> LibInputDevice<'a> {
|
|||
pub fn has_natural_scrolling(&self) -> bool {
|
||||
unsafe { libinput_device_config_scroll_has_natural_scroll(self.dev) != 0 }
|
||||
}
|
||||
|
||||
pub fn device_group(&self) -> LibInputDeviceGroup<'_> {
|
||||
LibInputDeviceGroup {
|
||||
group: unsafe { libinput_device_get_device_group(self.dev) },
|
||||
_phantom: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn product(&self) -> u32 {
|
||||
unsafe { libinput_device_get_id_product(self.dev) as u32 }
|
||||
}
|
||||
|
||||
pub fn vendor(&self) -> u32 {
|
||||
unsafe { libinput_device_get_id_vendor(self.dev) as u32 }
|
||||
}
|
||||
|
||||
pub fn pad_num_buttons(&self) -> u32 {
|
||||
match unsafe { libinput_device_tablet_pad_get_num_buttons(self.dev) } {
|
||||
-1 => 0,
|
||||
n => n as u32,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pad_num_rings(&self) -> u32 {
|
||||
match unsafe { libinput_device_tablet_pad_get_num_rings(self.dev) } {
|
||||
-1 => 0,
|
||||
n => n as u32,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pad_num_strips(&self) -> u32 {
|
||||
match unsafe { libinput_device_tablet_pad_get_num_strips(self.dev) } {
|
||||
-1 => 0,
|
||||
n => n as u32,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pad_num_mode_groups(&self) -> u32 {
|
||||
match unsafe { libinput_device_tablet_pad_get_num_mode_groups(self.dev) } {
|
||||
-1 => 0,
|
||||
n => n as u32,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pad_mode_group(&self, group: u32) -> Option<LibInputTabletPadModeGroup<'_>> {
|
||||
let group = unsafe { libinput_device_tablet_pad_get_mode_group(self.dev, group as _) };
|
||||
if group.is_null() {
|
||||
return None;
|
||||
}
|
||||
Some(LibInputTabletPadModeGroup {
|
||||
group,
|
||||
_phantom: Default::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LibInputDeviceGroup<'a> {
|
||||
pub fn user_data(&self) -> usize {
|
||||
unsafe { libinput_device_group_get_user_data(self.group) }
|
||||
}
|
||||
|
||||
pub fn set_user_data(&self, user_data: usize) {
|
||||
unsafe { libinput_device_group_set_user_data(self.group, user_data) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LibInputTabletPadModeGroup<'a> {
|
||||
pub fn index(&self) -> u32 {
|
||||
unsafe { libinput_tablet_pad_mode_group_get_index(self.group) as u32 }
|
||||
}
|
||||
|
||||
pub fn num_modes(&self) -> u32 {
|
||||
unsafe { libinput_tablet_pad_mode_group_get_num_modes(self.group) as u32 }
|
||||
}
|
||||
|
||||
pub fn mode(&self) -> u32 {
|
||||
unsafe { libinput_tablet_pad_mode_group_get_mode(self.group) as u32 }
|
||||
}
|
||||
|
||||
pub fn has_button(&self, button: u32) -> bool {
|
||||
unsafe { libinput_tablet_pad_mode_group_has_button(self.group, button as _) != 0 }
|
||||
}
|
||||
|
||||
pub fn has_ring(&self, ring: u32) -> bool {
|
||||
unsafe { libinput_tablet_pad_mode_group_has_ring(self.group, ring as _) != 0 }
|
||||
}
|
||||
|
||||
pub fn has_strip(&self, strip: u32) -> bool {
|
||||
unsafe { libinput_tablet_pad_mode_group_has_strip(self.group, strip as _) != 0 }
|
||||
}
|
||||
}
|
||||
|
||||
impl RegisteredDevice {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue