Make second joystick works again
This commit is contained in:
parent
5de07e0360
commit
810aa1a7d4
3 changed files with 55 additions and 9 deletions
|
@ -278,10 +278,10 @@ uae_u16 JOY0DAT (void)
|
||||||
{
|
{
|
||||||
update_mouse_xy();
|
update_mouse_xy();
|
||||||
#ifdef RASPBERRY
|
#ifdef RASPBERRY
|
||||||
if (currprefs.pandora_custom_dpad == 0)
|
|
||||||
return joy0dir;
|
|
||||||
if (currprefs.pandora_custom_dpad == 1)
|
if (currprefs.pandora_custom_dpad == 1)
|
||||||
return ((uae_u8)mouse_x) | ((uae_u16)mouse_y << 8);
|
return ((uae_u8)mouse_x) | ((uae_u16)mouse_y << 8);
|
||||||
|
else
|
||||||
|
return joy0dir;
|
||||||
#else
|
#else
|
||||||
return ((uae_u8)mouse_x) + ((uae_u16)mouse_y << 8) + joy0dir;
|
return ((uae_u8)mouse_x) + ((uae_u16)mouse_y << 8) + joy0dir;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -74,32 +74,63 @@ void read_joystick(int nr, unsigned int *dir, int *button)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*button = 0;
|
*button = 0;
|
||||||
|
|
||||||
|
#ifndef RASPBERRY
|
||||||
if(currprefs.pandora_joyPort != 0)
|
if(currprefs.pandora_joyPort != 0)
|
||||||
{
|
{
|
||||||
// Only one joystick active
|
// Only one joystick active
|
||||||
if((nr == 0 && currprefs.pandora_joyPort == 2) || (nr == 1 && currprefs.pandora_joyPort == 1))
|
if((nr == 0 && currprefs.pandora_joyPort == 2) || (nr == 1 && currprefs.pandora_joyPort == 1))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
*dir = 0;
|
*dir = 0;
|
||||||
|
|
||||||
SDL_JoystickUpdate ();
|
SDL_JoystickUpdate ();
|
||||||
|
|
||||||
#ifdef RASPBERRY
|
|
||||||
// Always check joystick state on Raspberry pi.
|
if (nr != 1)
|
||||||
#else
|
{
|
||||||
|
// get joystick direction via joystick or Hat
|
||||||
|
int hat = SDL_JoystickGetHat(joy,0);
|
||||||
|
int val = SDL_JoystickGetAxis(joy, 0);
|
||||||
|
if ((hat & SDL_HAT_RIGHT) || (val > 6000)) right=1;
|
||||||
|
if ((hat & SDL_HAT_LEFT) || (val < -6000)) left=1;
|
||||||
|
val = SDL_JoystickGetAxis(joy, 1);
|
||||||
|
if ((hat & SDL_HAT_UP) || (val < -6000)) top=1;
|
||||||
|
if ((hat & SDL_HAT_DOWN) || (val > 6000)) bot=1;
|
||||||
|
|
||||||
|
*button |= (SDL_JoystickGetButton(joy, 0)) & 1;
|
||||||
|
*button |= ((SDL_JoystickGetButton(joy, 1)) & 1) << 1;
|
||||||
|
|
||||||
|
#ifdef SIX_AXIS_WORKAROUND
|
||||||
|
*button |= (SDL_JoystickGetButton(joy, 13)) & 1;
|
||||||
|
*button |= ((SDL_JoystickGetButton(joy, 14)) & 1) << 1;
|
||||||
|
|
||||||
|
if ( SDL_JoystickGetButton(joy, 4)) top =1;
|
||||||
|
if ( SDL_JoystickGetButton(joy, 5)) right=1;
|
||||||
|
if ( SDL_JoystickGetButton(joy, 6)) bot =1;
|
||||||
|
if ( SDL_JoystickGetButton(joy, 7)) left =1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Go over custom management which is only available for first joystick.
|
||||||
|
goto no_custom;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef PANDORA_SPECIFIC
|
||||||
if (!triggerR /*R+dpad = arrow keys*/ && currprefs.pandora_custom_dpad==0)
|
if (!triggerR /*R+dpad = arrow keys*/ && currprefs.pandora_custom_dpad==0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// get joystick direction via dPad or joystick
|
// get joystick direction via dPad or joystick or Hat
|
||||||
int hat=SDL_JoystickGetHat(joy,0);
|
int hat = SDL_JoystickGetHat(joy,0);
|
||||||
int val = SDL_JoystickGetAxis(joy, 0);
|
int val = SDL_JoystickGetAxis(joy, 0);
|
||||||
if (((hat & SDL_HAT_RIGHT) && currprefs.pandora_custom_dpad < 2) || (dpadRight && currprefs.pandora_custom_dpad < 2) || val > 6000) right=1;
|
if (((hat & SDL_HAT_RIGHT) && currprefs.pandora_custom_dpad < 2) || (dpadRight && currprefs.pandora_custom_dpad < 2) || val > 6000) right=1;
|
||||||
if (((hat & SDL_HAT_LEFT) && currprefs.pandora_custom_dpad < 2) || (dpadLeft && currprefs.pandora_custom_dpad < 2) || val < -6000) left=1;
|
if (((hat & SDL_HAT_LEFT) && currprefs.pandora_custom_dpad < 2) || (dpadLeft && currprefs.pandora_custom_dpad < 2) || val < -6000) left=1;
|
||||||
val = SDL_JoystickGetAxis(joy, 1);
|
val = SDL_JoystickGetAxis(joy, 1);
|
||||||
if (((hat & SDL_HAT_UP) && currprefs.pandora_custom_dpad < 2) || (dpadUp && currprefs.pandora_custom_dpad < 2) || val < -6000) top=1;
|
if (((hat & SDL_HAT_UP) && currprefs.pandora_custom_dpad < 2) || (dpadUp && currprefs.pandora_custom_dpad < 2) || val < -6000) top=1;
|
||||||
if (((hat & SDL_HAT_DOWN) && currprefs.pandora_custom_dpad < 2) || (dpadDown && currprefs.pandora_custom_dpad < 2) || val > 6000) bot=1;
|
if (((hat & SDL_HAT_DOWN) && currprefs.pandora_custom_dpad < 2) || (dpadDown && currprefs.pandora_custom_dpad < 2) || val > 6000) bot=1;
|
||||||
|
|
||||||
if (currprefs.pandora_joyConf)
|
if (currprefs.pandora_joyConf)
|
||||||
{
|
{
|
||||||
if ((buttonX && currprefs.pandora_jump > -1) || SDL_JoystickGetButton(joy, currprefs.pandora_jump))
|
if ((buttonX && currprefs.pandora_jump > -1) || SDL_JoystickGetButton(joy, currprefs.pandora_jump))
|
||||||
|
@ -107,6 +138,8 @@ void read_joystick(int nr, unsigned int *dir, int *button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(currprefs.pandora_customControls)
|
if(currprefs.pandora_customControls)
|
||||||
{
|
{
|
||||||
// get joystick direction via custom keys
|
// get joystick direction via custom keys
|
||||||
|
@ -143,6 +176,7 @@ void read_joystick(int nr, unsigned int *dir, int *button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(currprefs.pandora_custom_dpad == 0) // dPad as joystick
|
if(currprefs.pandora_custom_dpad == 0) // dPad as joystick
|
||||||
{
|
{
|
||||||
// Handle autofire (only available if no custom controls active)
|
// Handle autofire (only available if no custom controls active)
|
||||||
|
@ -200,6 +234,7 @@ void read_joystick(int nr, unsigned int *dir, int *button)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef RASPBERRY
|
#ifdef RASPBERRY
|
||||||
if(!currprefs.pandora_customControls || currprefs.pandora_custom_A == 0)
|
if(!currprefs.pandora_customControls || currprefs.pandora_custom_A == 0)
|
||||||
*button |= (SDL_JoystickGetButton(joy, 0)) & 1;
|
*button |= (SDL_JoystickGetButton(joy, 0)) & 1;
|
||||||
|
@ -216,6 +251,8 @@ void read_joystick(int nr, unsigned int *dir, int *button)
|
||||||
if (!currprefs.pandora_customControls && SDL_JoystickGetButton(joy, 7)) left=1;
|
if (!currprefs.pandora_customControls && SDL_JoystickGetButton(joy, 7)) left=1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
no_custom:
|
||||||
|
|
||||||
// normal joystick movement
|
// normal joystick movement
|
||||||
if (left)
|
if (left)
|
||||||
top = !top;
|
top = !top;
|
||||||
|
|
|
@ -1091,6 +1091,9 @@ void handle_events (void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_JOYBUTTONDOWN: /* Handle Joystick Button Presses */
|
case SDL_JOYBUTTONDOWN: /* Handle Joystick Button Presses */
|
||||||
|
// Handle custom only for first joystick
|
||||||
|
if (rEvent.jbutton.which != 0)
|
||||||
|
break;
|
||||||
if (rEvent.jbutton.button == 8) JoystickQuit[0] = 1; //Next if statements are for buttons 8 & 9 together to quit emulator
|
if (rEvent.jbutton.button == 8) JoystickQuit[0] = 1; //Next if statements are for buttons 8 & 9 together to quit emulator
|
||||||
if (rEvent.jbutton.button == 9) JoystickQuit[1] = 1;
|
if (rEvent.jbutton.button == 9) JoystickQuit[1] = 1;
|
||||||
if (JoystickQuit[0] && JoystickQuit[1])
|
if (JoystickQuit[0] && JoystickQuit[1])
|
||||||
|
@ -1106,6 +1109,9 @@ void handle_events (void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_JOYBUTTONUP: /* Handle Joystick Button Releases */
|
case SDL_JOYBUTTONUP: /* Handle Joystick Button Releases */
|
||||||
|
// Handle custom only for first joystick
|
||||||
|
if (rEvent.jbutton.which != 0)
|
||||||
|
break;
|
||||||
if (rEvent.jbutton.button == 8) JoystickQuit[0] = 0;
|
if (rEvent.jbutton.button == 8) JoystickQuit[0] = 0;
|
||||||
if (rEvent.jbutton.button == 9) JoystickQuit[1] = 0;
|
if (rEvent.jbutton.button == 9) JoystickQuit[1] = 0;
|
||||||
if (rEvent.jbutton.button > 5 && currprefs.pandora_custom_dpad < 3) break; //Ignore buttons num above 5 if Custom DPad is not on special
|
if (rEvent.jbutton.button > 5 && currprefs.pandora_custom_dpad < 3) break; //Ignore buttons num above 5 if Custom DPad is not on special
|
||||||
|
@ -1116,6 +1122,9 @@ void handle_events (void)
|
||||||
if (currprefs.pandora_custom_dpad == 2 )
|
if (currprefs.pandora_custom_dpad == 2 )
|
||||||
{
|
{
|
||||||
case SDL_JOYHATMOTION:
|
case SDL_JOYHATMOTION:
|
||||||
|
// Handle custom only for first joystick
|
||||||
|
if (rEvent.jbutton.which != 0)
|
||||||
|
break;
|
||||||
if (rEvent.jhat.value & SDL_HAT_UP) JoystickButton[6] = 1; else JoystickButton[6] = 0;
|
if (rEvent.jhat.value & SDL_HAT_UP) JoystickButton[6] = 1; else JoystickButton[6] = 0;
|
||||||
if (rEvent.jhat.value & SDL_HAT_DOWN) JoystickButton[7] = 1; else JoystickButton[7] = 0;
|
if (rEvent.jhat.value & SDL_HAT_DOWN) JoystickButton[7] = 1; else JoystickButton[7] = 0;
|
||||||
if (rEvent.jhat.value & SDL_HAT_LEFT) JoystickButton[8] = 1; else JoystickButton[8] = 0;
|
if (rEvent.jhat.value & SDL_HAT_LEFT) JoystickButton[8] = 1; else JoystickButton[8] = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue