mirror of https://github.com/stella-emu/stella.git
Added GUI widgets to InputDialog to change speed of paddle movement when
emulating paddles with the keyboard or joystick. These slider widgets go from 0 to 100 percent, and represent minimum (0) to maximum (100) speed. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@910 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
514ff4ea9a
commit
e6aa6391eb
|
@ -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.127 2005-12-13 00:35:24 stephena Exp $
|
||||
// $Id: EventHandler.cxx,v 1.128 2005-12-16 14:41:14 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -180,11 +180,16 @@ void EventHandler::reset(State state)
|
|||
if(myState == S_LAUNCHER)
|
||||
myUseLauncherFlag = true;
|
||||
|
||||
// Start paddle emulation in a known state
|
||||
for(int i = 0; i < 4; ++i)
|
||||
{
|
||||
memset(&myPaddle[i], 0, sizeof(myJoyMouse));
|
||||
myPaddle[i].amt = 70000; // FIXME - get scale factor from GUI and apply to this value
|
||||
myEvent->set(Paddle_Resistance[i], 1000000);
|
||||
}
|
||||
setPaddleSpeed(0, myOSystem->settings().getInt("p1speed"));
|
||||
setPaddleSpeed(1, myOSystem->settings().getInt("p2speed"));
|
||||
setPaddleSpeed(2, myOSystem->settings().getInt("p3speed"));
|
||||
setPaddleSpeed(3, myOSystem->settings().getInt("p4speed"));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -767,7 +772,6 @@ void EventHandler::poll(uInt32 time)
|
|||
{
|
||||
int resistance = (int)(1000000.0 * (1000000.0 - myPaddle[i].x) / 1000000.0);
|
||||
myEvent->set(Paddle_Resistance[i], resistance);
|
||||
cerr << "do paddle resistance for value = " << myPaddle[i].x << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1960,7 +1964,7 @@ cerr << "load recording!\n";
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::setPaddleMode(uInt32 num, bool showmessage)
|
||||
void EventHandler::setPaddleMode(int num, bool showmessage)
|
||||
{
|
||||
if(num < 0 || num > 3)
|
||||
return;
|
||||
|
@ -1977,6 +1981,18 @@ void EventHandler::setPaddleMode(uInt32 num, bool showmessage)
|
|||
myOSystem->settings().setInt("paddle", myPaddleMode);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::setPaddleSpeed(int num, int speed)
|
||||
{
|
||||
if(num < 0 || num > 3 || speed < 0 || speed > 100)
|
||||
return;
|
||||
|
||||
myPaddle[num].amt = (int) (20000 + speed/100.0 * 50000);
|
||||
ostringstream buf;
|
||||
buf << "p" << num+1 << "speed";
|
||||
myOSystem->settings().setInt(buf.str(), speed);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::enterMenuMode(State state)
|
||||
{
|
||||
|
|
|
@ -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.65 2005-12-13 00:35:24 stephena Exp $
|
||||
// $Id: EventHandler.hxx,v 1.66 2005-12-16 14:41:14 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef EVENTHANDLER_HXX
|
||||
|
@ -92,7 +92,7 @@ struct Stella_Joystick {
|
|||
mapping can take place.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: EventHandler.hxx,v 1.65 2005-12-13 00:35:24 stephena Exp $
|
||||
@version $Id: EventHandler.hxx,v 1.66 2005-12-16 14:41:14 stephena Exp $
|
||||
*/
|
||||
class EventHandler
|
||||
{
|
||||
|
@ -252,7 +252,15 @@ class EventHandler
|
|||
@param num The paddle which the mouse should emulate
|
||||
@param showmessage Print a message to the framebuffer
|
||||
*/
|
||||
void setPaddleMode(uInt32 num, bool showmessage = false);
|
||||
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);
|
||||
|
||||
inline bool kbdAlt(int mod)
|
||||
{
|
||||
|
|
|
@ -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.67 2005-12-07 20:46:49 stephena Exp $
|
||||
// $Id: Settings.cxx,v 1.68 2005-12-16 14:41:14 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -63,6 +63,11 @@ Settings::Settings(OSystem* osystem)
|
|||
set("joymouse", "false");
|
||||
set("sa1", "left");
|
||||
set("sa2", "right");
|
||||
set("mspeed", "50");
|
||||
set("p1speed", "50");
|
||||
set("p2speed", "50");
|
||||
set("p3speed", "50");
|
||||
set("p4speed", "50");
|
||||
|
||||
set("showinfo", "false");
|
||||
|
||||
|
|
|
@ -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.5 2005-12-07 20:46:49 stephena Exp $
|
||||
// $Id: InputDialog.cxx,v 1.6 2005-12-16 14:41:15 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "OSystem.hxx"
|
||||
|
@ -27,8 +27,11 @@
|
|||
#include "bspf.hxx"
|
||||
|
||||
enum {
|
||||
kPaddleChanged = 'PDch',
|
||||
kSenseChanged = 'PSch'
|
||||
kPaddleChanged = 'PDch',
|
||||
kP0SpeedID = 100,
|
||||
kP1SpeedID = 101,
|
||||
kP2SpeedID = 102,
|
||||
kP3SpeedID = 103
|
||||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -109,29 +112,65 @@ void InputDialog::addVDeviceTab()
|
|||
wid.push_back(myRightPort);
|
||||
|
||||
// Add 'mouse to paddle' mapping
|
||||
ypos += 2*lineHeight + 3;
|
||||
lwidth = font.getStringWidth("Mouse sensitivity: ");
|
||||
ypos += 2*lineHeight;
|
||||
lwidth = font.getStringWidth("Mouse is paddle: ");
|
||||
myPaddleMode = new SliderWidget(myTab, xpos, ypos, lwidth + 30, lineHeight,
|
||||
"Mouse is paddle: ",
|
||||
lwidth, kPaddleChanged);
|
||||
myPaddleMode->setMinValue(0); myPaddleMode->setMaxValue(3);
|
||||
xpos += myPaddleMode->getWidth() + 5;
|
||||
myPaddleLabel = new StaticTextWidget(myTab, xpos, ypos+1, 24, lineHeight,
|
||||
"", kTextAlignLeft);
|
||||
myPaddleLabel->setFlags(WIDGET_CLEARBG);
|
||||
myPaddleModeLabel = new StaticTextWidget(myTab, xpos, ypos+1, 24, lineHeight,
|
||||
"", kTextAlignLeft);
|
||||
myPaddleModeLabel->setFlags(WIDGET_CLEARBG);
|
||||
wid.push_back(myPaddleMode);
|
||||
|
||||
// Add mouse sensitivity
|
||||
// Add paddle 0 speed
|
||||
xpos = 5; ypos += lineHeight + 3;
|
||||
myPaddleSense = new SliderWidget(myTab, xpos, ypos, lwidth + 30, lineHeight,
|
||||
"Mouse sensitivity: ",
|
||||
lwidth, kSenseChanged);
|
||||
myPaddleSense->setMinValue(1); myPaddleSense->setMaxValue(100);
|
||||
xpos += myPaddleSense->getWidth() + 5;
|
||||
mySenseLabel = new StaticTextWidget(myTab, xpos, ypos+1, 24, lineHeight,
|
||||
"", kTextAlignLeft);
|
||||
mySenseLabel->setFlags(WIDGET_CLEARBG);
|
||||
wid.push_back(myPaddleSense);
|
||||
myPaddleSpeed[0] = new SliderWidget(myTab, xpos, ypos, lwidth + 30, lineHeight,
|
||||
"Paddle 1 speed: ",
|
||||
lwidth, kP0SpeedID);
|
||||
myPaddleSpeed[0]->setMinValue(1); myPaddleSpeed[0]->setMaxValue(100);
|
||||
xpos += myPaddleSpeed[0]->getWidth() + 5;
|
||||
myPaddleLabel[0] = new StaticTextWidget(myTab, 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, xpos, ypos, lwidth + 30, lineHeight,
|
||||
"Paddle 2 speed: ",
|
||||
lwidth, kP1SpeedID);
|
||||
myPaddleSpeed[1]->setMinValue(1); myPaddleSpeed[1]->setMaxValue(100);
|
||||
xpos += myPaddleSpeed[1]->getWidth() + 5;
|
||||
myPaddleLabel[1] = new StaticTextWidget(myTab, 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, xpos, ypos, lwidth + 30, lineHeight,
|
||||
"Paddle 3 speed: ",
|
||||
lwidth, kP2SpeedID);
|
||||
myPaddleSpeed[2]->setMinValue(1); myPaddleSpeed[2]->setMaxValue(100);
|
||||
xpos += myPaddleSpeed[2]->getWidth() + 5;
|
||||
myPaddleLabel[2] = new StaticTextWidget(myTab, 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, xpos, ypos, lwidth + 30, lineHeight,
|
||||
"Paddle 4 speed: ",
|
||||
lwidth, kP3SpeedID);
|
||||
myPaddleSpeed[3]->setMinValue(1); myPaddleSpeed[3]->setMaxValue(100);
|
||||
xpos += myPaddleSpeed[3]->getWidth() + 5;
|
||||
myPaddleLabel[3] = new StaticTextWidget(myTab, xpos, ypos+1, 24, lineHeight,
|
||||
"", kTextAlignLeft);
|
||||
myPaddleLabel[3]->setFlags(WIDGET_CLEARBG);
|
||||
wid.push_back(myPaddleSpeed[3]);
|
||||
|
||||
// Add items for virtual device ports
|
||||
addToFocusList(wid, tabID);
|
||||
|
@ -150,13 +189,17 @@ void InputDialog::loadConfig()
|
|||
|
||||
// Paddle mode
|
||||
myPaddleMode->setValue(instance()->settings().getInt("paddle"));
|
||||
myPaddleLabel->setLabel(instance()->settings().getString("paddle"));
|
||||
myPaddleModeLabel->setLabel(instance()->settings().getString("paddle"));
|
||||
|
||||
/* FIXME - add this to eventhandler core
|
||||
// Paddle sensitivity
|
||||
myPaddleSense->setValue(instance()->settings().getInt("paddle"));
|
||||
mySenseLabel->setLabel(instance()->settings().getString("paddle"));
|
||||
*/
|
||||
// Paddle speed settings
|
||||
myPaddleSpeed[0]->setValue(instance()->settings().getInt("p1speed"));
|
||||
myPaddleLabel[0]->setLabel(instance()->settings().getString("p1speed"));
|
||||
myPaddleSpeed[1]->setValue(instance()->settings().getInt("p2speed"));
|
||||
myPaddleLabel[1]->setLabel(instance()->settings().getString("p2speed"));
|
||||
myPaddleSpeed[2]->setValue(instance()->settings().getInt("p3speed"));
|
||||
myPaddleLabel[2]->setLabel(instance()->settings().getString("p3speed"));
|
||||
myPaddleSpeed[3]->setValue(instance()->settings().getInt("p4speed"));
|
||||
myPaddleLabel[3]->setLabel(instance()->settings().getString("p4speed"));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -171,11 +214,9 @@ void InputDialog::saveConfig()
|
|||
int mode = myPaddleMode->getValue();
|
||||
instance()->eventHandler().setPaddleMode(mode);
|
||||
|
||||
/* FIXME - add this to eventhandler core
|
||||
// Paddle sensitivity
|
||||
int sense = myPaddleSense->getValue();
|
||||
instance()->eventHandler().setPaddleSense(sense);
|
||||
*/
|
||||
// Paddle speed settings
|
||||
for(int i = 0; i < 4; ++i)
|
||||
instance()->eventHandler().setPaddleSpeed(i, myPaddleSpeed[i]->getValue());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -225,11 +266,14 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
break;
|
||||
|
||||
case kPaddleChanged:
|
||||
myPaddleLabel->setValue(myPaddleMode->getValue());
|
||||
myPaddleModeLabel->setValue(myPaddleMode->getValue());
|
||||
break;
|
||||
|
||||
case kSenseChanged:
|
||||
mySenseLabel->setValue(myPaddleSense->getValue());
|
||||
case kP0SpeedID:
|
||||
case kP1SpeedID:
|
||||
case kP2SpeedID:
|
||||
case kP3SpeedID:
|
||||
myPaddleLabel[cmd-100]->setValue(myPaddleSpeed[cmd-100]->getValue());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -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.3 2005-12-07 20:46:49 stephena Exp $
|
||||
// $Id: InputDialog.hxx,v 1.4 2005-12-16 14:41:15 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef INPUT_DIALOG_HXX
|
||||
|
@ -59,9 +59,9 @@ class InputDialog : public Dialog
|
|||
PopUpWidget* myRightPort;
|
||||
|
||||
SliderWidget* myPaddleMode;
|
||||
StaticTextWidget* myPaddleLabel;
|
||||
SliderWidget* myPaddleSense;
|
||||
StaticTextWidget* mySenseLabel;
|
||||
StaticTextWidget* myPaddleModeLabel;
|
||||
SliderWidget* myPaddleSpeed[4];
|
||||
StaticTextWidget* myPaddleLabel[4];
|
||||
|
||||
CheckBoxWidget* myJoyMouse;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue