예제 #1
0
파일: main.c 프로젝트: mmodahl/RetroArch
static void menu_init(void)
{
   rgui = rgui_init("",
         menu_framebuf, RGUI_WIDTH * sizeof(uint32_t),
         NULL /* _binary_console_font_bmp_start */, _binary_console_font_bin_start, folder_cb, NULL);

   g_console.mode_switch = MODE_MENU;
   rgui_iterate(rgui, RGUI_ACTION_REFRESH);
}
예제 #2
0
파일: main.c 프로젝트: ficoos/RetroArch
int main(void)
{
#ifdef HW_RVL
   L2Enhance();
#endif

   fatInitDefault();

#ifdef HAVE_FILE_LOGGER
   g_extern.verbose = true;
   log_fp = fopen("/retroarch-log.txt", "w");
#endif

   config_set_defaults();

   g_settings.audio.rate_control = true;
   g_settings.audio.rate_control_delta = 0.004;
   g_console.block_config_read = true;

   wii_video_init();
   input_wii.init();

   rgui_handle_t *rgui = rgui_init("",
         menu_framebuf, RGUI_WIDTH * sizeof(uint16_t),
         _binary_console_font_bmp_start, folder_cb, NULL);
   rgui_iterate(rgui, RGUI_ACTION_REFRESH);

   int ret = 0;
   while (get_rom_path(rgui) && ret == 0)
   {
      bool repeat = false;

      input_wii.poll(NULL);

      do{
         repeat = rarch_main_iterate();
      }while(repeat && !g_console.frame_advance_enable);

      audio_stop_func();
   }

   if(g_console.emulator_initialized)
      rarch_main_deinit();

   wii_video_deinit();
   input_wii.free(NULL);

#ifdef HAVE_FILE_LOGGER
   fclose(log_fp);
#endif

   rgui_free(rgui);
   return ret;
}
예제 #3
0
void menu_init(void)
{
   gx_video_t *gx = (gx_video_t*)driver.video_data;

   gx->menu_data = (uint32_t *) menu_framebuf;

   rgui = rgui_init("",
         menu_framebuf, RGUI_WIDTH * sizeof(uint16_t),
         NULL /* _binary_console_font_bmp_start */, bitmap_bin, folder_cb, NULL);

   rgui_iterate(rgui, RGUI_ACTION_REFRESH);
}
예제 #4
0
static void system_process_args(int argc, char *argv[])
{
   if (argc > 2 && argv[1] != NULL && argv[2] != NULL)
   {
      char rom[PATH_MAX];
      g_extern.lifecycle_mode_state |= (1ULL << MODE_EXTLAUNCH_CHANNEL);
      snprintf(rom, sizeof(rom), "%s%s", argv[1], argv[2]);

      strlcpy(g_extern.fullpath, rom, sizeof(g_extern.fullpath));
      g_extern.lifecycle_mode_state |= (1ULL << MODE_LOAD_GAME);

      rgui_iterate(rgui, RGUI_ACTION_MESSAGE);
      g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_DRAW);
      rarch_render_cached_frame();
      g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_DRAW);
      g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU);
      g_extern.lifecycle_mode_state |= (1ULL << MODE_INIT);
   }
   else
      g_extern.lifecycle_mode_state |= (1ULL << MODE_EXTLAUNCH_SALAMANDER);
}
예제 #5
0
void load_menu_game_prepare(void)
{
   if (*g_extern.fullpath || rgui->load_no_rom)
   {
      if (*g_extern.fullpath &&
            g_extern.lifecycle_mode_state & (1ULL << MODE_INFO_DRAW))
      {
         char tmp[PATH_MAX];
         char str[PATH_MAX];

         fill_pathname_base(tmp, g_extern.fullpath, sizeof(tmp));
         snprintf(str, sizeof(str), "INFO - Loading %s ...", tmp);
         msg_queue_push(g_extern.msg_queue, str, 1, 1);
      }

      menu_rom_history_push(*g_extern.fullpath ? g_extern.fullpath : NULL,
            g_settings.libretro,
            rgui->info.library_name ? rgui->info.library_name : "");
   }

#ifdef HAVE_RGUI
   // redraw RGUI frame
   rgui->old_input_state = rgui->trigger_state = 0;
   rgui->do_held = false;
   rgui->msg_force = true;
   rgui_iterate(rgui);
#endif

   // Draw frame for loading message
   if (driver.video_poke && driver.video_poke->set_texture_enable)
      driver.video_poke->set_texture_enable(driver.video_data, rgui->frame_buf_show, MENU_TEXTURE_FULLSCREEN);

   if (driver.video)
      rarch_render_cached_frame();

   if (driver.video_poke && driver.video_poke->set_texture_enable)
      driver.video_poke->set_texture_enable(driver.video_data, false,
            MENU_TEXTURE_FULLSCREEN);
}
예제 #6
0
파일: main.c 프로젝트: mmodahl/RetroArch
int main(int argc, char *argv[])
{
#ifdef HW_RVL
   IOS_ReloadIOS(IOS_GetVersion());
   L2Enhance();
   gx_init_mem2();
#endif

   fatInitDefault();

#ifdef HAVE_LOGGER
   g_extern.verbose = true;
   logger_init();
   devoptab_list[STD_OUT] = &dotab_stdout;
   devoptab_list[STD_ERR] = &dotab_stdout;
   dotab_stdout.write_r = gx_logger_net;
#elif defined(HAVE_FILE_LOGGER)
   g_extern.verbose = true;
   log_fp = fopen("/retroarch-log.txt", "w");
   devoptab_list[STD_OUT] = &dotab_stdout;
   devoptab_list[STD_ERR] = &dotab_stdout;
   dotab_stdout.write_r = gx_logger_file;
#endif

#ifdef HW_RVL
   lwp_t gx_device_thread;
   gx_devices[GX_DEVICE_SD].interface = &__io_wiisd;
   gx_devices[GX_DEVICE_SD].name = "sd";
   gx_devices[GX_DEVICE_SD].mounted = fatMountSimple(gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface);
   gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage;
   gx_devices[GX_DEVICE_USB].name = "usb";
   gx_devices[GX_DEVICE_USB].mounted = fatMountSimple(gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface);
   LWP_MutexInit(&gx_device_mutex, false);
   LWP_CreateThread(&gx_device_thread, gx_devthread, NULL, NULL, 0, 66);
#endif

   get_environment_settings();
   make_directories();
   config_set_defaults();
   input_gx.init();

   video_gx.start();
   driver.video = &video_gx;

   gx_video_t *gx = (gx_video_t*)driver.video_data;
   gx->menu_data = (uint32_t *) menu_framebuf;

   char tmp_path[PATH_MAX];
   const char *extension = default_paths.executable_extension;
   snprintf(tmp_path, sizeof(tmp_path), "%s/", default_paths.core_dir);
   const char *path_prefix = tmp_path; 

   char full_path[1024];
   snprintf(full_path, sizeof(full_path), "%sCORE%s", path_prefix, extension);

   bool find_libretro_file = rarch_configure_libretro_core(full_path, path_prefix, path_prefix, 
   default_paths.config_file, extension);

   rarch_settings_set_default(&input_gx);
   rarch_config_load(default_paths.config_file, path_prefix, extension, find_libretro_file);

   char core_name[64];
   rarch_console_name_from_id(core_name, sizeof(core_name));
   char input_path[1024];
   snprintf(input_path, sizeof(input_path), "%s/%s.cfg", default_paths.input_presets_dir, core_name);
   config_read_keybinds(input_path);

   init_libretro_sym();

   input_gx.post_init();

   menu_init();

   if (argc > 2 && argv[1] != NULL && argv[2] != NULL)
   {
      char rom[PATH_MAX];
      g_console.external_launcher_support = EXTERN_LAUNCHER_CHANNEL;
      snprintf(rom, sizeof(rom), "%s%s", argv[1], argv[2]);
      g_console.zip_extract_mode = ZIP_EXTRACT_TO_CURRENT_DIR_AND_LOAD_FIRST_FILE;
      rarch_console_load_game_wrap(rom, g_console.zip_extract_mode, S_DELAY_1);

      rgui_iterate(rgui, RGUI_ACTION_MESSAGE);
      gx->menu_render = true;
      rarch_render_cached_frame();
      gx->menu_render = false;

      rarch_startup(default_paths.config_file);
   }
   else
   {
      g_console.external_launcher_support = EXTERN_LAUNCHER_SALAMANDER;
   }

begin_loop:
   if(g_console.mode_switch == MODE_EMULATION)
   {
      bool repeat = false;

      input_gx.poll(NULL);

      video_set_aspect_ratio_func(g_console.aspect_ratio_index);

      audio_start_func();

      do{
         repeat = rarch_main_iterate();
      }while(repeat && !g_console.frame_advance_enable);

      audio_stop_func();
   }
   else if(g_console.mode_switch == MODE_MENU)
   {
      menu_loop();

      if (g_console.mode_switch != MODE_EXIT)
         rarch_startup(default_paths.config_file);
   }
   else
      goto begin_shutdown;
   goto begin_loop;

begin_shutdown:
   rarch_config_save(default_paths.config_file);
   config_save_keybinds(input_path);

   if(g_console.emulator_initialized)
      rarch_main_deinit();

   input_gx.free(NULL);

   video_gx.stop();
   menu_free();

#ifdef HAVE_LOGGER
   logger_shutdown();
#elif defined(HAVE_FILE_LOGGER)
   fclose(log_fp);
#endif

   if(g_console.return_to_launcher)
      rarch_console_exec(g_console.launch_app_on_exit);

   exit(0);
}
예제 #7
0
파일: main.c 프로젝트: mmodahl/RetroArch
static void menu_loop(void)
{
   gx_video_t *gx = (gx_video_t*)driver.video_data;

   uint16_t old_input_state = 0;
   bool first = true;
   bool first_held = false;
   bool initial_held = true;

   g_console.menu_enable = true;
   gx->menu_render = true;

   do
   {
      uint16_t input_state = 0;

      input_gx.poll(NULL);

      for (unsigned i = 0; i < GX_DEVICE_NAV_LAST; i++)
      {
         input_state |= input_gx.input_state(NULL, gx_nav_binds, 0,
               RETRO_DEVICE_JOYPAD, 0, i) ? (1 << i) : 0;
      }

      uint16_t trigger_state = input_state & ~old_input_state;
      bool do_held = (input_state & ((1 << GX_DEVICE_NAV_UP) | (1 << GX_DEVICE_NAV_DOWN) | (1 << GX_DEVICE_NAV_LEFT) | (1 << GX_DEVICE_NAV_RIGHT))) && !(input_state & ((1 << GX_DEVICE_NAV_MENU) | (1 << GX_DEVICE_NAV_QUIT)));

      if(do_held)
      {
         if(!first_held)
         {
            first_held = true;
            SET_TIMER_EXPIRATION(gx, (initial_held) ? 15 : 7);
         }

         if(IS_TIMER_EXPIRED(gx))
         {
            first_held = false;
            trigger_state = input_state; //second input frame set as current frame
         }

         initial_held = false;
      }
      else
      {
         first_held = false;
         initial_held = true;
      }

      rgui_action_t action = RGUI_ACTION_NOOP;

      // don't run anything first frame, only capture held inputs for old_input_state
      if (!first)
      {
         if (trigger_state & (1 << GX_DEVICE_NAV_UP))
            action = RGUI_ACTION_UP;
         else if (trigger_state & (1 << GX_DEVICE_NAV_DOWN))
            action = RGUI_ACTION_DOWN;
         else if (trigger_state & (1 << GX_DEVICE_NAV_LEFT))
            action = RGUI_ACTION_LEFT;
         else if (trigger_state & (1 << GX_DEVICE_NAV_RIGHT))
            action = RGUI_ACTION_RIGHT;
         else if (trigger_state & (1 << GX_DEVICE_NAV_B))
            action = RGUI_ACTION_CANCEL;
         else if (trigger_state & (1 << GX_DEVICE_NAV_A))
            action = RGUI_ACTION_OK;
         else if (trigger_state & (1 << GX_DEVICE_NAV_START))
            action = RGUI_ACTION_START;
         else if (trigger_state & (1 << GX_DEVICE_NAV_SELECT))
            action = RGUI_ACTION_SETTINGS;
      }
      else
      {
         first = false;
      }

      rgui_iterate(rgui, action);

      rarch_render_cached_frame();

      old_input_state = input_state;

      bool goto_menu_key_pressed = (trigger_state & (1 << GX_DEVICE_NAV_MENU));
      bool quit_key_pressed = (trigger_state & (1 << GX_DEVICE_NAV_QUIT));

      if(IS_TIMER_EXPIRED(gx))
      {
         // if we want to force goto the emulation loop, skip this
         if(g_console.mode_switch != MODE_EMULATION)
         {
            if(goto_menu_key_pressed)
            {
               g_console.menu_enable = (goto_menu_key_pressed && g_console.emulator_initialized) ? false : true;
               g_console.mode_switch = g_console.menu_enable ? MODE_MENU : MODE_EMULATION;
            }
         }
      }

      if(quit_key_pressed)
      {
         g_console.menu_enable = false;
         g_console.mode_switch = MODE_EXIT;
      }

      // set a timer delay so that we don't instantly switch back to the menu when
      // press and holding QUIT in the emulation loop (lasts for 30 frame ticks)
      if(g_console.mode_switch == MODE_EMULATION)
      {
         SET_TIMER_EXPIRATION(gx, 30);
      }

   }while(g_console.menu_enable);

   gx->menu_render = false;

   g_console.ingame_menu_enable = false;
}
예제 #8
0
bool menu_iterate(void)
{
   rarch_time_t time, delta, target_msec, sleep_msec;
   static bool initial_held = true;
   static bool first_held = false;
   uint64_t input_state = 0;
   int input_entry_ret;

   if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_PREINIT))
   {
      rgui->need_refresh = true;
      g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_PREINIT);
      rgui->old_input_state |= 1ULL << DEVICE_NAV_MENU;
   }

   rarch_input_poll();
#ifdef HAVE_OVERLAY
   rarch_check_overlay();
#endif

   if (input_key_pressed_func(RARCH_QUIT_KEY) || !video_alive_func())
   {
      g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME);
      goto deinit;
   }

   input_state = rgui_input();

   if (rgui->do_held)
   {
      if (!first_held)
      {
         first_held = true;
         rgui->delay_timer = initial_held ? 12 : 6;
         rgui->delay_count = 0;
      }

      if (rgui->delay_count >= rgui->delay_timer)
      {
         first_held = false;
         rgui->trigger_state = input_state;
      }

      initial_held = false;
   }
   else
   {
      first_held = false;
      initial_held = true;
   }

   rgui->delay_count++;
   rgui->old_input_state = input_state;
   input_entry_ret = rgui_iterate(rgui);

   if (driver.video_poke && driver.video_poke->set_texture_enable)
      driver.video_poke->set_texture_enable(driver.video_data, rgui->frame_buf_show, MENU_TEXTURE_FULLSCREEN);

   rarch_render_cached_frame();

   // Throttle in case VSync is broken (avoid 1000+ FPS RGUI).
   time = rarch_get_time_usec();
   delta = (time - rgui->last_time) / 1000;
   target_msec = 750 / g_settings.video.refresh_rate; // Try to sleep less, so we can hopefully rely on FPS logger.
   sleep_msec = target_msec - delta;
   if (sleep_msec > 0)
      rarch_sleep(sleep_msec);
   rgui->last_time = rarch_get_time_usec();

   if (driver.video_poke && driver.video_poke->set_texture_enable)
      driver.video_poke->set_texture_enable(driver.video_data, false,
            MENU_TEXTURE_FULLSCREEN);

   if (rgui_input_postprocess(rgui, rgui->old_input_state) || input_entry_ret)
      goto deinit;

   return true;

