Struct gamepad::GamepadState
source · pub struct GamepadState { /* private fields */ }
Implementations§
source§impl GamepadState
impl GamepadState
pub fn new() -> Self
Examples found in repository?
examples/gamepad.rs (line 12)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
pub fn main() {
let mut engine = GamepadEngine::new();
loop {
engine.update().unwrap();
for gamepad in engine.gamepads() {
for (key, button) in gamepad.buttons() {
if button.is_just_pressed() {
println!("Just Pressed: {:?}", key);
}
}
for (_, joystick) in gamepad.joysticks() {
println!("{:?}", joystick);
}
}
std::thread::sleep(Duration::from_millis(16));
}
}
pub fn joystick(&self, joystick: Joystick) -> (f32, f32)
pub fn joystick_raw(&self, joystick: Joystick) -> (i16, i16)
sourcepub fn joysticks(&self) -> &HashMap<Joystick, JoystickState>
pub fn joysticks(&self) -> &HashMap<Joystick, JoystickState>
Examples found in repository?
examples/gamepad.rs (line 18)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
pub fn main() {
let mut engine = GamepadEngine::new();
loop {
engine.update().unwrap();
for gamepad in engine.gamepads() {
for (key, button) in gamepad.buttons() {
if button.is_just_pressed() {
println!("Just Pressed: {:?}", key);
}
}
for (_, joystick) in gamepad.joysticks() {
println!("{:?}", joystick);
}
}
std::thread::sleep(Duration::from_millis(16));
}
}
pub fn joysticks_mut(&mut self) -> &mut HashMap<Joystick, JoystickState>
pub fn is_pressed(&self, button: Button) -> bool
pub fn is_just_pressed(&self, button: Button) -> bool
pub fn is_just_released(&self, button: Button) -> bool
Trait Implementations§
source§impl Clone for GamepadState
impl Clone for GamepadState
source§fn clone(&self) -> GamepadState
fn clone(&self) -> GamepadState
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl RefUnwindSafe for GamepadState
impl Send for GamepadState
impl Sync for GamepadState
impl Unpin for GamepadState
impl UnwindSafe for GamepadState
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more