1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
//!
/// The type of the [`NcInput`][crate::NcInput] event.
///
/// Note: *Unknown* and *Press* are considered equivalent.
#[repr(u32)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum NcInputType {
///
Unknown,
///
Press,
///
Repeat,
///
Release,
}
mod core_impls {
use super::{c_api::*, NcInputType};
use core::fmt;
impl Default for NcInputType {
fn default() -> Self {
Self::Unknown
}
}
impl fmt::Display for NcInputType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use NcInputType::*;
write!(
f,
"{}",
match self {
Unknown => "Unknown",
Press => "Press",
Repeat => "Repeat",
Release => "Release",
}
)
}
}
impl fmt::Debug for NcInputType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "NcInputType::{}", self)
}
}
impl From<NcInputType> for u32 {
fn from(it: NcInputType) -> Self {
use NcInputType::*;
match it {
Unknown => NCTYPE_UNKNOWN,
Press => NCTYPE_PRESS,
Repeat => NCTYPE_REPEAT,
Release => NCTYPE_RELEASE,
}
}
}
impl From<u32> for NcInputType {
fn from(value: u32) -> Self {
use NcInputType::*;
match value {
NCTYPE_UNKNOWN => Unknown,
NCTYPE_PRESS => Press,
NCTYPE_REPEAT => Repeat,
NCTYPE_RELEASE => Release,
_ => Unknown,
}
}
}
}
pub(crate) mod c_api {
use crate::c_api::ffi;
/// The type of the [`NcInput`][crate::NcInput] event.
///
/// It's recommended to use [`NcInputType`][crate::NcInputType] instead.
///
/// # Associated `c_api` constants:
/// - [`NCTYPE_UNKNOWN`]
/// - [`NCTYPE_PRESS`]
/// - [`NCTYPE_REPEAT`]
/// - [`NCTYPE_RELEASE`]
pub type NcInputType_u32 = u32;
/// [`NcInputType_u32`] *Unknown* input type event.
pub const NCTYPE_UNKNOWN: u32 = ffi::ncintype_e_NCTYPE_UNKNOWN;
/// [`NcInputType_u32`] *Press* input type event.
pub const NCTYPE_PRESS: u32 = ffi::ncintype_e_NCTYPE_PRESS;
/// [`NcInputType_u32`] *Repeat* input type event.
pub const NCTYPE_REPEAT: u32 = ffi::ncintype_e_NCTYPE_REPEAT;
/// [`NcInputType_u32`] *Release* input type event.
pub const NCTYPE_RELEASE: u32 = ffi::ncintype_e_NCTYPE_RELEASE;
}