More work

This commit is contained in:
twinaphex 2016-10-27 00:14:01 +02:00
parent a9a2749af9
commit 2bcbe017cd
4 changed files with 100 additions and 32 deletions

View File

@ -28,6 +28,7 @@
#include "menu_driver.h"
#include "menu_cbs.h"
#include "menu_display.h"
#include "menu_event.h"
#include "menu_navigation.h"
#include "widgets/menu_dialog.h"
#include "widgets/menu_list.h"
@ -221,19 +222,12 @@ static void menu_input_key_event(bool down, unsigned keycode,
(void)keycode;
(void)mod;
#if 0
RARCH_LOG("down: %d, keycode: %d, mod: %d\n", down, keycode, mod);
#if 1
RARCH_LOG("down: %d, keycode: %d, mod: %d, character: %d\n", down, keycode, mod, character);
#endif
switch (character)
{
case RETROK_SLASH:
menu_entry_action(NULL, 0, MENU_ACTION_SEARCH);
break;
default:
break;
}
if (down)
menu_event_keyboard_set((enum retro_key)keycode);
}
static void menu_driver_toggle(bool latch)

View File

@ -36,6 +36,8 @@
#include "../configuration.h"
static bool menu_keyboard_key_state[RETROK_LAST];
static int menu_event_pointer(unsigned *action)
{
const struct retro_keybind *binds[MAX_USERS] = {NULL};
@ -65,8 +67,24 @@ static int menu_event_pointer(unsigned *action)
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 i;
menu_animation_ctx_delta_t delta;
float delta_time;
/* Used for key repeat */
@ -187,6 +205,51 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input)
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_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))
ret = MENU_ACTION_UP;
else if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN))

View File

@ -22,6 +22,8 @@
#include <retro_common_api.h>
#include <libretro.h>
RETRO_BEGIN_DECLS
/* 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);
void menu_event_keyboard_set(enum retro_key key);
bool menu_event_keyboard_is_set(enum retro_key key);
unsigned kbd_index;
char kbd_grid[41];
bool kbd_upper;

View File

@ -852,23 +852,6 @@ static enum runloop_state runloop_check_state(
if (runloop_cmd_triggered(trigger_input, RARCH_GRAB_MOUSE_TOGGLE))
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
if (osk_enable && !input_keyboard_ctl(
@ -914,18 +897,40 @@ static enum runloop_state runloop_check_state(
if (focused || !runloop_idle)
menu_driver_ctl(RARCH_MENU_CTL_RENDER, NULL);
if (!focused || runloop_idle)
if (!focused)
return RUNLOOP_STATE_SLEEP;
}
#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)
return RUNLOOP_STATE_MENU_ITERATE;
return RUNLOOP_STATE_END;
}
#endif
if (runloop_idle)
return RUNLOOP_STATE_SLEEP;
if (settings->pause_nonactive)
focused = video_driver_is_focused();