Ejemplo n.º 1
0
/**
 * find_driver_nonempty:
 * @label              : string of driver type to be found.
 * @i                  : index of driver.
 * @str                : identifier name of the found driver
 *                       gets written to this string.
 * @len                : size of @str.
 *
 * Find driver based on @label.
 *
 * Returns: NULL if no driver based on @label found, otherwise
 * pointer to driver.
 **/
static const void *find_driver_nonempty(const char *label, int i,
      char *s, size_t len)
{
   const void *drv = NULL;
   uint32_t hash   = msg_hash_calculate(label);

   switch (hash)
   {
      case HASH_CAMERA_DRIVER:
         drv = camera_driver_find_handle(i);
         if (drv)
            strlcpy(s, camera_driver_find_ident(i), len);
         break;
      case HASH_LOCATION_DRIVER:
         drv = location_driver_find_handle(i);
         if (drv)
            strlcpy(s, location_driver_find_ident(i), len);
         break;
      case HASH_MENU_DRIVER:
#ifdef HAVE_MENU
         drv = menu_driver_find_handle(i);
         if (drv)
            strlcpy(s, menu_driver_find_ident(i), len);
#endif
         break;
      case HASH_INPUT_DRIVER:
         drv = input_driver_find_handle(i);
         if (drv)
            strlcpy(s, input_driver_find_ident(i), len);
         break;
      case HASH_INPUT_JOYPAD_DRIVER:
         drv = joypad_driver_find_handle(i);
         if (drv)
            strlcpy(s, joypad_driver_find_ident(i), len);
         break;
      case HASH_VIDEO_DRIVER:
         drv = video_driver_find_handle(i);
         if (drv)
            strlcpy(s, video_driver_find_ident(i), len);
         break;
      case HASH_AUDIO_DRIVER:
         drv = audio_driver_find_handle(i);
         if (drv)
            strlcpy(s, audio_driver_find_ident(i), len);
         break;
      case HASH_RECORD_DRIVER:
         drv = record_driver_find_handle(i);
         if (drv)
            strlcpy(s, record_driver_find_ident(i), len);
         break;
      case HASH_AUDIO_RESAMPLER_DRIVER:
         drv = audio_resampler_driver_find_handle(i);
         if (drv)
            strlcpy(s, audio_resampler_driver_find_ident(i), len);
         break;
   }

   return drv;
}
Ejemplo n.º 2
0
bool input_driver_find_driver(void)
{
   int i;
   driver_ctx_info_t drv;
   settings_t *settings = config_get_ptr();

   drv.label = "input_driver";
   drv.s     = settings->input.driver;

   driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv);

   i = drv.len;

   if (i >= 0)
      current_input = (const input_driver_t*)
         input_driver_find_handle(i);
   else
   {
      unsigned d;
      RARCH_ERR("Couldn't find any input driver named \"%s\"\n",
            settings->input.driver);
      RARCH_LOG_OUTPUT("Available input drivers are:\n");
      for (d = 0; input_driver_find_handle(d); d++)
         RARCH_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d));
      RARCH_WARN("Going to default to first input driver...\n");

      current_input = (const input_driver_t*)
         input_driver_find_handle(0);

      if (current_input)
         return true;
      retroarch_fail(1, "find_input_driver()");
      return false;
   }

   return true;
}
Ejemplo n.º 3
0
void find_input_driver(void)
{
   driver_t *driver = driver_get_ptr();
   settings_t *settings = config_get_ptr();
   int i = find_driver_index("input_driver", settings->input.driver);

   if (i >= 0)
      driver->input = (const input_driver_t*)input_driver_find_handle(i);
   else
   {
      unsigned d;
      RARCH_ERR("Couldn't find any input driver named \"%s\"\n",
            settings->input.driver);
      RARCH_LOG_OUTPUT("Available input drivers are:\n");
      for (d = 0; input_driver_find_handle(d); d++)
         RARCH_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d));
      RARCH_WARN("Going to default to first input driver...\n");

      driver->input = (const input_driver_t*)input_driver_find_handle(0);

      if (!driver->input)
         rarch_fail(1, "find_input_driver()");
   }
}
Ejemplo n.º 4
0
/**
 * config_get_input_driver_options:
 *
 * Get an enumerated list of all input driver names, separated by '|'.
 *
 * Returns: string listing of all input driver names, separated by '|'.
 **/
