refactor: split cargo workspace
This commit is contained in:
parent
5db14936e7
commit
1c21bd1259
695 changed files with 32023 additions and 44964 deletions
14
crates/input-types/Cargo.toml
Normal file
14
crates/input-types/Cargo.toml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "jay-input-types"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "GPL-3.0-only"
|
||||
description = "Input data types for the Jay compositor"
|
||||
repository = "https://github.com/mahkoh/jay"
|
||||
|
||||
[dependencies]
|
||||
jay-output-types = { version = "0.1.0", path = "../output-types" }
|
||||
jay-units = { version = "0.1.0", path = "../units" }
|
||||
jay-utils = { version = "0.1.0", path = "../utils" }
|
||||
|
||||
linearize = { version = "0.1.3", features = ["derive"] }
|
||||
482
crates/input-types/src/lib.rs
Normal file
482
crates/input-types/src/lib.rs
Normal file
|
|
@ -0,0 +1,482 @@
|
|||
use {
|
||||
jay_output_types::ConnectorId,
|
||||
jay_units::Fixed,
|
||||
jay_utils::{numcell::NumCell, static_text::StaticText},
|
||||
linearize::Linearize,
|
||||
std::{
|
||||
fmt::{Display, Formatter},
|
||||
ops::{BitOr, BitOrAssign},
|
||||
},
|
||||
};
|
||||
|
||||
macro_rules! linear_ids {
|
||||
($ids:ident, $id:ident $(,)?) => {
|
||||
linear_ids!($ids, $id, u32);
|
||||
};
|
||||
($ids:ident, $id:ident, $ty:ty $(,)?) => {
|
||||
#[derive(Debug)]
|
||||
pub struct $ids {
|
||||
next: NumCell<$ty>,
|
||||
}
|
||||
|
||||
impl Default for $ids {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
next: NumCell::new(1),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl $ids {
|
||||
pub fn next(&self) -> $id {
|
||||
$id(self.next.fetch_add(1))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||
pub struct $id($ty);
|
||||
|
||||
impl $id {
|
||||
pub fn raw(&self) -> $ty {
|
||||
self.0
|
||||
}
|
||||
|
||||
pub fn from_raw(id: $ty) -> Self {
|
||||
Self(id)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for $id {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
Display::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Linearize)]
|
||||
pub enum InputDeviceAccelProfile {
|
||||
Flat,
|
||||
Adaptive,
|
||||
}
|
||||
|
||||
impl StaticText for InputDeviceAccelProfile {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
InputDeviceAccelProfile::Flat => "Flat",
|
||||
InputDeviceAccelProfile::Adaptive => "Adaptive",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Linearize)]
|
||||
pub enum InputDeviceClickMethod {
|
||||
None,
|
||||
ButtonAreas,
|
||||
Clickfinger,
|
||||
}
|
||||
|
||||
impl StaticText for InputDeviceClickMethod {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
InputDeviceClickMethod::None => "none",
|
||||
InputDeviceClickMethod::ButtonAreas => "button-areas",
|
||||
InputDeviceClickMethod::Clickfinger => "clickfinger",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Linearize)]
|
||||
pub enum InputDeviceCapability {
|
||||
Keyboard,
|
||||
Pointer,
|
||||
Touch,
|
||||
TabletTool,
|
||||
TabletPad,
|
||||
Gesture,
|
||||
Switch,
|
||||
}
|
||||
|
||||
impl StaticText for InputDeviceCapability {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
InputDeviceCapability::Keyboard => "keyboard",
|
||||
InputDeviceCapability::Pointer => "pointer",
|
||||
InputDeviceCapability::Touch => "touch",
|
||||
InputDeviceCapability::TabletTool => "tablet tool",
|
||||
InputDeviceCapability::TabletPad => "tablet pad",
|
||||
InputDeviceCapability::Gesture => "gesture",
|
||||
InputDeviceCapability::Switch => "switch",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
linear_ids!(InputDeviceGroupIds, InputDeviceGroupId, usize);
|
||||
linear_ids!(InputDeviceIds, InputDeviceId);
|
||||
|
||||
pub type TransformMatrix = [[f64; 2]; 2];
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub enum KeyState {
|
||||
Released,
|
||||
Pressed,
|
||||
Repeated,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub enum ButtonState {
|
||||
Released,
|
||||
Pressed,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Linearize)]
|
||||
pub enum ScrollAxis {
|
||||
Vertical = 0,
|
||||
Horizontal = 1,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub enum AxisSource {
|
||||
Wheel,
|
||||
Finger,
|
||||
Continuous,
|
||||
}
|
||||
|
||||
pub const AXIS_120: i32 = 120;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq)]
|
||||
pub struct Leds(pub u32);
|
||||
|
||||
pub const LED_NUM_LOCK: Leds = Leds(1 << 0);
|
||||
pub const LED_CAPS_LOCK: Leds = Leds(1 << 1);
|
||||
pub const LED_SCROLL_LOCK: Leds = Leds(1 << 2);
|
||||
pub const LED_COMPOSE: Leds = Leds(1 << 3);
|
||||
pub const LED_KANA: Leds = Leds(1 << 4);
|
||||
|
||||
impl Leds {
|
||||
pub const fn none() -> Self {
|
||||
Self(0)
|
||||
}
|
||||
|
||||
pub const fn raw(self) -> u32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl BitOr for Leds {
|
||||
type Output = Self;
|
||||
|
||||
fn bitor(self, rhs: Self) -> Self::Output {
|
||||
Self(self.0 | rhs.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl BitOrAssign for Leds {
|
||||
fn bitor_assign(&mut self, rhs: Self) {
|
||||
self.0 |= rhs.0;
|
||||
}
|
||||
}
|
||||
|
||||
linear_ids!(TabletIds, TabletId);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TabletInit {
|
||||
pub id: TabletId,
|
||||
pub group: InputDeviceGroupId,
|
||||
pub name: String,
|
||||
pub pid: u32,
|
||||
pub vid: u32,
|
||||
pub bustype: Option<u32>,
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
linear_ids!(TabletToolIds, TabletToolId, usize);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TabletToolInit {
|
||||
pub tablet_id: TabletId,
|
||||
pub id: TabletToolId,
|
||||
pub type_: TabletToolType,
|
||||
pub hardware_serial: u64,
|
||||
pub hardware_id_wacom: u64,
|
||||
pub capabilities: Vec<TabletToolCapability>,
|
||||
}
|
||||
|
||||
linear_ids!(TabletPadIds, TabletPadId);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TabletPadInit {
|
||||
pub id: TabletPadId,
|
||||
pub group: InputDeviceGroupId,
|
||||
pub path: String,
|
||||
pub buttons: u32,
|
||||
pub strips: u32,
|
||||
pub rings: u32,
|
||||
pub dials: u32,
|
||||
pub groups: Vec<TabletPadGroupInit>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TabletPadGroupInit {
|
||||
pub buttons: Vec<u32>,
|
||||
pub rings: Vec<u32>,
|
||||
pub strips: Vec<u32>,
|
||||
pub dials: Vec<u32>,
|
||||
pub modes: u32,
|
||||
pub mode: u32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum PadButtonState {
|
||||
Released,
|
||||
Pressed,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum ToolButtonState {
|
||||
Released,
|
||||
Pressed,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum TabletToolType {
|
||||
Pen,
|
||||
Eraser,
|
||||
Brush,
|
||||
Pencil,
|
||||
Airbrush,
|
||||
Finger,
|
||||
Mouse,
|
||||
Lens,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum TabletToolCapability {
|
||||
Tilt,
|
||||
Pressure,
|
||||
Distance,
|
||||
Rotation,
|
||||
Slider,
|
||||
Wheel,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum TabletRingEventSource {
|
||||
Finger,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum TabletStripEventSource {
|
||||
Finger,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct TabletToolChanges {
|
||||
pub down: Option<bool>,
|
||||
pub pos: Option<TabletTool2dChange<TabletToolPositionChange>>,
|
||||
pub pressure: Option<f64>,
|
||||
pub distance: Option<f64>,
|
||||
pub tilt: Option<TabletTool2dChange<f64>>,
|
||||
pub rotation: Option<f64>,
|
||||
pub slider: Option<f64>,
|
||||
pub wheel: Option<TabletToolWheelChange>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct TabletTool2dChange<T> {
|
||||
pub x: T,
|
||||
pub y: T,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct TabletToolPositionChange {
|
||||
pub x: f64,
|
||||
pub dx: f64,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct TabletToolWheelChange {
|
||||
pub degrees: f64,
|
||||
pub clicks: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum SwitchEvent {
|
||||
LidOpened,
|
||||
LidClosed,
|
||||
ConvertedToLaptop,
|
||||
ConvertedToTablet,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum InputEvent {
|
||||
Key {
|
||||
time_usec: u64,
|
||||
key: u32,
|
||||
state: KeyState,
|
||||
},
|
||||
ConnectorPosition {
|
||||
time_usec: u64,
|
||||
connector: ConnectorId,
|
||||
x: Fixed,
|
||||
y: Fixed,
|
||||
},
|
||||
Motion {
|
||||
time_usec: u64,
|
||||
dx: Fixed,
|
||||
dy: Fixed,
|
||||
dx_unaccelerated: Fixed,
|
||||
dy_unaccelerated: Fixed,
|
||||
},
|
||||
MotionAbsolute {
|
||||
time_usec: u64,
|
||||
x_normed: f32,
|
||||
y_normed: f32,
|
||||
},
|
||||
Button {
|
||||
time_usec: u64,
|
||||
button: u32,
|
||||
state: ButtonState,
|
||||
},
|
||||
|
||||
AxisPx {
|
||||
dist: Fixed,
|
||||
axis: ScrollAxis,
|
||||
inverted: bool,
|
||||
},
|
||||
AxisSource {
|
||||
source: AxisSource,
|
||||
},
|
||||
AxisStop {
|
||||
axis: ScrollAxis,
|
||||
},
|
||||
Axis120 {
|
||||
dist: i32,
|
||||
axis: ScrollAxis,
|
||||
inverted: bool,
|
||||
},
|
||||
AxisFrame {
|
||||
time_usec: u64,
|
||||
},
|
||||
SwipeBegin {
|
||||
time_usec: u64,
|
||||
finger_count: u32,
|
||||
},
|
||||
SwipeUpdate {
|
||||
time_usec: u64,
|
||||
dx: Fixed,
|
||||
dy: Fixed,
|
||||
dx_unaccelerated: Fixed,
|
||||
dy_unaccelerated: Fixed,
|
||||
},
|
||||
SwipeEnd {
|
||||
time_usec: u64,
|
||||
cancelled: bool,
|
||||
},
|
||||
PinchBegin {
|
||||
time_usec: u64,
|
||||
finger_count: u32,
|
||||
},
|
||||
PinchUpdate {
|
||||
time_usec: u64,
|
||||
dx: Fixed,
|
||||
dy: Fixed,
|
||||
dx_unaccelerated: Fixed,
|
||||
dy_unaccelerated: Fixed,
|
||||
scale: Fixed,
|
||||
rotation: Fixed,
|
||||
},
|
||||
PinchEnd {
|
||||
time_usec: u64,
|
||||
cancelled: bool,
|
||||
},
|
||||
HoldBegin {
|
||||
time_usec: u64,
|
||||
finger_count: u32,
|
||||
},
|
||||
HoldEnd {
|
||||
time_usec: u64,
|
||||
cancelled: bool,
|
||||
},
|
||||
|
||||
SwitchEvent {
|
||||
time_usec: u64,
|
||||
event: SwitchEvent,
|
||||
},
|
||||
|
||||
TabletToolAdded {
|
||||
time_usec: u64,
|
||||
init: Box<TabletToolInit>,
|
||||
},
|
||||
TabletToolChanged {
|
||||
time_usec: u64,
|
||||
id: TabletToolId,
|
||||
changes: Box<TabletToolChanges>,
|
||||
},
|
||||
TabletToolButton {
|
||||
time_usec: u64,
|
||||
id: TabletToolId,
|
||||
button: u32,
|
||||
state: ToolButtonState,
|
||||
},
|
||||
TabletToolRemoved {
|
||||
time_usec: u64,
|
||||
id: TabletToolId,
|
||||
},
|
||||
|
||||
TabletPadButton {
|
||||
time_usec: u64,
|
||||
id: TabletPadId,
|
||||
button: u32,
|
||||
state: PadButtonState,
|
||||
},
|
||||
TabletPadModeSwitch {
|
||||
time_usec: u64,
|
||||
pad: TabletPadId,
|
||||
group: u32,
|
||||
mode: u32,
|
||||
},
|
||||
TabletPadRing {
|
||||
time_usec: u64,
|
||||
pad: TabletPadId,
|
||||
ring: u32,
|
||||
source: Option<TabletRingEventSource>,
|
||||
angle: Option<f64>,
|
||||
},
|
||||
TabletPadStrip {
|
||||
time_usec: u64,
|
||||
pad: TabletPadId,
|
||||
strip: u32,
|
||||
source: Option<TabletStripEventSource>,
|
||||
position: Option<f64>,
|
||||
},
|
||||
TabletPadDial {
|
||||
time_usec: u64,
|
||||
pad: TabletPadId,
|
||||
dial: u32,
|
||||
value120: i32,
|
||||
},
|
||||
TouchDown {
|
||||
time_usec: u64,
|
||||
id: i32,
|
||||
x_normed: Fixed,
|
||||
y_normed: Fixed,
|
||||
},
|
||||
TouchUp {
|
||||
time_usec: u64,
|
||||
id: i32,
|
||||
},
|
||||
TouchMotion {
|
||||
time_usec: u64,
|
||||
id: i32,
|
||||
x_normed: Fixed,
|
||||
y_normed: Fixed,
|
||||
},
|
||||
TouchCancel {
|
||||
time_usec: u64,
|
||||
id: i32,
|
||||
},
|
||||
TouchFrame {
|
||||
time_usec: u64,
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue