diff --git a/stella/src/emucore/Event.cxx b/stella/src/emucore/Event.cxx index 8e337dfb2..8148b5622 100644 --- a/stella/src/emucore/Event.cxx +++ b/stella/src/emucore/Event.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: Event.cxx,v 1.9 2006-12-08 16:49:24 stephena Exp $ +// $Id: Event.cxx,v 1.10 2006-12-12 01:02:11 stephena Exp $ //============================================================================ #include "Event.hxx" @@ -24,8 +24,15 @@ Event::Event(EventStreamer* ev) : myNumberOfTypes(Event::LastType), myEventStreamer(ev) { - // Set all of the events to 0 / false to start with + // Set all of the events to 0 / false to start with, + // including analog paddle events. Doing it this way + // is a bit of a hack ... clear(); + + myValues[PaddleZeroResistance] = + myValues[PaddleOneResistance] = + myValues[PaddleTwoResistance] = + myValues[PaddleThreeResistance] = 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -55,5 +62,9 @@ void Event::set(Type type, Int32 value) void Event::clear() { for(int i = 0; i < myNumberOfTypes; ++i) - myValues[i] = 0; + { + if(i != PaddleZeroResistance && i != PaddleOneResistance && + i != PaddleTwoResistance && i != PaddleThreeResistance) + myValues[i] = 0; + } } diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index a40a04a3b..c780ab0b9 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.185 2006-12-11 20:43:43 stephena Exp $ +// $Id: EventHandler.cxx,v 1.186 2006-12-12 01:02:12 stephena Exp $ //============================================================================ #include @@ -175,11 +175,13 @@ void EventHandler::reset(State state) if(myState == S_LAUNCHER) myUseLauncherFlag = true; - // Start paddle emulation in a known state + // Set all paddles to minimum resistance by default for(int i = 0; i < 4; ++i) { memset(&myPaddle[i], 0, sizeof(JoyMouse)); - myEvent->set(Paddle_Resistance[i], 1000000); + myPaddle[i].x = myPaddle[i].y = 1000000; + int resistance = (int)(1000000.0 * (1000000.0 - myPaddle[i].x) / 1000000.0); + myEvent->set(Paddle_Resistance[i], resistance); } setPaddleSpeed(0, myOSystem->settings().getInt("p0speed")); setPaddleSpeed(1, myOSystem->settings().getInt("p1speed")); @@ -886,6 +888,9 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event) int resistance = (int)(1000000.0 * (w - x) / w); myEvent->set(Paddle_Resistance[myPaddleMode], resistance); + + // Update the digital paddle emulation so it's consistent + myPaddle[myPaddleMode].x = 1000000 - resistance; } else if(myOverlay) myOverlay->handleMouseMotionEvent(x, y, 0); @@ -2022,8 +2027,8 @@ string EventHandler::keyAtIndex(int idx, EventMode mode) inline bool EventHandler::isJitter(int paddle, int value) { bool jitter = false; - bool leftMotion = myPaddle[paddle].joy_val - myPaddle[paddle].old_joy_val > 0; - int distance = value - myPaddle[paddle].joy_val; + bool leftMotion = myPaddle[paddle].val - myPaddle[paddle].old_val > 0; + int distance = value - myPaddle[paddle].val; // Filter out jitter by not allowing rapid direction changes if(distance > 0 && !leftMotion) // movement switched from left to right @@ -2031,8 +2036,8 @@ inline bool EventHandler::isJitter(int paddle, int value) else if(distance < 0 && leftMotion) // movement switched from right to left jitter = distance > -myPaddleThreshold; - myPaddle[paddle].old_joy_val = myPaddle[paddle].joy_val; - myPaddle[paddle].joy_val = value; + myPaddle[paddle].old_val = myPaddle[paddle].val; + myPaddle[paddle].val = value; return jitter; } diff --git a/stella/src/emucore/EventHandler.hxx b/stella/src/emucore/EventHandler.hxx index ed2598b47..8afdbd65f 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.94 2006-12-08 16:49:25 stephena Exp $ +// $Id: EventHandler.hxx,v 1.95 2006-12-12 01:02:12 stephena Exp $ //============================================================================ #ifndef EVENTHANDLER_HXX @@ -62,7 +62,7 @@ enum EventMode { mapping can take place. @author Stephen Anthony - @version $Id: EventHandler.hxx,v 1.94 2006-12-08 16:49:25 stephena Exp $ + @version $Id: EventHandler.hxx,v 1.95 2006-12-12 01:02:12 stephena Exp $ */ class EventHandler { @@ -510,10 +510,7 @@ class EventHandler }; struct JoyMouse { // Used for joystick to mouse emulation bool active; - int x, y, x_vel, y_vel, x_max, y_max, x_amt, y_amt, amt, - x_down_count, y_down_count; - unsigned int last_time, delay_time, x_down_time, y_down_time; - int joy_val, old_joy_val; + int x, y, x_amt, y_amt, amt, val, old_val; }; // Global OSystem object