2024-09-29 15:49:45 +02:00
|
|
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
|
|
|
|
|
pub struct DeviceId(u32);
|
2024-08-08 00:36:36 +02:00
|
|
|
|
|
|
|
|
impl DeviceId {
|
2024-09-29 15:49:45 +02:00
|
|
|
pub fn new(pointer_id: i32) -> Option<Self> {
|
|
|
|
|
if let Ok(pointer_id) = u32::try_from(pointer_id) {
|
|
|
|
|
Some(Self(pointer_id))
|
|
|
|
|
} else if pointer_id == -1 {
|
|
|
|
|
None
|
|
|
|
|
} else {
|
|
|
|
|
tracing::error!("found unexpected negative `PointerEvent.pointerId`: {pointer_id}");
|
|
|
|
|
None
|
|
|
|
|
}
|
2024-08-08 00:36:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
|
|
|
pub struct FingerId {
|
|
|
|
|
pointer_id: i32,
|
|
|
|
|
primary: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl FingerId {
|
|
|
|
|
pub fn new(pointer_id: i32, primary: bool) -> Self {
|
|
|
|
|
Self { pointer_id, primary }
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-29 15:49:45 +02:00
|
|
|
#[cfg(test)]
|
2024-08-08 00:36:36 +02:00
|
|
|
pub const fn dummy() -> Self {
|
|
|
|
|
Self { pointer_id: -1, primary: false }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn is_primary(self) -> bool {
|
|
|
|
|
self.primary
|
|
|
|
|
}
|
|
|
|
|
}
|