(GX) work with new console code

This commit is contained in:
ToadKing 2013-01-07 23:48:21 -05:00
parent 7c3b9486b3
commit 1dc08b9a6d
7 changed files with 198 additions and 263 deletions

View File

@ -374,9 +374,7 @@ MAIN
#include "../../frontend/frontend_xdk.c"
#elif defined(XENON)
#include "../../frontend/frontend_xenon.c"
#elif defined(GEKKO)
#include "../../frontend/frontend_gx.c"
#elif defined(__CELLOS_LV2__)
#elif defined(__CELLOS_LV2__) || defined(GEKKO)
#include "../../frontend/frontend_console.c"
#elif defined(PSP)
#include "../../frontend/frontend_psp.c"

View File

@ -217,6 +217,9 @@ static void adjust_system_rates(void)
g_extern.system.force_nonblock = false;
const struct retro_system_timing *info = &g_extern.system.av_info.timing;
if (!info->fps || !info->sample_rate)
return;
float timing_skew = fabs(1.0f - info->fps / g_settings.video.refresh_rate);
if (timing_skew > 0.05f) // We don't want to adjust pitch too much. If we have extreme cases, just don't readjust at all.
{

View File

@ -19,10 +19,10 @@
#include <stddef.h>
#include <string.h>
#include "../console/rmenu/rmenu.h"
#if defined(__CELLOS_LV2__)
#include "frontend_ps3.c"
#elif defined(GEKKO)
#include "frontend_gx.c"
#endif
#undef main
@ -86,7 +86,9 @@ begin_loop:
{
driver.input->poll(NULL);
driver.video->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx);
audio_start_func();
while(rarch_main_iterate());
audio_stop_func();
}
else if (g_extern.console.rmenu.mode == MODE_INIT)
{
@ -119,6 +121,8 @@ begin_loop:
begin_shutdown:
config_save_file(g_extern.config_path);
system_deinit_save();
if(g_extern.main_is_init)
rarch_main_deinit();
@ -126,6 +130,14 @@ begin_shutdown:
driver.video->stop();
menu_free();
#ifdef HAVE_LOGGER
logger_shutdown();
#elif defined(HAVE_FILE_LOGGER)
if (g_extern.log_file)
fclose(g_extern.log_file);
g_extern.log_file = NULL;
#endif
system_deinit();
system_exitspawn();

View File

@ -15,8 +15,6 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#undef main
#include <stdbool.h>
#include "../driver.h"
#include "../general.h"
@ -62,6 +60,7 @@ enum
uint16_t menu_framebuf[400 * 240];
rgui_handle_t *rgui;
char input_path[1024];
#if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER)
static devoptab_t dotab_stdout = {
@ -390,31 +389,6 @@ static void menu_free(void)
rgui_free(rgui);
}
static void get_environment_settings(void)
{
#ifdef HW_DOL
chdir("carda:/retroarch");
#endif
getcwd(default_paths.core_dir, MAXPATHLEN);
char *last_slash = strrchr(default_paths.core_dir, '/');
if (last_slash)
*last_slash = 0;
char *device_end = strchr(default_paths.core_dir, '/');
if (device_end)
snprintf(default_paths.port_dir, sizeof(default_paths.port_dir), "%.*s/retroarch", device_end - default_paths.core_dir, default_paths.core_dir);
else
strlcpy(default_paths.port_dir, "/retroarch", sizeof(default_paths.port_dir));
snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir);
snprintf(default_paths.system_dir, sizeof(default_paths.system_dir), "%s/system", default_paths.port_dir);
snprintf(default_paths.savestate_dir, sizeof(default_paths.savestate_dir), "%s/savestates", default_paths.port_dir);
strlcpy(default_paths.filesystem_root_dir, "/", sizeof(default_paths.filesystem_root_dir));
snprintf(default_paths.filebrowser_startup_dir, sizeof(default_paths.filebrowser_startup_dir), default_paths.filesystem_root_dir);
snprintf(default_paths.sram_dir, sizeof(default_paths.sram_dir), "%s/sram", default_paths.port_dir);
snprintf(default_paths.input_presets_dir, sizeof(default_paths.input_presets_dir), "%s/input", default_paths.port_dir);
strlcpy(default_paths.executable_extension, ".dol", sizeof(default_paths.executable_extension));
strlcpy(default_paths.salamander_file, "boot.dol", sizeof(default_paths.salamander_file));
}
#define MAKE_FILE(x) {\
if (!path_file_exists((x)))\
{\
@ -439,8 +413,33 @@ static void get_environment_settings(void)
}\
}
static void make_directories(void)
static void get_environment_settings(int argc, char *argv[])
{
(void)argc;
(void)argv;
#ifdef HW_DOL
chdir("carda:/retroarch");
#endif
getcwd(default_paths.core_dir, MAXPATHLEN);
char *last_slash = strrchr(default_paths.core_dir, '/');
if (last_slash)
*last_slash = 0;
char *device_end = strchr(default_paths.core_dir, '/');
if (device_end)
snprintf(default_paths.port_dir, sizeof(default_paths.port_dir), "%.*s/retroarch", device_end - default_paths.core_dir, default_paths.core_dir);
else
strlcpy(default_paths.port_dir, "/retroarch", sizeof(default_paths.port_dir));
snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir);
snprintf(default_paths.system_dir, sizeof(default_paths.system_dir), "%s/system", default_paths.port_dir);
snprintf(default_paths.savestate_dir, sizeof(default_paths.savestate_dir), "%s/savestates", default_paths.port_dir);
strlcpy(default_paths.filesystem_root_dir, "/", sizeof(default_paths.filesystem_root_dir));
snprintf(default_paths.filebrowser_startup_dir, sizeof(default_paths.filebrowser_startup_dir), default_paths.filesystem_root_dir);
snprintf(default_paths.sram_dir, sizeof(default_paths.sram_dir), "%s/sram", default_paths.port_dir);
snprintf(default_paths.input_presets_dir, sizeof(default_paths.input_presets_dir), "%s/input", default_paths.port_dir);
strlcpy(default_paths.executable_extension, ".dol", sizeof(default_paths.executable_extension));
strlcpy(default_paths.salamander_file, "boot.dol", sizeof(default_paths.salamander_file));
MAKE_DIR(default_paths.port_dir);
MAKE_DIR(default_paths.system_dir);
MAKE_DIR(default_paths.savestate_dir);
@ -450,9 +449,10 @@ static void make_directories(void)
MAKE_FILE(g_extern.config_path);
}
extern void __exception_setreload(int t);
int main(int argc, char *argv[])
static void system_init(void)
{
#ifdef HW_RVL
IOS_ReloadIOS(IOS_GetVersion());
@ -491,54 +491,22 @@ int main(int argc, char *argv[])
LWP_MutexInit(&gx_device_mutex, false);
LWP_CreateThread(&gx_device_thread, gx_devthread, NULL, NULL, 0, 66);
#endif
}
rarch_main_clear_state();
get_environment_settings();
make_directories();
config_set_defaults();
init_drivers_pre();
driver.input->init();
driver.video->start();
static void system_post_init(void)
{
gx_video_t *gx = (gx_video_t*)driver.video_data;
gx->menu_data = (uint32_t *) menu_framebuf;
rarch_settings_set_default();
rarch_input_set_controls_default(driver.input);
rarch_config_load();
#ifdef HAVE_LIBRETRO_MANAGEMENT
char core_exe_path[PATH_MAX];
char path_prefix[PATH_MAX];
const char *extension = default_paths.executable_extension;
snprintf(path_prefix, sizeof(path_prefix), "%s/", default_paths.core_dir);
snprintf(core_exe_path, sizeof(core_exe_path), "%sCORE%s", path_prefix, extension);
if (path_file_exists(core_exe_path))
{
if (rarch_libretro_core_install(core_exe_path, path_prefix, path_prefix,
g_extern.config_path, extension))
{
RARCH_LOG("New default libretro core saved to config file: %s.\n", g_settings.libretro);
config_save_file(g_extern.config_path);
}
}
#endif
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();
driver.input->post_init();
menu_init();
gx->menu_data = (uint32_t *) menu_framebuf;
}
static void system_process_args(int argc, char *argv[])
{
if (argc > 2 && argv[1] != NULL && argv[2] != NULL)
{
char rom[PATH_MAX];
@ -556,69 +524,19 @@ int main(int argc, char *argv[])
}
else
g_extern.console.external_launch.support = EXTERN_LAUNCHER_SALAMANDER;
begin_loop:
if(g_extern.console.rmenu.mode == MODE_EMULATION)
{
driver.input->poll(NULL);
video_set_aspect_ratio_func(g_settings.video.aspect_ratio_idx);
audio_start_func();
while(rarch_main_iterate());
audio_stop_func();
}
else if (g_extern.console.rmenu.mode == 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;
args.sram_path = g_extern.console.main_wrap.state.default_sram_dir.enable ? g_extern.console.main_wrap.paths.default_sram_dir : NULL,
args.state_path = g_extern.console.main_wrap.state.default_savestate_dir.enable ? g_extern.console.main_wrap.paths.default_savestate_dir : NULL,
args.rom_path = g_extern.file_state.rom_path;
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");
else
RARCH_ERR("rarch_main_init failed.\n");
}
else if(g_extern.console.rmenu.mode == MODE_MENU)
rmenu_iterate();
else
goto begin_shutdown;
goto begin_loop;
begin_shutdown:
config_save_file(g_extern.config_path);
config_save_keybinds(input_path);
if(g_extern.main_is_init)
rarch_main_deinit();
driver.input->free(NULL);
driver.video->stop();
menu_free();
#ifdef HAVE_LOGGER
logger_shutdown();
#elif defined(HAVE_FILE_LOGGER)
if (g_extern.log_file)
fclose(g_extern.log_file);
g_extern.log_file = NULL;
#endif
if(g_extern.console.external_launch.enable)
rarch_console_exec(g_settings.libretro);
exit(0);
}
static void system_deinit_save(void)
{
config_save_keybinds(input_path);
}
static void system_deinit(void)
{
}
static void system_exitspawn(void)
{
if(g_extern.console.external_launch.enable)
rarch_console_exec(g_settings.libretro);
}

