2001-12-27 19:54:36 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// 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
|
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// Copyright (c) 1995-2010 by Bradford W. Mott 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.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
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
|
|
|
#define TRIGMAX 240
|
|
|
|
#define TRIGMIN 1
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
#include "Event.hxx"
|
|
|
|
#include "Paddles.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2008-04-13 23:43:14 +00:00
|
|
|
Paddles::Paddles(Jack jack, const Event& event, const System& system, bool swap)
|
|
|
|
: Controller(jack, event, system, Controller::Paddles)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2006-12-09 00:25:20 +00:00
|
|
|
// Swap the paddle events, from paddle 0 <=> 1 and paddle 2 <=> 3
|
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
|
|
|
// Also consider whether this is the left or right port
|
|
|
|
if(myJack == Left)
|
2006-12-09 00:25:20 +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
|
|
|
if(!swap)
|
2007-10-09 23:56:57 +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
|
|
|
myP0AxisValue = Event::SALeftAxis0Value;
|
|
|
|
myP0DecEvent1 = Event::PaddleZeroDecrease;
|
|
|
|
myP0DecEvent2 = Event::JoystickZeroRight;
|
|
|
|
myP0IncEvent1 = Event::PaddleZeroIncrease;
|
|
|
|
myP0IncEvent2 = Event::JoystickZeroLeft;
|
2007-10-09 23:56:57 +00:00
|
|
|
myP0FireEvent1 = Event::PaddleZeroFire;
|
|
|
|
myP0FireEvent2 = Event::JoystickZeroFire1;
|
|
|
|
|
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
|
|
|
myP1AxisValue = Event::SALeftAxis1Value;
|
|
|
|
myP1DecEvent1 = Event::PaddleOneDecrease;
|
|
|
|
myP1DecEvent2 = Event::JoystickZeroUp;
|
|
|
|
myP1IncEvent1 = Event::PaddleOneIncrease;
|
|
|
|
myP1IncEvent2 = Event::JoystickZeroDown;
|
2007-10-09 23:56:57 +00:00
|
|
|
myP1FireEvent1 = Event::PaddleOneFire;
|
|
|
|
myP1FireEvent2 = Event::JoystickZeroFire3;
|
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
|
|
|
|
2008-03-22 17:35:03 +00:00
|
|
|
if(_MOUSEX_PADDLE < 0) _MOUSEX_PADDLE = 0;
|
2007-10-09 23:56:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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
|
|
|
myP0AxisValue = Event::SALeftAxis1Value;
|
|
|
|
myP0DecEvent1 = Event::PaddleOneDecrease;
|
|
|
|
myP0DecEvent2 = Event::JoystickZeroUp;
|
|
|
|
myP0IncEvent1 = Event::PaddleOneIncrease;
|
|
|
|
myP0IncEvent2 = Event::JoystickZeroDown;
|
2007-10-09 23:56:57 +00:00
|
|
|
myP0FireEvent1 = Event::PaddleOneFire;
|
|
|
|
myP0FireEvent2 = Event::JoystickZeroFire3;
|
|
|
|
|
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
|
|
|
myP1AxisValue = Event::SALeftAxis0Value;
|
|
|
|
myP1DecEvent1 = Event::PaddleZeroDecrease;
|
|
|
|
myP1DecEvent2 = Event::JoystickZeroRight;
|
|
|
|
myP1IncEvent1 = Event::PaddleZeroIncrease;
|
|
|
|
myP1IncEvent2 = Event::JoystickZeroLeft;
|
2007-10-09 23:56:57 +00:00
|
|
|
myP1FireEvent1 = Event::PaddleZeroFire;
|
|
|
|
myP1FireEvent2 = Event::JoystickZeroFire1;
|
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
|
|
|
|
2008-03-22 17:35:03 +00:00
|
|
|
if(_MOUSEX_PADDLE < 0) _MOUSEX_PADDLE = 1;
|
2007-10-09 23:56:57 +00:00
|
|
|
}
|
2006-12-09 00:25:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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
|
|
|
if(!swap)
|
2007-10-09 23:56:57 +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
|
|
|
myP0AxisValue = Event::SARightAxis0Value;
|
|
|
|
myP0DecEvent1 = Event::PaddleTwoDecrease;
|
|
|
|
myP0DecEvent2 = Event::JoystickOneRight;
|
|
|
|
myP0IncEvent1 = Event::PaddleTwoIncrease;
|
|
|
|
myP0IncEvent2 = Event::JoystickOneLeft;
|
2007-10-09 23:56:57 +00:00
|
|
|
myP0FireEvent1 = Event::PaddleTwoFire;
|
|
|
|
myP0FireEvent2 = Event::JoystickOneFire1;
|
|
|
|
|
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
|
|
|
myP1AxisValue = Event::SARightAxis1Value;
|
|
|
|
myP1DecEvent1 = Event::PaddleThreeDecrease;
|
|
|
|
myP1DecEvent2 = Event::JoystickOneUp;
|
|
|
|
myP1IncEvent1 = Event::PaddleThreeIncrease;
|
|
|
|
myP1IncEvent2 = Event::JoystickOneDown;
|
2007-10-09 23:56:57 +00:00
|
|
|
myP1FireEvent1 = Event::PaddleThreeFire;
|
|
|
|
myP1FireEvent2 = Event::JoystickOneFire3;
|
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
|
|
|
|
2008-03-22 17:35:03 +00:00
|
|
|
if(_MOUSEX_PADDLE < 0) _MOUSEX_PADDLE = 0;
|
2007-10-09 23:56:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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
|
|
|
myP0AxisValue = Event::SARightAxis1Value;
|
|
|
|
myP0DecEvent1 = Event::PaddleThreeDecrease;
|
|
|
|
myP0DecEvent2 = Event::JoystickOneUp;
|
|
|
|
myP0IncEvent1 = Event::PaddleThreeIncrease;
|
|
|
|
myP0IncEvent2 = Event::JoystickOneDown;
|
2007-10-09 23:56:57 +00:00
|
|
|
myP0FireEvent1 = Event::PaddleThreeFire;
|
|
|
|
myP0FireEvent2 = Event::JoystickOneFire3;
|
|
|
|
|
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
|
|
|
myP1AxisValue = Event::SARightAxis0Value;
|
|
|
|
myP1DecEvent1 = Event::PaddleTwoDecrease;
|
|
|
|
myP1DecEvent2 = Event::JoystickOneRight;
|
|
|
|
myP1IncEvent1 = Event::PaddleTwoIncrease;
|
|
|
|
myP1IncEvent2 = Event::JoystickOneLeft;
|
2007-10-09 23:56:57 +00:00
|
|
|
myP1FireEvent1 = Event::PaddleTwoFire;
|
|
|
|
myP1FireEvent2 = Event::JoystickOneFire1;
|
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
|
|
|
|
2008-03-22 17:35:03 +00:00
|
|
|
if(_MOUSEX_PADDLE < 0) _MOUSEX_PADDLE = 1;
|
2007-10-09 23:56:57 +00:00
|
|
|
}
|
2006-12-09 00:25:20 +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
|
|
|
// Digital pins 1, 2 and 6 are not connected
|
|
|
|
myDigitalPinState[One] =
|
|
|
|
myDigitalPinState[Two] =
|
|
|
|
myDigitalPinState[Six] = true;
|
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 emulation of analog paddle movement
|
|
|
|
myKeyRepeat0 = myPaddleRepeat0 = myKeyRepeat1 = myPaddleRepeat1 = 0;
|
|
|
|
|
|
|
|
myCharge[0] = myCharge[1] =
|
2008-03-22 17:35:03 +00:00
|
|
|
myLastCharge[0] = myLastCharge[1] = TRIGMAX/2; // half of maximum paddle charge
|
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
|
|
|
myLeftMotion[0] = myLeftMotion[1] = 0;
|
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
|
|
|
Paddles::~Paddles()
|
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 Paddles::update()
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2008-03-22 17:35:03 +00:00
|
|
|
myDigitalPinState[Three] = myDigitalPinState[Four] = true;
|
|
|
|
|
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)
|
2007-10-09 23:56:57 +00:00
|
|
|
myDigitalPinState[Three] =
|
|
|
|
(myEvent.get(myP1FireEvent1) == 0 && myEvent.get(myP1FireEvent2) == 0);
|
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[Four] =
|
|
|
|
(myEvent.get(myP0FireEvent1) == 0 && myEvent.get(myP0FireEvent2) == 0);
|
|
|
|
|
|
|
|
if(myKeyRepeat0)
|
|
|
|
{
|
|
|
|
myPaddleRepeat0++;
|
2008-03-02 20:48:51 +00:00
|
|
|
if(myPaddleRepeat0 > _PADDLE_SPEED) myPaddleRepeat0 = 2;
|
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
|
|
|
}
|
|
|
|
if(myKeyRepeat1)
|
|
|
|
{
|
|
|
|
myPaddleRepeat1++;
|
2008-03-02 20:48:51 +00:00
|
|
|
if(myPaddleRepeat1 > _PADDLE_SPEED) myPaddleRepeat1 = 2;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
myKeyRepeat0 = 0;
|
|
|
|
myKeyRepeat1 = 0;
|
|
|
|
|
|
|
|
if(myEvent.get(myP0DecEvent1) || myEvent.get(myP0DecEvent2))
|
|
|
|
{
|
|
|
|
myKeyRepeat0 = 1;
|
2008-03-02 20:48:51 +00:00
|
|
|
if(myCharge[0] > myPaddleRepeat0)
|
|
|
|
myCharge[0] -= myPaddleRepeat0;
|
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
|
|
|
}
|
|
|
|
if(myEvent.get(myP0IncEvent1) || myEvent.get(myP0IncEvent2))
|
|
|
|
{
|
|
|
|
myKeyRepeat0 = 1;
|
2008-03-02 20:48:51 +00:00
|
|
|
if((myCharge[0] + myPaddleRepeat0) < TRIGMAX)
|
|
|
|
myCharge[0] += myPaddleRepeat0;
|
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
|
|
|
}
|
|
|
|
if(myEvent.get(myP1DecEvent1) || myEvent.get(myP1DecEvent2))
|
|
|
|
{
|
|
|
|
myKeyRepeat1 = 1;
|
2008-03-02 20:48:51 +00:00
|
|
|
if(myCharge[1] > myPaddleRepeat1)
|
|
|
|
myCharge[1] -= myPaddleRepeat1;
|
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
|
|
|
}
|
|
|
|
if(myEvent.get(myP1IncEvent1) || myEvent.get(myP1IncEvent2))
|
|
|
|
{
|
|
|
|
myKeyRepeat1 = 1;
|
2008-03-02 20:48:51 +00:00
|
|
|
if((myCharge[1] + myPaddleRepeat1) < TRIGMAX)
|
|
|
|
myCharge[1] += myPaddleRepeat1;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Mouse events
|
2008-03-22 17:35:03 +00:00
|
|
|
if(myJack == Left && (_MOUSEX_PADDLE == 0 || _MOUSEX_PADDLE == 1))
|
|
|
|
{
|
|
|
|
// TODO - add infrastructure to map mouse direction to increase or decrease charge
|
|
|
|
myCharge[_MOUSEX_PADDLE] -= myEvent.get(Event::MouseAxisXValue);
|
|
|
|
if(myCharge[_MOUSEX_PADDLE] < TRIGMIN) myCharge[_MOUSEX_PADDLE] = TRIGMIN;
|
|
|
|
if(myCharge[_MOUSEX_PADDLE] > TRIGMAX) myCharge[_MOUSEX_PADDLE] = TRIGMAX;
|
|
|
|
if(myEvent.get(Event::MouseButtonValue))
|
|
|
|
myDigitalPinState[ourButtonPin[_MOUSEX_PADDLE]] = false;
|
|
|
|
}
|
|
|
|
else if(myJack == Right && (_MOUSEX_PADDLE == 2 || _MOUSEX_PADDLE == 3))
|
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
|
|
|
{
|
2008-03-22 17:35:03 +00:00
|
|
|
// TODO - add infrastructure to map mouse direction to increase or decrease charge
|
|
|
|
myCharge[_MOUSEX_PADDLE-2] -= myEvent.get(Event::MouseAxisXValue);
|
|
|
|
if(myCharge[_MOUSEX_PADDLE-2] < TRIGMIN) myCharge[_MOUSEX_PADDLE-2] = TRIGMIN;
|
|
|
|
if(myCharge[_MOUSEX_PADDLE-2] > TRIGMAX) myCharge[_MOUSEX_PADDLE-2] = TRIGMAX;
|
|
|
|
if(myEvent.get(Event::MouseButtonValue))
|
|
|
|
myDigitalPinState[ourButtonPin[_MOUSEX_PADDLE-2]] = false;
|
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 (possibly use analog values)
|
|
|
|
int xaxis = myEvent.get(myP0AxisValue);
|
|
|
|
int yaxis = myEvent.get(myP1AxisValue);
|
|
|
|
|
|
|
|
// Filter out jitter by not allowing rapid direction changes
|
|
|
|
int charge0 = ((32767 - xaxis) >> 8) & 0xff;
|
|
|
|
if(charge0 - myLastCharge[0] > 0) // we are moving left
|
|
|
|
{
|
|
|
|
if(!myLeftMotion[0]) // moving right before?
|
|
|
|
{
|
|
|
|
if(charge0 - myLastCharge[0] <= 4)
|
|
|
|
{
|
|
|
|
myCharge[0] = myLastCharge[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myCharge[0] = (charge0 + myLastCharge[0]) >> 1;
|
|
|
|
myLastCharge[0] = charge0;
|
|
|
|
myLeftMotion[0] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myCharge[0] = (charge0 + myLastCharge[0]) >> 1;
|
|
|
|
myLastCharge[0] = charge0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Filter out jitter by not allowing rapid direction changes
|
|
|
|
else if(charge0 - myLastCharge[0] < 0) // we are moving right
|
|
|
|
{
|
|
|
|
if(myLeftMotion[0]) // moving left before?
|
|
|
|
{
|
|
|
|
if(myLastCharge[0] - charge0 <= 4)
|
|
|
|
{
|
|
|
|
myCharge[0] = myLastCharge[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myCharge[0] = (charge0 + myLastCharge[0]) >> 1;
|
|
|
|
myLastCharge[0] = charge0;
|
|
|
|
myLeftMotion[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myCharge[0] = (charge0 + myLastCharge[0]) >> 1;
|
|
|
|
myLastCharge[0] = charge0;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
// Filter out jitter by not allowing rapid direction changes
|
|
|
|
int charge1 = ((32767 - yaxis) >> 8) & 0xff;
|
|
|
|
if(charge1 - myLastCharge[1] > 0) // we are moving left
|
|
|
|
{
|
|
|
|
if(!myLeftMotion[1]) // moving right before?
|
|
|
|
{
|
|
|
|
if(charge1 - myLastCharge[1] <= 4)
|
|
|
|
{
|
|
|
|
myCharge[1] = myLastCharge[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myCharge[1] = (charge1 + myLastCharge[1]) >> 1;
|
|
|
|
myLastCharge[1] = charge1;
|
|
|
|
myLeftMotion[1] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myCharge[1] = (charge1 + myLastCharge[1]) >> 1;
|
|
|
|
myLastCharge[1] = charge1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Filter out jitter by not allowing rapid direction changes
|
|
|
|
else if(charge1 - myLastCharge[1] < 0) // we are moving right
|
|
|
|
{
|
|
|
|
if(myLeftMotion[1]) // moving left before?
|
|
|
|
{
|
|
|
|
if(myLastCharge[1] - charge1 <= 4)
|
|
|
|
{
|
|
|
|
myCharge[1] = myLastCharge[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myCharge[1] = (charge1 + myLastCharge[1]) >> 1;
|
|
|
|
myLastCharge[1] = charge1;
|
|
|
|
myLeftMotion[1] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myCharge[1] = (charge1 + myLastCharge[1]) >> 1;
|
|
|
|
myLastCharge[1] = charge1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-31 17:45:05 +00:00
|
|
|
myAnalogPinValue[Five] = (Int32)(1400000 * (myCharge[1] / 255.0));
|
|
|
|
myAnalogPinValue[Nine] = (Int32)(1400000 * (myCharge[0] / 255.0));
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
2008-03-02 20:48:51 +00:00
|
|
|
|
2008-03-22 17:35:03 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void Paddles::setMouseIsPaddle(int number, int dir)
|
|
|
|
{
|
|
|
|
// TODO - make mouse Y axis be actually used in the code above
|
|
|
|
if(dir == 0)
|
|
|
|
_MOUSEX_PADDLE = number;
|
|
|
|
else
|
|
|
|
_MOUSEY_PADDLE = number;
|
|
|
|
}
|
|
|
|
|
2008-03-02 20:48:51 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
int Paddles::_PADDLE_SPEED = 6;
|
2008-03-22 17:35:03 +00:00
|
|
|
int Paddles::_MOUSEX_PADDLE = -1;
|
|
|
|
int Paddles::_MOUSEY_PADDLE = -1;
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
const Controller::DigitalPin Paddles::ourButtonPin[2] = { Four, Three };
|