|
@@ -462,8 +462,12 @@ void SteamPuckController::onAuxReport(int slot, uint8_t rid,
|
|
|
// Forward the controller's status report VERBATIM (the real puck does this; it's how the host reads
|
|
// Forward the controller's status report VERBATIM (the real puck does this; it's how the host reads
|
|
|
// battery). Padding the report to the descriptor-declared length broke battery in both lizard and
|
|
// battery). Padding the report to the descriptor-declared length broke battery in both lizard and
|
|
|
// Steam, so it's reverted -- send exactly what the controller sent.
|
|
// Steam, so it's reverted -- send exactly what the controller sent.
|
|
|
- if (g_slot[slot].used && hid[slot].ready())
|
|
|
|
|
|
|
+ if (g_slot[slot].used && hid[slot].ready()) {
|
|
|
|
|
+ // capture the pushed status report (0x43 battery / 0x44) device->host for the WebUSB panel: this is
|
|
|
|
|
+ // the channel Steam actually reads battery from; marker 0xFB = "->host push".
|
|
|
|
|
+ hapLogAdd(0xFB, rid, data, n);
|
|
|
hid[slot].sendReport(rid, data, n);
|
|
hid[slot].sendReport(rid, data, n);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// wake nudge: a bare USB resume signal is NOT enough to wake some hosts (Windows in particular) -- they only
|
|
// wake nudge: a bare USB resume signal is NOT enough to wake some hosts (Windows in particular) -- they only
|
|
@@ -568,7 +572,7 @@ void SteamPuckController::task()
|
|
|
// slot. The real puck's per-slot edge-triggered 0x79 prevents re-triggering Steam's connect-chime loop.
|
|
// slot. The real puck's per-slot edge-triggered 0x79 prevents re-triggering Steam's connect-chime loop.
|
|
|
static bool usbConn[NSLOT] = { 0 };
|
|
static bool usbConn[NSLOT] = { 0 };
|
|
|
static unsigned long last79[NSLOT] = { 0 }, last7B[NSLOT] = { 0 },
|
|
static unsigned long last79[NSLOT] = { 0 }, last7B[NSLOT] = { 0 },
|
|
|
- connEdgeMs[NSLOT] = { 0 };
|
|
|
|
|
|
|
+ connEdgeMs[NSLOT] = { 0 }, last43[NSLOT] = { 0 };
|
|
|
for (int s = 0; s < NSLOT; s++) {
|
|
for (int s = 0; s < NSLOT; s++) {
|
|
|
if (!g_slot[s].used || !hid[s].ready())
|
|
if (!g_slot[s].used || !hid[s].ready())
|
|
|
continue;
|
|
continue;
|
|
@@ -586,6 +590,7 @@ void SteamPuckController::task()
|
|
|
if (conn && !usbConn[s])
|
|
if (conn && !usbConn[s])
|
|
|
connEdgeMs[s] = millis();
|
|
connEdgeMs[s] = millis();
|
|
|
uint8_t st = conn ? 0x02 : 0x01;
|
|
uint8_t st = conn ? 0x02 : 0x01;
|
|
|
|
|
+ hapLogAdd(0xFB, 0x79, &st, 1); // ->host push (capture)
|
|
|
hid[s].sendReport(0x79, &st, 1);
|
|
hid[s].sendReport(0x79, &st, 1);
|
|
|
usbConn[s] = conn;
|
|
usbConn[s] = conn;
|
|
|
last79[s] = millis();
|
|
last79[s] = millis();
|
|
@@ -609,9 +614,27 @@ void SteamPuckController::task()
|
|
|
mag = 95;
|
|
mag = 95;
|
|
|
s7b[8] = (uint8_t)(0u - (uint8_t)mag);
|
|
s7b[8] = (uint8_t)(0u - (uint8_t)mag);
|
|
|
}
|
|
}
|
|
|
|
|
+ hapLogAdd(0xFB, 0x7B, s7b, 12); // ->host push (capture)
|
|
|
hid[s].sendReport(0x7B, s7b, 12);
|
|
hid[s].sendReport(0x7B, s7b, 12);
|
|
|
last7B[s] = millis();
|
|
last7B[s] = millis();
|
|
|
}
|
|
}
|
|
|
|
|
+ // Synthesized 0x43 = ID_TRITON_BATTERY_STATUS for SDL/Steam's gamepad driver. The verbatim forward of
|
|
|
|
|
+ // the controller's own 0x43 (onAuxReport) is what the LIZARD/kernel path reads, but SDL's Triton driver
|
|
|
|
|
+ // requires the FULL TritonBatteryStatus_t length (r >= 1 + 14) and lapses to the "wired" glyph without a
|
|
|
|
|
+ // fresh one -- so we push a clean 14-byte report from g_battery every 2s. Body: [ucChargeState][ucBattery
|
|
|
|
|
+ // Level][voltages/current/temp = 0]; SDL only reads the first two. Map unknown/reset state -> discharging
|
|
|
|
|
+ // so it shows ON_BATTERY + % rather than UNKNOWN. Skipped until the controller has reported a level.
|
|
|
|
|
+ if (conn && g_battery[s] && millis() - last43[s] >= 2000) {
|
|
|
|
|
+ uint8_t st = g_batteryState[s];
|
|
|
|
|
+ if (st != 1 && st != 2 && st != 4)
|
|
|
|
|
+ st = 1; // EChargeState discharging -> SDL_POWERSTATE_ON_BATTERY
|
|
|
|
|
+ uint8_t b43[14] = { 0 };
|
|
|
|
|
+ b43[0] = st; // ucChargeState
|
|
|
|
|
+ b43[1] = g_battery[s]; // ucBatteryLevel (percent)
|
|
|
|
|
+ hapLogAdd(0xFB, 0x43, b43, 14); // ->host push (capture)
|
|
|
|
|
+ hid[s].sendReport(0x43, b43, sizeof b43);
|
|
|
|
|
+ last43[s] = millis();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
// Reset edge state for slots that are no longer used/ready (so a re-bond sees a fresh edge).
|
|
// Reset edge state for slots that are no longer used/ready (so a re-bond sees a fresh edge).
|
|
|
for (int s = 0; s < NSLOT; s++)
|
|
for (int s = 0; s < NSLOT; s++)
|