pub fn hid_usage_to_code_point(hid_usage: u32, modifier_state: &ModifierState) -> Result<u32> {
    if (hid_usage as usize) < QWERTY_MAP.len() {
        if let Some(map_entry) = QWERTY_MAP[hid_usage as usize] {
            if modifier_state.is_shift_active() {
                map_entry
                    .1
                    .and_then(|shifted_char| Some(shifted_char as u32))
                    .ok_or(format_err!("Invalid USB HID code: {:?}", hid_usage))
            } else {
                Ok(map_entry.0 as u32)
            }
        } else {
            Ok(EMPTY_CODEPOINT) // No code point provided by a keymap, e.g. Enter.
        }
    } else {
        Ok(EMPTY_CODEPOINT) // No code point available, e.g. Shift, Alt, etc.
    }
}
/// Converts a HID usage for a key to a Unicode code point where such a code point exists, based on
/// a US QWERTY keyboard layout.  Returns EMPTY_CODEPOINT if a code point does not exist (e.g. Alt),
/// and an error in case the mapping somehow fails.
Converts a HID usage for a key to a Unicode code point where such a code point exists, based on
a US QWERTY keyboard layout.  Returns EMPTY_CODEPOINT if a code point does not exist ,
and an error in case the mapping somehow fails.
Converts a HID usage for a key to a Unicode code point where such a code point exists based on a US QWERTY keyboard layout . Returns EMPTY_CODEPOINT if a code point does not exist and an error in case the mapping somehow fails .
pub fn hid_usage_to_code_point(hid_usage: u32, modifier_state: &ModifierState) -> Result<u32> {
    if (hid_usage as usize) < QWERTY_MAP.len() {
        if let Some(map_entry) = QWERTY_MAP[hid_usage as usize] {
            if modifier_state.is_shift_active() {
                map_entry
                    .1
                    .and_then(|shifted_char| Some(shifted_char as u32))
                    .ok_or(format_err!("Invalid USB HID code: {:?}", hid_usage))
            } else {
                Ok(map_entry.0 as u32)
            }
        } else {
            Ok(EMPTY_CODEPOINT) // No code point provided by a keymap, e.g. Enter.
        }
    } else {
        Ok(EMPTY_CODEPOINT) // No code point available, e.g. Shift, Alt, etc.
    }
}
pub fn hid_usage_to_code_point ( hid_usage : u32 , modifier_state : & ModifierState ) -> Result < u32 > { if ( hid_usage as usize ) < QWERTY_MAP . len ( ) { if let Some ( map_entry ) = QWERTY_MAP [ hid_usage as usize ] { if modifier_state . is_shift_active ( ) { map_entry . 1 . and_then ( | shifted_char | Some ( shifted_char as u32 ) ) . ok_or ( format_err ! ( " " hid_usage ) ) } else { Ok ( map_entry . 0 as u32 ) } } else { Ok ( EMPTY_CODEPOINT ) // No code point provided by a keymap, e.g. Enter. } } else { Ok ( EMPTY_CODEPOINT ) // No code point available, e.g. Shift, Alt, etc. } }
Converts a HID usage for a key to a Unicode code point where such a code point exists, based on
a US QWERTY keyboard layout.
Converts a HID usage for a key to a Unicode code point where such a code point exists based on a US QWERTY keyboard layout .
hid_usage
u32
modifier_state
&ModifierState
hid_usage
u32
modifier_state
&ModifierState