/// This is where we handle controller inputs
This is where we handle controller inputs
This is where we handle controller inputs
fn input(&mut self, event: &WindowEvent) -> bool {
        match event {
            WindowEvent::KeyboardInput { input, .. } => match input {
                // Handle controller inputs
                KeyboardInput {
                    state: ElementState::Pressed,
                    virtual_keycode: Some(key_code),
                    ..
                } => {
                    if let Ok(f) = virtual_keycode_to_controller_input(key_code) {
                        self.controller1.insert(f);
                        let _ = self
                            .emulator_handle
                            .send(EmulationMessage::Input(self.controller1));
                        true
                    } else {
                        false
                    }
                }
                KeyboardInput {
                    state: ElementState::Released,
                    virtual_keycode: Some(key_code),
                    ..
                } => {
                    if let Ok(f) = virtual_keycode_to_controller_input(key_code) {
                        self.controller1.remove(f);
                        let _ = self
                            .emulator_handle
                            .send(EmulationMessage::Input(self.controller1));
                        true
                    } else {
                        false
                    }
                }
                _ => false,
            },
            _ => false,
        }
    }
fn input ( & mut self , event : & WindowEvent ) -> bool { match event { WindowEvent :: KeyboardInput { input , .. } => match input { // Handle controller inputs KeyboardInput { state : ElementState :: Pressed , virtual_keycode : Some ( key_code ) , .. } => { if let Ok ( f ) = virtual_keycode_to_controller_input ( key_code ) { self . controller1 . insert ( f ) ; let _ = self . emulator_handle . send ( EmulationMessage :: Input ( self . controller1 ) ) ; true } else { false } } KeyboardInput { state : ElementState :: Released , virtual_keycode : Some ( key_code ) , .. } => { if let Ok ( f ) = virtual_keycode_to_controller_input ( key_code ) { self . controller1 . remove ( f ) ; let _ = self . emulator_handle . send ( EmulationMessage :: Input ( self . controller1 ) ) ; true } else { false } } _ => false , } , _ => false , } }
This is where we handle controller inputs
This is where we handle controller inputs
&mut self
event
&WindowEvent