Added mouse-as-joystick code from z26. This basically allows the mouse to

act as a controller in joystick-only games.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2200 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2011-01-01 19:25:27 +00:00
parent 3339dc276d
commit 5d4de8291e
2 changed files with 32 additions and 1 deletions

View File

@ -14,6 +14,10 @@
3.3 to 3.4: (xx. xx, 2010)
* The mouse can now be used in joystick games (ie, moving the mouse
emulates joystick directions, and pressing a mouse button emulates
the joystick fire button).
* Updated built-in version of the PNG library to the latest version.
* Updated internal ROM properties database to ROM-Hunter version 6

View File

@ -8,7 +8,7 @@
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2010 by Bradford W. Mott, Stephen Anthony
// Copyright (c) 1995-2011 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
@ -85,6 +85,33 @@ void Joystick::update()
}
if(yaxis < -16384)
myDigitalPinState[One] = false;
// The following code was taken from z26
// Mouse events
#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
if(myEvent.get(Event::MouseButtonValue))
myDigitalPinState[Six] = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -