(Wii) Menu now takes input again from Gamecube pad, Wiimote, Wiimote + Classic

and Nunchuk
This commit is contained in:
twinaphex 2013-12-12 20:50:13 +01:00
parent a35396840f
commit 21ae4c24af
5 changed files with 78 additions and 25 deletions

View File

@ -30,6 +30,10 @@
#include "config.h"
#endif
#ifdef HW_RVL
#include "gx/gx_input.h"
#endif
enum
{
VIDEO_GL = 0,
@ -674,6 +678,68 @@ static const struct retro_keybind retro_keybinds_1[] = {
#endif
};
#ifdef HW_RVL
static const struct retro_keybind retro_keybinds_menu[] = {
{ true, RETRO_DEVICE_ID_JOYPAD_B, NULL, 0, GX_GC_B | GX_CLASSIC_B | GX_WIIMOTE_B | GX_WIIMOTE_1, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_Y, NULL, 0, GX_GC_Y | GX_CLASSIC_Y, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_SELECT, NULL, 0, GX_GC_Z_TRIGGER | GX_CLASSIC_MINUS | GX_WIIMOTE_MINUS, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_START, NULL, 0, GX_GC_START | GX_CLASSIC_PLUS | GX_WIIMOTE_PLUS, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_UP, NULL, 0, GX_GC_UP | GX_CLASSIC_UP | GX_WIIMOTE_UP | GX_NUNCHUK_UP, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_DOWN, NULL, 0, GX_GC_DOWN | GX_CLASSIC_DOWN | GX_WIIMOTE_DOWN | GX_NUNCHUK_DOWN, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_LEFT, NULL, 0, GX_GC_LEFT | GX_CLASSIC_LEFT | GX_WIIMOTE_LEFT | GX_NUNCHUK_LEFT, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_RIGHT, NULL, 0, GX_GC_RIGHT | GX_CLASSIC_RIGHT | GX_WIIMOTE_RIGHT | GX_NUNCHUK_RIGHT, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_A, NULL, 0, GX_GC_A | GX_CLASSIC_A | GX_WIIMOTE_A | GX_WIIMOTE_2, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_X, NULL, 0, GX_GC_X | GX_CLASSIC_X, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_L, NULL, 0, GX_GC_L_TRIGGER | GX_CLASSIC_L_TRIGGER, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_R, NULL, 0, GX_GC_R_TRIGGER | GX_CLASSIC_R_TRIGGER, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_L2, NULL, 0, GX_CLASSIC_ZL_TRIGGER, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_R2, NULL, 0, GX_CLASSIC_ZR_TRIGGER, 0 },
{ true, RETRO_DEVICE_ID_JOYPAD_L3, RETRO_LBL_JOYPAD_L3, RETROK_UNKNOWN, RETRO_DEF_JOYPAD_L3, 0, AXIS_NONE },
{ true, RETRO_DEVICE_ID_JOYPAD_R3, RETRO_LBL_JOYPAD_R3, RETROK_UNKNOWN, RETRO_DEF_JOYPAD_R3, 0, AXIS_NONE },
{ true, RARCH_ANALOG_LEFT_X_PLUS, RETRO_LBL_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_ANALOG_LEFT_X_MINUS, RETRO_LBL_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_ANALOG_LEFT_Y_PLUS, RETRO_LBL_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_ANALOG_LEFT_Y_MINUS, RETRO_LBL_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_ANALOG_RIGHT_X_PLUS, RETRO_LBL_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_ANALOG_RIGHT_X_MINUS, RETRO_LBL_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_ANALOG_RIGHT_Y_PLUS, RETRO_LBL_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_ANALOG_RIGHT_Y_MINUS, RETRO_LBL_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_TURBO_ENABLE, RETRO_LBL_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_FAST_FORWARD_KEY, RETRO_LBL_FAST_FORWARD_KEY, RETROK_SPACE, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_FAST_FORWARD_HOLD_KEY, RETRO_LBL_FAST_FORWARD_HOLD_KEY,RETROK_l, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_LOAD_STATE_KEY, RETRO_LBL_LOAD_STATE_KEY, RETROK_F4, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_SAVE_STATE_KEY, RETRO_LBL_SAVE_STATE_KEY, RETROK_F2, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_FULLSCREEN_TOGGLE_KEY, RETRO_LBL_FULLSCREEN_TOGGLE_KEY,RETROK_f, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_QUIT_KEY, RETRO_LBL_QUIT_KEY, RETROK_ESCAPE, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_STATE_SLOT_PLUS, RETRO_LBL_STATE_SLOT_PLUS, RETROK_F7, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_STATE_SLOT_MINUS, RETRO_LBL_STATE_SLOT_MINUS, RETROK_F6, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_REWIND, RETRO_LBL_REWIND, RETROK_r, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_MOVIE_RECORD_TOGGLE, RETRO_LBL_MOVIE_RECORD_TOGGLE, RETROK_o, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_PAUSE_TOGGLE, RETRO_LBL_PAUSE_TOGGLE, RETROK_p, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_FRAMEADVANCE, RETRO_LBL_FRAMEADVANCE, RETROK_k, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_RESET, RETRO_LBL_RESET, RETROK_h, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_SHADER_NEXT, RETRO_LBL_SHADER_NEXT, RETROK_m, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_SHADER_PREV, RETRO_LBL_SHADER_PREV, RETROK_n, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_CHEAT_INDEX_PLUS, RETRO_LBL_CHEAT_INDEX_PLUS, RETROK_y, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_CHEAT_INDEX_MINUS, RETRO_LBL_CHEAT_INDEX_MINUS, RETROK_t, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_CHEAT_TOGGLE, RETRO_LBL_CHEAT_TOGGLE, RETROK_u, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_SCREENSHOT, RETRO_LBL_SCREENSHOT, RETROK_F8, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_DSP_CONFIG, RETRO_LBL_DSP_CONFIG, RETROK_c, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_MUTE, RETRO_LBL_MUTE, RETROK_F9, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_NETPLAY_FLIP, RETRO_LBL_NETPLAY_FLIP, RETROK_i, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_SLOWMOTION, RETRO_LBL_SLOWMOTION, RETROK_e, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_ENABLE_HOTKEY, RETRO_LBL_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_VOLUME_UP, RETRO_LBL_VOLUME_UP, RETROK_KP_PLUS, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_VOLUME_DOWN, RETRO_LBL_VOLUME_DOWN, RETROK_KP_MINUS,NO_BTN, 0, AXIS_NONE },
{ 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_GRAB_MOUSE_TOGGLE, RETRO_LBL_GRAB_MOUSE_TOGGLE, RETROK_F11, NO_BTN, 0, AXIS_NONE },
{ true, RARCH_MENU_TOGGLE, NULL, 0, GX_WIIMOTE_HOME | GX_CLASSIC_HOME, 0 },
};
#endif
// Player 2-5
static const struct retro_keybind retro_keybinds_rest[] = {
// | RetroPad button | desc | keyboard key | js btn | js axis |

View File

@ -475,7 +475,7 @@ static uint64_t menu_input(void)
unsigned i;
uint64_t input_state = 0;
static const struct retro_keybind *binds[] = { g_settings.input.binds[0] };
static const struct retro_keybind *binds[] = { g_settings.input.menu_binds };
for (i = 0; i < RETRO_DEVICE_ID_JOYPAD_R2; i++)
{

View File

@ -222,6 +222,7 @@ struct settings
char joypad_driver[32];
char keyboard_layout[64];
struct retro_keybind binds[MAX_PLAYERS][RARCH_BIND_LIST_END];
struct retro_keybind menu_binds[RARCH_BIND_LIST_END];
// Set by autoconfiguration in joypad_autoconfig_dir. Does not override main binds.
struct retro_keybind autoconf_binds[MAX_PLAYERS][RARCH_BIND_LIST_END];

View File

@ -40,9 +40,6 @@
typedef struct gx_input
{
uint32_t pad_connect[MAX_PADS];
uint32_t pad_type[MAX_PADS];
uint32_t pad_detect_pending[MAX_PADS];
uint64_t pad_state[MAX_PADS];
int16_t analog_state[MAX_PADS][2][2];
} gx_input_t;
@ -146,7 +143,6 @@ static void power_callback(void)
static void gx_input_set_keybinds(void *data, unsigned device, unsigned port,
unsigned id, unsigned keybind_action)
{
gx_input_t *gx = (gx_input_t*)data;
uint64_t *key = &g_settings.input.binds[port][id].joykey;
size_t arr_size = sizeof(platform_keys) / sizeof(platform_keys[0]);
@ -270,8 +266,6 @@ static void gx_input_set_keybinds(void *data, unsigned device, unsigned port,
strlcpy(ret->desc, "Unknown", sizeof(ret->desc));
}
}
gx->pad_detect_pending[port] = 1;
}
static void *gx_input_init(void)
@ -280,13 +274,6 @@ static void *gx_input_init(void)
if (!gx)
return NULL;
for (unsigned i = 0; i < MAX_PADS; i++)
{
gx->pad_connect[i] = 0;
gx->pad_type[i] = 0;
gx->pad_detect_pending[i] = 1;
}
PAD_Init();
#ifdef HW_RVL
WPAD_Init();
@ -324,15 +311,8 @@ static void gx_input_poll(void *data)
uint64_t *state_cur = &gx->pad_state[port];
#ifdef HW_RVL
if (gx->pad_detect_pending[port])
{
uint32_t *ptype = &gx->pad_type[port];
gx->pad_connect[port] = WPAD_Probe(port, ptype);
gx->pad_detect_pending[port] = 0;
}
uint32_t connected = gx->pad_connect[port];
uint32_t type = gx->pad_type[port];
uint32_t ptype = 0;
uint32_t connected = WPAD_Probe(port, &ptype);
if (connected == WPAD_ERR_NONE)
{
@ -355,7 +335,7 @@ static void gx_input_poll(void *data)
expansion_t *exp = &wpaddata->exp;
if (type == WPAD_EXP_CLASSIC)
if (ptype == WPAD_EXP_CLASSIC)
{
*state_cur |= (down & WPAD_CLASSIC_BUTTON_A) ? GX_CLASSIC_A : 0;
*state_cur |= (down & WPAD_CLASSIC_BUTTON_B) ? GX_CLASSIC_B : 0;
@ -406,7 +386,7 @@ static void gx_input_poll(void *data)
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = rs_x;
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = rs_y;
}
else if (type == WPAD_EXP_NUNCHUK)
else if (ptype == 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;

View File

@ -184,6 +184,7 @@ const char *config_get_default_camera(void)
}
#endif
void config_set_defaults(void)
{
unsigned i, j;
@ -283,6 +284,11 @@ void config_set_defaults(void)
rarch_assert(sizeof(g_settings.input.binds[0]) >= sizeof(retro_keybinds_1));
rarch_assert(sizeof(g_settings.input.binds[1]) >= sizeof(retro_keybinds_rest));
memcpy(g_settings.input.binds[0], retro_keybinds_1, sizeof(retro_keybinds_1));
#ifdef HW_RVL
memcpy(g_settings.input.menu_binds, retro_keybinds_menu, sizeof(retro_keybinds_menu));
#else
memcpy(g_settings.input.menu_binds, retro_keybinds_1, sizeof(retro_keybinds_1));
#endif
for (i = 1; i < MAX_PLAYERS; i++)
memcpy(g_settings.input.binds[i], retro_keybinds_rest, sizeof(retro_keybinds_rest));