mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +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.
|
// Check hat.
|
||||||
if (GET_HAT_DIR(joykey))
|
if (GET_HAT_DIR(joykey))
|
||||||
{
|
{
|
||||||
int hat = GET_HAT(joykey);
|
uint16_t hat = GET_HAT(joykey);
|
||||||
if (hat < (int)sdl->num_hats[port_num])
|
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);
|
case HAT_UP_MASK:
|
||||||
switch (GET_HAT_DIR(joykey))
|
return dir & SDL_HAT_UP;
|
||||||
{
|
case HAT_DOWN_MASK:
|
||||||
case HAT_UP_MASK:
|
return dir & SDL_HAT_DOWN;
|
||||||
if (dir & SDL_HAT_UP)
|
case HAT_LEFT_MASK:
|
||||||
return true;
|
return dir & SDL_HAT_LEFT;
|
||||||
break;
|
case HAT_RIGHT_MASK:
|
||||||
case HAT_DOWN_MASK:
|
return dir & SDL_HAT_RIGHT;
|
||||||
if (dir & SDL_HAT_DOWN)
|
default:
|
||||||
return true;
|
return false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Check the button
|
else // Check the button
|
||||||
{
|
{
|
||||||
if (joykey < sdl->num_buttons[port_num] && SDL_JoystickGetButton(sdl->joysticks[port_num], joykey))
|
if (joykey < sdl->num_buttons[port_num] && SDL_JoystickGetButton(sdl->joysticks[port_num], joykey))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool sdl_axis_pressed(sdl_input_t *sdl, int port_num, uint32_t joyaxis)
|
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)
|
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;
|
SSNES_WARN("Found invalid hat in config!\n");
|
||||||
int hat = strtol(str, &dir, 0);
|
return;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
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