Add dock clone modes

This commit is contained in:
Baptiste MOINE committed 2026-11-13 01:41:31 +01:00
1 parent 41245dc22b
commit afc3dfe28a
3 files changed
+17 -1

No files matched your search

+4
View File
@@ -513,6 +513,10 @@ struct EmuState {
// adapter, 3 Nintendo charger; tv=0/1. --dock overrides. // adapter, 3 Nintendo charger; tv=0/1. --dock overrides.
std::atomic<uint8_t> dock_kind{0}; std::atomic<uint8_t> dock_kind{0};
std::atomic<bool> dock_tv{true}; std::atomic<bool> 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<uint8_t> dock_clone{0};
std::atomic<uint16_t> usb_pd_voltage_mv{5000}; std::atomic<uint16_t> usb_pd_voltage_mv{5000};
std::atomic<uint16_t> usb_pd_amperage_ma{1500}; std::atomic<uint16_t> usb_pd_amperage_ma{1500};
+5 -1
View File
@@ -344,7 +344,10 @@ int main(int argc, char *argv[]) {
} else if (strcmp(argv[i], "--dock") == 0 && i + 1 < argc) { } else if (strcmp(argv[i], "--dock") == 0 && i + 1 < argc) {
// What is on the USB-C port. Same contract as --oem: overrides // What is on the USB-C port. Same contract as --oem: overrides
// the ini. "nintendo", "thirdparty" (Ugreen-style), "charger", // 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]; const char *d = argv[++i];
uint8_t k = 0xFF; uint8_t k = 0xFF;
if (!strncmp(d, "nintendo", 8)) k = 1; if (!strncmp(d, "nintendo", 8)) k = 1;
@@ -357,6 +360,7 @@ int main(int argc, char *argv[]) {
} }
state.dock_kind = k; state.dock_kind = k;
state.dock_tv = strstr(d, ":notv") == nullptr; 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, ""); printf("[emu] Dock: %s%s [overrides ini]\n", d, "");
} else if (strcmp(argv[i], "--oem") == 0 && i + 1 < argc) { } else if (strcmp(argv[i], "--oem") == 0 && i + 1 < argc) {
const char *oem = argv[++i]; const char *oem = argv[++i];
+8
View File
@@ -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, ...] // Nintendo dock vendor messages: [REQ, 0, 7E 05, rw, src, cmd, 0, ...]
if (k != DOCK_NINTENDO || svid != 0x057E || len < 8 || !chip.nin_mode) if (k != DOCK_NINTENDO || svid != 0x057E || len < 8 || !chip.nin_mode)
return; 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]; uint8_t ncmd = msg[6];
memset(chip.staged, 0, sizeof(chip.staged)); memset(chip.staged, 0, sizeof(chip.staged));
uint8_t data[4] = {}; 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; data[0] = 0x00; data[1] = 0x00; data[2] = 0x1D; data[3] = 0x00;
size = 12; size = 12;
break; break;
case 0x0B: case 0x18: // read by HOS after the state; meaning unknown
size = 12;
break;
case 0x01: // LED control case 0x01: // LED control
memcpy(chip.led, &msg[8], len >= 12 ? 4 : 0); 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]); DLOG("dock LED set %02X %02X %02X %02X\n", msg[8], msg[9], msg[10], msg[11]);