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

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;
}
}