aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/android
diff options
context:
space:
mode:
authorMatt Brubeck <mbrubeck@limpet.net>2015-09-22 09:22:46 -0700
committerMatt Brubeck <mbrubeck@limpet.net>2015-09-22 09:25:49 -0700
commit1827910927833b53cb183032a10d5a3c454b7852 (patch)
tree45d8e3d6f56c9c1343fa2510e2bd978ee1b223fe /src/api/android
parent08cb668037c9fd1608c376a93623b4a60a5d3c46 (diff)
downloadglutin-1827910927833b53cb183032a10d5a3c454b7852.tar.gz
glutin-1827910927833b53cb183032a10d5a3c454b7852.zip
Support multi-touch events on Android
Depends on tomaka/android-rs-glue#64.
Diffstat (limited to 'src/api/android')
-rw-r--r--src/api/android/mod.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/api/android/mod.rs b/src/api/android/mod.rs
index 0f770c2..1f18008 100644
--- a/src/api/android/mod.rs
+++ b/src/api/android/mod.rs
@@ -8,8 +8,7 @@ use std::sync::mpsc::{Receiver, channel};
use {CreationError, Event, MouseCursor};
use CreationError::OsError;
use events::ElementState::{Pressed, Released};
-use events::Event::{MouseInput, MouseMoved};
-use events::MouseButton;
+use events::{Touch, TouchPhase};
use std::collections::VecDeque;
@@ -68,15 +67,19 @@ impl<'a> Iterator for PollEventsIterator<'a> {
fn next(&mut self) -> Option<Event> {
match self.window.event_rx.try_recv() {
- Ok(event) => {
- match event {
- android_glue::Event::EventDown => Some(MouseInput(Pressed, MouseButton::Left)),
- android_glue::Event::EventUp => Some(MouseInput(Released, MouseButton::Left)),
- android_glue::Event::EventMove(x, y) => Some(MouseMoved((x as i32, y as i32))),
- _ => None,
- }
+ Ok(android_glue::Event::EventMotion(motion)) => {
+ Some(Event::Touch(Touch {
+ phase: match motion.action {
+ android_glue::MotionAction::Down => TouchPhase::Started,
+ android_glue::MotionAction::Move => TouchPhase::Moved,
+ android_glue::MotionAction::Up => TouchPhase::Ended,
+ android_glue::MotionAction::Cancel => TouchPhase::Cancelled,
+ },
+ location: (motion.x as f64, motion.y as f64),
+ id: motion.pointer_id as u64,
+ }))
}
- Err(_) => {
+ _ => {
None
}
}