pub fn input(&self) -> u8 {
        let buttons = self.buttons.get();

        // For simplicity we'll mark the active lines with 1 and
        // invert the value at the end
        let mut active = 0;

        if self.directions_selected {
            active |= 0x10;

            active |= (buttons.right.is_down() as u8) << 0;
            active |= (buttons.left .is_down() as u8) << 1;
            active |= (buttons.up   .is_down() as u8) << 2;
            active |= (buttons.down .is_down() as u8) << 3;
        }

        if self.buttons_selected {
            active |= 0x20;

            active |= (buttons.a     .is_down() as u8) << 0;
            active |= (buttons.b     .is_down() as u8) << 1;
            active |= (buttons.select.is_down() as u8) << 2;
            active |= (buttons.start .is_down() as u8) << 3;
        }

        // Now we can complement the value and return it
        !active
    }
/// Return the value of the INPUT register. Lines are to 1 when
/// inactive.
Return the value of the INPUT register. Lines are to 1 when
inactive.
Return the value of the INPUT register . Lines are to 1 when inactive .
pub fn input(&self) -> u8 {
        let buttons = self.buttons.get();
        // For simplicity we'll mark the active lines with 1 and
        // invert the value at the end
        let mut active = 0;
        if self.directions_selected {
            active |= 0x10;
            active |= (buttons.right.is_down() as u8) << 0;
            active |= (buttons.left .is_down() as u8) << 1;
            active |= (buttons.up   .is_down() as u8) << 2;
            active |= (buttons.down .is_down() as u8) << 3;
        }
        if self.buttons_selected {
            active |= 0x20;
            active |= (buttons.a     .is_down() as u8) << 0;
            active |= (buttons.b     .is_down() as u8) << 1;
            active |= (buttons.select.is_down() as u8) << 2;
            active |= (buttons.start .is_down() as u8) << 3;
        }
        // Now we can complement the value and return it
        !active
    }
pub fn input ( & self ) -> u8 { let buttons = self . buttons . get ( ) ; // For simplicity we'll mark the active lines with 1 and // invert the value at the end let mut active = 0 ; if self . directions_selected { active |= 0x10 ; active |= ( buttons . right . is_down ( ) as u8 ) << 0 ; active |= ( buttons . left . is_down ( ) as u8 ) << 1 ; active |= ( buttons . up . is_down ( ) as u8 ) << 2 ; active |= ( buttons . down . is_down ( ) as u8 ) << 3 ; } if self . buttons_selected { active |= 0x20 ; active |= ( buttons . a . is_down ( ) as u8 ) << 0 ; active |= ( buttons . b . is_down ( ) as u8 ) << 1 ; active |= ( buttons . select . is_down ( ) as u8 ) << 2 ; active |= ( buttons . start . is_down ( ) as u8 ) << 3 ; } // Now we can complement the value and return it ! active }
Return the value of the INPUT register.
Return the value of the INPUT register .
&self
&self