diff --git a/Cargo.lock b/Cargo.lock index 584b04d6..64bcda38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -915,6 +915,8 @@ dependencies = [ name = "jay-input-types" version = "0.1.0" dependencies = [ + "jay-output-types", + "jay-units", "jay-utils", "linearize", ] diff --git a/input-types/Cargo.toml b/input-types/Cargo.toml index 9d58f348..6dafe60b 100644 --- a/input-types/Cargo.toml +++ b/input-types/Cargo.toml @@ -7,6 +7,8 @@ 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"] } diff --git a/input-types/src/lib.rs b/input-types/src/lib.rs index c2537fde..ee58c13f 100644 --- a/input-types/src/lib.rs +++ b/input-types/src/lib.rs @@ -1,4 +1,6 @@ use { + jay_output_types::ConnectorId, + jay_units::Fixed, jay_utils::{numcell::NumCell, static_text::StaticText}, linearize::Linearize, std::{ @@ -297,3 +299,184 @@ 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, + }, + TabletToolChanged { + time_usec: u64, + id: TabletToolId, + changes: Box, + }, + 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, + angle: Option, + }, + TabletPadStrip { + time_usec: u64, + pad: TabletPadId, + strip: u32, + source: Option, + position: Option, + }, + 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, + }, +} diff --git a/src/backend.rs b/src/backend.rs index bca16b22..31da3cfb 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -6,12 +6,10 @@ use { BackendConnectorTransactionType, BackendConnectorTransactionTypeDyn, }, drm_feedback::DrmFeedback, - fixed::Fixed, format::Format, gfx_api::{FdSync, GfxApi, GfxFramebuffer}, video::drm::{ConnectorType, DrmConnector, DrmError, DrmVersion}, }, - jay_config::input::SwitchEvent, std::{ any::Any, error::Error, @@ -34,11 +32,11 @@ pub use jay_output_types::{ pub use jay_input_types::{ AXIS_120, AxisSource, ButtonState, InputDeviceAccelProfile, InputDeviceCapability, InputDeviceClickMethod, InputDeviceGroupId, InputDeviceGroupIds, InputDeviceId, - InputDeviceIds, KeyState, Leds, PadButtonState, ScrollAxis, TabletId, TabletIds, TabletInit, - TabletPadGroupInit, TabletPadId, TabletPadIds, TabletPadInit, TabletRingEventSource, - TabletStripEventSource, TabletTool2dChange, TabletToolCapability, TabletToolChanges, - TabletToolId, TabletToolIds, TabletToolInit, TabletToolPositionChange, TabletToolType, - TabletToolWheelChange, ToolButtonState, TransformMatrix, + InputDeviceIds, InputEvent, KeyState, Leds, PadButtonState, ScrollAxis, SwitchEvent, TabletId, + TabletIds, TabletInit, TabletPadGroupInit, TabletPadId, TabletPadIds, TabletPadInit, + TabletRingEventSource, TabletStripEventSource, TabletTool2dChange, TabletToolCapability, + TabletToolChanges, TabletToolId, TabletToolIds, TabletToolInit, TabletToolPositionChange, + TabletToolType, TabletToolWheelChange, ToolButtonState, TransformMatrix, }; pub trait Backend: Any { @@ -218,179 +216,6 @@ pub enum BackendEvent { DevicesEnumerated, } -#[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, - }, - TabletToolChanged { - time_usec: u64, - id: TabletToolId, - changes: Box, - }, - 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, - angle: Option, - }, - TabletPadStrip { - time_usec: u64, - pad: TabletPadId, - strip: u32, - source: Option, - position: Option, - }, - 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, - }, -} - pub enum DrmEvent { #[expect(dead_code)] Removed, diff --git a/src/backends/metal/input.rs b/src/backends/metal/input.rs index 3e9d8107..eea033e1 100644 --- a/src/backends/metal/input.rs +++ b/src/backends/metal/input.rs @@ -2,7 +2,7 @@ use { crate::{ backend::{ AxisSource, ButtonState, InputEvent, KeyState, PadButtonState, ScrollAxis, - TabletRingEventSource, TabletStripEventSource, TabletTool2dChange, + SwitchEvent, TabletRingEventSource, TabletStripEventSource, TabletTool2dChange, TabletToolCapability, TabletToolChanges, TabletToolId, TabletToolInit, TabletToolPositionChange, TabletToolType, TabletToolWheelChange, ToolButtonState, }, @@ -25,7 +25,6 @@ use { }, utils::{bitflags::BitflagsExt, errorfmt::ErrorFmt}, }, - jay_config::input::SwitchEvent, std::rc::Rc, uapi::c, }; diff --git a/src/ifs/jay_seat_events.rs b/src/ifs/jay_seat_events.rs index 144d0b1e..8757608b 100644 --- a/src/ifs/jay_seat_events.rs +++ b/src/ifs/jay_seat_events.rs @@ -234,7 +234,7 @@ impl JaySeatEvents { seat: SeatId, input_device: InputDeviceId, time_usec: u64, - event: jay_config::input::SwitchEvent, + event: crate::backend::SwitchEvent, ) { self.client.event(SwitchEvent { self_id: self.id, diff --git a/src/ifs/wl_seat/event_handling.rs b/src/ifs/wl_seat/event_handling.rs index 877151c4..8d19ac5f 100644 --- a/src/ifs/wl_seat/event_handling.rs +++ b/src/ifs/wl_seat/event_handling.rs @@ -2,7 +2,7 @@ use { crate::{ backend::{ AXIS_120, AxisSource, ButtonState, ConnectorId, InputDeviceId, InputEvent, KeyState, - ScrollAxis, + ScrollAxis, SwitchEvent, }, client::ClientId, config::InvokedShortcut, @@ -52,12 +52,9 @@ use { }, CursorPositionType::Motion, isnt::std_1::primitive::IsntSliceExt, - jay_config::{ - input::SwitchEvent, - keyboard::{ - mods::{CAPS, Modifiers, NUM, RELEASE}, - syms::KeySym, - }, + jay_config::keyboard::{ + mods::{CAPS, Modifiers, NUM, RELEASE}, + syms::KeySym, }, kbvm::{Keycode, ModifierMask, evdev, state_machine::Event}, linearize::LinearizeExt, @@ -70,6 +67,15 @@ use { }, }; +fn config_switch_event(event: SwitchEvent) -> jay_config::input::SwitchEvent { + match event { + SwitchEvent::LidOpened => jay_config::input::SwitchEvent::LidOpened, + SwitchEvent::LidClosed => jay_config::input::SwitchEvent::LidClosed, + SwitchEvent::ConvertedToLaptop => jay_config::input::SwitchEvent::ConvertedToLaptop, + SwitchEvent::ConvertedToTablet => jay_config::input::SwitchEvent::ConvertedToTablet, + } +} + #[derive(Default)] pub struct NodeSeatState { pointer_foci: SmallMap, 1>, @@ -816,7 +822,7 @@ impl WlSeatGlobal { t.send_switch_event(self.id, dev, time_usec, event); }); if let Some(config) = self.state.config.get() { - config.switch_event(self.id, dev, event); + config.switch_event(self.id, dev, config_switch_event(event)); } }