* CXX_BUILD buildfixes
* (D3D11) Buildfixes for CXX_BUILD
* (Linux/qb) Disable KMS for Linux when building for C89, headers use inline which is not
available for C89
COMMON: The common library can now be used independently by any number of features.
COMMON: The common library no longer restricts HAVE_SOCKET_LEGACY.
Netplay Task: Network interface scoring changed from byte-level to bit-level.
* make roms copy to a specific cache dir in the localstate folder when its copied
* auto delete vfs cache dir on start up
Co-authored-by: Tunip3 <tunip3@users.noreply.github.com>
* Netplay Stuff
## PROTOCOL FALLBACK
In order to support older clients a protocol fallback system was introduced.
The host will no longer send its header automatically after a TCP connection is established, instead, it awaits for the client to send his before determining which protocol this connection is going to operate on.
Netplay has now two protocols, a low protocol and a high protocol; the low protocol is the minimum protocol it supports, while the high protocol is the highest protocol it can operate on.
To fully support older clients, a hack was necessary: sending the high protocol in the unused client's header salt field, while keeping the protocol field to the low protocol. Without this hack we would only be able to support older clients if a newer client was the host.
Any future system can make use of this system by checking connection->netplay_protocol, which is available for both the client and host.
## NETPLAY CHAT
Starting with protocol 6, netplay chat is available through the new NETPLAY_CMD_PLAYER_CHAT command.
Limitations of the command code, which causes a disconnection on unknown commands, makes this system not possible on protocol 5.
Protocol 5 connections can neither send nor receive chat, but other netplay operations are unaffected.
Clients send chat as a string to the server, and it's the server's sole responsability to relay chat messages.
As of now, sending chat uses RetroArch's input menu, while the display of on-screen chat uses a widget overlay and RetroArch's notifications as a fallback.
If a new overlay and/or input system is desired, no backwards compatibility changes need to be made.
Only clients in playing mode (as opposed to spectating mode) can send and receive chat.
## SETTINGS SHARING
Some settings are better used when both host and clients share the same configuration.
As of protocol 6, the following settings will be shared from host to clients (without altering a client's configuration file): input latency frames and allow pausing.
## NETPLAY TUNNEL/MITM
With the current MITM system being defunct (at least as of 1.9.X), a new system was in order to solve most if not all of the problems with the current system.
This new system uses a tunneling approach, which is similar to most VPN and tunneling services around.
Tunnel commands:
RATS[unique id] (RetroArch Tunnel Session) - 16 bytes -> When this command is sent with a zeroed unique id, the tunnel server interprets this as a netplay host wanting to create a new session, in this case, the same command is returned to the host, but now with its unique session id. When a client needs to connect to a host, this command is sent with the unique session id of the host, causing the tunnel server to send a RATL command to the host.
RATL[unique id] (RetroArch Tunnel Link) - 16 bytes -> The tunnel server sends this command to the host when a client wants to connect to the host. Once the host receives this command, it establishes a new connection to the tunnel server, sending this command together with the client's unique id through this new connection, causing the tunnel server to link this connection to the connection of the client.
RATP (RetroArch Tunnel Ping) - 4 bytes -> The tunnel server sends this command to verify that the host, whom the session belongs to, is still around. The host replies with the same command. A session is closed if the tunnel server can not verify that the host is alive.
Operations:
Host -> Instead of listening and accepting connections, it connects to the tunnel server, requests a new session and then monitor this connection for new linking requests. Once a request is received, it establishes a new connection to the tunnel server for linking with a client. The tunnel server's address and port are obtained by querying the lobby server. The host will publish its session id together with the rest of its info to the lobby server.
Client -> It connects to the tunnel server and then sends the session id of the host it wants to connect to. A host's session id is obtained from the json data sent by the lobby server.
Improvements (from current MITM system):
No longer a risk of TCP port exhaustion; we only use one port now at the tunnel server.
Very little cpu usage. About 95% net I/O bound now.
Future backwards compatible with any and all changes to netplay as it no longer runs any netplay logic at MITM servers.
No longer operates the host in client mode, which was a source of many of the current problems.
Cleaner and more maintainable system and code.
Notable functions:
netplay_mitm_query -> Grabs the tunnel's address and port from the lobby server.
init_tcp_socket -> Handles the creation and operation mode of the TCP socket based on whether it's host, host+MITM or client.
handle_mitm_connection -> Creates and completes linking connections and replies to ping commands (only 1 of each per call to not affect performance).
## MISC
Ping Limiter: If a client's estimated latency to the server is higher than this value, connection will be dropped just before finishing the netplay handshake.
Ping Counter: A ping counter (similar to the FPS one) can be shown in the bottom right corner of the screen, if you are connected to a host.
LAN Discovery: Refactored and moved to its own "Refresh Netplay LAN List" button.
## FIXES
Many minor fixes to the current netplay implementation are also included.
* Remove NETPLAY_TEST_BUILD
* make check for standard io by access rather than the just assuming based on path string
* add code to auto permissions so files can be accessed by non vfs cores
(no exfat or fat32 support yet)
* remove commit from macro because apparently it causes issues
Co-authored-by: Tunip3 <tunip3@users.noreply.github.com>
== DETAILS
So, basically this back-and-forth is because we used fixed-size
data types (i.e. `uint32_t`) which maps to different primitive data
types on different platforms. So `uint32_t` might be a `long` on some
platforms (e.g. Wii U), while it's just a plain integer on others (PC).
And the format specifier works off primitive data type, not data type
size.
So, to resolve this, we:
- keep `%lx` as the format specifier
- cast the parameter to printf to unsigned long
This is better than the alternatives that could cause problems trying to
cast a long down to an int.
== DETAILS
These changes fall into a few broad categories:
1. Explicitly undefine things we want to re-define due to conflicts with
the version of devkitpro we're using
2. Clean up hex format specifiers to use `%lx` or `%lX` when working with
long integers
3. Move variables inside the ifdef they're used in to squelch "unused variable"
messages
4. Add parenthesis to make Wii U shader declarations stop complaining
And then there's a weird "misleading indent" warning that I fixed by just
rewriting a block of code to use a switch statement instead of if-then-else.
These changes work fine on Wii U, but we'll need to keep an eye on CI/CD to see
if other platform builds break.
* (3DS) Add bottom screen menu
-> User can save/load state on botom screen with thumbnail.
-> Call a save_state_to_file() when RAM state has data to write a disk.
-> If the bottom screen needs updating, swap the bottom framebuffers.
Add: SAVE/LODE STATE TO RAM
-> This is useful for devices with slow I/O
-> 3DS bottom save state use CMD_EVENT_SAVE_STATE_TO_RAM
-> 3DS bottom load state use CMD_EVENT_LOAD_STATE when RAM state has no data
-> 3DS bottom load state use CMD_EVENT_LOAD_STATE_FROM_RAM when RAM sate has data
* Rewrite path_get_state to retroarch_get_current_savestate_path
* Fix unterminated state_path
- strlen was being called on path for each loop iteration, when
path is not subject to change - do it once outside
- String copying was being performed even when the string would
equal a string not subject to change
This also allows WiFi passwords to be remembered. The underlying
tool (connman) allows to store passswords (that's why it auto connects
whenever you boot a Lakka device), so we expose this so that the user
does not have to re-input the pass when connecting to a saved wifi.
Option to forget a password to come in a future PR, for now a password
is automatically forgotten if the Wifi connect operation fails (we assume
it fails due to password).
Changes the WiFi API to enable these features of course!
when calling the frontend environment get callback - we want to
look at the 'default' directories, and then if they don't yet exist,
auto-create them so we can store files in them.
and string_list_deinitialize - takes a pointer to initialize
and deinitialize a string list, but importantly does not
implicitly allocate and deallocate the string list pointer
itself. This way, string lists can be put on the stack instead
of always implicitly being put on heap - the struct itself is
small enough to fit on stack