mirror of https://github.com/stella-emu/stella.git
Fixed crash when toggling software and OpenGL mode with a Stelladaptor
plugged in. It seems SDL sends button events for buttons 2, 3, 4, 5 in this case, which really doesn't make sense; a Stelladaptor can only have two buttons. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1415 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
6f2f1da0f9
commit
3fde38a1b0
|
@ -14,7 +14,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: EventHandler.cxx,v 1.216 2008-03-02 20:48:51 stephena Exp $
|
// $Id: EventHandler.cxx,v 1.217 2008-03-03 16:14:50 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -627,39 +627,32 @@ void EventHandler::poll(uInt32 time)
|
||||||
|
|
||||||
// Stelladaptors handle buttons differently than regular joysticks
|
// Stelladaptors handle buttons differently than regular joysticks
|
||||||
int type = ourJoysticks[event.jbutton.which].type;
|
int type = ourJoysticks[event.jbutton.which].type;
|
||||||
|
int stick = event.jbutton.which;
|
||||||
|
int button = event.jbutton.button;
|
||||||
|
int state = event.jbutton.state == SDL_PRESSED ? 1 : 0;
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case JT_REGULAR:
|
case JT_REGULAR:
|
||||||
{
|
|
||||||
if(event.jbutton.button >= kNumJoyButtons)
|
if(event.jbutton.button >= kNumJoyButtons)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int stick = event.jbutton.which;
|
|
||||||
int button = event.jbutton.button;
|
|
||||||
int state = event.jbutton.state == SDL_PRESSED ? 1 : 0;
|
|
||||||
|
|
||||||
// Filter out buttons handled by OSystem
|
// Filter out buttons handled by OSystem
|
||||||
if(!myOSystem->joyButtonHandled(button))
|
if(!myOSystem->joyButtonHandled(button))
|
||||||
handleJoyEvent(stick, button, state);
|
handleJoyEvent(stick, button, state);
|
||||||
|
|
||||||
break; // Regular button
|
break; // Regular button
|
||||||
}
|
|
||||||
|
|
||||||
case JT_STELLADAPTOR_LEFT:
|
case JT_STELLADAPTOR_LEFT:
|
||||||
case JT_STELLADAPTOR_RIGHT:
|
case JT_STELLADAPTOR_RIGHT:
|
||||||
{
|
|
||||||
int button = event.jbutton.button;
|
|
||||||
int state = event.jbutton.state == SDL_PRESSED ? 1 : 0;
|
|
||||||
|
|
||||||
// The 'type-2' here refers to the fact that 'JT_STELLADAPTOR_LEFT'
|
// The 'type-2' here refers to the fact that 'JT_STELLADAPTOR_LEFT'
|
||||||
// and 'JT_STELLADAPTOR_RIGHT' are at index 2 and 3 in the JoyType
|
// and 'JT_STELLADAPTOR_RIGHT' are at index 2 and 3 in the JoyType
|
||||||
// enum; subtracting two gives us Controller 0 and 1
|
// enum; subtracting two gives us Controller 0 and 1
|
||||||
|
|
||||||
// These events don't have to pass through handleEvent, since
|
// These events don't have to pass through handleEvent, since
|
||||||
// they can never be remapped
|
// they can never be remapped
|
||||||
myEvent->set(SA_Button[type-2][button], state);
|
if(button < 2) myEvent->set(SA_Button[type-2][button], state);
|
||||||
break; // Stelladaptor button
|
break; // Stelladaptor button
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break; // SDL_JOYBUTTONUP, SDL_JOYBUTTONDOWN
|
break; // SDL_JOYBUTTONUP, SDL_JOYBUTTONDOWN
|
||||||
}
|
}
|
||||||
|
@ -671,27 +664,21 @@ void EventHandler::poll(uInt32 time)
|
||||||
|
|
||||||
// Stelladaptors handle axis differently than regular joysticks
|
// Stelladaptors handle axis differently than regular joysticks
|
||||||
int type = ourJoysticks[event.jbutton.which].type;
|
int type = ourJoysticks[event.jbutton.which].type;
|
||||||
|
int stick = event.jaxis.which;
|
||||||
|
int axis = event.jaxis.axis;
|
||||||
|
int value = event.jaxis.value;
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case JT_REGULAR:
|
case JT_REGULAR:
|
||||||
{
|
|
||||||
int stick = event.jaxis.which;
|
|
||||||
int axis = event.jaxis.axis;
|
|
||||||
int value = event.jaxis.value;
|
|
||||||
|
|
||||||
if(myState == S_EMULATE)
|
if(myState == S_EMULATE)
|
||||||
handleJoyAxisEvent(stick, axis, value);
|
handleJoyAxisEvent(stick, axis, value);
|
||||||
else if(myOverlay != NULL)
|
else if(myOverlay != NULL)
|
||||||
myOverlay->handleJoyAxisEvent(stick, axis, value);
|
myOverlay->handleJoyAxisEvent(stick, axis, value);
|
||||||
break; // Regular joystick axis
|
break; // Regular joystick axis
|
||||||
}
|
|
||||||
|
|
||||||
case JT_STELLADAPTOR_LEFT:
|
case JT_STELLADAPTOR_LEFT:
|
||||||
case JT_STELLADAPTOR_RIGHT:
|
case JT_STELLADAPTOR_RIGHT:
|
||||||
{
|
|
||||||
int axis = event.jaxis.axis;
|
|
||||||
int value = event.jaxis.value;
|
|
||||||
|
|
||||||
// Since the various controller classes deal with the
|
// Since the various controller classes deal with the
|
||||||
// Stelladaptor differently, we send the raw X and Y axis
|
// Stelladaptor differently, we send the raw X and Y axis
|
||||||
// data directly, and let the controller handle it
|
// data directly, and let the controller handle it
|
||||||
|
@ -701,9 +688,8 @@ void EventHandler::poll(uInt32 time)
|
||||||
|
|
||||||
// These events don't have to pass through handleEvent, since
|
// These events don't have to pass through handleEvent, since
|
||||||
// they can never be remapped
|
// they can never be remapped
|
||||||
myEvent->set(SA_Axis[type-2][axis], value);
|
if(axis < 2) myEvent->set(SA_Axis[type-2][axis], value);
|
||||||
break; // Stelladaptor axis
|
break; // Stelladaptor axis
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break; // SDL_JOYAXISMOTION
|
break; // SDL_JOYAXISMOTION
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue