mirror of https://github.com/stella-emu/stella.git
Added mapping of analog joystick axes to paddle events.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@913 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
0f90b07e1a
commit
37bf0dc029
|
@ -13,14 +13,13 @@
|
||||||
// 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: Deserializer.cxx,v 1.7 2005-12-17 01:23:07 stephena Exp $
|
// $Id: Deserializer.cxx,v 1.8 2005-12-17 22:48:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include "Deserializer.hxx"
|
#include "Deserializer.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Deserializer::Deserializer(void)
|
Deserializer::Deserializer(void)
|
||||||
: myStream(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ Deserializer::~Deserializer(void)
|
||||||
bool Deserializer::open(const string& fileName)
|
bool Deserializer::open(const string& fileName)
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
myStream = new ifstream(fileName.c_str(), ios::in | ios::binary);
|
myStream.open(fileName.c_str(), ios::in | ios::binary);
|
||||||
|
|
||||||
return isOpen();
|
return isOpen();
|
||||||
}
|
}
|
||||||
|
@ -42,31 +41,24 @@ bool Deserializer::open(const string& fileName)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Deserializer::close(void)
|
void Deserializer::close(void)
|
||||||
{
|
{
|
||||||
if(myStream)
|
myStream.close();
|
||||||
{
|
|
||||||
if(myStream->is_open())
|
|
||||||
myStream->close();
|
|
||||||
|
|
||||||
delete myStream;
|
|
||||||
myStream = (ifstream*) 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool Deserializer::isOpen(void)
|
bool Deserializer::isOpen(void)
|
||||||
{
|
{
|
||||||
return myStream && myStream->is_open();
|
return myStream && myStream.is_open();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
int Deserializer::getInt(void)
|
int Deserializer::getInt(void)
|
||||||
{
|
{
|
||||||
if(myStream->eof())
|
if(myStream.eof())
|
||||||
throw "Deserializer: end of file";
|
throw "Deserializer: end of file";
|
||||||
|
|
||||||
int val = 0;
|
int val = 0;
|
||||||
unsigned char buf[4];
|
unsigned char buf[4];
|
||||||
myStream->read((char*)buf, 4);
|
myStream.read((char*)buf, 4);
|
||||||
for(int i = 0; i < 4; ++i)
|
for(int i = 0; i < 4; ++i)
|
||||||
val += (int)(buf[i]) << (i<<3);
|
val += (int)(buf[i]) << (i<<3);
|
||||||
|
|
||||||
|
@ -79,9 +71,9 @@ string Deserializer::getString(void)
|
||||||
int len = getInt();
|
int len = getInt();
|
||||||
string str;
|
string str;
|
||||||
str.resize((string::size_type)len);
|
str.resize((string::size_type)len);
|
||||||
myStream->read(&str[0], (streamsize)len);
|
myStream.read(&str[0], (streamsize)len);
|
||||||
|
|
||||||
if(myStream->bad())
|
if(myStream.bad())
|
||||||
throw "Deserializer: file read failed";
|
throw "Deserializer: file read failed";
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
@ -93,9 +85,6 @@ bool Deserializer::getBool(void)
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
int b = getInt();
|
int b = getInt();
|
||||||
if(myStream->bad())
|
|
||||||
throw "Deserializer: file read failed";
|
|
||||||
|
|
||||||
if(b == (int)TruePattern)
|
if(b == (int)TruePattern)
|
||||||
result = true;
|
result = true;
|
||||||
else if(b == (int)FalsePattern)
|
else if(b == (int)FalsePattern)
|
||||||
|
|
|
@ -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: Deserializer.hxx,v 1.8 2005-12-17 01:23:07 stephena Exp $
|
// $Id: Deserializer.hxx,v 1.9 2005-12-17 22:48:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef DESERIALIZER_HXX
|
#ifndef DESERIALIZER_HXX
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
return.
|
return.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: Deserializer.hxx,v 1.8 2005-12-17 01:23:07 stephena Exp $
|
@version $Id: Deserializer.hxx,v 1.9 2005-12-17 22:48:24 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Deserializer
|
class Deserializer
|
||||||
{
|
{
|
||||||
|
@ -92,7 +92,7 @@ class Deserializer
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The stream to get the deserialized data from.
|
// The stream to get the deserialized data from.
|
||||||
ifstream* myStream;
|
fstream myStream;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
TruePattern = 0xfab1fab2,
|
TruePattern = 0xfab1fab2,
|
||||||
|
|
|
@ -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: Event.hxx,v 1.16 2005-12-12 19:04:03 stephena Exp $
|
// $Id: Event.hxx,v 1.17 2005-12-17 22:48:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef EVENT_HXX
|
#ifndef EVENT_HXX
|
||||||
|
@ -27,7 +27,7 @@ class Serializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@author Bradford W. Mott
|
@author Bradford W. Mott
|
||||||
@version $Id: Event.hxx,v 1.16 2005-12-12 19:04:03 stephena Exp $
|
@version $Id: Event.hxx,v 1.17 2005-12-17 22:48:24 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Event
|
class Event
|
||||||
{
|
{
|
||||||
|
@ -53,10 +53,14 @@ class Event
|
||||||
BoosterGripZeroTrigger, BoosterGripZeroBooster,
|
BoosterGripZeroTrigger, BoosterGripZeroBooster,
|
||||||
BoosterGripOneTrigger, BoosterGripOneBooster,
|
BoosterGripOneTrigger, BoosterGripOneBooster,
|
||||||
|
|
||||||
PaddleZeroResistance, PaddleZeroFire, PaddleZeroDecrease, PaddleZeroIncrease,
|
PaddleZeroResistance, PaddleZeroFire,
|
||||||
PaddleOneResistance, PaddleOneFire, PaddleOneDecrease, PaddleOneIncrease,
|
PaddleZeroDecrease, PaddleZeroIncrease, PaddleZeroAnalog,
|
||||||
PaddleTwoResistance, PaddleTwoFire, PaddleTwoDecrease, PaddleTwoIncrease,
|
PaddleOneResistance, PaddleOneFire,
|
||||||
PaddleThreeResistance, PaddleThreeFire, PaddleThreeDecrease, PaddleThreeIncrease,
|
PaddleOneDecrease, PaddleOneIncrease, PaddleOneAnalog,
|
||||||
|
PaddleTwoResistance, PaddleTwoFire,
|
||||||
|
PaddleTwoDecrease, PaddleTwoIncrease, PaddleTwoAnalog,
|
||||||
|
PaddleThreeResistance, PaddleThreeFire,
|
||||||
|
PaddleThreeDecrease, PaddleThreeIncrease, PaddleThreeAnalog,
|
||||||
|
|
||||||
KeyboardZero1, KeyboardZero2, KeyboardZero3,
|
KeyboardZero1, KeyboardZero2, KeyboardZero3,
|
||||||
KeyboardZero4, KeyboardZero5, KeyboardZero6,
|
KeyboardZero4, KeyboardZero5, KeyboardZero6,
|
||||||
|
|
|
@ -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: EventHandler.cxx,v 1.128 2005-12-16 14:41:14 stephena Exp $
|
// $Id: EventHandler.cxx,v 1.129 2005-12-17 22:48:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -1052,42 +1052,6 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value)
|
||||||
Event::Type eventAxisNeg = myJoyAxisTable[stick][axis][0];
|
Event::Type eventAxisNeg = myJoyAxisTable[stick][axis][0];
|
||||||
Event::Type eventAxisPos = myJoyAxisTable[stick][axis][1];
|
Event::Type eventAxisPos = myJoyAxisTable[stick][axis][1];
|
||||||
|
|
||||||
// Paddle emulation *REALLY* complicates this method
|
|
||||||
if(value == 0)
|
|
||||||
{
|
|
||||||
if(0)//stick is analog && (isPaddleEvent(eventAxisNeg) || isPaddleEvent(eventAxisPos)))
|
|
||||||
{
|
|
||||||
// deal with zero value for analog input
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Turn off both events, since we don't know exactly which one
|
|
||||||
// was previously activated.
|
|
||||||
handleEvent(eventAxisNeg, 0);
|
|
||||||
handleEvent(eventAxisPos, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(value < 0)
|
|
||||||
{
|
|
||||||
if(0)//stick is analog && isPaddleEvent(eventAxisNeg))
|
|
||||||
{
|
|
||||||
// turn on paddle event defined here
|
|
||||||
}
|
|
||||||
else
|
|
||||||
handleEvent(eventAxisNeg, 1);
|
|
||||||
}
|
|
||||||
else // value > 0
|
|
||||||
{
|
|
||||||
if(0)//stick is analog && isPaddleEvent(eventAxisPos))
|
|
||||||
{
|
|
||||||
// turn on paddle event defined here
|
|
||||||
}
|
|
||||||
else
|
|
||||||
handleEvent(eventAxisPos, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// FIXME - This isn't ready for production use just yet ...
|
|
||||||
// Determine what type of axis we're dealing with
|
// Determine what type of axis we're dealing with
|
||||||
// Figure out the actual type if it's undefined
|
// Figure out the actual type if it's undefined
|
||||||
JoyAxisType type = myJoyAxisType[stick][axis];
|
JoyAxisType type = myJoyAxisType[stick][axis];
|
||||||
|
@ -1100,69 +1064,43 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value)
|
||||||
type = myJoyAxisType[stick][axis] = JA_ANALOG;
|
type = myJoyAxisType[stick][axis] = JA_ANALOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make use of an analog axis/stick for those events that are analog
|
// Paddle emulation *REALLY* complicates this method
|
||||||
// in nature (currently only paddle resistance).
|
if(type == JA_ANALOG)
|
||||||
// If an event is analog in nature but the axis is digital, then
|
|
||||||
// emulate the analog values.
|
|
||||||
switch((int)type)
|
|
||||||
{
|
{
|
||||||
case JA_ANALOG:
|
int idx = -1;
|
||||||
switch((int)eventAxisNeg)
|
switch((int)eventAxisNeg)
|
||||||
{
|
{
|
||||||
case Event::PaddleZeroResistance:
|
case Event::PaddleZeroAnalog:
|
||||||
case Event::PaddleOneResistance:
|
idx = 0;
|
||||||
case Event::PaddleTwoResistance:
|
break;
|
||||||
case Event::PaddleThreeResistance:
|
case Event::PaddleOneAnalog:
|
||||||
{
|
idx = 1;
|
||||||
if(value > 0) break;
|
break;
|
||||||
int resistance = (int) (1000000.0 * -value / 32767);
|
case Event::PaddleTwoAnalog:
|
||||||
myEvent->set(eventAxisNeg, resistance);
|
idx = 2;
|
||||||
return;
|
break;
|
||||||
break;
|
case Event::PaddleThreeAnalog:
|
||||||
}
|
idx = 3;
|
||||||
}
|
break;
|
||||||
switch((int)eventAxisPos)
|
}
|
||||||
{
|
if(idx >= 0)
|
||||||
case Event::PaddleZeroResistance:
|
{
|
||||||
case Event::PaddleOneResistance:
|
int resistance = (int)(1000000.0 * (32767 - value) / 65534);
|
||||||
case Event::PaddleTwoResistance:
|
myEvent->set(Paddle_Resistance[idx], resistance);
|
||||||
case Event::PaddleThreeResistance:
|
return;
|
||||||
{
|
}
|
||||||
if(value < 0) return;
|
|
||||||
int resistance = (int) (1000000.0 * value / 32767);
|
|
||||||
myEvent->set(eventAxisPos, resistance);
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case JA_DIGITAL:
|
|
||||||
switch((int)eventAxisNeg)
|
|
||||||
{
|
|
||||||
case Event::PaddleZeroResistance:
|
|
||||||
case Event::PaddleOneResistance:
|
|
||||||
case Event::PaddleTwoResistance:
|
|
||||||
case Event::PaddleThreeResistance:
|
|
||||||
if(value > 0) break;
|
|
||||||
cerr << "paddle resistance - from digital axis\n";
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch((int)eventAxisPos)
|
|
||||||
{
|
|
||||||
case Event::PaddleZeroResistance:
|
|
||||||
case Event::PaddleOneResistance:
|
|
||||||
case Event::PaddleTwoResistance:
|
|
||||||
case Event::PaddleThreeResistance:
|
|
||||||
if(value < 0) return;
|
|
||||||
cerr << "paddle resistance + from digital axis\n";
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
// Otherwise, we know the event is digital
|
||||||
|
if(value == 0)
|
||||||
|
{
|
||||||
|
// Turn off both events, since we don't know exactly which one
|
||||||
|
// was previously activated.
|
||||||
|
handleEvent(eventAxisNeg, 0);
|
||||||
|
handleEvent(eventAxisPos, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
handleEvent(value < 0 ? eventAxisNeg : eventAxisPos, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -1391,7 +1329,12 @@ void EventHandler::setActionMappings()
|
||||||
buf.str("");
|
buf.str("");
|
||||||
buf << "J" << stick << " axis " << axis;
|
buf << "J" << stick << " axis " << axis;
|
||||||
if(eventIsAnalog(event))
|
if(eventIsAnalog(event))
|
||||||
|
{
|
||||||
|
myJoyAxisTable[stick][axis][0] = event;
|
||||||
|
myJoyAxisTable[stick][axis][1] = event;
|
||||||
|
dir = 2; // Immediately exit the inner loop after this iteration
|
||||||
buf << " abs";
|
buf << " abs";
|
||||||
|
}
|
||||||
else if(dir == 0)
|
else if(dir == 0)
|
||||||
buf << " neg";
|
buf << " neg";
|
||||||
else
|
else
|
||||||
|
@ -1764,18 +1707,10 @@ inline bool EventHandler::eventIsAnalog(Event::Type event)
|
||||||
{
|
{
|
||||||
switch((int)event)
|
switch((int)event)
|
||||||
{
|
{
|
||||||
case Event::PaddleZeroResistance:
|
case Event::PaddleZeroAnalog:
|
||||||
case Event::PaddleZeroDecrease:
|
case Event::PaddleOneAnalog:
|
||||||
case Event::PaddleZeroIncrease:
|
case Event::PaddleTwoAnalog:
|
||||||
case Event::PaddleOneResistance:
|
case Event::PaddleThreeAnalog:
|
||||||
case Event::PaddleOneDecrease:
|
|
||||||
case Event::PaddleOneIncrease:
|
|
||||||
case Event::PaddleTwoResistance:
|
|
||||||
case Event::PaddleTwoDecrease:
|
|
||||||
case Event::PaddleTwoIncrease:
|
|
||||||
case Event::PaddleThreeResistance:
|
|
||||||
case Event::PaddleThreeDecrease:
|
|
||||||
case Event::PaddleThreeIncrease:
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -1926,7 +1861,6 @@ void EventHandler::startRecording()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string eventfile = /*myOSystem->baseDir() + BSPF_PATH_SEPARATOR +*/ "test.inp";
|
string eventfile = /*myOSystem->baseDir() + BSPF_PATH_SEPARATOR +*/ "test.inp";
|
||||||
myEventStream.close();
|
|
||||||
if(!myEventStream.open(eventfile))
|
if(!myEventStream.open(eventfile))
|
||||||
{
|
{
|
||||||
myOSystem->frameBuffer().showMessage("Error opening eventstream");
|
myOSystem->frameBuffer().showMessage("Error opening eventstream");
|
||||||
|
@ -2385,22 +2319,22 @@ ActionList EventHandler::ourActionList[kActionListSize] = {
|
||||||
{ Event::JoystickOneRight, "P2 Joystick Right", "" },
|
{ Event::JoystickOneRight, "P2 Joystick Right", "" },
|
||||||
{ Event::JoystickOneFire, "P2 Joystick Fire", "" },
|
{ Event::JoystickOneFire, "P2 Joystick Fire", "" },
|
||||||
|
|
||||||
// { Event::PaddleZeroAnalog, "Paddle 1 Analog", "" },
|
{ Event::PaddleZeroAnalog, "Paddle 1 Analog", "" },
|
||||||
{ Event::PaddleZeroDecrease, "Paddle 1 Decrease", "" },
|
{ Event::PaddleZeroDecrease, "Paddle 1 Decrease", "" },
|
||||||
{ Event::PaddleZeroIncrease, "Paddle 1 Increase", "" },
|
{ Event::PaddleZeroIncrease, "Paddle 1 Increase", "" },
|
||||||
{ Event::PaddleZeroFire, "Paddle 1 Fire", "" },
|
{ Event::PaddleZeroFire, "Paddle 1 Fire", "" },
|
||||||
|
|
||||||
// { Event::PaddleOneAnalog, "Paddle 2 Analog", "" },
|
{ Event::PaddleOneAnalog, "Paddle 2 Analog", "" },
|
||||||
{ Event::PaddleOneDecrease, "Paddle 2 Decrease", "" },
|
{ Event::PaddleOneDecrease, "Paddle 2 Decrease", "" },
|
||||||
{ Event::PaddleOneIncrease, "Paddle 2 Increase", "" },
|
{ Event::PaddleOneIncrease, "Paddle 2 Increase", "" },
|
||||||
{ Event::PaddleOneFire, "Paddle 2 Fire", "" },
|
{ Event::PaddleOneFire, "Paddle 2 Fire", "" },
|
||||||
|
|
||||||
// { Event::PaddleTwoAnalog, "Paddle 3 Analog", "" },
|
{ Event::PaddleTwoAnalog, "Paddle 3 Analog", "" },
|
||||||
{ Event::PaddleTwoDecrease, "Paddle 3 Decrease", "" },
|
{ Event::PaddleTwoDecrease, "Paddle 3 Decrease", "" },
|
||||||
{ Event::PaddleTwoIncrease, "Paddle 3 Increase", "" },
|
{ Event::PaddleTwoIncrease, "Paddle 3 Increase", "" },
|
||||||
{ Event::PaddleTwoFire, "Paddle 3 Fire", "" },
|
{ Event::PaddleTwoFire, "Paddle 3 Fire", "" },
|
||||||
|
|
||||||
// { Event::PaddleThreeAnalog, "Paddle 4 Analog", "" },
|
{ Event::PaddleThreeAnalog, "Paddle 4 Analog", "" },
|
||||||
{ Event::PaddleThreeDecrease, "Paddle 4 Decrease", "" },
|
{ Event::PaddleThreeDecrease, "Paddle 4 Decrease", "" },
|
||||||
{ Event::PaddleThreeIncrease, "Paddle 4 Increase", "" },
|
{ Event::PaddleThreeIncrease, "Paddle 4 Increase", "" },
|
||||||
{ Event::PaddleThreeFire, "Paddle 4 Fire", "" },
|
{ Event::PaddleThreeFire, "Paddle 4 Fire", "" },
|
||||||
|
|
|
@ -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: EventHandler.hxx,v 1.66 2005-12-16 14:41:14 stephena Exp $
|
// $Id: EventHandler.hxx,v 1.67 2005-12-17 22:48:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef EVENTHANDLER_HXX
|
#ifndef EVENTHANDLER_HXX
|
||||||
|
@ -50,7 +50,7 @@ struct ActionList {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kActionListSize = 75
|
kActionListSize = 79
|
||||||
};
|
};
|
||||||
|
|
||||||
// Joystick related items
|
// Joystick related items
|
||||||
|
@ -92,7 +92,7 @@ struct Stella_Joystick {
|
||||||
mapping can take place.
|
mapping can take place.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: EventHandler.hxx,v 1.66 2005-12-16 14:41:14 stephena Exp $
|
@version $Id: EventHandler.hxx,v 1.67 2005-12-17 22:48:24 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class EventHandler
|
class EventHandler
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,14 +13,13 @@
|
||||||
// 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: Serializer.cxx,v 1.7 2005-12-17 01:23:07 stephena Exp $
|
// $Id: Serializer.cxx,v 1.8 2005-12-17 22:48:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include "Serializer.hxx"
|
#include "Serializer.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Serializer::Serializer(void)
|
Serializer::Serializer(void)
|
||||||
: myStream(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ Serializer::~Serializer(void)
|
||||||
bool Serializer::open(const string& fileName)
|
bool Serializer::open(const string& fileName)
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
myStream = new ofstream(fileName.c_str(), ios::out | ios::binary);
|
myStream.open(fileName.c_str(), ios::out | ios::binary);
|
||||||
|
|
||||||
return isOpen();
|
return isOpen();
|
||||||
}
|
}
|
||||||
|
@ -42,20 +41,13 @@ bool Serializer::open(const string& fileName)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Serializer::close(void)
|
void Serializer::close(void)
|
||||||
{
|
{
|
||||||
if(myStream)
|
myStream.close();
|
||||||
{
|
|
||||||
if(myStream->is_open())
|
|
||||||
myStream->close();
|
|
||||||
|
|
||||||
delete myStream;
|
|
||||||
myStream = (ofstream*) 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool Serializer::isOpen(void)
|
bool Serializer::isOpen(void)
|
||||||
{
|
{
|
||||||
return myStream && myStream->is_open();
|
return myStream.is_open();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -65,8 +57,8 @@ void Serializer::putInt(int value)
|
||||||
for(int i = 0; i < 4; ++i)
|
for(int i = 0; i < 4; ++i)
|
||||||
buf[i] = (value >> (i<<3)) & 0xff;
|
buf[i] = (value >> (i<<3)) & 0xff;
|
||||||
|
|
||||||
myStream->write((char*)buf, 4);
|
myStream.write((char*)buf, 4);
|
||||||
if(myStream->bad())
|
if(myStream.bad())
|
||||||
throw "Serializer: file write failed";
|
throw "Serializer: file write failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,18 +67,14 @@ void Serializer::putString(const string& str)
|
||||||
{
|
{
|
||||||
int len = str.length();
|
int len = str.length();
|
||||||
putInt(len);
|
putInt(len);
|
||||||
myStream->write(str.data(), (streamsize)len);
|
myStream.write(str.data(), (streamsize)len);
|
||||||
|
|
||||||
if(myStream->bad())
|
if(myStream.bad())
|
||||||
throw "Serializer: file write failed";
|
throw "Serializer: file write failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Serializer::putBool(bool b)
|
void Serializer::putBool(bool b)
|
||||||
{
|
{
|
||||||
int l = b ? TruePattern: FalsePattern;
|
putInt(b ? TruePattern: FalsePattern);
|
||||||
putInt(l);
|
|
||||||
|
|
||||||
if(myStream->bad ())
|
|
||||||
throw "Serializer: file write failed";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: Serializer.hxx,v 1.9 2005-12-17 01:23:07 stephena Exp $
|
// $Id: Serializer.hxx,v 1.10 2005-12-17 22:48:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef SERIALIZER_HXX
|
#ifndef SERIALIZER_HXX
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
Boolean values are written using a special pattern.
|
Boolean values are written using a special pattern.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: Serializer.hxx,v 1.9 2005-12-17 01:23:07 stephena Exp $
|
@version $Id: Serializer.hxx,v 1.10 2005-12-17 22:48:24 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Serializer
|
class Serializer
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@ class Serializer
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The stream to send the serialized data to.
|
// The stream to send the serialized data to.
|
||||||
ofstream* myStream;
|
fstream myStream;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
TruePattern = 0xfab1fab2,
|
TruePattern = 0xfab1fab2,
|
||||||
|
|
Loading…
Reference in New Issue