mirror of
https://github.com/libretro/RetroArch
synced 2025-01-26 09:35:21 +00:00
(Wii) use input driver for menu
This commit is contained in:
parent
30b77de46c
commit
02ee5b7948
@ -1,5 +1,6 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2012 - Michael Lelli
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
@ -41,16 +42,20 @@ FILE * log_fp;
|
||||
|
||||
static uint16_t menu_framebuf[RGUI_WIDTH * RGUI_HEIGHT];
|
||||
|
||||
static const uint64_t wii_nav_buttons[9] = {
|
||||
WII_GC_UP | WII_GC_LSTICK_UP | WII_GC_RSTICK_UP | WII_CLASSIC_UP | WII_CLASSIC_LSTICK_UP | WII_CLASSIC_RSTICK_UP | WII_WIIMOTE_UP | WII_NUNCHUK_UP,
|
||||
WII_GC_DOWN | WII_GC_LSTICK_DOWN | WII_GC_RSTICK_DOWN | WII_CLASSIC_DOWN | WII_CLASSIC_LSTICK_DOWN | WII_CLASSIC_RSTICK_DOWN | WII_WIIMOTE_DOWN | WII_NUNCHUK_DOWN,
|
||||
WII_GC_LEFT | WII_GC_LSTICK_LEFT | WII_GC_RSTICK_LEFT | WII_CLASSIC_LEFT | WII_CLASSIC_LSTICK_LEFT | WII_CLASSIC_RSTICK_LEFT | WII_WIIMOTE_LEFT | WII_NUNCHUK_LEFT,
|
||||
WII_GC_RIGHT | WII_GC_LSTICK_RIGHT | WII_GC_RSTICK_RIGHT | WII_CLASSIC_RIGHT | WII_CLASSIC_LSTICK_RIGHT | WII_CLASSIC_RSTICK_RIGHT | WII_WIIMOTE_RIGHT | WII_NUNCHUK_RIGHT,
|
||||
WII_GC_A | WII_CLASSIC_A | WII_WIIMOTE_A | WII_WIIMOTE_2,
|
||||
WII_GC_B | WII_CLASSIC_B | WII_WIIMOTE_B | WII_WIIMOTE_1,
|
||||
WII_GC_START | WII_CLASSIC_PLUS | WII_WIIMOTE_PLUS,
|
||||
WII_GC_Z_TRIGGER | WII_CLASSIC_MINUS | WII_WIIMOTE_MINUS,
|
||||
WII_WIIMOTE_HOME | WII_CLASSIC_HOME,
|
||||
static const struct retro_keybind _wii_nav_binds[] = {
|
||||
{ 0, 0, 0, WII_GC_UP | WII_GC_LSTICK_UP | WII_GC_RSTICK_UP | WII_CLASSIC_UP | WII_CLASSIC_LSTICK_UP | WII_CLASSIC_RSTICK_UP | WII_WIIMOTE_UP | WII_NUNCHUK_UP, 0 },
|
||||
{ 0, 0, 0, WII_GC_DOWN | WII_GC_LSTICK_DOWN | WII_GC_RSTICK_DOWN | WII_CLASSIC_DOWN | WII_CLASSIC_LSTICK_DOWN | WII_CLASSIC_RSTICK_DOWN | WII_WIIMOTE_DOWN | WII_NUNCHUK_DOWN, 0 },
|
||||
{ 0, 0, 0, WII_GC_LEFT | WII_GC_LSTICK_LEFT | WII_GC_RSTICK_LEFT | WII_CLASSIC_LEFT | WII_CLASSIC_LSTICK_LEFT | WII_CLASSIC_RSTICK_LEFT | WII_WIIMOTE_LEFT | WII_NUNCHUK_LEFT, 0 },
|
||||
{ 0, 0, 0, WII_GC_RIGHT | WII_GC_LSTICK_RIGHT | WII_GC_RSTICK_RIGHT | WII_CLASSIC_RIGHT | WII_CLASSIC_LSTICK_RIGHT | WII_CLASSIC_RSTICK_RIGHT | WII_WIIMOTE_RIGHT | WII_NUNCHUK_RIGHT, 0 },
|
||||
{ 0, 0, 0, WII_GC_A | WII_CLASSIC_A | WII_WIIMOTE_A | WII_WIIMOTE_2, 0 },
|
||||
{ 0, 0, 0, WII_GC_B | WII_CLASSIC_B | WII_WIIMOTE_B | WII_WIIMOTE_1, 0 },
|
||||
{ 0, 0, 0, WII_GC_START | WII_CLASSIC_PLUS | WII_WIIMOTE_PLUS, 0 },
|
||||
{ 0, 0, 0, WII_GC_Z_TRIGGER | WII_CLASSIC_MINUS | WII_WIIMOTE_MINUS, 0 },
|
||||
{ 0, 0, 0, WII_WIIMOTE_HOME | WII_CLASSIC_HOME, 0 },
|
||||
};
|
||||
|
||||
static const struct retro_keybind *wii_nav_binds[] = {
|
||||
_wii_nav_binds
|
||||
};
|
||||
|
||||
enum
|
||||
@ -64,6 +69,7 @@ enum
|
||||
WII_DEVICE_NAV_START,
|
||||
WII_DEVICE_NAV_SELECT,
|
||||
WII_DEVICE_NAV_EXIT,
|
||||
WII_DEVICE_NAV_LAST
|
||||
};
|
||||
|
||||
static bool folder_cb(const char *directory, rgui_file_enum_cb_t file_cb,
|
||||
@ -118,15 +124,19 @@ static bool get_rom_path(rgui_handle_t *rgui)
|
||||
for (;;)
|
||||
{
|
||||
uint16_t input_state = 0;
|
||||
uint64_t input_poll = wii_input_update(0);
|
||||
|
||||
for (unsigned i = 0; i < sizeof(wii_nav_buttons) / sizeof(wii_nav_buttons[0]); i++)
|
||||
input_wii.poll(NULL);
|
||||
|
||||
for (unsigned i = 0; i < WII_DEVICE_NAV_LAST; i++)
|
||||
{
|
||||
input_state |= input_poll & wii_nav_buttons[i] ? (1 << i) : 0;
|
||||
input_state |= input_wii.input_state(NULL, wii_nav_binds, 0,
|
||||
RETRO_DEVICE_JOYPAD, 0, i) ? (1 << i) : 0;
|
||||
}
|
||||
|
||||
uint16_t trigger_state = input_state & ~old_input_state;
|
||||
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 << WII_DEVICE_NAV_EXIT))
|
||||
@ -136,9 +146,7 @@ static bool get_rom_path(rgui_handle_t *rgui)
|
||||
}
|
||||
else
|
||||
can_quit = true;
|
||||
}
|
||||
|
||||
rgui_action_t action = RGUI_ACTION_NOOP;
|
||||
if (trigger_state & (1 << WII_DEVICE_NAV_B))
|
||||
action = RGUI_ACTION_CANCEL;
|
||||
else if (trigger_state & (1 << WII_DEVICE_NAV_A))
|
||||
@ -153,8 +161,13 @@ static bool get_rom_path(rgui_handle_t *rgui)
|
||||
action = RGUI_ACTION_RIGHT;
|
||||
else if (trigger_state & (1 << WII_DEVICE_NAV_START))
|
||||
action = RGUI_ACTION_START;
|
||||
else if (trigger_state & (1 << WII_DEVICE_NAV_SELECT) && !first) // don't catch start+select+l+r when exiting
|
||||
else if (trigger_state & (1 << WII_DEVICE_NAV_SELECT))
|
||||
action = RGUI_ACTION_SETTINGS;
|
||||
}
|
||||
else
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
|
||||
const char *ret = rgui_iterate(rgui, action);
|
||||
video_wii.frame(NULL, menu_framebuf,
|
||||
@ -170,7 +183,6 @@ static bool get_rom_path(rgui_handle_t *rgui)
|
||||
}
|
||||
|
||||
old_input_state = input_state;
|
||||
first = false;
|
||||
rarch_sleep(10);
|
||||
}
|
||||
}
|
||||
|
27
wii/input.c
27
wii/input.c
@ -1,5 +1,6 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2012 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2012 - Michael Lelli
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
@ -192,12 +193,17 @@ static void *wii_input_initialize(void)
|
||||
#define wii_stick_x(x) ((s8)((sin((x).ang * M_PI / 180.0f)) * (x).mag * 128.0f))
|
||||
#define wii_stick_y(x) ((s8)((cos((x).ang * M_PI / 180.0f)) * (x).mag * 128.0f))
|
||||
|
||||
uint64_t wii_input_update(unsigned port)
|
||||
static void wii_input_poll(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
unsigned pads = PAD_ScanPads();
|
||||
#ifdef HW_RVL
|
||||
unsigned wpads = WPAD_ScanPads();
|
||||
#endif
|
||||
|
||||
for (unsigned port = 0; port < 4; port++)
|
||||
{
|
||||
uint64_t state = 0;
|
||||
if (port < pads)
|
||||
{
|
||||
@ -339,23 +345,14 @@ uint64_t wii_input_update(unsigned port)
|
||||
state |= WII_WIIMOTE_HOME;
|
||||
}
|
||||
|
||||
if (port == 0 && g_quit)
|
||||
pad_state[port] = state;
|
||||
}
|
||||
|
||||
if (g_quit)
|
||||
{
|
||||
state |= WII_WIIMOTE_HOME;
|
||||
pad_state[0] |= WII_WIIMOTE_HOME;
|
||||
g_quit = false;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
static void wii_input_poll(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
for (unsigned i = 0; i < 4; i++)
|
||||
{
|
||||
pad_state[i] = wii_input_update(i);
|
||||
}
|
||||
}
|
||||
|
||||
static bool wii_key_pressed(void *data, int key)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2012 - Michael Lelli
|
||||
* Copyright (C) 2012 - Michael Lelli
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
@ -173,6 +173,4 @@ enum wii_device_id
|
||||
RARCH_LAST_PLATFORM_KEY
|
||||
};
|
||||
|
||||
uint64_t wii_input_update(unsigned port);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user