[−][src]Struct stick::Port
An interface to all joystick, gamepad and controller devices.
Methods
impl Port
[src]
pub fn new() -> Port
[src]
Create a new interface to all joystick, gamepad and controller devices currently plugged in to this computer.
pub fn poll(&mut self) -> Option<u8>
[src]
Block thread until input is available.
pub fn get(&self, stick: u8) -> Option<&Device>
[src]
Get the state of a device
pub fn swap(&mut self, a: u8, b: u8)
[src]
Swap two devices in the interface by their indexes.
Panics
If either a
or b
are out of bounds.
Note
This is useful for if in a game, you want P1 and P2 to swap which controller they are assigned to. You can do this with:
// Assuming P1 is at index 0, and P2 is at index 1,
devices.swap(0, 1);
pub fn name(&self, a: u8) -> String
[src]
Get the name of a device by index.
pub fn count(&self) -> u8
[src]
Get the number of plugged in controllers.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,