add num_derive's FromPrimitive derive to keyboard and mouse button enums
this has very limited use, outside of some tests i am writing right now, but maybe it will be useful down the road. (i suppose mostly, i just wanted to try this out for myself ...)
This commit is contained in:
parent
8e02fdd657
commit
43c921680b
|
@ -10,7 +10,9 @@ byte-slice-cast = "1.2.1"
|
||||||
byteorder = "1.4.3"
|
byteorder = "1.4.3"
|
||||||
thiserror = "=1.0.30"
|
thiserror = "=1.0.30"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
num-traits = "0.2.14"
|
num = "0.4.0"
|
||||||
|
num-derive = "0.3.3"
|
||||||
|
num-traits = "0.2.15"
|
||||||
bitflags = "2.0.2"
|
bitflags = "2.0.2"
|
||||||
flate2 = "1.0.25"
|
flate2 = "1.0.25"
|
||||||
crc32fast = "1.3.2"
|
crc32fast = "1.3.2"
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
use num_derive::FromPrimitive;
|
||||||
|
|
||||||
// ugh
|
// ugh
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, FromPrimitive)]
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
pub enum Keycode {
|
pub enum Keycode {
|
||||||
Backspace = sdl2::keyboard::Keycode::Backspace as i32,
|
Backspace = sdl2::keyboard::Keycode::Backspace as i32,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
use num_derive::FromPrimitive;
|
||||||
|
|
||||||
// ugh
|
// ugh
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, FromPrimitive)]
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
pub enum Scancode {
|
pub enum Scancode {
|
||||||
A = sdl2::keyboard::Scancode::A as i32,
|
A = sdl2::keyboard::Scancode::A as i32,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
|
use num_derive::FromPrimitive;
|
||||||
|
|
||||||
// equivalent to SDL's "SDL_BUTTON" macro
|
// equivalent to SDL's "SDL_BUTTON" macro
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -18,7 +19,7 @@ bitflags! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, FromPrimitive)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum MouseButton {
|
pub enum MouseButton {
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
|
|
Loading…
Reference in a new issue