mirror of https://github.com/stella-emu/stella.git
More work on virtual ports in the InputDialog. You can now use the GUI
to select which joysticks are mapped to which virtual port. Some work on the mouse/paddle emulation. It now uses a slider instead of a dropdown widget. Added slider for paddle sensitivity, but it's not tied to the core yet, and doesn't do anything. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@881 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
532a9a6184
commit
4b3ed7a63d
|
@ -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.113 2005-11-13 16:17:10 stephena Exp $
|
||||
// $Id: EventHandler.cxx,v 1.114 2005-11-14 17:01:18 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -129,6 +129,8 @@ EventHandler::EventHandler(OSystem* osystem)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
EventHandler::~EventHandler()
|
||||
{
|
||||
ourJoystickNames.clear();
|
||||
|
||||
if(myEvent)
|
||||
delete myEvent;
|
||||
|
||||
|
@ -269,6 +271,7 @@ void EventHandler::setupJoysticks()
|
|||
<< " with " << SDL_JoystickNumButtons(ourJoysticks[i].stick)
|
||||
<< " buttons" << endl;
|
||||
}
|
||||
ourJoystickNames.push_back(ourJoysticks[i].name);
|
||||
}
|
||||
if(showinfo)
|
||||
cout << endl;
|
||||
|
|
|
@ -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.56 2005-11-13 16:17:10 stephena Exp $
|
||||
// $Id: EventHandler.hxx,v 1.57 2005-11-14 17:01:18 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef EVENTHANDLER_HXX
|
||||
|
@ -25,6 +25,7 @@
|
|||
#include "Event.hxx"
|
||||
#include "Array.hxx"
|
||||
#include "Control.hxx"
|
||||
#include "StringList.hxx"
|
||||
|
||||
class Console;
|
||||
class OSystem;
|
||||
|
@ -87,7 +88,7 @@ struct Joystick_Map {
|
|||
mapping can take place.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: EventHandler.hxx,v 1.56 2005-11-13 16:17:10 stephena Exp $
|
||||
@version $Id: EventHandler.hxx,v 1.57 2005-11-14 17:01:18 stephena Exp $
|
||||
*/
|
||||
class EventHandler
|
||||
{
|
||||
|
@ -119,6 +120,14 @@ class EventHandler
|
|||
*/
|
||||
void setupJoysticks();
|
||||
|
||||
/**
|
||||
Maps the enumerated joysticks to the specified ports on a real 2600
|
||||
|
||||
@param leftport Index of joystick to use for the left Atari 2600 port
|
||||
@param rightport Index of joystick to use for the right Atari 2600 port
|
||||
*/
|
||||
void mapJoysticks(int leftport, int rightport);
|
||||
|
||||
/**
|
||||
Collects and dispatches any pending events. This method should be
|
||||
called regularly (at X times per second, where X is the game framerate).
|
||||
|
@ -214,6 +223,13 @@ class EventHandler
|
|||
*/
|
||||
void setPaddleMode(uInt32 num, bool showmessage = false);
|
||||
|
||||
/**
|
||||
The list of joysticks found by SDL.
|
||||
|
||||
@return List of joystick names in SDL-enumerated order
|
||||
*/
|
||||
const StringList& joystickNames() { return ourJoystickNames; }
|
||||
|
||||
inline bool kbdAlt(int mod)
|
||||
{
|
||||
#ifndef MAC_OSX
|
||||
|
@ -305,14 +321,6 @@ class EventHandler
|
|||
*/
|
||||
inline bool eventStateChange(Event::Type type);
|
||||
|
||||
/**
|
||||
Maps the enumerated joysticks to the specified ports on a real 2600
|
||||
|
||||
@param leftport Index of joystick to use for the left Atari 2600 port
|
||||
@param rightport Index of joystick to use for the right Atari 2600 port
|
||||
*/
|
||||
void mapJoysticks(int leftport, int rightport);
|
||||
|
||||
/**
|
||||
The following methods take care of assigning action mappings.
|
||||
*/
|
||||
|
@ -419,6 +427,9 @@ class EventHandler
|
|||
// Type of device on each controller port (based on ROM properties)
|
||||
Controller::Type myController[2];
|
||||
|
||||
// List of names of all joysticks found by SDL
|
||||
StringList ourJoystickNames;
|
||||
|
||||
// Lookup table for paddle resistance events
|
||||
static const Event::Type Paddle_Resistance[4];
|
||||
|
||||
|
|
|
@ -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.1 2005-11-13 22:25:47 stephena Exp $
|
||||
// $Id: InputDialog.cxx,v 1.2 2005-11-14 17:01:19 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "OSystem.hxx"
|
||||
|
@ -26,19 +26,19 @@
|
|||
|
||||
#include "bspf.hxx"
|
||||
|
||||
enum {
|
||||
kPaddleChanged = 'PDch',
|
||||
kSenseChanged = 'PSch'
|
||||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
InputDialog::InputDialog(
|
||||
OSystem* osystem, DialogContainer* parent,
|
||||
int x, int y, int w, int h)
|
||||
: Dialog(osystem, parent, x, y, w, h)
|
||||
{
|
||||
const GUI::Font& font = instance()->font();
|
||||
const int fontHeight = font.getFontHeight(),
|
||||
lineHeight = font.getLineHeight();
|
||||
|
||||
const int vBorder = 4;
|
||||
int xpos, ypos, tabID;
|
||||
WidgetArray wid;
|
||||
|
||||
// The tab widget
|
||||
xpos = 2; ypos = vBorder;
|
||||
|
@ -54,22 +54,7 @@ InputDialog::InputDialog(
|
|||
addToFocusList(myEventMapper->getFocusList(), tabID);
|
||||
|
||||
// 2) Virtual device support
|
||||
wid.clear();
|
||||
tabID = myTab->addTab("Virtual Devices");
|
||||
|
||||
// Add 'mouse to paddle' mapping
|
||||
myPaddleModeText = new StaticTextWidget(myTab, 168, 93, 50, fontHeight,
|
||||
"Mouse is", kTextAlignCenter);
|
||||
myPaddleModePopup = new PopUpWidget(myTab, 160, 105, 60, lineHeight,
|
||||
"paddle: ", 40, 0);
|
||||
myPaddleModePopup->appendEntry("0", 0);
|
||||
myPaddleModePopup->appendEntry("1", 1);
|
||||
myPaddleModePopup->appendEntry("2", 2);
|
||||
myPaddleModePopup->appendEntry("3", 3);
|
||||
wid.push_back(myPaddleModePopup);
|
||||
|
||||
// Add items for virtual device ports
|
||||
addToFocusList(wid, tabID);
|
||||
addVDeviceTab();
|
||||
|
||||
// Activate the first tab
|
||||
myTab->setActiveTab(0);
|
||||
|
@ -89,20 +74,109 @@ InputDialog::~InputDialog()
|
|||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::addVDeviceTab()
|
||||
{
|
||||
const GUI::Font& font = instance()->font();
|
||||
const int fontHeight = font.getFontHeight(),
|
||||
lineHeight = font.getLineHeight();
|
||||
const StringList& joynames = instance()->eventHandler().joystickNames();
|
||||
|
||||
WidgetArray wid;
|
||||
int xpos, ypos, lwidth, fwidth, tabID;
|
||||
|
||||
// Virtual device/ports
|
||||
tabID = myTab->addTab("Virtual Devices");
|
||||
|
||||
// Leftport and rightport commandline arguments
|
||||
xpos = 5; ypos = 5;
|
||||
lwidth = font.getStringWidth("Right port: ");
|
||||
fwidth = _w - xpos - lwidth - 10;
|
||||
new StaticTextWidget(myTab, xpos, ypos+1, lwidth, fontHeight,
|
||||
"Left Port:", kTextAlignLeft);
|
||||
myLeftPort = new PopUpWidget(myTab, xpos+lwidth, ypos,
|
||||
fwidth, lineHeight, "", 0, 0);
|
||||
myLeftPort->appendEntry("None", 0);
|
||||
for(unsigned int i = 0; i < joynames.size(); ++i)
|
||||
myLeftPort->appendEntry(joynames[i], i+1);
|
||||
wid.push_back(myLeftPort);
|
||||
|
||||
ypos += lineHeight + 3;
|
||||
new StaticTextWidget(myTab, xpos, ypos+1, lwidth, fontHeight,
|
||||
"Right Port:", kTextAlignLeft);
|
||||
myRightPort = new PopUpWidget(myTab, xpos+lwidth, ypos,
|
||||
fwidth, lineHeight, "", 0, 0);
|
||||
myRightPort->appendEntry("None", 0);
|
||||
for(unsigned int i = 0; i < joynames.size(); ++i)
|
||||
myRightPort->appendEntry(joynames[i], i+1);
|
||||
wid.push_back(myRightPort);
|
||||
|
||||
// Add 'mouse to paddle' mapping
|
||||
ypos += 2*lineHeight + 3;
|
||||
lwidth = font.getStringWidth("Mouse sensitivity: ");
|
||||
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);
|
||||
wid.push_back(myPaddleMode);
|
||||
|
||||
// Add mouse sensitivity
|
||||
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);
|
||||
|
||||
// Add items for virtual device ports
|
||||
addToFocusList(wid, tabID);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::loadConfig()
|
||||
{
|
||||
// Left & right ports
|
||||
int lport = instance()->settings().getInt("leftport") + 1;
|
||||
myLeftPort->setSelectedTag(lport);
|
||||
int rport = instance()->settings().getInt("rightport") + 1;
|
||||
myRightPort->setSelectedTag(rport);
|
||||
|
||||
// Paddle mode
|
||||
int mode = instance()->settings().getInt("paddle");
|
||||
myPaddleModePopup->setSelectedTag(mode);
|
||||
myPaddleMode->setValue(instance()->settings().getInt("paddle"));
|
||||
myPaddleLabel->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"));
|
||||
*/
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::saveConfig()
|
||||
{
|
||||
// Left & right ports
|
||||
int lport = myLeftPort->getSelectedTag() - 1;
|
||||
int rport = myRightPort->getSelectedTag() - 1;
|
||||
instance()->eventHandler().mapJoysticks(lport, rport);
|
||||
|
||||
// Paddle mode
|
||||
int mode = myPaddleModePopup->getSelectedTag();
|
||||
int mode = myPaddleMode->getValue();
|
||||
instance()->eventHandler().setPaddleMode(mode);
|
||||
|
||||
/* FIXME - add this to eventhandler core
|
||||
// Paddle sensitivity
|
||||
int sense = myPaddleSense->getValue();
|
||||
instance()->eventHandler().setPaddleSensee(sense);
|
||||
*/
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -141,6 +215,14 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
close();
|
||||
break;
|
||||
|
||||
case kPaddleChanged:
|
||||
myPaddleLabel->setValue(myPaddleMode->getValue());
|
||||
break;
|
||||
|
||||
case kSenseChanged:
|
||||
mySenseLabel->setValue(myPaddleSense->getValue());
|
||||
break;
|
||||
|
||||
default:
|
||||
Dialog::handleCommand(sender, cmd, data, 0);
|
||||
}
|
||||
|
|
|
@ -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.1 2005-11-13 22:25:47 stephena Exp $
|
||||
// $Id: InputDialog.hxx,v 1.2 2005-11-14 17:01:19 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef INPUT_DIALOG_HXX
|
||||
|
@ -23,8 +23,10 @@ class OSystem;
|
|||
class GuiObject;
|
||||
class TabWidget;
|
||||
class EventMappingWidget;
|
||||
class StaticTextWidget;
|
||||
class CheckBoxWidget;
|
||||
class PopUpWidget;
|
||||
class SliderWidget;
|
||||
class StaticTextWidget;
|
||||
|
||||
#include "Dialog.hxx"
|
||||
#include "bspf.hxx"
|
||||
|
@ -45,12 +47,23 @@ class InputDialog : public Dialog
|
|||
void loadConfig();
|
||||
void saveConfig();
|
||||
|
||||
private:
|
||||
void addVDeviceTab();
|
||||
|
||||
private:
|
||||
TabWidget* myTab;
|
||||
|
||||
EventMappingWidget* myEventMapper;
|
||||
PopUpWidget* myPaddleModePopup;
|
||||
StaticTextWidget* myPaddleModeText;
|
||||
|
||||
PopUpWidget* myLeftPort;
|
||||
PopUpWidget* myRightPort;
|
||||
|
||||
SliderWidget* myPaddleMode;
|
||||
StaticTextWidget* myPaddleLabel;
|
||||
SliderWidget* myPaddleSense;
|
||||
StaticTextWidget* mySenseLabel;
|
||||
|
||||
CheckBoxWidget* myJoyMouse;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue