Skip to content

Commit

Permalink
refactor: Replace enums with associated constants.
Browse files Browse the repository at this point in the history
refs #92.
  • Loading branch information
pravic committed Feb 7, 2021
1 parent d8d1dea commit 6695472
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/capi/scbehavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,19 @@ pub enum MOUSE_BUTTONS

#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug, PartialOrd, PartialEq)]
#[derive(Debug, Default, PartialOrd, PartialEq)]
/// Keyboard modifier buttons state.
pub enum KEYBOARD_STATES
{
CONTROL_KEY_PRESSED = 0x01,
SHIFT_KEY_PRESSED = 0x02,
ALT_KEY_PRESSED = 0x04,
pub struct KEYBOARD_STATES(u32);

impl KEYBOARD_STATES {
pub const CONTROL_KEY_PRESSED: u32 = 0x01;
pub const SHIFT_KEY_PRESSED: u32 = 0x02;
pub const ALT_KEY_PRESSED: u32 = 0x04;
}

impl std::convert::From<u32> for KEYBOARD_STATES {
fn from(u: u32) -> Self {
unsafe { std::mem::transmute(u) }
Self(u)
}
}

Expand Down

0 comments on commit 6695472

Please sign in to comment.