const char* config_get_input_driver_options(void)
{
   union string_list_elem_attr attr;
   unsigned i;
   char *options = NULL;
   int options_len = 0;
   struct string_list *options_l = string_list_new();

   attr.i = 0;

   if (!options_l)
      return NULL;

   for (i = 0; input_driver_find_handle(i); i++)
   {
      const char *opt = input_driver_find_ident(i);
      options_len += strlen(opt) + 1;
      string_list_append(options_l, opt, attr);
   }

   options = (char*)calloc(options_len, sizeof(char));

   if (!options)
   {
      string_list_free(options_l);
      options_l = NULL;
      return NULL;
   }

   string_list_join_concat(options, options_len, options_l, "|");

   string_list_free(options_l);
   options_l = NULL;

   return options;
}
Ejemplo n.º 5
0
bool input_driver_ctl(enum rarch_input_ctl_state state, void *data)
{
   static bool input_driver_block_hotkey             = false;
   static bool input_driver_block_libretro_input     = false;
   static bool input_driver_osk_enabled              = false;
   static bool input_driver_keyboard_linefeed_enable = false;
   static bool input_driver_nonblock_state           = false;
   static bool input_driver_flushing_input           = false;
   static bool input_driver_data_own                 = false;

   switch (state)
   {
      case RARCH_INPUT_CTL_KEY_PRESSED:
         {
            unsigned *key = (unsigned*)data;
            if (key && current_input->key_pressed)
               return current_input->key_pressed(current_input_data, *key);
         }
         return false;
      case RARCH_INPUT_CTL_HAS_CAPABILITIES:
         if (!current_input->get_capabilities || !current_input_data)
            return false;
         break;
      case RARCH_INPUT_CTL_POLL:
         current_input->poll(current_input_data);
         break;
      case RARCH_INPUT_CTL_INIT:
         if (current_input)
            current_input_data = current_input->init();

         if (!current_input_data)
            return false;
         break;
      case RARCH_INPUT_CTL_DEINIT:
         if (current_input && current_input->free)
            current_input->free(current_input_data);
         current_input_data = NULL;
         break;
      case RARCH_INPUT_CTL_DESTROY_DATA:
         current_input_data = NULL;
         break;
      case RARCH_INPUT_CTL_DESTROY:
         input_driver_block_hotkey             = false;
         input_driver_block_libretro_input     = false;
         input_driver_keyboard_linefeed_enable = false;
         input_driver_nonblock_state           = false;
         input_driver_flushing_input           = false;
         input_driver_data_own                 = false;
         memset(&input_driver_turbo_btns, 0, sizeof(turbo_buttons_t));
         current_input                         = NULL;
         break;
      case RARCH_INPUT_CTL_GRAB_STDIN:
         if (!current_input->grab_stdin)
            return false;
         return current_input->grab_stdin(current_input_data);
      case RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED:
         if (!current_input->keyboard_mapping_is_blocked)
            return false;
         return current_input->keyboard_mapping_is_blocked(
               current_input_data);
      case RARCH_INPUT_CTL_FIND_DRIVER:
         {
            int i;
            driver_ctx_info_t drv;
            settings_t *settings = config_get_ptr();

            drv.label = "input_driver";
            drv.s     = settings->input.driver;

            driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv);

            i = drv.len;

            if (i >= 0)
               current_input = (const input_driver_t*)
                  input_driver_find_handle(i);
            else
            {
               unsigned d;
               RARCH_ERR("Couldn't find any input driver named \"%s\"\n",
                     settings->input.driver);
               RARCH_LOG_OUTPUT("Available input drivers are:\n");
               for (d = 0; input_driver_find_handle(d); d++)
                  RARCH_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d));
               RARCH_WARN("Going to default to first input driver...\n");

               current_input = (const input_driver_t*)
                  input_driver_find_handle(0);

               if (current_input)
                  return true;
               retro_fail(1, "find_input_driver()");
               return false;
            }
         }
         break;
      case RARCH_INPUT_CTL_SET_FLUSHING_INPUT:
         input_driver_flushing_input = true;
         break;
      case RARCH_INPUT_CTL_UNSET_FLUSHING_INPUT:
         input_driver_flushing_input = false;
         break;
      case RARCH_INPUT_CTL_IS_FLUSHING_INPUT:
         return input_driver_flushing_input;
      case RARCH_INPUT_CTL_SET_HOTKEY_BLOCK:
         input_driver_block_hotkey = true;
         break;
      case RARCH_INPUT_CTL_UNSET_HOTKEY_BLOCK:
         input_driver_block_hotkey = false;
         break;
      case RARCH_INPUT_CTL_IS_HOTKEY_BLOCKED:
         return input_driver_block_hotkey;
      case RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED:
         input_driver_block_libretro_input = true;
         break;
      case RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED:
         input_driver_block_libretro_input = false;
         break;
      case RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED:
         return input_driver_block_libretro_input;
      case RARCH_INPUT_CTL_SET_NONBLOCK_STATE:
         input_driver_nonblock_state = true;
         break;
      case RARCH_INPUT_CTL_UNSET_NONBLOCK_STATE:
         input_driver_nonblock_state = false;
         break;
      case RARCH_INPUT_CTL_IS_NONBLOCK_STATE:
         return input_driver_nonblock_state;
      case RARCH_INPUT_CTL_SET_OWN_DRIVER:
         input_driver_data_own = true;
         break;
      case RARCH_INPUT_CTL_UNSET_OWN_DRIVER:
         input_driver_data_own = false;
         break;
      case RARCH_INPUT_CTL_OWNS_DRIVER:
         return input_driver_data_own;
      case RARCH_INPUT_CTL_SET_OSK_ENABLED:
         input_driver_osk_enabled = true;
         break;
      case RARCH_INPUT_CTL_UNSET_OSK_ENABLED:
         input_driver_osk_enabled = false;
         break;
      case RARCH_INPUT_CTL_IS_OSK_ENABLED:
         return input_driver_osk_enabled;
      case RARCH_INPUT_CTL_SET_KEYBOARD_LINEFEED_ENABLED:
         input_driver_keyboard_linefeed_enable = true;
         break;
      case RARCH_INPUT_CTL_UNSET_KEYBOARD_LINEFEED_ENABLED:
         input_driver_keyboard_linefeed_enable = false;
         break;
      case RARCH_INPUT_CTL_IS_KEYBOARD_LINEFEED_ENABLED:
         return input_driver_keyboard_linefeed_enable;
      case RARCH_INPUT_CTL_COMMAND_INIT:
