1
0
Fork 0
forked from wry/wry

input: move shared types into workspace crate

This commit is contained in:
kossLAN 2026-05-29 12:03:45 -04:00
parent 54aefd8c41
commit 151dc313ba
No known key found for this signature in database
5 changed files with 126 additions and 70 deletions

9
Cargo.lock generated
View file

@ -738,6 +738,7 @@ dependencies = [
"jay-formats",
"jay-geometry",
"jay-gfx-types",
"jay-input-types",
"jay-io-uring",
"jay-layout-animation",
"jay-libinput",
@ -908,6 +909,14 @@ dependencies = [
"uapi",
]
[[package]]
name = "jay-input-types"
version = "0.1.0"
dependencies = [
"jay-utils",
"linearize",
]
[[package]]
name = "jay-io-uring"
version = "0.1.0"

View file

@ -43,6 +43,7 @@ members = [
"bugs",
"logger",
"video-types",
"input-types",
"gfx-types",
"theme",
"clientmem",
@ -97,6 +98,7 @@ jay-pr-caps = { version = "0.1.0", path = "pr-caps" }
jay-bugs = { version = "0.1.0", path = "bugs" }
jay-logger = { version = "0.1.0", path = "logger" }
jay-video-types = { version = "0.1.0", path = "video-types" }
jay-input-types = { version = "0.1.0", path = "input-types" }
jay-gfx-types = { version = "0.1.0", path = "gfx-types" }
jay-theme = { version = "0.1.0", path = "theme" }
jay-clientmem = { version = "0.1.0", path = "clientmem" }

12
input-types/Cargo.toml Normal file
View file

@ -0,0 +1,12 @@
[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-utils = { version = "0.1.0", path = "../utils" }
linearize = { version = "0.1.3", features = ["derive"] }

98
input-types/src/lib.rs Normal file
View file

@ -0,0 +1,98 @@
use {
jay_utils::static_text::StaticText,
linearize::Linearize,
std::ops::{BitOr, BitOrAssign},
};
#[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, 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;
}
}

View file

@ -18,7 +18,6 @@ use {
TabletStripEventSource, TabletToolChanges, TabletToolId, TabletToolInit,
ToolButtonState,
},
wl_pointer::{CONTINUOUS, FINGER, HORIZONTAL_SCROLL, VERTICAL_SCROLL, WHEEL},
},
},
libinput::consts::DeviceCapability,
@ -43,6 +42,11 @@ use {
pub mod transaction;
pub use jay_input_types::{
AXIS_120, AxisSource, ButtonState, InputDeviceAccelProfile, InputDeviceClickMethod, KeyState,
LED_CAPS_LOCK, LED_COMPOSE, LED_KANA, LED_NUM_LOCK, LED_SCROLL_LOCK, Leds, ScrollAxis,
};
linear_ids!(ConnectorIds, ConnectorId);
linear_ids!(InputDeviceIds, InputDeviceId);
linear_ids!(DrmDeviceIds, DrmDeviceId);
@ -316,38 +320,6 @@ impl InputDeviceCapability {
}
}
#[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",
}
}
}
pub enum BackendEvent {
NewDrmDevice(Rc<dyn BackendDrmDevice>),
NewConnector(Rc<dyn Connector>),
@ -355,43 +327,6 @@ pub enum BackendEvent {
DevicesEnumerated,
}
#[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 {
Horizontal = HORIZONTAL_SCROLL as _,
Vertical = VERTICAL_SCROLL as _,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum AxisSource {
Wheel = WHEEL as _,
Finger = FINGER as _,
Continuous = CONTINUOUS as _,
}
pub const AXIS_120: i32 = 120;
bitflags! {
Leds: u32;
LED_NUM_LOCK,
LED_CAPS_LOCK,
LED_SCROLL_LOCK,
LED_COMPOSE,
LED_KANA,
}
#[derive(Debug)]
pub enum InputEvent {
Key {