mirror of https://github.com/stella-emu/stella.git
The driving controllers can now be used in mouse 'specific-axis' mode.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2372 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
1ef29f585e
commit
b7e489a071
|
@ -26,7 +26,9 @@
|
|||
Driving::Driving(Jack jack, const Event& event, const System& system)
|
||||
: Controller(jack, event, system, Controller::Driving),
|
||||
myCounter(0),
|
||||
myControlID(-1)
|
||||
myControlID(-1),
|
||||
myControlIDX(-1),
|
||||
myControlIDY(-1)
|
||||
{
|
||||
if(myJack == Left)
|
||||
{
|
||||
|
@ -78,9 +80,31 @@ void Driving::update()
|
|||
int m_axis = myEvent.get(Event::MouseAxisXValue);
|
||||
if(m_axis < -2) myCounter--;
|
||||
else if(m_axis > 2) myCounter++;
|
||||
if(myEvent.get(Event::MouseButtonLeftValue))
|
||||
if(myEvent.get(Event::MouseButtonLeftValue) ||
|
||||
myEvent.get(Event::MouseButtonRightValue))
|
||||
myDigitalPinState[Six] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Test for 'untied' mouse axis mode, where each axis is potentially
|
||||
// mapped to a separate driving controller
|
||||
if(myControlIDX > -1)
|
||||
{
|
||||
int m_axis = myEvent.get(Event::MouseAxisXValue);
|
||||
if(m_axis < -2) myCounter--;
|
||||
else if(m_axis > 2) myCounter++;
|
||||
if(myEvent.get(Event::MouseButtonLeftValue))
|
||||
myDigitalPinState[Six] = false;
|
||||
}
|
||||
if(myControlIDY > -1)
|
||||
{
|
||||
int m_axis = myEvent.get(Event::MouseAxisYValue);
|
||||
if(m_axis < -2) myCounter--;
|
||||
else if(m_axis > 2) myCounter++;
|
||||
if(myEvent.get(Event::MouseButtonRightValue))
|
||||
myDigitalPinState[Six] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Only consider the lower-most bits (corresponding to pins 1 & 2)
|
||||
myCounter &= 0x0f;
|
||||
|
@ -120,10 +144,25 @@ void Driving::setMouseControl(
|
|||
// In 'automatic' mode, only the X-axis is used
|
||||
if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic)
|
||||
{
|
||||
myControlID = ((myJack == Left && (ctrlID == 0 || ctrlID == 1)) ||
|
||||
(myJack == Right && (ctrlID == 2 || ctrlID == 3))
|
||||
) ? ctrlID & 0x01 : -1;
|
||||
myControlID = ((myJack == Left && ctrlID == 0) ||
|
||||
(myJack == Right && ctrlID == 1)
|
||||
) ? ctrlID : -1;
|
||||
myControlIDX = myControlIDY = -1;
|
||||
}
|
||||
else // Otherwise, joysticks are not used in 'non-auto' mode
|
||||
else
|
||||
{
|
||||
// The following is somewhat complex, but we need to pre-process as much
|
||||
// as possible, so that ::update() can run quickly
|
||||
myControlID = -1;
|
||||
if(myJack == Left)
|
||||
{
|
||||
myControlIDX = xaxis == MouseControl::Driving0 ? 0 : -1;
|
||||
myControlIDY = yaxis == MouseControl::Driving0 ? 0 : -1;
|
||||
}
|
||||
else // myJack == Right
|
||||
{
|
||||
myControlIDX = xaxis == MouseControl::Driving1 ? 1 : -1;
|
||||
myControlIDY = yaxis == MouseControl::Driving1 ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,10 @@ class Driving : public Controller
|
|||
myXAxisValue, myYAxisValue, myAxisMouseMotion;
|
||||
|
||||
// Controller to emulate in mouse axis 'automatic' mode
|
||||
int myControlID;
|
||||
int myControlID;
|
||||
|
||||
// Controller to emulate in mouse axis 'specific' mode
|
||||
int myControlIDX, myControlIDY;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -384,7 +384,8 @@ void Paddles::update()
|
|||
void Paddles::setMouseControl(
|
||||
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID)
|
||||
{
|
||||
// In 'automatic' mode, both axes on the mouse map to a single paddle
|
||||
// In 'automatic' mode, both axes on the mouse map to a single paddle,
|
||||
// and the paddle axis and direction settings are taken into account
|
||||
// This overrides any other mode
|
||||
if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue