1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-05 09:48:42 +00:00

Input refactors pt3 (#13053)

* Move more internal state over to input_driver.c and menu_driver.c -
retroarch.c now down to 893kb
- Remove now unused p_rarch pointers in functions
This commit is contained in:
Autechre 2021-10-01 07:18:30 +02:00 committed by GitHub
parent bd76388fc5
commit 8807e2957e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1896 additions and 1836 deletions

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,7 @@
#ifdef HAVE_OVERLAY
#include "input_overlay.h"
#endif
#include "input_osk.h"
#include "../msg_hash.h"
#include "include/hid_types.h"
@ -49,6 +50,54 @@
#include "../command.h"
#endif
#if defined(ANDROID)
#define DEFAULT_MAX_PADS 8
#define ANDROID_KEYBOARD_PORT DEFAULT_MAX_PADS
#elif defined(_3DS)
#define DEFAULT_MAX_PADS 1
#elif defined(SWITCH) || defined(HAVE_LIBNX)
#define DEFAULT_MAX_PADS 8
#elif defined(WIIU)
#ifdef WIIU_HID
#define DEFAULT_MAX_PADS 16
#else
#define DEFAULT_MAX_PADS 5
#endif /* WIIU_HID */
#elif defined(DJGPP)
#define DEFAULT_MAX_PADS 1
#define DOS_KEYBOARD_PORT DEFAULT_MAX_PADS
#elif defined(XENON)
#define DEFAULT_MAX_PADS 4
#elif defined(VITA) || defined(SN_TARGET_PSP2)
#define DEFAULT_MAX_PADS 4
#elif defined(PSP)
#define DEFAULT_MAX_PADS 1
#elif defined(PS2)
#define DEFAULT_MAX_PADS 8
#elif defined(GEKKO) || defined(HW_RVL)
#define DEFAULT_MAX_PADS 4
#elif defined(HAVE_ODROIDGO2)
#define DEFAULT_MAX_PADS 1
#elif defined(__linux__) || (defined(BSD) && !defined(__MACH__))
#define DEFAULT_MAX_PADS 8
#elif defined(__QNX__)
#define DEFAULT_MAX_PADS 8
#elif defined(__PS3__)
#define DEFAULT_MAX_PADS 7
#elif defined(_XBOX)
#define DEFAULT_MAX_PADS 4
#elif defined(HAVE_XINPUT) && !defined(HAVE_DINPUT)
#define DEFAULT_MAX_PADS 4
#elif defined(DINGUX)
#define DEFAULT_MAX_PADS 2
#else
#define DEFAULT_MAX_PADS 16
#endif /* defined(ANDROID) */
#define MAPPER_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1)
#define MAPPER_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32)
#define MAPPER_UNSET_KEY(state, key) (state)->keys[(key) / 32] &= ~(1 << ((key) % 32))
RETRO_BEGIN_DECLS
/**
@ -317,8 +366,13 @@ typedef struct
*/
rarch_timer_t combo_timers[INPUT_COMBO_LAST];
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
input_remote_state_t remote_st_ptr; /* uint64_t alignment */
#endif
/* pointers */
void *keyboard_press_data;
input_keyboard_line_t keyboard_line; /* ptr alignment */
input_keyboard_press_t keyboard_press_cb; /* ptr alignment */
input_driver_t *current_driver;
void *current_data;
@ -328,15 +382,30 @@ typedef struct
#ifdef HAVE_COMMAND
command_t *command[MAX_CMD_DRIVERS];
#endif
#ifdef HAVE_OVERLAY
input_overlay_t *overlay_ptr;
enum overlay_visibility *overlay_visibility;
#endif
#ifdef HAVE_NETWORKGAMEPAD
input_remote_t *remote;
#endif
pad_connection_listener_t *pad_connection_listener;
char *osk_grid[45]; /* ptr alignment */
int osk_ptr;
turbo_buttons_t turbo_btns; /* int32_t alignment */
input_mapper_t mapper; /* uint32_t alignment */
input_device_info_t input_device_info[MAX_INPUT_DEVICES]; /* unsigned alignment */
input_mouse_info_t input_mouse_info[MAX_INPUT_DEVICES];
unsigned osk_last_codepoint;
unsigned osk_last_codepoint_len;
unsigned input_hotkey_block_counter;
#ifdef HAVE_ACCESSIBILITY
unsigned gamepad_input_override;
#endif
enum osk_type osk_idx;
/* primitives */
bool nonblocking_flag;
@ -347,7 +416,8 @@ typedef struct
bool grab_mouse_state;
bool analog_requested[MAX_USERS];
bool keyboard_mapping_blocked;
retro_bits_512_t keyboard_mapping_bits; /* bool alignment */
retro_bits_512_t keyboard_mapping_bits; /* bool alignment */
input_game_focus_state_t game_focus_state; /* bool alignment */
} input_driver_state_t;
@ -803,6 +873,8 @@ input_remote_t *input_driver_init_remote(
void input_remote_free(input_remote_t *handle, unsigned max_users);
#endif
void input_game_focus_free(void);
void input_config_get_bind_string_joyaxis(
bool input_descriptor_label_show,
char *buf, const char *prefix,
@ -821,6 +893,19 @@ bool input_key_pressed(int key, bool keyboard_pressed);
bool input_set_rumble_state(unsigned port,
enum retro_rumble_effect effect, uint16_t strength);
/**
* input_keyboard_line_event:
* @state : Input keyboard line handle.
* @character : Inputted character.
*
* Called on every keyboard character event.
*
* Returns: true (1) on success, otherwise false (0).
**/
bool input_keyboard_line_event(
input_driver_state_t *input_st,
input_keyboard_line_t *state, uint32_t character);
bool input_set_rumble_gain(unsigned gain);
float input_get_sensor_state(unsigned port, unsigned id);
@ -840,6 +925,14 @@ const char *joypad_driver_name(unsigned i);
void joypad_driver_reinit(void *data, const char *joypad_driver_name);
#ifdef HAVE_COMMAND
void input_driver_init_command(
input_driver_state_t *input_st,
settings_t *settings);
void input_driver_deinit_command(input_driver_state_t *input_st);
#endif
#ifdef HAVE_OVERLAY
/*
* input_poll_overlay:
@ -854,51 +947,36 @@ void input_poll_overlay(
float opacity,
unsigned analog_dpad_mode,
float axis_threshold);
void input_overlay_deinit(void);
void input_overlay_set_visibility(int overlay_idx,
enum overlay_visibility vis);
void input_overlay_init(void);
#endif
#if defined(ANDROID)
#define DEFAULT_MAX_PADS 8
#define ANDROID_KEYBOARD_PORT DEFAULT_MAX_PADS
#elif defined(_3DS)
#define DEFAULT_MAX_PADS 1
#elif defined(SWITCH) || defined(HAVE_LIBNX)
#define DEFAULT_MAX_PADS 8
#elif defined(WIIU)
#ifdef WIIU_HID
#define DEFAULT_MAX_PADS 16
#else
#define DEFAULT_MAX_PADS 5
#endif /* WIIU_HID */
#elif defined(DJGPP)
#define DEFAULT_MAX_PADS 1
#define DOS_KEYBOARD_PORT DEFAULT_MAX_PADS
#elif defined(XENON)
#define DEFAULT_MAX_PADS 4
#elif defined(VITA) || defined(SN_TARGET_PSP2)
#define DEFAULT_MAX_PADS 4
#elif defined(PSP)
#define DEFAULT_MAX_PADS 1
#elif defined(PS2)
#define DEFAULT_MAX_PADS 8
#elif defined(GEKKO) || defined(HW_RVL)
#define DEFAULT_MAX_PADS 4
#elif defined(HAVE_ODROIDGO2)
#define DEFAULT_MAX_PADS 1
#elif defined(__linux__) || (defined(BSD) && !defined(__MACH__))
#define DEFAULT_MAX_PADS 8
#elif defined(__QNX__)
#define DEFAULT_MAX_PADS 8
#elif defined(__PS3__)
#define DEFAULT_MAX_PADS 7
#elif defined(_XBOX)
#define DEFAULT_MAX_PADS 4
#elif defined(HAVE_XINPUT) && !defined(HAVE_DINPUT)
#define DEFAULT_MAX_PADS 4
#elif defined(DINGUX)
#define DEFAULT_MAX_PADS 2
#else
#define DEFAULT_MAX_PADS 16
#endif /* defined(ANDROID) */
bool input_keys_pressed_other_sources(
input_driver_state_t *input_st,
unsigned i,
input_bits_t* p_new_state);
int16_t input_state_device(
input_driver_state_t *input_st,
settings_t *settings,
input_mapper_t *handle,
unsigned input_analog_dpad_mode,
int16_t ret,
unsigned port, unsigned device,
unsigned idx, unsigned id,
bool button_mask);
/**
* input_poll:
*
* Input polling callback function.
**/
void input_driver_poll(void);
extern input_device_driver_t *joypad_drivers[];
extern input_driver_t *input_drivers[];

View File

@ -27,6 +27,14 @@ enum input_auto_game_focus_type
AUTO_GAME_FOCUS_LAST
};
enum input_game_focus_cmd_type
{
GAME_FOCUS_CMD_OFF = 0,
GAME_FOCUS_CMD_ON,
GAME_FOCUS_CMD_TOGGLE,
GAME_FOCUS_CMD_REAPPLY
};
/* Turbo support. */
struct turbo_buttons
{
@ -87,6 +95,12 @@ typedef struct input_mapper
input_bits_t buttons[MAX_USERS];
} input_mapper_t;
typedef struct input_game_focus_state
{
bool enabled;
bool core_requested;
} input_game_focus_state_t;
typedef struct rarch_joypad_driver input_device_driver_t;
typedef struct input_keyboard_line input_keyboard_line_t;
typedef struct rarch_joypad_info rarch_joypad_info_t;

View File

@ -51,11 +51,27 @@
#include "../cheevos/cheevos_menu.h"
#endif
#include "../gfx/gfx_animation.h"
#include "../input/input_driver.h"
#include "../input/input_remapping.h"
#include "../performance_counters.h"
#include "../version.h"
#ifdef HAVE_LIBNX
#include <switch.h>
#endif
#if defined(HAVE_LAKKA) || defined(HAVE_LIBNX)
#include "../switch_performance_profiles.h"
#endif
#ifdef HAVE_LIBNX
#define LIBNX_SWKBD_LIMIT 500 /* enforced by HOS */
/* TODO/FIXME - public global variable */
extern u32 __nx_applet_type;
#endif
struct key_desc key_descriptors[RARCH_MAX_KEYS] =
{
{RETROK_FIRST, "Unmapped"},
@ -5623,3 +5639,458 @@ current_time;
return false;
}
bool menu_input_dialog_get_display_kb(void)
{
struct menu_state *menu_st = menu_state_get_ptr();
#ifdef HAVE_LIBNX
input_driver_state_t *input_st = input_state_get_ptr();
SwkbdConfig kbd;
Result rc;
/* Indicates that we are "typing" from the swkbd
* result to RetroArch with repeated calls to input_keyboard_event
* This prevents input_keyboard_event from calling back
* menu_input_dialog_get_display_kb, looping indefinintely */
static bool typing = false;
if (typing)
return false;
/* swkbd only works on "real" titles */
if ( __nx_applet_type != AppletType_Application
&& __nx_applet_type != AppletType_SystemApplication)
return menu_st->input_dialog_kb_display;
if (!menu_st->input_dialog_kb_display)
return false;
rc = swkbdCreate(&kbd, 0);
if (R_SUCCEEDED(rc))
{
unsigned i;
char buf[LIBNX_SWKBD_LIMIT] = {'\0'};
swkbdConfigMakePresetDefault(&kbd);
swkbdConfigSetGuideText(&kbd,
menu_st->input_dialog_kb_label);
rc = swkbdShow(&kbd, buf, sizeof(buf));
swkbdClose(&kbd);
/* RetroArch uses key-by-key input
so we need to simulate it */
typing = true;
for (i = 0; i < LIBNX_SWKBD_LIMIT; i++)
{
/* In case a previous "Enter" press closed the keyboard */
if (!menu_st->input_dialog_kb_display)
break;
if (buf[i] == '\n' || buf[i] == '\0')
input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD);
else
{
const char *word = &buf[i];
/* input_keyboard_line_append expects a null-terminated
string, so just make one (yes, the touch keyboard is
a list of "null-terminated characters") */
char oldchar = buf[i+1];
buf[i+1] = '\0';
input_keyboard_line_append(&input_st->keyboard_line, word);
osk_update_last_codepoint(
&input_st->osk_last_codepoint,
&input_st->osk_last_codepoint_len,
word);
buf[i+1] = oldchar;
}
}
/* fail-safe */
if (menu_st->input_dialog_kb_display)
input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD);
typing = false;
libnx_apply_overclock();
return false;
}
libnx_apply_overclock();
#endif /* HAVE_LIBNX */
return menu_st->input_dialog_kb_display;
}
unsigned menu_event(
settings_t *settings,
input_bits_t *p_input,
input_bits_t *p_trigger_input,
bool display_kb)
{
/* Used for key repeat */
static float delay_timer = 0.0f;
static float delay_count = 0.0f;
static bool initial_held = true;
static bool first_held = false;
static unsigned ok_old = 0;
unsigned ret = MENU_ACTION_NOOP;
bool set_scroll = false;
size_t new_scroll_accel = 0;
struct menu_state *menu_st = menu_state_get_ptr();
menu_input_t *menu_input = &menu_st->input_state;
input_driver_state_t *input_st = input_state_get_ptr();
input_driver_t *current_input = input_st->current_driver;
const input_device_driver_t
*joypad = input_st->primary_joypad;
#ifdef HAVE_MFI
const input_device_driver_t *sec_joypad =
input_st->secondary_joypad;
#else
const input_device_driver_t *sec_joypad = NULL;
#endif
gfx_display_t *p_disp = disp_get_ptr();
menu_input_pointer_hw_state_t *pointer_hw_state = &menu_st->input_pointer_hw_state;
menu_handle_t *menu = menu_st->driver_data;
bool keyboard_mapping_blocked = input_st->keyboard_mapping_blocked;
bool menu_mouse_enable = settings->bools.menu_mouse_enable;
bool menu_pointer_enable = settings->bools.menu_pointer_enable;
bool swap_ok_cancel_btns = settings->bools.input_menu_swap_ok_cancel_buttons;
bool menu_scroll_fast = settings->bools.menu_scroll_fast;
bool pointer_enabled = settings->bools.menu_pointer_enable;
unsigned input_touch_scale = settings->uints.input_touch_scale;
unsigned menu_scroll_delay =
settings->uints.menu_scroll_delay;
#ifdef HAVE_OVERLAY
bool input_overlay_enable = settings->bools.input_overlay_enable;
bool overlay_active = input_overlay_enable
&& input_st->overlay_ptr
&& input_st->overlay_ptr->alive;
#else
bool input_overlay_enable = false;
bool overlay_active = false;
#endif
unsigned menu_ok_btn = swap_ok_cancel_btns ?
RETRO_DEVICE_ID_JOYPAD_B : RETRO_DEVICE_ID_JOYPAD_A;
unsigned menu_cancel_btn = swap_ok_cancel_btns ?
RETRO_DEVICE_ID_JOYPAD_A : RETRO_DEVICE_ID_JOYPAD_B;
unsigned ok_current = BIT256_GET_PTR(p_input, menu_ok_btn);
unsigned ok_trigger = ok_current & ~ok_old;
unsigned i = 0;
static unsigned navigation_initial = 0;
unsigned navigation_current = 0;
unsigned navigation_buttons[6] =
{
RETRO_DEVICE_ID_JOYPAD_UP,
RETRO_DEVICE_ID_JOYPAD_DOWN,
RETRO_DEVICE_ID_JOYPAD_LEFT,
RETRO_DEVICE_ID_JOYPAD_RIGHT,
RETRO_DEVICE_ID_JOYPAD_L,
RETRO_DEVICE_ID_JOYPAD_R
};
ok_old = ok_current;
/* Get pointer (mouse + touchscreen) input
* Note: Must be done regardless of menu screensaver
* state */
/* > If pointer input is disabled, do nothing */
if (!menu_mouse_enable && !menu_pointer_enable)
menu_input->pointer.type = MENU_POINTER_DISABLED;
else
{
menu_input_pointer_hw_state_t mouse_hw_state = {0};
menu_input_pointer_hw_state_t touchscreen_hw_state = {0};
/* Read mouse */
if (menu_mouse_enable)
menu_input_get_mouse_hw_state(
p_disp,
menu,
input_st,
current_input,
joypad,
sec_joypad,
keyboard_mapping_blocked,
menu_mouse_enable,
input_overlay_enable,
overlay_active,
&mouse_hw_state);
/* Read touchscreen
* Note: Could forgo this if mouse is currently active,
* but this is 'cleaner' code... (if performance is a
* concern - and it isn't - user can just disable touch
* screen support) */
if (menu_pointer_enable)
menu_input_get_touchscreen_hw_state(
p_disp,
menu,
input_st,
current_input,
joypad,
sec_joypad,
keyboard_mapping_blocked,
overlay_active,
pointer_enabled,
input_touch_scale,
&touchscreen_hw_state);
/* Mouse takes precedence */
if (mouse_hw_state.active)
menu_input->pointer.type = MENU_POINTER_MOUSE;
else if (touchscreen_hw_state.active)
menu_input->pointer.type = MENU_POINTER_TOUCHSCREEN;
/* Copy input from the current device */
if (menu_input->pointer.type == MENU_POINTER_MOUSE)
memcpy(pointer_hw_state, &mouse_hw_state, sizeof(menu_input_pointer_hw_state_t));
else if (menu_input->pointer.type == MENU_POINTER_TOUCHSCREEN)
memcpy(pointer_hw_state, &touchscreen_hw_state, sizeof(menu_input_pointer_hw_state_t));
if (pointer_hw_state->active)
menu_st->input_last_time_us = menu_st->current_time_us;
}
/* Populate menu_input_state
* Note: dx, dy, ptr, y_accel, etc. entries are set elsewhere */
menu_input->pointer.x = pointer_hw_state->x;
menu_input->pointer.y = pointer_hw_state->y;
if (menu_input->select_inhibit || menu_input->cancel_inhibit)
{
menu_input->pointer.active = false;
menu_input->pointer.pressed = false;
}
else
{
menu_input->pointer.active = pointer_hw_state->active;
menu_input->pointer.pressed = pointer_hw_state->select_pressed;
}
/* If menu screensaver is active, any input
* is intercepted and used to switch it off */
if (menu_st->screensaver_active)
{
/* Check pointer input */
bool input_active = (menu_input->pointer.type != MENU_POINTER_DISABLED) &&
menu_input->pointer.active;
/* Check regular input */
if (!input_active)
input_active = bits_any_set(p_input->data, ARRAY_SIZE(p_input->data));
if (!input_active)
input_active = bits_any_set(p_trigger_input->data, ARRAY_SIZE(p_trigger_input->data));
/* Disable screensaver if required */
if (input_active)
{
menu_ctx_environment_t menu_environ;
menu_environ.type = MENU_ENVIRON_DISABLE_SCREENSAVER;
menu_environ.data = NULL;
menu_st->screensaver_active = false;
menu_st->input_last_time_us = menu_st->current_time_us;
menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ);
}
/* Annul received input */
menu_input->pointer.active = false;
menu_input->pointer.pressed = false;
menu_input->select_inhibit = true;
menu_input->cancel_inhibit = true;
pointer_hw_state->up_pressed = false;
pointer_hw_state->down_pressed = false;
pointer_hw_state->left_pressed = false;
pointer_hw_state->right_pressed = false;
return MENU_ACTION_NOOP;
}
/* Accelerate only navigation buttons */
for (i = 0; i < 6; i++)
{
if (BIT256_GET_PTR(p_input, navigation_buttons[i]))
navigation_current |= (1 << navigation_buttons[i]);
}
if (navigation_current)
{
if (!first_held)
{
/* Store first direction in order to block "diagonals" */
if (!navigation_initial)
navigation_initial = navigation_current;
/* don't run anything first frame, only capture held inputs
* for old_input_state. */
first_held = true;
if (initial_held)
delay_timer = menu_scroll_delay;
else
delay_timer = menu_scroll_fast ? 100 : 20;
delay_count = 0;
}
if (delay_count >= delay_timer)
{
uint32_t input_repeat = 0;
for (i = 0; i < 6; i++)
BIT32_SET(input_repeat, navigation_buttons[i]);
set_scroll = true;
first_held = false;
p_trigger_input->data[0] |= p_input->data[0] & input_repeat;
new_scroll_accel = menu_st->scroll.acceleration;
if (menu_scroll_fast)
new_scroll_accel = MIN(new_scroll_accel + 1, 64);
else
new_scroll_accel = MIN(new_scroll_accel + 1, 5);
}
initial_held = false;
}
else
{
set_scroll = true;
first_held = false;
initial_held = true;
navigation_initial = 0;
}
if (set_scroll)
menu_st->scroll.acceleration = (unsigned)(new_scroll_accel);
delay_count += anim_get_ptr()->delta_time;
if (display_kb)
{
bool show_osk_symbols = input_event_osk_show_symbol_pages(menu_st->driver_data);
input_event_osk_iterate(input_st->osk_grid, input_st->osk_idx);
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN))
{
menu_st->input_last_time_us = menu_st->current_time_us;
if (input_st->osk_ptr < 33)
input_st->osk_ptr += OSK_CHARS_PER_LINE;
}
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_UP))
{
menu_st->input_last_time_us = menu_st->current_time_us;
if (input_st->osk_ptr >= OSK_CHARS_PER_LINE)
input_st->osk_ptr -= OSK_CHARS_PER_LINE;
}
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT))
{
menu_st->input_last_time_us = menu_st->current_time_us;
if (input_st->osk_ptr < 43)
input_st->osk_ptr += 1;
}
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT))
{
menu_st->input_last_time_us = menu_st->current_time_us;
if (input_st->osk_ptr >= 1)
input_st->osk_ptr -= 1;
}
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L))
{
menu_st->input_last_time_us = menu_st->current_time_us;
if (input_st->osk_idx > OSK_TYPE_UNKNOWN + 1)
input_st->osk_idx = ((enum osk_type)
(input_st->osk_idx - 1));
else
input_st->osk_idx = ((enum osk_type)(show_osk_symbols
? OSK_TYPE_LAST - 1
: OSK_SYMBOLS_PAGE1));
}
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R))
{
menu_st->input_last_time_us = menu_st->current_time_us;
if (input_st->osk_idx < (show_osk_symbols
? OSK_TYPE_LAST - 1
: OSK_SYMBOLS_PAGE1))
input_st->osk_idx = ((enum osk_type)(
input_st->osk_idx + 1));
else
input_st->osk_idx = ((enum osk_type)(OSK_TYPE_UNKNOWN + 1));
}
if (BIT256_GET_PTR(p_trigger_input, menu_ok_btn))
{
if (input_st->osk_ptr >= 0)
input_event_osk_append(
&input_st->keyboard_line,
&input_st->osk_idx,
&input_st->osk_last_codepoint,
&input_st->osk_last_codepoint_len,
input_st->osk_ptr,
show_osk_symbols,
input_st->osk_grid[input_st->osk_ptr]);
}
if (BIT256_GET_PTR(p_trigger_input, menu_cancel_btn))
input_keyboard_event(true, '\x7f', '\x7f',
0, RETRO_DEVICE_KEYBOARD);
/* send return key to close keyboard input window */
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_START))
input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD);
BIT256_CLEAR_ALL_PTR(p_trigger_input);
}
else
{
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_UP))
{
if (navigation_initial == (1 << RETRO_DEVICE_ID_JOYPAD_UP))
ret = MENU_ACTION_UP;
}
else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN))
{
if (navigation_initial == (1 << RETRO_DEVICE_ID_JOYPAD_DOWN))
ret = MENU_ACTION_DOWN;
}
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT))
{
if (navigation_initial == (1 << RETRO_DEVICE_ID_JOYPAD_LEFT))
ret = MENU_ACTION_LEFT;
}
else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT))
{
if (navigation_initial == (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT))
ret = MENU_ACTION_RIGHT;
}
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L))
ret = MENU_ACTION_SCROLL_UP;
else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R))
ret = MENU_ACTION_SCROLL_DOWN;
else if (ok_trigger)
ret = MENU_ACTION_OK;
else if (BIT256_GET_PTR(p_trigger_input, menu_cancel_btn))
ret = MENU_ACTION_CANCEL;
else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_X))
ret = MENU_ACTION_SEARCH;
else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_Y))
ret = MENU_ACTION_SCAN;
else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_START))
ret = MENU_ACTION_START;
else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_SELECT))
ret = MENU_ACTION_INFO;
else if (BIT256_GET_PTR(p_trigger_input, RARCH_MENU_TOGGLE))
ret = MENU_ACTION_TOGGLE;
if (ret != MENU_ACTION_NOOP)
menu_st->input_last_time_us = menu_st->current_time_us;
}
return ret;
}

