(input_driver.c) Cleanup

This commit is contained in:
twinaphex 2019-04-21 07:46:52 +02:00
parent af2805406d
commit a79eec8698

View File

@ -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)
{
/* current axis is negative */
if (AXIS_NEG_GET(joyaxis) < 2)
{
/* current stick is the left */
if (AXIS_NEG_GET(joyaxis) < 2)
left = true;
}
else
left = false;
}
else
{
/* current axis is positive */
if (AXIS_POS_GET(joyaxis) < 2)
{
/* current stick is the left */
if (AXIS_POS_GET(joyaxis) < 2)
left = true;
}
else
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)
{
/* 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 y = input_joypad_axis_raw(drv, port, left ? 1 : 3);
int mag = sqrt(x * x + y * y);
float normalized;
float normal_mag = (1.0f / 0x7fff) * mag;
/* 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)
{
uint32_t axis = 0;
const struct retro_keybind *bind = NULL;
bind = &binds[ ident ];
const struct retro_keybind *bind = &binds[ ident ];
if (!bind->valid)
return 0;
@ -1805,12 +1799,9 @@ int16_t input_joypad_analog(const input_device_driver_t *drv,
res = 0x7fff;
}
}
else
{
/* not a suitable button */
else /* not a suitable button */
res = 0;
}
}
else
{
/* 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:
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN;
break;
} /* switch ( bind->mbutton ) */
}
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)
{
if (!string_is_empty(name))
{
strlcpy(input_device_config_names[port],
name,
sizeof(input_device_config_names[port]));
}
}
void input_config_set_device_display_name(unsigned port, const char *name)
{
if (!string_is_empty(name))
{
strlcpy(input_device_display_names[port],
name,
sizeof(input_device_display_names[port]));
}
}
void input_config_clear_device_name(unsigned port)
{
@ -3073,9 +3060,7 @@ void config_read_keybinds_conf(void *data)
continue;
if (!input_config_bind_map_get_valid(j))
continue;
if (!btn)
continue;
if (!prefix)
if (!btn || !prefix)
continue;
input_config_parse_key(conf, prefix, btn, bind);