Struct gamepad::GamepadEngine
source · pub struct GamepadEngine { /* private fields */ }
Implementations§
source§impl GamepadEngine
impl GamepadEngine
sourcepub fn new() -> Self
pub fn new() -> Self
Instantiates gamepad engine, begins polling for input
Examples found in repository?
examples/gamepad.rs (line 6)
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));
}
}
sourcepub fn update(&mut self) -> Result<(), GamepadError>
pub fn update(&mut self) -> Result<(), GamepadError>
Polls for input and updates all gamepad states
Examples found in repository?
examples/gamepad.rs (line 9)
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));
}
}
sourcepub fn gamepads(&self) -> &Vec<GamepadState>
pub fn gamepads(&self) -> &Vec<GamepadState>
Examples found in repository?
examples/gamepad.rs (line 11)
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 gamepads_mut(&mut self) -> &mut Vec<GamepadState>
Trait Implementations§
impl Send for GamepadEngine
impl Sync for GamepadEngine
Auto Trait Implementations§
impl !RefUnwindSafe for GamepadEngine
impl Unpin for GamepadEngine
impl !UnwindSafe for GamepadEngine
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