View File

@ -866,6 +866,31 @@ bool menu_input_key_bind_iterate(
menu_input_ctx_bind_t *bind,
retro_time_t current_time);
/*
* This function gets called in order to process all input events
* for the current frame.
*
* Sends input code to menu for one frame.
*
* It uses as input the local variables 'input' and 'trigger_input'.
*
* Mouse and touch input events get processed inside this function.
*
* NOTE: 'input' and 'trigger_input' is sourced from the keyboard and/or
* the gamepad. It does not contain input state derived from the mouse
* and/or touch - this gets dealt with separately within this function.
*
* TODO/FIXME - maybe needs to be overhauled so we can send multiple
* events per frame if we want to, and we shouldn't send the
* entire button state either but do a separate event per button
* state.
*/
unsigned menu_event(
settings_t *settings,
input_bits_t *p_input,
input_bits_t *p_trigger_input,
bool display_kb);
extern const menu_ctx_driver_t *menu_ctx_drivers[];
RETRO_END_DECLS

File diff suppressed because it is too large Load Diff

View File

@ -150,9 +150,6 @@
#define BSV_MOVIE_IS_EOF(p_rarch)
#endif
/* Depends on ASCII character values */
#define ISPRINT(c) (((int)(c) >= ' ' && (int)(c) <= '~') ? 1 : 0)
#define VIDEO_HAS_FOCUS(p_rarch) (p_rarch->current_video->focus ? (p_rarch->current_video->focus(p_rarch->video_driver_data)) : true)
#if HAVE_DYNAMIC
@ -204,10 +201,6 @@
old_pressed3 = pressed3; \
}
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
#define INPUT_REMOTE_KEY_PRESSED(p_rarch, key, port) (p_rarch->remote_st_ptr.buttons[(port)] & (UINT64_C(1) << (key)))
#endif
/**
* check_input_driver_block_hotkey:
*
@ -232,10 +225,6 @@
#define INHERIT_JOYAXIS(binds) (((binds)[x_plus].joyaxis == (binds)[x_minus].joyaxis) || ( (binds)[y_plus].joyaxis == (binds)[y_minus].joyaxis))
#define MAPPER_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1)
#define MAPPER_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32)
#define MAPPER_UNSET_KEY(state, key) (state)->keys[(key) / 32] &= ~(1 << ((key) % 32))
#define CDN_URL "https://cdn.discordapp.com/avatars"
#ifdef HAVE_DYNAMIC
@ -327,10 +316,6 @@
#define BSV_MOVIE_ARG
#endif
#ifdef HAVE_LIBNX
#define LIBNX_SWKBD_LIMIT 500 /* enforced by HOS */
#endif
/* Griffin hack */
#ifdef HAVE_QT
#ifndef HAVE_MAIN
@ -743,14 +728,6 @@ enum poll_type_override_t
POLL_TYPE_OVERRIDE_LATE
};
enum input_game_focus_cmd_type
{
GAME_FOCUS_CMD_OFF = 0,
GAME_FOCUS_CMD_ON,
GAME_FOCUS_CMD_TOGGLE,
GAME_FOCUS_CMD_REAPPLY
};
typedef void *(*constructor_t)(void);
typedef void (*destructor_t )(void*);
@ -763,12 +740,6 @@ typedef struct my_list_t
int size;
} my_list;
typedef struct input_game_focus_state
{
bool enabled;
bool core_requested;
} input_game_focus_state_t;
#ifdef HAVE_RUNAHEAD
typedef bool(*runahead_load_state_function)(const void*, size_t);
#endif
@ -843,9 +814,6 @@ struct rarch_state
uint64_t video_driver_frame_time_count;
uint64_t video_driver_frame_count;
struct retro_camera_callback camera_cb; /* uint64_t alignment */
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
input_remote_state_t remote_st_ptr; /* uint64_t alignment */
#endif
struct string_list *subsystem_fullpaths;
struct string_list *audio_driver_devices_list;
@ -853,7 +821,6 @@ struct rarch_state
uint8_t *video_driver_record_gpu_buffer;
bool *load_no_content_hook;
float *audio_driver_output_samples_buf;
char *osk_grid[45];
#if defined(HAVE_RUNAHEAD)
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
char *secondary_library_path;
@ -924,13 +891,6 @@ struct rarch_state
void *audio_driver_resampler_data;
const audio_driver_t *current_audio;
void *audio_driver_context_audio_data;
#ifdef HAVE_OVERLAY
input_overlay_t *overlay_ptr;
#endif
pad_connection_listener_t *pad_connection_listener;
#ifdef HAVE_HID
const void *hid_data;
@ -956,7 +916,6 @@ struct rarch_state
#ifdef HAVE_REWIND
struct state_manager_rewind_state rewind_st;
#endif
input_keyboard_line_t keyboard_line; /* ptr alignment */
struct retro_subsystem_rom_info
subsystem_data_roms[SUBSYSTEM_MAX_SUBSYSTEMS]
[SUBSYSTEM_MAX_SUBSYSTEM_ROMS]; /* ptr alignment */
@ -1031,7 +990,6 @@ struct rarch_state
jmp_buf error_sjlj_context; /* 4-byte alignment,
put it right before long */
int osk_ptr;
#if defined(HAVE_COMMAND)
#ifdef HAVE_NETWORK_CMD
int lastcmd_net_fd;
@ -1071,12 +1029,6 @@ struct rarch_state
unsigned frame_cache_height;
unsigned video_driver_width;
unsigned video_driver_height;
unsigned osk_last_codepoint;
unsigned osk_last_codepoint_len;
unsigned input_hotkey_block_counter;
#ifdef HAVE_ACCESSIBILITY
unsigned gamepad_input_override;
#endif
#ifdef HAVE_NETWORKING
unsigned server_port_deferred;
#endif
@ -1099,7 +1051,6 @@ struct rarch_state
float audio_driver_input;
float audio_driver_volume_gain;
enum osk_type osk_idx;
enum rarch_core_type current_core_type;
enum rarch_core_type explicit_current_core_type;
enum rotation initial_screen_orientation;
@ -1113,9 +1064,6 @@ struct rarch_state
#endif
enum rarch_display_type video_driver_display_type;
enum poll_type_override_t core_poll_type_override;
#ifdef HAVE_OVERLAY
enum overlay_visibility *overlay_visibility;
#endif
enum resampler_quality audio_driver_resampler_quality;
/**
@ -1298,8 +1246,6 @@ struct rarch_state
bool has_set_netplay_check_frames;
#endif
input_game_focus_state_t game_focus_state; /* bool alignment */
bool recording_enable;
bool streaming_enable;
bool main_ui_companion_is_on_foreground;

View File

@ -83,11 +83,6 @@ static bool recording_init(settings_t *settings,
struct rarch_state *p_rarch);
static bool recording_deinit(struct rarch_state *p_rarch);
#ifdef HAVE_OVERLAY
static void retroarch_overlay_init(struct rarch_state *p_rarch);
static void retroarch_overlay_deinit(struct rarch_state *p_rarch);
#endif
#ifdef HAVE_AUDIOMIXER
static void audio_mixer_play_stop_sequential_cb(
audio_mixer_sound_t *sound, unsigned reason);