188 lines
5.2 KiB
C
Raw Normal View History

2012-04-21 23:13:50 +02:00
/* RetroArch - A frontend for libretro.
2014-01-01 01:50:59 +01:00
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
2017-01-22 13:40:32 +01:00
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2017 - Gregor Richards
*
2012-04-21 23:13:50 +02:00
* RetroArch is free software: you can redistribute it and/or modify it under the terms
2011-02-13 16:40:24 +01:00
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
2012-04-21 23:13:50 +02:00
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
2011-02-13 16:40:24 +01:00
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
2012-04-21 23:31:57 +02:00
* You should have received a copy of the GNU General Public License along with RetroArch.
2011-02-13 16:40:24 +01:00
* If not, see <http://www.gnu.org/licenses/>.
*/
2012-04-21 23:25:32 +02:00
#ifndef __RARCH_NETPLAY_H
#define __RARCH_NETPLAY_H
2011-02-13 16:40:24 +01:00
#include <stdint.h>
2012-04-05 11:47:43 +02:00
#include <stddef.h>
2015-12-05 16:24:31 +01:00
#include <boolean.h>
#include <libretro.h>
2015-12-05 16:24:31 +01:00
#include "../../core.h"
2011-02-13 16:40:24 +01:00
2015-01-09 18:34:00 +01:00
typedef struct netplay netplay_t;
2019-06-26 07:13:50 +02:00
typedef struct mitm_server
{
const char *name;
const char *description;
} mitm_server_t;
static const mitm_server_t netplay_mitm_server_list[] = {
{ "nyc", "New York City, USA" },
{ "madrid", "Madrid, Spain" },
2018-12-09 22:15:45 -05:00
{ "montreal", "Montreal, Canada" },
2020-01-06 18:14:59 +01:00
{ "saopaulo", "Sao Paulo, Brazil" },
};
2015-12-05 16:24:31 +01:00
enum rarch_netplay_ctl_state
{
RARCH_NETPLAY_CTL_NONE = 0,
RARCH_NETPLAY_CTL_GAME_WATCH,
RARCH_NETPLAY_CTL_POST_FRAME,
RARCH_NETPLAY_CTL_PRE_FRAME,
RARCH_NETPLAY_CTL_ENABLE_SERVER,
RARCH_NETPLAY_CTL_ENABLE_CLIENT,
RARCH_NETPLAY_CTL_DISABLE,
RARCH_NETPLAY_CTL_IS_ENABLED,
RARCH_NETPLAY_CTL_IS_REPLAYING,
RARCH_NETPLAY_CTL_IS_SERVER,
RARCH_NETPLAY_CTL_IS_CONNECTED,
RARCH_NETPLAY_CTL_IS_DATA_INITED,
RARCH_NETPLAY_CTL_PAUSE,
RARCH_NETPLAY_CTL_UNPAUSE,
RARCH_NETPLAY_CTL_LOAD_SAVESTATE,
RARCH_NETPLAY_CTL_RESET,
RARCH_NETPLAY_CTL_DISCONNECT,
RARCH_NETPLAY_CTL_FINISHED_NAT_TRAVERSAL,
RARCH_NETPLAY_CTL_DESYNC_PUSH,
RARCH_NETPLAY_CTL_DESYNC_POP
2015-12-05 16:24:31 +01:00
};
2017-09-10 22:49:25 -04:00
/* Preferences for sharing digital devices */
enum rarch_netplay_share_digital_preference
{
2018-09-25 15:00:29 +02:00
RARCH_NETPLAY_SHARE_DIGITAL_NO_SHARING = 0,
2017-09-10 22:49:25 -04:00
RARCH_NETPLAY_SHARE_DIGITAL_NO_PREFERENCE,
RARCH_NETPLAY_SHARE_DIGITAL_OR,
RARCH_NETPLAY_SHARE_DIGITAL_XOR,
RARCH_NETPLAY_SHARE_DIGITAL_VOTE,
RARCH_NETPLAY_SHARE_DIGITAL_LAST
};
2017-09-10 22:49:25 -04:00
/* Preferences for sharing analog devices */
enum rarch_netplay_share_analog_preference
{
2018-09-25 15:00:29 +02:00
RARCH_NETPLAY_SHARE_ANALOG_NO_SHARING = 0,
2017-09-10 22:49:25 -04:00
RARCH_NETPLAY_SHARE_ANALOG_NO_PREFERENCE,
RARCH_NETPLAY_SHARE_ANALOG_MAX,
RARCH_NETPLAY_SHARE_ANALOG_AVERAGE,
RARCH_NETPLAY_SHARE_ANALOG_LAST
};
2015-12-05 16:24:31 +01:00
bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data);
2017-03-04 01:31:24 -05:00
int netplay_rooms_parse(const char *buf);
struct netplay_room* netplay_room_get(int index);
2018-06-21 07:52:01 +02:00
int netplay_rooms_get_count(void);
2017-03-04 01:31:24 -05:00
2018-06-21 07:52:01 +02:00
void netplay_rooms_free(void);
2017-03-04 01:31:24 -05:00
/**
* netplay_frontend_paused
* @netplay : pointer to netplay object
* @paused : true if frontend is paused
*
* Inform Netplay of the frontend's pause state (paused or otherwise)
*/
void netplay_frontend_paused(netplay_t *netplay, bool paused);
/**
* netplay_toggle_play_spectate
*
* Toggle between play mode and spectate mode
*/
void netplay_toggle_play_spectate(netplay_t *netplay);
/**
* netplay_load_savestate
* @netplay : pointer to netplay object
* @serial_info : the savestate being loaded, NULL means
* "load it yourself"
* @save : Whether to save the provided serial_info
* into the frame buffer
*
* Inform Netplay of a savestate load and send it to the other side
**/
void netplay_load_savestate(netplay_t *netplay,
retro_ctx_serialize_info_t *serial_info, bool save);
/**
* netplay_core_reset
* @netplay : pointer to netplay object
*
* Indicate that the core has been reset to netplay peers
**/
void netplay_core_reset(netplay_t *netplay);
int16_t netplay_input_state(netplay_t *netplay,
unsigned port, unsigned device,
unsigned idx, unsigned id);
/**
* netplay_poll:
* @netplay : pointer to netplay object
*
* Polls network to see if we have anything new. If our
* network buffer is full, we simply have to block
* for new input data.
*
* Returns: true (1) if successful, otherwise false (0).
**/
bool netplay_poll(
bool block_libretro_input,
void *settings_data,
netplay_t *netplay);
/**
* netplay_is_alive:
* @netplay : pointer to netplay object
*
* Checks if input port/index is controlled by netplay or not.
*
* Returns: true (1) if alive, otherwise false (0).
**/
bool netplay_is_alive(netplay_t *netplay);
/**
* netplay_should_skip:
* @netplay : pointer to netplay object
*
* If we're fast-forward replaying to resync, check if we
* should actually show frame.
*
* Returns: bool (1) if we should skip this frame, otherwise
* false (0).
**/
bool netplay_should_skip(netplay_t *netplay);
2021-09-18 22:05:03 +02:00
/**
* netplay_post_frame:
* @netplay : pointer to netplay object
*
* Post-frame for Netplay.
* We check if we have new input and replay from recorded input.
* Call this after running retro_run().
**/
void netplay_post_frame(netplay_t *netplay);
2015-11-17 16:19:22 -07:00
#endif