Can almost run RGUI on PC.

Input in menu is broken. Binds are set up wrongly for PC.
This commit is contained in:
Themaister 2013-03-16 10:35:22 +01:00
parent 15099f8e4f
commit 12cc1c43d4
6 changed files with 89 additions and 40 deletions

View File

@ -546,6 +546,8 @@ static const bool input_autodetect_enable = true;
#define RETRO_LBL_OVERLAY_NEXT "Next Overlay"
#define RETRO_LBL_DISK_EJECT_TOGGLE "Disk Eject Toggle"
#define RETRO_LBL_DISK_NEXT "Disk Swap Next"
#define RETRO_LBL_MENU_TOGGLE "Menu toggle"
#define RETRO_LBL_MENU_QUICKMENU_TOGGLE "Menu quickmenu toggle"
// Player 1
static const struct retro_keybind retro_keybinds_1[] = {
@ -616,6 +618,8 @@ static const struct retro_keybind retro_keybinds_1[] = {
{ true, RARCH_OVERLAY_NEXT, RETRO_LBL_OVERLAY_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_DISK_EJECT_TOGGLE, RETRO_LBL_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_DISK_NEXT, RETRO_LBL_DISK_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_MENU_TOGGLE, RETRO_LBL_MENU_TOGGLE, RETROK_F1, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_MENU_QUICKMENU_TOGGLE, RETRO_LBL_MENU_QUICKMENU_TOGGLE,RETROK_F1, NO_BTN, 0, AXIS_NONE },
};
// Player 2-5

View File

@ -16,6 +16,10 @@
#include "../general.h"
#ifdef HAVE_RGUI
#include "../frontend/menu/rgui.h"
#endif
#ifdef __APPLE__
#include "SDL.h"
// OSX seems to really need -lSDLmain,
@ -29,11 +33,68 @@ int main(int argc, char *argv[])
// Consoles use the higher level API.
return rarch_main(argc, argv);
#else
rarch_init_msg_queue();
int init_ret;
if ((init_ret = rarch_main_init(argc, argv))) return init_ret;
rarch_init_msg_queue();
#ifdef HAVE_RGUI
menu_init();
g_extern.lifecycle_mode_state |= 1ULL << MODE_GAME;
for (;;)
{
if (g_extern.lifecycle_mode_state & (1ULL << MODE_GAME))
{
while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate());
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME);
}
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_INIT))
{
if (g_extern.main_is_init)
rarch_main_deinit();
struct rarch_main_wrap args = {0};
args.verbose = g_extern.verbose;
args.config_path = *g_extern.config_path ? g_extern.config_path : NULL;
args.sram_path = NULL;
args.state_path = NULL;
args.rom_path = g_extern.fullpath;
args.libretro_path = g_settings.libretro;
int init_ret = rarch_main_init_wrap(&args);
if (init_ret == 0)
{
RARCH_LOG("rarch_main_init() succeeded.\n");
g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME);
}
else
{
RARCH_ERR("rarch_main_init() failed.\n");
g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU);
}
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_INIT);
}
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU))
{
g_extern.lifecycle_mode_state |= 1ULL << MODE_MENU_PREINIT;
while (menu_iterate());
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU);
}
else
break;
}
menu_free();
if (g_extern.main_is_init)
rarch_main_deinit();
#else
while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate());
rarch_main_deinit();
#endif
rarch_deinit_msg_queue();
#ifdef PERF_TEST

View File

