aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2014-11-17 10:41:13 +0100
committertomaka <pierre.krieger1708@gmail.com>2014-11-17 10:41:13 +0100
commit0dc5086efb29e84c48cd4dcc1da48ee9755842e3 (patch)
treedd5fa639f12733287adc803e2eec2bcab6656e66
parente7b25878fc0f73526ccfd7ef4286e25ac6fda776 (diff)
parentc0305c47817e56fe39b4dc39d6f5af7434130881 (diff)
downloadglutin-0dc5086efb29e84c48cd4dcc1da48ee9755842e3.tar.gz
glutin-0dc5086efb29e84c48cd4dcc1da48ee9755842e3.zip
Merge pull request #118 from ozkriff/master
Android: Implemented basic inputs
-rw-r--r--src/android/mod.rs27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/android/mod.rs b/src/android/mod.rs
index 4b1c7eb..2e0ab74 100644
--- a/src/android/mod.rs
+++ b/src/android/mod.rs
@@ -3,11 +3,13 @@ extern crate native;
use libc;
use {CreationError, OsError, Event, WindowBuilder};
+use {Pressed, Released, LeftMouseButton, MouseInput, MouseMoved};
pub struct Window {
display: ffi::egl::types::EGLDisplay,
context: ffi::egl::types::EGLContext,
surface: ffi::egl::types::EGLSurface,
+ event_rx: Receiver<android_glue::Event>,
}
pub struct MonitorID;
@@ -111,10 +113,14 @@ impl Window {
android_glue::write_log("eglCreateWindowSurface succeeded");
+ let (tx, rx) = channel();
+ android_glue::add_sender(tx);
+
Ok(Window {
display: display,
context: context,
surface: surface,
+ event_rx: rx,
})
}
@@ -169,7 +175,26 @@ impl Window {
use std::time::Duration;
use std::io::timer;
timer::sleep(Duration::milliseconds(16));
- Vec::new()
+ let mut events = Vec::new();
+ loop {
+ match self.event_rx.try_recv() {
+ Ok(event) => match event {
+ android_glue::EventDown => {
+ events.push(MouseInput(Pressed, LeftMouseButton));
+ },
+ android_glue::EventUp => {
+ events.push(MouseInput(Released, LeftMouseButton));
+ },
+ android_glue::EventMove(x, y) => {
+ events.push(MouseMoved((x as int, y as int)));
+ },
+ },
+ Err(_) => {
+ break;
+ },
+ }
+ }
+ events
}
pub fn make_current(&self) {