-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wayland: implement wl_touch #177
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,6 +231,23 @@ pub enum KeyState { | |
Pressed, | ||
} | ||
|
||
#[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
pub struct TouchPosition { | ||
pub x: Fixed, | ||
pub y: Fixed, | ||
pub x_transformed: Fixed, | ||
pub y_transformed: Fixed, | ||
} | ||
|
||
#[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
pub enum TouchEvent { | ||
Down { pos: TouchPosition }, | ||
Up, | ||
Motion { pos: TouchPosition }, | ||
Cancel, | ||
Frame, | ||
} | ||
|
||
#[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
pub enum ScrollAxis { | ||
Horizontal = HORIZONTAL_SCROLL as _, | ||
|
@@ -272,6 +289,12 @@ pub enum InputEvent { | |
state: KeyState, | ||
}, | ||
|
||
Touch { | ||
seat_slot: i32, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be named something else due to the existing meaning of seat. |
||
time_usec: u64, | ||
event: TouchEvent, | ||
}, | ||
|
||
AxisPx { | ||
dist: Fixed, | ||
axis: ScrollAxis, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ use { | |
TabletPadStripSource, TabletPadStripStop, TabletToolButton, TabletToolDistance, | ||
TabletToolDown, TabletToolFrame, TabletToolMotion, TabletToolPressure, | ||
TabletToolProximityIn, TabletToolProximityOut, TabletToolRotation, | ||
TabletToolSlider, TabletToolTilt, TabletToolUp, TabletToolWheel, | ||
TabletToolSlider, TabletToolTilt, TabletToolUp, TabletToolWheel, TouchCancel, | ||
TouchDown, TouchFrame, TouchMotion, TouchUp, | ||
}, | ||
}, | ||
}, | ||
|
@@ -583,6 +584,63 @@ async fn run(seat_test: Rc<SeatTest>) { | |
} | ||
println!(); | ||
}); | ||
let st = seat_test.clone(); | ||
TouchDown::handle(tc, se, (), move |_, ev| { | ||
if all || ev.seat == seat { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The events should be collected and only be printed on the next frame event. Similar to the tablet frame event. |
||
if all { | ||
print!("Seat: {}, ", st.name(ev.seat)); | ||
} | ||
println!( | ||
"Time: {:.4}, Touch: {}, Down: {}x{}", | ||
time(ev.time_usec), | ||
ev.id, | ||
ev.x, | ||
ev.y | ||
); | ||
} | ||
}); | ||
let st = seat_test.clone(); | ||
TouchUp::handle(tc, se, (), move |_, ev| { | ||
if all || ev.seat == seat { | ||
if all { | ||
print!("Seat: {}, ", st.name(ev.seat)); | ||
} | ||
println!("Time: {:.4}, Touch: {}, Up", time(ev.time_usec), ev.id); | ||
} | ||
}); | ||
let st = seat_test.clone(); | ||
TouchMotion::handle(tc, se, (), move |_, ev| { | ||
if all || ev.seat == seat { | ||
if all { | ||
print!("Seat: {}, ", st.name(ev.seat)); | ||
} | ||
println!( | ||
"Time: {:.4}, Touch: {} Motion: {}x{}", | ||
time(ev.time_usec), | ||
ev.id, | ||
ev.x, | ||
ev.y | ||
); | ||
} | ||
}); | ||
let st = seat_test.clone(); | ||
TouchFrame::handle(tc, se, (), move |_, ev| { | ||
if all || ev.seat == seat { | ||
if all { | ||
print!("Seat: {}, ", st.name(ev.seat)); | ||
} | ||
println!("Time: {:.4}, Touch: {}, Frame", time(ev.time_usec), ev.id); | ||
} | ||
}); | ||
let st = seat_test.clone(); | ||
TouchCancel::handle(tc, se, (), move |_, ev| { | ||
if all || ev.seat == seat { | ||
if all { | ||
print!("Seat: {}, ", st.name(ev.seat)); | ||
} | ||
println!("Time: {:.4}, Touch: {}, Cancel", time(ev.time_usec), ev.id); | ||
} | ||
}); | ||
pending::<()>().await; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be flattened into the InputEvent enum and the fields of TouchPosition should be flattened into the Down and Motion variants.