@ -289,25 +289,27 @@ static void fill_rect(uint16_t *buf, unsigned pitch,
}
static void blit_line(rgui_handle_t *rgui,
unsigned x, unsigned y, const char *message, bool green)
int x, int y, const char *message, bool green)
{
while (*message)
{
for (unsigned j = 0; j < FONT_HEIGHT; j++)
for (int j = 0; j < FONT_HEIGHT; j++)
{
for (unsigned i = 0; i < FONT_WIDTH; i++)
for (int i = 0; i < FONT_WIDTH; i++)
{
uint8_t rem = 1 << ((i + j * FONT_WIDTH) & 7);
unsigned offset = (i + j * FONT_WIDTH) >> 3;
int offset = (i + j * FONT_WIDTH) >> 3;
bool col = (rgui->font[FONT_OFFSET((unsigned char)*message) + offset] & rem);
if (col)
{
rgui->frame_buf[(y + j) * (rgui->frame_buf_pitch >> 1) + (x + i)] = green ?
#ifdef GEKKO
(3 << 0) | (10 << 4) | (3 << 8) | (7 << 12) : 0x7FFF;
#else
(15 << 0) | (7 << 4) | (15 << 8) | (7 << 12) : 0xFFFF;
#endif
}
}
}
@ -350,8 +352,8 @@ static void render_messagebox(rgui_handle_t *rgui, const char *message)
unsigned width = strlen(msg) * FONT_WIDTH_STRIDE - 1 + 6 + 10;
unsigned height = FONT_HEIGHT + 6 + 10;
unsigned x = (RGUI_WIDTH - width) / 2;
unsigned y = (RGUI_HEIGHT - height) / 2;
int x = (RGUI_WIDTH - width) / 2;
int y = (RGUI_HEIGHT - height) / 2;
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
x + 5, y + 5, width - 10, height - 10, gray_filler);
@ -1637,35 +1639,7 @@ bool menu_iterate(void)
g_extern.frame_count++;
input_state = 0;
driver.input->poll(NULL);
#ifdef HAVE_OVERLAY
if (driver.overlay)
{
driver.overlay_state = 0;
unsigned device = input_overlay_full_screen(driver.overlay) ?
RARCH_DEVICE_POINTER_SCREEN : RETRO_DEVICE_POINTER;
bool polled = false;
for (unsigned i = 0;
input_input_state_func(NULL, 0, device, i, RETRO_DEVICE_ID_POINTER_PRESSED);
i++)
{
int16_t x = input_input_state_func(NULL, 0,
device, i, RETRO_DEVICE_ID_POINTER_X);
int16_t y = input_input_state_func(NULL, 0,
device, i, RETRO_DEVICE_ID_POINTER_Y);
driver.overlay_state |= input_overlay_poll(driver.overlay, x, y);
polled = true;
}
if (!polled)
input_overlay_poll_clear(driver.overlay);
}
#endif
rarch_input_poll();
#ifndef GEKKO
/* TODO - not sure if correct regarding RARCH_QUIT_KEY */
@ -1676,8 +1650,9 @@ bool menu_iterate(void)
}
#endif
// FIXME: Broken for PC atm.
for (unsigned i = 0; i < RMENU_DEVICE_NAV_LAST; i++)
input_state |= driver.input->input_state(NULL, menu_nav_binds, 0,
input_state |= driver.input->input_state(driver.input_data, menu_nav_binds, 0,
RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
input_state |= driver.input->key_pressed(driver.input_data, RARCH_MENU_TOGGLE) ? (1ULL << GX_DEVICE_NAV_MENU) : 0;

View File

@ -123,6 +123,10 @@ int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action);
void rgui_free(rgui_handle_t *rgui);
void menu_init(void);
bool menu_iterate(void);
void menu_free(void);
#ifdef __cplusplus
}
#endif

View File

@ -646,6 +646,7 @@ void rarch_main_deinit(void);
void rarch_render_cached_frame(void);
void rarch_init_msg_queue(void);
void rarch_deinit_msg_queue(void);
void rarch_input_poll(void);
void rarch_load_state(void);
void rarch_save_state(void);

View File

@ -495,7 +495,7 @@ static inline void input_poll_overlay(void)
}
#endif
static void input_poll(void)
void rarch_input_poll(void)
{
input_poll_func();
@ -1615,7 +1615,7 @@ static void init_libretro_cbs_plain(void)
pretro_set_audio_sample(audio_sample);
pretro_set_audio_sample_batch(audio_sample_batch);
pretro_set_input_state(input_state);
pretro_set_input_poll(input_poll);
pretro_set_input_poll(rarch_input_poll);
}
static void init_libretro_cbs(void)
@ -2848,6 +2848,7 @@ error:
return 1;
}
#ifdef HAVE_RGUI
static inline bool check_enter_rgui(void)
{
static bool old_rmenu_toggle = true;
@ -2868,6 +2869,7 @@ static inline bool check_enter_rgui(void)
return false;
}
}
#endif
bool rarch_main_iterate(void)
{
@ -2891,8 +2893,10 @@ bool rarch_main_iterate(void)
return false;
}
#ifdef HAVE_RGUI
if (check_enter_rgui())
return false; // Enter menu, don't exit.
#endif
#ifdef HAVE_COMMAND
if (driver.command)
@ -3069,7 +3073,7 @@ bool rarch_main_idle_iterate(void)
return false;
do_state_checks();
input_poll();
rarch_input_poll();
rarch_sleep(10);
return true;
}