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
|
2017-12-11 23:55:31 -08:00
|
|
|
*
|
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
|
|
|
|
2014-10-21 05:05:52 +02:00
|
|
|
#include <boolean.h>
|
2016-05-10 19:03:53 +02:00
|
|
|
#include <libretro.h>
|
2015-12-05 16:24:31 +01:00
|
|
|
|
2016-05-19 11:46:54 +02: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;
|
|
|
|
|
2018-02-02 15:37:02 -05: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" },
|
|
|
|
};
|
|
|
|
|
2015-12-05 16:24:31 +01:00
|
|
|
enum rarch_netplay_ctl_state
|
|
|
|
{
|
|
|
|
RARCH_NETPLAY_CTL_NONE = 0,
|
2016-12-12 17:22:35 -05:00
|
|
|
RARCH_NETPLAY_CTL_GAME_WATCH,
|
2015-12-05 16:27:00 +01:00
|
|
|
RARCH_NETPLAY_CTL_POST_FRAME,
|
2015-12-05 16:38:24 +01:00
|
|
|
RARCH_NETPLAY_CTL_PRE_FRAME,
|
2016-10-03 17:28:20 -04:00
|
|
|
RARCH_NETPLAY_CTL_ENABLE_SERVER,
|
|
|
|
RARCH_NETPLAY_CTL_ENABLE_CLIENT,
|
2016-10-02 22:13:34 -04:00
|
|
|
RARCH_NETPLAY_CTL_DISABLE,
|
|
|
|
RARCH_NETPLAY_CTL_IS_ENABLED,
|
2018-05-30 22:01:02 -04:00
|
|
|
RARCH_NETPLAY_CTL_IS_REPLAYING,
|
2017-05-16 00:15:06 -05:00
|
|
|
RARCH_NETPLAY_CTL_IS_SERVER,
|
|
|
|
RARCH_NETPLAY_CTL_IS_CONNECTED,
|
2016-09-14 14:25:54 -04:00
|
|
|
RARCH_NETPLAY_CTL_IS_DATA_INITED,
|
|
|
|
RARCH_NETPLAY_CTL_PAUSE,
|
2016-09-14 18:03:40 -04:00
|
|
|
RARCH_NETPLAY_CTL_UNPAUSE,
|
2016-09-24 23:47:57 -04:00
|
|
|
RARCH_NETPLAY_CTL_LOAD_SAVESTATE,
|
2017-02-15 14:40:37 -05:00
|
|
|
RARCH_NETPLAY_CTL_RESET,
|
2017-02-20 19:08:31 -05:00
|
|
|
RARCH_NETPLAY_CTL_DISCONNECT,
|
2017-04-18 15:25:58 -04:00
|
|
|
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
|
2017-09-10 21:46:18 -04:00
|
|
|
{
|
2017-09-10 22:49:25 -04:00
|
|
|
RARCH_NETPLAY_SHARE_DIGITAL_NO_SHARING,
|
|
|
|
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 21:46:18 -04:00
|
|
|
|
2017-09-10 22:49:25 -04:00
|
|
|
/* Preferences for sharing analog devices */
|
|
|
|
enum rarch_netplay_share_analog_preference
|
|
|
|
{
|
|
|
|
RARCH_NETPLAY_SHARE_ANALOG_NO_SHARING,
|
|
|
|
RARCH_NETPLAY_SHARE_ANALOG_NO_PREFERENCE,
|
|
|
|
RARCH_NETPLAY_SHARE_ANALOG_MAX,
|
|
|
|
RARCH_NETPLAY_SHARE_ANALOG_AVERAGE,
|
|
|
|
RARCH_NETPLAY_SHARE_ANALOG_LAST
|
2017-09-10 21:46:18 -04:00
|
|
|
};
|
|
|
|
|
2014-09-07 05:47:18 +02:00
|
|
|
int16_t input_state_net(unsigned port, unsigned device,
|
2014-10-20 19:29:49 +02:00
|
|
|
unsigned idx, unsigned id);
|
2014-09-07 05:47:18 +02:00
|
|
|
|
|
|
|
void video_frame_net(const void *data, unsigned width,
|
|
|
|
unsigned height, size_t pitch);
|
|
|
|
|
2012-04-05 11:47:43 +02:00
|
|
|
void audio_sample_net(int16_t left, int16_t right);
|
2014-09-07 05:47:18 +02:00
|
|
|
|
2012-04-07 11:55:37 +02:00
|
|
|
size_t audio_sample_batch_net(const int16_t *data, size_t frames);
|
2011-02-13 16:40:24 +01:00
|
|
|
|
2017-01-20 16:04:10 -05:00
|
|
|
bool init_netplay_deferred(const char* server, unsigned port);
|
|
|
|
|
2015-04-11 13:29:40 +02:00
|
|
|
/**
|
2016-10-02 22:13:34 -04:00
|
|
|
* init_netplay
|
2016-12-13 15:26:20 -05:00
|
|
|
* @direct_host : Host to connect to directly, if applicable (client only)
|
2016-10-02 22:13:34 -04:00
|
|
|
* @server : server address to connect to (client only)
|
|
|
|
* @port : TCP port to host on/connect to
|
2015-04-11 13:29:40 +02:00
|
|
|
*
|
|
|
|
* Initializes netplay.
|
|
|
|
*
|
|
|
|
* If netplay is already initialized, will return false (0).
|
|
|
|
*
|
|
|
|
* Returns: true (1) if successful, otherwise false (0).
|
|
|
|
**/
|
2016-12-21 09:51:50 -05:00
|
|
|
bool init_netplay(void *direct_host, const char *server, unsigned port);
|
2015-04-11 13:29:40 +02:00
|
|
|
|
2015-04-11 13:31:33 +02:00
|
|
|
void deinit_netplay(void);
|
|
|
|
|
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
|
|
|
|
2017-12-17 11:51:50 -05:00
|
|
|
void netplay_get_architecture(char *frontend_architecture, size_t size);
|
|
|
|
|
2015-11-17 16:19:22 -07:00
|
|
|
#endif
|