[][src]Module cala::controller

API for getting joystick / controller / gamepad input. Enable with the controller feature.

Usage

// Set the home loop to `run()`.
cala::init!(run, ());

// Function that runs while your app runs.
pub fn run(_: &mut ()) -> cala::Loop<()> {
    let layout = cala::ControllerLayout::new().joy(false).lrt(false).abxy(false);

    // Iterate through all of the controllers.
    'a: for (id, state) in cala::controllers(&layout) {
        println!("{}: {:?}", id, state.get());
    }
    std::thread::sleep(std::time::Duration::from_millis(16));
    // Exit.
    cala::Continue
}

Structs

ControllerIter

Iterator over controllers. Use controllers() to get.

ControllerLayout

Select which buttons and axis you want on your controller.

ControllerState

State of a controller.

Constants

CONTROLLER_MAX

The maximum number of controllers allowed.

Functions

controller_count

Return the number of controllers.

controller_get

Get the state of a controller from the requested controller layout.

controllers

Get an iterator over controller IDs. Warning: They are not guarenteed to be consecutive, even though they usually are.