Added one setting to change the speed for all digital paddle emulation

movement, named 'pspeed'.  This replaces the 4 'pXspeed' commandline
arguments.  Also removed 'pthresh', since it no longer serves any purpose.

Updated UI to change this setting dynamically from within Stella.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1413 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-03-02 20:48:51 +00:00
parent 9dd3582a86
commit 0550990c59
8 changed files with 69 additions and 189 deletions

View File

@ -14,7 +14,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.215 2008-03-02 19:20:50 stephena Exp $
// $Id: EventHandler.cxx,v 1.216 2008-03-02 20:48:51 stephena Exp $
//============================================================================
#include <sstream>
@ -31,6 +31,7 @@
#include "Launcher.hxx"
#include "Menu.hxx"
#include "OSystem.hxx"
#include "Paddles.hxx"
#include "PropsSet.hxx"
#include "ScrollBarWidget.hxx"
#include "Settings.hxx"
@ -66,8 +67,7 @@ EventHandler::EventHandler(OSystem* osystem)
myUseLauncherFlag(false),
myAllowAllDirectionsFlag(false),
myFryingFlag(false),
myPaddleMode(0),
myPaddleThreshold(0)
myPaddleMode(0)
{
// Create the event object which will be used for this handler
myEvent = new Event();
@ -145,8 +145,9 @@ void EventHandler::initialize()
setActionMappings(kMenuMode);
myGrabMouseFlag = myOSystem->settings().getBool("grabmouse");
setPaddleMode(myOSystem->settings().getInt("paddle"), false);
setPaddleThreshold(myOSystem->settings().getInt("pthresh"));
Paddles::setDigitalSpeed(myOSystem->settings().getInt("pspeed"));
// Set number of lines a mousewheel will scroll
ScrollBarWidget::setWheelLines(myOSystem->settings().getInt("mwheel"));
@ -163,12 +164,6 @@ void EventHandler::reset(State state)
if(myState == S_LAUNCHER)
myUseLauncherFlag = true;
// FIXME - this should go directly into the Paddles class
setPaddleSpeed(0, myOSystem->settings().getInt("p0speed"));
setPaddleSpeed(1, myOSystem->settings().getInt("p1speed"));
setPaddleSpeed(2, myOSystem->settings().getInt("p2speed"));
setPaddleSpeed(3, myOSystem->settings().getInt("p3speed"));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1868,30 +1863,6 @@ void EventHandler::setPaddleMode(int num, bool showmessage)
myOSystem->settings().setInt("paddle", myPaddleMode);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setPaddleSpeed(int num, int speed)
{
/* FIXME - move functionality to Paddles class
if(num < 0 || num > 3 || speed < 0 || speed > 100)
return;
myPaddle[num].amt = (int) (20000 + speed/100.0 * 50000);
ostringstream buf;
buf << "p" << num << "speed";
myOSystem->settings().setInt(buf.str(), speed);
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setPaddleThreshold(int thresh)
{
/* FIXME - move functionality to Paddles class
myPaddleThreshold = thresh;
myOSystem->settings().setInt("pthresh", thresh);
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::enterMenuMode(State state)
{

View File

@ -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.107 2008-03-02 19:20:50 stephena Exp $
// $Id: EventHandler.hxx,v 1.108 2008-03-02 20:48:51 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -61,7 +61,7 @@ enum EventMode {
mapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.107 2008-03-02 19:20:50 stephena Exp $
@version $Id: EventHandler.hxx,v 1.108 2008-03-02 20:48:51 stephena Exp $
*/
class EventHandler
{
@ -198,23 +198,6 @@ class EventHandler
*/
void setPaddleMode(int num, bool showmessage = false);
/**
Sets the speed of the given paddle
@param num The paddle number (0-3)
@param speed The speed of paddle movement for the given paddle
*/
void setPaddleSpeed(int num, int speed);
/**
Sets the amount by which paddle jitter is detected. Quick movements
of less than this amount constitute jitter, and do not generate
paddle events.
@param thresh The threshold to use for jitter detection
*/
void setPaddleThreshold(int thresh);
inline bool kbdAlt(int mod)
{
#ifndef MAC_OSX
@ -526,9 +509,6 @@ class EventHandler
// Indicates which paddle the mouse currently emulates
Int8 myPaddleMode;
// Indicates the amount by which we consider a paddle to be jittering
int myPaddleThreshold;
// Type of device on each controller port (based on ROM properties)
Controller::Type myController[2];

View File

@ -13,10 +13,9 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Paddles.cxx,v 1.12 2008-03-02 19:20:50 stephena Exp $
// $Id: Paddles.cxx,v 1.13 2008-03-02 20:48:51 stephena Exp $
//============================================================================
#define PADDLE_SENSITIVITY 6
#define TRIGMAX 240
#define TRIGMIN 1
@ -148,12 +147,12 @@ void Paddles::update()
if(myKeyRepeat0)
{
myPaddleRepeat0++;
if(myPaddleRepeat0 > PADDLE_SENSITIVITY) myPaddleRepeat0 = 2;
if(myPaddleRepeat0 > _PADDLE_SPEED) myPaddleRepeat0 = 2;
}
if(myKeyRepeat1)
{
myPaddleRepeat1++;
if(myPaddleRepeat1 > PADDLE_SENSITIVITY) myPaddleRepeat1 = 2;
if(myPaddleRepeat1 > _PADDLE_SPEED) myPaddleRepeat1 = 2;
}
myKeyRepeat0 = 0;
@ -162,26 +161,26 @@ void Paddles::update()
if(myEvent.get(myP0DecEvent1) || myEvent.get(myP0DecEvent2))
{
myKeyRepeat0 = 1;
if(myCharge[0] > (myPaddleRepeat0 >> 1))
myCharge[0] -= (myPaddleRepeat0 >> 1);
if(myCharge[0] > myPaddleRepeat0)
myCharge[0] -= myPaddleRepeat0;
}
if(myEvent.get(myP0IncEvent1) || myEvent.get(myP0IncEvent2))
{
myKeyRepeat0 = 1;
if((myCharge[0] + (myPaddleRepeat0 >> 1)) < TRIGMAX)
myCharge[0] += (myPaddleRepeat0 >> 1);
if((myCharge[0] + myPaddleRepeat0) < TRIGMAX)
myCharge[0] += myPaddleRepeat0;
}
if(myEvent.get(myP1DecEvent1) || myEvent.get(myP1DecEvent2))
{
myKeyRepeat1 = 1;
if(myCharge[1] > (myPaddleRepeat1 >> 1))
myCharge[1] -= (myPaddleRepeat1 >> 1);
if(myCharge[1] > myPaddleRepeat1)
myCharge[1] -= myPaddleRepeat1;
}
if(myEvent.get(myP1IncEvent1) || myEvent.get(myP1IncEvent2))
{
myKeyRepeat1 = 1;
if((myCharge[1] + (myPaddleRepeat1 >> 1)) < TRIGMAX)
myCharge[1] += (myPaddleRepeat1 >> 1);
if((myCharge[1] + myPaddleRepeat1) < TRIGMAX)
myCharge[1] += myPaddleRepeat1;
}
// Mouse events
@ -304,3 +303,6 @@ void Paddles::update()
myAnalogPinValue[Five] = (Int32)(1000000 * (myCharge[1] / 255.0));
myAnalogPinValue[Nine] = (Int32)(1000000 * (myCharge[0] / 255.0));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Paddles::_PADDLE_SPEED = 6;

View File

@ -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: Paddles.hxx,v 1.11 2008-03-02 19:20:50 stephena Exp $
// $Id: Paddles.hxx,v 1.12 2008-03-02 20:48:51 stephena Exp $
//============================================================================
#ifndef PADDLES_HXX
@ -27,7 +27,7 @@
The standard Atari 2600 pair of paddle controllers.
@author Bradford W. Mott
@version $Id: Paddles.hxx,v 1.11 2008-03-02 19:20:50 stephena Exp $
@version $Id: Paddles.hxx,v 1.12 2008-03-02 20:48:51 stephena Exp $
*/
class Paddles : public Controller
{
@ -53,6 +53,14 @@ class Paddles : public Controller
*/
virtual void update();
/**
Sets the speed for digital emulation of paddle movement.
This is only used for *digital* events (ie, buttons or keys
generating paddle movement events); axis events from joysticks,
Stelladaptors or the mouse are not modified.
*/
static void setDigitalSpeed(int speed) { _PADDLE_SPEED = speed; }
private:
// Pre-compute the events we care about based on given port
// This will eliminate test for left or right port in update()
@ -71,6 +79,8 @@ class Paddles : public Controller
int myLeftMotion[2];
int myMouseBaseX, myMouseBaseY;
static int _PADDLE_SPEED;
};
#endif

View File

@ -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: Settings.cxx,v 1.130 2008-02-06 13:45:22 stephena Exp $
// $Id: Settings.cxx,v 1.131 2008-03-02 20:48:51 stephena Exp $
//============================================================================
#include <cassert>
@ -52,7 +52,7 @@ Settings::Settings(OSystem* osystem)
setInternal("fullscreen", "false");
setInternal("fullres", "");
setInternal("center", "true");
setInternal("grabmouse", "false");
setInternal("grabmouse", "true");
setInternal("palette", "standard");
setInternal("colorloss", "false");
@ -70,13 +70,9 @@ Settings::Settings(OSystem* osystem)
setInternal("joyaxismap", "");
setInternal("joyhatmap", "");
setInternal("paddle", "0");
setInternal("pspeed", "6");
setInternal("sa1", "left");
setInternal("sa2", "right");
setInternal("p0speed", "50");
setInternal("p1speed", "50");
setInternal("p2speed", "50");
setInternal("p3speed", "50");
setInternal("pthresh", "600");
// Snapshot options
setInternal("ssdir", string(".") + BSPF_PATH_SEPARATOR);
@ -253,11 +249,11 @@ void Settings::validate()
if(i < 0 || i > 3)
setInternal("paddle", "0");
i = getInt("pthresh");
if(i < 400)
setInternal("pthresh", "400");
else if(i > 800)
setInternal("pthresh", "800");
i = getInt("pspeed");
if(i < 1)
setInternal("pspeed", "1");
else if(i > 15)
setInternal("pspeed", "15");
s = getString("palette");
if(s != "standard" && s != "z26" && s != "user")
@ -316,13 +312,9 @@ void Settings::usage()
<< " -cheat <code> Use the specified cheatcode (see manual for description)\n"
<< " -showinfo <1|0> Shows some game info\n"
<< " -paddle <0|1|2|3> Indicates which paddle the mouse should emulate\n"
<< " -pspeed <number> Speed of digital emulated paddle movement (1-15)\n"
<< " -sa1 <left|right> Stelladaptor 1 emulates specified joystick port\n"
<< " -sa2 <left|right> Stelladaptor 2 emulates specified joystick port\n"
<< " -p0speed <number> Speed of emulated mouse movement for paddle 0 (0-100)\n"
<< " -p1speed <number> Speed of emulated mouse movement for paddle 1 (0-100)\n"
<< " -p2speed <number> Speed of emulated mouse movement for paddle 2 (0-100)\n"
<< " -p3speed <number> Speed of emulated mouse movement for paddle 3 (0-100)\n"
<< " -pthresh <number> Set threshold for eliminating paddle jitter\n"
<< " -rombrowse <1|0> Use ROM browser mode (shows files and folders)\n"
<< " -romviewer <1|0> Show ROM info viewer in ROM launcher\n"
<< " -autoslot <1|0> Automatically switch to next save slot when state saving\n"

View File

@ -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: InputDialog.cxx,v 1.27 2008-02-06 13:45:23 stephena Exp $
// $Id: InputDialog.cxx,v 1.28 2008-03-02 20:48:51 stephena Exp $
//============================================================================
#include "bspf.hxx"
@ -21,6 +21,7 @@
#include "Array.hxx"
#include "EventMappingWidget.hxx"
#include "OSystem.hxx"
#include "Paddles.hxx"
#include "PopUpWidget.hxx"
#include "Settings.hxx"
#include "TabWidget.hxx"
@ -139,66 +140,17 @@ void InputDialog::addVDeviceTab(const GUI::Font& font)
myPaddleModeLabel->setFlags(WIDGET_CLEARBG);
wid.push_back(myPaddleMode);
// Add 'paddle threshhold' setting
// Add paddle speed
xpos = 5; ypos += lineHeight + 3;
myPaddleThreshold = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"Paddle threshold: ",
lwidth, kPaddleThreshChanged);
myPaddleThreshold->setMinValue(400); myPaddleThreshold->setMaxValue(800);
xpos += myPaddleThreshold->getWidth() + 5;
myPaddleThresholdLabel = new StaticTextWidget(myTab, font, xpos, ypos+1,
24, lineHeight,
"", kTextAlignLeft);
myPaddleThresholdLabel->setFlags(WIDGET_CLEARBG);
wid.push_back(myPaddleThreshold);
// Add paddle 0 speed
xpos = 5; ypos += lineHeight + 3;
myPaddleSpeed[0] = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"Paddle 0 speed: ",
lwidth, kP0SpeedID);
myPaddleSpeed[0]->setMinValue(1); myPaddleSpeed[0]->setMaxValue(100);
xpos += myPaddleSpeed[0]->getWidth() + 5;
myPaddleLabel[0] = new StaticTextWidget(myTab, font, xpos, ypos+1, 24, lineHeight,
"", kTextAlignLeft);
myPaddleLabel[0]->setFlags(WIDGET_CLEARBG);
wid.push_back(myPaddleSpeed[0]);
// Add paddle 1 speed
xpos = 5; ypos += lineHeight + 3;
myPaddleSpeed[1] = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"Paddle 1 speed: ",
lwidth, kP1SpeedID);
myPaddleSpeed[1]->setMinValue(1); myPaddleSpeed[1]->setMaxValue(100);
xpos += myPaddleSpeed[1]->getWidth() + 5;
myPaddleLabel[1] = new StaticTextWidget(myTab, font, xpos, ypos+1, 24, lineHeight,
"", kTextAlignLeft);
myPaddleLabel[1]->setFlags(WIDGET_CLEARBG);
wid.push_back(myPaddleSpeed[1]);
// Add paddle 2 speed
xpos = 5; ypos += lineHeight + 3;
myPaddleSpeed[2] = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"Paddle 2 speed: ",
lwidth, kP2SpeedID);
myPaddleSpeed[2]->setMinValue(1); myPaddleSpeed[2]->setMaxValue(100);
xpos += myPaddleSpeed[2]->getWidth() + 5;
myPaddleLabel[2] = new StaticTextWidget(myTab, font, xpos, ypos+1, 24, lineHeight,
"", kTextAlignLeft);
myPaddleLabel[2]->setFlags(WIDGET_CLEARBG);
wid.push_back(myPaddleSpeed[2]);
// Add paddle 3 speed
xpos = 5; ypos += lineHeight + 3;
myPaddleSpeed[3] = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"Paddle 3 speed: ",
lwidth, kP3SpeedID);
myPaddleSpeed[3]->setMinValue(1); myPaddleSpeed[3]->setMaxValue(100);
xpos += myPaddleSpeed[3]->getWidth() + 5;
myPaddleLabel[3] = new StaticTextWidget(myTab, font, xpos, ypos+1, 24, lineHeight,
"", kTextAlignLeft);
myPaddleLabel[3]->setFlags(WIDGET_CLEARBG);
wid.push_back(myPaddleSpeed[3]);
myPaddleSpeed = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"Paddle speed: ",
lwidth, kPSpeedChanged);
myPaddleSpeed->setMinValue(1); myPaddleSpeed->setMaxValue(15);
xpos += myPaddleSpeed->getWidth() + 5;
myPaddleLabel = new StaticTextWidget(myTab, font, xpos, ypos+1, 24, lineHeight,
"", kTextAlignLeft);
myPaddleLabel->setFlags(WIDGET_CLEARBG);
wid.push_back(myPaddleSpeed);
// Add items for virtual device ports
addToFocusList(wid, tabID);
@ -219,19 +171,9 @@ void InputDialog::loadConfig()
myPaddleMode->setValue(instance()->settings().getInt("paddle"));
myPaddleModeLabel->setLabel(instance()->settings().getString("paddle"));
// Paddle threshold
myPaddleThreshold->setValue(instance()->settings().getInt("pthresh"));
myPaddleThresholdLabel->setLabel(instance()->settings().getString("pthresh"));
// Paddle speed settings
myPaddleSpeed[0]->setValue(instance()->settings().getInt("p0speed"));
myPaddleLabel[0]->setLabel(instance()->settings().getString("p0speed"));
myPaddleSpeed[1]->setValue(instance()->settings().getInt("p1speed"));
myPaddleLabel[1]->setLabel(instance()->settings().getString("p1speed"));
myPaddleSpeed[2]->setValue(instance()->settings().getInt("p2speed"));
myPaddleLabel[2]->setLabel(instance()->settings().getString("p2speed"));
myPaddleSpeed[3]->setValue(instance()->settings().getInt("p3speed"));
myPaddleLabel[3]->setLabel(instance()->settings().getString("p3speed"));
// Paddle speed
myPaddleSpeed->setValue(instance()->settings().getInt("pspeed"));
myPaddleLabel->setLabel(instance()->settings().getString("pspeed"));
myTab->loadConfig();
}
@ -248,13 +190,10 @@ void InputDialog::saveConfig()
int mode = myPaddleMode->getValue();
instance()->eventHandler().setPaddleMode(mode);
// Paddle threshold
int threshold = myPaddleThreshold->getValue();
instance()->eventHandler().setPaddleThreshold(threshold);
// Paddle speed settings
for(int i = 0; i < 4; ++i)
instance()->eventHandler().setPaddleSpeed(i, myPaddleSpeed[i]->getValue());
// Paddle speed
int speed = myPaddleSpeed->getValue();
instance()->settings().setInt("pspeed", speed);
Paddles::setDigitalSpeed(speed);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -325,15 +264,8 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
myPaddleModeLabel->setValue(myPaddleMode->getValue());
break;
case kPaddleThreshChanged:
myPaddleThresholdLabel->setValue(myPaddleThreshold->getValue());
break;
case kP0SpeedID:
case kP1SpeedID:
case kP2SpeedID:
case kP3SpeedID:
myPaddleLabel[cmd-100]->setValue(myPaddleSpeed[cmd-100]->getValue());
case kPSpeedChanged:
myPaddleLabel->setValue(myPaddleSpeed->getValue());
break;
default:

