pub fn read_input(&mut self, command: Option<&PollCommand>) -> Result<Device, Error<E>> {
        let mut buffer = [0u8; MESSAGE_MAX_LENGTH];
        let data = self.read_port(command)?;

        // Shift the controller data over because we don't need the header anymore
        buffer[0 .. MESSAGE_MAX_LENGTH - 3].copy_from_slice(&data[HEADER_LEN..]);

        let controller = ControllerData { data: buffer };
        let device;

        unsafe {
            device = match data[1] {
                CONTROLLER_NOT_PRESENT => Device::None,
                CONTROLLER_CONFIGURATION => Device::ConfigurationMode,
                CONTROLLER_MOUSE => Device::Mouse(controller.pm),
                CONTROLLER_CLASSIC => Device::Classic(controller.classic),
                CONTROLLER_ANALOG_JOYSTICK => Device::AnalogJoystick(controller.ds),
                CONTROLLER_DUALSHOCK_DIGITAL => Device::Classic(controller.classic),                
                CONTROLLER_DUALSHOCK_ANALOG => Device::DualShock(controller.ds),
                CONTROLLER_DUALSHOCK_PRESSURE => Device::DualShock2(controller.ds2),
                CONTROLLER_JOGCON => Device::JogCon(controller.jc),
                CONTROLLER_NEGCON => Device::NegCon(controller.nc),
                CONTROLLER_GUNCON => Device::GunCon(controller.gc),
                _ => Device::Unknown,
            }
        }

        Ok(device)
    }
/// Ask the controller for input states. Different contoller types will be returned automatically
/// for you. If you'd like to cooerce a controller yourself, use `read_raw`.
Ask the controller for input states. Different contoller types will be returned automatically
for you. If you'd like to cooerce a controller yourself, use `read_raw`.
Ask the controller for input states . Different contoller types will be returned automatically for you . If you ' d like to cooerce a controller yourself use ` read_raw ` .
pub fn read_input(&mut self, command: Option<&PollCommand>) -> Result<Device, Error<E>> {
        let mut buffer = [0u8; MESSAGE_MAX_LENGTH];
        let data = self.read_port(command)?;
        // Shift the controller data over because we don't need the header anymore
        buffer[0 .. MESSAGE_MAX_LENGTH - 3].copy_from_slice(&data[HEADER_LEN..]);
        let controller = ControllerData { data: buffer };
        let device;
        unsafe {
            device = match data[1] {
                CONTROLLER_NOT_PRESENT => Device::None,
                CONTROLLER_CONFIGURATION => Device::ConfigurationMode,
                CONTROLLER_MOUSE => Device::Mouse(controller.pm),
                CONTROLLER_CLASSIC => Device::Classic(controller.classic),
                CONTROLLER_ANALOG_JOYSTICK => Device::AnalogJoystick(controller.ds),
                CONTROLLER_DUALSHOCK_DIGITAL => Device::Classic(controller.classic),                
                CONTROLLER_DUALSHOCK_ANALOG => Device::DualShock(controller.ds),
                CONTROLLER_DUALSHOCK_PRESSURE => Device::DualShock2(controller.ds2),
                CONTROLLER_JOGCON => Device::JogCon(controller.jc),
                CONTROLLER_NEGCON => Device::NegCon(controller.nc),
                CONTROLLER_GUNCON => Device::GunCon(controller.gc),
                _ => Device::Unknown,
            }
        }
        Ok(device)
    }
pub fn read_input ( & mut self , command : Option < & PollCommand > ) -> Result < Device , Error < E > > { let mut buffer = [ 0u8 ; MESSAGE_MAX_LENGTH ] ; let data = self . read_port ( command ) ? ; // Shift the controller data over because we don't need the header anymore buffer [ 0 .. MESSAGE_MAX_LENGTH - 3 ] . copy_from_slice ( & data [ HEADER_LEN .. ] ) ; let controller = ControllerData { data : buffer } ; let device ; unsafe { device = match data [ 1 ] { CONTROLLER_NOT_PRESENT => Device :: None , CONTROLLER_CONFIGURATION => Device :: ConfigurationMode , CONTROLLER_MOUSE => Device :: Mouse ( controller . pm ) , CONTROLLER_CLASSIC => Device :: Classic ( controller . classic ) , CONTROLLER_ANALOG_JOYSTICK => Device :: AnalogJoystick ( controller . ds ) , CONTROLLER_DUALSHOCK_DIGITAL => Device :: Classic ( controller . classic ) , CONTROLLER_DUALSHOCK_ANALOG => Device :: DualShock ( controller . ds ) , CONTROLLER_DUALSHOCK_PRESSURE => Device :: DualShock2 ( controller . ds2 ) , CONTROLLER_JOGCON => Device :: JogCon ( controller . jc ) , CONTROLLER_NEGCON => Device :: NegCon ( controller . nc ) , CONTROLLER_GUNCON => Device :: GunCon ( controller . gc ) , _ => Device :: Unknown , } } Ok ( device ) }
Ask the controller for input states.
Ask the controller for input states .
&mut self
command
Option<&PollCommand>
&mut self
command
Option<&PollCommand>