input: move capability conversion to libinput boundary
This commit is contained in:
parent
a20deb0628
commit
46d39becd4
5 changed files with 50 additions and 50 deletions
|
|
@ -84,6 +84,31 @@ impl StaticText for InputDeviceClickMethod {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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!(InputDeviceGroupIds, InputDeviceGroupId, usize);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@ use {
|
||||||
fixed::Fixed,
|
fixed::Fixed,
|
||||||
format::Format,
|
format::Format,
|
||||||
gfx_api::{FdSync, GfxApi, GfxFramebuffer},
|
gfx_api::{FdSync, GfxApi, GfxFramebuffer},
|
||||||
libinput::consts::DeviceCapability,
|
|
||||||
utils::static_text::StaticText,
|
|
||||||
video::drm::{
|
video::drm::{
|
||||||
ConnectorType, DRM_MODE_COLORIMETRY_BT2020_RGB, DRM_MODE_COLORIMETRY_DEFAULT,
|
ConnectorType, DRM_MODE_COLORIMETRY_BT2020_RGB, DRM_MODE_COLORIMETRY_DEFAULT,
|
||||||
DrmConnector, DrmError, DrmVersion, HDMI_EOTF_SMPTE_ST2084,
|
DrmConnector, DrmError, DrmVersion, HDMI_EOTF_SMPTE_ST2084,
|
||||||
|
|
@ -35,12 +33,13 @@ pub mod transaction;
|
||||||
pub use jay_output_types::OutputId;
|
pub use jay_output_types::OutputId;
|
||||||
|
|
||||||
pub use jay_input_types::{
|
pub use jay_input_types::{
|
||||||
AXIS_120, AxisSource, ButtonState, InputDeviceAccelProfile, InputDeviceClickMethod,
|
AXIS_120, AxisSource, ButtonState, InputDeviceAccelProfile, InputDeviceCapability,
|
||||||
InputDeviceGroupId, InputDeviceGroupIds, KeyState, Leds, PadButtonState, ScrollAxis, TabletId,
|
InputDeviceClickMethod, InputDeviceGroupId, InputDeviceGroupIds, KeyState, Leds,
|
||||||
TabletIds, TabletInit, TabletPadGroupInit, TabletPadId, TabletPadIds, TabletPadInit,
|
PadButtonState, ScrollAxis, TabletId, TabletIds, TabletInit, TabletPadGroupInit, TabletPadId,
|
||||||
TabletRingEventSource, TabletStripEventSource, TabletTool2dChange, TabletToolCapability,
|
TabletPadIds, TabletPadInit, TabletRingEventSource, TabletStripEventSource,
|
||||||
TabletToolChanges, TabletToolId, TabletToolIds, TabletToolInit, TabletToolPositionChange,
|
TabletTool2dChange, TabletToolCapability, TabletToolChanges, TabletToolId, TabletToolIds,
|
||||||
TabletToolType, TabletToolWheelChange, ToolButtonState,
|
TabletToolInit, TabletToolPositionChange, TabletToolType, TabletToolWheelChange,
|
||||||
|
ToolButtonState,
|
||||||
};
|
};
|
||||||
|
|
||||||
linear_ids!(ConnectorIds, ConnectorId);
|
linear_ids!(ConnectorIds, ConnectorId);
|
||||||
|
|
@ -274,46 +273,6 @@ pub trait InputDevice {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl InputDeviceCapability {
|
|
||||||
pub fn to_libinput(self) -> DeviceCapability {
|
|
||||||
use crate::libinput::consts::*;
|
|
||||||
match self {
|
|
||||||
InputDeviceCapability::Keyboard => LIBINPUT_DEVICE_CAP_KEYBOARD,
|
|
||||||
InputDeviceCapability::Pointer => LIBINPUT_DEVICE_CAP_POINTER,
|
|
||||||
InputDeviceCapability::Touch => LIBINPUT_DEVICE_CAP_TOUCH,
|
|
||||||
InputDeviceCapability::TabletTool => LIBINPUT_DEVICE_CAP_TABLET_TOOL,
|
|
||||||
InputDeviceCapability::TabletPad => LIBINPUT_DEVICE_CAP_TABLET_PAD,
|
|
||||||
InputDeviceCapability::Gesture => LIBINPUT_DEVICE_CAP_GESTURE,
|
|
||||||
InputDeviceCapability::Switch => LIBINPUT_DEVICE_CAP_SWITCH,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum BackendEvent {
|
pub enum BackendEvent {
|
||||||
NewDrmDevice(Rc<dyn BackendDrmDevice>),
|
NewDrmDevice(Rc<dyn BackendDrmDevice>),
|
||||||
NewConnector(Rc<dyn Connector>),
|
NewConnector(Rc<dyn Connector>),
|
||||||
|
|
|
||||||
|
|
@ -543,7 +543,7 @@ impl InputDevice for MetalInputDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_capability(&self, cap: InputDeviceCapability) -> bool {
|
fn has_capability(&self, cap: InputDeviceCapability) -> bool {
|
||||||
let li = cap.to_libinput();
|
let li = crate::libinput::device_capability(cap);
|
||||||
match self.inputdev.get() {
|
match self.inputdev.get() {
|
||||||
Some(dev) => dev.device().has_cap(li),
|
Some(dev) => dev.device().has_cap(li),
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ impl JayInput {
|
||||||
let mut caps = ArrayVec::<_, { InputDeviceCapability::LENGTH }>::new();
|
let mut caps = ArrayVec::<_, { InputDeviceCapability::LENGTH }>::new();
|
||||||
for cap in InputDeviceCapability::variants() {
|
for cap in InputDeviceCapability::variants() {
|
||||||
if data.data.device.has_capability(cap) {
|
if data.data.device.has_capability(cap) {
|
||||||
caps.push(cap.to_libinput().raw());
|
caps.push(crate::libinput::device_capability(cap).raw());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let dev = &data.data.device;
|
let dev = &data.data.device;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,17 @@
|
||||||
pub use jay_libinput::*;
|
pub use jay_libinput::*;
|
||||||
|
|
||||||
|
use crate::backend::InputDeviceCapability;
|
||||||
|
|
||||||
|
pub fn device_capability(cap: InputDeviceCapability) -> consts::DeviceCapability {
|
||||||
|
use consts::*;
|
||||||
|
|
||||||
|
match cap {
|
||||||
|
InputDeviceCapability::Keyboard => LIBINPUT_DEVICE_CAP_KEYBOARD,
|
||||||
|
InputDeviceCapability::Pointer => LIBINPUT_DEVICE_CAP_POINTER,
|
||||||
|
InputDeviceCapability::Touch => LIBINPUT_DEVICE_CAP_TOUCH,
|
||||||
|
InputDeviceCapability::TabletTool => LIBINPUT_DEVICE_CAP_TABLET_TOOL,
|
||||||
|
InputDeviceCapability::TabletPad => LIBINPUT_DEVICE_CAP_TABLET_PAD,
|
||||||
|
InputDeviceCapability::Gesture => LIBINPUT_DEVICE_CAP_GESTURE,
|
||||||
|
InputDeviceCapability::Switch => LIBINPUT_DEVICE_CAP_SWITCH,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue