From a97401aed2a173260a4abfdb65a77975ce6c0f01 Mon Sep 17 00:00:00 2001
From: Héctor Ramón Jiménez <hector0193@gmail.com>
Date: Sat, 14 Sep 2019 19:16:06 +0200
Subject: Rethink workspace structure

---
 src/input/button_state.rs | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 src/input/button_state.rs

(limited to 'src/input/button_state.rs')

diff --git a/src/input/button_state.rs b/src/input/button_state.rs
new file mode 100644
index 00000000..e9dc05d7
--- /dev/null
+++ b/src/input/button_state.rs
@@ -0,0 +1,24 @@
+/// The state of a button.
+///
+/// If you are using [`winit`], consider enabling the `winit` feature to get
+/// conversion implementations for free!
+///
+/// [`winit`]: https://docs.rs/winit/0.20.0-alpha3/winit/
+#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy)]
+pub enum ButtonState {
+    /// The button is pressed.
+    Pressed,
+
+    /// The button is __not__ pressed.
+    Released,
+}
+
+#[cfg(feature = "winit")]
+impl From<winit::event::ElementState> for ButtonState {
+    fn from(element_state: winit::event::ElementState) -> Self {
+        match element_state {
+            winit::event::ElementState::Pressed => ButtonState::Pressed,
+            winit::event::ElementState::Released => ButtonState::Released,
+        }
+    }
+}
-- 
cgit