aboutsummaryrefslogtreecommitdiff
path: root/src/input/button.rs
diff options
context:
space:
mode:
authorArne Dußin2021-01-27 14:01:50 +0100
committerArne Dußin2021-02-02 22:16:15 +0100
commitf92e9f6f07b1e3834c2ca58ce3510734819d08e4 (patch)
tree20e3d3afce342a56ae98f6c20491482ccd2b5c6b /src/input/button.rs
parentc60a6d07efb120724b308e29e8e70f27c87c952d (diff)
downloadgraf_karto-f92e9f6f07b1e3834c2ca58ce3510734819d08e4.tar.gz
graf_karto-f92e9f6f07b1e3834c2ca58ce3510734819d08e4.zip
Rework graf karto to fit the client/server structure
Diffstat (limited to 'src/input/button.rs')
-rw-r--r--src/input/button.rs177
1 files changed, 0 insertions, 177 deletions
diff --git a/src/input/button.rs b/src/input/button.rs
deleted file mode 100644
index e9ef45e..0000000
--- a/src/input/button.rs
+++ /dev/null
@@ -1,177 +0,0 @@
-//! Reimplementation crate of the KeyboardKey and MouseButton structs of raylib, because they do
-//! not implement `serde::Serialize` and `serde::Deserialize`. If you have a better idea on how to
-//! handle it, feel free.
-
-use raylib::ffi::{KeyboardKey as rlKeyboardKey, MouseButton as rlMouseButton};
-use serde::{Deserialize, Serialize};
-use std::mem;
-
-/// Abstraction over different key-types. A binding can be constructed from this button-type or
-/// multiple button-presses can be chained together to create a binding. Just be careful to not
-/// have bindings where one binding is included in another. This includes bindings where on your
-/// keyboard you have Scancode(Shift) + Scancode(A) and another binding of Text(A) (Text(a) would
-/// be okay)
-#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq, Hash)]
-pub enum Button {
- /// A button on the mouse (raylib supports just three :/ )
- Mouse(MouseButton),
- /// Scancode that is sent by the OS. This can change between OSes, but stays the same between
- /// runs and layout changes in the keyboard.
- Scancode(Scancode),
- /// The text input read from the operating system. This means even characters composed or
- /// non-ASCII characters can be used. I mean, who doesn't want to bind the wall tool to 壁?
- Text(char),
-}
-
-#[allow(missing_docs)]
-#[repr(u32)]
-#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq, Hash)]
-pub enum MouseButton {
- Left = 0,
- Right = 1,
- Middle = 2,
-}
-
-#[allow(missing_docs)]
-#[repr(u32)]
-#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq, Hash)]
-pub enum Scancode {
- Apostrophe = 39,
- Comma = 44,
- Minus = 45,
- Period = 46,
- Slash = 47,
- Zero = 48,
- One = 49,
- Two = 50,
- Three = 51,
- Four = 52,
- Five = 53,
- Six = 54,
- Seven = 55,
- Eight = 56,
- Nine = 57,
- Semicolon = 59,
- Equal = 61,
- A = 65,
- B = 66,
- C = 67,
- D = 68,
- E = 69,
- F = 70,
- G = 71,
- H = 72,
- I = 73,
- J = 74,
- K = 75,
- L = 76,
- M = 77,
- N = 78,
- O = 79,
- P = 80,
- Q = 81,
- R = 82,
- S = 83,
- T = 84,
- U = 85,
- V = 86,
- W = 87,
- X = 88,
- Y = 89,
- Z = 90,
- Space = 32,
- Escape = 256,
- Enter = 257,
- Tab = 258,
- Backspace = 259,
- Insert = 260,
- Delete = 261,
- Right = 262,
- Left = 263,
- Down = 264,
- Up = 265,
- PageUp = 266,
- PageDown = 267,
- Home = 268,
- End = 269,
- CapsLock = 280,
- ScrollLock = 281,
- NumLock = 282,
- PrintScreen = 283,
- Pause = 284,
- F1 = 290,
- F2 = 291,
- F3 = 292,
- F4 = 293,
- F5 = 294,
- F6 = 295,
- F7 = 296,
- F8 = 297,
- F9 = 298,
- F10 = 299,
- F11 = 300,
- F12 = 301,
- LeftShift = 340,
- LeftControl = 341,
- LeftAlt = 342,
- LeftSuper = 343,
- RightShift = 344,
- RightControl = 345,
- RightAlt = 346,
- RightSuper = 347,
- Menu = 348,
- LeftBracket = 91,
- Backslash = 92,
- RightBracket = 93,
- Grave = 96,
- Keypad0 = 320,
- Keypad1 = 321,
- Keypad2 = 322,
- Keypad3 = 323,
- Keypad4 = 324,
- Keypad5 = 325,
- Keypad6 = 326,
- Keypad7 = 327,
- Keypad8 = 328,
- Keypad9 = 329,
- KeypadDecimal = 330,
- KeypadDivide = 331,
- KeypadMultiply = 332,
- KeypadSubtract = 333,
- KeypadAdd = 334,
- KeypadEnter = 335,
- KeypadEqual = 336,
-}
-
-impl From<rlMouseButton> for Button {
- fn from(button: rlMouseButton) -> Self {
- Self::Mouse(MouseButton::from(button))
- }
-}
-impl From<rlKeyboardKey> for Button {
- fn from(key: rlKeyboardKey) -> Self {
- Self::Scancode(Scancode::from(key))
- }
-}
-
-impl From<rlMouseButton> for MouseButton {
- fn from(button: rlMouseButton) -> Self {
- unsafe { mem::transmute(button as u32) }
- }
-}
-impl Into<rlMouseButton> for MouseButton {
- fn into(self) -> rlMouseButton {
- unsafe { mem::transmute(self as u32) }
- }
-}
-
-impl From<rlKeyboardKey> for Scancode {
- fn from(key: rlKeyboardKey) -> Self {
- unsafe { mem::transmute(key as u32) }
- }
-}
-impl Into<rlKeyboardKey> for Scancode {
- fn into(self) -> rlKeyboardKey {
- unsafe { mem::transmute(self as u32) }
- }
-}