Merge branch 'master' into ratecontrol

This commit is contained in:
Themaister 2012-02-18 13:05:47 +01:00
commit 3407e765c3
2 changed files with 40 additions and 44 deletions

View File

@ -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)

View File

@ -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)