diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index 83f0b7d50..4e33bc126 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -2712,6 +2712,8 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou axis_value = lt[first_player] << 8; else axis_value = 0; + if (axisDesc.inverted) + axis_value = 0xff00u - axis_value; half_axis_count++; } else diff --git a/core/hw/naomi/naomi_roms.h b/core/hw/naomi/naomi_roms.h index 480619804..003935e02 100644 --- a/core/hw/naomi/naomi_roms.h +++ b/core/hw/naomi/naomi_roms.h @@ -3939,7 +3939,9 @@ Games[] = { "mpr-23723.ic5", 0x4800000, 0x1000000 }, { "mpr-23724.ic6", 0x5800000, 0x1000000 }, { NULL, 0, 0 }, - } + }, + NULL, + &wrungp_inputs, }, // Wave Runner GP (USA, Rev A) { @@ -3967,7 +3969,9 @@ Games[] = //ROM_LOAD( "epr-19250.ic8", 0x000000, 0x010000, CRC(542d3836) SHA1(128cb0bfaf05791d219437653002f6bb948a4ad5) ) { NULL, 0, 0 }, - } + }, + NULL, + &wrungp_inputs, }, // World Kicks (WK2 Ver. A) { diff --git a/core/hw/naomi/naomi_roms_input.h b/core/hw/naomi/naomi_roms_input.h index fc70e2876..9ef77600e 100644 --- a/core/hw/naomi/naomi_roms_input.h +++ b/core/hw/naomi/naomi_roms_input.h @@ -363,6 +363,22 @@ static InputDescriptors tokyobus_inputs = { }, }; +static InputDescriptors wrungp_inputs = { + { + { NAOMI_UP_KEY, "VIEW" }, + NAO_START_DESC + NAO_BASE_BTN_DESC + { 0 }, + }, + { + { "HANDLE BAR", Full, 0 }, + { "THROTTLE LEVER", Half, 1, true }, + { "ROLL", Full, 2 }, + { "PITCH", Full, 3 }, + { NULL }, + }, +}; + // // AtomisWave games // diff --git a/core/network/naomi_network.cpp b/core/network/naomi_network.cpp index bb60e158c..c0920c5ae 100644 --- a/core/network/naomi_network.cpp +++ b/core/network/naomi_network.cpp @@ -314,10 +314,10 @@ bool NaomiNetwork::startNetwork() u8 buf[2]; if (::recv(client_sock, (char *)buf, 2, 0) < 2) { - ERROR_LOG(NETWORK, "Connection failed: errno=%d", get_last_error()); + ERROR_LOG(NETWORK, "recv failed: errno=%d", get_last_error()); closesocket(client_sock); - client_sock = -1; - gui_display_notification("Connection failed", 10000); + client_sock = INVALID_SOCKET; + gui_display_notification("Server failed to start", 10000); return false; } @@ -343,10 +343,26 @@ void NaomiNetwork::pipeSlaves() char buf[16384]; for (auto it = slaves.begin(); it != slaves.end() - 1; it++) { + if (*it == INVALID_SOCKET || *(it + 1) == INVALID_SOCKET) + // TODO keep link on + continue; ssize_t l = ::recv(*it, buf, sizeof(buf), 0); - if (l > 0) - ::send(*(it + 1), buf, l, 0); - // TODO handle errors + if (l <= 0) + { + if (get_last_error() == L_EAGAIN || get_last_error() == L_EWOULDBLOCK) + continue; + WARN_LOG(NETWORK, "pipeSlaves: receive failed. errno=%d", get_last_error()); + closesocket(*it); + *it = INVALID_SOCKET; + continue; + } + ssize_t l2 = ::send(*(it + 1), buf, l, 0); + if (l2 != l) + { + WARN_LOG(NETWORK, "pipeSlaves: send failed. errno=%d", get_last_error()); + closesocket(*(it + 1)); + *(it + 1) = INVALID_SOCKET; + } } } @@ -369,10 +385,12 @@ bool NaomiNetwork::receive(u8 *data, u32 size) WARN_LOG(NETWORK, "receiveNetwork: read failed. errno=%d", get_last_error()); if (isMaster()) { - slaves.back() = -1; + slaves.back() = INVALID_SOCKET; closesocket(sockfd); got_token = false; } + else + shutdown(); } return false; } @@ -389,10 +407,12 @@ bool NaomiNetwork::receive(u8 *data, u32 size) WARN_LOG(NETWORK, "receiveNetwork: read failed. errno=%d", get_last_error()); if (isMaster()) { - slaves.back() = -1; + slaves.back() = INVALID_SOCKET; closesocket(sockfd); got_token = false; } + else + shutdown(); return false; } } @@ -418,16 +438,18 @@ void NaomiNetwork::send(u8 *data, u32 size) return; u16 pktnum = packet_number + 1; - if (::send(sockfd, (const char *)&pktnum, sizeof(pktnum), 0) < 2) + if (::send(sockfd, (const char *)&pktnum, sizeof(pktnum), 0) < sizeof(pktnum)) { - if (errno != L_EAGAIN && errno != L_EWOULDBLOCK) + if (get_last_error() != L_EAGAIN && get_last_error() != L_EWOULDBLOCK) { WARN_LOG(NETWORK, "send failed. errno=%d", get_last_error()); if (isMaster()) { - slaves.front() = -1; + slaves.front() = INVALID_SOCKET; closesocket(sockfd); } + else + shutdown(); } return; } @@ -436,9 +458,11 @@ void NaomiNetwork::send(u8 *data, u32 size) WARN_LOG(NETWORK, "send failed. errno=%d", get_last_error()); if (isMaster()) { - slaves.front() = -1; + slaves.front() = INVALID_SOCKET; closesocket(sockfd); } + else + shutdown(); } else { @@ -453,14 +477,17 @@ void NaomiNetwork::shutdown() network_stopping = true; { std::lock_guard lock(mutex); - for (auto& clientSock : slaves) + for (auto& sock : slaves) { - closesocket(clientSock); - clientSock = -1; + closesocket(sock); + sock = INVALID_SOCKET; } } if (client_sock != INVALID_SOCKET) + { closesocket(client_sock); + client_sock = INVALID_SOCKET; + } } void NaomiNetwork::terminate()