Exemple #1
0
static bool input_try_autoconfigure_joypad_from_conf(config_file_t *conf, unsigned index, const char *name, const char *driver, bool block_osd_spam)
{
   if (!conf)
      return false;
         
   char ident[1024];
   char input_driver[1024];
   
   *ident = *input_driver = '\0';
   
   config_get_array(conf, "input_device", ident, sizeof(ident));
   config_get_array(conf, "input_driver", input_driver, sizeof(input_driver));

   if (!strcmp(ident, name) && !strcmp(driver, input_driver))
   {
      g_settings.input.autoconfigured[index] = true;
      input_autoconfigure_joypad_conf(conf, g_settings.input.autoconf_binds[index]);

      char msg[512];
      snprintf(msg, sizeof(msg), "Joypad port #%u (%s) configured.",
            index, name);

      if (!block_osd_spam)
         msg_queue_push(g_extern.msg_queue, msg, 0, 60);
      RARCH_LOG("%s\n", msg);

      return true;
   }

   return false;
}
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;
}
Exemple #4
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
}
Exemple #5
0
static void input_autoconfigure_joypad_add(config_file_t *conf,
      autoconfig_params_t *params, retro_task_t *task)
{
   char msg[128], display_name[128], device_type[128];
   /* This will be the case if input driver is reinitialized.
    * No reason to spam autoconfigure messages every time. */
   bool block_osd_spam                =
#if defined(HAVE_LIBNX) && defined(HAVE_MENU_WIDGETS)
      true;
#else
      input_autoconfigured[params->idx]
      && !string_is_empty(params->name);
#endif

   msg[0] = display_name[0] = device_type[0] = '\0';

   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));

   input_autoconfigured[params->idx] = true;

   input_autoconfigure_joypad_conf(conf,
         input_autoconf_binds[params->idx]);

   if (string_is_equal(device_type, "remote"))
   {
      static bool remote_is_bound        = false;

      snprintf(msg, sizeof(msg), "%s configured.",
            (string_is_empty(display_name) &&
             !string_is_empty(params->name)) ? params->name : (!string_is_empty(display_name) ? display_name : "N/A"));

      if (!remote_is_bound)
      {
         task_free_title(task);
         task_set_title(task, strdup(msg));
      }
      remote_is_bound = true;
      if (params->idx == 0)
         input_autoconfigure_swap_override = true;
   }
   else
   {
      bool tmp = false;
      snprintf(msg, sizeof(msg), "%s %s #%u.",
            (string_is_empty(display_name) &&
             !string_is_empty(params->name))
            ? params->name : (!string_is_empty(display_name) ? display_name : "N/A"),
            msg_hash_to_str(MSG_DEVICE_CONFIGURED_IN_PORT),
            params->idx);

      /* allow overriding the swap menu controls for player 1*/
      if (params->idx == 0)
      {
         if (config_get_bool(conf, "input_swap_override", &tmp))
            input_autoconfigure_swap_override = tmp;
         else
            input_autoconfigure_swap_override = false;
      }

      if (!block_osd_spam)
      {
         task_free_title(task);
         task_set_title(task, strdup(msg));
      }
   }
   if (!string_is_empty(display_name))
      input_config_set_device_display_name(params->idx, display_name);
   else
      input_config_set_device_display_name(params->idx, params->name);
   if (!string_is_empty(conf->path))
   {
      input_config_set_device_config_name(params->idx, path_basename(conf->path));
      input_config_set_device_config_path(params->idx, conf->path);
   }
   else
   {
      input_config_set_device_config_name(params->idx, "N/A");
      input_config_set_device_config_path(params->idx, "N/A");
   }

   input_autoconfigure_joypad_reindex_devices();
}
Exemple #6
0
void input_config_autoconfigure_joypad(unsigned index, const char *name, const char *driver)
{
   if (!g_settings.input.autodetect_enable)
      return;

   // This will be the case if input driver is reinit. No reason to spam autoconfigure messages
   // every time (fine in log).
   bool block_osd_spam = g_settings.input.autoconfigured[index] && name;

   for (unsigned i = 0; i < RARCH_BIND_LIST_END; i++)
   {
      g_settings.input.autoconf_binds[index][i].joykey = NO_BTN;
      g_settings.input.autoconf_binds[index][i].joyaxis = AXIS_NONE;
   }
   g_settings.input.autoconfigured[index] = false;

   if (!name)
      return;

   if (!*g_settings.input.autoconfig_dir)
      return;

   struct string_list *list = dir_list_new(g_settings.input.autoconfig_dir, "cfg", false);
   if (!list)
      return;

   char ident[1024];
   char input_driver[1024];
   for (size_t i = 0; i < list->size; i++)
   {
      *ident = *input_driver = '\0';

      config_file_t *conf = config_file_new(list->elems[i].data);
      if (!conf)
         continue;

      config_get_array(conf, "input_device", ident, sizeof(ident));
      config_get_array(conf, "input_driver", input_driver, sizeof(input_driver));

      if (!strcmp(ident, name) && !strcmp(driver, input_driver))
      {
         g_settings.input.autoconfigured[index] = true;
         input_autoconfigure_joypad_conf(conf, g_settings.input.autoconf_binds[index]);

         char msg[512];
         snprintf(msg, sizeof(msg), "Joypad port #%u (%s) configured.",
               index, name);

         if (!block_osd_spam)
            msg_queue_push(g_extern.msg_queue, msg, 0, 60);
         RARCH_LOG("%s\n", msg);

         config_file_free(conf);
         break;
      }
      else
         config_file_free(conf);
   }

   string_list_free(list);
}