deinit:
   return false;
}
예제 #9
0
bool rmenu_iterate(void)
{
   static uint16_t old_input_state = 0;
   static bool initial_held = true;
   static bool first_held = false;

   g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_DRAW);
   driver.video->apply_state_changes();

   g_extern.frame_count++;

   uint16_t input_state = 0;

   driver.input->poll(NULL);

   for (unsigned i = 0; i < RMENU_DEVICE_NAV_LAST; i++)
      input_state |= driver.input->input_state(NULL, rmenu_nav_binds, 0,
            RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;

   trigger_state = input_state & ~old_input_state;
   bool do_held = (input_state & ((1ULL << GX_DEVICE_NAV_UP) | (1ULL << GX_DEVICE_NAV_DOWN) | (1ULL << GX_DEVICE_NAV_LEFT) | (1ULL << GX_DEVICE_NAV_RIGHT))) && !(input_state & ((1ULL << GX_DEVICE_NAV_MENU) | (1ULL << GX_DEVICE_NAV_QUIT)));

   if(do_held)
   {
      if(!first_held)
      {
         first_held = true;
         g_extern.delay_timer[1] = g_extern.frame_count + (initial_held ? 15 : 7);
      }

      if (!(g_extern.frame_count < g_extern.delay_timer[1]))
      {
         first_held = false;
         trigger_state = input_state; //second input frame set as current frame
      }

      initial_held = false;
   }
   else
   {
      first_held = false;
      initial_held = true;
   }

   old_input_state = input_state;

   rgui_action_t action = RGUI_ACTION_NOOP;

   // don't run anything first frame, only capture held inputs for old_input_state
   if (trigger_state & (1ULL << GX_DEVICE_NAV_UP))
      action = RGUI_ACTION_UP;
   else if (trigger_state & (1ULL << GX_DEVICE_NAV_DOWN))
      action = RGUI_ACTION_DOWN;
   else if (trigger_state & (1ULL << GX_DEVICE_NAV_LEFT))
      action = RGUI_ACTION_LEFT;
   else if (trigger_state & (1ULL << GX_DEVICE_NAV_RIGHT))
      action = RGUI_ACTION_RIGHT;
   else if (trigger_state & (1ULL << GX_DEVICE_NAV_B))
      action = RGUI_ACTION_CANCEL;
   else if (trigger_state & (1ULL << GX_DEVICE_NAV_A))
      action = RGUI_ACTION_OK;
   else if (trigger_state & (1ULL << GX_DEVICE_NAV_START))
      action = RGUI_ACTION_START;
   else if (trigger_state & (1ULL << GX_DEVICE_NAV_SELECT))
      action = RGUI_ACTION_SETTINGS;
   else if (trigger_state & (1ULL << GX_DEVICE_NAV_QUIT))
   {
      g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT);
      goto deinit;
   }

   int input_entry_ret = 0;
   int input_process_ret = 0;

   input_entry_ret = rgui_iterate(rgui, action);

   // draw last frame for loading messages
   rarch_render_cached_frame();

   input_process_ret = rmenu_input_process(NULL, NULL);

   if (input_entry_ret != 0 || input_process_ret != 0)
      goto deinit;

   return true;

