mirror of https://github.com/stella-emu/stella.git
Fixed issue with paddles 'jumping' when exiting from Command or Options
menus. Also, paddles now default to minimum resistance when starting a paddle game, and changes in paddle location by the mouse are detected by the digital paddle emulation (so pressing 'PaddleXXXIncrease/Decrease after moving with the mouse will continue from the current onscreen paddle position). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1205 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
0abbc77bff
commit
af61380785
|
@ -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: 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"
|
#include "Event.hxx"
|
||||||
|
@ -24,8 +24,15 @@ Event::Event(EventStreamer* ev)
|
||||||
: myNumberOfTypes(Event::LastType),
|
: myNumberOfTypes(Event::LastType),
|
||||||
myEventStreamer(ev)
|
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();
|
clear();
|
||||||
|
|
||||||
|
myValues[PaddleZeroResistance] =
|
||||||
|
myValues[PaddleOneResistance] =
|
||||||
|
myValues[PaddleTwoResistance] =
|
||||||
|
myValues[PaddleThreeResistance] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -55,5 +62,9 @@ void Event::set(Type type, Int32 value)
|
||||||
void Event::clear()
|
void Event::clear()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < myNumberOfTypes; ++i)
|
for(int i = 0; i < myNumberOfTypes; ++i)
|
||||||
|
{
|
||||||
|
if(i != PaddleZeroResistance && i != PaddleOneResistance &&
|
||||||
|
i != PaddleTwoResistance && i != PaddleThreeResistance)
|
||||||
myValues[i] = 0;
|
myValues[i] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.185 2006-12-11 20:43:43 stephena Exp $
|
// $Id: EventHandler.cxx,v 1.186 2006-12-12 01:02:12 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -175,11 +175,13 @@ void EventHandler::reset(State state)
|
||||||
if(myState == S_LAUNCHER)
|
if(myState == S_LAUNCHER)
|
||||||
myUseLauncherFlag = true;
|
myUseLauncherFlag = true;
|
||||||
|
|
||||||
// Start paddle emulation in a known state
|
// Set all paddles to minimum resistance by default
|
||||||
for(int i = 0; i < 4; ++i)
|
for(int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
memset(&myPaddle[i], 0, sizeof(JoyMouse));
|
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(0, myOSystem->settings().getInt("p0speed"));
|
||||||
setPaddleSpeed(1, myOSystem->settings().getInt("p1speed"));
|
setPaddleSpeed(1, myOSystem->settings().getInt("p1speed"));
|
||||||
|
@ -886,6 +888,9 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event)
|
||||||
|
|
||||||
int resistance = (int)(1000000.0 * (w - x) / w);
|
int resistance = (int)(1000000.0 * (w - x) / w);
|
||||||
myEvent->set(Paddle_Resistance[myPaddleMode], resistance);
|
myEvent->set(Paddle_Resistance[myPaddleMode], resistance);
|
||||||
|
|
||||||
|
// Update the digital paddle emulation so it's consistent
|
||||||
|
myPaddle[myPaddleMode].x = 1000000 - resistance;
|
||||||
}
|
}
|
||||||
else if(myOverlay)
|
else if(myOverlay)
|
||||||
myOverlay->handleMouseMotionEvent(x, y, 0);
|
myOverlay->handleMouseMotionEvent(x, y, 0);
|
||||||
|
@ -2022,8 +2027,8 @@ string EventHandler::keyAtIndex(int idx, EventMode mode)
|
||||||
inline bool EventHandler::isJitter(int paddle, int value)
|
inline bool EventHandler::isJitter(int paddle, int value)
|
||||||
{
|
{
|
||||||
bool jitter = false;
|
bool jitter = false;
|
||||||
bool leftMotion = myPaddle[paddle].joy_val - myPaddle[paddle].old_joy_val > 0;
|
bool leftMotion = myPaddle[paddle].val - myPaddle[paddle].old_val > 0;
|
||||||
int distance = value - myPaddle[paddle].joy_val;
|
int distance = value - myPaddle[paddle].val;
|
||||||
|
|
||||||
// Filter out jitter by not allowing rapid direction changes
|
// Filter out jitter by not allowing rapid direction changes
|
||||||
if(distance > 0 && !leftMotion) // movement switched from left to right
|
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
|
else if(distance < 0 && leftMotion) // movement switched from right to left
|
||||||
jitter = distance > -myPaddleThreshold;
|
jitter = distance > -myPaddleThreshold;
|
||||||
|
|
||||||
myPaddle[paddle].old_joy_val = myPaddle[paddle].joy_val;
|
myPaddle[paddle].old_val = myPaddle[paddle].val;
|
||||||
myPaddle[paddle].joy_val = value;
|
myPaddle[paddle].val = value;
|
||||||
|
|
||||||
return jitter;
|
return jitter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.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
|
#ifndef EVENTHANDLER_HXX
|
||||||
|
@ -62,7 +62,7 @@ enum EventMode {
|
||||||
mapping can take place.
|
mapping can take place.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@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
|
class EventHandler
|
||||||
{
|
{
|
||||||
|
@ -510,10 +510,7 @@ class EventHandler
|
||||||
};
|
};
|
||||||
struct JoyMouse { // Used for joystick to mouse emulation
|
struct JoyMouse { // Used for joystick to mouse emulation
|
||||||
bool active;
|
bool active;
|
||||||
int x, y, x_vel, y_vel, x_max, y_max, x_amt, y_amt, amt,
|
int x, y, x_amt, y_amt, amt, val, old_val;
|
||||||
x_down_count, y_down_count;
|
|
||||||
unsigned int last_time, delay_time, x_down_time, y_down_time;
|
|
||||||
int joy_val, old_joy_val;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global OSystem object
|
// Global OSystem object
|
||||||
|
|
Loading…
Reference in New Issue