Struct gcnctrlusb::Listener
[−]
[src]
pub struct Listener<'a> { /* fields omitted */ }
An interface that reads packets of controller data on each iteration.
This interface owns an opened handle to the USB device that is closed once the Listener
instance is dropped.
Methods
impl<'a> Listener<'a>
[src]
fn read(&mut self) -> Result<[Option<Controller>; 4], Error>
Reads a data packet and returns the states for each of the four possibly connected controllers.
If reading a single packet takes over 1 second, a timeout error with occur. In testing, these packets are available at over 100 times per second.
Reasons an error may occur include:
- The USB device becomes disconnected
- The USB driver throws an error, fatal or not
- A USB message was successfully read, but it was not the right size
It is wise to treat all errors returned as fatal, and to reestablish the adapter connection
through Scanner::find_device
.