input: move backend events into type crate
This commit is contained in:
parent
03f35d7944
commit
524836bef3
7 changed files with 208 additions and 191 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -915,6 +915,8 @@ dependencies = [
|
|||
name = "jay-input-types"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"jay-output-types",
|
||||
"jay-units",
|
||||
"jay-utils",
|
||||
"linearize",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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"] }
|
||||
|
|
|
|||
|
|
@ -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<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,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
185
src/backend.rs
185
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<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,
|
||||
},
|
||||
}
|
||||
|
||||
pub enum DrmEvent {
|
||||
#[expect(dead_code)]
|
||||
Removed,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<SeatId, Rc<WlSeatGlobal>, 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue