Skip to content

Commit

Permalink
libei touch events
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Apr 25, 2024
1 parent ecc6529 commit 4b081e2
Showing 1 changed file with 67 additions and 9 deletions.
76 changes: 67 additions & 9 deletions src/backend/libei/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,9 @@ impl InputBackend for EiInput {
type GestureHoldBeginEvent = input::UnusedEvent;
type GestureHoldEndEvent = input::UnusedEvent;

// TODO
// type TouchDownEvent = request::TouchDown;
// type TouchUpEvent = request::TouchUp;
// type TouchMotionEvent = request::TouchMotion;
type TouchDownEvent = input::UnusedEvent;
type TouchUpEvent = input::UnusedEvent;
type TouchMotionEvent = input::UnusedEvent;
type TouchDownEvent = request::TouchDown;
type TouchUpEvent = request::TouchUp;
type TouchMotionEvent = request::TouchMotion;
type TouchCancelEvent = input::UnusedEvent; // XXX?
type TouchFrameEvent = input::UnusedEvent; // XXX

Expand Down Expand Up @@ -312,7 +308,62 @@ impl input::AbsolutePositionEvent<EiInput> for request::PointerMotionAbsolute {
}
}

// Want event source producing (among others?) InputEvent<LibinputInputBackend>
impl input::TouchDownEvent<EiInput> for request::TouchDown {}
impl input::TouchEvent<EiInput> for request::TouchDown {
fn slot(&self) -> input::TouchSlot {
Some(self.touch_id).into()
}
}
impl input::AbsolutePositionEvent<EiInput> for request::TouchDown {
fn x(&self) -> f64 {
self.x.into()
}

fn y(&self) -> f64 {
self.y.into()
}

fn x_transformed(&self, _width: i32) -> f64 {
// XXX ?
self.x.into()
}

fn y_transformed(&self, _height: i32) -> f64 {
self.y.into()
}
}

impl input::TouchUpEvent<EiInput> for request::TouchUp {}
impl input::TouchEvent<EiInput> for request::TouchUp {
fn slot(&self) -> input::TouchSlot {
Some(self.touch_id).into()
}
}

impl input::TouchMotionEvent<EiInput> for request::TouchMotion {}
impl input::TouchEvent<EiInput> for request::TouchMotion {
fn slot(&self) -> input::TouchSlot {
Some(self.touch_id).into()
}
}
impl input::AbsolutePositionEvent<EiInput> for request::TouchMotion {
fn x(&self) -> f64 {
self.x.into()
}

fn y(&self) -> f64 {
self.y.into()
}

fn x_transformed(&self, _width: i32) -> f64 {
// XXX ?
self.x.into()
}

fn y_transformed(&self, _height: i32) -> f64 {
self.y.into()
}
}

impl EventSource for EiInput {
type Event = InputEvent<EiInput>;
Expand Down Expand Up @@ -487,7 +538,14 @@ fn convert_request(request: EisRequest) -> Option<InputEvent<EiInput>> {
EisRequest::ScrollDiscrete(event) => Some(InputEvent::PointerAxis {
event: ScrollEvent::Discrete(event),
}),
_ => None,
EisRequest::TouchDown(event) => Some(InputEvent::TouchDown { event }),
EisRequest::TouchUp(event) => Some(InputEvent::TouchUp { event }),
EisRequest::TouchMotion(event) => Some(InputEvent::TouchMotion { event }),
EisRequest::Frame(_) => None, // TODO
EisRequest::Disconnect
| EisRequest::Bind(_)
| EisRequest::DeviceStartEmulating(_)
| EisRequest::DeviceStopEmulating(_) => None,
}
}

Expand Down

0 comments on commit 4b081e2

Please sign in to comment.