commonlibsse_ng\re\i/
InputDevices.rs

1#[commonlibsse_ng_derive_internal::ffi_enum]
2#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
3#[repr(u32)]
4pub enum INPUT_DEVICE_SE {
5    Keyboard = 0,
6    Mouse = 1,
7    Gamepad = 2,
8    FlatVirtualKeyboard = 3,
9}
10const _: () = assert!(INPUT_DEVICE_SE_CEnum::count() == 4);
11
12#[commonlibsse_ng_derive_internal::ffi_enum]
13#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
14#[repr(u32)]
15pub enum INPUT_DEVICE_VR {
16    Keyboard = 0,
17    Mouse = 1,
18    Gamepad = 2,
19    VivePrimary = 3,
20    ViveSecondary = 4,
21    OculusPrimary = 5,
22    OculusSecondary = 6,
23    WMRPrimary = 7,
24    WMRSecondary = 8,
25    VRVirtualKeyboard = 9,
26}
27const _: () = assert!(INPUT_DEVICE_VR_CEnum::count() == 10);
28
29/// `INPUT_DEVICE` to store the raw value.
30///
31/// This is a generic type that exists because the correct value varies depending on the SE, AE , VR environment.
32#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
33#[repr(transparent)]
34pub struct INPUT_DEVICE(pub u32);
35const _: () = assert!(core::mem::size_of::<INPUT_DEVICE>() == 0x4);
36
37impl INPUT_DEVICE {
38    /// Try to cast valid enum for SE, AE.
39    #[inline]
40    pub const fn as_se(&self) -> Option<INPUT_DEVICE_SE> {
41        INPUT_DEVICE_SE_CEnum(self.0).to_enum()
42    }
43
44    /// Try to cast valid enum for VR.
45    #[inline]
46    pub const fn as_vr(&self) -> Option<INPUT_DEVICE_VR> {
47        INPUT_DEVICE_VR_CEnum(self.0).to_enum()
48    }
49}
50
51impl From<INPUT_DEVICE_SE> for INPUT_DEVICE {
52    #[inline]
53    fn from(value: INPUT_DEVICE_SE) -> Self {
54        Self(value as u32)
55    }
56}
57
58impl From<INPUT_DEVICE_VR> for INPUT_DEVICE {
59    #[inline]
60    fn from(value: INPUT_DEVICE_VR) -> Self {
61        Self(value as u32)
62    }
63}