Reworked the mapping of joysticks yet again. After some thought, it

made no sense to restrict Stella to only work with two joysticks, since
there's no reason one couldn't use four devices, with each one emulating
a paddle (once I get paddle remapping done).  So I've removed that
restriction, and also removed the 'leftport' and 'rightport' arguments.

The one case where remapping a joystick *does* make sense is for
multiple Stelladaptors.  In that case, there might only be one
Stelladaptor installed, but you'd like it to emulate the right virtual
port.  Previously this wasn't possible, but now it is with the addition
of the 'sa1' and 'sa2' commandline arguments.  These arguments accept
either 'left' or 'right', specifying which virtual port to emulate.

Updated the InputDialog virtual device tab for remapping Stelladaptors.

Shortened some keynames in EventHandler, so that the actual character is
used (for example, ? instead of QUESTION).

Some fixes for the OS/2 port.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@884 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-11-19 22:26:14 +00:00
parent 976b1551e7
commit ac1dbc31cc
6 changed files with 140 additions and 175 deletions

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.cxx,v 1.114 2005-11-14 17:01:18 stephena Exp $
// $Id: EventHandler.cxx,v 1.115 2005-11-19 22:26:13 stephena Exp $
//============================================================================
#include <algorithm>
@ -64,8 +64,6 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandler::EventHandler(OSystem* osystem)
: myOSystem(osystem),
myLeftJoyPort(0),
myRightJoyPort(0),
myState(S_NONE),
myOverlay(NULL),
myLSState(0),
@ -243,20 +241,11 @@ void EventHandler::setupJoysticks()
{
saCount++;
if(saCount > 2) // Ignore more than 2 Stelladaptors
{
ourJoysticks[i].type = JT_NONE;
continue;
}
else if(saCount == 1)
{
ourJoysticks[i].type = JT_STELLADAPTOR_1;
ourJoysticks[i].name = "Stelladaptor 1";
}
else if(saCount == 2)
{
ourJoysticks[i].type = JT_STELLADAPTOR_2;
ourJoysticks[i].name = "Stelladaptor 2";
}
if(showinfo)
cout << " " << i << ": " << ourJoysticks[i].name << endl;
@ -271,86 +260,61 @@ void EventHandler::setupJoysticks()
<< " with " << SDL_JoystickNumButtons(ourJoysticks[i].stick)
<< " buttons" << endl;
}
ourJoystickNames.push_back(ourJoysticks[i].name);
}
if(showinfo)
cout << endl;
// Map the joysticks we've found according to the specified ports
int lport = myOSystem->settings().getInt("leftport");
int rport = myOSystem->settings().getInt("rightport");
mapJoysticks(lport, rport);
// Map the stelladaptors we've found according to the specified ports
const string& sa1 = myOSystem->settings().getString("sa1");
const string& sa2 = myOSystem->settings().getString("sa2");
mapStelladaptors(sa1, sa2);
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::mapJoysticks(int leftport, int rightport)
void EventHandler::mapStelladaptors(const string& sa1, const string& sa2)
{
#ifdef JOYSTICK_SUPPORT
bool showinfo = myOSystem->settings().getBool("showinfo");
JoyType type;
for(uInt32 i = 0; i < kNumJoysticks; i++)
for(int i = 0; i < kNumJoysticks; i++)
{
ourJoystickMapping[i].stick = -1;
ourJoystickMapping[i].type = JT_NONE;
if(ourJoysticks[i].name == "Stelladaptor 1")
{
if(sa1 == "left")
{
ourJoysticks[i].type = JT_STELLADAPTOR_LEFT;
if(showinfo)
cout << " Stelladaptor 1 emulates left joystick port\n";
}
else if(sa1 == "right")
{
ourJoysticks[i].type = JT_STELLADAPTOR_RIGHT;
if(showinfo)
cout << " Stelladaptor 1 emulates right joystick port\n";
}
}
else if(ourJoysticks[i].name == "Stelladaptor 2")
{
if(sa2 == "left")
{
ourJoysticks[i].type = JT_STELLADAPTOR_LEFT;
if(showinfo)
cout << " Stelladaptor 2 emulates left joystick port\n";
}
else if(sa2 == "right")
{
ourJoysticks[i].type = JT_STELLADAPTOR_RIGHT;
if(showinfo)
cout << " Stelladaptor 2 emulates right joystick port\n";
}
}
}
if(showinfo)
cout << "Joystick mapping:" << endl;
// Map left port
if(leftport >= 0 && leftport < kNumJoysticks)
{
type = ourJoysticks[leftport].type;
ourJoystickMapping[leftport].stick = 0;
ourJoystickMapping[leftport].type = type;
if(showinfo)
cout << " Left port : " << ourJoysticks[leftport].name << endl;
// JT_STELLADAPTOR_1 is *always* tied to left port events,
// so we always remap it type 'JT_STELLADAPTOR_1'
if(type == JT_STELLADAPTOR_2)
ourJoystickMapping[leftport].type = JT_STELLADAPTOR_1;
}
else
{
if(showinfo)
cout << " Left port : None" << endl;
}
// Map right port (can't be the same as the left port)
if(leftport == rightport)
rightport = -1;
if(rightport >= 0 && rightport < kNumJoysticks)
{
type = ourJoysticks[rightport].type;
ourJoystickMapping[rightport].stick = 1;
ourJoystickMapping[rightport].type = type;
if(showinfo)
cout << " Right port: " << ourJoysticks[rightport].name << endl;
// JT_STELLADAPTOR_2 is *always* tied to right port events,
// so we always remap it type 'JT_STELLADAPTOR_2'
if(type == JT_STELLADAPTOR_1)
ourJoystickMapping[rightport].type = JT_STELLADAPTOR_2;
}
else
{
if(showinfo)
cout << " Right port: None" << endl;
}
if(showinfo)
cout << endl;
myOSystem->settings().setInt("leftport", leftport);
myOSystem->settings().setInt("rightport", rightport);
myOSystem->settings().setString("sa1", sa1);
myOSystem->settings().setString("sa2", sa2);
#endif
}
@ -628,7 +592,7 @@ void EventHandler::poll(uInt32 time)
break;
// Stelladaptors handle buttons differently than regular joysticks
int type = ourJoystickMapping[event.jbutton.which].type;
int type = ourJoysticks[event.jbutton.which].type;
switch(type)
{
case JT_REGULAR:
@ -636,7 +600,7 @@ void EventHandler::poll(uInt32 time)
if(event.jbutton.button >= kNumJoyButtons-4)
return;
int stick = ourJoystickMapping[event.jbutton.which].stick;
int stick = event.jbutton.which;
int code = event.jbutton.button;
int state = event.jbutton.state == SDL_PRESSED ? 1 : 0;
@ -644,8 +608,8 @@ void EventHandler::poll(uInt32 time)
break; // Regular joystick button
}
case JT_STELLADAPTOR_1:
case JT_STELLADAPTOR_2:
case JT_STELLADAPTOR_LEFT:
case JT_STELLADAPTOR_RIGHT:
{
int button = event.jbutton.button;
int state = event.jbutton.state == SDL_PRESSED ? 1 : 0;
@ -683,12 +647,12 @@ void EventHandler::poll(uInt32 time)
break;
// Stelladaptors handle axis differently than regular joysticks
int type = ourJoystickMapping[event.jbutton.which].type;
int type = ourJoysticks[event.jbutton.which].type;
switch(type)
{
case JT_REGULAR:
{
int stick = ourJoystickMapping[event.jbutton.which].stick;
int stick = event.jbutton.which;
int axis = event.jaxis.axis;
int value = event.jaxis.value;
@ -711,8 +675,8 @@ void EventHandler::poll(uInt32 time)
break; // Regular joystick axis
}
case JT_STELLADAPTOR_1:
case JT_STELLADAPTOR_2:
case JT_STELLADAPTOR_LEFT:
case JT_STELLADAPTOR_RIGHT:
{
int axis = event.jaxis.axis;
int value = event.jaxis.value;
@ -1757,20 +1721,20 @@ void EventHandler::setSDLMappings()
ourSDLMapping[ SDLK_PAUSE ] = "PAUSE";
ourSDLMapping[ SDLK_ESCAPE ] = "ESCAPE";
ourSDLMapping[ SDLK_SPACE ] = "SPACE";
ourSDLMapping[ SDLK_EXCLAIM ] = "EXCLAIM";
ourSDLMapping[ SDLK_QUOTEDBL ] = "QUOTEDBL";
ourSDLMapping[ SDLK_HASH ] = "HASH";
ourSDLMapping[ SDLK_DOLLAR ] = "DOLLAR";
ourSDLMapping[ SDLK_AMPERSAND ] = "AMPERSAND";
ourSDLMapping[ SDLK_QUOTE ] = "QUOTE";
ourSDLMapping[ SDLK_LEFTPAREN ] = "LEFTPAREN";
ourSDLMapping[ SDLK_RIGHTPAREN ] = "RIGHTPAREN";
ourSDLMapping[ SDLK_ASTERISK ] = "ASTERISK";
ourSDLMapping[ SDLK_PLUS ] = "PLUS";
ourSDLMapping[ SDLK_EXCLAIM ] = "!";
ourSDLMapping[ SDLK_QUOTEDBL ] = "\"";
ourSDLMapping[ SDLK_HASH ] = "#";
ourSDLMapping[ SDLK_DOLLAR ] = "$";
ourSDLMapping[ SDLK_AMPERSAND ] = "&";
ourSDLMapping[ SDLK_QUOTE ] = "\'";
ourSDLMapping[ SDLK_LEFTPAREN ] = "(";
ourSDLMapping[ SDLK_RIGHTPAREN ] = ")";
ourSDLMapping[ SDLK_ASTERISK ] = "*";
ourSDLMapping[ SDLK_PLUS ] = "+";
ourSDLMapping[ SDLK_COMMA ] = "COMMA";
ourSDLMapping[ SDLK_MINUS ] = "MINUS";
ourSDLMapping[ SDLK_PERIOD ] = "PERIOD";
ourSDLMapping[ SDLK_SLASH ] = "SLASH";
ourSDLMapping[ SDLK_MINUS ] = "-";
ourSDLMapping[ SDLK_PERIOD ] = ".";
ourSDLMapping[ SDLK_SLASH ] = "/";
ourSDLMapping[ SDLK_0 ] = "0";
ourSDLMapping[ SDLK_1 ] = "1";
ourSDLMapping[ SDLK_2 ] = "2";
@ -1781,19 +1745,19 @@ void EventHandler::setSDLMappings()
ourSDLMapping[ SDLK_7 ] = "7";
ourSDLMapping[ SDLK_8 ] = "8";
ourSDLMapping[ SDLK_9 ] = "9";
ourSDLMapping[ SDLK_COLON ] = "COLON";
ourSDLMapping[ SDLK_SEMICOLON ] = "SEMICOLON";
ourSDLMapping[ SDLK_LESS ] = "LESS";
ourSDLMapping[ SDLK_EQUALS ] = "EQUALS";
ourSDLMapping[ SDLK_GREATER ] = "GREATER";
ourSDLMapping[ SDLK_QUESTION ] = "QUESTION";
ourSDLMapping[ SDLK_AT ] = "AT";
ourSDLMapping[ SDLK_LEFTBRACKET ] = "LEFTBRACKET";
ourSDLMapping[ SDLK_BACKSLASH ] = "BACKSLASH";
ourSDLMapping[ SDLK_RIGHTBRACKET ] = "RIGHTBRACKET";
ourSDLMapping[ SDLK_CARET ] = "CARET";
ourSDLMapping[ SDLK_UNDERSCORE ] = "UNDERSCORE";
ourSDLMapping[ SDLK_BACKQUOTE ] = "BACKQUOTE";
ourSDLMapping[ SDLK_COLON ] = ":";
ourSDLMapping[ SDLK_SEMICOLON ] = ";";
ourSDLMapping[ SDLK_LESS ] = "<";
ourSDLMapping[ SDLK_EQUALS ] = "=";
ourSDLMapping[ SDLK_GREATER ] = ">";
ourSDLMapping[ SDLK_QUESTION ] = "?";
ourSDLMapping[ SDLK_AT ] = "@";
ourSDLMapping[ SDLK_LEFTBRACKET ] = "[";
ourSDLMapping[ SDLK_BACKSLASH ] = "\\";
ourSDLMapping[ SDLK_RIGHTBRACKET ] = "]";
ourSDLMapping[ SDLK_CARET ] = "^";
ourSDLMapping[ SDLK_UNDERSCORE ] = "_";
ourSDLMapping[ SDLK_BACKQUOTE ] = "`";
ourSDLMapping[ SDLK_a ] = "A";
ourSDLMapping[ SDLK_b ] = "B";
ourSDLMapping[ SDLK_c ] = "C";
@ -1927,22 +1891,22 @@ void EventHandler::setSDLMappings()
ourSDLMapping[ SDLK_KP7 ] = "KP7";
ourSDLMapping[ SDLK_KP8 ] = "KP8";
ourSDLMapping[ SDLK_KP9 ] = "KP9";
ourSDLMapping[ SDLK_KP_PERIOD ] = "KP_PERIOD";
ourSDLMapping[ SDLK_KP_DIVIDE ] = "KP_DIVIDE";
ourSDLMapping[ SDLK_KP_MULTIPLY ] = "KP_MULTIPLY";
ourSDLMapping[ SDLK_KP_MINUS ] = "KP_MINUS";
ourSDLMapping[ SDLK_KP_PLUS ] = "KP_PLUS";
ourSDLMapping[ SDLK_KP_ENTER ] = "KP_ENTER";
ourSDLMapping[ SDLK_KP_EQUALS ] = "KP_EQUALS";
ourSDLMapping[ SDLK_KP_PERIOD ] = "KP .";
ourSDLMapping[ SDLK_KP_DIVIDE ] = "KP /";
ourSDLMapping[ SDLK_KP_MULTIPLY ] = "KP *";
ourSDLMapping[ SDLK_KP_MINUS ] = "KP -";
ourSDLMapping[ SDLK_KP_PLUS ] = "KP +";
ourSDLMapping[ SDLK_KP_ENTER ] = "KP ENTER";
ourSDLMapping[ SDLK_KP_EQUALS ] = "KP =";
ourSDLMapping[ SDLK_UP ] = "UP";
ourSDLMapping[ SDLK_DOWN ] = "DOWN";
ourSDLMapping[ SDLK_RIGHT ] = "RIGHT";
ourSDLMapping[ SDLK_LEFT ] = "LEFT";
ourSDLMapping[ SDLK_INSERT ] = "INSERT";
ourSDLMapping[ SDLK_INSERT ] = "INS";
ourSDLMapping[ SDLK_HOME ] = "HOME";
ourSDLMapping[ SDLK_END ] = "END";
ourSDLMapping[ SDLK_PAGEUP ] = "PAGEUP";
ourSDLMapping[ SDLK_PAGEDOWN ] = "PAGEDOWN";
ourSDLMapping[ SDLK_PAGEUP ] = "PGUP";
ourSDLMapping[ SDLK_PAGEDOWN ] = "PGDN";
ourSDLMapping[ SDLK_F1 ] = "F1";
ourSDLMapping[ SDLK_F2 ] = "F2";
ourSDLMapping[ SDLK_F3 ] = "F3";

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.57 2005-11-14 17:01:18 stephena Exp $
// $Id: EventHandler.hxx,v 1.58 2005-11-19 22:26:13 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -61,7 +61,12 @@ enum {
kJAxisRight = kNumJoyButtons - 1
};
enum JoyType { JT_NONE, JT_REGULAR, JT_STELLADAPTOR_1, JT_STELLADAPTOR_2 };
enum JoyType {
JT_NONE,
JT_REGULAR,
JT_STELLADAPTOR_LEFT,
JT_STELLADAPTOR_RIGHT
};
struct Stella_Joystick {
SDL_Joystick* stick;
@ -69,12 +74,6 @@ struct Stella_Joystick {
string name;
};
struct Joystick_Map {
int stick;
JoyType type;
};
/**
This class takes care of event remapping and dispatching for the
Stella core, as well as keeping track of the current 'mode'.
@ -88,7 +87,7 @@ struct Joystick_Map {
mapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.57 2005-11-14 17:01:18 stephena Exp $
@version $Id: EventHandler.hxx,v 1.58 2005-11-19 22:26:13 stephena Exp $
*/
class EventHandler
{
@ -121,12 +120,12 @@ class EventHandler
void setupJoysticks();
/**
Maps the enumerated joysticks to the specified ports on a real 2600
Maps the given stelladaptors to 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
@param sa1 Port for the first Stelladaptor to emulate (left or right)
@param sa2 Port for the second Stelladaptor to emulate (left or right)
*/
void mapJoysticks(int leftport, int rightport);
void mapStelladaptors(const string& sa1, const string& sa2);
/**
Collects and dispatches any pending events. This method should be
@ -369,11 +368,6 @@ class EventHandler
// Array of joysticks available to Stella
Stella_Joystick ourJoysticks[kNumJoysticks];
// Mappings from SDL_Joystick to internal 2600 joystick ports
Joystick_Map ourJoystickMapping[kNumJoysticks];
int myLeftJoyPort;
int myRightJoyPort;
// Indicates the current state of the system (ie, which mode is current)
State myState;

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: FrameBuffer.cxx,v 1.67 2005-10-18 18:49:46 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.68 2005-11-19 22:26:13 stephena Exp $
//============================================================================
#include <sstream>
@ -40,22 +40,25 @@
#include "macOSXDisplay.h"
#elif defined(PSP)
#include "DisplayPSP.hxx"
#elif defined(OS2)
#define INCL_WIN
#include <os2emx.h>
#endif
#include "stella.xpm" // The Stella icon
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBuffer::FrameBuffer(OSystem* osystem)
: myOSystem(osystem),
theRedrawTIAIndicator(true),
theZoomLevel(2),
theMaxZoomLevel(2),
theAspectRatio(1.0),
myFrameRate(0),
myPauseStatus(false),
myMessageTime(0),
myMessageText(""),
myNumRedraws(0)
: myOSystem(osystem),
theRedrawTIAIndicator(true),
theZoomLevel(2),
theMaxZoomLevel(2),
theAspectRatio(1.0),
myFrameRate(0),
myPauseStatus(false),
myMessageTime(0),
myMessageText(""),
myNumRedraws(0)
{
myBaseDim.x = myBaseDim.y = myBaseDim.w = myBaseDim.h = 0;
myImageDim = myScreenDim = myDesktopDim = myBaseDim;
@ -90,7 +93,7 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height,
// Calculate the desktop size
// This is really the job of SDL
myDesktopDim.w = myDesktopDim.h = 0;
#if defined(UNIX)
#if defined(UNIX) && !defined(OS2)
SDL_SysWMinfo myWMInfo;
SDL_VERSION(&myWMInfo.version);
if(SDL_GetWMInfo(&myWMInfo) > 0 && myWMInfo.subsystem == SDL_SYSWM_X11)
@ -111,6 +114,9 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height,
#elif defined(PSP)
myDesktopDim.w = PSP_SCREEN_WIDTH;
myDesktopDim.h = PSP_SCREEN_HEIGHT;
#elif defined(OS2)
myDesktopDim.w = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
myDesktopDim.h = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
#endif
// Set fullscreen flag

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.65 2005-10-30 20:29:56 stephena Exp $
// $Id: Settings.cxx,v 1.66 2005-11-19 22:26:13 stephena Exp $
//============================================================================
#include <cassert>
@ -60,8 +60,8 @@ Settings::Settings(OSystem* osystem)
set("joymap", "");
set("paddle", "0");
set("joymouse", "false");
set("leftport", "0");
set("rightport", "1");
set("sa1", "left");
set("sa2", "right");
set("showinfo", "false");
@ -285,6 +285,8 @@ void Settings::usage()
<< " -paddle <0|1|2|3> Indicates which paddle the mouse should emulate\n"
<< " -joymouse <1|0> Enable joystick emulates mouse in GUI\n"
<< " -showinfo <1|0> Shows some game info\n"
<< " -sa1 <left|right> Stelladaptor 1 emulates specified joystick port\n"
<< " -sa2 <left|right> Stelladaptor 2 emulates specified joystick port\n"
#ifdef UNIX
<< " -accurate <1|0> Accurate game timing (uses more CPU)\n"
#endif
@ -480,14 +482,14 @@ bool Settings::getBool(const string& key) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Settings::getString(const string& key) const
const string& Settings::getString(const string& key) const
{
// Try to find the named setting and answer its value
for(unsigned int i = 0; i < mySize; ++i)
if(key == mySettings[i].key)
return mySettings[i].value;
return "";
return EmptyString;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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.hxx,v 1.25 2005-06-16 01:11:28 stephena Exp $
// $Id: Settings.hxx,v 1.26 2005-11-19 22:26:13 stephena Exp $
//============================================================================
#ifndef SETTINGS_HXX
@ -28,7 +28,7 @@ class OSystem;
This class provides an interface for accessing frontend specific settings.
@author Stephen Anthony
@version $Id: Settings.hxx,v 1.25 2005-06-16 01:11:28 stephena Exp $
@version $Id: Settings.hxx,v 1.26 2005-11-19 22:26:13 stephena Exp $
*/
class Settings
{
@ -106,7 +106,7 @@ class Settings
@param key The key of the setting to lookup
@return The string value of the setting
*/
string getString(const string& key) const;
const string& getString(const string& key) const;
/**
Set the value associated with key to the given value.

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.2 2005-11-14 17:01:19 stephena Exp $
// $Id: InputDialog.cxx,v 1.3 2005-11-19 22:26:14 stephena Exp $
//============================================================================
#include "OSystem.hxx"
@ -80,7 +80,6 @@ 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;
@ -88,27 +87,25 @@ void InputDialog::addVDeviceTab()
// Virtual device/ports
tabID = myTab->addTab("Virtual Devices");
// Leftport and rightport commandline arguments
// Stelladaptor mappings
xpos = 5; ypos = 5;
lwidth = font.getStringWidth("Right port: ");
lwidth = font.getStringWidth("Stelladaptor 2 is: ");
fwidth = _w - xpos - lwidth - 10;
new StaticTextWidget(myTab, xpos, ypos+1, lwidth, fontHeight,
"Left Port:", kTextAlignLeft);
"Stelladaptor 1 is:", 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);
myLeftPort->appendEntry("left virtual port", 1);
myLeftPort->appendEntry("right virtual port", 2);
wid.push_back(myLeftPort);
ypos += lineHeight + 3;
new StaticTextWidget(myTab, xpos, ypos+1, lwidth, fontHeight,
"Right Port:", kTextAlignLeft);
"Stelladaptor 2 is:", 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);
myRightPort->appendEntry("left virtual port", 1);
myRightPort->appendEntry("right virtual port", 2);
wid.push_back(myRightPort);
// Add 'mouse to paddle' mapping
@ -144,9 +141,11 @@ void InputDialog::addVDeviceTab()
void InputDialog::loadConfig()
{
// Left & right ports
int lport = instance()->settings().getInt("leftport") + 1;
const string& sa1 = instance()->settings().getString("sa1");
int lport = sa1 == "right" ? 2 : 1;
myLeftPort->setSelectedTag(lport);
int rport = instance()->settings().getInt("rightport") + 1;
const string& sa2 = instance()->settings().getString("sa2");
int rport = sa2 == "right" ? 2 : 1;
myRightPort->setSelectedTag(rport);
// Paddle mode
@ -164,9 +163,9 @@ void InputDialog::loadConfig()
void InputDialog::saveConfig()
{
// Left & right ports
int lport = myLeftPort->getSelectedTag() - 1;
int rport = myRightPort->getSelectedTag() - 1;
instance()->eventHandler().mapJoysticks(lport, rport);
string sa1 = myLeftPort->getSelectedTag() == 2 ? "right" : "left";
string sa2 = myRightPort->getSelectedTag() == 2 ? "right" : "left";
instance()->eventHandler().mapStelladaptors(sa1, sa2);
// Paddle mode
int mode = myPaddleMode->getValue();
@ -175,7 +174,7 @@ void InputDialog::saveConfig()
/* FIXME - add this to eventhandler core
// Paddle sensitivity
int sense = myPaddleSense->getValue();
instance()->eventHandler().setPaddleSensee(sense);
instance()->eventHandler().setPaddleSense(sense);
*/
}