#ifdef HAVE_COMMAND
         input_driver_command_init();
#endif
         break;
      case RARCH_INPUT_CTL_COMMAND_DEINIT:
#ifdef HAVE_COMMAND
         if (input_driver_command)
            rarch_cmd_free(input_driver_command);
         input_driver_command = NULL;
#endif
         break;
      case RARCH_INPUT_CTL_REMOTE_DEINIT:
#ifdef HAVE_NETWORK_GAMEPAD
         if (input_driver_remote)
            rarch_remote_free(input_driver_remote);
         input_driver_remote = NULL;
#endif
         break;
      case RARCH_INPUT_CTL_REMOTE_INIT:
#ifdef HAVE_NETWORK_GAMEPAD
         input_driver_remote_init();
#endif
         break;
      case RARCH_INPUT_CTL_NONE:
      default:
         break;
   }

   return true;
}
Ejemplo n.º 6
0
struct string_list *string_list_new_special(enum string_list_type type,
      void *data, unsigned *len, size_t *list_size)
{
   union string_list_elem_attr attr;
   unsigned i;
   core_info_list_t *core_info_list = NULL;
   const core_info_t *core_info     = NULL;
   struct string_list *s            = string_list_new();

   if (!s || !len)
      goto error;

   attr.i = 0;
   *len   = 0;

   switch (type)
   {
      case STRING_LIST_MENU_DRIVERS:
#ifdef HAVE_MENU
         for (i = 0; menu_driver_find_handle(i); i++)
         {
            const char *opt  = menu_driver_find_ident(i);
            *len            += strlen(opt) + 1;

            string_list_append(s, opt, attr);
         }
         break;
#endif
      case STRING_LIST_CAMERA_DRIVERS:
#ifdef HAVE_CAMERA
         for (i = 0; camera_driver_find_handle(i); i++)
         {
            const char *opt  = camera_driver_find_ident(i);
            *len            += strlen(opt) + 1;

            string_list_append(s, opt, attr);
         }
         break;
#endif
      case STRING_LIST_LOCATION_DRIVERS:
#ifdef HAVE_LOCATION
         for (i = 0; location_driver_find_handle(i); i++)
         {
            const char *opt  = location_driver_find_ident(i);
            *len            += strlen(opt) + 1;
            string_list_append(options_l, opt, attr);
         }
         break;
#endif
      case STRING_LIST_AUDIO_DRIVERS:
         for (i = 0; audio_driver_find_handle(i); i++)
         {
            const char *opt  = audio_driver_find_ident(i);
            *len            += strlen(opt) + 1;

            string_list_append(s, opt, attr);
         }
         break;
      case STRING_LIST_AUDIO_RESAMPLER_DRIVERS:
         for (i = 0; audio_resampler_driver_find_handle(i); i++)
         {
            const char *opt  = audio_resampler_driver_find_ident(i);
            *len            += strlen(opt) + 1;

            string_list_append(s, opt, attr);
         }
         break;
      case STRING_LIST_VIDEO_DRIVERS:
         for (i = 0; video_driver_find_handle(i); i++)
         {
            const char *opt  = video_driver_find_ident(i);
            *len            += strlen(opt) + 1;

            string_list_append(s, opt, attr);
         }
         break;
      case STRING_LIST_INPUT_DRIVERS:
         for (i = 0; input_driver_find_handle(i); i++)
         {
            const char *opt  = input_driver_find_ident(i);
            *len            += strlen(opt) + 1;

            string_list_append(s, opt, attr);
         }
         break;
      case STRING_LIST_INPUT_HID_DRIVERS:
         for (i = 0; hid_driver_find_handle(i); i++)
         {
            const char *opt  = hid_driver_find_ident(i);
            *len            += strlen(opt) + 1;

            string_list_append(s, opt, attr);
         }
         break;
      case STRING_LIST_INPUT_JOYPAD_DRIVERS:
         for (i = 0; joypad_driver_find_handle(i); i++)
         {
            const char *opt  = joypad_driver_find_ident(i);
            *len            += strlen(opt) + 1;

            string_list_append(s, opt, attr);
         }
         break;
      case STRING_LIST_RECORD_DRIVERS:
         for (i = 0; record_driver_find_handle(i); i++)
         {
            const char *opt  = record_driver_find_ident(i);
            *len            += strlen(opt) + 1;

            string_list_append(s, opt, attr);
         }
         break;
      case STRING_LIST_SUPPORTED_CORES_PATHS:
         core_info_get_list(&core_info_list);

         core_info_list_get_supported_cores(core_info_list,
               (const char*)data, &core_info, list_size);

         if (!core_info)
            goto error;

         if (*list_size == 0)
            goto error;

         for (i = 0; i < *list_size; i++)
         {
            const core_info_t *info = (const core_info_t*)&core_info[i];
            const char *opt = info->path;

            if (!opt)
               goto error;

            *len += strlen(opt) + 1;
            string_list_append(s, opt, attr);
         }
         break;
      case STRING_LIST_SUPPORTED_CORES_NAMES:
         core_info_get_list(&core_info_list);
         core_info_list_get_supported_cores(core_info_list,
               (const char*)data, &core_info, list_size);

         if (!core_info)
            goto error;

         if (*list_size == 0)
            goto error;

         for (i = 0; i < *list_size; i++)
         {
            const char          *opt = NULL;
            core_info_t *info        = (core_info_t*)&core_info[i];
            
            if (!info)
               goto error;
            
            opt = info->display_name;

            if (!opt)
               goto error;

            *len            += strlen(opt) + 1;
            string_list_append(s, opt, attr);
         }
         break;
      case STRING_LIST_NONE:
      default:
         goto error;
   }

   return s;

error:
   string_list_free(s);
   s    = NULL;
   return NULL;
}
Ejemplo n.º 7
0
/**
 * find_driver_nonempty:
 * @label              : string of driver type to be found.
 * @i                  : index of driver.
 * @str                : identifier name of the found driver
 *                       gets written to this string.
 * @sizeof_str         : size of @str.
 *
 * Find driver based on @label.
 *
 * Returns: NULL if no driver based on @label found, otherwise
 * pointer to driver.
 **/
