mirror of
https://github.com/Oibaf66/uae-wii.git
synced 2024-11-22 02:29:17 +01:00
Add handling of the joystick hats. This allows the classic controller Dpad
to be used (maybe the wiimote as well)
This commit is contained in:
parent
0fa258f107
commit
735aa67171
@ -29,7 +29,7 @@ static struct joyinfo joys[MAX_INPUT_DEVICES];
|
||||
|
||||
static void read_joy (unsigned int nr)
|
||||
{
|
||||
unsigned int num, i, axes, axis;
|
||||
unsigned int num, i, axes, axis, hats;
|
||||
SDL_Joystick *joy;
|
||||
|
||||
if (currprefs.input_selected_setting == 0) {
|
||||
@ -43,6 +43,25 @@ static void read_joy (unsigned int nr)
|
||||
setjoystickstate (nr, i, axis, 32767);
|
||||
}
|
||||
|
||||
/* Handle hat - used e.g., for the Wii */
|
||||
hats = SDL_JoystickNumHats (joy);
|
||||
for (i = 0; i < hats; i++) {
|
||||
Uint8 v = SDL_JoystickGetHat (joy, i);
|
||||
int x = 0, y = 0;
|
||||
|
||||
if (v & SDL_HAT_UP)
|
||||
y = -1;
|
||||
if (v & SDL_HAT_DOWN)
|
||||
y = 1;
|
||||
if (v & SDL_HAT_LEFT)
|
||||
x = -1;
|
||||
if (v & SDL_HAT_RIGHT)
|
||||
x = 1;
|
||||
|
||||
setjoystickstate (nr, 0, x, 1);
|
||||
setjoystickstate (nr, 1, y, 1);
|
||||
}
|
||||
|
||||
num = SDL_JoystickNumButtons (joy);
|
||||
for (i = 0; i < num; i++) {
|
||||
int bs = SDL_JoystickGetButton (joy, i) ? 1 : 0;
|
||||
|
Loading…
Reference in New Issue
Block a user