diff --git a/emu_state.h b/emu_state.h index ab92db3..7e26dbc 100644 --- a/emu_state.h +++ b/emu_state.h @@ -513,6 +513,10 @@ struct EmuState { // adapter, 3 Nintendo charger; tv=0/1. --dock overrides. std::atomic dock_kind{0}; std::atomic dock_tv{true}; + // A clone of the Nintendo dock: 1 (--dock nintendo:clone) answers the + // reads HOS docks with (state 0x16, 0x0B, 0x18) but not the LED or hub + // messages; 2 (nintendo:mute) answers none of the dock's own messages. + std::atomic dock_clone{0}; std::atomic usb_pd_voltage_mv{5000}; std::atomic usb_pd_amperage_ma{1500}; diff --git a/main.cpp b/main.cpp index 03c6469..93d489a 100644 --- a/main.cpp +++ b/main.cpp @@ -344,7 +344,10 @@ int main(int argc, char *argv[]) { } else if (strcmp(argv[i], "--dock") == 0 && i + 1 < argc) { // What is on the USB-C port. Same contract as --oem: overrides // the ini. "nintendo", "thirdparty" (Ugreen-style), "charger", - // "none"; append ":notv" for a dock with nothing on its HDMI. + // "none"; append ":notv" for a dock with nothing on its HDMI, + // ":clone" for one that answers the reads HOS docks with but + // not the LED or hub messages, ":mute" for one that answers + // none of the Nintendo dock's own messages. const char *d = argv[++i]; uint8_t k = 0xFF; if (!strncmp(d, "nintendo", 8)) k = 1; @@ -357,6 +360,7 @@ int main(int argc, char *argv[]) { } state.dock_kind = k; state.dock_tv = strstr(d, ":notv") == nullptr; + state.dock_clone = strstr(d, ":mute") ? 2 : strstr(d, ":clone") ? 1 : 0; printf("[emu] Dock: %s%s [overrides ini]\n", d, ""); } else if (strcmp(argv[i], "--oem") == 0 && i + 1 < argc) { const char *oem = argv[++i]; diff --git a/t210/dock.cpp b/t210/dock.cpp index 92e48dd..341744c 100644 --- a/t210/dock.cpp +++ b/t210/dock.cpp @@ -255,6 +255,11 @@ void partner_vdm(const uint8_t *msg, uint32_t len) { // Nintendo dock vendor messages: [REQ, 0, 7E 05, rw, src, cmd, 0, ...] if (k != DOCK_NINTENDO || svid != 0x057E || len < 8 || !chip.nin_mode) return; + uint8_t clone = g_state ? g_state->dock_clone.load() : 0; + if (clone == 2 || (clone == 1 && (msg[6] == 0x01 || msg[6] == 0x20))) { + DLOG("dock clone: no answer to vendor message %02X\n", msg[6]); + return; + } uint8_t ncmd = msg[6]; memset(chip.staged, 0, sizeof(chip.staged)); uint8_t data[4] = {}; @@ -264,6 +269,9 @@ void partner_vdm(const uint8_t *msg, uint32_t len) { data[0] = 0x00; data[1] = 0x00; data[2] = 0x1D; data[3] = 0x00; size = 12; break; + case 0x0B: case 0x18: // read by HOS after the state; meaning unknown + size = 12; + break; case 0x01: // LED control memcpy(chip.led, &msg[8], len >= 12 ? 4 : 0); DLOG("dock LED set %02X %02X %02X %02X\n", msg[8], msg[9], msg[10], msg[11]);