static const void *find_driver_nonempty(const char *label, int i,
      char *str, size_t sizeof_str)
{
   const void *drv = NULL;

   if (!strcmp(label, "camera_driver"))
   {
      drv = camera_driver_find_handle(i);
      if (drv)
         strlcpy(str, camera_driver_find_ident(i), sizeof_str);
   }
   else if (!strcmp(label, "location_driver"))
   {
      drv = location_driver_find_handle(i);
      if (drv)
         strlcpy(str, location_driver_find_ident(i), sizeof_str);
   }
#ifdef HAVE_MENU
   else if (!strcmp(label, "menu_driver"))
   {
      drv = menu_driver_find_handle(i);
      if (drv)
         strlcpy(str, menu_driver_find_ident(i), sizeof_str);
   }
#endif
   else if (!strcmp(label, "input_driver"))
   {
      drv = input_driver_find_handle(i);
      if (drv)
         strlcpy(str, input_driver_find_ident(i), sizeof_str);
   }
   else if (!strcmp(label, "input_joypad_driver"))
   {
      drv = joypad_driver_find_handle(i);
      if (drv)
         strlcpy(str, joypad_driver_find_ident(i), sizeof_str);
   }
   else if (!strcmp(label, "video_driver"))
   {
      drv = video_driver_find_handle(i);
      if (drv)
         strlcpy(str, video_driver_find_ident(i), sizeof_str);
   }
   else if (!strcmp(label, "audio_driver"))
   {
      drv = audio_driver_find_handle(i);
      if (drv)
         strlcpy(str, audio_driver_find_ident(i), sizeof_str);
   }
   else if (!strcmp(label, "record_driver"))
   {
      drv = record_driver_find_handle(i);
      if (drv)
         strlcpy(str, record_driver_find_ident(i), sizeof_str);
   }
   else if (!strcmp(label, "audio_resampler_driver"))
   {
      drv = audio_resampler_driver_find_handle(i);
      if (drv)
         strlcpy(str, audio_resampler_driver_find_ident(i), sizeof_str);
   }

   return drv;
}
Ejemplo n.º 8
0
/**
 * find_driver_nonempty:
 * @label              : string of driver type to be found.
 * @i                  : index of driver.
 * @str                : identifier name of the found driver
 *                       gets written to this string.
 * @len                : size of @str.
 *
 * Find driver based on @label.
 *
 * Returns: NULL if no driver based on @label found, otherwise
 * pointer to driver.
 **/
