aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrooks J Rady <b.j.rady@gmail.com>2021-01-10 22:58:48 +0000
committerBrooks J Rady <b.j.rady@gmail.com>2021-01-10 22:58:48 +0000
commitd79db4acb33f14c93c4f4b1e18c09ffb702212e1 (patch)
treee5c811046d12734d85f5d807d38d42a74d58f75b
parentVersion bump! (diff)
downloadsl0ppij-d79db4acb33f14c93c4f4b1e18c09ffb702212e1.tar.gz
sl0ppij-d79db4acb33f14c93c4f4b1e18c09ffb702212e1.tar.xz
sl0ppij-d79db4acb33f14c93c4f4b1e18c09ffb702212e1.zip
Add a global key callback
-rw-r--r--Cargo.toml2
-rw-r--r--src/lib.rs16
2 files changed, 13 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 6ecbe6c9..24ca614e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "mosaic-tile"
-version = "0.2.1"
+version = "0.2.2"
authors = ["Brooks J Rady <b.j.rady@gmail.com>"]
edition = "2018"
description = "A small client-side library for writing mosaic plugins (tiles)"
diff --git a/src/lib.rs b/src/lib.rs
index a1e4f1fd..9d373a02 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,11 +1,12 @@
mod shim;
pub use shim::*;
-
+#[allow(unused_variables)]
pub trait MosaicTile {
- fn init(&mut self);
- fn draw(&mut self, rows: usize, cols: usize);
- fn handle_key(&mut self, key: Key);
+ fn init(&mut self) {}
+ fn draw(&mut self, rows: usize, cols: usize) {}
+ fn handle_key(&mut self, key: Key) {}
+ fn handle_global_key(&mut self, key: Key) {}
}
#[macro_export]
@@ -37,5 +38,12 @@ macro_rules! register_tile {
state.borrow_mut().handle_key(get_key());
});
}
+
+ #[no_mangle]
+ pub fn handle_global_key() {
+ STATE.with(|state| {
+ state.borrow_mut().handle_global_key(get_key());
+ });
+ }
};
}