mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-09 10:54:30 +00:00
Merge branch 'master' into ratecontrol
This commit is contained in:
commit
3407e765c3
@ -193,39 +193,32 @@ static bool sdl_joykey_pressed(sdl_input_t *sdl, int port_num, uint16_t joykey)
|
||||
// Check hat.
|
||||
if (GET_HAT_DIR(joykey))
|
||||
{
|
||||
int hat = GET_HAT(joykey);
|
||||
if (hat < (int)sdl->num_hats[port_num])
|
||||
uint16_t hat = GET_HAT(joykey);
|
||||
if (hat >= sdl->num_hats[port_num])
|
||||
return false;
|
||||
|
||||
Uint8 dir = SDL_JoystickGetHat(sdl->joysticks[port_num], hat);
|
||||
switch (GET_HAT_DIR(joykey))
|
||||
{
|
||||
Uint8 dir = SDL_JoystickGetHat(sdl->joysticks[port_num], hat);
|
||||
switch (GET_HAT_DIR(joykey))
|
||||
{
|
||||
case HAT_UP_MASK:
|
||||
if (dir & SDL_HAT_UP)
|
||||
return true;
|
||||
break;
|
||||
case HAT_DOWN_MASK:
|
||||
if (dir & SDL_HAT_DOWN)
|
||||
return true;
|
||||
break;
|
||||
case HAT_LEFT_MASK:
|
||||
if (dir & SDL_HAT_LEFT)
|
||||
return true;
|
||||
break;
|
||||
case HAT_RIGHT_MASK:
|
||||
if (dir & SDL_HAT_RIGHT)
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case HAT_UP_MASK:
|
||||
return dir & SDL_HAT_UP;
|
||||
case HAT_DOWN_MASK:
|
||||
return dir & SDL_HAT_DOWN;
|
||||
case HAT_LEFT_MASK:
|
||||
return dir & SDL_HAT_LEFT;
|
||||
case HAT_RIGHT_MASK:
|
||||
return dir & SDL_HAT_RIGHT;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else // Check the button
|
||||
{
|
||||
if (joykey < sdl->num_buttons[port_num] && SDL_JoystickGetButton(sdl->joysticks[port_num], joykey))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool sdl_axis_pressed(sdl_input_t *sdl, int port_num, uint32_t joyaxis)
|
||||
|
41
settings.c
41
settings.c
@ -701,27 +701,30 @@ static void read_keybinds_keyboard(config_file_t *conf, unsigned player, unsigne
|
||||
|
||||
static void parse_hat(struct snes_keybind *bind, const char *str)
|
||||
{
|
||||
if (isdigit(*str))
|
||||
if (!isdigit(*str))
|
||||
return;
|
||||
|
||||
char *dir = NULL;
|
||||
uint16_t hat = strtoul(str, &dir, 0);
|
||||
uint16_t hat_dir = 0;
|
||||
|
||||
if (!dir)
|
||||
{
|
||||
char *dir = NULL;
|
||||
int hat = strtol(str, &dir, 0);
|
||||
int hat_dir = 0;
|
||||
|
||||
if (dir)
|
||||
{
|
||||
if (strcasecmp(str, "up") == 0)
|
||||
hat_dir = HAT_UP_MASK;
|
||||
else if (strcasecmp(str, "down") == 0)
|
||||
hat_dir = HAT_DOWN_MASK;
|
||||
else if (strcasecmp(str, "left") == 0)
|
||||
hat_dir = HAT_LEFT_MASK;
|
||||
else if (strcasecmp(str, "right") == 0)
|
||||
hat_dir = HAT_RIGHT_MASK;
|
||||
|
||||
if (hat_dir)
|
||||
bind->joykey = HAT_MAP(hat, hat_dir);
|
||||
}
|
||||
SSNES_WARN("Found invalid hat in config!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcasecmp(dir, "up") == 0)
|
||||
hat_dir = HAT_UP_MASK;
|
||||
else if (strcasecmp(dir, "down") == 0)
|
||||
hat_dir = HAT_DOWN_MASK;
|
||||
else if (strcasecmp(dir, "left") == 0)
|
||||
hat_dir = HAT_LEFT_MASK;
|
||||
else if (strcasecmp(dir, "right") == 0)
|
||||
hat_dir = HAT_RIGHT_MASK;
|
||||
|
||||
if (hat_dir)
|
||||
bind->joykey = HAT_MAP(hat, hat_dir);
|
||||
}
|
||||
|
||||
static void read_keybinds_button(config_file_t *conf, unsigned player, unsigned index, struct snes_keybind *bind)
|
||||
|
Loading…
x
Reference in New Issue
Block a user