View File

@ -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: InputDialog.hxx,v 1.14 2008-02-06 13:45:23 stephena Exp $
// $Id: InputDialog.hxx,v 1.15 2008-03-02 20:48:51 stephena Exp $
//============================================================================
#ifndef INPUT_DIALOG_HXX
@ -53,12 +53,8 @@ class InputDialog : public Dialog
private:
enum {
kPaddleChanged = 'PDch',
kPaddleThreshChanged = 'PDth',
kP0SpeedID = 100,
kP1SpeedID = 101,
kP2SpeedID = 102,
kP3SpeedID = 103
kPaddleChanged = 'PDch',
kPSpeedChanged = 'PSch'
};
TabWidget* myTab;
@ -71,10 +67,8 @@ class InputDialog : public Dialog
SliderWidget* myPaddleMode;
StaticTextWidget* myPaddleModeLabel;
SliderWidget* myPaddleThreshold;
StaticTextWidget* myPaddleThresholdLabel;
SliderWidget* myPaddleSpeed[4];
StaticTextWidget* myPaddleLabel[4];
SliderWidget* myPaddleSpeed;
StaticTextWidget* myPaddleLabel;
};
#endif

View File

@ -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: ScrollBarWidget.cxx,v 1.21 2008-02-06 13:45:24 stephena Exp $
// $Id: ScrollBarWidget.cxx,v 1.22 2008-03-02 20:48:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -281,6 +281,5 @@ void ScrollBarWidget::drawWidget(bool hilite)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ScrollBarWidget::_WHEEL_LINES = 4;