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"
|
||||
thiserror = "=1.0.30"
|
||||
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"
|
||||
flate2 = "1.0.25"
|
||||
crc32fast = "1.3.2"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use num_derive::FromPrimitive;
|
||||
|
||||
// ugh
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, FromPrimitive)]
|
||||
#[repr(i32)]
|
||||
pub enum Keycode {
|
||||
Backspace = sdl2::keyboard::Keycode::Backspace as i32,
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use num_derive::FromPrimitive;
|
||||
|
||||
// ugh
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, FromPrimitive)]
|
||||
#[repr(i32)]
|
||||
pub enum Scancode {
|
||||
A = sdl2::keyboard::Scancode::A as i32,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use bitflags::bitflags;
|
||||
use num_derive::FromPrimitive;
|
||||
|
||||
// equivalent to SDL's "SDL_BUTTON" macro
|
||||
#[inline]
|
||||
|
@ -18,7 +19,7 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, FromPrimitive)]
|
||||
#[repr(u8)]
|
||||
pub enum MouseButton {
|
||||
Unknown = 0,
|
||||
|
|
Loading…
Reference in a new issue