From b7e489a0718c2ca658487cd4ee9c40c8a103299f Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 29 Jan 2012 17:33:36 +0000 Subject: [PATCH] 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 --- src/emucore/Driving.cxx | 51 ++++++++++++++++++++++++++++++++++++----- src/emucore/Driving.hxx | 5 +++- src/emucore/Paddles.cxx | 3 ++- 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/src/emucore/Driving.cxx b/src/emucore/Driving.cxx index 2b9b557ed..0f0b6a692 100644 --- a/src/emucore/Driving.cxx +++ b/src/emucore/Driving.cxx @@ -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; + } + } } diff --git a/src/emucore/Driving.hxx b/src/emucore/Driving.hxx index 326521884..296be350f 100644 --- a/src/emucore/Driving.hxx +++ b/src/emucore/Driving.hxx @@ -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 diff --git a/src/emucore/Paddles.cxx b/src/emucore/Paddles.cxx index 21b778c18..2b07b61b2 100644 --- a/src/emucore/Paddles.cxx +++ b/src/emucore/Paddles.cxx @@ -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) {