Skip to content

Commit 4b081e2

Browse files
committed
libei touch events
1 parent ecc6529 commit 4b081e2

File tree

1 file changed

+67
-9
lines changed

1 file changed

+67
-9
lines changed

src/backend/libei/mod.rs

+67-9
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,9 @@ impl InputBackend for EiInput {
117117
type GestureHoldBeginEvent = input::UnusedEvent;
118118
type GestureHoldEndEvent = input::UnusedEvent;
119119

120-
// TODO
121-
// type TouchDownEvent = request::TouchDown;
122-
// type TouchUpEvent = request::TouchUp;
123-
// type TouchMotionEvent = request::TouchMotion;
124-
type TouchDownEvent = input::UnusedEvent;
125-
type TouchUpEvent = input::UnusedEvent;
126-
type TouchMotionEvent = input::UnusedEvent;
120+
type TouchDownEvent = request::TouchDown;
121+
type TouchUpEvent = request::TouchUp;
122+
type TouchMotionEvent = request::TouchMotion;
127123
type TouchCancelEvent = input::UnusedEvent; // XXX?
128124
type TouchFrameEvent = input::UnusedEvent; // XXX
129125

@@ -312,7 +308,62 @@ impl input::AbsolutePositionEvent<EiInput> for request::PointerMotionAbsolute {
312308
}
313309
}
314310

315-
// Want event source producing (among others?) InputEvent<LibinputInputBackend>
311+
impl input::TouchDownEvent<EiInput> for request::TouchDown {}
312+
impl input::TouchEvent<EiInput> for request::TouchDown {
313+
fn slot(&self) -> input::TouchSlot {
314+
Some(self.touch_id).into()
315+
}
316+
}
317+
impl input::AbsolutePositionEvent<EiInput> for request::TouchDown {
318+
fn x(&self) -> f64 {
319+
self.x.into()
320+
}
321+
322+
fn y(&self) -> f64 {
323+
self.y.into()
324+
}
325+
326+
fn x_transformed(&self, _width: i32) -> f64 {
327+
// XXX ?
328+
self.x.into()
329+
}
330+
331+
fn y_transformed(&self, _height: i32) -> f64 {
332+
self.y.into()
333+
}
334+
}
335+
336+
impl input::TouchUpEvent<EiInput> for request::TouchUp {}
337+
impl input::TouchEvent<EiInput> for request::TouchUp {
338+
fn slot(&self) -> input::TouchSlot {
339+
Some(self.touch_id).into()
340+
}
341+
}
342+
343+
impl input::TouchMotionEvent<EiInput> for request::TouchMotion {}
344+
impl input::TouchEvent<EiInput> for request::TouchMotion {
345+
fn slot(&self) -> input::TouchSlot {
346+
Some(self.touch_id).into()
347+
}
348+
}
349+
impl input::AbsolutePositionEvent<EiInput> for request::TouchMotion {
350+
fn x(&self) -> f64 {
351+
self.x.into()
352+
}
353+
354+
fn y(&self) -> f64 {
355+
self.y.into()
356+
}
357+
358+
fn x_transformed(&self, _width: i32) -> f64 {
359+
// XXX ?
360+
self.x.into()
361+
}
362+
363+
fn y_transformed(&self, _height: i32) -> f64 {
364+
self.y.into()
365+
}
366+
}
316367

317368
impl EventSource for EiInput {
318369
type Event = InputEvent<EiInput>;
@@ -487,7 +538,14 @@ fn convert_request(request: EisRequest) -> Option<InputEvent<EiInput>> {
487538
EisRequest::ScrollDiscrete(event) => Some(InputEvent::PointerAxis {
488539
event: ScrollEvent::Discrete(event),
489540
}),
490-
_ => None,
541+
EisRequest::TouchDown(event) => Some(InputEvent::TouchDown { event }),
542+
EisRequest::TouchUp(event) => Some(InputEvent::TouchUp { event }),
543+
EisRequest::TouchMotion(event) => Some(InputEvent::TouchMotion { event }),
544+
EisRequest::Frame(_) => None, // TODO
545+
EisRequest::Disconnect
546+
| EisRequest::Bind(_)
547+
| EisRequest::DeviceStartEmulating(_)
548+
| EisRequest::DeviceStopEmulating(_) => None,
491549
}
492550
}
493551

0 commit comments

Comments
 (0)