mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-26 04:10:04 +00:00
netCore stubb
This commit is contained in:
parent
6a72bd62b5
commit
281a84e8c5
@ -5,6 +5,7 @@ add_subdirectory(common)
|
|||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
add_subdirectory(video_core)
|
add_subdirectory(video_core)
|
||||||
add_subdirectory(audio_core)
|
add_subdirectory(audio_core)
|
||||||
|
add_subdirectory(net_core)
|
||||||
add_subdirectory(input_common)
|
add_subdirectory(input_common)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
if (ENABLE_SDL2)
|
if (ENABLE_SDL2)
|
||||||
|
@ -97,7 +97,7 @@ if (APPLE)
|
|||||||
else()
|
else()
|
||||||
add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS})
|
add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS})
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(citra-qt core video_core audio_core common input_common)
|
target_link_libraries(citra-qt core video_core audio_core net_core common input_common)
|
||||||
target_link_libraries(citra-qt ${OPENGL_gl_LIBRARY} ${CITRA_QT_LIBS})
|
target_link_libraries(citra-qt ${OPENGL_gl_LIBRARY} ${CITRA_QT_LIBS})
|
||||||
target_link_libraries(citra-qt ${PLATFORM_LIBRARIES} Threads::Threads)
|
target_link_libraries(citra-qt ${PLATFORM_LIBRARIES} Threads::Threads)
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include "input_common/keyboard.h"
|
#include "input_common/keyboard.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
|
#include "net_core/local.h"
|
||||||
#include "video_core/debug_utils/debug_utils.h"
|
#include "video_core/debug_utils/debug_utils.h"
|
||||||
#include "video_core/video_core.h"
|
#include "video_core/video_core.h"
|
||||||
|
|
||||||
@ -108,9 +109,11 @@ GRenderWindow::GRenderWindow(QWidget* parent, EmuThread* emu_thread)
|
|||||||
setWindowTitle(QString::fromStdString(window_title));
|
setWindowTitle(QString::fromStdString(window_title));
|
||||||
|
|
||||||
InputCommon::Init();
|
InputCommon::Init();
|
||||||
|
NetCore::Local::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
GRenderWindow::~GRenderWindow() {
|
GRenderWindow::~GRenderWindow() {
|
||||||
|
NetCore::Local::Shutdown();
|
||||||
InputCommon::Shutdown();
|
InputCommon::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ namespace Log {
|
|||||||
SUB(Audio, DSP) \
|
SUB(Audio, DSP) \
|
||||||
SUB(Audio, Sink) \
|
SUB(Audio, Sink) \
|
||||||
CLS(Input) \
|
CLS(Input) \
|
||||||
|
CLS(Network) \
|
||||||
CLS(Loader)
|
CLS(Loader)
|
||||||
|
|
||||||
// GetClassName is a macro defined by Windows.h, grrr...
|
// GetClassName is a macro defined by Windows.h, grrr...
|
||||||
|
@ -90,6 +90,7 @@ enum class Class : ClassType {
|
|||||||
Audio_Sink, ///< Emulator audio output backend
|
Audio_Sink, ///< Emulator audio output backend
|
||||||
Loader, ///< ROM loader
|
Loader, ///< ROM loader
|
||||||
Input, ///< Input emulation
|
Input, ///< Input emulation
|
||||||
|
Network, ///< Network emulation
|
||||||
Count ///< Total number of logging classes
|
Count ///< Total number of logging classes
|
||||||
};
|
};
|
||||||
|
|
||||||
|
14
src/net_core/CMakeLists.txt
Normal file
14
src/net_core/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
set(SRCS
|
||||||
|
net_core.cpp
|
||||||
|
local.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(HEADERS
|
||||||
|
net_core.h
|
||||||
|
local.h
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
create_directory_groups(${SRCS} ${HEADERS})
|
||||||
|
|
||||||
|
add_library(net_core STATIC ${SRCS} ${HEADERS})
|
90
src/net_core/local.cpp
Normal file
90
src/net_core/local.cpp
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// Copyright 2017 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "common/logging/log.h"
|
||||||
|
#include "net_core/local.h"
|
||||||
|
|
||||||
|
namespace NetCore {
|
||||||
|
namespace Local {
|
||||||
|
|
||||||
|
bool Init() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Shutdown() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
}
|
||||||
|
|
||||||
|
MemberState GetMemberState() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
return MemberState::Idle;
|
||||||
|
}
|
||||||
|
|
||||||
|
RoomState GetRoomState() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
return RoomState::Closed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsConnected() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemberList GetMemberInformation() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
RoomInformation GetRoomInformation() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::deque<ChatEntry> PopChatEntries() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::deque<WifiPacket> PopWifiPackets(WifiPacket::PacketType type, const MacAddress& sender) {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendChatMessage(const std::string& message) {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendWifiPacket(const WifiPacket& packet) {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetStatistics() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetPing() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Join(const std::string& nickname, const std::string& server, const uint16_t serverPort, const uint16_t clientPort) {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Leave() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Create(const std::string& name, const std::string& server, uint16_t server_port) {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Destroy() {
|
||||||
|
LOG_DEBUG(Network, "(STUBBED) called");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
167
src/net_core/local.h
Normal file
167
src/net_core/local.h
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
// Copyright 2017 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <deque>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace NetCore {
|
||||||
|
namespace Local {
|
||||||
|
|
||||||
|
const uint16_t DefaultPort = 1234;
|
||||||
|
|
||||||
|
using MacAddress = std::array<uint8_t, 6>;
|
||||||
|
const MacAddress NoPreferredMac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
|
const MacAddress BroadcastMac = NoPreferredMac;
|
||||||
|
|
||||||
|
struct MemberInformation {
|
||||||
|
std::string nickname; // Nickname of the member.
|
||||||
|
std::string game_name; // Name of the game they're currently playing, or empty if they're not playing anything.
|
||||||
|
MacAddress mac_address; // MAC address associated with this member.
|
||||||
|
};
|
||||||
|
using MemberList = std::vector<MemberInformation>;
|
||||||
|
|
||||||
|
struct RoomInformation {
|
||||||
|
std::string name; // Name of the room
|
||||||
|
uint32_t member_slots; // Maximum number of members in this room
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Information about the received WiFi packets.
|
||||||
|
/// Acts as our own 802.11 header.
|
||||||
|
struct WifiPacket {
|
||||||
|
enum class PacketType {
|
||||||
|
Beacon,
|
||||||
|
ConnectionRequest,
|
||||||
|
ConnectionResponse,
|
||||||
|
Data
|
||||||
|
};
|
||||||
|
PacketType type; ///< The type of 802.11 frame, Beacon / Data.
|
||||||
|
std::vector<uint8_t> data; ///< Raw 802.11 frame data, starting at the management frame header for management frames.
|
||||||
|
MacAddress transmitter_address; ///< Mac address of the transmitter.
|
||||||
|
MacAddress destination_address; ///< Mac address of the receiver.
|
||||||
|
uint8_t data_channel; ///< The Data Channel used by NWM_UDS::SendTo and Bind. Works like a port.
|
||||||
|
/// Only used by Packets of Type Data
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Represents a chat message.
|
||||||
|
struct ChatEntry {
|
||||||
|
std::string nickname; ///< Nickname of the client who sent this message.
|
||||||
|
std::string message; ///< Body of the message.
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class MemberState {
|
||||||
|
Idle, // Default state
|
||||||
|
Error, // Some error [permissions to network device missing or something]
|
||||||
|
Joining, // The client is attempting to join a room.
|
||||||
|
Joined, // The client is connected to the room and is ready to send/receive packets.
|
||||||
|
Leaving, // The client is about to close the connection
|
||||||
|
|
||||||
|
// Reasons for connection loss
|
||||||
|
LostConnection,
|
||||||
|
|
||||||
|
// Reasons why connection was rejected
|
||||||
|
RoomFull, // The room is full and is not accepting any more connections.
|
||||||
|
RoomDestroyed, // Unknown reason, server not reachable or not responding for w/e reason
|
||||||
|
NameCollision, // Somebody is already using this name
|
||||||
|
MacCollision, // Somebody is already using that mac-address
|
||||||
|
WrongVersion, // The version does not match.
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum class RoomState {
|
||||||
|
Open, // The room is open and ready to accept connections.
|
||||||
|
Closed, // The room is not opened and can not accept connections.
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Initialise NetCore::Local
|
||||||
|
bool Init();
|
||||||
|
|
||||||
|
/// Shutdown NetCore::Local
|
||||||
|
void Shutdown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the status of our connection to the room.
|
||||||
|
*/
|
||||||
|
MemberState GetMemberState();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current state of the room.
|
||||||
|
*/
|
||||||
|
RoomState GetRoomState();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether we're connected to a room or not.
|
||||||
|
*/
|
||||||
|
bool IsConnected();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns information about the members in the room we're currently connected to.
|
||||||
|
*/
|
||||||
|
MemberList GetMemberInformation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns information about the room we're currently connected to.
|
||||||
|
*/
|
||||||
|
RoomInformation GetRoomInformation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of received chat messages since the last call.
|
||||||
|
*/
|
||||||
|
std::deque<ChatEntry> PopChatEntries();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of received 802.11 frames from the specified sender
|
||||||
|
* matching the type since the last call.
|
||||||
|
*/
|
||||||
|
std::deque<WifiPacket> PopWifiPackets(WifiPacket::PacketType type, const MacAddress& sender = NoPreferredMac);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a chat message to the room.
|
||||||
|
* @param message The contents of the message.
|
||||||
|
*/
|
||||||
|
void SendChatMessage(const std::string& message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a WiFi packet to the room.
|
||||||
|
* @param packet The WiFi packet to send.
|
||||||
|
*/
|
||||||
|
void SendWifiPacket(const WifiPacket& packet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string with informations about the connection
|
||||||
|
*/
|
||||||
|
std::string GetStatistics();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the latest ping to the room
|
||||||
|
*/
|
||||||
|
int GetPing();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to join a room at the specified address and port, using the specified nickname.
|
||||||
|
* This may fail if the username is already taken.
|
||||||
|
*/
|
||||||
|
void Join(const std::string& nickname, const std::string& server = "127.0.0.1",
|
||||||
|
const uint16_t serverPort = DefaultPort, const uint16_t clientPort = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leaves the current room.
|
||||||
|
*/
|
||||||
|
void Leave();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a room to join to. Returns true on success. Will bind to default address if server is empty string.
|
||||||
|
*/
|
||||||
|
void Create(const std::string& name, const std::string& server = "", uint16_t server_port = DefaultPort);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys the room
|
||||||
|
*/
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
18
src/net_core/net_core.cpp
Normal file
18
src/net_core/net_core.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2017 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "net_core/local.h"
|
||||||
|
#include "net_core/net_core.h"
|
||||||
|
|
||||||
|
namespace NetCore {
|
||||||
|
|
||||||
|
bool Init() {
|
||||||
|
return NetCore::Local::Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Shutdown() {
|
||||||
|
NetCore::Local::Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
15
src/net_core/net_core.h
Normal file
15
src/net_core/net_core.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2017 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace NetCore {
|
||||||
|
|
||||||
|
/// Initialise NetCore
|
||||||
|
bool Init();
|
||||||
|
|
||||||
|
/// Shutdown NetCore
|
||||||
|
void Shutdown();
|
||||||
|
|
||||||
|
} // namespace
|
@ -13,7 +13,7 @@ create_directory_groups(${SRCS} ${HEADERS})
|
|||||||
include_directories(../../externals/catch/single_include/)
|
include_directories(../../externals/catch/single_include/)
|
||||||
|
|
||||||
add_executable(tests ${SRCS} ${HEADERS})
|
add_executable(tests ${SRCS} ${HEADERS})
|
||||||
target_link_libraries(tests core video_core audio_core common)
|
target_link_libraries(tests core video_core audio_core net_core common)
|
||||||
target_link_libraries(tests ${PLATFORM_LIBRARIES} Threads::Threads)
|
target_link_libraries(tests ${PLATFORM_LIBRARIES} Threads::Threads)
|
||||||
|
|
||||||
add_test(NAME tests COMMAND $<TARGET_FILE:tests>)
|
add_test(NAME tests COMMAND $<TARGET_FILE:tests>)
|
||||||
|
Loading…
Reference in New Issue
Block a user