Fix for custom joystick controls
Updated custom joystick controls along with hard coding of buttons 8 + 9 together to exit emulator.
This commit is contained in:
parent
f6a6c90d3a
commit
90a5fa1649
4 changed files with 118 additions and 27 deletions
|
@ -95,11 +95,11 @@ void read_joystick(int nr, unsigned int *dir, int *button)
|
|||
// get joystick direction via dPad or joystick
|
||||
int hat=SDL_JoystickGetHat(joy,0);
|
||||
int val = SDL_JoystickGetAxis(joy, 0);
|
||||
if ((hat & SDL_HAT_RIGHT) || dpadRight || val > 4000) right=1;
|
||||
if ((hat & SDL_HAT_LEFT) || dpadLeft || val < -4000) left=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;
|
||||
val = SDL_JoystickGetAxis(joy, 1);
|
||||
if ((hat & SDL_HAT_UP) || dpadUp || val < -4000) top=1;
|
||||
if ((hat & SDL_HAT_DOWN) || dpadDown || val > 4000) bot=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 (currprefs.pandora_joyConf)
|
||||
{
|
||||
if ((buttonX && currprefs.pandora_jump > -1) || SDL_JoystickGetButton(joy, currprefs.pandora_jump))
|
||||
|
@ -182,24 +182,38 @@ void read_joystick(int nr, unsigned int *dir, int *button)
|
|||
else
|
||||
{
|
||||
// get joystick button via ABXY or joystick
|
||||
*button |= ((currprefs.pandora_button1==GP2X_BUTTON_B && buttonA) || (currprefs.pandora_button1==GP2X_BUTTON_X && buttonX) || (currprefs.pandora_button1==GP2X_BUTTON_Y && buttonY) || SDL_JoystickGetButton(joy, currprefs.pandora_button1)) & 1;
|
||||
delay++;
|
||||
if (!currprefs.pandora_customControls)
|
||||
{
|
||||
if (!currprefs.pandora_button1 == 3 && currprefs.pandora_joyConf < 2)
|
||||
{
|
||||
*button |= ((currprefs.pandora_button1==GP2X_BUTTON_B && buttonA) || (currprefs.pandora_button1==GP2X_BUTTON_X && buttonX) || (currprefs.pandora_button1==GP2X_BUTTON_Y && buttonY) || SDL_JoystickGetButton(joy, currprefs.pandora_button1)) & 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*button |= ((currprefs.pandora_button1==GP2X_BUTTON_B && buttonA) || (currprefs.pandora_button1==GP2X_BUTTON_X && buttonX)) & 1;
|
||||
}
|
||||
delay++;
|
||||
}
|
||||
|
||||
*button |= ((buttonB || SDL_JoystickGetButton(joy, currprefs.pandora_button2)) & 1) << 1;
|
||||
if (!SDL_JoystickGetButton(joy, 1))
|
||||
*button |= ((buttonB || SDL_JoystickGetButton(joy, currprefs.pandora_button2)) & 1) << 1;
|
||||
|
||||
}
|
||||
|
||||
#ifdef RASPBERRY
|
||||
*button |= (SDL_JoystickGetButton(joy, 0)) & 1;
|
||||
*button |= ((SDL_JoystickGetButton(joy, 1)) & 1) << 1;
|
||||
if(!currprefs.pandora_customControls || currprefs.pandora_custom_A == 0)
|
||||
*button |= (SDL_JoystickGetButton(joy, 0)) & 1;
|
||||
if(!currprefs.pandora_customControls || currprefs.pandora_custom_B == 0)
|
||||
*button |= ((SDL_JoystickGetButton(joy, 1)) & 1) << 1;
|
||||
#endif
|
||||
|
||||
#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;
|
||||
if (!currprefs.pandora_customControls && SDL_JoystickGetButton(joy, 4)) top=1;
|
||||
if (!currprefs.pandora_customControls && SDL_JoystickGetButton(joy, 5)) right=1;
|
||||
if (!currprefs.pandora_customControls && SDL_JoystickGetButton(joy, 6)) bot=1;
|
||||
if (!currprefs.pandora_customControls && SDL_JoystickGetButton(joy, 7)) left=1;
|
||||
#endif
|
||||
|
||||
// normal joystick movement
|
||||
|
|
|
@ -106,6 +106,10 @@ extern int keycode2amiga(SDL_keysym *prKeySym);
|
|||
extern int loadconfig_old(struct uae_prefs *p, const char *orgpath);
|
||||
extern void SetLastActiveConfig(const char *filename);
|
||||
|
||||
/* Joystick */
|
||||
int JoystickButton[20];
|
||||
int JoystickQuit[2];
|
||||
|
||||
/* Keyboard and mouse */
|
||||
int buttonstate[3];
|
||||
|
||||
|
@ -1085,6 +1089,40 @@ void handle_events (void)
|
|||
setmousestate(0, 1, y * mouseScale, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_JOYBUTTONDOWN: /* Handle Joystick Button Presses */
|
||||
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 (JoystickQuit[0] && JoystickQuit[1])
|
||||
{
|
||||
JoystickQuit[0] = 0;
|
||||
JoystickQuit[1] = 0;
|
||||
uae_quit();
|
||||
break;
|
||||
}
|
||||
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 == 0 || rEvent.jbutton.button == 1) && !currprefs.pandora_customControls) break; //Ignore buttons 0 & 1 if custom controls are not active to stop double triggering
|
||||
JoystickButton[rEvent.jbutton.button] = 1;
|
||||
break;
|
||||
|
||||
case SDL_JOYBUTTONUP: /* Handle Joystick Button Releases */
|
||||
if (rEvent.jbutton.button == 8) JoystickQuit[0] = 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 == 0 || rEvent.jbutton.button == 1) && !currprefs.pandora_customControls) break; //Ignore buttons 0 & 1 if custom controls are not active to stop double triggering
|
||||
JoystickButton[rEvent.jbutton.button] = 0;
|
||||
break;
|
||||
|
||||
if (currprefs.pandora_custom_dpad == 2 )
|
||||
{
|
||||
case SDL_JOYHATMOTION:
|
||||
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_LEFT) JoystickButton[8] = 1; else JoystickButton[8] = 0;
|
||||
if (rEvent.jhat.value & SDL_HAT_RIGHT) JoystickButton[9] = 1; else JoystickButton[9] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -559,25 +559,34 @@ void gui_handle_events (void)
|
|||
int key = 0;
|
||||
|
||||
Uint8 *keystate = SDL_GetKeyState(NULL);
|
||||
dpadUp = keystate[SDLK_UP];
|
||||
dpadDown = keystate[SDLK_DOWN];
|
||||
dpadLeft = keystate[SDLK_LEFT];
|
||||
dpadRight = keystate[SDLK_RIGHT];
|
||||
buttonA = keystate[SDLK_HOME];
|
||||
buttonB = keystate[SDLK_END];
|
||||
buttonX = keystate[SDLK_PAGEDOWN];
|
||||
buttonY = keystate[SDLK_PAGEUP];
|
||||
triggerL = keystate[SDLK_RSHIFT];
|
||||
triggerR = keystate[SDLK_RCTRL];
|
||||
|
||||
if(keystate[SDLK_HOME] || JoystickButton[0]) //Updated with Joystick input
|
||||
buttonA = 1; else buttonA = 0;
|
||||
if(keystate[SDLK_END] || JoystickButton[1])
|
||||
buttonB = 1; else buttonB = 0;
|
||||
if(keystate[SDLK_PAGEDOWN] || JoystickButton[2])
|
||||
buttonX = 1; else buttonX = 0;
|
||||
if(keystate[SDLK_PAGEUP] || JoystickButton[3])
|
||||
buttonY = 1; else buttonY = 0;
|
||||
if(keystate[SDLK_RSHIFT] || JoystickButton[4])
|
||||
triggerL = 1; else triggerL = 0;
|
||||
if(keystate[SDLK_RCTRL] || JoystickButton[5])
|
||||
triggerR = 1; else triggerR = 0;
|
||||
if(keystate[SDLK_UP] || JoystickButton[6])
|
||||
dpadUp = 1; else dpadUp = 0;
|
||||
if(keystate[SDLK_DOWN] || JoystickButton[7])
|
||||
dpadDown = 1; else dpadDown = 0;
|
||||
if(keystate[SDLK_LEFT] || JoystickButton[8])
|
||||
dpadLeft = 1; else dpadLeft = 0;
|
||||
if(keystate[SDLK_RIGHT] || JoystickButton[9])
|
||||
dpadRight = 1; else dpadRight = 0;
|
||||
|
||||
if(keystate[SDLK_F12])
|
||||
goMenu();
|
||||
if(uae4all_keystate[AK_CTRL] && uae4all_keystate[AK_LAMI] && uae4all_keystate[AK_RAMI])
|
||||
uae_reset(0);
|
||||
#ifndef PANDORA_SPECIFIC
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef PANDORA_SPECIFIC
|
||||
//L + R
|
||||
if(triggerL && triggerR)
|
||||
{
|
||||
|
@ -711,6 +720,7 @@ void gui_handle_events (void)
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
if(currprefs.pandora_customControls)
|
||||
{
|
||||
if(currprefs.pandora_custom_dpad == 2) // dPad is custom
|
||||
|
@ -1006,7 +1016,34 @@ void gui_handle_events (void)
|
|||
justPressedR=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef RASPBERRY
|
||||
|
||||
else if(currprefs.pandora_joyConf < 2)
|
||||
{
|
||||
// Y-Button mapped to Space
|
||||
if(buttonY)
|
||||
{
|
||||
if(!justPressedY)
|
||||
{
|
||||
//SPACE
|
||||
uae4all_keystate[AK_SPC] = 1;
|
||||
record_key(AK_SPC << 1);
|
||||
justPressedY=1;
|
||||
}
|
||||
}
|
||||
else if(justPressedY)
|
||||
{
|
||||
//SPACE
|
||||
uae4all_keystate[AK_SPC] = 0;
|
||||
record_key((AK_SPC << 1) | 1);
|
||||
justPressedY=0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PANDORA_SPECIFIC
|
||||
else // Custom controls not active
|
||||
{
|
||||
if(currprefs.pandora_custom_dpad < 2 && triggerR)
|
||||
|
@ -1338,6 +1375,7 @@ void gui_handle_events (void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void gui_disk_image_change (int unitnum, const char *name, bool writeprotected)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define OPTIONSFILENAME "uaeconfig"
|
||||
|
||||
extern int emulating;
|
||||
extern int JoystickButton[20]; //Joystick Button state
|
||||
extern int uae4all_keystate[256];
|
||||
|
||||
extern int z3_start_adr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue