refactor: split cargo workspace
This commit is contained in:
parent
5db14936e7
commit
1c21bd1259
695 changed files with 32023 additions and 44964 deletions
20
crates/libinput/Cargo.toml
Normal file
20
crates/libinput/Cargo.toml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
[package]
|
||||
name = "jay-libinput"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "GPL-3.0-only"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
jay-utils = { version = "0.1.0", path = "../utils" }
|
||||
|
||||
bstr = { version = "1.9.0", default-features = false, features = ["std"] }
|
||||
isnt = "0.2.0"
|
||||
libloading = "0.9.0"
|
||||
log = { version = "0.4.20", features = ["std"] }
|
||||
thiserror = "2.0.11"
|
||||
uapi = "0.2.13"
|
||||
|
||||
[build-dependencies]
|
||||
anyhow = "1.0.79"
|
||||
repc = "0.1.1"
|
||||
175
crates/libinput/build.rs
Normal file
175
crates/libinput/build.rs
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
use {
|
||||
repc::layout::{Type, TypeVariant},
|
||||
std::{
|
||||
env,
|
||||
fs::{File, OpenOptions},
|
||||
io::{self, BufWriter, Write},
|
||||
path::PathBuf,
|
||||
},
|
||||
};
|
||||
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! cenum {
|
||||
($name:ident, $uc:ident; $($name2:ident = $val:expr,)*) => {
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub struct $name(pub i32);
|
||||
|
||||
impl $name {
|
||||
pub fn raw(self) -> i32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
$(
|
||||
pub const $name2: $name = $name($val);
|
||||
)*
|
||||
|
||||
pub const $uc: &[i32] = &[$($val,)*];
|
||||
};
|
||||
}
|
||||
|
||||
#[path = "src/consts.rs"]
|
||||
mod consts;
|
||||
|
||||
fn open(s: &str) -> io::Result<BufWriter<File>> {
|
||||
let mut path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
path.push(s);
|
||||
Ok(BufWriter::new(
|
||||
OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.truncate(true)
|
||||
.open(path)?,
|
||||
))
|
||||
}
|
||||
|
||||
fn get_target() -> repc::Target {
|
||||
let rustc_target = env::var("TARGET").unwrap();
|
||||
repc::TARGET_MAP
|
||||
.iter()
|
||||
.cloned()
|
||||
.find(|t| t.0 == rustc_target)
|
||||
.unwrap()
|
||||
.1
|
||||
}
|
||||
|
||||
fn get_enum_ty(variants: Vec<i128>) -> anyhow::Result<u64> {
|
||||
let target = get_target();
|
||||
let ty = Type {
|
||||
layout: (),
|
||||
annotations: vec![],
|
||||
variant: TypeVariant::Enum(variants),
|
||||
};
|
||||
let ty = repc::compute_layout(target, &ty)?;
|
||||
assert!(ty.layout.pointer_alignment_bits <= ty.layout.size_bits);
|
||||
Ok(ty.layout.size_bits)
|
||||
}
|
||||
|
||||
fn write_ty<W: Write>(f: &mut W, vals: &[i32], ty: &str) -> anyhow::Result<()> {
|
||||
let variants: Vec<_> = vals.iter().cloned().map(|v| v as i128).collect();
|
||||
let size = get_enum_ty(variants)?;
|
||||
writeln!(f, "#[allow(clippy::allow_attributes, dead_code)]")?;
|
||||
writeln!(f, "pub type {} = i{};", ty, size)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let mut f = open("libinput_tys.rs")?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_LOG_PRIORITY,
|
||||
"libinput_log_priority",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_DEVICE_CAPABILITY,
|
||||
"libinput_device_capability",
|
||||
)?;
|
||||
write_ty(&mut f, consts::LIBINPUT_KEY_STATE, "libinput_key_state")?;
|
||||
write_ty(&mut f, consts::LIBINPUT_LED, "libinput_led")?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_BUTTON_STATE,
|
||||
"libinput_button_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_POINTER_AXIS,
|
||||
"libinput_pointer_axis",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_POINTER_AXIS_SOURCE,
|
||||
"libinput_pointer_axis_source",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_TABLET_PAD_RING_AXIS_SOURCE,
|
||||
"libinput_tablet_pad_ring_axis_source",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_TABLET_PAD_STRIP_AXIS_SOURCE,
|
||||
"libinput_tablet_pad_strip_axis_source",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_TABLET_TOOL_TYPE,
|
||||
"libinput_tablet_tool_type",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_TABLET_TOOL_PROXIMITY_STATE,
|
||||
"libinput_tablet_tool_proximity_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_TABLET_TOOL_TIP_STATE,
|
||||
"libinput_tablet_tool_tip_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_SWITCH_STATE,
|
||||
"libinput_switch_state",
|
||||
)?;
|
||||
write_ty(&mut f, consts::LIBINPUT_SWITCH, "libinput_switch")?;
|
||||
write_ty(&mut f, consts::LIBINPUT_EVENT_TYPE, "libinput_event_type")?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_STATUS,
|
||||
"libinput_config_status",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_ACCEL_PROFILE,
|
||||
"libinput_config_accel_profile",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_TAP_STATE,
|
||||
"libinput_config_tap_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_DRAG_STATE,
|
||||
"libinput_config_drag_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_DRAG_LOCK_STATE,
|
||||
"libinput_config_drag_lock_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_CLICK_METHOD,
|
||||
"libinput_config_click_method",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_MIDDLE_EMULATION_STATE,
|
||||
"libinput_config_middle_emulation_state",
|
||||
)?;
|
||||
|
||||
println!("cargo:rerun-if-changed=src/consts.rs");
|
||||
Ok(())
|
||||
}
|
||||
207
crates/libinput/src/consts.rs
Normal file
207
crates/libinput/src/consts.rs
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
cenum! {
|
||||
LogPriority, LIBINPUT_LOG_PRIORITY;
|
||||
|
||||
LIBINPUT_LOG_PRIORITY_DEBUG = 10,
|
||||
LIBINPUT_LOG_PRIORITY_INFO = 20,
|
||||
LIBINPUT_LOG_PRIORITY_ERROR = 30,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
DeviceCapability, LIBINPUT_DEVICE_CAPABILITY;
|
||||
|
||||
LIBINPUT_DEVICE_CAP_KEYBOARD = 0,
|
||||
LIBINPUT_DEVICE_CAP_POINTER = 1,
|
||||
LIBINPUT_DEVICE_CAP_TOUCH = 2,
|
||||
LIBINPUT_DEVICE_CAP_TABLET_TOOL = 3,
|
||||
LIBINPUT_DEVICE_CAP_TABLET_PAD = 4,
|
||||
LIBINPUT_DEVICE_CAP_GESTURE = 5,
|
||||
LIBINPUT_DEVICE_CAP_SWITCH = 6,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
KeyState, LIBINPUT_KEY_STATE;
|
||||
|
||||
LIBINPUT_KEY_STATE_RELEASED = 0,
|
||||
LIBINPUT_KEY_STATE_PRESSED = 1,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
Led, LIBINPUT_LED;
|
||||
|
||||
LIBINPUT_LED_NUM_LOCK = 1 << 0,
|
||||
LIBINPUT_LED_CAPS_LOCK = 1 << 1,
|
||||
LIBINPUT_LED_SCROLL_LOCK = 1 << 2,
|
||||
LIBINPUT_LED_COMPOSE = 1 << 3,
|
||||
LIBINPUT_LED_KANA = 1 << 4,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
ButtonState, LIBINPUT_BUTTON_STATE;
|
||||
|
||||
LIBINPUT_BUTTON_STATE_RELEASED = 0,
|
||||
LIBINPUT_BUTTON_STATE_PRESSED = 1,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
PointerAxis, LIBINPUT_POINTER_AXIS;
|
||||
|
||||
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL = 0,
|
||||
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL = 1,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
PointerAxisSource, LIBINPUT_POINTER_AXIS_SOURCE;
|
||||
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL = 1,
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_FINGER = 2,
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS = 3,
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT = 4,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
TabletPadRingAxisSource, LIBINPUT_TABLET_PAD_RING_AXIS_SOURCE;
|
||||
|
||||
LIBINPUT_TABLET_PAD_RING_SOURCE_UNKNOWN = 1,
|
||||
LIBINPUT_TABLET_PAD_RING_SOURCE_FINGER = 2,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
TabletPadStripAxisSource, LIBINPUT_TABLET_PAD_STRIP_AXIS_SOURCE;
|
||||
|
||||
LIBINPUT_TABLET_PAD_STRIP_SOURCE_UNKNOWN = 1,
|
||||
LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER = 2,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
TabletToolType, LIBINPUT_TABLET_TOOL_TYPE;
|
||||
|
||||
LIBINPUT_TABLET_TOOL_TYPE_PEN = 1,
|
||||
LIBINPUT_TABLET_TOOL_TYPE_ERASER = 2,
|
||||
LIBINPUT_TABLET_TOOL_TYPE_BRUSH = 3,
|
||||
LIBINPUT_TABLET_TOOL_TYPE_PENCIL = 4,
|
||||
LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH = 5,
|
||||
LIBINPUT_TABLET_TOOL_TYPE_MOUSE = 6,
|
||||
LIBINPUT_TABLET_TOOL_TYPE_LENS = 7,
|
||||
LIBINPUT_TABLET_TOOL_TYPE_TOTEM = 8,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
TabletToolProximityState, LIBINPUT_TABLET_TOOL_PROXIMITY_STATE;
|
||||
|
||||
LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT = 0,
|
||||
LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN = 1,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
TabletToolTipState, LIBINPUT_TABLET_TOOL_TIP_STATE;
|
||||
|
||||
LIBINPUT_TABLET_TOOL_TIP_UP = 0,
|
||||
LIBINPUT_TABLET_TOOL_TIP_DOWN = 1,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
SwitchState, LIBINPUT_SWITCH_STATE;
|
||||
|
||||
LIBINPUT_SWITCH_STATE_OFF = 0,
|
||||
LIBINPUT_SWITCH_STATE_ON = 1,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
Switch, LIBINPUT_SWITCH;
|
||||
|
||||
LIBINPUT_SWITCH_LID = 1,
|
||||
LIBINPUT_SWITCH_TABLET_MODE = 2,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
EventType, LIBINPUT_EVENT_TYPE;
|
||||
|
||||
LIBINPUT_EVENT_NONE = 0,
|
||||
LIBINPUT_EVENT_DEVICE_ADDED = 1,
|
||||
LIBINPUT_EVENT_DEVICE_REMOVED = 2,
|
||||
LIBINPUT_EVENT_KEYBOARD_KEY = 300,
|
||||
LIBINPUT_EVENT_POINTER_MOTION = 400,
|
||||
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE = 401,
|
||||
LIBINPUT_EVENT_POINTER_BUTTON = 402,
|
||||
LIBINPUT_EVENT_POINTER_AXIS = 403,
|
||||
LIBINPUT_EVENT_POINTER_SCROLL_WHEEL = 404,
|
||||
LIBINPUT_EVENT_POINTER_SCROLL_FINGER = 405,
|
||||
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS = 406,
|
||||
LIBINPUT_EVENT_TOUCH_DOWN = 500,
|
||||
LIBINPUT_EVENT_TOUCH_UP = 501,
|
||||
LIBINPUT_EVENT_TOUCH_MOTION = 502,
|
||||
LIBINPUT_EVENT_TOUCH_CANCEL = 503,
|
||||
LIBINPUT_EVENT_TOUCH_FRAME = 504,
|
||||
LIBINPUT_EVENT_TABLET_TOOL_AXIS = 600,
|
||||
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY = 601,
|
||||
LIBINPUT_EVENT_TABLET_TOOL_TIP = 602,
|
||||
LIBINPUT_EVENT_TABLET_TOOL_BUTTON = 603,
|
||||
LIBINPUT_EVENT_TABLET_PAD_BUTTON = 700,
|
||||
LIBINPUT_EVENT_TABLET_PAD_RING = 701,
|
||||
LIBINPUT_EVENT_TABLET_PAD_STRIP = 702,
|
||||
LIBINPUT_EVENT_TABLET_PAD_KEY = 703,
|
||||
LIBINPUT_EVENT_TABLET_PAD_DIAL = 704,
|
||||
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN = 800,
|
||||
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE = 801,
|
||||
LIBINPUT_EVENT_GESTURE_SWIPE_END = 802,
|
||||
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN = 803,
|
||||
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE = 804,
|
||||
LIBINPUT_EVENT_GESTURE_PINCH_END = 805,
|
||||
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN = 806,
|
||||
LIBINPUT_EVENT_GESTURE_HOLD_END = 807,
|
||||
LIBINPUT_EVENT_SWITCH_TOGGLE = 900,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
ConfigStatus, LIBINPUT_CONFIG_STATUS;
|
||||
|
||||
LIBINPUT_CONFIG_STATUS_SUCCESS = 0,
|
||||
LIBINPUT_CONFIG_STATUS_UNSUPPORTED = 1,
|
||||
LIBINPUT_CONFIG_STATUS_INVALID = 2,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
AccelProfile, LIBINPUT_CONFIG_ACCEL_PROFILE;
|
||||
|
||||
LIBINPUT_CONFIG_ACCEL_PROFILE_NONE = 0,
|
||||
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,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
ConfigClickMethod, LIBINPUT_CONFIG_CLICK_METHOD;
|
||||
|
||||
LIBINPUT_CONFIG_CLICK_METHOD_NONE = 0,
|
||||
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS = 1 << 0,
|
||||
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER = 1 << 1,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
ConfigMiddleEmulationState, LIBINPUT_CONFIG_MIDDLE_EMULATION_STATE;
|
||||
|
||||
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED = 0,
|
||||
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED = 1,
|
||||
}
|
||||
416
crates/libinput/src/device.rs
Normal file
416
crates/libinput/src/device.rs
Normal file
|
|
@ -0,0 +1,416 @@
|
|||
use {
|
||||
crate::{
|
||||
LibInput,
|
||||
consts::{
|
||||
AccelProfile, ConfigClickMethod, ConfigDragLockState, ConfigDragState,
|
||||
ConfigMiddleEmulationState, ConfigTapState, DeviceCapability,
|
||||
LIBINPUT_CONFIG_DRAG_DISABLED, LIBINPUT_CONFIG_DRAG_ENABLED,
|
||||
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED,
|
||||
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED,
|
||||
LIBINPUT_CONFIG_TAP_DISABLED, LIBINPUT_CONFIG_TAP_ENABLED, Led,
|
||||
},
|
||||
sys::{
|
||||
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_calibration_get_matrix,
|
||||
libinput_device_config_calibration_has_matrix,
|
||||
libinput_device_config_calibration_set_matrix, libinput_device_config_click_get_method,
|
||||
libinput_device_config_click_get_methods, libinput_device_config_click_set_method,
|
||||
libinput_device_config_left_handed_get,
|
||||
libinput_device_config_left_handed_is_available,
|
||||
libinput_device_config_left_handed_set,
|
||||
libinput_device_config_middle_emulation_get_enabled,
|
||||
libinput_device_config_middle_emulation_is_available,
|
||||
libinput_device_config_middle_emulation_set_enabled,
|
||||
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_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_device_group,
|
||||
libinput_device_get_id_bustype, 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_led_update, 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_dials,
|
||||
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_dial,
|
||||
libinput_tablet_pad_mode_group_has_ring, libinput_tablet_pad_mode_group_has_strip,
|
||||
},
|
||||
},
|
||||
bstr::ByteSlice,
|
||||
std::{ffi::CStr, marker::PhantomData, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct LibInputDevice<'a> {
|
||||
pub(super) dev: *mut libinput_device,
|
||||
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,
|
||||
}
|
||||
|
||||
impl<'a> LibInputDevice<'a> {
|
||||
pub fn set_slot(&self, slot: usize) {
|
||||
self.set_slot_(slot + 1)
|
||||
}
|
||||
|
||||
pub fn unset_slot(&self) {
|
||||
self.set_slot_(0)
|
||||
}
|
||||
|
||||
fn set_slot_(&self, slot: usize) {
|
||||
unsafe {
|
||||
libinput_device_set_user_data(self.dev, slot as _);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn slot(&self) -> Option<usize> {
|
||||
let res = unsafe { libinput_device_get_user_data(self.dev) as usize };
|
||||
if res == 0 { None } else { Some(res - 1) }
|
||||
}
|
||||
|
||||
pub fn has_cap(&self, cap: DeviceCapability) -> bool {
|
||||
let res = unsafe { libinput_device_has_capability(self.dev, cap.raw() as _) };
|
||||
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 _);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_accel_speed(&self, speed: f64) {
|
||||
unsafe {
|
||||
libinput_device_config_accel_set_speed(self.dev, speed);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> String {
|
||||
unsafe {
|
||||
let name = libinput_device_get_name(self.dev);
|
||||
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 _);
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
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 _);
|
||||
}
|
||||
}
|
||||
|
||||
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 _);
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_natural_scrolling_enabled(&self, enabled: bool) {
|
||||
unsafe {
|
||||
libinput_device_config_scroll_set_natural_scroll_enabled(self.dev, enabled as _);
|
||||
}
|
||||
}
|
||||
|
||||
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 }
|
||||
}
|
||||
|
||||
pub fn has_click_methods(&self) -> bool {
|
||||
unsafe { libinput_device_config_click_get_methods(self.dev) != 0 }
|
||||
}
|
||||
|
||||
pub fn click_method(&self) -> ConfigClickMethod {
|
||||
unsafe { ConfigClickMethod(libinput_device_config_click_get_method(self.dev)) }
|
||||
}
|
||||
|
||||
pub fn set_click_method(&self, method: ConfigClickMethod) {
|
||||
unsafe {
|
||||
libinput_device_config_click_set_method(self.dev, method.raw() as _);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_middle_button_emulation_enabled(&self, enabled: bool) {
|
||||
let enabled = match enabled {
|
||||
true => LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED,
|
||||
false => LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED,
|
||||
};
|
||||
unsafe {
|
||||
libinput_device_config_middle_emulation_set_enabled(self.dev, enabled.raw() as _);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn middle_button_emulation_enabled(&self) -> bool {
|
||||
let enabled = unsafe {
|
||||
ConfigMiddleEmulationState(libinput_device_config_middle_emulation_get_enabled(
|
||||
self.dev,
|
||||
))
|
||||
};
|
||||
match enabled {
|
||||
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn middle_button_emulation_available(&self) -> bool {
|
||||
unsafe { libinput_device_config_middle_emulation_is_available(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 bustype(&self) -> Option<u32> {
|
||||
libinput_device_get_id_bustype.map(|f| unsafe { f(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_dials(&self) -> u32 {
|
||||
match unsafe {
|
||||
libinput_device_tablet_pad_get_num_dials
|
||||
.map(|f| f(self.dev))
|
||||
.unwrap_or_default()
|
||||
} {
|
||||
-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(),
|
||||
})
|
||||
}
|
||||
|
||||
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]]]
|
||||
}
|
||||
|
||||
pub fn led_update(&self, led: Led) {
|
||||
unsafe {
|
||||
libinput_device_led_update(self.dev, led.raw() as _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 }
|
||||
}
|
||||
|
||||
pub fn has_dial(&self, dial: u32) -> bool {
|
||||
unsafe {
|
||||
libinput_tablet_pad_mode_group_has_dial
|
||||
.map(|f| f(self.group, dial as _))
|
||||
.unwrap_or_default()
|
||||
!= 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RegisteredDevice {
|
||||
pub fn device(&self) -> LibInputDevice<'_> {
|
||||
LibInputDevice {
|
||||
dev: self.dev,
|
||||
_phantom: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for RegisteredDevice {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
libinput_path_remove_device(self.dev);
|
||||
libinput_device_unref(self.dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
526
crates/libinput/src/event.rs
Normal file
526
crates/libinput/src/event.rs
Normal file
|
|
@ -0,0 +1,526 @@
|
|||
use {
|
||||
crate::{
|
||||
consts::{
|
||||
ButtonState, EventType, KeyState, PointerAxis, Switch, SwitchState,
|
||||
TabletPadRingAxisSource, TabletPadStripAxisSource, TabletToolProximityState,
|
||||
TabletToolTipState, TabletToolType,
|
||||
},
|
||||
device::{LibInputDevice, LibInputTabletPadModeGroup},
|
||||
sys::{
|
||||
libinput_event, libinput_event_destroy, libinput_event_gesture,
|
||||
libinput_event_gesture_get_angle_delta, libinput_event_gesture_get_cancelled,
|
||||
libinput_event_gesture_get_dx, libinput_event_gesture_get_dx_unaccelerated,
|
||||
libinput_event_gesture_get_dy, libinput_event_gesture_get_dy_unaccelerated,
|
||||
libinput_event_gesture_get_finger_count, libinput_event_gesture_get_scale,
|
||||
libinput_event_gesture_get_time_usec, libinput_event_get_device,
|
||||
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_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_absolute_x_transformed,
|
||||
libinput_event_pointer_get_absolute_y_transformed, 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_dial_delta_v120,
|
||||
libinput_event_tablet_pad_get_dial_number, 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,
|
||||
libinput_event_tablet_pad_get_strip_number,
|
||||
libinput_event_tablet_pad_get_strip_position,
|
||||
libinput_event_tablet_pad_get_strip_source, libinput_event_tablet_pad_get_time_usec,
|
||||
libinput_event_tablet_tool, libinput_event_tablet_tool_get_button,
|
||||
libinput_event_tablet_tool_get_button_state,
|
||||
libinput_event_tablet_tool_get_proximity_state,
|
||||
libinput_event_tablet_tool_get_time_usec, libinput_event_tablet_tool_get_tip_state,
|
||||
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_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,
|
||||
};
|
||||
|
||||
pub struct LibInputEvent<'a> {
|
||||
pub(super) event: *mut libinput_event,
|
||||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
pub struct LibInputEventKeyboard<'a> {
|
||||
pub(super) event: *mut libinput_event_keyboard,
|
||||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
pub struct LibInputEventPointer<'a> {
|
||||
pub(super) event: *mut libinput_event_pointer,
|
||||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
pub struct LibInputEventGesture<'a> {
|
||||
pub(super) event: *mut libinput_event_gesture,
|
||||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
pub struct LibInputEventSwitch<'a> {
|
||||
pub(super) event: *mut libinput_event_switch,
|
||||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
pub struct LibInputEventTabletTool<'a> {
|
||||
pub(super) event: *mut libinput_event_tablet_tool,
|
||||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
pub struct LibInputEventTabletPad<'a> {
|
||||
pub(super) event: *mut libinput_event_tablet_pad,
|
||||
pub(super) _phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
pub struct LibInputTabletTool<'a> {
|
||||
pub(super) tool: *mut libinput_tablet_tool,
|
||||
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 {
|
||||
libinput_event_destroy(self.event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! converter {
|
||||
($name:ident, $out:ident, $f:ident) => {
|
||||
pub fn $name(&self) -> Option<$out<'_>> {
|
||||
let res = unsafe { $f(self.event) };
|
||||
if res.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some($out {
|
||||
event: res,
|
||||
_phantom: Default::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl<'a> LibInputEvent<'a> {
|
||||
pub fn ty(&self) -> EventType {
|
||||
unsafe { EventType(libinput_event_get_type(self.event)) }
|
||||
}
|
||||
|
||||
pub fn device(&self) -> LibInputDevice<'_> {
|
||||
LibInputDevice {
|
||||
dev: unsafe { libinput_event_get_device(self.event) },
|
||||
_phantom: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
converter!(
|
||||
keyboard_event,
|
||||
LibInputEventKeyboard,
|
||||
libinput_event_get_keyboard_event
|
||||
);
|
||||
converter!(
|
||||
pointer_event,
|
||||
LibInputEventPointer,
|
||||
libinput_event_get_pointer_event
|
||||
);
|
||||
converter!(
|
||||
gesture_event,
|
||||
LibInputEventGesture,
|
||||
libinput_event_get_gesture_event
|
||||
);
|
||||
converter!(
|
||||
switch_event,
|
||||
LibInputEventSwitch,
|
||||
libinput_event_get_switch_event
|
||||
);
|
||||
converter!(
|
||||
tablet_tool_event,
|
||||
LibInputEventTabletTool,
|
||||
libinput_event_get_tablet_tool_event
|
||||
);
|
||||
converter!(
|
||||
tablet_pad_event,
|
||||
LibInputEventTabletPad,
|
||||
libinput_event_get_tablet_pad_event
|
||||
);
|
||||
converter!(
|
||||
touch_event,
|
||||
LibInputEventTouch,
|
||||
libinput_event_get_touch_event
|
||||
);
|
||||
}
|
||||
|
||||
impl<'a> LibInputEventKeyboard<'a> {
|
||||
pub fn key(&self) -> u32 {
|
||||
unsafe { libinput_event_keyboard_get_key(self.event) }
|
||||
}
|
||||
|
||||
pub fn key_state(&self) -> KeyState {
|
||||
unsafe { KeyState(libinput_event_keyboard_get_key_state(self.event)) }
|
||||
}
|
||||
|
||||
pub fn time_usec(&self) -> u64 {
|
||||
unsafe { libinput_event_keyboard_get_time_usec(self.event) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LibInputEventPointer<'a> {
|
||||
pub fn x_transformed(&self, width: u32) -> f64 {
|
||||
unsafe { libinput_event_pointer_get_absolute_x_transformed(self.event, width) }
|
||||
}
|
||||
|
||||
pub fn y_transformed(&self, height: u32) -> f64 {
|
||||
unsafe { libinput_event_pointer_get_absolute_y_transformed(self.event, height) }
|
||||
}
|
||||
|
||||
pub fn dx(&self) -> f64 {
|
||||
unsafe { libinput_event_pointer_get_dx(self.event) }
|
||||
}
|
||||
|
||||
pub fn dy(&self) -> f64 {
|
||||
unsafe { libinput_event_pointer_get_dy(self.event) }
|
||||
}
|
||||
|
||||
pub fn dx_unaccelerated(&self) -> f64 {
|
||||
unsafe { libinput_event_pointer_get_dx_unaccelerated(self.event) }
|
||||
}
|
||||
|
||||
pub fn dy_unaccelerated(&self) -> f64 {
|
||||
unsafe { libinput_event_pointer_get_dy_unaccelerated(self.event) }
|
||||
}
|
||||
|
||||
pub fn button(&self) -> u32 {
|
||||
unsafe { libinput_event_pointer_get_button(self.event) }
|
||||
}
|
||||
|
||||
pub fn button_state(&self) -> ButtonState {
|
||||
unsafe { ButtonState(libinput_event_pointer_get_button_state(self.event)) }
|
||||
}
|
||||
|
||||
pub fn scroll_value(&self, axis: PointerAxis) -> f64 {
|
||||
unsafe { libinput_event_pointer_get_scroll_value(self.event, axis.raw() as _) }
|
||||
}
|
||||
|
||||
pub fn scroll_value_v120(&self, axis: PointerAxis) -> f64 {
|
||||
unsafe { libinput_event_pointer_get_scroll_value_v120(self.event, axis.raw() as _) }
|
||||
}
|
||||
|
||||
pub fn has_axis(&self, axis: PointerAxis) -> bool {
|
||||
unsafe { libinput_event_pointer_has_axis(self.event, axis.raw() as _) != 0 }
|
||||
}
|
||||
|
||||
pub fn time_usec(&self) -> u64 {
|
||||
unsafe { libinput_event_pointer_get_time_usec(self.event) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LibInputEventGesture<'a> {
|
||||
pub fn time_usec(&self) -> u64 {
|
||||
unsafe { libinput_event_gesture_get_time_usec(self.event) }
|
||||
}
|
||||
|
||||
pub fn finger_count(&self) -> u32 {
|
||||
unsafe { libinput_event_gesture_get_finger_count(self.event) as u32 }
|
||||
}
|
||||
|
||||
pub fn cancelled(&self) -> bool {
|
||||
unsafe { libinput_event_gesture_get_cancelled(self.event) != 0 }
|
||||
}
|
||||
|
||||
pub fn dx(&self) -> f64 {
|
||||
unsafe { libinput_event_gesture_get_dx(self.event) }
|
||||
}
|
||||
|
||||
pub fn dy(&self) -> f64 {
|
||||
unsafe { libinput_event_gesture_get_dy(self.event) }
|
||||
}
|
||||
|
||||
pub fn dx_unaccelerated(&self) -> f64 {
|
||||
unsafe { libinput_event_gesture_get_dx_unaccelerated(self.event) }
|
||||
}
|
||||
|
||||
pub fn dy_unaccelerated(&self) -> f64 {
|
||||
unsafe { libinput_event_gesture_get_dy_unaccelerated(self.event) }
|
||||
}
|
||||
|
||||
pub fn scale(&self) -> f64 {
|
||||
unsafe { libinput_event_gesture_get_scale(self.event) }
|
||||
}
|
||||
|
||||
pub fn angle_delta(&self) -> f64 {
|
||||
unsafe { libinput_event_gesture_get_angle_delta(self.event) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LibInputEventSwitch<'a> {
|
||||
pub fn time_usec(&self) -> u64 {
|
||||
unsafe { libinput_event_switch_get_time_usec(self.event) }
|
||||
}
|
||||
|
||||
pub fn switch(&self) -> Switch {
|
||||
unsafe { Switch(libinput_event_switch_get_switch(self.event)) }
|
||||
}
|
||||
|
||||
pub fn switch_state(&self) -> SwitchState {
|
||||
unsafe { SwitchState(libinput_event_switch_get_switch_state(self.event)) }
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! has_changed {
|
||||
($name:ident, $f:ident) => {
|
||||
pub fn $name(&self) -> bool {
|
||||
unsafe { crate::sys::$f(self.event) != 0 }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! get_double {
|
||||
($name:ident, $f:ident) => {
|
||||
pub fn $name(&self) -> f64 {
|
||||
unsafe { crate::sys::$f(self.event) }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! has_capability {
|
||||
($name:ident, $f:ident) => {
|
||||
pub fn $name(&self) -> bool {
|
||||
unsafe { crate::sys::$f(self.tool) != 0 }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl<'a> LibInputTabletTool<'a> {
|
||||
pub fn user_data(&self) -> usize {
|
||||
unsafe { libinput_tablet_tool_get_user_data(self.tool) }
|
||||
}
|
||||
|
||||
pub fn set_user_data(&self, user_data: usize) {
|
||||
unsafe { libinput_tablet_tool_set_user_data(self.tool, user_data) }
|
||||
}
|
||||
|
||||
pub fn type_(&self) -> TabletToolType {
|
||||
unsafe { TabletToolType(libinput_tablet_tool_get_type(self.tool)) }
|
||||
}
|
||||
|
||||
pub fn tool_id(&self) -> u64 {
|
||||
unsafe { libinput_tablet_tool_get_tool_id(self.tool) }
|
||||
}
|
||||
|
||||
pub fn serial(&self) -> u64 {
|
||||
unsafe { libinput_tablet_tool_get_serial(self.tool) }
|
||||
}
|
||||
|
||||
has_capability!(has_pressure, libinput_tablet_tool_has_pressure);
|
||||
has_capability!(has_distance, libinput_tablet_tool_has_distance);
|
||||
has_capability!(has_tilt, libinput_tablet_tool_has_tilt);
|
||||
has_capability!(has_rotation, libinput_tablet_tool_has_rotation);
|
||||
has_capability!(has_slider, libinput_tablet_tool_has_slider);
|
||||
// has_capability!(has_size, libinput_tablet_tool_has_size);
|
||||
has_capability!(has_wheel, libinput_tablet_tool_has_wheel);
|
||||
}
|
||||
|
||||
impl<'a> LibInputEventTabletTool<'a> {
|
||||
pub fn tool(&self) -> LibInputTabletTool<'_> {
|
||||
LibInputTabletTool {
|
||||
tool: unsafe { libinput_event_tablet_tool_get_tool(self.event) },
|
||||
_phantom: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn time_usec(&self) -> u64 {
|
||||
unsafe { libinput_event_tablet_tool_get_time_usec(self.event) }
|
||||
}
|
||||
|
||||
has_changed!(x_has_changed, libinput_event_tablet_tool_x_has_changed);
|
||||
has_changed!(y_has_changed, libinput_event_tablet_tool_y_has_changed);
|
||||
has_changed!(
|
||||
pressure_has_changed,
|
||||
libinput_event_tablet_tool_pressure_has_changed
|
||||
);
|
||||
has_changed!(
|
||||
distance_has_changed,
|
||||
libinput_event_tablet_tool_distance_has_changed
|
||||
);
|
||||
has_changed!(
|
||||
tilt_x_has_changed,
|
||||
libinput_event_tablet_tool_tilt_x_has_changed
|
||||
);
|
||||
has_changed!(
|
||||
tilt_y_has_changed,
|
||||
libinput_event_tablet_tool_tilt_y_has_changed
|
||||
);
|
||||
has_changed!(
|
||||
rotation_has_changed,
|
||||
libinput_event_tablet_tool_rotation_has_changed
|
||||
);
|
||||
has_changed!(
|
||||
slider_has_changed,
|
||||
libinput_event_tablet_tool_slider_has_changed
|
||||
);
|
||||
// has_changed!(
|
||||
// size_major_has_changed,
|
||||
// libinput_event_tablet_tool_size_major_has_changed
|
||||
// );
|
||||
// has_changed!(
|
||||
// size_minor_has_changed,
|
||||
// libinput_event_tablet_tool_size_minor_has_changed
|
||||
// );
|
||||
has_changed!(
|
||||
wheel_has_changed,
|
||||
libinput_event_tablet_tool_wheel_has_changed
|
||||
);
|
||||
|
||||
// get_double!(x, libinput_event_tablet_tool_get_x);
|
||||
// get_double!(y, libinput_event_tablet_tool_get_y);
|
||||
get_double!(dx, libinput_event_tablet_tool_get_dx);
|
||||
get_double!(dy, libinput_event_tablet_tool_get_dy);
|
||||
get_double!(pressure, libinput_event_tablet_tool_get_pressure);
|
||||
get_double!(distance, libinput_event_tablet_tool_get_distance);
|
||||
get_double!(tilt_x, libinput_event_tablet_tool_get_tilt_x);
|
||||
get_double!(tilt_y, libinput_event_tablet_tool_get_tilt_y);
|
||||
get_double!(rotation, libinput_event_tablet_tool_get_rotation);
|
||||
get_double!(
|
||||
slider_position,
|
||||
libinput_event_tablet_tool_get_slider_position
|
||||
);
|
||||
// get_double!(size_major, libinput_event_tablet_tool_get_size_major);
|
||||
// get_double!(size_minor, libinput_event_tablet_tool_get_size_minor);
|
||||
get_double!(wheel_delta, libinput_event_tablet_tool_get_wheel_delta);
|
||||
|
||||
pub fn wheel_delta_discrete(&self) -> i32 {
|
||||
unsafe { libinput_event_tablet_tool_get_wheel_delta_discrete(self.event) as _ }
|
||||
}
|
||||
|
||||
pub fn x_transformed(&self, width: u32) -> f64 {
|
||||
unsafe { libinput_event_tablet_tool_get_x_transformed(self.event, width) }
|
||||
}
|
||||
|
||||
pub fn y_transformed(&self, width: u32) -> f64 {
|
||||
unsafe { libinput_event_tablet_tool_get_y_transformed(self.event, width) }
|
||||
}
|
||||
|
||||
pub fn proximity_state(&self) -> TabletToolProximityState {
|
||||
unsafe {
|
||||
TabletToolProximityState(libinput_event_tablet_tool_get_proximity_state(self.event))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tip_state(&self) -> TabletToolTipState {
|
||||
unsafe { TabletToolTipState(libinput_event_tablet_tool_get_tip_state(self.event)) }
|
||||
}
|
||||
|
||||
pub fn button(&self) -> u32 {
|
||||
unsafe { libinput_event_tablet_tool_get_button(self.event) }
|
||||
}
|
||||
|
||||
pub fn button_state(&self) -> ButtonState {
|
||||
unsafe { ButtonState(libinput_event_tablet_tool_get_button_state(self.event)) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LibInputEventTabletPad<'a> {
|
||||
pub fn time_usec(&self) -> u64 {
|
||||
unsafe { libinput_event_tablet_pad_get_time_usec(self.event) }
|
||||
}
|
||||
|
||||
pub fn ring_position(&self) -> f64 {
|
||||
unsafe { libinput_event_tablet_pad_get_ring_position(self.event) }
|
||||
}
|
||||
|
||||
pub fn ring_number(&self) -> u32 {
|
||||
unsafe { libinput_event_tablet_pad_get_ring_number(self.event) as u32 }
|
||||
}
|
||||
|
||||
pub fn ring_source(&self) -> TabletPadRingAxisSource {
|
||||
unsafe { TabletPadRingAxisSource(libinput_event_tablet_pad_get_ring_source(self.event)) }
|
||||
}
|
||||
|
||||
pub fn strip_position(&self) -> f64 {
|
||||
unsafe { libinput_event_tablet_pad_get_strip_position(self.event) }
|
||||
}
|
||||
|
||||
pub fn strip_number(&self) -> u32 {
|
||||
unsafe { libinput_event_tablet_pad_get_strip_number(self.event) as u32 }
|
||||
}
|
||||
|
||||
pub fn strip_source(&self) -> TabletPadStripAxisSource {
|
||||
unsafe { TabletPadStripAxisSource(libinput_event_tablet_pad_get_strip_source(self.event)) }
|
||||
}
|
||||
|
||||
pub fn dial_number(&self) -> Option<u32> {
|
||||
libinput_event_tablet_pad_get_dial_number.map(|f| unsafe { f(self.event) as u32 })
|
||||
}
|
||||
|
||||
pub fn dial_delta_v120(&self) -> Option<f64> {
|
||||
libinput_event_tablet_pad_get_dial_delta_v120.map(|f| unsafe { f(self.event) })
|
||||
}
|
||||
|
||||
pub fn button_number(&self) -> u32 {
|
||||
unsafe { libinput_event_tablet_pad_get_button_number(self.event) }
|
||||
}
|
||||
|
||||
pub fn button_state(&self) -> ButtonState {
|
||||
unsafe { ButtonState(libinput_event_tablet_pad_get_button_state(self.event)) }
|
||||
}
|
||||
|
||||
pub fn mode(&self) -> u32 {
|
||||
unsafe { libinput_event_tablet_pad_get_mode(self.event) as u32 }
|
||||
}
|
||||
|
||||
pub fn mode_group(&self) -> LibInputTabletPadModeGroup<'_> {
|
||||
LibInputTabletPadModeGroup {
|
||||
group: unsafe { libinput_event_tablet_pad_get_mode_group(self.event) },
|
||||
_phantom: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) }
|
||||
}
|
||||
}
|
||||
205
crates/libinput/src/lib.rs
Normal file
205
crates/libinput/src/lib.rs
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
#![allow(non_camel_case_types)]
|
||||
|
||||
macro_rules! cenum {
|
||||
($name:ident, $uc:ident; $($name2:ident = $val:expr,)*) => {
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub struct $name(pub i32);
|
||||
|
||||
impl $name {
|
||||
#[allow(dead_code)]
|
||||
pub fn raw(self) -> i32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
$(
|
||||
pub const $name2: $name = $name($val);
|
||||
)*
|
||||
|
||||
pub const $uc: &[i32] = &[$($val,)*];
|
||||
};
|
||||
}
|
||||
|
||||
pub mod consts;
|
||||
pub mod device;
|
||||
pub mod event;
|
||||
mod sys;
|
||||
|
||||
use {
|
||||
crate::{
|
||||
consts::{
|
||||
LIBINPUT_LOG_PRIORITY_DEBUG, LIBINPUT_LOG_PRIORITY_ERROR, LIBINPUT_LOG_PRIORITY_INFO,
|
||||
LogPriority,
|
||||
},
|
||||
device::RegisteredDevice,
|
||||
event::LibInputEvent,
|
||||
sys::{
|
||||
libinput, libinput_device_ref, libinput_dispatch, libinput_get_event, libinput_get_fd,
|
||||
libinput_interface, libinput_log_priority, libinput_log_set_handler,
|
||||
libinput_log_set_priority, libinput_path_add_device, libinput_path_create_context,
|
||||
libinput_unref,
|
||||
},
|
||||
},
|
||||
bstr::ByteSlice,
|
||||
isnt::std_1::primitive::IsntConstPtrExt,
|
||||
jay_utils::{errorfmt::ErrorFmt, oserror::OsError, ptr_ext::PtrExt},
|
||||
std::{ffi::CStr, rc::Rc},
|
||||
thiserror::Error,
|
||||
uapi::{IntoUstr, OwnedFd, c},
|
||||
};
|
||||
|
||||
static INTERFACE: libinput_interface = libinput_interface {
|
||||
open_restricted,
|
||||
close_restricted,
|
||||
};
|
||||
|
||||
unsafe extern "C" fn open_restricted(
|
||||
path: *const c::c_char,
|
||||
_flags: c::c_int,
|
||||
user_data: *mut c::c_void,
|
||||
) -> c::c_int {
|
||||
unsafe {
|
||||
let ud = (user_data as *const UserData).deref();
|
||||
match ud.adapter.open(CStr::from_ptr(path)) {
|
||||
Ok(f) => f.unwrap(),
|
||||
Err(e) => {
|
||||
log::error!("Could not open device for libinput: {}", ErrorFmt(e));
|
||||
-1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn close_restricted(fd: c::c_int, _user_data: *mut c::c_void) {
|
||||
drop(OwnedFd::new(fd));
|
||||
}
|
||||
|
||||
struct UserData {
|
||||
adapter: Rc<dyn LibInputAdapter>,
|
||||
}
|
||||
|
||||
pub trait LibInputAdapter {
|
||||
fn open(&self, path: &CStr) -> Result<OwnedFd, LibInputError>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum LibInputError {
|
||||
#[error("Could not create a libinput instance")]
|
||||
New,
|
||||
#[error("Could not open a libinput device")]
|
||||
Open,
|
||||
#[error("Could not dispatch libinput events")]
|
||||
Dispatch(#[source] OsError),
|
||||
#[error("The requested device is not available")]
|
||||
DeviceUnavailable,
|
||||
#[error("Dupfd failed")]
|
||||
DupFd(#[source] OsError),
|
||||
#[error("Stat failed")]
|
||||
Stat(#[source] OsError),
|
||||
}
|
||||
|
||||
pub struct LibInput {
|
||||
_data: Box<UserData>,
|
||||
li: *mut libinput,
|
||||
}
|
||||
|
||||
unsafe extern "C" {
|
||||
fn jay_libinput_log_handler_bridge();
|
||||
}
|
||||
|
||||
impl LibInput {
|
||||
pub fn new(adapter: Rc<dyn LibInputAdapter>) -> Result<Self, LibInputError> {
|
||||
let mut ud = Box::new(UserData { adapter });
|
||||
let li = unsafe {
|
||||
libinput_path_create_context(&INTERFACE, &mut *ud as *mut _ as *mut c::c_void)
|
||||
};
|
||||
if li.is_null() {
|
||||
return Err(LibInputError::New);
|
||||
}
|
||||
unsafe {
|
||||
libinput_log_set_handler(li, jay_libinput_log_handler_bridge);
|
||||
let priority = if log::log_enabled!(log::Level::Debug) {
|
||||
LIBINPUT_LOG_PRIORITY_DEBUG
|
||||
} else if log::log_enabled!(log::Level::Info) {
|
||||
LIBINPUT_LOG_PRIORITY_INFO
|
||||
} else {
|
||||
LIBINPUT_LOG_PRIORITY_ERROR
|
||||
};
|
||||
libinput_log_set_priority(li, priority.raw() as _);
|
||||
}
|
||||
Ok(Self { _data: ud, li })
|
||||
}
|
||||
|
||||
pub fn fd(&self) -> c::c_int {
|
||||
unsafe { libinput_get_fd(self.li) }
|
||||
}
|
||||
|
||||
pub fn open<'a>(
|
||||
self: &Rc<Self>,
|
||||
path: impl IntoUstr<'a>,
|
||||
) -> Result<RegisteredDevice, LibInputError> {
|
||||
let path = path.into_ustr();
|
||||
let res = unsafe { libinput_path_add_device(self.li, path.as_ptr()) };
|
||||
if res.is_null() {
|
||||
Err(LibInputError::Open)
|
||||
} else {
|
||||
unsafe {
|
||||
libinput_device_ref(res);
|
||||
}
|
||||
Ok(RegisteredDevice {
|
||||
_li: self.clone(),
|
||||
dev: res,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dispatch(&self) -> Result<(), LibInputError> {
|
||||
let res = unsafe { libinput_dispatch(self.li) };
|
||||
if res < 0 {
|
||||
Err(LibInputError::Dispatch(OsError(-res)))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn event(&self) -> Option<LibInputEvent<'_>> {
|
||||
let res = unsafe { libinput_get_event(self.li) };
|
||||
if res.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(LibInputEvent {
|
||||
event: res,
|
||||
_phantom: Default::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for LibInput {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
libinput_unref(self.li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn jay_libinput_log_handler(
|
||||
_libinput: *mut libinput,
|
||||
priority: libinput_log_priority,
|
||||
line: *const c::c_char,
|
||||
) {
|
||||
assert!(line.is_not_null());
|
||||
let str = unsafe { CStr::from_ptr(line) };
|
||||
let priority = match LogPriority(priority as _) {
|
||||
LIBINPUT_LOG_PRIORITY_DEBUG => log::Level::Debug,
|
||||
LIBINPUT_LOG_PRIORITY_INFO => log::Level::Info,
|
||||
LIBINPUT_LOG_PRIORITY_ERROR => log::Level::Error,
|
||||
_ => log::Level::Error,
|
||||
};
|
||||
log::log!(
|
||||
priority,
|
||||
"libinput: {}",
|
||||
str.to_bytes().trim_ascii().as_bstr()
|
||||
);
|
||||
}
|
||||
460
crates/libinput/src/sys.rs
Normal file
460
crates/libinput/src/sys.rs
Normal file
|
|
@ -0,0 +1,460 @@
|
|||
use {libloading::os::unix::Library, std::sync::LazyLock, uapi::c};
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/libinput_tys.rs"));
|
||||
|
||||
pub type libinput_log_handler = unsafe extern "C" fn();
|
||||
|
||||
#[repr(transparent)]
|
||||
pub struct libinput(u8);
|
||||
#[repr(transparent)]
|
||||
pub struct libinput_device(u8);
|
||||
#[repr(transparent)]
|
||||
pub struct libinput_device_group(u8);
|
||||
#[repr(transparent)]
|
||||
pub struct libinput_event(u8);
|
||||
#[repr(transparent)]
|
||||
pub struct libinput_event_keyboard(u8);
|
||||
#[repr(transparent)]
|
||||
pub struct libinput_event_pointer(u8);
|
||||
#[repr(transparent)]
|
||||
pub struct libinput_event_gesture(u8);
|
||||
#[repr(transparent)]
|
||||
pub struct libinput_event_switch(u8);
|
||||
#[repr(transparent)]
|
||||
pub struct libinput_event_tablet_tool(u8);
|
||||
#[repr(transparent)]
|
||||
pub struct libinput_event_tablet_pad(u8);
|
||||
#[repr(transparent)]
|
||||
pub struct libinput_tablet_pad_mode_group(u8);
|
||||
#[repr(transparent)]
|
||||
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")]
|
||||
unsafe extern "C" {
|
||||
pub fn libinput_log_set_handler(libinput: *mut libinput, log_handler: libinput_log_handler);
|
||||
pub fn libinput_log_set_priority(libinput: *mut libinput, priority: libinput_log_priority);
|
||||
pub fn libinput_path_create_context(
|
||||
interface: *const libinput_interface,
|
||||
user_data: *mut c::c_void,
|
||||
) -> *mut libinput;
|
||||
pub fn libinput_unref(libinput: *mut libinput) -> *mut libinput;
|
||||
pub fn libinput_get_fd(libinput: *mut libinput) -> c::c_int;
|
||||
pub fn libinput_dispatch(libinput: *mut libinput) -> c::c_int;
|
||||
pub fn libinput_get_event(libinput: *mut libinput) -> *mut libinput_event;
|
||||
|
||||
pub fn libinput_device_set_user_data(device: *mut libinput_device, user_data: *mut c::c_void);
|
||||
pub fn libinput_device_get_user_data(device: *mut libinput_device) -> *mut c::c_void;
|
||||
pub fn libinput_device_ref(device: *mut libinput_device) -> *mut libinput_device;
|
||||
pub fn libinput_device_unref(device: *mut libinput_device) -> *mut libinput_device;
|
||||
pub fn libinput_path_add_device(
|
||||
libinput: *mut libinput,
|
||||
path: *const c::c_char,
|
||||
) -> *mut libinput_device;
|
||||
pub fn libinput_path_remove_device(device: *mut libinput_device);
|
||||
pub fn libinput_device_has_capability(
|
||||
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,
|
||||
) -> 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_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_device_config_scroll_has_natural_scroll(
|
||||
device: *mut libinput_device,
|
||||
) -> c::c_int;
|
||||
|
||||
pub fn libinput_device_config_click_get_methods(device: *mut libinput_device) -> u32;
|
||||
pub fn libinput_device_config_click_get_method(
|
||||
device: *mut libinput_device,
|
||||
) -> libinput_config_click_method;
|
||||
pub fn libinput_device_config_click_set_method(
|
||||
device: *mut libinput_device,
|
||||
method: libinput_config_click_method,
|
||||
) -> libinput_config_status;
|
||||
|
||||
pub fn libinput_device_config_middle_emulation_set_enabled(
|
||||
device: *mut libinput_device,
|
||||
enable: libinput_config_middle_emulation_state,
|
||||
) -> libinput_config_status;
|
||||
pub fn libinput_device_config_middle_emulation_get_enabled(
|
||||
device: *mut libinput_device,
|
||||
) -> libinput_config_middle_emulation_state;
|
||||
pub fn libinput_device_config_middle_emulation_is_available(
|
||||
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;
|
||||
pub fn libinput_event_get_device(event: *mut libinput_event) -> *mut libinput_device;
|
||||
|
||||
pub fn libinput_event_get_keyboard_event(
|
||||
event: *mut libinput_event,
|
||||
) -> *mut libinput_event_keyboard;
|
||||
pub fn libinput_event_keyboard_get_key(event: *mut libinput_event_keyboard) -> u32;
|
||||
pub fn libinput_event_keyboard_get_key_state(
|
||||
event: *mut libinput_event_keyboard,
|
||||
) -> libinput_key_state;
|
||||
pub fn libinput_event_keyboard_get_time_usec(event: *mut libinput_event_keyboard) -> u64;
|
||||
|
||||
pub fn libinput_event_get_pointer_event(
|
||||
event: *mut libinput_event,
|
||||
) -> *mut libinput_event_pointer;
|
||||
pub fn libinput_event_pointer_get_time_usec(event: *mut libinput_event_pointer) -> u64;
|
||||
pub fn libinput_event_pointer_get_dx(event: *mut libinput_event_pointer) -> f64;
|
||||
pub fn libinput_event_pointer_get_dy(event: *mut libinput_event_pointer) -> f64;
|
||||
pub fn libinput_event_pointer_get_dx_unaccelerated(event: *mut libinput_event_pointer) -> f64;
|
||||
pub fn libinput_event_pointer_get_dy_unaccelerated(event: *mut libinput_event_pointer) -> f64;
|
||||
pub fn libinput_event_pointer_get_absolute_x_transformed(
|
||||
event: *mut libinput_event_pointer,
|
||||
width: u32,
|
||||
) -> f64;
|
||||
pub fn libinput_event_pointer_get_absolute_y_transformed(
|
||||
event: *mut libinput_event_pointer,
|
||||
height: u32,
|
||||
) -> f64;
|
||||
pub fn libinput_event_pointer_get_button(event: *mut libinput_event_pointer) -> u32;
|
||||
pub fn libinput_event_pointer_get_button_state(
|
||||
event: *mut libinput_event_pointer,
|
||||
) -> libinput_button_state;
|
||||
pub fn libinput_event_pointer_get_scroll_value(
|
||||
event: *mut libinput_event_pointer,
|
||||
axis: libinput_pointer_axis,
|
||||
) -> f64;
|
||||
pub fn libinput_event_pointer_get_scroll_value_v120(
|
||||
event: *mut libinput_event_pointer,
|
||||
axis: libinput_pointer_axis,
|
||||
) -> f64;
|
||||
pub fn libinput_event_pointer_has_axis(
|
||||
event: *mut libinput_event_pointer,
|
||||
axis: libinput_pointer_axis,
|
||||
) -> c::c_int;
|
||||
// pub fn libinput_event_pointer_get_axis_source(
|
||||
// event: *mut libinput_event_pointer,
|
||||
// ) -> libinput_pointer_axis_source;
|
||||
// pub fn libinput_event_pointer_get_axis_value_discrete(
|
||||
// event: *mut libinput_event_pointer,
|
||||
// axis: libinput_pointer_axis,
|
||||
// ) -> f64;
|
||||
|
||||
pub fn libinput_event_get_gesture_event(
|
||||
event: *mut libinput_event,
|
||||
) -> *mut libinput_event_gesture;
|
||||
pub fn libinput_event_gesture_get_time_usec(event: *mut libinput_event_gesture) -> u64;
|
||||
pub fn libinput_event_gesture_get_finger_count(event: *mut libinput_event_gesture) -> c::c_int;
|
||||
pub fn libinput_event_gesture_get_cancelled(event: *mut libinput_event_gesture) -> c::c_int;
|
||||
pub fn libinput_event_gesture_get_dx(event: *mut libinput_event_gesture) -> f64;
|
||||
pub fn libinput_event_gesture_get_dy(event: *mut libinput_event_gesture) -> f64;
|
||||
pub fn libinput_event_gesture_get_dx_unaccelerated(event: *mut libinput_event_gesture) -> f64;
|
||||
pub fn libinput_event_gesture_get_dy_unaccelerated(event: *mut libinput_event_gesture) -> f64;
|
||||
pub fn libinput_event_gesture_get_scale(event: *mut libinput_event_gesture) -> f64;
|
||||
pub fn libinput_event_gesture_get_angle_delta(event: *mut libinput_event_gesture) -> f64;
|
||||
|
||||
pub fn libinput_event_get_switch_event(
|
||||
event: *mut libinput_event,
|
||||
) -> *mut libinput_event_switch;
|
||||
pub fn libinput_event_switch_get_switch(event: *mut libinput_event_switch) -> libinput_switch;
|
||||
pub fn libinput_event_switch_get_switch_state(
|
||||
event: *mut libinput_event_switch,
|
||||
) -> libinput_switch_state;
|
||||
pub fn libinput_event_switch_get_time_usec(event: *mut libinput_event_switch) -> u64;
|
||||
|
||||
pub fn libinput_device_get_device_group(
|
||||
device: *mut libinput_device,
|
||||
) -> *mut libinput_device_group;
|
||||
pub fn libinput_device_group_set_user_data(group: *mut libinput_device_group, user_data: usize);
|
||||
pub fn libinput_device_group_get_user_data(group: *mut libinput_device_group) -> usize;
|
||||
|
||||
pub fn libinput_device_get_id_product(device: *mut libinput_device) -> c::c_uint;
|
||||
pub fn libinput_device_get_id_vendor(device: *mut libinput_device) -> c::c_uint;
|
||||
|
||||
pub fn libinput_event_get_tablet_tool_event(
|
||||
event: *mut libinput_event,
|
||||
) -> *mut libinput_event_tablet_tool;
|
||||
pub fn libinput_event_get_tablet_pad_event(
|
||||
event: *mut libinput_event,
|
||||
) -> *mut libinput_event_tablet_pad;
|
||||
pub fn libinput_event_tablet_tool_get_tool(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> *mut libinput_tablet_tool;
|
||||
pub fn libinput_event_tablet_pad_get_mode_group(
|
||||
event: *mut libinput_event_tablet_pad,
|
||||
) -> *mut libinput_tablet_pad_mode_group;
|
||||
pub fn libinput_event_tablet_tool_x_has_changed(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_event_tablet_tool_y_has_changed(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_event_tablet_tool_pressure_has_changed(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_event_tablet_tool_distance_has_changed(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_event_tablet_tool_tilt_x_has_changed(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_event_tablet_tool_tilt_y_has_changed(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_event_tablet_tool_rotation_has_changed(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_event_tablet_tool_slider_has_changed(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> c::c_int;
|
||||
// pub fn libinput_event_tablet_tool_size_major_has_changed(
|
||||
// event: *mut libinput_event_tablet_tool,
|
||||
// ) -> c::c_int;
|
||||
// pub fn libinput_event_tablet_tool_size_minor_has_changed(
|
||||
// event: *mut libinput_event_tablet_tool,
|
||||
// ) -> c::c_int;
|
||||
pub fn libinput_event_tablet_tool_wheel_has_changed(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> c::c_int;
|
||||
// pub fn libinput_event_tablet_tool_get_x(event: *mut libinput_event_tablet_tool) -> f64;
|
||||
// pub fn libinput_event_tablet_tool_get_y(event: *mut libinput_event_tablet_tool) -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_dx(event: *mut libinput_event_tablet_tool) -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_dy(event: *mut libinput_event_tablet_tool) -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_pressure(event: *mut libinput_event_tablet_tool) -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_distance(event: *mut libinput_event_tablet_tool) -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_tilt_x(event: *mut libinput_event_tablet_tool) -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_tilt_y(event: *mut libinput_event_tablet_tool) -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_rotation(event: *mut libinput_event_tablet_tool) -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_slider_position(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> f64;
|
||||
// pub fn libinput_event_tablet_tool_get_size_major(event: *mut libinput_event_tablet_tool)
|
||||
// -> f64;
|
||||
// pub fn libinput_event_tablet_tool_get_size_minor(event: *mut libinput_event_tablet_tool)
|
||||
// -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_wheel_delta(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_wheel_delta_discrete(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_event_tablet_tool_get_x_transformed(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
width: u32,
|
||||
) -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_y_transformed(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
width: u32,
|
||||
) -> f64;
|
||||
pub fn libinput_event_tablet_tool_get_proximity_state(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> libinput_tablet_tool_proximity_state;
|
||||
pub fn libinput_event_tablet_tool_get_tip_state(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> libinput_tablet_tool_tip_state;
|
||||
pub fn libinput_event_tablet_tool_get_button(event: *mut libinput_event_tablet_tool) -> u32;
|
||||
pub fn libinput_event_tablet_tool_get_button_state(
|
||||
event: *mut libinput_event_tablet_tool,
|
||||
) -> libinput_button_state;
|
||||
// pub fn libinput_event_tablet_tool_get_seat_button_count(
|
||||
// event: *mut libinput_event_tablet_tool,
|
||||
// ) -> u32;
|
||||
pub fn libinput_event_tablet_tool_get_time_usec(event: *mut libinput_event_tablet_tool) -> u64;
|
||||
pub fn libinput_tablet_tool_get_type(
|
||||
tool: *mut libinput_tablet_tool,
|
||||
) -> libinput_tablet_tool_type;
|
||||
pub fn libinput_tablet_tool_get_tool_id(tool: *mut libinput_tablet_tool) -> u64;
|
||||
pub fn libinput_tablet_tool_has_pressure(tool: *mut libinput_tablet_tool) -> c::c_int;
|
||||
pub fn libinput_tablet_tool_has_distance(tool: *mut libinput_tablet_tool) -> c::c_int;
|
||||
pub fn libinput_tablet_tool_has_tilt(tool: *mut libinput_tablet_tool) -> c::c_int;
|
||||
pub fn libinput_tablet_tool_has_rotation(tool: *mut libinput_tablet_tool) -> c::c_int;
|
||||
pub fn libinput_tablet_tool_has_slider(tool: *mut libinput_tablet_tool) -> c::c_int;
|
||||
// pub fn libinput_tablet_tool_has_size(tool: *mut libinput_tablet_tool) -> c::c_int;
|
||||
pub fn libinput_tablet_tool_has_wheel(tool: *mut libinput_tablet_tool) -> c::c_int;
|
||||
// pub fn libinput_tablet_tool_has_button(tool: *mut libinput_tablet_tool, code: u32) -> c::c_int;
|
||||
// pub fn libinput_tablet_tool_is_unique(tool: *mut libinput_tablet_tool) -> c::c_int;
|
||||
pub fn libinput_tablet_tool_get_serial(tool: *mut libinput_tablet_tool) -> u64;
|
||||
pub fn libinput_tablet_tool_get_user_data(tool: *mut libinput_tablet_tool) -> usize;
|
||||
pub fn libinput_tablet_tool_set_user_data(tool: *mut libinput_tablet_tool, user_data: usize);
|
||||
pub fn libinput_event_tablet_pad_get_ring_position(
|
||||
event: *mut libinput_event_tablet_pad,
|
||||
) -> f64;
|
||||
pub fn libinput_event_tablet_pad_get_ring_number(
|
||||
event: *mut libinput_event_tablet_pad,
|
||||
) -> c::c_uint;
|
||||
pub fn libinput_event_tablet_pad_get_ring_source(
|
||||
event: *mut libinput_event_tablet_pad,
|
||||
) -> libinput_tablet_pad_ring_axis_source;
|
||||
pub fn libinput_event_tablet_pad_get_strip_position(
|
||||
event: *mut libinput_event_tablet_pad,
|
||||
) -> f64;
|
||||
pub fn libinput_event_tablet_pad_get_strip_number(
|
||||
event: *mut libinput_event_tablet_pad,
|
||||
) -> c::c_uint;
|
||||
pub fn libinput_event_tablet_pad_get_strip_source(
|
||||
event: *mut libinput_event_tablet_pad,
|
||||
) -> libinput_tablet_pad_strip_axis_source;
|
||||
pub fn libinput_event_tablet_pad_get_button_number(
|
||||
event: *mut libinput_event_tablet_pad,
|
||||
) -> u32;
|
||||
pub fn libinput_event_tablet_pad_get_button_state(
|
||||
event: *mut libinput_event_tablet_pad,
|
||||
) -> libinput_button_state;
|
||||
// pub fn libinput_event_tablet_pad_get_key(event: *mut libinput_event_tablet_pad) -> u32;
|
||||
// pub fn libinput_event_tablet_pad_get_key_state(
|
||||
// event: *mut libinput_event_tablet_pad,
|
||||
// ) -> libinput_key_state;
|
||||
pub fn libinput_event_tablet_pad_get_mode(event: *mut libinput_event_tablet_pad) -> c::c_uint;
|
||||
pub fn libinput_event_tablet_pad_get_time_usec(event: *mut libinput_event_tablet_pad) -> u64;
|
||||
pub fn libinput_device_tablet_pad_get_mode_group(
|
||||
device: *mut libinput_device,
|
||||
index: c::c_uint,
|
||||
) -> *mut libinput_tablet_pad_mode_group;
|
||||
pub fn libinput_device_tablet_pad_get_num_mode_groups(device: *mut libinput_device)
|
||||
-> c::c_int;
|
||||
pub fn libinput_device_tablet_pad_get_num_buttons(device: *mut libinput_device) -> c::c_int;
|
||||
pub fn libinput_device_tablet_pad_get_num_rings(device: *mut libinput_device) -> c::c_int;
|
||||
pub fn libinput_device_tablet_pad_get_num_strips(device: *mut libinput_device) -> c::c_int;
|
||||
pub fn libinput_tablet_pad_mode_group_get_index(
|
||||
group: *mut libinput_tablet_pad_mode_group,
|
||||
) -> c::c_uint;
|
||||
pub fn libinput_tablet_pad_mode_group_get_num_modes(
|
||||
group: *mut libinput_tablet_pad_mode_group,
|
||||
) -> c::c_uint;
|
||||
pub fn libinput_tablet_pad_mode_group_get_mode(
|
||||
group: *mut libinput_tablet_pad_mode_group,
|
||||
) -> c::c_uint;
|
||||
pub fn libinput_tablet_pad_mode_group_has_button(
|
||||
group: *mut libinput_tablet_pad_mode_group,
|
||||
button: c::c_uint,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_tablet_pad_mode_group_has_ring(
|
||||
group: *mut libinput_tablet_pad_mode_group,
|
||||
ring: c::c_uint,
|
||||
) -> c::c_int;
|
||||
pub fn libinput_tablet_pad_mode_group_has_strip(
|
||||
group: *mut libinput_tablet_pad_mode_group,
|
||||
strip: c::c_uint,
|
||||
) -> c::c_int;
|
||||
// pub fn libinput_tablet_pad_mode_group_button_is_toggle(
|
||||
// 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;
|
||||
|
||||
pub fn libinput_device_led_update(device: *mut libinput_device, leds: libinput_led);
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct libinput_interface {
|
||||
pub open_restricted: unsafe extern "C" fn(
|
||||
path: *const c::c_char,
|
||||
flags: c::c_int,
|
||||
user_data: *mut c::c_void,
|
||||
) -> c::c_int,
|
||||
pub close_restricted: unsafe extern "C" fn(fd: c::c_int, user_data: *mut c::c_void),
|
||||
}
|
||||
|
||||
macro_rules! dynload {
|
||||
(
|
||||
$(
|
||||
fn $name:ident($($arg:ident: $ty:ty),* $(,)?) -> $ret:ty;
|
||||
)*
|
||||
) => {
|
||||
$(
|
||||
#[expect(non_upper_case_globals)]
|
||||
pub static $name: LazyLock<Option<unsafe extern "C" fn($($arg: $ty),*) -> $ret>> = LazyLock::new(|| {
|
||||
unsafe {
|
||||
Library::this()
|
||||
.get(concat!(stringify!($name), "\0").as_bytes())
|
||||
.ok()
|
||||
.map(|sym| *sym)
|
||||
}
|
||||
});
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
dynload! {
|
||||
fn libinput_device_get_id_bustype(device: *mut libinput_device) -> c::c_uint;
|
||||
|
||||
fn libinput_event_tablet_pad_get_dial_delta_v120(event: *mut libinput_event_tablet_pad) -> f64;
|
||||
|
||||
fn libinput_event_tablet_pad_get_dial_number(event: *mut libinput_event_tablet_pad) -> c::c_uint;
|
||||
|
||||
fn libinput_device_tablet_pad_get_num_dials(device: *mut libinput_device) -> c::c_int;
|
||||
|
||||
fn libinput_tablet_pad_mode_group_has_dial(
|
||||
group: *mut libinput_tablet_pad_mode_group,
|
||||
dial: c::c_uint,
|
||||
) -> c::c_int;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue