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)
|
Driving::Driving(Jack jack, const Event& event, const System& system)
|
||||||
: Controller(jack, event, system, Controller::Driving),
|
: Controller(jack, event, system, Controller::Driving),
|
||||||
myCounter(0),
|
myCounter(0),
|
||||||
myControlID(-1)
|
myControlID(-1),
|
||||||
|
myControlIDX(-1),
|
||||||
|
myControlIDY(-1)
|
||||||
{
|
{
|
||||||
if(myJack == Left)
|
if(myJack == Left)
|
||||||
{
|
{
|
||||||
|
@ -74,6 +76,19 @@ void Driving::update()
|
||||||
// Since there are 4 possible controller numbers, we use 0 & 2
|
// Since there are 4 possible controller numbers, we use 0 & 2
|
||||||
// for the left jack, and 1 & 3 for the right jack
|
// for the left jack, and 1 & 3 for the right jack
|
||||||
if(myControlID > -1)
|
if(myControlID > -1)
|
||||||
|
{
|
||||||
|
int m_axis = myEvent.get(Event::MouseAxisXValue);
|
||||||
|
if(m_axis < -2) myCounter--;
|
||||||
|
else if(m_axis > 2) myCounter++;
|
||||||
|
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);
|
int m_axis = myEvent.get(Event::MouseAxisXValue);
|
||||||
if(m_axis < -2) myCounter--;
|
if(m_axis < -2) myCounter--;
|
||||||
|
@ -81,6 +96,15 @@ void Driving::update()
|
||||||
if(myEvent.get(Event::MouseButtonLeftValue))
|
if(myEvent.get(Event::MouseButtonLeftValue))
|
||||||
myDigitalPinState[Six] = false;
|
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)
|
// Only consider the lower-most bits (corresponding to pins 1 & 2)
|
||||||
myCounter &= 0x0f;
|
myCounter &= 0x0f;
|
||||||
|
@ -120,10 +144,25 @@ void Driving::setMouseControl(
|
||||||
// In 'automatic' mode, only the X-axis is used
|
// In 'automatic' mode, only the X-axis is used
|
||||||
if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic)
|
if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic)
|
||||||
{
|
{
|
||||||
myControlID = ((myJack == Left && (ctrlID == 0 || ctrlID == 1)) ||
|
myControlID = ((myJack == Left && ctrlID == 0) ||
|
||||||
(myJack == Right && (ctrlID == 2 || ctrlID == 3))
|
(myJack == Right && ctrlID == 1)
|
||||||
) ? ctrlID & 0x01 : -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;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,9 @@ class Driving : public Controller
|
||||||
|
|
||||||
// Controller to emulate in mouse axis 'automatic' mode
|
// Controller to emulate in mouse axis 'automatic' mode
|
||||||
int myControlID;
|
int myControlID;
|
||||||
|
|
||||||
|
// Controller to emulate in mouse axis 'specific' mode
|
||||||
|
int myControlIDX, myControlIDY;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -384,7 +384,8 @@ void Paddles::update()
|
||||||
void Paddles::setMouseControl(
|
void Paddles::setMouseControl(
|
||||||
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID)
|
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
|
// This overrides any other mode
|
||||||
if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic)
|
if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue