2001-12-27 19:54:36 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
2001-12-27 19:54:36 +00:00
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2017-12-29 20:40:37 +00:00
|
|
|
// Copyright (c) 1995-2018 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2001-12-27 19:54:36 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2001-12-27 19:54:36 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include "Event.hxx"
|
|
|
|
#include "Booster.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2008-04-13 23:43:14 +00:00
|
|
|
BoosterGrip::BoosterGrip(Jack jack, const Event& event, const System& system)
|
2011-12-26 21:40:28 +00:00
|
|
|
: Controller(jack, event, system, Controller::BoosterGrip),
|
|
|
|
myControlID(-1)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
if(myJack == Left)
|
|
|
|
{
|
|
|
|
myUpEvent = Event::JoystickZeroUp;
|
|
|
|
myDownEvent = Event::JoystickZeroDown;
|
|
|
|
myLeftEvent = Event::JoystickZeroLeft;
|
|
|
|
myRightEvent = Event::JoystickZeroRight;
|
2012-03-04 19:20:29 +00:00
|
|
|
myFireEvent = Event::JoystickZeroFire;
|
|
|
|
myTriggerEvent = Event::JoystickZeroFire5;
|
|
|
|
myBoosterEvent = Event::JoystickZeroFire9;
|
Large number of changes related to controller input and handling.
Moved a lot of the code into the respective Controller classes, in the
process cleaning up the EventHandler (which was starting to get a little
unwieldy).
I've borrowed some code and ideas from z26, but also improved on it as
well:
1) Stelladaptor devices now send their events directly to a
controller class, allowing for any Stelladaptor device to emulate
a controller (to the limits of the input device, of course).
2) Hopefully fixed Stelladaptor driving controller support. Eckhard,
could you test this, since I don't have any of those myself?
3) Improved interaction with different input devices. For example,
a Stelladaptor, mouse, joystick (digital and/or analog axis), and
the keyboard can now simulate paddle events at the same time. So it
shouldn't matter what input devices you have plugged in; things should
'just work'. In the case of Stelladaptor paddles, you may have to
'zero' them by turning completely left, however.
4) Related to (3), changed mouse events to use relative motion. This
should fix the issues with paddle emulation/movement behaving
differently based on the window size.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1412 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-03-02 19:20:50 +00:00
|
|
|
myXAxisValue = Event::SALeftAxis0Value;
|
|
|
|
myYAxisValue = Event::SALeftAxis1Value;
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myUpEvent = Event::JoystickOneUp;
|
|
|
|
myDownEvent = Event::JoystickOneDown;
|
|
|
|
myLeftEvent = Event::JoystickOneLeft;
|
|
|
|
myRightEvent = Event::JoystickOneRight;
|
2012-03-04 19:20:29 +00:00
|
|
|
myFireEvent = Event::JoystickOneFire;
|
|
|
|
myTriggerEvent = Event::JoystickOneFire5;
|
|
|
|
myBoosterEvent = Event::JoystickOneFire9;
|
Large number of changes related to controller input and handling.
Moved a lot of the code into the respective Controller classes, in the
process cleaning up the EventHandler (which was starting to get a little
unwieldy).
I've borrowed some code and ideas from z26, but also improved on it as
well:
1) Stelladaptor devices now send their events directly to a
controller class, allowing for any Stelladaptor device to emulate
a controller (to the limits of the input device, of course).
2) Hopefully fixed Stelladaptor driving controller support. Eckhard,
could you test this, since I don't have any of those myself?
3) Improved interaction with different input devices. For example,
a Stelladaptor, mouse, joystick (digital and/or analog axis), and
the keyboard can now simulate paddle events at the same time. So it
shouldn't matter what input devices you have plugged in; things should
'just work'. In the case of Stelladaptor paddles, you may have to
'zero' them by turning completely left, however.
4) Related to (3), changed mouse events to use relative motion. This
should fix the issues with paddle emulation/movement behaving
differently based on the window size.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1412 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-03-02 19:20:50 +00:00
|
|
|
myXAxisValue = Event::SARightAxis0Value;
|
|
|
|
myYAxisValue = Event::SARightAxis1Value;
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
}
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
void BoosterGrip::update()
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
Large number of changes related to controller input and handling.
Moved a lot of the code into the respective Controller classes, in the
process cleaning up the EventHandler (which was starting to get a little
unwieldy).
I've borrowed some code and ideas from z26, but also improved on it as
well:
1) Stelladaptor devices now send their events directly to a
controller class, allowing for any Stelladaptor device to emulate
a controller (to the limits of the input device, of course).
2) Hopefully fixed Stelladaptor driving controller support. Eckhard,
could you test this, since I don't have any of those myself?
3) Improved interaction with different input devices. For example,
a Stelladaptor, mouse, joystick (digital and/or analog axis), and
the keyboard can now simulate paddle events at the same time. So it
shouldn't matter what input devices you have plugged in; things should
'just work'. In the case of Stelladaptor paddles, you may have to
'zero' them by turning completely left, however.
4) Related to (3), changed mouse events to use relative motion. This
should fix the issues with paddle emulation/movement behaving
differently based on the window size.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1412 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-03-02 19:20:50 +00:00
|
|
|
// Digital events (from keyboard or joystick hats & buttons)
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
myDigitalPinState[One] = (myEvent.get(myUpEvent) == 0);
|
|
|
|
myDigitalPinState[Two] = (myEvent.get(myDownEvent) == 0);
|
|
|
|
myDigitalPinState[Three] = (myEvent.get(myLeftEvent) == 0);
|
|
|
|
myDigitalPinState[Four] = (myEvent.get(myRightEvent) == 0);
|
|
|
|
myDigitalPinState[Six] = (myEvent.get(myFireEvent) == 0);
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
// The CBS Booster-grip has two more buttons on it. These buttons are
|
|
|
|
// connected to the inputs usually used by paddles.
|
2017-07-21 22:35:55 +00:00
|
|
|
updateAnalogPin(
|
|
|
|
Five,
|
|
|
|
(myEvent.get(myTriggerEvent) != 0) ? minimumResistance : maximumResistance
|
|
|
|
);
|
|
|
|
updateAnalogPin(
|
|
|
|
Nine,
|
|
|
|
(myEvent.get(myBoosterEvent) != 0) ? minimumResistance : maximumResistance
|
|
|
|
);
|
Large number of changes related to controller input and handling.
Moved a lot of the code into the respective Controller classes, in the
process cleaning up the EventHandler (which was starting to get a little
unwieldy).
I've borrowed some code and ideas from z26, but also improved on it as
well:
1) Stelladaptor devices now send their events directly to a
controller class, allowing for any Stelladaptor device to emulate
a controller (to the limits of the input device, of course).
2) Hopefully fixed Stelladaptor driving controller support. Eckhard,
could you test this, since I don't have any of those myself?
3) Improved interaction with different input devices. For example,
a Stelladaptor, mouse, joystick (digital and/or analog axis), and
the keyboard can now simulate paddle events at the same time. So it
shouldn't matter what input devices you have plugged in; things should
'just work'. In the case of Stelladaptor paddles, you may have to
'zero' them by turning completely left, however.
4) Related to (3), changed mouse events to use relative motion. This
should fix the issues with paddle emulation/movement behaving
differently based on the window size.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1412 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-03-02 19:20:50 +00:00
|
|
|
|
|
|
|
// Axis events (usually generated by the Stelladaptor)
|
|
|
|
int xaxis = myEvent.get(myXAxisValue);
|
|
|
|
int yaxis = myEvent.get(myYAxisValue);
|
|
|
|
if(xaxis > 16384-4096)
|
|
|
|
{
|
|
|
|
myDigitalPinState[Four] = false;
|
|
|
|
// Stelladaptor sends "half moved right" for L+R pushed together
|
|
|
|
if(xaxis < 16384+4096)
|
|
|
|
myDigitalPinState[Three] = false;
|
|
|
|
}
|
2011-05-06 14:29:39 +00:00
|
|
|
else if(xaxis < -16384)
|
Large number of changes related to controller input and handling.
Moved a lot of the code into the respective Controller classes, in the
process cleaning up the EventHandler (which was starting to get a little
unwieldy).
I've borrowed some code and ideas from z26, but also improved on it as
well:
1) Stelladaptor devices now send their events directly to a
controller class, allowing for any Stelladaptor device to emulate
a controller (to the limits of the input device, of course).
2) Hopefully fixed Stelladaptor driving controller support. Eckhard,
could you test this, since I don't have any of those myself?
3) Improved interaction with different input devices. For example,
a Stelladaptor, mouse, joystick (digital and/or analog axis), and
the keyboard can now simulate paddle events at the same time. So it
shouldn't matter what input devices you have plugged in; things should
'just work'. In the case of Stelladaptor paddles, you may have to
'zero' them by turning completely left, however.
4) Related to (3), changed mouse events to use relative motion. This
should fix the issues with paddle emulation/movement behaving
differently based on the window size.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1412 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-03-02 19:20:50 +00:00
|
|
|
myDigitalPinState[Three] = false;
|
|
|
|
if(yaxis > 16384-4096)
|
|
|
|
{
|
|
|
|
myDigitalPinState[Two] = false;
|
|
|
|
// Stelladaptor sends "half moved down" for U+D pushed together
|
|
|
|
if(yaxis < 16384+4096)
|
|
|
|
myDigitalPinState[One] = false;
|
|
|
|
}
|
2011-05-06 14:29:39 +00:00
|
|
|
else if(yaxis < -16384)
|
Large number of changes related to controller input and handling.
Moved a lot of the code into the respective Controller classes, in the
process cleaning up the EventHandler (which was starting to get a little
unwieldy).
I've borrowed some code and ideas from z26, but also improved on it as
well:
1) Stelladaptor devices now send their events directly to a
controller class, allowing for any Stelladaptor device to emulate
a controller (to the limits of the input device, of course).
2) Hopefully fixed Stelladaptor driving controller support. Eckhard,
could you test this, since I don't have any of those myself?
3) Improved interaction with different input devices. For example,
a Stelladaptor, mouse, joystick (digital and/or analog axis), and
the keyboard can now simulate paddle events at the same time. So it
shouldn't matter what input devices you have plugged in; things should
'just work'. In the case of Stelladaptor paddles, you may have to
'zero' them by turning completely left, however.
4) Related to (3), changed mouse events to use relative motion. This
should fix the issues with paddle emulation/movement behaving
differently based on the window size.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1412 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-03-02 19:20:50 +00:00
|
|
|
myDigitalPinState[One] = false;
|
2011-05-06 14:29:39 +00:00
|
|
|
|
|
|
|
// Mouse motion and button events
|
2011-12-26 21:40:28 +00:00
|
|
|
if(myControlID > -1)
|
2011-05-06 14:29:39 +00:00
|
|
|
{
|
|
|
|
// The following code was taken from z26
|
|
|
|
#define MJ_Threshold 2
|
|
|
|
int mousex = myEvent.get(Event::MouseAxisXValue),
|
|
|
|
mousey = myEvent.get(Event::MouseAxisYValue);
|
|
|
|
if(mousex || mousey)
|
|
|
|
{
|
|
|
|
if((!(abs(mousey) > abs(mousex) << 1)) && (abs(mousex) >= MJ_Threshold))
|
|
|
|
{
|
|
|
|
if(mousex < 0)
|
|
|
|
myDigitalPinState[Three] = false;
|
|
|
|
else if (mousex > 0)
|
|
|
|
myDigitalPinState[Four] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((!(abs(mousex) > abs(mousey) << 1)) && (abs(mousey) >= MJ_Threshold))
|
|
|
|
{
|
|
|
|
if(mousey < 0)
|
|
|
|
myDigitalPinState[One] = false;
|
|
|
|
else if(mousey > 0)
|
|
|
|
myDigitalPinState[Two] = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Get mouse button state
|
2012-03-04 19:20:29 +00:00
|
|
|
if(myEvent.get(Event::MouseButtonLeftValue))
|
2011-05-06 14:29:39 +00:00
|
|
|
myDigitalPinState[Six] = false;
|
2012-03-04 19:20:29 +00:00
|
|
|
if(myEvent.get(Event::MouseButtonRightValue))
|
2017-07-21 22:35:55 +00:00
|
|
|
updateAnalogPin(Nine, minimumResistance);
|
2011-05-06 14:29:39 +00:00
|
|
|
}
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
2011-12-26 21:40:28 +00:00
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2012-04-19 13:00:02 +00:00
|
|
|
bool BoosterGrip::setMouseControl(
|
|
|
|
Controller::Type xtype, int xid, Controller::Type ytype, int yid)
|
2011-12-26 21:40:28 +00:00
|
|
|
{
|
2012-04-19 13:00:02 +00:00
|
|
|
// Currently, the booster-grip takes full control of the mouse, using both
|
|
|
|
// axes for its two degrees of movement, and the left/right buttons for
|
|
|
|
// fire and booster, respectively
|
|
|
|
if(xtype == Controller::BoosterGrip && ytype == Controller::BoosterGrip &&
|
|
|
|
xid == yid)
|
2011-12-26 21:40:28 +00:00
|
|
|
{
|
2012-04-19 13:00:02 +00:00
|
|
|
myControlID = ((myJack == Left && xid == 0) ||
|
|
|
|
(myJack == Right && xid == 1)
|
|
|
|
) ? xid : -1;
|
2011-12-26 21:40:28 +00:00
|
|
|
}
|
2012-04-19 13:00:02 +00:00
|
|
|
else
|
2011-12-26 21:40:28 +00:00
|
|
|
myControlID = -1;
|
2012-04-19 13:00:02 +00:00
|
|
|
|
|
|
|
return true;
|
2011-12-26 21:40:28 +00:00
|
|
|
}
|