[][src]Struct stick::Port

pub struct Port { /* fields omitted */ }

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

impl Default for Port[src]

Auto Trait Implementations

impl Send for Port

impl Sync for Port

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]