static const void *find_driver_nonempty(const char *label, int i,
      char *s, size_t len)
{
   const void *drv = NULL;

   if (string_is_equal(label, "camera_driver"))
   {
      drv = camera_driver_find_handle(i);
      if (drv)
         strlcpy(s, camera_driver_find_ident(i), len);
   }
   else if (string_is_equal(label, "location_driver"))
   {
      drv = location_driver_find_handle(i);
      if (drv)
         strlcpy(s, location_driver_find_ident(i), len);
   }
#ifdef HAVE_MENU
   else if (string_is_equal(label, "menu_driver"))
   {
      drv = menu_driver_find_handle(i);
      if (drv)
         strlcpy(s, menu_driver_find_ident(i), len);
   }
#endif
   else if (string_is_equal(label, "input_driver"))
   {
      drv = input_driver_find_handle(i);
      if (drv)
         strlcpy(s, input_driver_find_ident(i), len);
   }
   else if (string_is_equal(label, "input_joypad_driver"))
   {
      drv = joypad_driver_find_handle(i);
      if (drv)
         strlcpy(s, joypad_driver_find_ident(i), len);
   }
   else if (string_is_equal(label, "video_driver"))
   {
      drv = video_driver_find_handle(i);
      if (drv)
         strlcpy(s, video_driver_find_ident(i), len);
   }
   else if (string_is_equal(label, "audio_driver"))
   {
      drv = audio_driver_find_handle(i);
      if (drv)
         strlcpy(s, audio_driver_find_ident(i), len);
   }
   else if (string_is_equal(label, "record_driver"))
   {
      drv = record_driver_find_handle(i);
      if (drv)
         strlcpy(s, record_driver_find_ident(i), len);
   }
   else if (string_is_equal(label, "midi_driver"))
   {
      drv = midi_driver_find_handle(i);
      if (drv)
         strlcpy(s, midi_driver_find_ident(i), len);
   }
   else if (string_is_equal(label, "audio_resampler_driver"))
   {
      drv = audio_resampler_driver_find_handle(i);
      if (drv)
         strlcpy(s, audio_resampler_driver_find_ident(i), len);
   }
   else if (string_is_equal(label, "wifi_driver"))
   {
      drv = wifi_driver_find_handle(i);
      if (drv)
         strlcpy(s, wifi_driver_find_ident(i), len);
   }

   return drv;
}