mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
Configurable sharing mode.
This commit is contained in:
parent
abf045ef0e
commit
39243a8d40
@ -27,6 +27,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETWORKING
|
||||
#include "network/netplay/netplay.h"
|
||||
#endif
|
||||
|
||||
#if defined(HW_RVL)
|
||||
#define MAX_GAMMA_SETTING 30
|
||||
#elif defined(GEKKO)
|
||||
@ -544,6 +548,10 @@ static const int netplay_check_frames = 600;
|
||||
|
||||
static const bool netplay_use_mitm_server = false;
|
||||
|
||||
static const unsigned netplay_share_digital = RARCH_NETPLAY_SHARE_DIGITAL_NO_PREFERENCE;
|
||||
|
||||
static const unsigned netplay_share_analog = RARCH_NETPLAY_SHARE_ANALOG_NO_PREFERENCE;
|
||||
|
||||
/* On save state load, block SRAM from being overwritten.
|
||||
* This could potentially lead to buggy games. */
|
||||
static const bool block_sram_overwrite = false;
|
||||
|
@ -1463,6 +1463,8 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
|
||||
SETTING_UINT("netplay_ip_port", &settings->uints.netplay_port, true, RARCH_DEFAULT_PORT, false);
|
||||
SETTING_UINT("netplay_input_latency_frames_min",&settings->uints.netplay_input_latency_frames_min, true, 0, false);
|
||||
SETTING_UINT("netplay_input_latency_frames_range",&settings->uints.netplay_input_latency_frames_range, true, 0, false);
|
||||
SETTING_UINT("netplay_share_digital", &settings->uints.netplay_share_digital, true, netplay_share_digital, false);
|
||||
SETTING_UINT("netplay_share_analog", &settings->uints.netplay_share_analog, true, netplay_share_analog, false);
|
||||
#endif
|
||||
#ifdef HAVE_LANGEXTRA
|
||||
SETTING_UINT("user_language", msg_hash_get_uint(MSG_HASH_USER_LANGUAGE), true, RETRO_LANGUAGE_ENGLISH, false);
|
||||
|
@ -629,6 +629,10 @@ MSG_HASH(MENU_ENUM_LABEL_NETPLAY_CLIENT_SWAP_INPUT,
|
||||
"netplay_client_swap_input")
|
||||
MSG_HASH(MENU_ENUM_LABEL_NETPLAY_REQUEST_DEVICE_I,
|
||||
"netplay_request_device_%u")
|
||||
MSG_HASH(MENU_ENUM_LABEL_NETPLAY_SHARE_ANALOG,
|
||||
"netplay_share_analog")
|
||||
MSG_HASH(MENU_ENUM_LABEL_NETPLAY_SHARE_DIGITAL,
|
||||
"netplay_share_digital")
|
||||
MSG_HASH(MENU_ENUM_LABEL_NETPLAY_INPUT_LATENCY_FRAMES_MIN,
|
||||
"netplay_input_latency_frames_min")
|
||||
MSG_HASH(MENU_ENUM_LABEL_NETPLAY_INPUT_LATENCY_FRAMES_RANGE,
|
||||
|
@ -1077,6 +1077,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REQUIRE_SLAVES,
|
||||
"Disallow Non-Slave-Mode Clients")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SETTINGS,
|
||||
"Netplay settings")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG,
|
||||
"Analog Input Sharing")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG_MAX,
|
||||
"Max")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG_AVERAGE,
|
||||
"Average")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL,
|
||||
"Digital Input Sharing")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_OR,
|
||||
"Share")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_XOR,
|
||||
"Grapple")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_VOTE,
|
||||
"Vote")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NONE,
|
||||
"None")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NO_PREFERENCE,
|
||||
"No preference")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_START_AS_SPECTATOR,
|
||||
"Netplay Spectator Mode")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_STATELESS_MODE,
|
||||
|
@ -43,6 +43,10 @@
|
||||
#include "../../verbosity.h"
|
||||
#include "../../wifi/wifi_driver.h"
|
||||
|
||||
#ifdef HAVE_NETWORKING
|
||||
#include "../network/netplay/netplay.h"
|
||||
#endif
|
||||
|
||||
#ifndef BIND_ACTION_GET_VALUE
|
||||
#define BIND_ACTION_GET_VALUE(cbs, name) \
|
||||
cbs->action_get_value = name; \
|
||||
@ -1714,6 +1718,84 @@ static void menu_action_setting_disp_set_label_setting_path(file_list_t* list,
|
||||
strlcpy(s2, path, len2);
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label_netplay_share_digital(file_list_t* list,
|
||||
unsigned *w, unsigned type, unsigned i,
|
||||
const char *label,
|
||||
char *s, size_t len,
|
||||
const char *entry_label,
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *src;
|
||||
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
strlcpy(s2, path, len2);
|
||||
*w = 19;
|
||||
switch (settings->uints.netplay_share_digital)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_NO_PREFERENCE:
|
||||
src = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NO_PREFERENCE);
|
||||
break;
|
||||
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_OR:
|
||||
src = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_OR);
|
||||
break;
|
||||
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_XOR:
|
||||
src = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_XOR);
|
||||
break;
|
||||
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_VOTE:
|
||||
src = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_VOTE);
|
||||
break;
|
||||
|
||||
default:
|
||||
src = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NONE);
|
||||
break;
|
||||
}
|
||||
strlcpy(s, src, len);
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label_netplay_share_analog(file_list_t* list,
|
||||
unsigned *w, unsigned type, unsigned i,
|
||||
const char *label,
|
||||
char *s, size_t len,
|
||||
const char *entry_label,
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *src;
|
||||
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
strlcpy(s2, path, len2);
|
||||
*w = 19;
|
||||
switch (settings->uints.netplay_share_analog)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_ANALOG_NO_PREFERENCE:
|
||||
src = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NO_PREFERENCE);
|
||||
break;
|
||||
|
||||
case RARCH_NETPLAY_SHARE_ANALOG_MAX:
|
||||
src = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG_MAX);
|
||||
break;
|
||||
|
||||
case RARCH_NETPLAY_SHARE_ANALOG_AVERAGE:
|
||||
src = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG_AVERAGE);
|
||||
break;
|
||||
|
||||
default:
|
||||
src = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NONE);
|
||||
break;
|
||||
}
|
||||
strlcpy(s, src, len);
|
||||
}
|
||||
|
||||
static int menu_cbs_init_bind_get_string_representation_compare_label(
|
||||
menu_file_list_cbs_t *cbs)
|
||||
{
|
||||
@ -1817,6 +1899,14 @@ static int menu_cbs_init_bind_get_string_representation_compare_label(
|
||||
BIND_ACTION_GET_VALUE(cbs,
|
||||
menu_action_setting_disp_set_label_menu_input_keyboard_gamepad_mapping_type);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_NETPLAY_SHARE_DIGITAL:
|
||||
BIND_ACTION_GET_VALUE(cbs,
|
||||
menu_action_setting_disp_set_label_netplay_share_digital);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_NETPLAY_SHARE_ANALOG:
|
||||
BIND_ACTION_GET_VALUE(cbs,
|
||||
menu_action_setting_disp_set_label_netplay_share_analog);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST:
|
||||
case MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY:
|
||||
case MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST:
|
||||
|
@ -5537,6 +5537,14 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
|
||||
MENU_ENUM_LABEL_NETPLAY_CLIENT_SWAP_INPUT,
|
||||
PARSE_ONLY_BOOL, false) != -1)
|
||||
count++;
|
||||
if (menu_displaylist_parse_settings_enum(menu, info,
|
||||
MENU_ENUM_LABEL_NETPLAY_SHARE_DIGITAL,
|
||||
PARSE_ONLY_UINT, false) != -1)
|
||||
count++;
|
||||
if (menu_displaylist_parse_settings_enum(menu, info,
|
||||
MENU_ENUM_LABEL_NETPLAY_SHARE_ANALOG,
|
||||
PARSE_ONLY_UINT, false) != -1)
|
||||
count++;
|
||||
for (user = 0; user < MAX_USERS; user++)
|
||||
{
|
||||
if (menu_displaylist_parse_settings_enum(menu, info,
|
||||
|
@ -86,6 +86,10 @@
|
||||
|
||||
#include "../tasks/tasks_internal.h"
|
||||
|
||||
#ifdef HAVE_NETWORKING
|
||||
#include "../network/netplay/netplay.h"
|
||||
#endif
|
||||
|
||||
enum settings_list_type
|
||||
{
|
||||
SETTINGS_LIST_NONE = 0,
|
||||
@ -6921,6 +6925,32 @@ static bool setting_append_list(
|
||||
SD_FLAG_NONE);
|
||||
settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED);
|
||||
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
&settings->uints.netplay_share_digital,
|
||||
MENU_ENUM_LABEL_NETPLAY_SHARE_DIGITAL,
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL,
|
||||
0,
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
menu_settings_list_current_add_range(list, list_info, 0, RARCH_NETPLAY_SHARE_DIGITAL_LAST-1, 1, true, true);
|
||||
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
&settings->uints.netplay_share_analog,
|
||||
MENU_ENUM_LABEL_NETPLAY_SHARE_ANALOG,
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG,
|
||||
0,
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
menu_settings_list_current_add_range(list, list_info, 0, RARCH_NETPLAY_SHARE_ANALOG_LAST-1, 1, true, true);
|
||||
|
||||
for (user = 0; user < MAX_USERS; user++)
|
||||
{
|
||||
snprintf(dev_req_label, sizeof(dev_req_label),
|
||||
|
10
msg_hash.h
10
msg_hash.h
@ -1172,6 +1172,16 @@ enum msg_hash_enums
|
||||
MENU_LABEL(NETPLAY_REQUEST_DEVICE_I),
|
||||
MENU_ENUM_LABEL_NETPLAY_REQUEST_DEVICE_1,
|
||||
MENU_ENUM_LABEL_NETPLAY_REQUEST_DEVICE_LAST = MENU_ENUM_LABEL_NETPLAY_REQUEST_DEVICE_1 + MAX_USERS,
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NONE,
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_NO_PREFERENCE,
|
||||
MENU_LABEL(NETPLAY_SHARE_DIGITAL),
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_OR,
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_XOR,
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_DIGITAL_VOTE,
|
||||
MENU_LABEL(NETPLAY_SHARE_ANALOG),
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG_MAX,
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_SHARE_ANALOG_AVERAGE,
|
||||
|
||||
MENU_LABEL(SORT_SAVEFILES_ENABLE),
|
||||
MENU_LABEL(SORT_SAVESTATES_ENABLE),
|
||||
MENU_LABEL(SAVEFILES_IN_CONTENT_DIR_ENABLE),
|
||||
|
@ -53,26 +53,25 @@ enum rarch_netplay_ctl_state
|
||||
RARCH_NETPLAY_CTL_DESYNC_POP
|
||||
};
|
||||
|
||||
/* Preferences for sharing devices */
|
||||
enum rarch_netplay_share_preference
|
||||
/* Preferences for sharing digital devices */
|
||||
enum rarch_netplay_share_digital_preference
|
||||
{
|
||||
/* Prefer not to share, shouldn't be set as a sharing mode for an shared device */
|
||||
RARCH_NETPLAY_SHARE_NO_SHARING = 0x0,
|
||||
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
|
||||
};
|
||||
|
||||
/* No preference. Only for requests. Set if sharing is requested but either
|
||||
* digital or analog doesn't have a preference. */
|
||||
RARCH_NETPLAY_SHARE_NO_PREFERENCE = 0x1,
|
||||
|
||||
/* For digital devices */
|
||||
RARCH_NETPLAY_SHARE_DIGITAL_BITS = 0x1C,
|
||||
RARCH_NETPLAY_SHARE_DIGITAL_OR = 0x4,
|
||||
RARCH_NETPLAY_SHARE_DIGITAL_XOR = 0x8,
|
||||
RARCH_NETPLAY_SHARE_DIGITAL_VOTE = 0xC,
|
||||
|
||||
/* For analog devices */
|
||||
RARCH_NETPLAY_SHARE_ANALOG_BITS = 0xE0,
|
||||
RARCH_NETPLAY_SHARE_ANALOG_MAX = 0x20,
|
||||
RARCH_NETPLAY_SHARE_ANALOG_AVERAGE = 0x40
|
||||
/* 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
|
||||
};
|
||||
|
||||
int16_t input_state_net(unsigned port, unsigned device,
|
||||
|
@ -1121,6 +1121,49 @@ static void netplay_core_reset(netplay_t *netplay)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* netplay_settings_share_mode
|
||||
*
|
||||
* Get the preferred share mode
|
||||
*/
|
||||
uint8_t netplay_settings_share_mode(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
uint8_t share_mode = 0;
|
||||
|
||||
if (settings->uints.netplay_share_digital
|
||||
|| settings->uints.netplay_share_analog)
|
||||
{
|
||||
switch (settings->uints.netplay_share_digital)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_OR:
|
||||
share_mode |= NETPLAY_SHARE_DIGITAL_OR;
|
||||
break;
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_XOR:
|
||||
share_mode |= NETPLAY_SHARE_DIGITAL_XOR;
|
||||
break;
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_VOTE:
|
||||
share_mode |= NETPLAY_SHARE_DIGITAL_VOTE;
|
||||
break;
|
||||
default:
|
||||
share_mode |= NETPLAY_SHARE_NO_PREFERENCE;
|
||||
}
|
||||
switch (settings->uints.netplay_share_analog)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_ANALOG_MAX:
|
||||
share_mode |= NETPLAY_SHARE_ANALOG_MAX;
|
||||
break;
|
||||
case RARCH_NETPLAY_SHARE_ANALOG_AVERAGE:
|
||||
share_mode |= NETPLAY_SHARE_ANALOG_AVERAGE;
|
||||
break;
|
||||
default:
|
||||
share_mode |= NETPLAY_SHARE_NO_PREFERENCE;
|
||||
}
|
||||
}
|
||||
|
||||
return share_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* netplay_toggle_play_spectate
|
||||
*
|
||||
@ -1157,8 +1200,9 @@ static void netplay_toggle_play_spectate(netplay_t *netplay)
|
||||
}
|
||||
else if (netplay->self_mode == NETPLAY_CONNECTION_SPECTATING)
|
||||
{
|
||||
/* FIXME: Own device request */
|
||||
uint32_t device;
|
||||
uint8_t share_mode = RARCH_NETPLAY_SHARE_DIGITAL_OR|RARCH_NETPLAY_SHARE_ANALOG_MAX;
|
||||
uint8_t share_mode = netplay_settings_share_mode();
|
||||
|
||||
/* Take an input device */
|
||||
for (device = 0; device < MAX_INPUT_DEVICES; device++)
|
||||
@ -1171,7 +1215,7 @@ static void netplay_toggle_play_spectate(netplay_t *netplay)
|
||||
if (!netplay->device_clients[device])
|
||||
break;
|
||||
}
|
||||
if (device >= MAX_INPUT_DEVICES)
|
||||
if (device >= MAX_INPUT_DEVICES && share_mode)
|
||||
{
|
||||
/* Share one */
|
||||
for (device = 0; device < MAX_INPUT_DEVICES; device++)
|
||||
|
@ -470,6 +470,7 @@ bool netplay_cmd_mode(netplay_t *netplay,
|
||||
{
|
||||
uint32_t cmd, device;
|
||||
uint32_t payloadBuf = 0, *payload = NULL;
|
||||
uint8_t share_mode;
|
||||
settings_t *settings = config_get_ptr();
|
||||
switch (mode)
|
||||
{
|
||||
@ -483,7 +484,10 @@ bool netplay_cmd_mode(netplay_t *netplay,
|
||||
|
||||
case NETPLAY_CONNECTION_PLAYING:
|
||||
payload = &payloadBuf;
|
||||
payloadBuf |= RARCH_NETPLAY_SHARE_NO_PREFERENCE<<16;
|
||||
|
||||
/* Add a share mode if requested */
|
||||
share_mode = netplay_settings_share_mode();
|
||||
payloadBuf |= ((uint32_t) share_mode) << 16;
|
||||
|
||||
/* Request devices */
|
||||
for (device = 0; device < MAX_INPUT_DEVICES; device++)
|
||||
@ -956,11 +960,11 @@ static bool netplay_get_cmd(netplay_t *netplay,
|
||||
/* Fix our share mode */
|
||||
if (share_mode)
|
||||
{
|
||||
if ((share_mode & RARCH_NETPLAY_SHARE_DIGITAL_BITS) == 0)
|
||||
share_mode |= RARCH_NETPLAY_SHARE_DIGITAL_OR;
|
||||
if ((share_mode & RARCH_NETPLAY_SHARE_ANALOG_BITS) == 0)
|
||||
share_mode |= RARCH_NETPLAY_SHARE_ANALOG_MAX;
|
||||
share_mode &= ~RARCH_NETPLAY_SHARE_NO_PREFERENCE;
|
||||
if ((share_mode & NETPLAY_SHARE_DIGITAL_BITS) == 0)
|
||||
share_mode |= NETPLAY_SHARE_DIGITAL_OR;
|
||||
if ((share_mode & NETPLAY_SHARE_ANALOG_BITS) == 0)
|
||||
share_mode |= NETPLAY_SHARE_ANALOG_MAX;
|
||||
share_mode &= ~NETPLAY_SHARE_NO_PREFERENCE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -207,6 +207,28 @@ enum netplay_cmd_mode_reasons
|
||||
NETPLAY_CMD_MODE_REFUSED_REASON_NOT_AVAILABLE
|
||||
};
|
||||
|
||||
/* Real preferences for sharing devices */
|
||||
enum rarch_netplay_share_preference
|
||||
{
|
||||
/* Prefer not to share, shouldn't be set as a sharing mode for an shared device */
|
||||
NETPLAY_SHARE_NO_SHARING = 0x0,
|
||||
|
||||
/* No preference. Only for requests. Set if sharing is requested but either
|
||||
* digital or analog doesn't have a preference. */
|
||||
NETPLAY_SHARE_NO_PREFERENCE = 0x1,
|
||||
|
||||
/* For digital devices */
|
||||
NETPLAY_SHARE_DIGITAL_BITS = 0x1C,
|
||||
NETPLAY_SHARE_DIGITAL_OR = 0x4,
|
||||
NETPLAY_SHARE_DIGITAL_XOR = 0x8,
|
||||
NETPLAY_SHARE_DIGITAL_VOTE = 0xC,
|
||||
|
||||
/* For analog devices */
|
||||
NETPLAY_SHARE_ANALOG_BITS = 0xE0,
|
||||
NETPLAY_SHARE_ANALOG_MAX = 0x20,
|
||||
NETPLAY_SHARE_ANALOG_AVERAGE = 0x40
|
||||
};
|
||||
|
||||
/* The current status of a connection */
|
||||
enum rarch_netplay_connection_mode
|
||||
{
|
||||
@ -695,6 +717,13 @@ bool netplay_lan_ad_server(netplay_t *netplay);
|
||||
void netplay_load_savestate(netplay_t *netplay,
|
||||
retro_ctx_serialize_info_t *serial_info, bool save);
|
||||
|
||||
/**
|
||||
* netplay_settings_share_mode
|
||||
*
|
||||
* Get the preferred share mode
|
||||
*/
|
||||
uint8_t netplay_settings_share_mode(void);
|
||||
|
||||
/**
|
||||
* input_poll_net
|
||||
*
|
||||
|
@ -124,8 +124,8 @@ static void netplay_merge_digital(netplay_t *netplay,
|
||||
{
|
||||
netplay_input_state_t simstate;
|
||||
uint32_t word, bit, client;
|
||||
uint8_t share_mode = netplay->device_share_modes[device] & RARCH_NETPLAY_SHARE_DIGITAL_BITS;
|
||||
if (share_mode == RARCH_NETPLAY_SHARE_DIGITAL_VOTE)
|
||||
uint8_t share_mode = netplay->device_share_modes[device] & NETPLAY_SHARE_DIGITAL_BITS;
|
||||
if (share_mode == NETPLAY_SHARE_DIGITAL_VOTE)
|
||||
{
|
||||
/* Vote mode requires counting all the bits */
|
||||
uint32_t client_count = 0;
|
||||
@ -178,7 +178,7 @@ static void netplay_merge_digital(netplay_t *netplay,
|
||||
/* Combine the whole word */
|
||||
switch (share_mode)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_XOR: resstate->data[word] ^= part; break;
|
||||
case NETPLAY_SHARE_DIGITAL_XOR: resstate->data[word] ^= part; break;
|
||||
default: resstate->data[word] |= part;
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ static void netplay_merge_digital(netplay_t *netplay,
|
||||
if (!(digital[word] & (1<<bit))) continue;
|
||||
switch (share_mode)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_XOR: resstate->data[word] ^= part & (1<<bit); break;
|
||||
case NETPLAY_SHARE_DIGITAL_XOR: resstate->data[word] ^= part & (1<<bit); break;
|
||||
default: resstate->data[word] |= part & (1<<bit);
|
||||
}
|
||||
}
|
||||
@ -217,7 +217,7 @@ static void merge_analog_part(netplay_t *netplay,
|
||||
{
|
||||
netplay_input_state_t simstate;
|
||||
uint32_t client, client_count = 0;;
|
||||
uint8_t share_mode = netplay->device_share_modes[device] & RARCH_NETPLAY_SHARE_ANALOG_BITS;
|
||||
uint8_t share_mode = netplay->device_share_modes[device] & NETPLAY_SHARE_ANALOG_BITS;
|
||||
int32_t value = 0, new_value;
|
||||
|
||||
for (client = 0; client < MAX_CLIENTS; client++)
|
||||
@ -229,7 +229,7 @@ static void merge_analog_part(netplay_t *netplay,
|
||||
new_value = (int16_t) ((simstate->data[word]>>bit) & 0xFFFF);
|
||||
switch (share_mode)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_ANALOG_AVERAGE:
|
||||
case NETPLAY_SHARE_ANALOG_AVERAGE:
|
||||
value += (int32_t) new_value;
|
||||
break;
|
||||
default:
|
||||
@ -239,7 +239,7 @@ static void merge_analog_part(netplay_t *netplay,
|
||||
}
|
||||
}
|
||||
|
||||
if (share_mode == RARCH_NETPLAY_SHARE_ANALOG_AVERAGE)
|
||||
if (share_mode == NETPLAY_SHARE_ANALOG_AVERAGE)
|
||||
value /= client_count;
|
||||
|
||||
resstate->data[word] |= ((uint32_t) (uint16_t) value) << bit;
|
||||
|
Loading…
x
Reference in New Issue
Block a user