embassy-usb-host

Crates

git

Versions

default

Flavors

Module gip

Module gip 

Source
Expand description

GIP (Gaming Input Protocol) host class driver.

Supports Xbox One, Xbox Series X|S, and compatible controllers using Microsoft’s Gaming Input Protocol (MS-GIPUSB) over USB.

§Architecture

GipHost handles the common GIP protocol framing — headers, ACKs, sequence numbers, Hello handshake, and channel management. Device-specific behavior (init sequences, input parsing quirks) is delegated to a GipDevice trait implementation.

A built-in XboxOneSGamepad covers the Xbox One S controller and is broadly compatible with other standard GIP gamepads.

§GIP lifecycle

After USB enumeration, GipHost::try_register performs the full GIP handshake:

  1. The controller enters the Arrival state and sends Hello (0x02) messages every ~500 ms.
  2. The driver responds with the device-specific init packets from GipDevice::init_packets (e.g., power-on).
  3. Remaining handshake traffic (ACKs, status) is drained until the controller transitions to the Active state.

Once try_register returns successfully, the driver is ready for GipHost::poll.

§Example

Rumble while the A button is held:

use embassy_usb_host::class::gip::{GipHost, XboxOneSGamepad, GipEvent, RumbleCommand};

let mut gip = GipHost::<_, XboxOneSGamepad>::try_register(
    &bus,
    &config_buf[..config_len],
    addr,
    dev_desc.vendor_id,
    dev_desc.product_id,
).await?;

let mut rumbling = false;
loop {
    match gip.poll().await? {
        GipEvent::Input(report) => {
            if report.a && !rumbling {
                gip.set_rumble(&RumbleCommand {
                    strong: 128,
                    weak: 64,
                    ..Default::default()
                }).await?;
                rumbling = true;
            } else if !report.a && rumbling {
                gip.stop_rumble().await?;
                rumbling = false;
            }
        }
        _ => {}
    }
}

Structs§

GamepadReport
Parsed gamepad input report from a GIP controller.
GipHost
GIP host class driver.
GipInterfaceInfo
Information about a GIP data interface found in a configuration descriptor.
RumbleCommand
Rumble motor intensities.
XboxOneSGamepad
GIP device implementation for the Xbox One S controller.

Enums§

GipError
GIP host class driver error.
GipEvent
Event produced by GipHost::poll.

Constants§

GIP_MAX_PACKET
Maximum GIP packet size (matches the Command/Low-Latency MTU).

Traits§

GipDevice
Trait for GIP device-specific behavior.

Functions§

build_standard_rumble
Build a standard GIP rumble packet (message type 0x09, 9-byte payload).
find_gip
Locate the GIP data interface in a configuration descriptor.
parse_standard_input
Parse a standard GIP gamepad input report (message type 0x20).