static int action_ok_remap_file_save_game(const char *path, const char *label, unsigned type, size_t idx) { global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); const char *core_name; core_name = global->system.info.library_name; const char *game_name; game_name = path_basename(global->basename); char directory[PATH_MAX_LENGTH]; char file[PATH_MAX_LENGTH]; fill_pathname_join(directory,settings->input_remapping_directory,core_name,PATH_MAX_LENGTH); fill_pathname_join(file,core_name,game_name,PATH_MAX_LENGTH); if(!path_file_exists(directory)) path_mkdir(directory); if(input_remapping_save_file(file)) rarch_main_msg_queue_push("Remap file saved successfully", 1, 100, true); else rarch_main_msg_queue_push("Error saving remap file", 1, 100, true); return 0; }
static void input_autoconfigure_joypad_add( config_file_t *conf, autoconfig_params_t *params) { bool block_osd_spam; char msg[PATH_MAX_LENGTH] = {0}; char display_name[PATH_MAX_LENGTH] = {0}; char device_type[PATH_MAX_LENGTH] = {0}; settings_t *settings = config_get_ptr(); config_get_array(conf, "input_device_display_name", display_name, sizeof(display_name)); config_get_array(conf, "input_device_type", device_type, sizeof(device_type)); if (!settings) return; /* This will be the case if input driver is reinitialized. * No reason to spam autoconfigure messages every time. */ block_osd_spam = settings->input.autoconfigured[params->idx] && *params->name; settings->input.autoconfigured[params->idx] = true; input_autoconfigure_joypad_conf(conf, settings->input.autoconf_binds[params->idx]); if (!strcmp(device_type,"remote")) { if (display_name[0] != '\0' || strcmp(display_name, "")) snprintf(msg, sizeof(msg), "%s configured", display_name); else snprintf(msg, sizeof(msg), "%s configured", params->name); if(!remote_is_bound) rarch_main_msg_queue_push(msg, 0, 60, false); remote_is_bound = true; } else { if (display_name[0] != '\0' || strcmp(display_name, "")) snprintf(msg, sizeof(msg), "%s configured in port #%u.", display_name, params->idx); else snprintf(msg, sizeof(msg), "%s configured in port #%u.", params->name, params->idx); if (!block_osd_spam) rarch_main_msg_queue_push(msg, 0, 60, false); } #if 0 RARCH_LOG("Autodetect: %s\n", msg); #endif }
/** * netplay_command: * @netplay : pointer to netplay object * @cmd : command to send * @data : data to send as argument * @sz : size of data * @flags : flags of CMD_OPT_* * @command_str : name of action * @success_msg : message to display upon success * * Sends a single netplay command and waits for response. */ bool netplay_command(netplay_t* netplay, enum netplay_cmd cmd, void* data, size_t sz, uint32_t flags, const char* command_str, const char* success_msg) { char m[256]; const char* msg = NULL; bool allowed_spectate = !!(flags & CMD_OPT_ALLOWED_IN_SPECTATE_MODE); bool host_only = !!(flags & CMD_OPT_HOST_ONLY); bool require_sync = !!(flags & CMD_OPT_REQUIRE_SYNC); assert(netplay); if (netplay->spectate.enabled && !allowed_spectate) { msg = "Cannot %s in spectate mode."; goto error; } if (host_only && netplay->port == 0) { msg = "Cannot %s as a client."; goto error; } if(require_sync && check_netplay_synched(netplay)) { msg = "Cannot %s while host and client are not in sync."; goto error; } if(netplay_send_raw_cmd(netplay, cmd, data, sz)) { if(netplay_get_response(netplay)) rarch_main_msg_queue_push(success_msg, 1, 180, false); else { msg = "Failed to send command \"%s\""; goto error; } } return true; error: snprintf(m, sizeof(m), msg, command_str); RARCH_WARN("%s\n", m); rarch_main_msg_queue_push(m, 1, 180, false); return false; }
/** * netplay_flip_users: * @netplay : pointer to netplay object * * On regular netplay, flip who controls user 1 and 2. **/ void netplay_flip_users(netplay_t *netplay) { uint32_t flip_frame = netplay->frame_count + 2 * UDP_FRAME_PACKETS; uint32_t flip_frame_net = htonl(flip_frame); const char *msg = NULL; if (netplay->spectate) { msg = "Cannot flip users in spectate mode."; goto error; } if (netplay->port == 0) { msg = "Cannot flip users if you're not the host."; goto error; } /* Make sure both clients are definitely synced up. */ if (netplay->frame_count < (netplay->flip_frame + 2 * UDP_FRAME_PACKETS)) { msg = "Cannot flip users yet. Wait a second or two before attempting flip."; goto error; } if (netplay_send_cmd(netplay, NETPLAY_CMD_FLIP_PLAYERS, &flip_frame_net, sizeof(flip_frame_net)) && netplay_get_response(netplay)) { RARCH_LOG("Netplay users are flipped.\n"); rarch_main_msg_queue_push("Netplay users are flipped.", 1, 180, false); /* Queue up a flip well enough in the future. */ netplay->flip ^= true; netplay->flip_frame = flip_frame; } else { msg = "Failed to flip users."; goto error; } return; error: RARCH_WARN("%s\n", msg); rarch_main_msg_queue_push(msg, 1, 180, false); }
static bool cmd_set_shader(const char *arg) { char msg[PATH_MAX_LENGTH] = {0}; enum rarch_shader_type type = RARCH_SHADER_NONE; const char *ext = path_get_extension(arg); uint32_t ext_hash = msg_hash_calculate(ext); switch (ext_hash) { case COMMAND_EXT_GLSL: case COMMAND_EXT_GLSLP: type = RARCH_SHADER_GLSL; break; case COMMAND_EXT_CG: case COMMAND_EXT_CGP: type = RARCH_SHADER_CG; break; default: return false; } snprintf(msg, sizeof(msg), "Shader: \"%s\"", arg); rarch_main_msg_queue_push(msg, 1, 120, true); RARCH_LOG("%s \"%s\".\n", msg_hash_to_str(MSG_APPLYING_SHADER), arg); return video_driver_set_shader(type, arg); }
static void gfx_ctx_d3d_update_title(void *data) { char buf[128] = {0}; char buffer_fps[128] = {0}; settings_t *settings = config_get_ptr(); if (video_monitor_get_fps(buf, sizeof(buf), buffer_fps, sizeof(buffer_fps))) { #ifndef _XBOX d3d_video_t *d3d = (d3d_video_t*)data; SetWindowText(g_hwnd, buf); #endif } if (settings->fps_show) { #ifdef _XBOX MEMORYSTATUS stat; char mem[128] = {0}; GlobalMemoryStatus(&stat); snprintf(mem, sizeof(mem), "|| MEM: %.2f/%.2fMB", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f)); strlcat(buffer_fps, mem, sizeof(buffer_fps)); #endif rarch_main_msg_queue_push(buffer_fps, 1, 1, false); } }
static void event_load_auto_state(void) { bool ret; char msg[PATH_MAX_LENGTH] = {0}; char savestate_name_auto[PATH_MAX_LENGTH] = {0}; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); #ifdef HAVE_NETPLAY if (global->netplay_enable && !global->netplay_is_spectate) return; #endif if (!settings->savestate_auto_load) return; fill_pathname_noext(savestate_name_auto, global->savestate_name, ".auto", sizeof(savestate_name_auto)); if (!path_file_exists(savestate_name_auto)) return; ret = load_state(savestate_name_auto); RARCH_LOG("Found auto savestate in: %s\n", savestate_name_auto); snprintf(msg, sizeof(msg), "Auto-loading savestate from \"%s\" %s.", savestate_name_auto, ret ? "succeeded" : "failed"); rarch_main_msg_queue_push(msg, 1, 180, false); RARCH_LOG("%s\n", msg); }
/** * event_disk_control_set_eject: * @new_state : Eject or close the virtual drive tray. * false (0) : Close * true (1) : Eject * @print_log : Show message onscreen. * * Ejects/closes of the virtual drive tray. **/ static void event_disk_control_set_eject(bool new_state, bool print_log) { char msg[PATH_MAX_LENGTH] = {0}; bool error = false; rarch_system_info_t *info = rarch_system_info_get_ptr(); const struct retro_disk_control_callback *control = info ? (const struct retro_disk_control_callback*)&info->disk_control : NULL; if (!control || !control->get_num_images) return; *msg = '\0'; if (control->set_eject_state(new_state)) snprintf(msg, sizeof(msg), "%s virtual disk tray.", new_state ? "Ejected" : "Closed"); else { error = true; snprintf(msg, sizeof(msg), "Failed to %s virtual disk tray.", new_state ? "eject" : "close"); } if (*msg) { if (error) RARCH_ERR("%s\n", msg); else RARCH_LOG("%s\n", msg); /* Only noise in menu. */ if (print_log) rarch_main_msg_queue_push(msg, 1, 180, true); } }
static void event_main_state(unsigned cmd) { char path[PATH_MAX_LENGTH] = {0}; char msg[PATH_MAX_LENGTH] = {0}; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); if (settings->state_slot > 0) snprintf(path, sizeof(path), "%s%d", global->name.savestate, settings->state_slot); else if (settings->state_slot < 0) fill_pathname_join_delim(path, global->name.savestate, "auto", '.', sizeof(path)); else strlcpy(path, global->name.savestate, sizeof(path)); if (core.retro_serialize_size()) { switch (cmd) { case EVENT_CMD_SAVE_STATE: event_save_state(path, msg, sizeof(msg)); break; case EVENT_CMD_LOAD_STATE: event_load_state(path, msg, sizeof(msg)); break; } } else strlcpy(msg, msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_SAVESTATES), sizeof(msg)); rarch_main_msg_queue_push(msg, 2, 180, true); RARCH_LOG("%s\n", msg); }
static void menu_push_to_history_playlist(void) { settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); if (!settings->history_list_enable) return; if (*global->fullpath) { char tmp[PATH_MAX_LENGTH] = {0}; char str[PATH_MAX_LENGTH] = {0}; fill_pathname_base(tmp, global->fullpath, sizeof(tmp)); snprintf(str, sizeof(str), "INFO - Loading %s ...", tmp); rarch_main_msg_queue_push(str, 1, 1, false); } content_playlist_push(g_defaults.history, global->fullpath, NULL, settings->libretro, global->menu.info.library_name, NULL, NULL); }
static void event_main_state(unsigned cmd) { char path[PATH_MAX_LENGTH] = {0}; char msg[PATH_MAX_LENGTH] = {0}; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); if (settings->state_slot > 0) snprintf(path, sizeof(path), "%s%d", global->savestate_name, settings->state_slot); else if (settings->state_slot < 0) fill_pathname_join_delim(path, global->savestate_name, "auto", '.', sizeof(path)); else strlcpy(path, global->savestate_name, sizeof(path)); if (pretro_serialize_size()) { if (cmd == EVENT_CMD_SAVE_STATE) event_save_state(path, msg, sizeof(msg)); else if (cmd == EVENT_CMD_LOAD_STATE) event_load_state(path, msg, sizeof(msg)); } else strlcpy(msg, "Core does not support save states.", sizeof(msg)); rarch_main_msg_queue_push(msg, 2, 180, true); RARCH_LOG("%s\n", msg); }
static int action_start_video_resolution( unsigned type, const char *label) { unsigned width = 0, height = 0; global_t *global = global_get_ptr(); video_driver_set_video_mode(640, 480, true); if (!global) return -1; if (video_driver_get_video_output_size(&width, &height)) { char msg[PATH_MAX_LENGTH] = {0}; video_driver_set_video_mode(width, height, true); global->console.screen.resolutions.width = width; global->console.screen.resolutions.height = height; snprintf(msg, sizeof(msg),"Resetting to: %dx%d",width, height); rarch_main_msg_queue_push(msg, 1, 100, true); } return 0; }
static int database_info_iterate_start (database_info_handle_t *db, const char *name) { char msg[PATH_MAX_LENGTH] = {0}; snprintf(msg, sizeof(msg), #ifdef _WIN32 "%Iu/%Iu: %s %s...\n", #else "%zu/%zu: %s %s...\n", #endif db->list_ptr, db->list->size, msg_hash_to_str(MSG_SCANNING), name); if (msg[0] != '\0') rarch_main_msg_queue_push(msg, 1, 180, true); #if 0 RARCH_LOG("msg: %s\n", msg); #endif db->status = DATABASE_STATUS_ITERATE; return 0; }
/** * netplay_post_frame_spectate: * @netplay : pointer to netplay object * * Post-frame for Netplay (spectate mode version). * We check if we have new input and replay from recorded input. **/ static void netplay_post_frame_spectate(netplay_t *netplay) { unsigned i; if (netplay->spectate_client) return; for (i = 0; i < MAX_SPECTATORS; i++) { char msg[PATH_MAX_LENGTH] = {0}; if (netplay->spectate_fds[i] == -1) continue; if (socket_send_all_blocking(netplay->spectate_fds[i], netplay->spectate_input, netplay->spectate_input_ptr * sizeof(int16_t))) continue; RARCH_LOG("Client (#%u) disconnected ...\n", i); snprintf(msg, sizeof(msg), "Client (#%u) disconnected.", i); rarch_main_msg_queue_push(msg, 1, 180, false); socket_close(netplay->spectate_fds[i]); netplay->spectate_fds[i] = -1; break; } netplay->spectate_input_ptr = 0; }
bool input_config_autoconfigure_joypad(autoconfig_params_t *params) { bool ret = false; if (!input_config_autoconfigure_joypad_init(params)) return ret; if (!*params->name) return ret; if (!ret) ret = input_autoconfigure_joypad_from_conf_dir(params); #if defined(HAVE_BUILTIN_AUTOCONFIG) if (!ret) ret = input_autoconfigure_joypad_from_conf_internal(params); #endif if (!ret) { char msg[PATH_MAX_LENGTH]; RARCH_LOG("Autodetect: no profiles found for %s (%d/%d)", params->name, params->vid, params->pid); snprintf(msg, sizeof(msg), "%s (%ld/%ld) not configured", params->name, (long)params->vid, (long)params->pid); rarch_main_msg_queue_push(msg, 0, 60, false); } return ret; }
static void input_autoconfigure_joypad_add( config_file_t *conf, autoconfig_params_t *params) { char msg[PATH_MAX_LENGTH] = {0}; char buf[PATH_MAX_LENGTH] = {0}; settings_t *settings = config_get_ptr(); config_get_array(conf, "input_display_name", buf, sizeof(buf)); /* This will be the case if input driver is reinitialized. * No reason to spam autoconfigure messages every time. */ bool block_osd_spam = settings && settings->input.autoconfigured[params->idx] && *params->name; if (!settings) return; settings->input.autoconfigured[params->idx] = true; input_autoconfigure_joypad_conf(conf, settings->input.autoconf_binds[params->idx]); if (buf[0] != '\0' || strcmp(buf, "")) snprintf(msg, sizeof(msg), "%s configured in port #%u.", buf, params->idx); else snprintf(msg, sizeof(msg), "%s configured in port #%u.", params->name, params->idx); if (!block_osd_spam) rarch_main_msg_queue_push(msg, 0, 60, false); RARCH_LOG("%s\n", msg); }
static bool input_try_autoconfigure_joypad_from_conf(config_file_t *conf, unsigned idx, const char *name, const char *drv, int32_t vid, int32_t pid, bool block_osd_spam) { char ident[PATH_MAX_LENGTH], ident_idx[PATH_MAX_LENGTH]; char input_driver[PATH_MAX_LENGTH], msg[PATH_MAX_LENGTH]; int input_vid = 0, input_pid = 0; bool cond_found_idx, cond_found_general, cond_found_vid = false, cond_found_pid = false; if (!conf) return false; *ident = *input_driver = '\0'; config_get_array(conf, "input_device", ident, sizeof(ident)); config_get_array(conf, "input_driver", input_driver, sizeof(input_driver)); config_get_int(conf, "input_vendor_id", &input_vid); config_get_int(conf, "input_product_id", &input_pid); snprintf(ident_idx, sizeof(ident_idx), "%s_p%u", ident, idx); #if 0 RARCH_LOG("ident_idx: %s\n", ident_idx); #endif cond_found_idx = !strcmp(ident_idx, name); cond_found_general = !strcmp(ident, name) && !strcmp(drv, input_driver); if ((vid != 0) && (input_vid != 0)) cond_found_vid = (vid == input_vid); if ((pid != 0) && (input_pid != 0)) cond_found_pid = (pid == input_pid); /* If Vendor ID and Product ID matches, we've found our * entry. */ if (cond_found_vid && cond_found_pid) goto found; /* Check for name match. */ if (cond_found_idx) goto found; else if (cond_found_general) goto found; return false; found: g_settings.input.autoconfigured[idx] = true; input_autoconfigure_joypad_conf(conf, g_settings.input.autoconf_binds[idx]); snprintf(msg, sizeof(msg), "Joypad port #%u (%s) configured.", idx, name); if (!block_osd_spam) rarch_main_msg_queue_push(msg, 0, 60, false); RARCH_LOG("%s\n", msg); return true; }
void input_config_autoconfigure_disconnect(unsigned i, const char *ident) { char msg[PATH_MAX_LENGTH] = {0}; snprintf(msg, sizeof(msg), "Device #%u (%s) disconnected.", i, ident); rarch_main_msg_queue_push(msg, 0, 60, false); RARCH_LOG("Autodetect: %s\n", msg); }
static bool get_info_spectate(netplay_t *netplay) { size_t save_state_size, size; void *buf = NULL; uint32_t header[4] = {0}; char msg[512] = {0}; bool ret = true; if (!send_nickname(netplay, netplay->fd)) { RARCH_ERR("Failed to send nickname to host.\n"); return false; } if (!get_nickname(netplay, netplay->fd)) { RARCH_ERR("Failed to receive nickname from host.\n"); return false; } snprintf(msg, sizeof(msg), "Connected to \"%s\"", netplay->other_nick); rarch_main_msg_queue_push(msg, 1, 180, false); RARCH_LOG("%s\n", msg); if (!socket_receive_all_blocking(netplay->fd, header, sizeof(header))) { RARCH_ERR("Cannot get header from host.\n"); return false; } save_state_size = core.retro_serialize_size(); if (!bsv_parse_header(header, implementation_magic_value())) { RARCH_ERR("Received invalid BSV header from host.\n"); return false; } buf = malloc(save_state_size); if (!buf) return false; size = save_state_size; if (!socket_receive_all_blocking(netplay->fd, buf, size)) { RARCH_ERR("Failed to receive save state from host.\n"); free(buf); return false; } if (save_state_size) ret = core.retro_unserialize(buf, save_state_size); free(buf); return ret; }
/** * check_shader_dir: * @pressed_next : was next shader key pressed? * @pressed_previous : was previous shader key pressed? * * Checks if any one of the shader keys has been pressed for this frame: * a) Next shader index. * b) Previous shader index. * * Will also immediately apply the shader. **/ static void check_shader_dir(global_t *global, bool pressed_next, bool pressed_prev) { uint32_t ext_hash; char msg[PATH_MAX_LENGTH]; const char *shader = NULL; const char *ext = NULL; enum rarch_shader_type type = RARCH_SHADER_NONE; if (!global || !global->shader_dir.list) return; if (pressed_next) { global->shader_dir.ptr = (global->shader_dir.ptr + 1) % global->shader_dir.list->size; } else if (pressed_prev) { if (global->shader_dir.ptr == 0) global->shader_dir.ptr = global->shader_dir.list->size - 1; else global->shader_dir.ptr--; } else return; shader = global->shader_dir.list->elems[global->shader_dir.ptr].data; ext = path_get_extension(shader); ext_hash = msg_hash_calculate(ext); switch (ext_hash) { case SHADER_EXT_GLSL: case SHADER_EXT_GLSLP: type = RARCH_SHADER_GLSL; break; case SHADER_EXT_CG: case SHADER_EXT_CGP: type = RARCH_SHADER_CG; break; default: return; } snprintf(msg, sizeof(msg), "%s #%u: \"%s\".", msg_hash_to_str(MSG_SHADER), (unsigned)global->shader_dir.ptr, shader); rarch_main_msg_queue_push(msg, 1, 120, true); RARCH_LOG("%s \"%s\".\n", msg_hash_to_str(MSG_APPLYING_SHADER), shader); if (!video_driver_set_shader(type, shader)) RARCH_WARN("%s\n", msg_hash_to_str(MSG_FAILED_TO_APPLY_SHADER)); }
void rarch_main_msg_queue_push_new(uint32_t hash, unsigned prio, unsigned duration, bool flush) { const char *msg = msg_hash_to_str(hash); if (!msg) return; rarch_main_msg_queue_push(msg, prio, duration, flush); }
static void android_gfx_ctx_update_window_title(void *data) { char buf[128], buf_fps[128]; settings_t *settings = config_get_ptr(); video_monitor_get_fps(buf, sizeof(buf), buf_fps, sizeof(buf_fps)); if (settings->fps_show) rarch_main_msg_queue_push(buf_fps, 1, 1, false); }
void rarch_main_data_iterate(void) { data_runloop_t *runloop = rarch_main_data_get_ptr(); settings_t *settings = config_get_ptr(); (void)settings; #ifdef HAVE_THREADS if (settings->menu.threaded_data_runloop_enable) { switch (runloop->thread_code) { case THREAD_CODE_INIT: rarch_main_data_thread_init(); break; case THREAD_CODE_DEINIT: case THREAD_CODE_ALIVE: break; } } #endif #ifdef HAVE_OVERLAY rarch_main_data_overlay_image_upload_iterate(false); #endif #ifdef HAVE_RPNG rarch_main_data_nbio_image_upload_iterate(false); #endif #ifdef HAVE_OVERLAY rarch_main_data_overlay_iterate (false); #endif #ifdef HAVE_MENU #ifdef HAVE_LIBRETRODB if (rarch_main_data_db_pending_scan_finished()) menu_environment_cb(MENU_ENVIRON_RESET_HORIZONTAL_LIST, NULL); #endif #endif if (data_runloop_msg[0] != '\0') { rarch_main_msg_queue_push(data_runloop_msg, 1, 10, true); data_runloop_msg[0] = '\0'; } #ifdef HAVE_MENU menu_entries_refresh(MENU_ACTION_REFRESH); #endif #ifdef HAVE_THREADS if (settings->menu.threaded_data_runloop_enable && runloop->alive) return; #endif data_runloop_iterate(false); }
/** * video_monitor_set_refresh_rate: * @hz : New refresh rate for monitor. * * Sets monitor refresh rate to new value. **/ void video_monitor_set_refresh_rate(float hz) { char msg[PATH_MAX_LENGTH]; settings_t *settings = config_get_ptr(); snprintf(msg, sizeof(msg), "Setting refresh rate to: %.3f Hz.", hz); rarch_main_msg_queue_push(msg, 1, 180, false); RARCH_LOG("%s\n", msg); settings->video.refresh_rate = hz; }
static void event_init_movie(void) { settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); if (global->bsv.movie_start_playback) { if (!(global->bsv.movie = bsv_movie_init(global->bsv.movie_start_path, RARCH_MOVIE_PLAYBACK))) { RARCH_ERR("Failed to load movie file: \"%s\".\n", global->bsv.movie_start_path); rarch_fail(1, "event_init_movie()"); } global->bsv.movie_playback = true; rarch_main_msg_queue_push("Starting movie playback.", 2, 180, false); RARCH_LOG("Starting movie playback.\n"); settings->rewind_granularity = 1; } else if (global->bsv.movie_start_recording) { char msg[PATH_MAX_LENGTH] = {0}; snprintf(msg, sizeof(msg), "Starting movie record to \"%s\".", global->bsv.movie_start_path); if (!(global->bsv.movie = bsv_movie_init(global->bsv.movie_start_path, RARCH_MOVIE_RECORD))) { rarch_main_msg_queue_push("Failed to start movie record.", 1, 180, true); RARCH_ERR("Failed to start movie record.\n"); return; } rarch_main_msg_queue_push(msg, 1, 180, true); RARCH_LOG("Starting movie record to \"%s\".\n", global->bsv.movie_start_path); settings->rewind_granularity = 1; } }
/* Custom inet_ntop. Win32 doesn't seem to support this ... */ static void log_connection(const struct sockaddr_storage *their_addr, unsigned slot, const char *nick) { union { const struct sockaddr_storage *storage; const struct sockaddr_in *v4; const struct sockaddr_in6 *v6; } u; const char *str = NULL; char buf_v4[INET_ADDRSTRLEN] = {0}; char buf_v6[INET6_ADDRSTRLEN] = {0}; u.storage = their_addr; if (their_addr->ss_family == AF_INET) { struct sockaddr_in in; str = buf_v4; memset(&in, 0, sizeof(in)); in.sin_family = AF_INET; memcpy(&in.sin_addr, &u.v4->sin_addr, sizeof(struct in_addr)); getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in), buf_v4, sizeof(buf_v4), NULL, 0, NI_NUMERICHOST); } else if (their_addr->ss_family == AF_INET6) { struct sockaddr_in6 in; str = buf_v6; memset(&in, 0, sizeof(in)); in.sin6_family = AF_INET6; memcpy(&in.sin6_addr, &u.v6->sin6_addr, sizeof(struct in6_addr)); getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in6), buf_v6, sizeof(buf_v6), NULL, 0, NI_NUMERICHOST); } if (str) { char msg[512] = {0}; snprintf(msg, sizeof(msg), "Got connection from: \"%s (%s)\" (#%u)", nick, str, slot); rarch_main_msg_queue_push(msg, 1, 180, false); RARCH_LOG("%s\n", msg); } }
static void gfx_ctx_glx_update_window_title(void *data) { char buf[128], buf_fps[128]; driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)driver->video_context_data; if (video_monitor_get_fps(buf, sizeof(buf), buf_fps, sizeof(buf_fps))) XStoreName(glx->g_dpy, glx->g_win, buf); if (settings->fps_show) rarch_main_msg_queue_push(buf_fps, 1, 1, false); }
static bool netplay_get_cmd(netplay_t *netplay) { uint32_t cmd, flip_frame; size_t cmd_size; if (!socket_receive_all_blocking(netplay->fd, &cmd, sizeof(cmd))) return false; cmd = ntohl(cmd); cmd_size = cmd & 0xffff; cmd = cmd >> 16; switch (cmd) { case NETPLAY_CMD_FLIP_PLAYERS: if (cmd_size != sizeof(uint32_t)) { RARCH_ERR("CMD_FLIP_PLAYERS has unexpected command size.\n"); return netplay_cmd_nak(netplay); } if (!socket_receive_all_blocking(netplay->fd, &flip_frame, sizeof(flip_frame))) { RARCH_ERR("Failed to receive CMD_FLIP_PLAYERS argument.\n"); return netplay_cmd_nak(netplay); } flip_frame = ntohl(flip_frame); if (flip_frame < netplay->flip_frame) { RARCH_ERR("Host asked us to flip users in the past. Not possible ...\n"); return netplay_cmd_nak(netplay); } netplay->flip ^= true; netplay->flip_frame = flip_frame; RARCH_LOG("Netplay users are flipped.\n"); rarch_main_msg_queue_push("Netplay users are flipped.", 1, 180, false); return netplay_cmd_ack(netplay); default: break; } RARCH_ERR("Unknown netplay command received.\n"); return netplay_cmd_nak(netplay); }
static void gfx_ctx_xegl_update_window_title(void *data) { char buf[128] = {0}; char buf_fps[128] = {0}; settings_t *settings = config_get_ptr(); (void)data; if (video_monitor_get_fps(buf, sizeof(buf), buf_fps, sizeof(buf_fps))) XStoreName(g_dpy, g_win, buf); if (settings->fps_show) rarch_main_msg_queue_push(buf_fps, 1, 1, false); }
static int16_t netplay_get_spectate_input(netplay_t *netplay, bool port, unsigned device, unsigned idx, unsigned id) { int16_t inp; if (socket_receive_all_blocking(netplay->fd, (char*)&inp, sizeof(inp))) return swap_if_big16(inp); RARCH_ERR("Connection with host was cut.\n"); rarch_main_msg_queue_push("Connection with host was cut.", 1, 180, true); core.retro_set_input_state(netplay->cbs.state_cb); return netplay->cbs.state_cb(port, device, idx, id); }