Only bind joystick axis events to paddle movement in analog mode, since

that's the only input where it really makes sense.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@970 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-01-18 20:43:22 +00:00
parent cff3bf75a4
commit a245adcc12
2 changed files with 40 additions and 51 deletions

View File

@ -13,7 +13,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.146 2006-01-11 14:13:19 stephena Exp $ // $Id: EventHandler.cxx,v 1.147 2006-01-18 20:43:22 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -1405,17 +1405,6 @@ void EventHandler::setActionMappings()
case kJHatLeft: buf << " left"; break; case kJHatLeft: buf << " left"; break;
case kJHatRight: buf << " right"; break; case kJHatRight: buf << " right"; break;
} }
/* FIXME - figure out how to combine analog & hats
if(eventIsAnalog(event))
{
dir = 2; // Immediately exit the inner loop after this iteration
buf << " abs";
}
else if(dir == 0)
buf << " neg";
else
buf << " pos";
*/
if(key == "") if(key == "")
key = key + buf.str(); key = key + buf.str();
else else
@ -1518,16 +1507,19 @@ void EventHandler::setJoyHatMap()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::addKeyMapping(Event::Type event, int key) bool EventHandler::addKeyMapping(Event::Type event, int key)
{ {
// These keys cannot be remapped. // These keys cannot be remapped.
if(key == SDLK_TAB) if(key == SDLK_TAB || eventIsAnalog(event))
return; return false;
else
{
myKeyTable[key] = event;
saveKeyMapping();
myKeyTable[key] = event; setActionMappings();
saveKeyMapping(); return true;
}
setActionMappings();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1540,12 +1532,18 @@ void EventHandler::setDefaultJoyMapping(Event::Type event, int stick, int button
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::addJoyMapping(Event::Type event, int stick, int button) bool EventHandler::addJoyMapping(Event::Type event, int stick, int button)
{ {
setDefaultJoyMapping(event, stick, button); if(!eventIsAnalog(event))
{
setDefaultJoyMapping(event, stick, button);
saveJoyMapping(); saveJoyMapping();
setActionMappings(); setActionMappings();
return true;
}
else
return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1574,13 +1572,15 @@ void EventHandler::setDefaultJoyAxisMapping(Event::Type event, int stick,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::addJoyAxisMapping(Event::Type event, int stick, int axis, bool EventHandler::addJoyAxisMapping(Event::Type event, int stick, int axis,
int value) int value)
{ {
setDefaultJoyAxisMapping(event, stick, axis, value); setDefaultJoyAxisMapping(event, stick, axis, value);
saveJoyAxisMapping(); saveJoyAxisMapping();
setActionMappings(); setActionMappings();
return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1600,34 +1600,23 @@ void EventHandler::setDefaultJoyHatMapping(Event::Type event, int stick,
myJoyHatTable[stick][hat][value] = event; myJoyHatTable[stick][hat][value] = event;
break; break;
} }
/* FIXME - deal with assignment of analog events
// This confusing code is because each axis has two associated values,
// but analog events only affect one of the axis.
if(eventIsAnalog(event))
myJoyAxisTable[stick][axis][0] = myJoyAxisTable[stick][axis][1] = event;
else
{
// Otherwise, turn off the analog event(s) for this axis
if(eventIsAnalog(myJoyAxisTable[stick][axis][0]))
myJoyAxisTable[stick][axis][0] = Event::NoType;
if(eventIsAnalog(myJoyAxisTable[stick][axis][1]))
myJoyAxisTable[stick][axis][1] = Event::NoType;
myJoyAxisTable[stick][axis][(value > 0)] = event;
}
*/
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::addJoyHatMapping(Event::Type event, int stick, int hat, bool EventHandler::addJoyHatMapping(Event::Type event, int stick, int hat,
int value) int value)
{ {
setDefaultJoyHatMapping(event, stick, hat, value); if(!eventIsAnalog(event))
{
setDefaultJoyHatMapping(event, stick, hat, value);
saveJoyHatMapping(); saveJoyHatMapping();
setActionMappings(); setActionMappings();
return true;
}
else
return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,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.hxx,v 1.75 2006-01-09 19:30:04 stephena Exp $ // $Id: EventHandler.hxx,v 1.76 2006-01-18 20:43:22 stephena Exp $
//============================================================================ //============================================================================
#ifndef EVENTHANDLER_HXX #ifndef EVENTHANDLER_HXX
@ -133,7 +133,7 @@ struct JoyMouse {
mapping can take place. mapping can take place.
@author Stephen Anthony @author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.75 2006-01-09 19:30:04 stephena Exp $ @version $Id: EventHandler.hxx,v 1.76 2006-01-18 20:43:22 stephena Exp $
*/ */
class EventHandler class EventHandler
{ {
@ -342,7 +342,7 @@ class EventHandler
@param event The event we are remapping @param event The event we are remapping
@param key The key to bind to this event @param key The key to bind to this event
*/ */
void addKeyMapping(Event::Type event, int key); bool addKeyMapping(Event::Type event, int key);
/** /**
Bind a joystick button to an event/action and regenerate the Bind a joystick button to an event/action and regenerate the
@ -352,7 +352,7 @@ class EventHandler
@param stick The joystick number @param stick The joystick number
@param button The joystick button @param button The joystick button
*/ */
void addJoyMapping(Event::Type event, int stick, int button); bool addJoyMapping(Event::Type event, int stick, int button);
/** /**
Bind a joystick axis direction to an event/action and regenerate Bind a joystick axis direction to an event/action and regenerate
@ -363,7 +363,7 @@ class EventHandler
@param axis The joystick axis @param axis The joystick axis
@param value The value on the given axis @param value The value on the given axis
*/ */
void addJoyAxisMapping(Event::Type event, int stick, int axis, int value); bool addJoyAxisMapping(Event::Type event, int stick, int axis, int value);
/** /**
Bind a joystick hat direction to an event/action and regenerate Bind a joystick hat direction to an event/action and regenerate
@ -374,7 +374,7 @@ class EventHandler
@param axis The joystick hat @param axis The joystick hat
@param value The value on the given hat @param value The value on the given hat
*/ */
void addJoyHatMapping(Event::Type event, int stick, int hat, int value); bool addJoyHatMapping(Event::Type event, int stick, int hat, int value);
/** /**
Erase the specified mapping Erase the specified mapping