mirror of https://github.com/stella-emu/stella.git
Fixed a bug that was preventing driving controllers on the Stelladaptor to coexist peacefully with other PC inputs. Also corrected the driving controller movement drection for the Stelladaptor.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1416 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
3fde38a1b0
commit
9e23fa3c72
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Driving.cxx,v 1.15 2008-03-02 19:20:50 stephena Exp $
|
||||
// $Id: Driving.cxx,v 1.16 2008-03-03 16:27:16 estolberg Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "Event.hxx"
|
||||
|
@ -58,8 +58,10 @@ Driving::~Driving()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Driving::update()
|
||||
{
|
||||
int grayIndex = 0;
|
||||
|
||||
// Make sure direct gray codes from Stelladaptor stay in sync with
|
||||
// simulated gray codes generated by PC keyboard or PC joystick
|
||||
myCounter = (myGrayIndex << 2) | (myCounter & 3);
|
||||
|
||||
// Digital events (from keyboard or joystick hats & buttons)
|
||||
myDigitalPinState[Six] = (myEvent.get(myFireEvent) == 0);
|
||||
|
||||
|
@ -69,24 +71,31 @@ void Driving::update()
|
|||
|
||||
// Only consider the lower-most bits (corresponding to pins 1 & 2)
|
||||
myCounter &= 0x0f;
|
||||
grayIndex = myCounter >> 2;
|
||||
myGrayIndex = myCounter >> 2;
|
||||
|
||||
// Stelladaptor is the only controller that should set this
|
||||
int yaxis = myEvent.get(myYAxisValue);
|
||||
if(yaxis <= -16384-4096)
|
||||
grayIndex = 2;
|
||||
else if(yaxis > 16384+4096)
|
||||
grayIndex = 1;
|
||||
else if(yaxis >= 16384-4096)
|
||||
grayIndex = 0;
|
||||
else if(yaxis < -16384+4096)
|
||||
grayIndex = 3;
|
||||
|
||||
|
||||
// Only overwrite gray code when Stelladaptor input has changed
|
||||
// (that means real changes, not just analog signal jitter)
|
||||
if((yaxis < (myLastYaxis - 1024)) || (yaxis > (myLastYaxis + 1024)))
|
||||
{
|
||||
myLastYaxis = yaxis;
|
||||
if(yaxis <= -16384-4096)
|
||||
myGrayIndex = 3; // up
|
||||
else if(yaxis > 16384+4096)
|
||||
myGrayIndex = 1; // down
|
||||
else if(yaxis >= 16384-4096)
|
||||
myGrayIndex = 2; // up + down
|
||||
else if(yaxis < 16384-4096)
|
||||
myGrayIndex = 0; // no movement
|
||||
}
|
||||
|
||||
// Gray codes for rotation
|
||||
static const uInt8 graytable[] = { 0x03, 0x01, 0x00, 0x02 };
|
||||
|
||||
// Determine which bits are set
|
||||
uInt8 gray = graytable[grayIndex];
|
||||
uInt8 gray = graytable[myGrayIndex];
|
||||
myDigitalPinState[One] = (gray & 0x1) != 0;
|
||||
myDigitalPinState[Two] = (gray & 0x2) != 0;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Driving.hxx,v 1.9 2008-03-02 19:20:50 stephena Exp $
|
||||
// $Id: Driving.hxx,v 1.10 2008-03-03 16:27:16 estolberg Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef DRIVING_HXX
|
||||
|
@ -27,7 +27,7 @@
|
|||
The standard Atari 2600 Indy 500 driving controller.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: Driving.hxx,v 1.9 2008-03-02 19:20:50 stephena Exp $
|
||||
@version $Id: Driving.hxx,v 1.10 2008-03-03 16:27:16 estolberg Exp $
|
||||
*/
|
||||
class Driving : public Controller
|
||||
{
|
||||
|
@ -57,6 +57,13 @@ class Driving : public Controller
|
|||
// Counter to iterate through the gray codes
|
||||
uInt32 myCounter;
|
||||
|
||||
// Index into the gray code table
|
||||
uInt32 myGrayIndex;
|
||||
|
||||
// Y axis value from last yaxis event that was used to generate a new
|
||||
// gray code
|
||||
int myLastYaxis;
|
||||
|
||||
// Pre-compute the events we care about based on given port
|
||||
// This will eliminate test for left or right port in update()
|
||||
Event::Type myCWEvent, myCCWEvent, myFireEvent, myXAxisValue, myYAxisValue;
|
||||
|
|
Loading…
Reference in New Issue