diff --git a/aurora-main/lib/dolphin/pad/pad.cpp b/aurora-main/lib/dolphin/pad/pad.cpp index 75ef372..1b315ca 100644 --- a/aurora-main/lib/dolphin/pad/pad.cpp +++ b/aurora-main/lib/dolphin/pad/pad.cpp @@ -399,19 +399,20 @@ const char* PADGetNameForControllerIndex(const u32 idx) { } void PADSetPortForIndex(const u32 idx, const u32 port) { + if (port >= PAD_MAX_CONTROLLERS) return; const auto* ctrl = __PADGetControllerForIndex(idx); if (ctrl == nullptr) { return; } - const int32_t oldPort = SDL_GetGamepadPlayerIndex(ctrl->m_controller); + const int32_t oldPort = aurora::input::player_index(ctrl->m_index); if (const auto* dest = aurora::input::get_controller_for_player(port); dest != nullptr && dest != ctrl) { - SDL_SetGamepadPlayerIndex(dest->m_controller, -1); + aurora::input::set_player_index(dest->m_index, -1); } if (oldPort >= 0 && oldPort != port) { aurora::input::persist_controller_for_player(oldPort, nullptr); } - SDL_SetGamepadPlayerIndex(ctrl->m_controller, static_cast(port)); + aurora::input::set_player_index(ctrl->m_index, static_cast(port)); aurora::input::persist_controller_for_player(port, ctrl); } @@ -437,7 +438,7 @@ void PADClearPort(const u32 port) { if (ctrl == nullptr) { return; } - SDL_SetGamepadPlayerIndex(ctrl->m_controller, -1); + aurora::input::set_player_index(ctrl->m_index, -1); } // Secondary bindings live only in memory; the runtime re-applies them from its diff --git a/aurora-main/lib/input.cpp b/aurora-main/lib/input.cpp index 6c9418b..96a9c1d 100644 --- a/aurora-main/lib/input.cpp +++ b/aurora-main/lib/input.cpp @@ -414,6 +414,29 @@ SDL_JoystickID add_controller(SDL_JoystickID which) noexcept { g_GameControllers[instance] = controller; ensure_player_index(g_GameControllers[instance]); apply_port_preferences(); +#if defined(SDL_PLATFORM_MACOS) + // First-use convenience only: never override a saved assignment or None. + if (g_portPreferences[0].state == PortPreferenceState::Unset) { + bool hasOtherPortPreference = false; + for (size_t port = 1; port < g_portPreferences.size(); ++port) { + if (g_portPreferences[port].state == PortPreferenceState::Controller && + identity_match(g_portPreferences[port].identity, controller_identity(g_GameControllers[instance])) != + IdentityMatch::None) { + hasOtherPortPreference = true; + break; + } + } + if (!hasOtherPortPreference) { + const auto* p0 = get_controller_for_player(0); + if (p0 == nullptr) { + assign_player_index(g_GameControllers[instance], 0); + persist_controller_for_player(0, &g_GameControllers[instance]); + } else if (p0 == &g_GameControllers[instance]) { + persist_controller_for_player(0, &g_GameControllers[instance]); + } + } + } +#endif return instance; } diff --git a/runtime/src/controller_mapping_wizard.cpp b/runtime/src/controller_mapping_wizard.cpp index fe1ba1d..9291dd6 100644 --- a/runtime/src/controller_mapping_wizard.cpp +++ b/runtime/src/controller_mapping_wizard.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -146,7 +147,7 @@ std::string BuildMappingString() { mapping += std::string(kSteps[i].mappingKey) + ":" + *g_wizard.bindings[i] + ","; } } - mapping += "platform:Windows,"; + mapping += std::string("platform:") + SDL_GetPlatform() + ","; return mapping; } diff --git a/runtime/src/hle/net/network_socket.cpp b/runtime/src/hle/net/network_socket.cpp index b5e0b17..f8a55fb 100644 --- a/runtime/src/hle/net/network_socket.cpp +++ b/runtime/src/hle/net/network_socket.cpp @@ -467,7 +467,8 @@ int32_t HandleIpTopIoctlv(uint32_t cmd, const std::vector& in, const s const int ret = sendto(s->native, reinterpret_cast(sendData), static_cast(sendSize), static_cast(flags), destPtr, destLen); const int hostError = ret < 0 ? NativeLastError() : 0; - int32_t result = SocketResult(ret); + // Diagnostics may change the native error; use the send result captured above. + int32_t result = ret >= 0 ? SocketResult(ret) : SocketErrorResult(hostError); if (patchedWrite && ret == static_cast(sendSize)) { result = static_cast(in[0].size); }