mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
(input_driver.c) Cleanup
This commit is contained in:
parent
af2805406d
commit
a79eec8698
@ -897,22 +897,18 @@ static int16_t input_joypad_axis(const input_device_driver_t *drv, unsigned port
|
|||||||
if (AXIS_POS_GET(joyaxis) == AXIS_DIR_NONE)
|
if (AXIS_POS_GET(joyaxis) == AXIS_DIR_NONE)
|
||||||
{
|
{
|
||||||
/* current axis is negative */
|
/* current axis is negative */
|
||||||
if (AXIS_NEG_GET(joyaxis) < 2)
|
|
||||||
{
|
|
||||||
/* current stick is the left */
|
/* current stick is the left */
|
||||||
|
if (AXIS_NEG_GET(joyaxis) < 2)
|
||||||
left = true;
|
left = true;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
left = false;
|
left = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* current axis is positive */
|
/* current axis is positive */
|
||||||
if (AXIS_POS_GET(joyaxis) < 2)
|
|
||||||
{
|
|
||||||
/* current stick is the left */
|
/* current stick is the left */
|
||||||
|
if (AXIS_POS_GET(joyaxis) < 2)
|
||||||
left = true;
|
left = true;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
left = false;
|
left = false;
|
||||||
}
|
}
|
||||||
@ -920,10 +916,10 @@ static int16_t input_joypad_axis(const input_device_driver_t *drv, unsigned port
|
|||||||
if (settings->floats.input_analog_deadzone)
|
if (settings->floats.input_analog_deadzone)
|
||||||
{
|
{
|
||||||
/* 0/1 are the left analog X/Y axes, 2/3 are the right analog X/Y axes */
|
/* 0/1 are the left analog X/Y axes, 2/3 are the right analog X/Y axes */
|
||||||
|
float normalized;
|
||||||
int16_t x = input_joypad_axis_raw(drv, port, left ? 0 : 2);
|
int16_t x = input_joypad_axis_raw(drv, port, left ? 0 : 2);
|
||||||
int16_t y = input_joypad_axis_raw(drv, port, left ? 1 : 3);
|
int16_t y = input_joypad_axis_raw(drv, port, left ? 1 : 3);
|
||||||
int mag = sqrt(x * x + y * y);
|
int mag = sqrt(x * x + y * y);
|
||||||
float normalized;
|
|
||||||
float normal_mag = (1.0f / 0x7fff) * mag;
|
float normal_mag = (1.0f / 0x7fff) * mag;
|
||||||
|
|
||||||
/* if analog value is below the deadzone, ignore it */
|
/* if analog value is below the deadzone, ignore it */
|
||||||
@ -1778,9 +1774,7 @@ int16_t input_joypad_analog(const input_device_driver_t *drv,
|
|||||||
if (ident < RARCH_FIRST_CUSTOM_BIND)
|
if (ident < RARCH_FIRST_CUSTOM_BIND)
|
||||||
{
|
{
|
||||||
uint32_t axis = 0;
|
uint32_t axis = 0;
|
||||||
const struct retro_keybind *bind = NULL;
|
const struct retro_keybind *bind = &binds[ ident ];
|
||||||
|
|
||||||
bind = &binds[ ident ];
|
|
||||||
|
|
||||||
if (!bind->valid)
|
if (!bind->valid)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1805,12 +1799,9 @@ int16_t input_joypad_analog(const input_device_driver_t *drv,
|
|||||||
res = 0x7fff;
|
res = 0x7fff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else /* not a suitable button */
|
||||||
{
|
|
||||||
/* not a suitable button */
|
|
||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Analog sticks. Either RETRO_DEVICE_INDEX_ANALOG_LEFT
|
/* Analog sticks. Either RETRO_DEVICE_INDEX_ANALOG_LEFT
|
||||||
@ -2852,7 +2843,7 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind,
|
|||||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
|
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
|
||||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN;
|
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN;
|
||||||
break;
|
break;
|
||||||
} /* switch ( bind->mbutton ) */
|
}
|
||||||
|
|
||||||
if (tag != 0)
|
if (tag != 0)
|
||||||
{
|
{
|
||||||
@ -2937,22 +2928,18 @@ void input_config_set_device_config_path(unsigned port, const char *path)
|
|||||||
void input_config_set_device_config_name(unsigned port, const char *name)
|
void input_config_set_device_config_name(unsigned port, const char *name)
|
||||||
{
|
{
|
||||||
if (!string_is_empty(name))
|
if (!string_is_empty(name))
|
||||||
{
|
|
||||||
strlcpy(input_device_config_names[port],
|
strlcpy(input_device_config_names[port],
|
||||||
name,
|
name,
|
||||||
sizeof(input_device_config_names[port]));
|
sizeof(input_device_config_names[port]));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void input_config_set_device_display_name(unsigned port, const char *name)
|
void input_config_set_device_display_name(unsigned port, const char *name)
|
||||||
{
|
{
|
||||||
if (!string_is_empty(name))
|
if (!string_is_empty(name))
|
||||||
{
|
|
||||||
strlcpy(input_device_display_names[port],
|
strlcpy(input_device_display_names[port],
|
||||||
name,
|
name,
|
||||||
sizeof(input_device_display_names[port]));
|
sizeof(input_device_display_names[port]));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void input_config_clear_device_name(unsigned port)
|
void input_config_clear_device_name(unsigned port)
|
||||||
{
|
{
|
||||||
@ -3073,9 +3060,7 @@ void config_read_keybinds_conf(void *data)
|
|||||||
continue;
|
continue;
|
||||||
if (!input_config_bind_map_get_valid(j))
|
if (!input_config_bind_map_get_valid(j))
|
||||||
continue;
|
continue;
|
||||||
if (!btn)
|
if (!btn || !prefix)
|
||||||
continue;
|
|
||||||
if (!prefix)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
input_config_parse_key(conf, prefix, btn, bind);
|
input_config_parse_key(conf, prefix, btn, bind);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user