- Removed the 'joyleft' and 'joyright' arguments, since they never

really worked right anyway.

 - Stella now tries to open all joysticks you have (up to 4), and
they can then be remapped any way you want.

 - As of the previous cvs commit, all old state files are now
invalid.  Sorry, but it had to happen sometime (and it may happen
again).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@241 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2004-04-27 00:50:52 +00:00
parent 6c3b06d19e
commit ada3f7cf24
11 changed files with 61 additions and 75 deletions

View File

@ -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: Console.cxx,v 1.26 2004-04-26 17:27:31 stephena Exp $ // $Id: Console.cxx,v 1.27 2004-04-27 00:50:51 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <assert.h>
@ -207,7 +207,6 @@ Console::~Console()
void Console::update() void Console::update()
{ {
myFrameBuffer.update(); myFrameBuffer.update();
//FIXME mySound.update();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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: FrameBuffer.cxx,v 1.7 2003-11-24 14:51:06 stephena Exp $ // $Id: FrameBuffer.cxx,v 1.8 2004-04-27 00:50:51 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -409,9 +409,9 @@ void FrameBuffer::sendJoyEvent(StellaEvent::JoyStick stick,
case MAIN_MENU: case MAIN_MENU:
// if(key == StellaEvent::KCODE_RETURN) // if(key == StellaEvent::KCODE_RETURN)
// myCurrentWidget = currentSelectedWidget(); // myCurrentWidget = currentSelectedWidget();
if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_UP) if(code == StellaEvent::JAXIS_UP)
moveCursorUp(1); moveCursorUp(1);
else if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_DOWN) else if(code == StellaEvent::JAXIS_DOWN)
moveCursorDown(1); moveCursorDown(1);
break; // MAIN_MENU break; // MAIN_MENU
@ -422,9 +422,9 @@ void FrameBuffer::sendJoyEvent(StellaEvent::JoyStick stick,
addJoyBinding(mySelectedEvent, stick, code); addJoyBinding(mySelectedEvent, stick, code);
myRemapEventSelectedFlag = false; myRemapEventSelectedFlag = false;
} }
else if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_UP) else if(code == StellaEvent::JAXIS_UP)
moveCursorUp(1); moveCursorUp(1);
else if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_DOWN) else if(code == StellaEvent::JAXIS_DOWN)
moveCursorDown(1); moveCursorDown(1);
// else if(key == StellaEvent::KCODE_PAGEUP) // else if(key == StellaEvent::KCODE_PAGEUP)
// movePageUp(); // movePageUp();

View File

@ -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: Settings.cxx,v 1.18 2004-04-04 02:03:15 stephena Exp $ // $Id: Settings.cxx,v 1.19 2004-04-27 00:50:51 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -53,8 +53,6 @@ Settings::Settings()
set("hidecursor", "false"); set("hidecursor", "false");
set("volume", "-1"); set("volume", "-1");
set("accurate", "true"); set("accurate", "true");
set("joyleft", "0");
set("joyright", "1");
set("framerate", "60"); set("framerate", "60");
set("keymap", ""); set("keymap", "");
set("joymap", ""); set("joymap", "");

View File

@ -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: Sound.cxx,v 1.10 2004-04-26 17:27:31 stephena Exp $ // $Id: Sound.cxx,v 1.11 2004-04-27 00:50:51 stephena Exp $
//============================================================================ //============================================================================
#include "Serializer.hxx" #include "Serializer.hxx"
@ -75,6 +75,8 @@ bool Sound::save(Serializer& out)
out.putLong(reg); out.putLong(reg);
out.putLong(reg); out.putLong(reg);
out.putLong(myLastSoundUpdateCycle);
return true; return true;
} }
@ -93,5 +95,7 @@ bool Sound::load(Deserializer& in)
reg = (uInt8) in.getLong(); reg = (uInt8) in.getLong();
reg = (uInt8) in.getLong(); reg = (uInt8) in.getLong();
myLastSoundUpdateCycle = (Int32) in.getLong();
return true; return true;
} }

View File

@ -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: StellaEvent.hxx,v 1.7 2003-09-30 18:46:12 stephena Exp $ // $Id: StellaEvent.hxx,v 1.8 2004-04-27 00:50:51 stephena Exp $
//============================================================================ //============================================================================
#ifndef STELLAEVENT_HXX #ifndef STELLAEVENT_HXX
@ -28,7 +28,7 @@
by the frontends directly. by the frontends directly.
@author Stephen Anthony @author Stephen Anthony
@version $Id: StellaEvent.hxx,v 1.7 2003-09-30 18:46:12 stephena Exp $ @version $Id: StellaEvent.hxx,v 1.8 2004-04-27 00:50:51 stephena Exp $
*/ */
class StellaEvent class StellaEvent
{ {
@ -80,7 +80,6 @@ class StellaEvent
enum JoyStick enum JoyStick
{ {
JSTICK_0, JSTICK_1, JSTICK_2, JSTICK_3, JSTICK_0, JSTICK_1, JSTICK_2, JSTICK_3,
JSTICK_4, JSTICK_5, JSTICK_6, JSTICK_7,
LastJSTICK LastJSTICK
}; };

View File

@ -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: TIA.cxx,v 1.31 2004-04-26 17:27:31 stephena Exp $ // $Id: TIA.cxx,v 1.32 2004-04-27 00:50:51 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -288,7 +288,6 @@ bool TIA::save(Serializer& out)
{ {
out.putString(device); out.putString(device);
//FIXME out.putLong(myLastSoundUpdateCycle);
out.putLong(myClockWhenFrameStarted); out.putLong(myClockWhenFrameStarted);
out.putLong(myClockStartDisplay); out.putLong(myClockStartDisplay);
out.putLong(myClockStopDisplay); out.putLong(myClockStopDisplay);
@ -385,7 +384,6 @@ bool TIA::load(Deserializer& in)
if(in.getString() != device) if(in.getString() != device)
return false; return false;
//FIXME myLastSoundUpdateCycle = (Int32) in.getLong();
myClockWhenFrameStarted = (Int32) in.getLong(); myClockWhenFrameStarted = (Int32) in.getLong();
myClockStartDisplay = (Int32) in.getLong(); myClockStartDisplay = (Int32) in.getLong();
myClockStopDisplay = (Int32) in.getLong(); myClockStopDisplay = (Int32) in.getLong();

View File

@ -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: FrameBufferGL.cxx,v 1.18 2004-04-26 12:49:46 stephena Exp $ // $Id: FrameBufferGL.cxx,v 1.19 2004-04-27 00:50:52 stephena Exp $
//============================================================================ //============================================================================
#include <SDL.h> #include <SDL.h>
@ -229,7 +229,7 @@ bool FrameBufferGL::init()
<< "Vendor : " << glGetString(GL_VENDOR) << endl << "Vendor : " << glGetString(GL_VENDOR) << endl
<< "Renderer: " << glGetString(GL_RENDERER) << endl << "Renderer: " << glGetString(GL_RENDERER) << endl
<< "Version : " << glGetString(GL_VERSION) << endl << "Version : " << glGetString(GL_VERSION) << endl
<< colormode.str() << endl; << colormode.str() << endl << endl;
} }
// Make sure that theUseFullScreenFlag sets up fullscreen mode correctly // Make sure that theUseFullScreenFlag sets up fullscreen mode correctly

View File

@ -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: SettingsUNIX.cxx,v 1.8 2004-04-04 02:03:15 stephena Exp $ // $Id: SettingsUNIX.cxx,v 1.9 2004-04-27 00:50:52 stephena Exp $
//============================================================================ //============================================================================
#include <cstdlib> #include <cstdlib>
@ -98,8 +98,6 @@ void SettingsUNIX::usage(string& message)
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
<< " -paddle <0|1|2|3|real> Indicates which paddle the mouse should emulate\n" << " -paddle <0|1|2|3|real> Indicates which paddle the mouse should emulate\n"
<< " or that real Atari 2600 paddles are being used\n" << " or that real Atari 2600 paddles are being used\n"
<< " -joyleft <number> The joystick number representing the left controller\n"
<< " -joyright <number> The joystick number representing the right controller\n"
#else #else
<< " -paddle <0|1|2|3> Indicates which paddle the mouse should emulate\n" << " -paddle <0|1|2|3> Indicates which paddle the mouse should emulate\n"
#endif #endif

View File

@ -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: SettingsWin32.cxx,v 1.3 2004-04-04 02:03:15 stephena Exp $ // $Id: SettingsWin32.cxx,v 1.4 2004-04-27 00:50:52 stephena Exp $
//============================================================================ //============================================================================
#include <cstdlib> #include <cstdlib>
@ -104,8 +104,6 @@ void SettingsWin32::usage(string& message)
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
<< " -paddle <0|1|2|3|real> Indicates which paddle the mouse should emulate\n" << " -paddle <0|1|2|3|real> Indicates which paddle the mouse should emulate\n"
<< " or that real Atari 2600 paddles are being used\n" << " or that real Atari 2600 paddles are being used\n"
<< " -joyleft <number> The joystick number representing the left controller\n"
<< " -joyright <number> The joystick number representing the right controller\n"
#else #else
<< " -paddle <0|1|2|3> Indicates which paddle the mouse should emulate\n" << " -paddle <0|1|2|3> Indicates which paddle the mouse should emulate\n"
#endif #endif

View File

@ -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: mainSDL.cxx,v 1.72 2004-04-26 12:49:46 stephena Exp $ // $Id: mainSDL.cxx,v 1.73 2004-04-27 00:50:52 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
@ -64,11 +64,20 @@ static uInt32 getTicks();
static bool setupProperties(PropertiesSet& set); static bool setupProperties(PropertiesSet& set);
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
static SDL_Joystick* theLeftJoystick = (SDL_Joystick*) NULL; static SDL_Joystick* theJoysticks[StellaEvent::LastJSTICK];
static SDL_Joystick* theRightJoystick = (SDL_Joystick*) NULL;
static uInt32 theLeftJoystickNumber;
static uInt32 theRightJoystickNumber;
// static uInt32 thePaddleNumber; // static uInt32 thePaddleNumber;
// Lookup table for joystick numbers and events
StellaEvent::JoyStick joyList[StellaEvent::LastJSTICK] = {
StellaEvent::JSTICK_0, StellaEvent::JSTICK_1,
StellaEvent::JSTICK_2, StellaEvent::JSTICK_3
};
StellaEvent::JoyCode joyButtonList[StellaEvent::LastJCODE] = {
StellaEvent::JBUTTON_0, StellaEvent::JBUTTON_1, StellaEvent::JBUTTON_2,
StellaEvent::JBUTTON_3, StellaEvent::JBUTTON_4, StellaEvent::JBUTTON_5,
StellaEvent::JBUTTON_6, StellaEvent::JBUTTON_7, StellaEvent::JBUTTON_8,
StellaEvent::JBUTTON_9
};
#endif #endif
// Pointer to the console object or the null pointer // Pointer to the console object or the null pointer
@ -221,19 +230,6 @@ static Switches keyList[] = {
{ SDLK_PAGEDOWN, StellaEvent::KCODE_PAGEDOWN } { SDLK_PAGEDOWN, StellaEvent::KCODE_PAGEDOWN }
}; };
// Lookup table for joystick numbers and events
StellaEvent::JoyStick joyList[StellaEvent::LastJSTICK] = {
StellaEvent::JSTICK_0, StellaEvent::JSTICK_1,
StellaEvent::JSTICK_2, StellaEvent::JSTICK_3
};
StellaEvent::JoyCode joyButtonList[StellaEvent::LastJCODE] = {
StellaEvent::JBUTTON_0, StellaEvent::JBUTTON_1, StellaEvent::JBUTTON_2,
StellaEvent::JBUTTON_3, StellaEvent::JBUTTON_4, StellaEvent::JBUTTON_5,
StellaEvent::JBUTTON_6, StellaEvent::JBUTTON_7, StellaEvent::JBUTTON_8,
StellaEvent::JBUTTON_9
};
/** /**
Returns number of ticks in microseconds Returns number of ticks in microseconds
*/ */
@ -260,41 +256,31 @@ inline uInt32 getTicks()
bool setupJoystick() bool setupJoystick()
{ {
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
// First clear the joystick array
for(uInt32 i = 0; i < StellaEvent::LastJSTICK; i++)
theJoysticks[i] = (SDL_Joystick*) NULL;
// Initialize the joystick subsystem // Initialize the joystick subsystem
if((SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) || (SDL_NumJoysticks() <= 0)) if((SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) || (SDL_NumJoysticks() <= 0))
{ {
if(theShowInfoFlag) if(theShowInfoFlag)
cout << "No joysticks present, use the keyboard.\n"; cout << "No joysticks present, use the keyboard.\n";
theLeftJoystick = theRightJoystick = 0;
return true; return true;
} }
theLeftJoystickNumber = (uInt32) theConsole->settings().getInt("joyleft"); // Try to open as many joysticks as possible (up to 4)
if((theLeftJoystick = SDL_JoystickOpen(theLeftJoystickNumber)) != NULL) // Let the user decide how to map them
uInt32 limit = SDL_NumJoysticks() <= StellaEvent::LastJSTICK ?
SDL_NumJoysticks() : StellaEvent::LastJSTICK;
for(uInt32 i = 0; i < limit; i++)
{ {
if(theShowInfoFlag) theJoysticks[i] = SDL_JoystickOpen(i);
cout << "Left joystick is a " if(theJoysticks[i] != NULL && theShowInfoFlag)
<< SDL_JoystickName(theLeftJoystickNumber) {
<< " with " << SDL_JoystickNumButtons(theLeftJoystick) << " buttons.\n"; cout << "Joystick " << i << ": " << SDL_JoystickName(i)
} << " with " << SDL_JoystickNumButtons(theJoysticks[i]) << " buttons.\n";
else }
{
if(theShowInfoFlag)
cout << "Left joystick not present, use keyboard instead.\n";
}
theRightJoystickNumber = theConsole->settings().getInt("joyright");
if((theRightJoystick = SDL_JoystickOpen(theRightJoystickNumber)) != NULL)
{
if(theShowInfoFlag)
cout << "Right joystick is a "
<< SDL_JoystickName(theRightJoystickNumber)
<< " with " << SDL_JoystickNumButtons(theRightJoystick) << " buttons.\n";
}
else
{
if(theShowInfoFlag)
cout << "Right joystick not present, use keyboard instead.\n";
} }
#endif #endif
@ -540,6 +526,7 @@ void handleEvents()
if(event.jbutton.which >= StellaEvent::LastJSTICK) if(event.jbutton.which >= StellaEvent::LastJSTICK)
return; return;
stick = joyList[event.jbutton.which]; stick = joyList[event.jbutton.which];
if((event.type == SDL_JOYBUTTONDOWN) || (event.type == SDL_JOYBUTTONUP)) if((event.type == SDL_JOYBUTTONDOWN) || (event.type == SDL_JOYBUTTONUP))
@ -644,10 +631,11 @@ void cleanup()
if(SDL_WasInit(SDL_INIT_EVERYTHING)) if(SDL_WasInit(SDL_INIT_EVERYTHING))
{ {
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
if(SDL_JoystickOpened(theLeftJoystickNumber)) for(uInt32 i = 0; i < StellaEvent::LastJSTICK; i++)
SDL_JoystickClose(theLeftJoystick); {
if(SDL_JoystickOpened(theRightJoystickNumber)) if(SDL_JoystickOpened(i))
SDL_JoystickClose(theRightJoystick); SDL_JoystickClose(theJoysticks[i]);
}
#endif #endif
SDL_Quit(); SDL_Quit();

View File

@ -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: SoundSDL.cxx,v 1.9 2004-04-26 17:27:32 stephena Exp $ // $Id: SoundSDL.cxx,v 1.10 2004-04-27 00:50:52 stephena Exp $
//============================================================================ //============================================================================
#include <SDL.h> #include <SDL.h>
@ -25,7 +25,7 @@
#include "SoundSDL.hxx" #include "SoundSDL.hxx"
#define DIGITAL_SOUND //#define DIGITAL_SOUND
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SoundSDL::SoundSDL(uInt32 fragsize, uInt32 queuesize) SoundSDL::SoundSDL(uInt32 fragsize, uInt32 queuesize)
@ -235,6 +235,8 @@ bool SoundSDL::save(Serializer& out)
out.putLong(reg4); out.putLong(reg4);
out.putLong(reg5); out.putLong(reg5);
out.putLong(reg6); out.putLong(reg6);
out.putLong(myLastSoundUpdateCycle);
} }
catch(char *msg) catch(char *msg)
{ {
@ -268,6 +270,8 @@ bool SoundSDL::load(Deserializer& in)
reg5 = (uInt8) in.getLong(); reg5 = (uInt8) in.getLong();
reg6 = (uInt8) in.getLong(); reg6 = (uInt8) in.getLong();
myLastSoundUpdateCycle = (Int32) in.getLong();
// Only update the TIA sound registers if sound is enabled // Only update the TIA sound registers if sound is enabled
if(myIsInitializedFlag) if(myIsInitializedFlag)
Tia_set_registers(reg1, reg2, reg3, reg4, reg5, reg6); Tia_set_registers(reg1, reg2, reg3, reg4, reg5, reg6);