wayland: implement wl_touch
Co-authored-by: Julian Orth <ju.orth@gmail.com>
This commit is contained in:
parent
905e2dd7ba
commit
681c1ad033
35 changed files with 1071 additions and 52 deletions
|
|
@ -10,7 +10,9 @@ use {
|
|||
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_calibration_get_matrix,
|
||||
libinput_device_config_calibration_has_matrix,
|
||||
libinput_device_config_calibration_set_matrix, 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,
|
||||
|
|
@ -265,6 +267,25 @@ impl<'a> LibInputDevice<'a> {
|
|||
_phantom: Default::default(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn has_calibration_matrix(&self) -> bool {
|
||||
unsafe { libinput_device_config_calibration_has_matrix(self.dev) != 0 }
|
||||
}
|
||||
|
||||
pub fn set_calibration_matrix(&self, m: [[f32; 3]; 2]) {
|
||||
let m = [m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2]];
|
||||
unsafe {
|
||||
libinput_device_config_calibration_set_matrix(self.dev, &m);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_calibration_matrix(&self) -> [[f32; 3]; 2] {
|
||||
let mut m = [0.0; 6];
|
||||
unsafe {
|
||||
libinput_device_config_calibration_get_matrix(self.dev, &mut m);
|
||||
}
|
||||
[[m[0], m[1], m[2]], [m[3], m[4], m[5]]]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LibInputDeviceGroup<'a> {
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@ use {
|
|||
libinput_event_get_gesture_event, libinput_event_get_keyboard_event,
|
||||
libinput_event_get_pointer_event, libinput_event_get_switch_event,
|
||||
libinput_event_get_tablet_pad_event, libinput_event_get_tablet_tool_event,
|
||||
libinput_event_get_type, libinput_event_keyboard, libinput_event_keyboard_get_key,
|
||||
libinput_event_keyboard_get_key_state, libinput_event_keyboard_get_time_usec,
|
||||
libinput_event_pointer, libinput_event_pointer_get_button,
|
||||
libinput_event_pointer_get_button_state, libinput_event_pointer_get_dx,
|
||||
libinput_event_pointer_get_dx_unaccelerated, libinput_event_pointer_get_dy,
|
||||
libinput_event_pointer_get_dy_unaccelerated, libinput_event_pointer_get_scroll_value,
|
||||
libinput_event_pointer_get_scroll_value_v120, libinput_event_pointer_get_time_usec,
|
||||
libinput_event_pointer_has_axis, libinput_event_switch,
|
||||
libinput_event_switch_get_switch, libinput_event_switch_get_switch_state,
|
||||
libinput_event_switch_get_time_usec, libinput_event_tablet_pad,
|
||||
libinput_event_tablet_pad_get_button_number,
|
||||
libinput_event_get_touch_event, libinput_event_get_type, libinput_event_keyboard,
|
||||
libinput_event_keyboard_get_key, libinput_event_keyboard_get_key_state,
|
||||
libinput_event_keyboard_get_time_usec, libinput_event_pointer,
|
||||
libinput_event_pointer_get_button, libinput_event_pointer_get_button_state,
|
||||
libinput_event_pointer_get_dx, libinput_event_pointer_get_dx_unaccelerated,
|
||||
libinput_event_pointer_get_dy, libinput_event_pointer_get_dy_unaccelerated,
|
||||
libinput_event_pointer_get_scroll_value, libinput_event_pointer_get_scroll_value_v120,
|
||||
libinput_event_pointer_get_time_usec, libinput_event_pointer_has_axis,
|
||||
libinput_event_switch, libinput_event_switch_get_switch,
|
||||
libinput_event_switch_get_switch_state, libinput_event_switch_get_time_usec,
|
||||
libinput_event_tablet_pad, libinput_event_tablet_pad_get_button_number,
|
||||
libinput_event_tablet_pad_get_button_state, libinput_event_tablet_pad_get_mode,
|
||||
libinput_event_tablet_pad_get_mode_group, libinput_event_tablet_pad_get_ring_number,
|
||||
libinput_event_tablet_pad_get_ring_position, libinput_event_tablet_pad_get_ring_source,
|
||||
|
|
@ -40,10 +40,12 @@ use {
|
|||
libinput_event_tablet_tool_get_tool,
|
||||
libinput_event_tablet_tool_get_wheel_delta_discrete,
|
||||
libinput_event_tablet_tool_get_x_transformed,
|
||||
libinput_event_tablet_tool_get_y_transformed, libinput_tablet_tool,
|
||||
libinput_tablet_tool_get_serial, libinput_tablet_tool_get_tool_id,
|
||||
libinput_tablet_tool_get_type, libinput_tablet_tool_get_user_data,
|
||||
libinput_tablet_tool_set_user_data,
|
||||
libinput_event_tablet_tool_get_y_transformed, libinput_event_touch,
|
||||
libinput_event_touch_get_seat_slot, libinput_event_touch_get_time_usec,
|
||||
libinput_event_touch_get_x_transformed, libinput_event_touch_get_y_transformed,
|
||||
libinput_tablet_tool, libinput_tablet_tool_get_serial,
|
||||
libinput_tablet_tool_get_tool_id, libinput_tablet_tool_get_type,
|
||||
libinput_tablet_tool_get_user_data, libinput_tablet_tool_set_user_data,
|
||||
},
|
||||
},
|
||||
std::marker::PhantomData,
|
||||
|
|
@ -89,6 +91,11 @@ pub struct LibInputTabletTool<'a> {
|
|||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
pub struct LibInputEventTouch<'a> {
|
||||
pub(super) event: *mut libinput_event_touch,
|
||||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
impl<'a> Drop for LibInputEvent<'a> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
|
|
@ -155,6 +162,11 @@ impl<'a> LibInputEvent<'a> {
|
|||
LibInputEventTabletPad,
|
||||
libinput_event_get_tablet_pad_event
|
||||
);
|
||||
converter!(
|
||||
touch_event,
|
||||
LibInputEventTouch,
|
||||
libinput_event_get_touch_event
|
||||
);
|
||||
}
|
||||
|
||||
impl<'a> LibInputEventKeyboard<'a> {
|
||||
|
|
@ -467,3 +479,29 @@ impl<'a> LibInputEventTabletPad<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LibInputEventTouch<'a> {
|
||||
pub fn seat_slot(&self) -> i32 {
|
||||
unsafe { libinput_event_touch_get_seat_slot(self.event) }
|
||||
}
|
||||
|
||||
// pub fn x(&self) -> f64 {
|
||||
// unsafe { libinput_event_touch_get_x(self.event) }
|
||||
// }
|
||||
//
|
||||
// pub fn y(&self) -> f64 {
|
||||
// unsafe { libinput_event_touch_get_y(self.event) }
|
||||
// }
|
||||
|
||||
pub fn x_transformed(&self, width: u32) -> f64 {
|
||||
unsafe { libinput_event_touch_get_x_transformed(self.event, width) }
|
||||
}
|
||||
|
||||
pub fn y_transformed(&self, height: u32) -> f64 {
|
||||
unsafe { libinput_event_touch_get_y_transformed(self.event, height) }
|
||||
}
|
||||
|
||||
pub fn time_usec(&self) -> u64 {
|
||||
unsafe { libinput_event_touch_get_time_usec(self.event) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ pub struct libinput_tablet_pad_mode_group(u8);
|
|||
pub struct libinput_tablet_tool(u8);
|
||||
// #[repr(transparent)]
|
||||
// pub struct libinput_tablet_pad(u8);
|
||||
#[repr(transparent)]
|
||||
pub struct libinput_event_touch(u8);
|
||||
|
||||
#[link(name = "input")]
|
||||
extern "C" {
|
||||
|
|
@ -357,6 +359,29 @@ extern "C" {
|
|||
// group: *mut libinput_tablet_pad_mode_group,
|
||||
// button: c::c_uint,
|
||||
// ) -> c::c_int;
|
||||
|
||||
pub fn libinput_event_get_touch_event(event: *mut libinput_event) -> *mut libinput_event_touch;
|
||||
pub fn libinput_event_touch_get_seat_slot(event: *mut libinput_event_touch) -> i32;
|
||||
pub fn libinput_event_touch_get_time_usec(event: *mut libinput_event_touch) -> u64;
|
||||
// pub fn libinput_event_touch_get_x(event: *mut libinput_event_touch) -> f64;
|
||||
pub fn libinput_event_touch_get_x_transformed(
|
||||
event: *mut libinput_event_touch,
|
||||
width: u32,
|
||||
) -> f64;
|
||||
// pub fn libinput_event_touch_get_y(event: *mut libinput_event_touch) -> f64;
|
||||
pub fn libinput_event_touch_get_y_transformed(
|
||||
event: *mut libinput_event_touch,
|
||||
height: u32,
|
||||
) -> f64;
|
||||
pub fn libinput_device_config_calibration_has_matrix(device: *mut libinput_device) -> c::c_int;
|
||||
pub fn libinput_device_config_calibration_set_matrix(
|
||||
device: *mut libinput_device,
|
||||
matrix: *const [f32; 6],
|
||||
) -> libinput_config_status;
|
||||
pub fn libinput_device_config_calibration_get_matrix(
|
||||
device: *mut libinput_device,
|
||||
matrix: *mut [f32; 6],
|
||||
) -> c::c_int;
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue