Esempio n. 1
0
static int iso_get_serial(database_state_handle_t *db_state,
                          database_info_handle_t *db, const char *name, char* serial)
{
    int32_t offset          = 0;
    const char* system_name = NULL;
    int                 rv  = detect_system(name, offset, &system_name);

    if (rv < 0)
        return rv;

    if (string_is_equal(system_name, "psp"))
    {
        if (detect_psp_game(name, serial) == 0)
            return 0;
        RARCH_LOG("%s '%s'\n", msg_hash_to_str(MSG_FOUND_DISK_LABEL), serial);
    }
    else if (string_is_equal(system_name, "ps1"))
    {
        if (detect_ps1_game(name, serial) == 0)
            return 0;
        RARCH_LOG("%s '%s'\n", msg_hash_to_str(MSG_FOUND_DISK_LABEL), serial);
    }

    return 0;
}
Esempio n. 2
0
static int iso_get_serial(database_state_handle_t *db_state,
      database_info_handle_t *db, const char *name, char* serial)
{
   int rv;
   int32_t offset = 0;
   const char* system_name = NULL;

   if ((rv = detect_system(name, offset, &system_name)) < 0)
      return rv;

   if (string_is_equal(system_name, "psp"))
   {
      if (detect_psp_game(name, serial) == 0)
         return 0;
      RARCH_LOG("Found disk label '%s'\n", serial);
   }
   else if (string_is_equal(system_name, "ps1"))
   {
      if (detect_ps1_game(name, serial) == 0)
         return 0;
      RARCH_LOG("Found disk label '%s'\n", serial);
   }

   return 0;
}
Esempio n. 3
0
static bool menu_display_check_compatibility(
      enum menu_display_driver_type type)
{
   const char *video_driver = menu_video_get_ident();

   switch (type)
   {
      case MENU_VIDEO_DRIVER_GENERIC:
         return true;
      case MENU_VIDEO_DRIVER_OPENGL:
         if (string_is_equal(video_driver, "gl"))
            return true;
         break;
      case MENU_VIDEO_DRIVER_VULKAN:
         if (string_is_equal(video_driver, "vulkan"))
            return true;
         break;
      case MENU_VIDEO_DRIVER_DIRECT3D:
         if (string_is_equal(video_driver, "d3d"))
            return true;
         break;
   }

   return false;
}
Esempio n. 4
0
/* Registry callbacks. */
static void registry_handle_global(void *data, struct wl_registry *reg,
      uint32_t id, const char *interface, uint32_t version)
{
   struct wl_output *output   = NULL;
   gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;

   (void)version;

   if (string_is_equal(interface, "wl_compositor"))
      wl->compositor = (struct wl_compositor*)wl_registry_bind(reg,
            id, &wl_compositor_interface, 3);
   else if (string_is_equal(interface, "wl_output"))
   {
      output = (struct wl_output*)wl_registry_bind(reg,
            id, &wl_output_interface, 2);
      wl_output_add_listener(output, &output_listener, wl);
      wl_display_roundtrip(wl->input.dpy);
   }
   else if (string_is_equal(interface, "wl_shell"))
      wl->shell = (struct wl_shell*)
         wl_registry_bind(reg, id, &wl_shell_interface, 1);
   else if (string_is_equal(interface, "wl_shm"))
      wl->shm = (struct wl_shm*)wl_registry_bind(reg, id, &wl_shm_interface, 1);
   else if (string_is_equal(interface, "wl_seat"))
   {
      wl->seat = (struct wl_seat*)wl_registry_bind(reg, id, &wl_seat_interface, 4);
      wl_seat_add_listener(wl->seat, &seat_listener, wl);
   }
}
Esempio n. 5
0
static void menu_action_setting_disp_set_label_playlist_associations(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)
{
   char playlist_name_with_ext[255];
   bool found_matching_core_association         = false;
   settings_t         *settings                 = config_get_ptr();
   struct string_list *str_list                 = string_split(settings->arrays.playlist_names, ";");
   struct string_list *str_list2                = string_split(settings->arrays.playlist_cores, ";");

   strlcpy(s2, path, len2);

   playlist_name_with_ext[0] = '\0';
   *s = '\0';
   *w = 19;

   fill_pathname_noext(playlist_name_with_ext, path,
         file_path_str(FILE_PATH_LPL_EXTENSION),
         sizeof(playlist_name_with_ext));

   for (i = 0; i < str_list->size; i++)
   {
      if (string_is_equal(str_list->elems[i].data, playlist_name_with_ext))
      {
         if (str_list->size != str_list2->size)
            break;

         if (!str_list2->elems[i].data)
            break;

         found_matching_core_association = true;
         strlcpy(s, str_list2->elems[i].data, len);
      }
   }

   string_list_free(str_list);
   string_list_free(str_list2);

   if (string_is_equal(s, file_path_str(FILE_PATH_DETECT)) || !found_matching_core_association)
      strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len);
   else
   {
      char buf[PATH_MAX_LENGTH];
      core_info_list_t *list = NULL;

      core_info_get_list(&list);

      if (core_info_list_get_display_name(list, s, buf, sizeof(buf)))
         strlcpy(s, buf, len);
   }

   strlcpy(s2, path, len2);
}
static void menu_action_setting_disp_set_label_playlist_associations(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)
{
   char playlist_name_with_ext[PATH_MAX_LENGTH] = {0};
   bool found_matching_core_association         = false;
   settings_t         *settings                 = config_get_ptr();
   struct string_list *str_list                 = string_split(settings->playlist_names, ";");
   struct string_list *str_list2                = string_split(settings->playlist_cores, ";");

   strlcpy(s2, path, len2);

   *s = '\0';
   *w = 19;

   strlcpy(playlist_name_with_ext, path, sizeof(playlist_name_with_ext));
   strlcat(playlist_name_with_ext, ".lpl", sizeof(playlist_name_with_ext));

   for (i = 0; i < str_list->size; i++)
   {
      if (string_is_equal(str_list->elems[i].data, playlist_name_with_ext))
      {
         if (str_list->size != str_list2->size)
            break;

         if (str_list2->elems[i].data == NULL)
            break;

         found_matching_core_association = true;
         strlcpy(s, str_list2->elems[i].data, len);
      }
   }

   string_list_free(str_list);
   string_list_free(str_list2);

   if (string_is_equal(s, "DETECT") || !found_matching_core_association)
      strlcpy(s, "N/A", len);
   else
   {
      char buf[PATH_MAX_LENGTH];
      core_info_list_t *list = NULL;

      core_info_get_list(&list);

      if (core_info_list_get_display_name(list, s, buf, sizeof(buf)))
         strlcpy(s, buf, len);
   }

   strlcpy(s2, path, len2);
}
Esempio n. 7
0
static inline host_htable_index cache_host_trans_ht_index(string_t *top_label)
{
    if (string_is_equal(top_label, &tld_com)) {
        return host_ht_com;
    } else if (string_is_equal(top_label, &tld_cn)) {
        return host_ht_cn;
    } else if (string_is_equal(top_label, &tld_com_cn)) {
        return host_ht_com_cn;
    } else {
        return host_ht_max;
    }
}
Esempio n. 8
0
void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
{
#if TARGET_OS_IPHONE
   static int asl_inited = 0;
#if !TARGET_IPHONE_SIMULATOR
static aslclient asl_client;
#endif
#endif

   if (!RARCH_LOG_VERBOSE())
      return;
#if TARGET_OS_IPHONE
#if TARGET_IPHONE_SIMULATOR
   vprintf(fmt, ap);
#else
   if (!asl_inited)
   {
      asl_client = asl_open("RetroArch", "com.apple.console", ASL_OPT_STDERR | ASL_OPT_NO_DELAY);
      asl_inited = 1;
   }
   aslmsg msg = asl_new(ASL_TYPE_MSG);
   asl_set(msg, ASL_KEY_READ_UID, "-1");
   if (tag)
      asl_log(asl_client, msg, ASL_LEVEL_NOTICE, "%s", tag);
   asl_vlog(asl_client, msg, ASL_LEVEL_NOTICE, fmt, ap);
   asl_free(msg);
#endif
#elif defined(_XBOX1)
   /* FIXME: Using arbitrary string as fmt argument is unsafe. */
   char msg_new[1024], buffer[1024];
   snprintf(msg_new, sizeof(msg_new), "%s: %s %s",
         PROGRAM_NAME,
         tag ? tag : "",
         fmt);
   wvsprintf(buffer, msg_new, ap);
   OutputDebugStringA(buffer);
#elif defined(ANDROID)
   int prio = ANDROID_LOG_INFO;
   if (tag)
   {
      if (string_is_equal("[WARN]", tag))
         prio = ANDROID_LOG_WARN;
      else if (string_is_equal("[ERROR]", tag))
         prio = ANDROID_LOG_ERROR;
   }
   __android_log_vprint(prio, PROGRAM_NAME, fmt, ap);
#else
   fprintf(LOG_FILE, "%s %s :: ", PROGRAM_NAME, tag ? tag : "[INFO]");
   vfprintf(LOG_FILE, fmt, ap);
   fflush(LOG_FILE);
#endif
}
Esempio n. 9
0
static void salamander_init(char *s, size_t len)
{
   /* normal executable loading path */
   bool config_exists = config_file_exists(g_defaults.path.config);

   if (config_exists)
   {
      char tmp_str[PATH_MAX_LENGTH] = {0};
      config_file_t * conf          = (config_file_t*)
         config_file_new(g_defaults.path.config);

      if (conf)
      {
         config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
         config_file_free(conf);

         if (!string_is_equal(tmp_str, "builtin"))
            strlcpy(s, tmp_str, len);
      }
#ifdef GEKKO
      /* stupid libfat bug or something; sometimes it says 
       * the file is there when it doesn't. */
      else 
      {
         config_exists = false;
      }
#endif
   }

   if (!config_exists || string_is_equal(s, ""))
   {
      char executable_name[PATH_MAX_LENGTH] = {0};

      frontend_driver_get_core_extension(
            executable_name, sizeof(executable_name));
      find_and_set_first_file(s, len, executable_name);
   }
   else
      RARCH_LOG("Start [%s] found in retroarch.cfg.\n", s);

   if (!config_exists)
   {
      config_file_t *conf = (config_file_t*)config_file_new(NULL);

      if (conf)
      {
         config_set_string(conf, "libretro_path", s);
         config_file_write(conf, g_defaults.path.config);
         config_file_free(conf);
      }
   }
}
Esempio n. 10
0
const struct retro_subsystem_info *libretro_find_subsystem_info(
      const struct retro_subsystem_info *info, unsigned num_info,
      const char *ident)
{
   unsigned i;
   for (i = 0; i < num_info; i++)
   {
      if (string_is_equal(info[i].ident, ident))
         return &info[i];
      else if (string_is_equal(info[i].desc, ident))
         return &info[i];
   }

   return NULL;
}
Esempio n. 11
0
static void *hlsl_init(void *data, const char *path)
{
   unsigned i;
   d3d_video_t *d3d = (d3d_video_t*)data;
   hlsl_shader_data_t *hlsl_data = (hlsl_shader_data_t*)
      calloc(1, sizeof(hlsl_shader_data_t));

   if (!hlsl_data)
	   return NULL;

   if (path && string_is_equal(path_get_extension(path), ".cgp"))
   {
      if (!hlsl_load_preset(hlsl_data, d3d, path))
         goto error;
   }
   else
   {
      if (!hlsl_load_plain(hlsl_data, d3d, path))
         goto error;
   }

   for(i = 1; i <= hlsl_data->cg_shader->passes; i++)
      hlsl_set_program_attributes(hlsl_data, i);

   d3d_set_vertex_shader(d3d->dev, 1, hlsl_data->prg[1].vprg);
   d3d->dev->SetPixelShader(hlsl_data->prg[1].fprg);

   return hlsl_data;

error:
   if (hlsl_data)
	   free(hlsl_data);
   return NULL;
}
Esempio n. 12
0
static void menu_action_setting_disp_set_label_netplay_mitm_server(
      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)
{
   unsigned j;
   settings_t *settings = config_get_ptr();

   *s = '\0';
   *w = 19;
   strlcpy(s2, path, len2);

   if (!settings)
      return;

   if (string_is_empty(settings->arrays.netplay_mitm_server))
      return;

   for (j = 0; j < ARRAY_SIZE(netplay_mitm_server_list); j++)
   {
      if (string_is_equal(settings->arrays.netplay_mitm_server,
               netplay_mitm_server_list[j].name))
         strlcpy(s, netplay_mitm_server_list[j].description, len);
   }
}
Esempio n. 13
0
void input_config_get_bind_string(char *buf, const struct retro_keybind *bind,
      const struct retro_keybind *auto_bind, size_t size)
{
#ifndef RARCH_CONSOLE
   char key[64];
   char keybuf[64];

   key[0] = keybuf[0] = '\0';
#endif

   *buf = '\0';
   if (bind->joykey != NO_BTN)
      input_config_get_bind_string_joykey(buf, "", bind, size);
   else if (bind->joyaxis != AXIS_NONE)
      input_config_get_bind_string_joyaxis(buf, "", bind, size);
   else if (auto_bind && auto_bind->joykey != NO_BTN)
      input_config_get_bind_string_joykey(buf, "Auto: ", auto_bind, size);
   else if (auto_bind && auto_bind->joyaxis != AXIS_NONE)
      input_config_get_bind_string_joyaxis(buf, "Auto: ", auto_bind, size);

#ifndef RARCH_CONSOLE
   input_keymaps_translate_rk_to_str(bind->key, key, sizeof(key));
   if (string_is_equal(key, file_path_str(FILE_PATH_NUL)))
      *key = '\0';

   snprintf(keybuf, sizeof(keybuf), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_KEY), key);
   strlcat(buf, keybuf, size);
#endif
}
Esempio n. 14
0
static const char* dat_converter_get_match(
      dat_converter_list_t* list,
      dat_converter_match_key_t* match_key)
{
   int i;

   retro_assert(match_key);

   if (list->type != DAT_CONVERTER_MAP_LIST)
      return NULL;

   for (i = 0; i < list->count; i++)
   {
      if (list->values[i].map.hash == match_key->hash)
      {
         retro_assert(string_is_equal(list->values[i].map.key, match_key->value));

         if (match_key->next)
            return dat_converter_get_match(
                  list->values[i].map.value.list, match_key->next);

         if ((list->values[i].map.type == DAT_CONVERTER_STRING_MAP))
            return list->values[i].map.value.string;

         return NULL;

      }
   }
   return NULL;
}
Esempio n. 15
0
bool menu_content_playlist_find_associated_core(const char *path, char *s, size_t len)
{
    unsigned j;
    bool                     ret = false;
    settings_t *settings         = config_get_ptr();
    struct string_list *existing_core_names =
        string_split(settings->playlist_names, ";");
    struct string_list *existing_core_paths =
        string_split(settings->playlist_cores, ";");

    for (j = 0; j < existing_core_names->size; j++)
    {
        if (string_is_equal(path, existing_core_names->elems[j].data))
        {
            if (existing_core_paths)
            {
                const char *existing_core = existing_core_paths->elems[j].data;

                if (existing_core)
                {
                    strlcpy(s, existing_core, len);
                    ret = true;
                }
            }
            break;
        }
    }

    string_list_free(existing_core_names);
    string_list_free(existing_core_paths);
    return ret;
}
Esempio n. 16
0
static void gfx_ctx_wgl_input_driver(void *data,
      const char *joypad_name,
      const input_driver_t **input, void **input_data)
{
   settings_t *settings = config_get_ptr();

#if _WIN32_WINNT >= 0x0501
   /* winraw only available since XP */
   if (string_is_equal(settings->arrays.input_driver, "raw"))
   {
      *input_data = input_winraw.init(joypad_name);
      if (*input_data)
      {
         *input     = &input_winraw;
         dinput_wgl = NULL;
         return;
      }
   }
#endif

#ifdef HAVE_DINPUT
   dinput_wgl  = input_dinput.init(joypad_name);
   *input      = dinput_wgl ? &input_dinput : NULL;
   *input_data = dinput_wgl;
#endif
}
Esempio n. 17
0
/* Find the index of a compatible DRM device. */
static int exynos_get_device_index(void)
{
   drmVersionPtr ver;
   char buf[32]       = {0};
   int index          = 0;
   bool found         = false;

   while (!found)
   {
      int fd;

      snprintf(buf, sizeof(buf), "/dev/dri/card%d", index);

      fd = open(buf, O_RDWR);
      if (fd < 0) break;

      ver = drmGetVersion(fd);

      if (string_is_equal(ver->name, "exynos"))
         found = true;
      else
         ++index;

      drmFreeVersion(ver);
      close(fd);
   }

   if (!found)
      return -1;
   return index;
}
Esempio n. 18
0
void input_config_get_bind_string(char *buf, const struct retro_keybind *bind,
      const struct retro_keybind *auto_bind, size_t size)
{
   char key[64]    = {0};
   char keybuf[64] = {0};

   (void)key;
   (void)keybuf;

   *buf = '\0';
   if (bind->joykey != NO_BTN)
      input_config_get_bind_string_joykey(buf, "", bind, size);
   else if (bind->joyaxis != AXIS_NONE)
      input_config_get_bind_string_joyaxis(buf, "", bind, size);
   else if (auto_bind && auto_bind->joykey != NO_BTN)
      input_config_get_bind_string_joykey(buf, "Auto: ", auto_bind, size);
   else if (auto_bind && auto_bind->joyaxis != AXIS_NONE)
      input_config_get_bind_string_joyaxis(buf, "Auto: ", auto_bind, size);

#ifndef RARCH_CONSOLE
   input_keymaps_translate_rk_to_str(bind->key, key, sizeof(key));
   if (string_is_equal(key, "nul"))
      *key = '\0';

   snprintf(keybuf, sizeof(keybuf), "(Key: %s)", key);
   strlcat(buf, keybuf, size);
#endif
}
Esempio n. 19
0
void input_config_parse_joy_button(config_file_t *conf, const char *prefix,
      const char *btn, struct retro_keybind *bind)
{
   char str[256]      = {0};
   char tmp[64]       = {0};
   char key[64]       = {0};
   char key_label[64] = {0};
   char *tmp_a        = NULL;

   fill_pathname_join_delim(str, prefix, btn, '_', sizeof(str));
   fill_pathname_join_delim(key, str, "btn", '_', sizeof(key));
   fill_pathname_join_delim(key_label, str, "btn_label", '_', sizeof(key_label));

   if (config_get_array(conf, key, tmp, sizeof(tmp)))
   {
      btn = tmp;
      if (string_is_equal(btn, "nul"))
         bind->joykey = NO_BTN;
      else
      {
         if (*btn == 'h')
            parse_hat(bind, btn + 1);
         else
            bind->joykey = strtoull(tmp, NULL, 0);
      }
   }

   if (config_get_string(conf, key_label, &tmp_a))
   {
      strlcpy(bind->joykey_label, tmp_a, sizeof(bind->joykey_label));
      free(tmp_a);
   }
}
Esempio n. 20
0
void content_playlist_get_index_by_path(content_playlist_t *playlist,
      const char *search_path,
      char **path, char **label,
      char **core_path, char **core_name,
      char **crc32,
      char **db_name)
{
   size_t i;
   if (!playlist)
      return;

   for (i = 0; i < playlist->size; i++)
   {
      if (!string_is_equal(playlist->entries[i].path, search_path))
         continue;

      if (path)
         *path      = playlist->entries[i].path;
      if (label)
         *label     = playlist->entries[i].label;
      if (core_path)
         *core_path = playlist->entries[i].core_path;
      if (core_name)
         *core_name = playlist->entries[i].core_name;
      if (db_name)
         *db_name   = playlist->entries[i].db_name;
      if (crc32)
         *crc32     = playlist->entries[i].crc32;
      break;
   }

}
Esempio n. 21
0
static int action_scan_input_desc(const char *path,
      const char *label, unsigned type, size_t idx)
{
   const char *menu_label         = NULL;
   unsigned key                   = 0;
   unsigned inp_desc_user         = 0;
   struct retro_keybind *target   = NULL;

   menu_entries_get_last_stack(NULL, &menu_label, NULL, NULL, NULL);

   if (string_is_equal(menu_label, "deferred_user_binds_list"))
   {
      unsigned char player_no_str = atoi(&label[1]);

      inp_desc_user      = (unsigned)(player_no_str - 1);
      /* This hardcoded value may cause issues if any entries are added on
         top of the input binds */
      key                = (unsigned)(idx - 7);
   }
   else
      key = input_config_translate_str_to_bind_id(label);

   target = &input_config_binds[inp_desc_user][key];

   if (target)
   {
      target->key     = RETROK_UNKNOWN;
      target->joykey  = NO_BTN;
      target->joyaxis = AXIS_NONE;
      target->mbutton = NO_BTN;
   }

   return 0;
}
Esempio n. 22
0
/**
 * wrap_str_to_mode:
 * @type              : Wrap type in human-readable string format.
 *
 * Translates wrap mode from human-readable string to enum mode value.
 *
 * Returns: enum mode value of wrap type.
 **/
static enum gfx_wrap_type wrap_str_to_mode(const char *wrap_mode)
{
   if (string_is_equal(wrap_mode,      "clamp_to_border"))
      return RARCH_WRAP_BORDER;
   else if (string_is_equal(wrap_mode, "clamp_to_edge"))
      return RARCH_WRAP_EDGE;
   else if (string_is_equal(wrap_mode, "repeat"))
      return RARCH_WRAP_REPEAT;
   else if (string_is_equal(wrap_mode, "mirrored_repeat"))
      return RARCH_WRAP_MIRRORED_REPEAT;

   RARCH_WARN("Invalid wrapping type %s. Valid ones are: clamp_to_border"
         " (default), clamp_to_edge, repeat and mirrored_repeat. Falling back to default.\n",
         wrap_mode);
   return RARCH_WRAP_DEFAULT;
}
Esempio n. 23
0
/* Adds an index for devices with the same name,
 * so they can be identified in the GUI. */
void input_autoconfigure_joypad_reindex_devices(void)
{
   unsigned i, j, k;

   for(i = 0; i < MAX_INPUT_DEVICES; i++)
      input_device_name_index[i] = 0;

   for(i = 0; i < MAX_INPUT_DEVICES; i++)
   {
      const char *tmp = input_config_get_device_name(i);
      if ( !tmp || input_device_name_index[i] )
         continue;

      k = 2; /*Additional devices start at two*/

      for(j = i+1; j < MAX_INPUT_DEVICES; j++)
      {
         const char *other = input_config_get_device_name(j);

         if (!other)
            continue;

         /*another device with the same name found, for the first time*/
         if (string_is_equal(tmp, other) &&
               input_device_name_index[j]==0 )
         {
            /*Mark the first device of the set*/
            input_device_name_index[i] = 1;

            /*count this additional device, from two up*/
            input_device_name_index[j] = k++;
         }
      }
   }
}
static INLINE CGparameter d3d9_cg_find_param_from_semantic(
      CGparameter param, const char *sem)
{
   for (; param; param = cgGetNextParameter(param))
   {
      const char *semantic = NULL;
      if (cgGetParameterType(param) == CG_STRUCT)
      {
         CGparameter ret = d3d9_cg_find_param_from_semantic(
               cgGetFirstStructParameter(param), sem);

         if (ret)
            return ret;
      }

      if (     cgGetParameterDirection(param)   != CG_IN
            || cgGetParameterVariability(param) != CG_VARYING)
         continue;

      semantic = cgGetParameterSemantic(param);
      if (!semantic)
         continue;

      if (string_is_equal(sem, semantic) &&
            d3d9_cg_validate_param_name(cgGetParameterName(param)))
         return param;
   }

   return NULL;
}
Esempio n. 25
0
void core_info_get_name(const char *path, char *s, size_t len)
{
   size_t i;
   settings_t             *settings = config_get_ptr();
   struct string_list *contents     = dir_list_new_special(
         settings->paths.directory_libretro,
         DIR_LIST_CORES, NULL);
   const char       *path_basedir   = !string_is_empty(settings->paths.path_libretro_info) ?
      settings->paths.path_libretro_info : settings->paths.directory_libretro;

   if (!contents)
      return;

   for (i = 0; i < contents->size; i++)
   {
      size_t path_size                = PATH_MAX_LENGTH * sizeof(char);
      char *info_path                 = NULL;
      config_file_t *conf             = NULL;
      char *new_core_name             = NULL;
      const char *current_path        = contents->elems[i].data;

      if (!string_is_equal(current_path, path))
         continue;

      info_path                       = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
      info_path[0]                    = '\0';

      if (!core_info_list_iterate(info_path,
               path_size, path_basedir, contents, i)
            && path_is_valid(info_path))
      {
         free(info_path);
         continue;
      }

      conf = config_file_new(info_path);

      if (!conf)
      {
         free(info_path);
         continue;
      }

      if (config_get_string(conf, "corename",
            &new_core_name))
      {
         strlcpy(s, new_core_name, len);
         free(new_core_name);
      }

      config_file_free(conf);
      free(info_path);
      break;
   }

   if (contents)
      dir_list_free(contents);
   contents = NULL;
}
Esempio n. 26
0
static int task_database_iterate_serial_lookup(
    database_state_handle_t *db_state,
    database_info_handle_t *db, const char *name)
{
    if (!db_state->list ||
            (unsigned)db_state->list_index == (unsigned)db_state->list->size)
        return database_info_list_iterate_end_no_match(db_state);

    if (db_state->entry_index == 0)
    {
        char query[50];
        char *serial_buf =
            bin_to_hex_alloc((uint8_t*)db_state->serial, 10 * sizeof(uint8_t));

        if (!serial_buf)
            return 1;

        query[0] = '\0';

        snprintf(query, sizeof(query), "{'serial': b'%s'}", serial_buf);
        database_info_list_iterate_new(db_state, query);

        free(serial_buf);
    }

    if (db_state->info)
    {
        database_info_t *db_info_entry = &db_state->info->list[
                                             db_state->entry_index];

        if (db_info_entry && db_info_entry->serial)
        {
#if 0
            RARCH_LOG("serial: %s , entry serial: %s (%s).\n",
                      db_state->serial, db_info_entry->serial,
                      db_info_entry->name);
#endif
            if (string_is_equal(db_state->serial, db_info_entry->serial))
                return database_info_list_iterate_found_match(db_state, db, NULL);
        }
    }

    db_state->entry_index++;

    if (db_state->info)
    {
        if (db_state->entry_index >= db_state->info->count)
            return database_info_list_iterate_next(db_state);
    }

    /* If we haven't reached the end of the database list yet,
     * continue iterating. */
    if (db_state->list_index < db_state->list->size)
        return 1;

    database_info_list_free(db_state->info);
    free(db_state->info);
    return 0;
}
Esempio n. 27
0
static int playlist_association_right(unsigned type, const char *label,
      bool wraparound)
{
   char core_path[PATH_MAX_LENGTH];
   char new_playlist_cores[PATH_MAX_LENGTH];
   size_t i, next, found, current   = 0;
   core_info_t *info                = NULL;
   struct string_list *stnames      = NULL;
   struct string_list *stcores      = NULL;
   core_info_list_t           *list = NULL;
   settings_t *settings             = config_get_ptr();
   const char *path                 = path_basename(label);

   core_info_get_list(&list);
   if (!list)
      return menu_cbs_exit();

   core_path[0] = new_playlist_cores[0] = '\0';

   stnames = string_split(settings->arrays.playlist_names, ";");
   stcores = string_split(settings->arrays.playlist_cores, ";");

   if (!menu_content_playlist_find_associated_core(path, core_path, sizeof(core_path)))
         strlcpy(core_path,
               file_path_str(FILE_PATH_DETECT), sizeof(core_path));

   for (i = 0; i < list->count; i++)
   {
      core_info_t *info = core_info_get(list, i);
      if (string_is_equal(info->path, core_path))
         current = i;
   }

   next = current + 1;
   if (next >= list->count)
   {
      if (wraparound)
         next = 0;
      else
         next = list->count-1;
   }

   info = core_info_get(list, next);

   found = string_list_find_elem(stnames, path);
   if (found && info)
      string_list_set(stcores, (unsigned)(found-1), info->path);

   string_list_join_concat(new_playlist_cores,
         sizeof(new_playlist_cores), stcores, ";");

   strlcpy(settings->arrays.playlist_cores,
         new_playlist_cores, sizeof(settings->arrays.playlist_cores));

   string_list_free(stnames);
   string_list_free(stcores);
   return 0;
}
Esempio n. 28
0
static uint32_t gfx_ctx_wgl_get_flags(void *data)
{
   uint32_t          flags = 0;

   BIT32_SET(flags, GFX_CTX_FLAGS_NONE);

   switch (win32_api)
   {
      case GFX_CTX_OPENGL_API:
         if (wgl_adaptive_vsync)
         {
            BIT32_SET(flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC);
         }

         if (win32_core_hw_context_enable)
         {
            BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
         }

         if (string_is_equal(video_driver_get_ident(), "gl1")) { }
         else if (string_is_equal(video_driver_get_ident(), "glcore")) { }
         else
         {
#ifdef HAVE_CG
            if (!win32_core_hw_context_enable)
               BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_CG);
#endif
#ifdef HAVE_GLSL
            BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_GLSL);
#endif
         }

         break;
      case GFX_CTX_VULKAN_API:
#ifdef HAVE_SLANG
         BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_SLANG);
#endif
         break;
      case GFX_CTX_NONE:
      default:
         break;
   }

   return flags;
}
Esempio n. 29
0
static bool d3d_process_shader(d3d_video_t *d3d)
{
#ifdef HAVE_FBO
   if (string_is_equal(path_get_extension(d3d->shader_path.c_str()), "cgp"))
      return d3d_init_multipass(d3d);
#endif

   return d3d_init_singlepass(d3d);
}
Esempio n. 30
0
int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
   const char* name, uint16_t vid, uint16_t pid,
   void *data, send_control_t ptr)
{
   static const struct
   {
      const char* name;
      uint16_t vid;
      uint16_t pid;
      pad_connection_interface_t *iface;
   } pad_map[] =
   {
      { "Nintendo RVL-CNT-01",         1406,  816,    &pad_connection_wii },
      { "Nintendo RVL-CNT-01-UC",      1406,  816,    &pad_connection_wiiupro },
      { "Wireless Controller",         1356,  1476,   &pad_connection_ps4 },
      { "PLAYSTATION(R)3 Controller",  1356,  616,    &pad_connection_ps3 },
      { "PLAYSTATION(R)3 Controller",  787,   8406,   &pad_connection_ps3 },
      { "Generic SNES USB Controller", 2079,  58369,  &pad_connection_snesusb },
      { "Generic NES USB Controller",  121,   17,     &pad_connection_nesusb },
      { "Wii U GC Controller Adapter", 1406,  823,    &pad_connection_wiiugca },
      { 0, 0}
   };
   joypad_connection_t *s = NULL;
   int                pad = pad_connection_find_vacant_pad(joyconn);

   if (pad == -1)
      return -1;

   s = &joyconn[pad];

   if (s)
   {
      unsigned i;

      for (i = 0; name && pad_map[i].name; i++)
      {
         const char *name_match = strstr(pad_map[i].name, name);

         /* Never change, Nintendo. */
         if(pad_map[i].vid == 1406 && pad_map[i].pid == 816)  
         {
            if(!string_is_equal(pad_map[i].name, name))
               continue;
         }

         if (name_match || (pad_map[i].vid == vid && pad_map[i].pid == pid))
         {
            s->iface      = pad_map[i].iface;
            s->data       = s->iface->init(data, pad, ptr);
            s->connected  = true;
            break;
         }
      }
   }

   return pad;
}