fn update_axis(&self, axis: Axis, val: i16) {
        let mut b = self.buttons.get();

        let state = AxisState::from_value(val);

        match axis {
            Axis::LeftX => {
                if state != self.x_axis_state.get() {
                    self.x_axis_state.set(state);

                    b.left  = state.down_if_negative();
                    b.right = state.down_if_positive();
                }
            }
            Axis::LeftY => {
                if state != self.y_axis_state.get() {
                    self.y_axis_state.set(state);

                    b.up   = state.down_if_negative();
                    b.down = state.down_if_positive();
                }
            }
            _ => (),
        }

        self.buttons.set(b);
    }
/// Map left stick X/Y to directional buttons
Map left stick X/Y to directional buttons
Map left stick X / Y to directional buttons
fn update_axis(&self, axis: Axis, val: i16) {
        let mut b = self.buttons.get();
        let state = AxisState::from_value(val);
        match axis {
            Axis::LeftX => {
                if state != self.x_axis_state.get() {
                    self.x_axis_state.set(state);
                    b.left  = state.down_if_negative();
                    b.right = state.down_if_positive();
                }
            }
            Axis::LeftY => {
                if state != self.y_axis_state.get() {
                    self.y_axis_state.set(state);
                    b.up   = state.down_if_negative();
                    b.down = state.down_if_positive();
                }
            }
            _ => (),
        }
        self.buttons.set(b);
    }
fn update_axis ( & self , axis : Axis , val : i16 ) { let mut b = self . buttons . get ( ) ; let state = AxisState :: from_value ( val ) ; match axis { Axis :: LeftX => { if state != self . x_axis_state . get ( ) { self . x_axis_state . set ( state ) ; b . left = state . down_if_negative ( ) ; b . right = state . down_if_positive ( ) ; } } Axis :: LeftY => { if state != self . y_axis_state . get ( ) { self . y_axis_state . set ( state ) ; b . up = state . down_if_negative ( ) ; b . down = state . down_if_positive ( ) ; } } _ => ( ) , } self . buttons . set ( b ) ; }
Map left stick X/Y to directional buttons
Map left stick X / Y to directional buttons
&self
axis
Axis
val
i16
&self
axis
Axis
val
i16