xinput/flags/
keystroke.rs

1use bytemuck::{Pod, Zeroable};
2use winapi::um::xinput::*;
3
4
5
6/// \[[microsoft.com](https://learn.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_keystroke#members)\]
7/// XINPUT_KEYSTROKE_\*
8#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[derive(Pod, Zeroable)]
10#[repr(transparent)] pub struct KeystrokeFlags(u16);
11use KeystrokeFlags as Keystroke;
12
13flags! { Keystroke => u16; None, KeyDown, KeyUp, Repeat }
14
15#[allow(non_upper_case_globals)] impl KeystrokeFlags {
16    /// No flags set
17    pub const None : Keystroke = Keystroke(0);
18
19    /// The key was pressed.
20    pub const KeyDown : Keystroke = Keystroke(XINPUT_KEYSTROKE_KEYDOWN);
21
22    /// The key was released.
23    pub const KeyUp : Keystroke = Keystroke(XINPUT_KEYSTROKE_KEYUP);
24
25    /// This was a repeated key event.
26    pub const Repeat : Keystroke = Keystroke(XINPUT_KEYSTROKE_REPEAT);
27}
28
29#[allow(non_upper_case_globals)] impl crate::Keystroke {
30    /// No flags set
31    pub const None : Keystroke = Keystroke(0);
32
33    /// The key was pressed.
34    pub const KeyDown : Keystroke = Keystroke(XINPUT_KEYSTROKE_KEYDOWN);
35
36    /// The key was released.
37    pub const KeyUp : Keystroke = Keystroke(XINPUT_KEYSTROKE_KEYUP);
38
39    /// This was a repeated key event.
40    pub const Repeat : Keystroke = Keystroke(XINPUT_KEYSTROKE_REPEAT);
41}
42
43//#cpp2rust XINPUT_KEYSTROKE_KEYDOWN    = xinput::Keystroke::KeyDown
44//#cpp2rust XINPUT_KEYSTROKE_KEYUP      = xinput::Keystroke::KeyUp
45//#cpp2rust XINPUT_KEYSTROKE_REPEAT     = xinput::Keystroke::Repeat