Handle hat rotation

This commit is contained in:
simon.kagstrom 2010-02-24 06:32:46 +00:00
parent 56f1d9c22d
commit 76e8e210ae
2 changed files with 30 additions and 14 deletions

View File

@ -837,23 +837,43 @@ uint8 C64::poll_joystick_hats(int port)
for (i = 0; i < hats; i++) { for (i = 0; i < hats; i++) {
Uint8 v = SDL_JoystickGetHat (js, i); Uint8 v = SDL_JoystickGetHat (js, i);
Uint8 up_mask = 0xfe;
Uint8 down_mask = 0xfd;
Uint8 left_mask = 0xfb;
Uint8 right_mask = 0xf7;
event_t up_ev = KEY_UP;
event_t down_ev = KEY_DOWN;
event_t left_ev = KEY_LEFT;
event_t right_ev = KEY_RIGHT;
if (ThePrefs.MenuJoystickHats[0] == HAT_ROTATED_90)
{
up_mask = 0xf7;
down_mask = 0xfb;
left_mask = 0xfe;
right_mask = 0xfd;
up_ev = KEY_RIGHT;
down_ev = KEY_LEFT;
left_ev = KEY_UP;
right_ev = KEY_DOWN;
}
/* FIXME! This is the wrong way for the Wii */ /* FIXME! This is the wrong way for the Wii */
if (v & SDL_HAT_UP) { if (v & SDL_HAT_UP) {
out &= 0xfe; out &= up_mask;
Gui::gui->pushEvent(KEY_UP); Gui::gui->pushEvent(up_ev);
} }
if (v & SDL_HAT_DOWN) { if (v & SDL_HAT_DOWN) {
out &= 0xfd; out &= down_mask;
Gui::gui->pushEvent(KEY_DOWN); Gui::gui->pushEvent(down_ev);
} }
if (v & SDL_HAT_LEFT) { if (v & SDL_HAT_LEFT) {
out &= 0xfb; out &= left_mask;
Gui::gui->pushEvent(KEY_LEFT); Gui::gui->pushEvent(left_ev);
} }
if (v & SDL_HAT_RIGHT) { if (v & SDL_HAT_RIGHT) {
out &= 0xf7; out &= right_mask;
Gui::gui->pushEvent(KEY_RIGHT); Gui::gui->pushEvent(right_ev);
} }
} }

View File

@ -171,13 +171,9 @@ void Prefs::SetupJoystickDefaults()
/* Saitek P380 */ /* Saitek P380 */
else if (strcmp(name, "Jess Tech Dual Analog Pad") == 0) else if (strcmp(name, "Jess Tech Dual Analog Pad") == 0)
{ {
/* Hat is plain */
/* Pad */ /* Pad */
this->JoystickHats[0] = 0x41; /* Up */ this->JoystickHats[0] = HAT_PLAIN;
this->JoystickHats[1] = 0x42; /* Down */ this->MenuJoystickHats[0] = HAT_PLAIN;
this->JoystickHats[2] = 0x44; /* Left */
this->JoystickHats[3] = 0x48; /* Right */
/* Analogue parts */ /* Analogue parts */
this->JoystickAxes[0] = JOY_HORIZ; this->JoystickAxes[0] = JOY_HORIZ;