/** * event_check_disk_next: * @control : Handle to disk control handle. * * Perform disk cycle to next index action (Core Disk Options). **/ static void event_check_disk_next( const struct retro_disk_control_callback *control) { unsigned num_disks = 0; unsigned current = 0; bool disk_next_enable = false; if (!control) return; if (!control->get_num_images) return; if (!control->get_image_index) return; num_disks = control->get_num_images(); current = control->get_image_index(); disk_next_enable = num_disks && num_disks != UINT_MAX; if (!disk_next_enable) { RARCH_ERR("Got invalid disk index from libretro.\n"); return; } if (current < num_disks - 1) current++; event_disk_control_set_index(current); }
/** * event_check_disk_next: * @control : Handle to disk control handle. * * Perform disk cycle to next index action (Core Disk Options). **/ static void event_check_disk_next( const struct retro_disk_control_callback *control) { unsigned num_disks = 0; unsigned current = 0; bool disk_next_enable = false; if (!control) return; if (!control->get_num_images) return; if (!control->get_image_index) return; num_disks = control->get_num_images(); current = control->get_image_index(); disk_next_enable = num_disks && num_disks != UINT_MAX; if (!disk_next_enable) { RARCH_ERR("%s.\n", msg_hash_to_str(MSG_GOT_INVALID_DISK_INDEX)); return; } if (current < num_disks - 1) current++; event_disk_control_set_index(current); }
/** * event_disk_control_append_image: * @path : Path to disk image. * * Appends disk image to disk image list. **/ static bool event_disk_control_append_image(const char *path) { unsigned new_idx; char msg[128] = {0}; struct retro_game_info info = {0}; global_t *global = global_get_ptr(); const struct retro_disk_control_callback *control = NULL; rarch_system_info_t *sysinfo = NULL; runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sysinfo); if (sysinfo) control = (const struct retro_disk_control_callback*) &sysinfo->disk_control_cb; if (!control) return false; event_disk_control_set_eject(true, false); control->add_image_index(); new_idx = control->get_num_images(); if (!new_idx) return false; new_idx--; info.path = path; control->replace_image_index(new_idx, &info); snprintf(msg, sizeof(msg), "%s: ", msg_hash_to_str(MSG_APPENDED_DISK)); strlcat(msg, path, sizeof(msg)); RARCH_LOG("%s\n", msg); runloop_msg_queue_push(msg, 0, 180, true); event_cmd_ctl(EVENT_CMD_AUTOSAVE_DEINIT, NULL); /* TODO: Need to figure out what to do with subsystems case. */ if (!*global->subsystem) { /* Update paths for our new image. * If we actually use append_image, we assume that we * started out in a single disk case, and that this way * of doing it makes the most sense. */ rarch_ctl(RARCH_CTL_SET_PATHS, (void*)path); rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); } event_cmd_ctl(EVENT_CMD_AUTOSAVE_INIT, NULL); event_disk_control_set_index(new_idx); event_disk_control_set_eject(false, false); return true; }
/** * event_disk_control_append_image: * @path : Path to disk image. * * Appends disk image to disk image list. **/ void event_disk_control_append_image(const char *path) { unsigned new_idx; char msg[PATH_MAX_LENGTH] = {0}; struct retro_game_info info = {0}; global_t *global = global_get_ptr(); rarch_system_info_t *sysinfo = rarch_system_info_get_ptr(); const struct retro_disk_control_callback *control = sysinfo ? (const struct retro_disk_control_callback*)&sysinfo->disk_control : NULL; if (!control) return; event_disk_control_set_eject(true, false); control->add_image_index(); new_idx = control->get_num_images(); if (!new_idx) return; new_idx--; info.path = path; control->replace_image_index(new_idx, &info); snprintf(msg, sizeof(msg), "%s: ", msg_hash_to_str(MSG_APPENDED_DISK)); strlcat(msg, path, sizeof(msg)); RARCH_LOG("%s\n", msg); rarch_main_msg_queue_push(msg, 0, 180, true); event_command(EVENT_CMD_AUTOSAVE_DEINIT); /* TODO: Need to figure out what to do with subsystems case. */ if (!*global->subsystem) { /* Update paths for our new image. * If we actually use append_image, we assume that we * started out in a single disk case, and that this way * of doing it makes the most sense. */ rarch_set_paths(path); rarch_ctl(RARCH_ACTION_STATE_FILL_PATHNAMES, NULL); } event_command(EVENT_CMD_AUTOSAVE_INIT); event_disk_control_set_index(new_idx); event_disk_control_set_eject(false, false); }
/** * event_check_disk_prev: * @control : Handle to disk control handle. * * Perform disk cycle to previous index action (Core Disk Options). **/ static void event_check_disk_prev( const struct retro_disk_control_callback *control) { unsigned num_disks = control->get_num_images(); unsigned current = control->get_image_index(); bool disk_prev_enable = num_disks && num_disks != UINT_MAX; if (!disk_prev_enable) { RARCH_ERR("Got invalid disk index from libretro.\n"); return; } if (current > 0) current--; event_disk_control_set_index(current); }