early-access version 2948
This commit is contained in:
parent
be5f850e61
commit
875eae2c07
@ -1,7 +1,7 @@
|
||||
yuzu emulator early access
|
||||
=============
|
||||
|
||||
This is the source code for early-access 2947.
|
||||
This is the source code for early-access 2948.
|
||||
|
||||
## Legal Notice
|
||||
|
||||
|
@ -35,12 +35,9 @@ void LanStation::OverrideInfo() {
|
||||
|
||||
LANDiscovery::LANDiscovery(Network::RoomNetwork& room_network_)
|
||||
: stations({{{1, this}, {2, this}, {3, this}, {4, this}, {5, this}, {6, this}, {7, this}}}),
|
||||
room_network{room_network_} {
|
||||
LOG_INFO(Service_LDN, "LANDiscovery");
|
||||
}
|
||||
room_network{room_network_} {}
|
||||
|
||||
LANDiscovery::~LANDiscovery() {
|
||||
LOG_INFO(Service_LDN, "~LANDiscovery");
|
||||
if (inited) {
|
||||
Result rc = Finalize();
|
||||
LOG_INFO(Service_LDN, "Finalize: {}", rc.raw);
|
||||
@ -62,7 +59,7 @@ void LANDiscovery::InitNetworkInfo() {
|
||||
}
|
||||
|
||||
void LANDiscovery::InitNodeStateChange() {
|
||||
for (auto& node_update : nodeChanges) {
|
||||
for (auto& node_update : node_changes) {
|
||||
node_update.state_change = NodeStateChange::None;
|
||||
}
|
||||
for (auto& node_state : node_last_states) {
|
||||
@ -97,8 +94,8 @@ Result LANDiscovery::GetNetworkInfo(NetworkInfo& out_network,
|
||||
if (state == State::AccessPointCreated || state == State::StationConnected) {
|
||||
std::memcpy(&out_network, &network_info, sizeof(network_info));
|
||||
for (std::size_t i = 0; i < buffer_count; i++) {
|
||||
out_updates[i].state_change = nodeChanges[i].state_change;
|
||||
nodeChanges[i].state_change = NodeStateChange::None;
|
||||
out_updates[i].state_change = node_changes[i].state_change;
|
||||
node_changes[i].state_change = NodeStateChange::None;
|
||||
}
|
||||
return ResultSuccess;
|
||||
}
|
||||
@ -168,9 +165,9 @@ Result LANDiscovery::Scan(std::vector<NetworkInfo>& networks, u16& count,
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result LANDiscovery::SetAdvertiseData(std::vector<u8>& data) {
|
||||
Result LANDiscovery::SetAdvertiseData(std::span<const u8> data) {
|
||||
std::scoped_lock lock{packet_mutex};
|
||||
std::size_t size = data.size();
|
||||
const std::size_t size = data.size();
|
||||
if (size > AdvertiseDataSizeMax) {
|
||||
return ResultAdvertiseDataTooLarge;
|
||||
}
|
||||
@ -328,7 +325,7 @@ Result LANDiscovery::Disconnect() {
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result LANDiscovery::Initialize(LanEventFunc lan_event, bool listening) {
|
||||
Result LANDiscovery::Initialize(LanEventFunc lan_event_, bool listening) {
|
||||
std::scoped_lock lock{packet_mutex};
|
||||
if (inited) {
|
||||
return ResultSuccess;
|
||||
@ -341,7 +338,7 @@ Result LANDiscovery::Initialize(LanEventFunc lan_event, bool listening) {
|
||||
}
|
||||
|
||||
connected_clients.clear();
|
||||
LanEvent = lan_event;
|
||||
LanEvent = lan_event_;
|
||||
|
||||
SetState(State::Initialized);
|
||||
|
||||
@ -439,7 +436,6 @@ void LANDiscovery::SendPacket(Network::LDNPacketType type, const Data& data,
|
||||
packet.local_ip = GetLocalIp();
|
||||
packet.remote_ip = remote_ip;
|
||||
|
||||
packet.data.clear();
|
||||
packet.data.resize(sizeof(data));
|
||||
std::memcpy(packet.data.data(), &data, sizeof(data));
|
||||
SendPacket(packet);
|
||||
@ -453,7 +449,6 @@ void LANDiscovery::SendPacket(Network::LDNPacketType type, Ipv4Address remote_ip
|
||||
packet.local_ip = GetLocalIp();
|
||||
packet.remote_ip = remote_ip;
|
||||
|
||||
packet.data.clear();
|
||||
SendPacket(packet);
|
||||
}
|
||||
|
||||
@ -465,7 +460,6 @@ void LANDiscovery::SendBroadcast(Network::LDNPacketType type, const Data& data)
|
||||
packet.broadcast = true;
|
||||
packet.local_ip = GetLocalIp();
|
||||
|
||||
packet.data.clear();
|
||||
packet.data.resize(sizeof(data));
|
||||
std::memcpy(packet.data.data(), &data, sizeof(data));
|
||||
SendPacket(packet);
|
||||
@ -478,7 +472,6 @@ void LANDiscovery::SendBroadcast(Network::LDNPacketType type) {
|
||||
packet.broadcast = true;
|
||||
packet.local_ip = GetLocalIp();
|
||||
|
||||
packet.data.clear();
|
||||
SendPacket(packet);
|
||||
}
|
||||
|
||||
@ -581,9 +574,9 @@ bool LANDiscovery::IsNodeStateChanged() {
|
||||
for (int i = 0; i < NodeCountMax; i++) {
|
||||
if (nodes[i].is_connected != node_last_states[i]) {
|
||||
if (nodes[i].is_connected) {
|
||||
nodeChanges[i].state_change |= NodeStateChange::Connect;
|
||||
node_changes[i].state_change |= NodeStateChange::Connect;
|
||||
} else {
|
||||
nodeChanges[i].state_change |= NodeStateChange::Disconnect;
|
||||
node_changes[i].state_change |= NodeStateChange::Disconnect;
|
||||
}
|
||||
node_last_states[i] = nodes[i].is_connected;
|
||||
changed = true;
|
||||
@ -598,7 +591,7 @@ bool LANDiscovery::IsFlagSet(ScanFilterFlag flag, ScanFilterFlag search_flag) co
|
||||
return (flag_value & search_flag_value) == search_flag_value;
|
||||
}
|
||||
|
||||
int LANDiscovery::GetStationCount() {
|
||||
int LANDiscovery::GetStationCount() const {
|
||||
int count = 0;
|
||||
for (const auto& station : stations) {
|
||||
if (station.GetStatus() != NodeStatus::Disconnected) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <random>
|
||||
#include <span>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
|
||||
@ -44,7 +45,7 @@ protected:
|
||||
|
||||
class LANDiscovery {
|
||||
public:
|
||||
typedef std::function<void()> LanEventFunc;
|
||||
using LanEventFunc = std::function<void()>;
|
||||
|
||||
LANDiscovery(Network::RoomNetwork& room_network_);
|
||||
~LANDiscovery();
|
||||
@ -58,7 +59,7 @@ public:
|
||||
|
||||
DisconnectReason GetDisconnectReason() const;
|
||||
Result Scan(std::vector<NetworkInfo>& networks, u16& count, const ScanFilter& filter);
|
||||
Result SetAdvertiseData(std::vector<u8>& data);
|
||||
Result SetAdvertiseData(std::span<const u8> data);
|
||||
|
||||
Result OpenAccessPoint();
|
||||
Result CloseAccessPoint();
|
||||
@ -74,7 +75,7 @@ public:
|
||||
u16 local_communication_version);
|
||||
Result Disconnect();
|
||||
|
||||
Result Initialize(LanEventFunc lan_event = empty_func, bool listening = true);
|
||||
Result Initialize(LanEventFunc lan_event_ = empty_func, bool listening = true);
|
||||
Result Finalize();
|
||||
|
||||
void ReceivePacket(const Network::LDNPacket& packet);
|
||||
@ -94,7 +95,7 @@ protected:
|
||||
|
||||
bool IsNodeStateChanged();
|
||||
bool IsFlagSet(ScanFilterFlag flag, ScanFilterFlag search_flag) const;
|
||||
int GetStationCount();
|
||||
int GetStationCount() const;
|
||||
MacAddress GetFakeMac() const;
|
||||
Result GetNodeInfo(NodeInfo& node, const UserConfig& user_config,
|
||||
u16 local_communication_version);
|
||||
@ -114,7 +115,7 @@ protected:
|
||||
bool inited{};
|
||||
std::mutex packet_mutex;
|
||||
std::array<LanStation, StationCountMax> stations;
|
||||
std::array<NodeLatestUpdate, NodeCountMax> nodeChanges{};
|
||||
std::array<NodeLatestUpdate, NodeCountMax> node_changes{};
|
||||
std::array<u8, NodeCountMax> node_last_states{};
|
||||
std::unordered_map<MacAddress, NetworkInfo, MACAddressHash> scan_results{};
|
||||
NodeInfo node_info{};
|
||||
@ -124,7 +125,7 @@ protected:
|
||||
|
||||
// TODO (flTobi): Should this be an std::set?
|
||||
std::vector<Ipv4Address> connected_clients;
|
||||
std::optional<Ipv4Address> host_ip = std::nullopt;
|
||||
std::optional<Ipv4Address> host_ip;
|
||||
|
||||
LanEventFunc LanEvent;
|
||||
|
||||
|
@ -205,8 +205,6 @@ public:
|
||||
}
|
||||
|
||||
void GetIpv4Address(Kernel::HLERequestContext& ctx) {
|
||||
LOG_CRITICAL(Service_LDN, "called");
|
||||
|
||||
const auto network_interface = Network::GetSelectedNetworkInterface();
|
||||
|
||||
if (!network_interface) {
|
||||
|
@ -31,13 +31,7 @@ enum class NodeStateChange : u8 {
|
||||
DisconnectAndConnect,
|
||||
};
|
||||
|
||||
inline NodeStateChange operator|(NodeStateChange a, NodeStateChange b) {
|
||||
return static_cast<NodeStateChange>(static_cast<u8>(a) | static_cast<u8>(b));
|
||||
}
|
||||
|
||||
inline NodeStateChange operator|=(NodeStateChange& a, NodeStateChange b) {
|
||||
return a = a | b;
|
||||
}
|
||||
DECLARE_ENUM_FLAG_OPERATORS(NodeStateChange)
|
||||
|
||||
enum class ScanFilterFlag : u32 {
|
||||
None = 0,
|
||||
|
@ -188,7 +188,7 @@ std::vector<NetworkInterface> GetAvailableNetworkInterfaces() {
|
||||
std::optional<NetworkInterface> GetSelectedNetworkInterface() {
|
||||
const auto& selected_network_interface = Settings::values.network_interface.GetValue();
|
||||
const auto network_interfaces = Network::GetAvailableNetworkInterfaces();
|
||||
if (network_interfaces.size() == 0) {
|
||||
if (network_interfaces.empty()) {
|
||||
LOG_ERROR(Network, "GetAvailableNetworkInterfaces returned no interfaces");
|
||||
return std::nullopt;
|
||||
}
|
||||
@ -209,7 +209,7 @@ std::optional<NetworkInterface> GetSelectedNetworkInterface() {
|
||||
void SelectFirstNetworkInterface() {
|
||||
const auto network_interfaces = Network::GetAvailableNetworkInterfaces();
|
||||
|
||||
if (network_interfaces.size() == 0) {
|
||||
if (network_interfaces.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -716,7 +716,7 @@ RoomMember::CallbackHandle<ProxyPacket> RoomMember::BindOnProxyPacketReceived(
|
||||
|
||||
RoomMember::CallbackHandle<LDNPacket> RoomMember::BindOnLdnPacketReceived(
|
||||
std::function<void(const LDNPacket&)> callback) {
|
||||
return room_member_impl->Bind(callback);
|
||||
return room_member_impl->Bind(std::move(callback));
|
||||
}
|
||||
|
||||
RoomMember::CallbackHandle<RoomInformation> RoomMember::BindOnRoomInformationChanged(
|
||||
|
@ -1417,7 +1417,7 @@ void ConfigureInputPlayer::HandleClick(
|
||||
ui->controllerFrame->BeginMappingAnalog(button_id);
|
||||
}
|
||||
|
||||
timeout_timer->start(2500); // Cancel after 2.5 seconds
|
||||
timeout_timer->start(4000); // Cancel after 4 seconds
|
||||
poll_timer->start(25); // Check for new inputs every 25ms
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user