Remove extraneous elses in input code

This commit is contained in:
twinaphex 2014-08-28 18:09:55 +02:00
parent 66ce3c1a0d
commit bf13548459
4 changed files with 22 additions and 28 deletions

View File

@ -254,11 +254,13 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y,
int16_t *res_x, int16_t *res_y, int16_t *res_screen_x, int16_t *res_screen_y)
{
struct rarch_viewport vp = {0};
if (driver.video && driver.video->viewport_info)
driver.video->viewport_info(driver.video_data, &vp);
else
bool have_viewport_info = driver.video && driver.video->viewport_info;
if (!have_viewport_info)
return false;
driver.video->viewport_info(driver.video_data, &vp);
int scaled_screen_x = (2 * mouse_x * 0x7fff) / (int)vp.full_width - 0x7fff;
int scaled_screen_y = (2 * mouse_y * 0x7fff) / (int)vp.full_height - 0x7fff;
if (scaled_screen_x < -0x7fff || scaled_screen_x > 0x7fff)
@ -280,6 +282,7 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y,
*res_y = scaled_y;
*res_screen_x = scaled_screen_x;
*res_screen_y = scaled_screen_y;
return true;
}
#endif
@ -1145,8 +1148,7 @@ enum retro_key input_translate_str_to_rk(const char *str)
{
if (strlen(str) == 1 && isalpha(*str))
return (enum retro_key)(RETROK_a + (tolower(*str) - (int)'a'));
else
return find_rk_bind(str);
return find_rk_bind(str);
}
void input_config_parse_key(config_file_t *conf, const char *prefix, const char *btn,
@ -1166,8 +1168,7 @@ const char *input_config_get_prefix(unsigned player, bool meta)
return meta ? "input" : bind_player_prefix[player];
else if (player != 0 && !meta)
return bind_player_prefix[player];
else
return NULL; // Don't bother with meta bind for anyone else than first player.
return NULL; // Don't bother with meta bind for anyone else than first player.
}
unsigned input_translate_str_to_bind_id(const char *str)

View File

@ -91,8 +91,7 @@ static bool sdl_bind_button_pressed(void *data, int key)
const struct retro_keybind *binds = g_settings.input.binds[0];
if (key >= 0 && key < RARCH_BIND_LIST_END)
return sdl_is_pressed((sdl_input_t*)data, 0, binds, key);
else
return false;
return false;
}
static int16_t sdl_joypad_device_state(sdl_input_t *sdl, const struct retro_keybind **binds_,
@ -101,8 +100,7 @@ static int16_t sdl_joypad_device_state(sdl_input_t *sdl, const struct retro_keyb
const struct retro_keybind *binds = binds_[port_num];
if (id < RARCH_BIND_LIST_END)
return binds[id].valid && sdl_is_pressed(sdl, port_num, binds, id);
else
return 0;
return 0;
}
static int16_t sdl_analog_device_state(sdl_input_t *sdl, const struct retro_keybind **binds,

View File

@ -49,8 +49,7 @@ static const char* pad_name(unsigned id)
#ifdef HAVE_SDL2
if (g_pads[id].controller)
return SDL_GameControllerNameForIndex(id);
else
return SDL_JoystickNameForIndex(id);
return SDL_JoystickNameForIndex(id);
#else
return SDL_JoystickName(id);
#endif
@ -62,9 +61,8 @@ static uint8_t pad_get_button(sdl_joypad_t *pad, unsigned button)
/* TODO: see if a LUT like winxinput_joypad.c's button_index_to_bitmap_code is needed. */
if (pad->controller)
return SDL_GameControllerGetButton(pad->controller, button);
else
#endif
return SDL_JoystickGetButton(pad->joypad, button);
return SDL_JoystickGetButton(pad->joypad, button);
}
static uint8_t pad_get_hat(sdl_joypad_t *pad, unsigned hat)
@ -72,9 +70,8 @@ static uint8_t pad_get_hat(sdl_joypad_t *pad, unsigned hat)
#ifdef HAVE_SDL2
if (pad->controller)
return pad_get_button(pad, hat);
else
#endif
return SDL_JoystickGetHat(pad->joypad, hat);
return SDL_JoystickGetHat(pad->joypad, hat);
}
static int16_t pad_get_axis(sdl_joypad_t *pad, unsigned axis)
@ -83,9 +80,8 @@ static int16_t pad_get_axis(sdl_joypad_t *pad, unsigned axis)
/* TODO: see if a rarch <-> sdl translation is needed. */
if (pad->controller)
return SDL_GameControllerGetAxis(pad->controller, axis);
else
#endif
return SDL_JoystickGetAxis(pad->joypad, axis);
return SDL_JoystickGetAxis(pad->joypad, axis);
}
static void pad_connect(unsigned id)
@ -281,16 +277,16 @@ static bool sdl_joypad_button(unsigned port, uint16_t joykey)
case HAT_RIGHT_MASK:
return dir & SDL_HAT_RIGHT;
default:
return false;
break;
}
}
else // Check the button
{
if (joykey < pad->num_buttons && pad_get_button(pad, joykey))
return true;
return false;
}
// Check the button
if (joykey < pad->num_buttons && pad_get_button(pad, joykey))
return true;
return false;
}
static int16_t sdl_joypad_axis(unsigned port, uint32_t joyaxis)

View File

@ -499,8 +499,7 @@ static bool udev_is_pressed(udev_input_t *udev, const struct retro_keybind *bind
const struct retro_keybind *bind = &binds[id];
return bind->valid && get_bit(udev->key_state, input_translate_rk_to_keysym(binds[id].key));
}
else
return false;
return false;
}
static int16_t udev_analog_pressed(udev_input_t *udev,