pub struct GipHost<'d, A: UsbHostAllocator<'d>, DEV: GipDevice> { /* private fields */ }Expand description
GIP host class driver.
Generic over the USB host driver D and a GipDevice implementation
that customizes init sequences and input parsing.
§Lifecycle
- Register with
GipHost::try_registerafter USB enumeration. - Poll for events with
GipHost::poll. - Optionally send rumble with
GipHost::set_rumble.
Implementations§
Source§impl<'d, A: UsbHostAllocator<'d>, DEV: GipDevice> GipHost<'d, A, DEV>
impl<'d, A: UsbHostAllocator<'d>, DEV: GipDevice> GipHost<'d, A, DEV>
Sourcepub async fn try_register(
alloc: &A,
config_desc: &[u8],
enum_info: &EnumerationInfo,
) -> Result<Self, GipError>
pub async fn try_register( alloc: &A, config_desc: &[u8], enum_info: &EnumerationInfo, ) -> Result<Self, GipError>
Create and initialize a GIP host driver.
Performs the full setup sequence:
- Validates the device via
GipDevice::try_new. - Locates the GIP data interface in the configuration descriptor.
- Allocates interrupt IN and OUT pipes.
- Completes the GIP handshake: waits for the device’s Hello
message, responds with
GipDevice::init_packets, and drains remaining handshake traffic until the controller is active.
On success the driver is ready for poll.
§Errors
GipError::UnsupportedDeviceifGipDevice::try_newreturnsNone.GipError::NoInterfaceif no GIP interface is found.GipError::NoPipeif pipes cannot be allocated.GipError::Transferif a handshake transfer fails.
Sourcepub async fn poll(&mut self) -> Result<GipEvent, GipError>
pub async fn poll(&mut self) -> Result<GipEvent, GipError>
Poll for the next GIP event.
Reads from the interrupt IN endpoint, parses the GIP header, and
dispatches to the GipDevice for interpretation.
Any incoming message with the ACK flag (0x10) set is automatically acknowledged before being processed. This is required by the GIP protocol — controllers stall and stop sending input if the host fails to acknowledge flagged messages.
This method blocks until a meaningful event is available. Protocol messages that don’t produce user-facing events are acknowledged and consumed internally.
Sourcepub async fn read_raw(&mut self, buf: &mut [u8]) -> Result<usize, GipError>
pub async fn read_raw(&mut self, buf: &mut [u8]) -> Result<usize, GipError>
Read a raw GIP packet from the device.
Returns the number of bytes received. No parsing or ACK handling
is performed; use poll for the high-level interface.
Sourcepub async fn set_rumble(&mut self, cmd: &RumbleCommand) -> Result<(), GipError>
pub async fn set_rumble(&mut self, cmd: &RumbleCommand) -> Result<(), GipError>
Send a rumble command to the controller.
Sourcepub async fn stop_rumble(&mut self) -> Result<(), GipError>
pub async fn stop_rumble(&mut self) -> Result<(), GipError>
Stop all rumble motors.