From a245adcc12819e31d5c9b0ac040223cc70224f6b Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 18 Jan 2006 20:43:22 +0000 Subject: [PATCH] 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 --- stella/src/emucore/EventHandler.cxx | 79 +++++++++++++---------------- stella/src/emucore/EventHandler.hxx | 12 ++--- 2 files changed, 40 insertions(+), 51 deletions(-) diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index ca30c59f2..58efad98d 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // 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 @@ -1405,17 +1405,6 @@ void EventHandler::setActionMappings() case kJHatLeft: buf << " left"; 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 == "") key = key + buf.str(); 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. - if(key == SDLK_TAB) - return; + if(key == SDLK_TAB || eventIsAnalog(event)) + return false; + else + { + myKeyTable[key] = event; + saveKeyMapping(); - myKeyTable[key] = event; - saveKeyMapping(); - - setActionMappings(); + setActionMappings(); + return true; + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -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(); - setActionMappings(); + saveJoyMapping(); + 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) { setDefaultJoyAxisMapping(event, stick, axis, value); saveJoyAxisMapping(); setActionMappings(); + + return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1600,34 +1600,23 @@ void EventHandler::setDefaultJoyHatMapping(Event::Type event, int stick, myJoyHatTable[stick][hat][value] = event; 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) { - setDefaultJoyHatMapping(event, stick, hat, value); + if(!eventIsAnalog(event)) + { + setDefaultJoyHatMapping(event, stick, hat, value); - saveJoyHatMapping(); - setActionMappings(); + saveJoyHatMapping(); + setActionMappings(); + return true; + } + else + return false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/emucore/EventHandler.hxx b/stella/src/emucore/EventHandler.hxx index dede4113e..9381efdd2 100644 --- a/stella/src/emucore/EventHandler.hxx +++ b/stella/src/emucore/EventHandler.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // 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 @@ -133,7 +133,7 @@ struct JoyMouse { mapping can take place. @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 { @@ -342,7 +342,7 @@ class EventHandler @param event The event we are remapping @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 @@ -352,7 +352,7 @@ class EventHandler @param stick The joystick number @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 @@ -363,7 +363,7 @@ class EventHandler @param axis The joystick 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 @@ -374,7 +374,7 @@ class EventHandler @param axis The joystick 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