deinit:
   // set a timer delay so that we don't instantly switch back to the menu when
   // press and holding QUIT in the emulation loop (lasts for 30 frame ticks)
   if (!(g_extern.lifecycle_state & (1ULL << RARCH_FRAMEADVANCE)))
      g_extern.delay_timer[0] = g_extern.frame_count + 30;

   g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_DRAW);
   g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_INGAME);

   return false;
}
예제 #10
0
파일: main.c 프로젝트: ficoos/RetroArch
static bool get_rom_path(rgui_handle_t *rgui)
{
   uint16_t old_input_state = 0;
   bool can_quit = false;
   bool first = true;

   for (;;)
   {
      uint16_t input_state = 0;
      input_wii.poll(NULL);

      if (input_wii.key_pressed(NULL, RARCH_QUIT_KEY))
      {
         if (can_quit)
            return false;
      }
      else
         can_quit = true;

      for (unsigned i = 0; i < RARCH_FIRST_META_KEY; i++)
      {
         input_state |= input_wii.input_state(NULL, NULL, false,
               RETRO_DEVICE_JOYPAD, 0, i) ? (1 << i) : 0;
      }

      uint16_t trigger_state = input_state & ~old_input_state;

      rgui_action_t action = RGUI_ACTION_NOOP;
      if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_B))
         action = RGUI_ACTION_CANCEL;
      else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_A))
         action = RGUI_ACTION_OK;
      else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_UP))
         action = RGUI_ACTION_UP;
      else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_DOWN))
         action = RGUI_ACTION_DOWN;
      else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_LEFT))
         action = RGUI_ACTION_LEFT;
      else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT))
         action = RGUI_ACTION_RIGHT;
      else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_START))
         action = RGUI_ACTION_START;
      else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_SELECT) && !first) // don't catch start+select+l+r when exiting
         action = RGUI_ACTION_SETTINGS;

      const char *ret = rgui_iterate(rgui, action);
      video_wii.frame(NULL, menu_framebuf,
            RGUI_WIDTH, RGUI_HEIGHT,
            RGUI_WIDTH * sizeof(uint16_t), NULL);

      if (ret)
      {
         g_console.initialize_rarch_enable = true;
         strlcpy(g_console.rom_path, ret, sizeof(g_console.rom_path));
         if (rarch_startup(NULL))
            return true;
      }

      old_input_state = input_state;
      first = false;
      rarch_sleep(10);
   }
}