fn mask_to_event(mask: u8, released: u8, pressed: u8) -> Option<Keys> {
    let pressed_bool = mask & pressed == mask;
    let released_bool = mask & released == mask;

    match mask {
        0x8 => {
            if released_bool {
                Some(Keys::BUp)
            } else if pressed_bool {
                Some(Keys::BDown)
            } else {
                None
            }
        }
        0x4 => {
            if released_bool {
                Some(Keys::AUp)
            } else if pressed_bool {
                Some(Keys::ADown)
            } else {
                None
            }
        }
        0x2 => {
            if released_bool {
                Some(Keys::StartUp)
            } else if pressed_bool {
                Some(Keys::StartDown)
            } else {
                None
            }
        }
        0x1 => {
            if released_bool {
                Some(Keys::SelectUp)
            } else if pressed_bool {
                Some(Keys::SelectDown)
            } else {
                None
            }
        }
        _ => None,
    }
}
//should be impossible for released and pressed, but gives released preference
should be impossible for released and pressed, but gives released preference
should be impossible for released and pressed but gives released preference
fn mask_to_event(mask: u8, released: u8, pressed: u8) -> Option<Keys> {
    let pressed_bool = mask & pressed == mask;
    let released_bool = mask & released == mask;
    match mask {
        0x8 => {
            if released_bool {
                Some(Keys::BUp)
            } else if pressed_bool {
                Some(Keys::BDown)
            } else {
                None
            }
        }
        0x4 => {
            if released_bool {
                Some(Keys::AUp)
            } else if pressed_bool {
                Some(Keys::ADown)
            } else {
                None
            }
        }
        0x2 => {
            if released_bool {
                Some(Keys::StartUp)
            } else if pressed_bool {
                Some(Keys::StartDown)
            } else {
                None
            }
        }
        0x1 => {
            if released_bool {
                Some(Keys::SelectUp)
            } else if pressed_bool {
                Some(Keys::SelectDown)
            } else {
                None
            }
        }
        _ => None,
    }
}
fn mask_to_event ( mask : u8 , released : u8 , pressed : u8 ) -> Option < Keys > { let pressed_bool = mask & pressed == mask ; let released_bool = mask & released == mask ; match mask { 0x8 => { if released_bool { Some ( Keys :: BUp ) } else if pressed_bool { Some ( Keys :: BDown ) } else { None } } 0x4 => { if released_bool { Some ( Keys :: AUp ) } else if pressed_bool { Some ( Keys :: ADown ) } else { None } } 0x2 => { if released_bool { Some ( Keys :: StartUp ) } else if pressed_bool { Some ( Keys :: StartDown ) } else { None } } 0x1 => { if released_bool { Some ( Keys :: SelectUp ) } else if pressed_bool { Some ( Keys :: SelectDown ) } else { None } } _ => None , } }
should be impossible for released and pressed, but gives released preference
should be impossible for released and pressed but gives released preference
mask
u8
released
u8
pressed
u8
mask
u8
released
u8
pressed
u8