View File

@ -55,6 +55,9 @@ static void dma_callback(void)
static void *gx_audio_init(const char *device, unsigned rate, unsigned latency)
{
if (g_audio)
return g_audio;
AUDIO_Init(NULL);
AUDIO_RegisterDMACallback(dma_callback);

View File

@ -282,153 +282,153 @@ static void gx_input_poll(void *data)
{
uint32_t type = 0;
uint32_t down = 0;
uint64_t *state_cur = NULL;
uint64_t *state_cur = &pad_state[port];
#ifdef HW_RVL
if (WPAD_Probe(port, &type) != WPAD_ERR_NONE)
continue;
state_cur = &pad_state[port];
WPADData *wpaddata = WPAD_Data(port);
down = wpaddata->btns_h;
*state_cur |= (down & WPAD_BUTTON_A) ? GX_WIIMOTE_A : 0;
*state_cur |= (down & WPAD_BUTTON_B) ? GX_WIIMOTE_B : 0;
*state_cur |= (down & WPAD_BUTTON_1) ? GX_WIIMOTE_1 : 0;
*state_cur |= (down & WPAD_BUTTON_2) ? GX_WIIMOTE_2 : 0;
*state_cur |= (down & WPAD_BUTTON_PLUS) ? GX_WIIMOTE_PLUS : 0;
*state_cur |= (down & WPAD_BUTTON_MINUS) ? GX_WIIMOTE_MINUS : 0;
*state_cur |= (down & WPAD_BUTTON_HOME) ? GX_WIIMOTE_HOME : 0;
// rotated d-pad on Wiimote
*state_cur |= (down & WPAD_BUTTON_UP) ? GX_WIIMOTE_LEFT : 0;
*state_cur |= (down & WPAD_BUTTON_DOWN) ? GX_WIIMOTE_RIGHT : 0;
*state_cur |= (down & WPAD_BUTTON_LEFT) ? GX_WIIMOTE_DOWN : 0;
*state_cur |= (down & WPAD_BUTTON_RIGHT) ? GX_WIIMOTE_UP : 0;
if((down & WPAD_BUTTON_HOME) && (down & WPAD_BUTTON_B))
*state_cur |= GX_QUIT_KEY;
expansion_t *exp = &wpaddata->exp;
if (type == WPAD_EXP_CLASSIC)
if (WPAD_Probe(port, &type) == WPAD_ERR_NONE)
{
*state_cur |= (down & WPAD_CLASSIC_BUTTON_A) ? GX_CLASSIC_A : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_B) ? GX_CLASSIC_B : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_X) ? GX_CLASSIC_X : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_Y) ? GX_CLASSIC_Y : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_UP) ? GX_CLASSIC_UP : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_DOWN) ? GX_CLASSIC_DOWN : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_LEFT) ? GX_CLASSIC_LEFT : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_RIGHT) ? GX_CLASSIC_RIGHT : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_PLUS) ? GX_CLASSIC_PLUS : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_MINUS) ? GX_CLASSIC_MINUS : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_HOME) ? GX_CLASSIC_HOME : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_FULL_L) ? GX_CLASSIC_L_TRIGGER : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_FULL_R) ? GX_CLASSIC_R_TRIGGER : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_ZL) ? GX_CLASSIC_ZL_TRIGGER : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_ZR) ? GX_CLASSIC_ZR_TRIGGER : 0;
WPADData *wpaddata = WPAD_Data(port);
if((down & WPAD_CLASSIC_BUTTON_HOME) && (down & WPAD_CLASSIC_BUTTON_ZL)
&& (down & WPAD_CLASSIC_BUTTON_ZR))
down = wpaddata->btns_h;
*state_cur |= (down & WPAD_BUTTON_A) ? GX_WIIMOTE_A : 0;
*state_cur |= (down & WPAD_BUTTON_B) ? GX_WIIMOTE_B : 0;
*state_cur |= (down & WPAD_BUTTON_1) ? GX_WIIMOTE_1 : 0;
*state_cur |= (down & WPAD_BUTTON_2) ? GX_WIIMOTE_2 : 0;
*state_cur |= (down & WPAD_BUTTON_PLUS) ? GX_WIIMOTE_PLUS : 0;
*state_cur |= (down & WPAD_BUTTON_MINUS) ? GX_WIIMOTE_MINUS : 0;
*state_cur |= (down & WPAD_BUTTON_HOME) ? GX_WIIMOTE_HOME : 0;
// rotated d-pad on Wiimote
*state_cur |= (down & WPAD_BUTTON_UP) ? GX_WIIMOTE_LEFT : 0;
*state_cur |= (down & WPAD_BUTTON_DOWN) ? GX_WIIMOTE_RIGHT : 0;
*state_cur |= (down & WPAD_BUTTON_LEFT) ? GX_WIIMOTE_DOWN : 0;
*state_cur |= (down & WPAD_BUTTON_RIGHT) ? GX_WIIMOTE_UP : 0;
if((down & WPAD_BUTTON_HOME) && (down & WPAD_BUTTON_B))
*state_cur |= GX_QUIT_KEY;
//TODO: Hack, analog stick twitchiness needs to be properly fixed
if(g_extern.draw_menu)
expansion_t *exp = &wpaddata->exp;
if (type == WPAD_EXP_CLASSIC)
{
s8 x = gx_stick_x(exp->classic.ljs);
s8 y = gx_stick_y(exp->classic.ljs);
*state_cur |= (down & WPAD_CLASSIC_BUTTON_A) ? GX_CLASSIC_A : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_B) ? GX_CLASSIC_B : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_X) ? GX_CLASSIC_X : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_Y) ? GX_CLASSIC_Y : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_UP) ? GX_CLASSIC_UP : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_DOWN) ? GX_CLASSIC_DOWN : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_LEFT) ? GX_CLASSIC_LEFT : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_RIGHT) ? GX_CLASSIC_RIGHT : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_PLUS) ? GX_CLASSIC_PLUS : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_MINUS) ? GX_CLASSIC_MINUS : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_HOME) ? GX_CLASSIC_HOME : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_FULL_L) ? GX_CLASSIC_L_TRIGGER : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_FULL_R) ? GX_CLASSIC_R_TRIGGER : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_ZL) ? GX_CLASSIC_ZL_TRIGGER : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_ZR) ? GX_CLASSIC_ZR_TRIGGER : 0;
if((down & WPAD_CLASSIC_BUTTON_HOME) && (down & WPAD_CLASSIC_BUTTON_ZL)
&& (down & WPAD_CLASSIC_BUTTON_ZR))
*state_cur |= GX_QUIT_KEY;
//TODO: Hack, analog stick twitchiness needs to be properly fixed
if(g_extern.draw_menu)
{
s8 x = gx_stick_x(exp->classic.ljs);
s8 y = gx_stick_y(exp->classic.ljs);
if (abs(x) > JOYSTICK_THRESHOLD)
*state_cur |= x > 0 ? GX_CLASSIC_LSTICK_RIGHT : GX_CLASSIC_LSTICK_LEFT;
if (abs(y) > JOYSTICK_THRESHOLD)
*state_cur |= y > 0 ? GX_CLASSIC_LSTICK_UP : GX_CLASSIC_LSTICK_DOWN;
x = gx_stick_x(exp->classic.rjs);
y = gx_stick_y(exp->classic.rjs);
if (abs(x) > JOYSTICK_THRESHOLD)
*state_cur |= x > 0 ? GX_CLASSIC_RSTICK_RIGHT : GX_CLASSIC_RSTICK_LEFT;
if (abs(y) > JOYSTICK_THRESHOLD)
*state_cur |= y > 0 ? GX_CLASSIC_RSTICK_UP : GX_CLASSIC_RSTICK_DOWN;
}
else
{
u8 ls_x = exp->classic.ljs.pos.x;
u8 ls_y = exp->classic.ljs.pos.y;
u8 rs_x = exp->classic.rjs.pos.x;
u8 rs_y = exp->classic.rjs.pos.y;
*state_cur |= (ls_x > 40) ? GX_CLASSIC_LSTICK_RIGHT : 0;
*state_cur |= (ls_x < 25) ? GX_CLASSIC_LSTICK_LEFT : 0;
*state_cur |= (ls_y > 45) ? GX_CLASSIC_LSTICK_UP : 0;
*state_cur |= (ls_y < 20) ? GX_CLASSIC_LSTICK_DOWN : 0;
*state_cur |= (rs_x > 40) ? GX_CLASSIC_RSTICK_RIGHT : 0;
*state_cur |= (rs_x < 25) ? GX_CLASSIC_RSTICK_LEFT: 0;
*state_cur |= (rs_y > 45) ? GX_CLASSIC_RSTICK_UP : 0;
*state_cur |= (rs_y < 20) ? GX_CLASSIC_RSTICK_DOWN : 0;
}
}
else if (type == WPAD_EXP_NUNCHUK)
{
// wiimote is held upright with nunchuk, do not change d-pad orientation
*state_cur |= (down & WPAD_BUTTON_UP) ? GX_WIIMOTE_UP : 0;
*state_cur |= (down & WPAD_BUTTON_DOWN) ? GX_WIIMOTE_DOWN : 0;
*state_cur |= (down & WPAD_BUTTON_LEFT) ? GX_WIIMOTE_LEFT : 0;
*state_cur |= (down & WPAD_BUTTON_RIGHT) ? GX_WIIMOTE_RIGHT : 0;
*state_cur |= (down & WPAD_NUNCHUK_BUTTON_Z) ? GX_NUNCHUK_Z : 0;
*state_cur |= (down & WPAD_NUNCHUK_BUTTON_C) ? GX_NUNCHUK_C : 0;
s8 x = gx_stick_x(exp->nunchuk.js);
s8 y = gx_stick_y(exp->nunchuk.js);
if (abs(x) > JOYSTICK_THRESHOLD)
*state_cur |= x > 0 ? GX_CLASSIC_LSTICK_RIGHT : GX_CLASSIC_LSTICK_LEFT;
*state_cur |= x > 0 ? GX_NUNCHUK_RIGHT : GX_NUNCHUK_LEFT;
if (abs(y) > JOYSTICK_THRESHOLD)
*state_cur |= y > 0 ? GX_CLASSIC_LSTICK_UP : GX_CLASSIC_LSTICK_DOWN;
x = gx_stick_x(exp->classic.rjs);
y = gx_stick_y(exp->classic.rjs);
if (abs(x) > JOYSTICK_THRESHOLD)
*state_cur |= x > 0 ? GX_CLASSIC_RSTICK_RIGHT : GX_CLASSIC_RSTICK_LEFT;
if (abs(y) > JOYSTICK_THRESHOLD)
*state_cur |= y > 0 ? GX_CLASSIC_RSTICK_UP : GX_CLASSIC_RSTICK_DOWN;
}
else
{
u8 ls_x = exp->classic.ljs.pos.x;
u8 ls_y = exp->classic.ljs.pos.y;
u8 rs_x = exp->classic.rjs.pos.x;
u8 rs_y = exp->classic.rjs.pos.y;
*state_cur |= (ls_x > 40) ? GX_CLASSIC_LSTICK_RIGHT : 0;
*state_cur |= (ls_x < 25) ? GX_CLASSIC_LSTICK_LEFT : 0;
*state_cur |= (ls_y > 45) ? GX_CLASSIC_LSTICK_UP : 0;
*state_cur |= (ls_y < 20) ? GX_CLASSIC_LSTICK_DOWN : 0;
*state_cur |= (rs_x > 40) ? GX_CLASSIC_RSTICK_RIGHT : 0;
*state_cur |= (rs_x < 25) ? GX_CLASSIC_RSTICK_LEFT: 0;
*state_cur |= (rs_y > 45) ? GX_CLASSIC_RSTICK_UP : 0;
*state_cur |= (rs_y < 20) ? GX_CLASSIC_RSTICK_DOWN : 0;
*state_cur |= y > 0 ? GX_NUNCHUK_UP : GX_NUNCHUK_DOWN;
}
}
else if (type == WPAD_EXP_NUNCHUK)
{
// wiimote is held upright with nunchuk, do not change d-pad orientation
*state_cur |= (down & WPAD_BUTTON_UP) ? GX_WIIMOTE_UP : 0;
*state_cur |= (down & WPAD_BUTTON_DOWN) ? GX_WIIMOTE_DOWN : 0;
*state_cur |= (down & WPAD_BUTTON_LEFT) ? GX_WIIMOTE_LEFT : 0;
*state_cur |= (down & WPAD_BUTTON_RIGHT) ? GX_WIIMOTE_RIGHT : 0;
*state_cur |= (down & WPAD_NUNCHUK_BUTTON_Z) ? GX_NUNCHUK_Z : 0;
*state_cur |= (down & WPAD_NUNCHUK_BUTTON_C) ? GX_NUNCHUK_C : 0;
s8 x = gx_stick_x(exp->nunchuk.js);
s8 y = gx_stick_y(exp->nunchuk.js);
if (abs(x) > JOYSTICK_THRESHOLD)
*state_cur |= x > 0 ? GX_NUNCHUK_RIGHT : GX_NUNCHUK_LEFT;
if (abs(y) > JOYSTICK_THRESHOLD)
*state_cur |= y > 0 ? GX_NUNCHUK_UP : GX_NUNCHUK_DOWN;
}
#endif
if (!(SI_GetType(port) & SI_TYPE_GC))
continue;
if (SI_GetType(port) & SI_TYPE_GC)
{
down = PAD_ButtonsHeld(port);
down = PAD_ButtonsHeld(port);
*state_cur |= (down & PAD_BUTTON_A) ? GX_GC_A : 0;
*state_cur |= (down & PAD_BUTTON_B) ? GX_GC_B : 0;
*state_cur |= (down & PAD_BUTTON_X) ? GX_GC_X : 0;
*state_cur |= (down & PAD_BUTTON_Y) ? GX_GC_Y : 0;
*state_cur |= (down & PAD_BUTTON_UP) ? GX_GC_UP : 0;
*state_cur |= (down & PAD_BUTTON_DOWN) ? GX_GC_DOWN : 0;
*state_cur |= (down & PAD_BUTTON_LEFT) ? GX_GC_LEFT : 0;
*state_cur |= (down & PAD_BUTTON_RIGHT) ? GX_GC_RIGHT : 0;
*state_cur |= (down & PAD_BUTTON_START) ? GX_GC_START : 0;
*state_cur |= (down & PAD_TRIGGER_Z) ? GX_GC_Z_TRIGGER : 0;
*state_cur |= ((down & PAD_TRIGGER_L) || PAD_TriggerL(port) > 127) ? GX_GC_L_TRIGGER : 0;
*state_cur |= ((down & PAD_TRIGGER_R) || PAD_TriggerR(port) > 127) ? GX_GC_R_TRIGGER : 0;
*state_cur |= (down & PAD_BUTTON_A) ? GX_GC_A : 0;
*state_cur |= (down & PAD_BUTTON_B) ? GX_GC_B : 0;
*state_cur |= (down & PAD_BUTTON_X) ? GX_GC_X : 0;
*state_cur |= (down & PAD_BUTTON_Y) ? GX_GC_Y : 0;
*state_cur |= (down & PAD_BUTTON_UP) ? GX_GC_UP : 0;
*state_cur |= (down & PAD_BUTTON_DOWN) ? GX_GC_DOWN : 0;
*state_cur |= (down & PAD_BUTTON_LEFT) ? GX_GC_LEFT : 0;
*state_cur |= (down & PAD_BUTTON_RIGHT) ? GX_GC_RIGHT : 0;
*state_cur |= (down & PAD_BUTTON_START) ? GX_GC_START : 0;
*state_cur |= (down & PAD_TRIGGER_Z) ? GX_GC_Z_TRIGGER : 0;
*state_cur |= ((down & PAD_TRIGGER_L) || PAD_TriggerL(port) > 127) ? GX_GC_L_TRIGGER : 0;
*state_cur |= ((down & PAD_TRIGGER_R) || PAD_TriggerR(port) > 127) ? GX_GC_R_TRIGGER : 0;
s8 x = PAD_StickX(port);
s8 y = PAD_StickY(port);
s8 x = PAD_StickX(port);
s8 y = PAD_StickY(port);
if (abs(x) > JOYSTICK_THRESHOLD)
*state_cur |= x > 0 ? GX_GC_LSTICK_RIGHT : GX_GC_LSTICK_LEFT;
if (abs(y) > JOYSTICK_THRESHOLD)
*state_cur |= y > 0 ? GX_GC_LSTICK_UP : GX_GC_LSTICK_DOWN;
if (abs(x) > JOYSTICK_THRESHOLD)
*state_cur |= x > 0 ? GX_GC_LSTICK_RIGHT : GX_GC_LSTICK_LEFT;
if (abs(y) > JOYSTICK_THRESHOLD)
*state_cur |= y > 0 ? GX_GC_LSTICK_UP : GX_GC_LSTICK_DOWN;
x = PAD_SubStickX(port);
y = PAD_SubStickY(port);
x = PAD_SubStickX(port);
y = PAD_SubStickY(port);
if (abs(x) > JOYSTICK_THRESHOLD)
*state_cur |= x > 0 ? GX_GC_RSTICK_RIGHT : GX_GC_RSTICK_LEFT;
if (abs(y) > JOYSTICK_THRESHOLD)
*state_cur |= y > 0 ? GX_GC_RSTICK_UP : GX_GC_RSTICK_DOWN;
if (abs(x) > JOYSTICK_THRESHOLD)
*state_cur |= x > 0 ? GX_GC_RSTICK_RIGHT : GX_GC_RSTICK_LEFT;
if (abs(y) > JOYSTICK_THRESHOLD)
*state_cur |= y > 0 ? GX_GC_RSTICK_UP : GX_GC_RSTICK_DOWN;
if ((*state_cur & (GX_GC_LSTICK_DOWN | GX_GC_RSTICK_DOWN | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER)) == (GX_GC_LSTICK_DOWN | GX_GC_RSTICK_DOWN | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER))
*state_cur |= GX_QUIT_KEY;
if ((*state_cur & (GX_GC_LSTICK_DOWN | GX_GC_RSTICK_DOWN | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER)) == (GX_GC_LSTICK_DOWN | GX_GC_RSTICK_DOWN | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER))
*state_cur |= GX_QUIT_KEY;
if ((*state_cur & (GX_GC_LSTICK_UP | GX_GC_RSTICK_UP | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER)) == (GX_GC_LSTICK_UP | GX_GC_RSTICK_UP | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER))
*state_cur |= GX_WIIMOTE_HOME;
if ((*state_cur & (GX_GC_LSTICK_UP | GX_GC_RSTICK_UP | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER)) == (GX_GC_LSTICK_UP | GX_GC_RSTICK_UP | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER))
*state_cur |= GX_WIIMOTE_HOME;
}
}
uint64_t *lifecycle_state = &g_extern.lifecycle_state;

View File

@ -1023,4 +1023,5 @@ const video_driver_t video_gx = {
.stop = gx_stop,
.restart = gx_restart,
.apply_state_changes = gx_apply_state_changes,
.set_aspect_ratio = gx_set_aspect_ratio
};