Beispiel #1
0
int menu_input_key_bind_set_mode(void *data,
      enum menu_input_bind_mode type)
{
   unsigned index_offset;
   menu_handle_t       *menu = menu_driver_get_ptr();
   menu_input_t  *menu_input = menu_input_get_ptr();
   rarch_setting_t  *setting = (rarch_setting_t*)data;
   settings_t *settings      = config_get_ptr();

   if (!setting)
      return -1;
   if (menu_input_key_bind_set_mode_common(setting, type) == -1)
      return -1;

   index_offset = menu_setting_get_index_offset(setting);
   bind_port    = settings->input.joypad_map[index_offset];

   menu_input_key_bind_poll_bind_get_rested_axes(&menu_input->binds, bind_port);
   menu_input_key_bind_poll_bind_state(&menu_input->binds, bind_port, false);

   menu_input->binds.timeout_end   = retro_get_time_usec() +
      MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;

   input_keyboard_wait_keys(menu,
         menu_input_key_bind_custom_bind_keyboard_cb);
   return 0;
}
Beispiel #2
0
static int menu_input_set_timeout(void)
{
   menu_handle_t       *menu = menu_driver_get_ptr();

   menu->binds.timeout_end = rarch_get_time_usec() +
      MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
   input_keyboard_wait_keys(menu,
         menu_input_custom_bind_keyboard_cb);

   return 0;
}
Beispiel #3
0
int menu_input_set_keyboard_bind_mode(void *data,
      enum menu_input_bind_mode type)
{
   struct retro_keybind *keybind = NULL;
   rarch_setting_t  *setting = (rarch_setting_t*)data;
   settings_t *settings      = config_get_ptr();
   menu_handle_t       *menu = menu_driver_get_ptr();

   if (!menu || !setting)
      return -1;

   switch (type)
   {
      case MENU_INPUT_BIND_NONE:
         return -1;
      case MENU_INPUT_BIND_SINGLE:
         keybind = (struct retro_keybind*)setting->value.keybind;

         if (!keybind)
            return -1;

         menu->binds.begin  = setting->bind_type;
         menu->binds.last   = setting->bind_type;
         menu->binds.target = keybind;
         menu->binds.user = setting->index_offset;
         menu_list_push_stack( menu->menu_list,
               "",
               "custom_bind",
               MENU_SETTINGS_CUSTOM_BIND_KEYBOARD,
               menu->navigation.selection_ptr);
         break;
      case MENU_INPUT_BIND_ALL:
         menu->binds.target = &settings->input.binds
            [setting->index_offset][0];
         menu->binds.begin = MENU_SETTINGS_BIND_BEGIN;
         menu->binds.last = MENU_SETTINGS_BIND_LAST;
         menu_list_push_stack( menu->menu_list,
               "",
               "custom_bind_all",
               MENU_SETTINGS_CUSTOM_BIND_KEYBOARD,
               menu->navigation.selection_ptr);
         break;
   }


   menu->binds.timeout_end =
      rarch_get_time_usec() + 
      MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
   input_keyboard_wait_keys(menu,
         menu_input_custom_bind_keyboard_cb);

   return 0;
}
Beispiel #4
0
int menu_input_key_bind_set_mode(void *data,
      enum menu_input_bind_mode type)
{
   menu_handle_t       *menu = menu_driver_get_ptr();
   menu_input_t  *menu_input = menu_input_get_ptr();
   rarch_setting_t  *setting = (rarch_setting_t*)data;
   settings_t *settings      = config_get_ptr();
   bool joypad_pressed = BIT64_GET(menu_input->devices_mask, settings->menu_ok_btn);

   if (!setting)
      return -1;
   if (menu_input_key_bind_set_mode_common(setting, type) == -1)
      return -1;

   switch (settings->input.bind_mode)
   {
      case 0:
         break;
      case 1:
         joypad_pressed = false;
         break;
      case 2:
         joypad_pressed = true;
         break;
   }

   if (joypad_pressed)
   {
      unsigned index_offset = menu_setting_get_index_offset(setting);
      bind_port    = settings->input.joypad_map[index_offset];

      menu_input_key_bind_poll_bind_get_rested_axes(&menu_input->binds, bind_port);
      menu_input_key_bind_poll_bind_state(&menu_input->binds, bind_port, false);

      menu_input_key_bind_set_timeout();

      menu_input->bind_mode_keyboard = false;
      return 0;
   }

   menu_input->bind_mode_keyboard = true;

   menu_input_key_bind_set_timeout();
   input_keyboard_wait_keys(menu,
         menu_input_key_bind_custom_bind_keyboard_cb);
   return 0;
}
static int menu_setting_ok_toggle(unsigned type,
      const char *dir, const char *label,
      unsigned action)
{
   if (type == MENU_SETTINGS_CUSTOM_BIND_ALL)
   {
      driver.menu->binds.target = &g_settings.input.binds
         [driver.menu->current_pad][0];
      driver.menu->binds.begin = MENU_SETTINGS_BIND_BEGIN;
      driver.menu->binds.last = MENU_SETTINGS_BIND_LAST;

      file_list_push(driver.menu->menu_stack, "", "",
            driver.menu->bind_mode_keyboard ?
            MENU_SETTINGS_CUSTOM_BIND_KEYBOARD :
            MENU_SETTINGS_CUSTOM_BIND,
            driver.menu->selection_ptr);
      if (driver.menu->bind_mode_keyboard)
      {
         driver.menu->binds.timeout_end =
            rarch_get_time_usec() + 
            MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
         input_keyboard_wait_keys(driver.menu,
               menu_custom_bind_keyboard_cb);
      }
      else
      {
         menu_poll_bind_get_rested_axes(&driver.menu->binds);
         menu_poll_bind_state(&driver.menu->binds);
      }
      return 0;
   }
#ifdef HAVE_SHADER_MANAGER
   else if (!strcmp(label, "video_shader_preset_save_as"))
   {
      if (action == MENU_ACTION_OK)
         menu_key_start_line(driver.menu, "Preset Filename",
               label, st_string_callback);
   }
   else if (!strcmp(label, "shader_apply_changes"))
   {
      rarch_main_command(RARCH_CMD_SHADERS_APPLY_CHANGES);
      return 0;
   }
#endif
   else if (type == MENU_SETTINGS_CUSTOM_BIND_DEFAULT_ALL)
   {
      unsigned i;
      struct retro_keybind *target = (struct retro_keybind*)
         &g_settings.input.binds[driver.menu->current_pad][0];
      const struct retro_keybind *def_binds = 
         driver.menu->current_pad ? retro_keybinds_rest : retro_keybinds_1;

      driver.menu->binds.begin = MENU_SETTINGS_BIND_BEGIN;
      driver.menu->binds.last = MENU_SETTINGS_BIND_LAST;

      for (i = MENU_SETTINGS_BIND_BEGIN;
            i <= MENU_SETTINGS_BIND_LAST; i++, target++)
      {
         if (driver.menu->bind_mode_keyboard)
            target->key = def_binds[i - MENU_SETTINGS_BIND_BEGIN].key;
         else
         {
            target->joykey = NO_BTN;
            target->joyaxis = AXIS_NONE;
         }
      }
      return 0;
   }
   else if (type >= MENU_SETTINGS_BIND_BEGIN &&
         type <= MENU_SETTINGS_BIND_ALL_LAST)
   {
      struct retro_keybind *bind = (struct retro_keybind*)
         &g_settings.input.binds[driver.menu->current_pad]
         [type - MENU_SETTINGS_BIND_BEGIN];

      driver.menu->binds.begin  = type;
      driver.menu->binds.last   = type;
      driver.menu->binds.target = bind;
      driver.menu->binds.player = driver.menu->current_pad;
      file_list_push(driver.menu->menu_stack, "", "",
            driver.menu->bind_mode_keyboard ?
            MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND,
            driver.menu->selection_ptr);

      if (driver.menu->bind_mode_keyboard)
      {
         driver.menu->binds.timeout_end = rarch_get_time_usec() +
            MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
         input_keyboard_wait_keys(driver.menu,
               menu_custom_bind_keyboard_cb);
      }
      else
      {
         menu_poll_bind_get_rested_axes(&driver.menu->binds);
         menu_poll_bind_state(&driver.menu->binds);
      }

      return 0;
   }
   else if (
         !strcmp(label, "load_content") ||
         !strcmp(label, "detect_core_list")
      )
   {
      menu_entries_push(driver.menu->menu_stack,
            g_settings.menu_content_directory, label, MENU_FILE_DIRECTORY,
            driver.menu->selection_ptr);
      return 0;
   }
   else if (!strcmp(label, "history_list") ||
         menu_common_type_is(label, type) == MENU_FILE_DIRECTORY
         )
   {
      menu_entries_push(driver.menu->menu_stack,
            "", label, type, driver.menu->selection_ptr);
      return 0;
   }
   else if (
         menu_common_type_is(label, type) == MENU_SETTINGS ||
         !strcmp(label, "core_list") ||
         !strcmp(label, "configurations") ||
         !strcmp(label, "disk_image_append")
         )
   {
      menu_entries_push(driver.menu->menu_stack,
            dir ? dir : label, label, type,
            driver.menu->selection_ptr);
      return 0;
   }
   else if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
   {
      file_list_push(driver.menu->menu_stack, "", "",
            MENU_SETTINGS_CUSTOM_VIEWPORT,
            driver.menu->selection_ptr);

      /* Start with something sane. */
      rarch_viewport_t *custom = (rarch_viewport_t*)
         &g_extern.console.screen.viewports.custom_vp;

      if (driver.video_data && driver.video &&
            driver.video->viewport_info)
         driver.video->viewport_info(driver.video_data, custom);
      aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
         (float)custom->width / custom->height;

      g_settings.video.aspect_ratio_idx = ASPECT_RATIO_CUSTOM;

      rarch_main_command(RARCH_CMD_VIDEO_SET_ASPECT_RATIO);
      return 0;
   }
   return -1;
}