mirror of
https://github.com/libretro/RetroArch
synced 2025-02-07 12:39:54 +00:00
Move more input code over to input_driver.c from retroarch.c
This commit is contained in:
parent
ccbbf45760
commit
c9e587a5a7
@ -695,6 +695,237 @@ int16_t input_joypad_axis(
|
||||
return val;
|
||||
}
|
||||
|
||||
int16_t input_joypad_analog_button(
|
||||
float input_analog_deadzone,
|
||||
float input_analog_sensitivity,
|
||||
const input_device_driver_t *drv,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
unsigned ident,
|
||||
const struct retro_keybind *bind)
|
||||
{
|
||||
int16_t res = 0;
|
||||
float normal_mag = 0.0f;
|
||||
uint32_t axis = (bind->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident].joyaxis
|
||||
: bind->joyaxis;
|
||||
|
||||
/* Analog button. */
|
||||
if (input_analog_deadzone)
|
||||
{
|
||||
int16_t mult = 0;
|
||||
if (axis != AXIS_NONE)
|
||||
if ((mult = drv->axis(
|
||||
joypad_info->joy_idx, axis)) != 0)
|
||||
normal_mag = fabs((1.0f / 0x7fff) * mult);
|
||||
}
|
||||
|
||||
/* If the result is zero, it's got a digital button
|
||||
* attached to it instead */
|
||||
if ((res = abs(input_joypad_axis(
|
||||
input_analog_deadzone,
|
||||
input_analog_sensitivity,
|
||||
drv,
|
||||
joypad_info->joy_idx, axis, normal_mag))) == 0)
|
||||
{
|
||||
uint16_t key = (bind->joykey == NO_BTN)
|
||||
? joypad_info->auto_binds[ident].joykey
|
||||
: bind->joykey;
|
||||
|
||||
if (drv->button(joypad_info->joy_idx, key))
|
||||
return 0x7fff;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int16_t input_joypad_analog_axis(
|
||||
unsigned input_analog_dpad_mode,
|
||||
float input_analog_deadzone,
|
||||
float input_analog_sensitivity,
|
||||
const input_device_driver_t *drv,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
unsigned idx,
|
||||
unsigned ident,
|
||||
const struct retro_keybind *binds)
|
||||
{
|
||||
int16_t res = 0;
|
||||
/* Analog sticks. Either RETRO_DEVICE_INDEX_ANALOG_LEFT
|
||||
* or RETRO_DEVICE_INDEX_ANALOG_RIGHT */
|
||||
unsigned ident_minus = 0;
|
||||
unsigned ident_plus = 0;
|
||||
unsigned ident_x_minus = 0;
|
||||
unsigned ident_x_plus = 0;
|
||||
unsigned ident_y_minus = 0;
|
||||
unsigned ident_y_plus = 0;
|
||||
const struct retro_keybind *bind_minus = NULL;
|
||||
const struct retro_keybind *bind_plus = NULL;
|
||||
const struct retro_keybind *bind_x_minus = NULL;
|
||||
const struct retro_keybind *bind_x_plus = NULL;
|
||||
const struct retro_keybind *bind_y_minus = NULL;
|
||||
const struct retro_keybind *bind_y_plus = NULL;
|
||||
|
||||
/* Skip analog input with analog_dpad_mode */
|
||||
switch (input_analog_dpad_mode)
|
||||
{
|
||||
case ANALOG_DPAD_LSTICK:
|
||||
if (idx == RETRO_DEVICE_INDEX_ANALOG_LEFT)
|
||||
return 0;
|
||||
break;
|
||||
case ANALOG_DPAD_RSTICK:
|
||||
if (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT)
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, ident, ident_minus, ident_plus);
|
||||
|
||||
bind_minus = &binds[ident_minus];
|
||||
bind_plus = &binds[ident_plus];
|
||||
|
||||
if (!bind_minus->valid || !bind_plus->valid)
|
||||
return 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx,
|
||||
RETRO_DEVICE_ID_ANALOG_X, ident_x_minus, ident_x_plus);
|
||||
|
||||
bind_x_minus = &binds[ident_x_minus];
|
||||
bind_x_plus = &binds[ident_x_plus];
|
||||
|
||||
if (!bind_x_minus->valid || !bind_x_plus->valid)
|
||||
return 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx,
|
||||
RETRO_DEVICE_ID_ANALOG_Y, ident_y_minus, ident_y_plus);
|
||||
|
||||
bind_y_minus = &binds[ident_y_minus];
|
||||
bind_y_plus = &binds[ident_y_plus];
|
||||
|
||||
if (!bind_y_minus->valid || !bind_y_plus->valid)
|
||||
return 0;
|
||||
|
||||
{
|
||||
uint32_t axis_minus = (bind_minus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_minus].joyaxis
|
||||
: bind_minus->joyaxis;
|
||||
uint32_t axis_plus = (bind_plus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_plus].joyaxis
|
||||
: bind_plus->joyaxis;
|
||||
float normal_mag = 0.0f;
|
||||
|
||||
/* normalized magnitude of stick actuation, needed for scaled
|
||||
* radial deadzone */
|
||||
if (input_analog_deadzone)
|
||||
{
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
uint32_t x_axis_minus = (bind_x_minus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_x_minus].joyaxis
|
||||
: bind_x_minus->joyaxis;
|
||||
uint32_t x_axis_plus = (bind_x_plus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_x_plus].joyaxis
|
||||
: bind_x_plus->joyaxis;
|
||||
uint32_t y_axis_minus = (bind_y_minus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_y_minus].joyaxis
|
||||
: bind_y_minus->joyaxis;
|
||||
uint32_t y_axis_plus = (bind_y_plus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_y_plus].joyaxis
|
||||
: bind_y_plus->joyaxis;
|
||||
/* normalized magnitude for radial scaled analog deadzone */
|
||||
if (x_axis_plus != AXIS_NONE)
|
||||
x = drv->axis(
|
||||
joypad_info->joy_idx, x_axis_plus);
|
||||
if (x_axis_minus != AXIS_NONE)
|
||||
x += drv->axis(joypad_info->joy_idx,
|
||||
x_axis_minus);
|
||||
if (y_axis_plus != AXIS_NONE)
|
||||
y = drv->axis(
|
||||
joypad_info->joy_idx, y_axis_plus);
|
||||
if (y_axis_minus != AXIS_NONE)
|
||||
y += drv->axis(
|
||||
joypad_info->joy_idx, y_axis_minus);
|
||||
normal_mag = (1.0f / 0x7fff) * sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
res = abs(
|
||||
input_joypad_axis(
|
||||
input_analog_deadzone,
|
||||
input_analog_sensitivity,
|
||||
drv, joypad_info->joy_idx,
|
||||
axis_plus, normal_mag));
|
||||
res -= abs(
|
||||
input_joypad_axis(
|
||||
input_analog_deadzone,
|
||||
input_analog_sensitivity,
|
||||
drv, joypad_info->joy_idx,
|
||||
axis_minus, normal_mag));
|
||||
}
|
||||
|
||||
if (res == 0)
|
||||
{
|
||||
uint16_t key_minus = (bind_minus->joykey == NO_BTN)
|
||||
? joypad_info->auto_binds[ident_minus].joykey
|
||||
: bind_minus->joykey;
|
||||
uint16_t key_plus = (bind_plus->joykey == NO_BTN)
|
||||
? joypad_info->auto_binds[ident_plus].joykey
|
||||
: bind_plus->joykey;
|
||||
if (drv->button(joypad_info->joy_idx, key_plus))
|
||||
res = 0x7fff;
|
||||
if (drv->button(joypad_info->joy_idx, key_minus))
|
||||
res += -0x7fff;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool input_keyboard_line_append(
|
||||
struct input_keyboard_line *keyboard_line,
|
||||
const char *word)
|
||||
{
|
||||
unsigned i = 0;
|
||||
unsigned len = (unsigned)strlen(word);
|
||||
char *newbuf = (char*)realloc(
|
||||
keyboard_line->buffer,
|
||||
keyboard_line->size + len * 2);
|
||||
|
||||
if (!newbuf)
|
||||
return false;
|
||||
|
||||
memmove(
|
||||
newbuf + keyboard_line->ptr + len,
|
||||
newbuf + keyboard_line->ptr,
|
||||
keyboard_line->size - keyboard_line->ptr + len);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
newbuf[keyboard_line->ptr]= word[i];
|
||||
keyboard_line->ptr++;
|
||||
keyboard_line->size++;
|
||||
}
|
||||
|
||||
newbuf[keyboard_line->size] = '\0';
|
||||
|
||||
keyboard_line->buffer = newbuf;
|
||||
return true;
|
||||
}
|
||||
|
||||
const char **input_keyboard_start_line(
|
||||
void *userdata,
|
||||
struct input_keyboard_line *keyboard_line,
|
||||
input_keyboard_line_complete_t cb)
|
||||
{
|
||||
keyboard_line->buffer = NULL;
|
||||
keyboard_line->ptr = 0;
|
||||
keyboard_line->size = 0;
|
||||
keyboard_line->cb = cb;
|
||||
keyboard_line->userdata = userdata;
|
||||
keyboard_line->enabled = true;
|
||||
|
||||
return (const char**)&keyboard_line->buffer;
|
||||
}
|
||||
|
||||
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
|
||||
static bool input_remote_init_network(input_remote_t *handle,
|
||||
uint16_t port, unsigned user)
|
||||
|
@ -100,6 +100,31 @@ struct retro_keybind
|
||||
bool valid;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* line_complete callback (when carriage return is pressed)
|
||||
*
|
||||
* @param userdata User data which will be passed to subsequent callbacks.
|
||||
* @param line the line of input, which can be NULL.
|
||||
**/
|
||||
typedef void (*input_keyboard_line_complete_t)(void *userdata,
|
||||
const char *line);
|
||||
|
||||
struct input_keyboard_line
|
||||
{
|
||||
char *buffer;
|
||||
void *userdata;
|
||||
/** Line complete callback.
|
||||
* Calls back after return is
|
||||
* pressed with the completed line.
|
||||
* Line can be NULL.
|
||||
**/
|
||||
input_keyboard_line_complete_t cb;
|
||||
size_t ptr;
|
||||
size_t size;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
extern struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END];
|
||||
extern struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END];
|
||||
|
||||
@ -445,15 +470,6 @@ const input_device_driver_t *input_joypad_init_driver(
|
||||
void input_pad_connect(unsigned port, input_device_driver_t *driver);
|
||||
|
||||
|
||||
/**
|
||||
* line_complete callback (when carriage return is pressed)
|
||||
*
|
||||
* @param userdata User data which will be passed to subsequent callbacks.
|
||||
* @param line the line of input, which can be NULL.
|
||||
**/
|
||||
typedef void (*input_keyboard_line_complete_t)(void *userdata,
|
||||
const char *line);
|
||||
|
||||
/**
|
||||
* Callback for keypress events
|
||||
*
|
||||
@ -713,6 +729,65 @@ int16_t input_joypad_axis(
|
||||
const input_device_driver_t *drv,
|
||||
unsigned port, uint32_t joyaxis, float normal_mag);
|
||||
|
||||
/**
|
||||
* input_joypad_analog:
|
||||
* @drv : Input device driver handle.
|
||||
* @port : User number.
|
||||
* @idx : Analog key index.
|
||||
* E.g.:
|
||||
* - RETRO_DEVICE_INDEX_ANALOG_LEFT
|
||||
* - RETRO_DEVICE_INDEX_ANALOG_RIGHT
|
||||
* @ident : Analog key identifier.
|
||||
* E.g.:
|
||||
* - RETRO_DEVICE_ID_ANALOG_X
|
||||
* - RETRO_DEVICE_ID_ANALOG_Y
|
||||
* @binds : Binds of user.
|
||||
*
|
||||
* Gets analog value of analog key identifiers @idx and @ident
|
||||
* from user with number @port with provided keybinds (@binds).
|
||||
*
|
||||
* Returns: analog value on success, otherwise 0.
|
||||
**/
|
||||
int16_t input_joypad_analog_button(
|
||||
float input_analog_deadzone,
|
||||
float input_analog_sensitivity,
|
||||
const input_device_driver_t *drv,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
unsigned ident,
|
||||
const struct retro_keybind *bind);
|
||||
|
||||
int16_t input_joypad_analog_axis(
|
||||
unsigned input_analog_dpad_mode,
|
||||
float input_analog_deadzone,
|
||||
float input_analog_sensitivity,
|
||||
const input_device_driver_t *drv,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
unsigned idx,
|
||||
unsigned ident,
|
||||
const struct retro_keybind *binds);
|
||||
|
||||
bool input_keyboard_line_append(
|
||||
struct input_keyboard_line *keyboard_line,
|
||||
const char *word);
|
||||
|
||||
/**
|
||||
* input_keyboard_start_line:
|
||||
* @userdata : Userdata.
|
||||
* @cb : Line complete callback function.
|
||||
*
|
||||
* Sets function pointer for keyboard line handle.
|
||||
*
|
||||
* The underlying buffer can be reallocated at any time
|
||||
* (or be NULL), but the pointer to it remains constant
|
||||
* throughout the objects lifetime.
|
||||
*
|
||||
* Returns: underlying buffer of the keyboard line.
|
||||
**/
|
||||
const char **input_keyboard_start_line(
|
||||
void *userdata,
|
||||
struct input_keyboard_line *keyboard_line,
|
||||
input_keyboard_line_complete_t cb);
|
||||
|
||||
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
|
||||
void input_remote_parse_packet(
|
||||
input_remote_state_t *input_state,
|
||||
|
267
retroarch.c
267
retroarch.c
@ -21780,210 +21780,6 @@ bool input_mouse_grabbed(void)
|
||||
return p_rarch->input_driver_grab_mouse_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* input_joypad_analog:
|
||||
* @drv : Input device driver handle.
|
||||
* @port : User number.
|
||||
* @idx : Analog key index.
|
||||
* E.g.:
|
||||
* - RETRO_DEVICE_INDEX_ANALOG_LEFT
|
||||
* - RETRO_DEVICE_INDEX_ANALOG_RIGHT
|
||||
* @ident : Analog key identifier.
|
||||
* E.g.:
|
||||
* - RETRO_DEVICE_ID_ANALOG_X
|
||||
* - RETRO_DEVICE_ID_ANALOG_Y
|
||||
* @binds : Binds of user.
|
||||
*
|
||||
* Gets analog value of analog key identifiers @idx and @ident
|
||||
* from user with number @port with provided keybinds (@binds).
|
||||
*
|
||||
* Returns: analog value on success, otherwise 0.
|
||||
**/
|
||||
static int16_t input_joypad_analog_button(
|
||||
float input_analog_deadzone,
|
||||
float input_analog_sensitivity,
|
||||
const input_device_driver_t *drv,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
unsigned ident,
|
||||
const struct retro_keybind *bind)
|
||||
{
|
||||
int16_t res = 0;
|
||||
float normal_mag = 0.0f;
|
||||
uint32_t axis = (bind->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident].joyaxis
|
||||
: bind->joyaxis;
|
||||
|
||||
/* Analog button. */
|
||||
if (input_analog_deadzone)
|
||||
{
|
||||
int16_t mult = 0;
|
||||
if (axis != AXIS_NONE)
|
||||
if ((mult = drv->axis(
|
||||
joypad_info->joy_idx, axis)) != 0)
|
||||
normal_mag = fabs((1.0f / 0x7fff) * mult);
|
||||
}
|
||||
|
||||
/* If the result is zero, it's got a digital button
|
||||
* attached to it instead */
|
||||
if ((res = abs(input_joypad_axis(
|
||||
input_analog_deadzone,
|
||||
input_analog_sensitivity,
|
||||
drv,
|
||||
joypad_info->joy_idx, axis, normal_mag))) == 0)
|
||||
{
|
||||
uint16_t key = (bind->joykey == NO_BTN)
|
||||
? joypad_info->auto_binds[ident].joykey
|
||||
: bind->joykey;
|
||||
|
||||
if (drv->button(joypad_info->joy_idx, key))
|
||||
return 0x7fff;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int16_t input_joypad_analog_axis(
|
||||
unsigned input_analog_dpad_mode,
|
||||
float input_analog_deadzone,
|
||||
float input_analog_sensitivity,
|
||||
const input_device_driver_t *drv,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
unsigned idx,
|
||||
unsigned ident,
|
||||
const struct retro_keybind *binds)
|
||||
{
|
||||
int16_t res = 0;
|
||||
/* Analog sticks. Either RETRO_DEVICE_INDEX_ANALOG_LEFT
|
||||
* or RETRO_DEVICE_INDEX_ANALOG_RIGHT */
|
||||
unsigned ident_minus = 0;
|
||||
unsigned ident_plus = 0;
|
||||
unsigned ident_x_minus = 0;
|
||||
unsigned ident_x_plus = 0;
|
||||
unsigned ident_y_minus = 0;
|
||||
unsigned ident_y_plus = 0;
|
||||
const struct retro_keybind *bind_minus = NULL;
|
||||
const struct retro_keybind *bind_plus = NULL;
|
||||
const struct retro_keybind *bind_x_minus = NULL;
|
||||
const struct retro_keybind *bind_x_plus = NULL;
|
||||
const struct retro_keybind *bind_y_minus = NULL;
|
||||
const struct retro_keybind *bind_y_plus = NULL;
|
||||
|
||||
/* Skip analog input with analog_dpad_mode */
|
||||
switch (input_analog_dpad_mode)
|
||||
{
|
||||
case ANALOG_DPAD_LSTICK:
|
||||
if (idx == RETRO_DEVICE_INDEX_ANALOG_LEFT)
|
||||
return 0;
|
||||
break;
|
||||
case ANALOG_DPAD_RSTICK:
|
||||
if (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT)
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, ident, ident_minus, ident_plus);
|
||||
|
||||
bind_minus = &binds[ident_minus];
|
||||
bind_plus = &binds[ident_plus];
|
||||
|
||||
if (!bind_minus->valid || !bind_plus->valid)
|
||||
return 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx,
|
||||
RETRO_DEVICE_ID_ANALOG_X, ident_x_minus, ident_x_plus);
|
||||
|
||||
bind_x_minus = &binds[ident_x_minus];
|
||||
bind_x_plus = &binds[ident_x_plus];
|
||||
|
||||
if (!bind_x_minus->valid || !bind_x_plus->valid)
|
||||
return 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx,
|
||||
RETRO_DEVICE_ID_ANALOG_Y, ident_y_minus, ident_y_plus);
|
||||
|
||||
bind_y_minus = &binds[ident_y_minus];
|
||||
bind_y_plus = &binds[ident_y_plus];
|
||||
|
||||
if (!bind_y_minus->valid || !bind_y_plus->valid)
|
||||
return 0;
|
||||
|
||||
{
|
||||
uint32_t axis_minus = (bind_minus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_minus].joyaxis
|
||||
: bind_minus->joyaxis;
|
||||
uint32_t axis_plus = (bind_plus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_plus].joyaxis
|
||||
: bind_plus->joyaxis;
|
||||
float normal_mag = 0.0f;
|
||||
|
||||
/* normalized magnitude of stick actuation, needed for scaled
|
||||
* radial deadzone */
|
||||
if (input_analog_deadzone)
|
||||
{
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
uint32_t x_axis_minus = (bind_x_minus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_x_minus].joyaxis
|
||||
: bind_x_minus->joyaxis;
|
||||
uint32_t x_axis_plus = (bind_x_plus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_x_plus].joyaxis
|
||||
: bind_x_plus->joyaxis;
|
||||
uint32_t y_axis_minus = (bind_y_minus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_y_minus].joyaxis
|
||||
: bind_y_minus->joyaxis;
|
||||
uint32_t y_axis_plus = (bind_y_plus->joyaxis == AXIS_NONE)
|
||||
? joypad_info->auto_binds[ident_y_plus].joyaxis
|
||||
: bind_y_plus->joyaxis;
|
||||
/* normalized magnitude for radial scaled analog deadzone */
|
||||
if (x_axis_plus != AXIS_NONE)
|
||||
x = drv->axis(
|
||||
joypad_info->joy_idx, x_axis_plus);
|
||||
if (x_axis_minus != AXIS_NONE)
|
||||
x += drv->axis(joypad_info->joy_idx,
|
||||
x_axis_minus);
|
||||
if (y_axis_plus != AXIS_NONE)
|
||||
y = drv->axis(
|
||||
joypad_info->joy_idx, y_axis_plus);
|
||||
if (y_axis_minus != AXIS_NONE)
|
||||
y += drv->axis(
|
||||
joypad_info->joy_idx, y_axis_minus);
|
||||
normal_mag = (1.0f / 0x7fff) * sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
res = abs(
|
||||
input_joypad_axis(
|
||||
input_analog_deadzone,
|
||||
input_analog_sensitivity,
|
||||
drv, joypad_info->joy_idx,
|
||||
axis_plus, normal_mag));
|
||||
res -= abs(
|
||||
input_joypad_axis(
|
||||
input_analog_deadzone,
|
||||
input_analog_sensitivity,
|
||||
drv, joypad_info->joy_idx,
|
||||
axis_minus, normal_mag));
|
||||
}
|
||||
|
||||
if (res == 0)
|
||||
{
|
||||
uint16_t key_minus = (bind_minus->joykey == NO_BTN)
|
||||
? joypad_info->auto_binds[ident_minus].joykey
|
||||
: bind_minus->joykey;
|
||||
uint16_t key_plus = (bind_plus->joykey == NO_BTN)
|
||||
? joypad_info->auto_binds[ident_plus].joykey
|
||||
: bind_plus->joykey;
|
||||
if (drv->button(joypad_info->joy_idx, key_plus))
|
||||
res = 0x7fff;
|
||||
if (drv->button(joypad_info->joy_idx, key_minus))
|
||||
res += -0x7fff;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void input_pad_connect(unsigned port, input_device_driver_t *driver)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
@ -22148,67 +21944,7 @@ static bool input_keyboard_line_event(
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
static bool input_keyboard_line_append(
|
||||
struct input_keyboard_line *keyboard_line,
|
||||
const char *word)
|
||||
{
|
||||
unsigned i = 0;
|
||||
unsigned len = (unsigned)strlen(word);
|
||||
char *newbuf = (char*)realloc(
|
||||
keyboard_line->buffer,
|
||||
keyboard_line->size + len * 2);
|
||||
|
||||
if (!newbuf)
|
||||
return false;
|
||||
|
||||
memmove(
|
||||
newbuf + keyboard_line->ptr + len,
|
||||
newbuf + keyboard_line->ptr,
|
||||
keyboard_line->size - keyboard_line->ptr + len);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
newbuf[keyboard_line->ptr]= word[i];
|
||||
keyboard_line->ptr++;
|
||||
keyboard_line->size++;
|
||||
}
|
||||
|
||||
newbuf[keyboard_line->size] = '\0';
|
||||
|
||||
keyboard_line->buffer = newbuf;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* input_keyboard_start_line:
|
||||
* @userdata : Userdata.
|
||||
* @cb : Line complete callback function.
|
||||
*
|
||||
* Sets function pointer for keyboard line handle.
|
||||
*
|
||||
* The underlying buffer can be reallocated at any time
|
||||
* (or be NULL), but the pointer to it remains constant
|
||||
* throughout the objects lifetime.
|
||||
*
|
||||
* Returns: underlying buffer of the keyboard line.
|
||||
**/
|
||||
static const char **input_keyboard_start_line(
|
||||
void *userdata,
|
||||
struct input_keyboard_line *keyboard_line,
|
||||
input_keyboard_line_complete_t cb)
|
||||
{
|
||||
keyboard_line->buffer = NULL;
|
||||
keyboard_line->ptr = 0;
|
||||
keyboard_line->size = 0;
|
||||
keyboard_line->cb = cb;
|
||||
keyboard_line->userdata = userdata;
|
||||
keyboard_line->enabled = true;
|
||||
|
||||
return (const char**)&keyboard_line->buffer;
|
||||
}
|
||||
|
||||
#ifdef HAVE_ACCESSIBILITY
|
||||
#if defined(HAVE_MENU) && defined(HAVE_ACCESSIBILITY)
|
||||
static const char *accessibility_lut_name(char key)
|
||||
{
|
||||
switch (key)
|
||||
@ -22288,7 +22024,6 @@ static const char *accessibility_lut_name(char key)
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* input_keyboard_event:
|
||||
|
@ -1119,21 +1119,6 @@ struct turbo_buttons
|
||||
bool mode1_enable[MAX_USERS];
|
||||
};
|
||||
|
||||
struct input_keyboard_line
|
||||
{
|
||||
char *buffer;
|
||||
void *userdata;
|
||||
/** Line complete callback.
|
||||
* Calls back after return is
|
||||
* pressed with the completed line.
|
||||
* Line can be NULL.
|
||||
**/
|
||||
input_keyboard_line_complete_t cb;
|
||||
size_t ptr;
|
||||
size_t size;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
typedef struct input_game_focus_state
|
||||
{
|
||||
bool enabled;
|
||||
|
@ -149,22 +149,6 @@ static void driver_location_stop(void);
|
||||
static bool driver_location_start(void);
|
||||
static void driver_camera_stop(void);
|
||||
static bool driver_camera_start(void);
|
||||
static int16_t input_joypad_analog_button(
|
||||
float input_analog_deadzone,
|
||||
float input_analog_sensitivity,
|
||||
const input_device_driver_t *drv,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
unsigned ident,
|
||||
const struct retro_keybind *binds);
|
||||
static int16_t input_joypad_analog_axis(
|
||||
unsigned input_analog_dpad_mode,
|
||||
float input_analog_deadzone,
|
||||
float input_analog_sensitivity,
|
||||
const input_device_driver_t *drv,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
unsigned idx,
|
||||
unsigned ident,
|
||||
const struct retro_keybind *binds);
|
||||
|
||||
#ifdef HAVE_ACCESSIBILITY
|
||||
static bool is_accessibility_enabled(bool accessibility_enable,
|
||||
@ -177,13 +161,6 @@ static bool accessibility_speak_priority(
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
static bool input_keyboard_line_append(
|
||||
struct input_keyboard_line *keyboard_line,
|
||||
const char *word);
|
||||
static const char **input_keyboard_start_line(
|
||||
void *userdata,
|
||||
struct input_keyboard_line *keyboard_line,
|
||||
input_keyboard_line_complete_t cb);
|
||||
static int menu_input_post_iterate(
|
||||
struct rarch_state *p_rarch,
|
||||
gfx_display_t *p_disp,
|
||||
|
Loading…
x
Reference in New Issue
Block a user