Controller

Struct Controller 

Source
pub struct Controller {
Show 15 fields pub left_stick: AnalogStick, pub right_stick: AnalogStick, pub l1: Button, pub l2: Button, pub r1: Button, pub r2: Button, pub up: Button, pub down: Button, pub left: Button, pub right: Button, pub x: Button, pub y: Button, pub a: Button, pub b: Button, pub screen: Screen, /* private fields */
}
Expand description

Represents a Vex controller.

Fields§

§left_stick: AnalogStick

The left analog stick.

§right_stick: AnalogStick

The right analog stick.

§l1: Button

The top-left shoulder button.

§l2: Button

The bottom-left shoulder button.

§r1: Button

The top-right shoulder button.

§r2: Button

The bottom-right shoulder button.

§up: Button

The up directional button.

§down: Button

The down directional button.

§left: Button

The left directional button.

§right: Button

The right directional button.

§x: Button

The “X” button.

§y: Button

The “Y” button.

§a: Button

The “A” button.

§b: Button

The “B” button.

§screen: Screen

The LCD screen

Implementations§

Source§

impl Controller

Source

pub unsafe fn new(id: ControllerId) -> Self

Creates a new controller.

§Safety

This function is unsafe because it allows the user to create multiple mutable references to the same controller. You likely want to implement Robot::new instead.

Source

pub fn is_connected(&self) -> Result<bool, ControllerError>

Returns false or true if the controller is connected.

Source

pub fn get_battery_level(&self) -> Result<i32, ControllerError>

Gets the battery level of the controller.

Source

pub fn get_battery_capacity(&self) -> Result<i32, ControllerError>

Gets the battery capacity of the controller.

Trait Implementations§

Source§

impl DataSource for Controller

Source§

type Data = ControllerData

The type of data produced by the data source.
Source§

type Error = ControllerError

The type of errors which could occur while reading data.
Source§

fn read(&self) -> Result<Self::Data, Self::Error>

Tries to read a new value form the data source.
Source§

impl Debug for Controller

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoBroadcast for T
where T: DataSource,

Source§

fn into_broadcast( self, ) -> Result<BroadcastWrapper<T>, (<T as DataSource>::Error, T)>

Converts the data source into a BroadcastWrapper. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.