pub struct APad {
pub left_stick_x: i16,
pub left_stick_y: i16,
pub buttons: DPad,
}Expand description
A simple virtual Game controller with digital buttons and a few analogue axis.
Fields§
§left_stick_x: i16§left_stick_y: i16Implementations§
Source§impl APad
impl APad
pub fn new() -> Self
Sourcepub fn copy_current_to_previous_state(&mut self)
pub fn copy_current_to_previous_state(&mut self)
Must be called once per frame, prior to setting any value for the current state.
Sourcepub fn is_just_pressed(&self, button: Button) -> bool
pub fn is_just_pressed(&self, button: Button) -> bool
Whether the given button has just been pressed this frame. Requires [copy_current_to_previous_state] to have been called at the beginning of the frame
Sourcepub fn is_just_released(&self, button: Button) -> bool
pub fn is_just_released(&self, button: Button) -> bool
Whether the given button has just been released this frame. Requires [copy_current_to_previous_state] to have been called at the beginning of the frame
A single u16 where each bit represents a button pressed or not.
Sourcepub fn left_stick_x(&self) -> f32
pub fn left_stick_x(&self) -> f32
The X state of the left stick in the -1.0 to 1.0 range
Sourcepub fn left_stick_y(&self) -> f32
pub fn left_stick_y(&self) -> f32
The Y state of the left stick in the -1.0 to 1.0 range
Sets the bit for a particular button.
Sourcepub fn set_left_stick_x(&mut self, x: f32)
pub fn set_left_stick_x(&mut self, x: f32)
Converts from f32 to i16, clamps anything outside -1.0 to 1.0 range.
Sourcepub fn set_left_stick_y(&mut self, y: f32)
pub fn set_left_stick_y(&mut self, y: f32)
Converts from f32 to i16, clamps anything outside -1.0 to 1.0 range.