mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
Merge branch 'menu_input'
This commit is contained in:
commit
1b6e7da2ce
@ -697,14 +697,14 @@ uint64_t input_menu_keys_pressed(void)
|
|||||||
if (
|
if (
|
||||||
(((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY)))
|
(((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY)))
|
||||||
|| !input_driver_block_hotkey) && current_input->key_pressed)
|
|| !input_driver_block_hotkey) && current_input->key_pressed)
|
||||||
#if 0
|
#if 1
|
||||||
&& settings->input.binds[0][i].valid
|
&& settings->input.binds[0][i].valid
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int port;
|
int port;
|
||||||
int port_max = 1;
|
int port_max = 1;
|
||||||
#if 0
|
#if 1
|
||||||
if (settings->input.all_users_control_menu)
|
if (settings->input.all_users_control_menu)
|
||||||
port_max = settings->input.max_users;
|
port_max = settings->input.max_users;
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "menu_driver.h"
|
#include "menu_driver.h"
|
||||||
#include "menu_cbs.h"
|
#include "menu_cbs.h"
|
||||||
#include "menu_display.h"
|
#include "menu_display.h"
|
||||||
|
#include "menu_event.h"
|
||||||
#include "menu_navigation.h"
|
#include "menu_navigation.h"
|
||||||
#include "widgets/menu_dialog.h"
|
#include "widgets/menu_dialog.h"
|
||||||
#include "widgets/menu_list.h"
|
#include "widgets/menu_list.h"
|
||||||
@ -221,8 +222,12 @@ static void menu_input_key_event(bool down, unsigned keycode,
|
|||||||
(void)keycode;
|
(void)keycode;
|
||||||
(void)mod;
|
(void)mod;
|
||||||
|
|
||||||
if (character == '/')
|
#if 1
|
||||||
menu_entry_action(NULL, 0, MENU_ACTION_SEARCH);
|
RARCH_LOG("down: %d, keycode: %d, mod: %d, character: %d\n", down, keycode, mod, character);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (down)
|
||||||
|
menu_event_keyboard_set((enum retro_key)keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void menu_driver_toggle(bool latch)
|
static void menu_driver_toggle(bool latch)
|
||||||
|
@ -28,13 +28,20 @@
|
|||||||
|
|
||||||
#include "menu_event.h"
|
#include "menu_event.h"
|
||||||
|
|
||||||
|
#include "content.h"
|
||||||
#include "menu_driver.h"
|
#include "menu_driver.h"
|
||||||
#include "menu_input.h"
|
#include "menu_input.h"
|
||||||
#include "menu_animation.h"
|
#include "menu_animation.h"
|
||||||
#include "menu_display.h"
|
#include "menu_display.h"
|
||||||
#include "menu_navigation.h"
|
#include "menu_navigation.h"
|
||||||
|
|
||||||
|
#include "widgets/menu_dialog.h"
|
||||||
|
|
||||||
#include "../configuration.h"
|
#include "../configuration.h"
|
||||||
|
#include "../retroarch.h"
|
||||||
|
#include "../runloop.h"
|
||||||
|
|
||||||
|
static bool menu_keyboard_key_state[RETROK_LAST];
|
||||||
|
|
||||||
static int menu_event_pointer(unsigned *action)
|
static int menu_event_pointer(unsigned *action)
|
||||||
{
|
{
|
||||||
@ -65,8 +72,24 @@ static int menu_event_pointer(unsigned *action)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool menu_event_keyboard_is_set(enum retro_key key)
|
||||||
|
{
|
||||||
|
if (menu_keyboard_key_state[key] && key == RETROK_F1)
|
||||||
|
{
|
||||||
|
menu_keyboard_key_state[key] = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return menu_keyboard_key_state[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
void menu_event_keyboard_set(enum retro_key key)
|
||||||
|
{
|
||||||
|
menu_keyboard_key_state[key] = true;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned menu_event(uint64_t input, uint64_t trigger_input)
|
unsigned menu_event(uint64_t input, uint64_t trigger_input)
|
||||||
{
|
{
|
||||||
|
unsigned i;
|
||||||
menu_animation_ctx_delta_t delta;
|
menu_animation_ctx_delta_t delta;
|
||||||
float delta_time;
|
float delta_time;
|
||||||
/* Used for key repeat */
|
/* Used for key repeat */
|
||||||
@ -187,6 +210,60 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input)
|
|||||||
trigger_input = 0;
|
trigger_input = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < RETROK_LAST; i++)
|
||||||
|
{
|
||||||
|
if (i == RETROK_F1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (menu_keyboard_key_state[i])
|
||||||
|
{
|
||||||
|
switch ((enum retro_key)i)
|
||||||
|
{
|
||||||
|
case RETROK_ESCAPE:
|
||||||
|
BIT32_SET(trigger_input, RARCH_QUIT_KEY);
|
||||||
|
break;
|
||||||
|
case RETROK_f:
|
||||||
|
BIT32_SET(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY);
|
||||||
|
break;
|
||||||
|
case RETROK_F11:
|
||||||
|
BIT32_SET(trigger_input, RARCH_GRAB_MOUSE_TOGGLE);
|
||||||
|
break;
|
||||||
|
case RETROK_PAGEUP:
|
||||||
|
BIT32_SET(trigger_input, settings->menu_scroll_up_btn);
|
||||||
|
break;
|
||||||
|
case RETROK_PAGEDOWN:
|
||||||
|
BIT32_SET(trigger_input, settings->menu_scroll_down_btn);
|
||||||
|
break;
|
||||||
|
case RETROK_SLASH:
|
||||||
|
BIT32_SET(trigger_input, settings->menu_search_btn);
|
||||||
|
break;
|
||||||
|
case RETROK_LEFT:
|
||||||
|
BIT32_SET(trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT);
|
||||||
|
break;
|
||||||
|
case RETROK_RIGHT:
|
||||||
|
BIT32_SET(trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT);
|
||||||
|
break;
|
||||||
|
case RETROK_UP:
|
||||||
|
BIT32_SET(trigger_input, RETRO_DEVICE_ID_JOYPAD_UP);
|
||||||
|
break;
|
||||||
|
case RETROK_DOWN:
|
||||||
|
BIT32_SET(trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN);
|
||||||
|
break;
|
||||||
|
case RETROK_BACKSPACE:
|
||||||
|
BIT32_SET(trigger_input, settings->menu_cancel_btn);
|
||||||
|
break;
|
||||||
|
case RETROK_RETURN:
|
||||||
|
BIT32_SET(trigger_input, settings->menu_ok_btn);
|
||||||
|
break;
|
||||||
|
#if 0
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
menu_keyboard_key_state[i] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP))
|
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP))
|
||||||
ret = MENU_ACTION_UP;
|
ret = MENU_ACTION_UP;
|
||||||
else if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN))
|
else if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN))
|
||||||
@ -214,6 +291,40 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input)
|
|||||||
else if (trigger_input & (UINT64_C(1) << RARCH_MENU_TOGGLE))
|
else if (trigger_input & (UINT64_C(1) << RARCH_MENU_TOGGLE))
|
||||||
ret = MENU_ACTION_TOGGLE;
|
ret = MENU_ACTION_TOGGLE;
|
||||||
|
|
||||||
|
if (runloop_cmd_triggered(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY))
|
||||||
|
command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL);
|
||||||
|
|
||||||
|
if (runloop_cmd_triggered(trigger_input, RARCH_GRAB_MOUSE_TOGGLE))
|
||||||
|
command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL);
|
||||||
|
|
||||||
|
if (runloop_cmd_press(trigger_input, RARCH_QUIT_KEY))
|
||||||
|
{
|
||||||
|
int should_we_quit = true;
|
||||||
|
|
||||||
|
if (!runloop_is_quit_confirm())
|
||||||
|
{
|
||||||
|
if (settings && settings->confirm_on_exit)
|
||||||
|
{
|
||||||
|
if (menu_dialog_is_active())
|
||||||
|
should_we_quit = false;
|
||||||
|
else if (content_is_inited())
|
||||||
|
{
|
||||||
|
if(menu_display_toggle_get_reason() != MENU_TOGGLE_REASON_USER)
|
||||||
|
menu_display_toggle_set_reason(MENU_TOGGLE_REASON_MESSAGE);
|
||||||
|
rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu_dialog_show_message(MENU_DIALOG_QUIT_CONFIRM, MENU_ENUM_LABEL_CONFIRM_ON_EXIT);
|
||||||
|
|
||||||
|
should_we_quit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((settings && !settings->confirm_on_exit) ||
|
||||||
|
should_we_quit)
|
||||||
|
return MENU_ACTION_QUIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mouse_enabled = settings->menu.mouse.enable;
|
mouse_enabled = settings->menu.mouse.enable;
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
if (!mouse_enabled)
|
if (!mouse_enabled)
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include <retro_common_api.h>
|
#include <retro_common_api.h>
|
||||||
|
|
||||||
|
#include <libretro.h>
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
/* Send input code to menu for one frame.
|
/* Send input code to menu for one frame.
|
||||||
@ -33,6 +35,10 @@ RETRO_BEGIN_DECLS
|
|||||||
*/
|
*/
|
||||||
unsigned menu_event(uint64_t input, uint64_t trigger_state);
|
unsigned menu_event(uint64_t input, uint64_t trigger_state);
|
||||||
|
|
||||||
|
void menu_event_keyboard_set(enum retro_key key);
|
||||||
|
|
||||||
|
bool menu_event_keyboard_is_set(enum retro_key key);
|
||||||
|
|
||||||
unsigned kbd_index;
|
unsigned kbd_index;
|
||||||
char kbd_grid[41];
|
char kbd_grid[41];
|
||||||
bool kbd_upper;
|
bool kbd_upper;
|
||||||
|
@ -42,7 +42,8 @@ enum menu_action
|
|||||||
MENU_ACTION_SCROLL_UP,
|
MENU_ACTION_SCROLL_UP,
|
||||||
MENU_ACTION_TOGGLE,
|
MENU_ACTION_TOGGLE,
|
||||||
MENU_ACTION_POINTER_MOVED,
|
MENU_ACTION_POINTER_MOVED,
|
||||||
MENU_ACTION_POINTER_PRESSED
|
MENU_ACTION_POINTER_PRESSED,
|
||||||
|
MENU_ACTION_QUIT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum menu_input_pointer_state
|
enum menu_input_pointer_state
|
||||||
|
82
runloop.c
82
runloop.c
@ -88,16 +88,20 @@
|
|||||||
#define DEFAULT_EXT ""
|
#define DEFAULT_EXT ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define runloop_cmd_triggered(trigger_input, id) (BIT64_GET(trigger_input, id))
|
|
||||||
|
|
||||||
#define runloop_cmd_press(current_input, id) BIT64_GET(current_input, id)
|
|
||||||
#define runloop_cmd_pressed(old_input, id) BIT64_GET(old_input, id)
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
#define runloop_cmd_menu_press(current_input, old_input, trigger_input) (BIT64_GET(trigger_input, RARCH_MENU_TOGGLE) || \
|
#define runloop_cmd_menu_press(current_input, old_input, trigger_input) (BIT64_GET(trigger_input, RARCH_MENU_TOGGLE) || runloop_cmd_get_state_menu_toggle_button_combo(settings, current_input, old_input, trigger_input))
|
||||||
runloop_cmd_get_state_menu_toggle_button_combo( \
|
|
||||||
settings, current_input, old_input, trigger_input))
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum runloop_state
|
||||||
|
{
|
||||||
|
RUNLOOP_STATE_NONE = 0,
|
||||||
|
RUNLOOP_STATE_ITERATE,
|
||||||
|
RUNLOOP_STATE_SLEEP,
|
||||||
|
RUNLOOP_STATE_MENU_ITERATE,
|
||||||
|
RUNLOOP_STATE_END,
|
||||||
|
RUNLOOP_STATE_QUIT
|
||||||
|
};
|
||||||
|
|
||||||
static rarch_system_info_t runloop_system;
|
static rarch_system_info_t runloop_system;
|
||||||
static struct retro_frame_time_callback runloop_frame_time;
|
static struct retro_frame_time_callback runloop_frame_time;
|
||||||
static retro_keyboard_event_t runloop_key_event = NULL;
|
static retro_keyboard_event_t runloop_key_event = NULL;
|
||||||
@ -720,16 +724,6 @@ void runloop_set_quit_confirm(bool on)
|
|||||||
runloop_quit_confirm = on;
|
runloop_quit_confirm = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum runloop_state
|
|
||||||
{
|
|
||||||
RUNLOOP_STATE_NONE = 0,
|
|
||||||
RUNLOOP_STATE_ITERATE,
|
|
||||||
RUNLOOP_STATE_SLEEP,
|
|
||||||
RUNLOOP_STATE_MENU_ITERATE,
|
|
||||||
RUNLOOP_STATE_END,
|
|
||||||
RUNLOOP_STATE_QUIT
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Time to exit out of the main loop?
|
/* Time to exit out of the main loop?
|
||||||
* Reasons for exiting:
|
* Reasons for exiting:
|
||||||
* a) Shutdown environment callback was invoked.
|
* a) Shutdown environment callback was invoked.
|
||||||
@ -801,6 +795,10 @@ static INLINE int runloop_iterate_time_to_exit(bool quit_key_pressed)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void runloop_external_state_checks(uint64_t trigger_input)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static enum runloop_state runloop_check_state(
|
static enum runloop_state runloop_check_state(
|
||||||
settings_t *settings,
|
settings_t *settings,
|
||||||
uint64_t current_input,
|
uint64_t current_input,
|
||||||
@ -852,23 +850,6 @@ static enum runloop_state runloop_check_state(
|
|||||||
if (runloop_cmd_triggered(trigger_input, RARCH_GRAB_MOUSE_TOGGLE))
|
if (runloop_cmd_triggered(trigger_input, RARCH_GRAB_MOUSE_TOGGLE))
|
||||||
command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL);
|
command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL);
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
|
||||||
if (runloop_cmd_menu_press(current_input, old_input, trigger_input) ||
|
|
||||||
rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
|
||||||
{
|
|
||||||
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
|
||||||
{
|
|
||||||
if (rarch_ctl(RARCH_CTL_IS_INITED, NULL) &&
|
|
||||||
!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
|
||||||
rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
menu_display_toggle_set_reason(MENU_TOGGLE_REASON_USER);
|
|
||||||
rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
if (osk_enable && !input_keyboard_ctl(
|
if (osk_enable && !input_keyboard_ctl(
|
||||||
@ -914,18 +895,43 @@ static enum runloop_state runloop_check_state(
|
|||||||
if (focused || !runloop_idle)
|
if (focused || !runloop_idle)
|
||||||
menu_driver_ctl(RARCH_MENU_CTL_RENDER, NULL);
|
menu_driver_ctl(RARCH_MENU_CTL_RENDER, NULL);
|
||||||
|
|
||||||
if (!focused || runloop_idle)
|
if (!focused)
|
||||||
return RUNLOOP_STATE_SLEEP;
|
return RUNLOOP_STATE_SLEEP;
|
||||||
|
|
||||||
|
if (action == MENU_ACTION_QUIT)
|
||||||
|
return RUNLOOP_STATE_QUIT;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (runloop_idle)
|
||||||
|
return RUNLOOP_STATE_SLEEP;
|
||||||
|
|
||||||
|
#ifdef HAVE_MENU
|
||||||
|
if ( menu_event_keyboard_is_set(RETROK_F1) ||
|
||||||
|
runloop_cmd_menu_press(current_input, old_input, trigger_input) ||
|
||||||
|
rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
||||||
|
{
|
||||||
|
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
||||||
|
{
|
||||||
|
if (rarch_ctl(RARCH_CTL_IS_INITED, NULL) &&
|
||||||
|
!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
||||||
|
rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu_display_toggle_set_reason(MENU_TOGGLE_REASON_USER);
|
||||||
|
rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
||||||
|
{
|
||||||
if (!settings->menu.throttle_framerate && !settings->fastforward_ratio)
|
if (!settings->menu.throttle_framerate && !settings->fastforward_ratio)
|
||||||
return RUNLOOP_STATE_MENU_ITERATE;
|
return RUNLOOP_STATE_MENU_ITERATE;
|
||||||
|
|
||||||
return RUNLOOP_STATE_END;
|
return RUNLOOP_STATE_END;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (runloop_idle)
|
|
||||||
return RUNLOOP_STATE_SLEEP;
|
|
||||||
|
|
||||||
if (settings->pause_nonactive)
|
if (settings->pause_nonactive)
|
||||||
focused = video_driver_is_focused();
|
focused = video_driver_is_focused();
|
||||||
|
@ -26,6 +26,11 @@
|
|||||||
|
|
||||||
#include "input/input_defines.h"
|
#include "input/input_defines.h"
|
||||||
|
|
||||||
|
#define runloop_cmd_triggered(trigger_input, id) (BIT64_GET(trigger_input, id))
|
||||||
|
|
||||||
|
#define runloop_cmd_press(current_input, id) (BIT64_GET(current_input, id))
|
||||||
|
#define runloop_cmd_pressed(old_input, id) (BIT64_GET(old_input, id))
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
enum runloop_ctl_state
|
enum runloop_ctl_state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user