diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index 43c289c36..0814524ac 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -697,7 +697,6 @@ bool PhysicalJoystickHandler::addJoyMapping(Event::Type event, EventMode mode, i if (Event::isAnalog(j->joyMap.get(mode, button, axis, JoyDir::ANALOG))) j->joyMap.erase(mode, button, axis, JoyDir::ANALOG); - j->joyMap.add(event, mode, button, axis, convertAxisValue(value)); } return true; @@ -733,61 +732,45 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value) // Stelladaptors handle axis differently than regular joysticks switch (j->type) { - case PhysicalJoystick::JT_REGULAR: - case PhysicalJoystick::JT_STELLADAPTOR_LEFT: - case PhysicalJoystick::JT_2600DAPTOR_LEFT: - case PhysicalJoystick::JT_STELLADAPTOR_RIGHT: - case PhysicalJoystick::JT_2600DAPTOR_RIGHT: + case PhysicalJoystick::JT_NONE: + break; + default: if (myHandler.state() == EventHandlerState::EMULATION) { Event::Type eventAxisAnalog = j->joyMap.get(kEmulationMode, button, JoyAxis(axis), JoyDir::ANALOG); // Check for analog events, which are handled differently - // We'll pass them off as Stelladaptor events, and let the controllers - // handle it - switch (eventAxisAnalog) + if (Event::isAnalog(eventAxisAnalog)) { - case Event::PaddleZeroAnalog: - myEvent.set(Event::SALeftAxis0Value, value); - break; - case Event::PaddleOneAnalog: - myEvent.set(Event::SALeftAxis1Value, value); - break; - case Event::PaddleTwoAnalog: - myEvent.set(Event::SARightAxis0Value, value); - break; - case Event::PaddleThreeAnalog: - myEvent.set(Event::SARightAxis1Value, value); - break; - default: + myHandler.handleEvent(eventAxisAnalog, value); + } + else + { + // Otherwise, we know the event is digital + // Every axis event has two associated values, negative and positive + Event::Type eventAxisNeg = j->joyMap.get(kEmulationMode, button, JoyAxis(axis), JoyDir::NEG); + Event::Type eventAxisPos = j->joyMap.get(kEmulationMode, button, JoyAxis(axis), JoyDir::POS); + + if (value > Joystick::deadzone()) + myHandler.handleEvent(eventAxisPos); + else if (value < -Joystick::deadzone()) + myHandler.handleEvent(eventAxisNeg); + else { - // Otherwise, we know the event is digital - // Every axis event has two associated values, negative and positive - Event::Type eventAxisNeg = j->joyMap.get(kEmulationMode, button, JoyAxis(axis), JoyDir::NEG); - Event::Type eventAxisPos = j->joyMap.get(kEmulationMode, button, JoyAxis(axis), JoyDir::POS); + // Treat any deadzone value as zero + value = 0; - if (value > Joystick::deadzone()) - myHandler.handleEvent(eventAxisPos); - else if (value < -Joystick::deadzone()) - myHandler.handleEvent(eventAxisNeg); - else + // Now filter out consecutive, similar values + // (only pass on the event if the state has changed) + if (j->axisLastValue[axis] != value) { - // Treat any deadzone value as zero - value = 0; - - // Now filter out consecutive, similar values - // (only pass on the event if the state has changed) - if (j->axisLastValue[axis] != value) - { - // Turn off both events, since we don't know exactly which one - // was previously activated. - myHandler.handleEvent(eventAxisNeg, false); - myHandler.handleEvent(eventAxisPos, false); - } + // Turn off both events, since we don't know exactly which one + // was previously activated. + myHandler.handleEvent(eventAxisNeg, false); + myHandler.handleEvent(eventAxisPos, false); } - j->axisLastValue[axis] = value; - break; } + j->axisLastValue[axis] = value; } } else if (myHandler.hasOverlay()) @@ -828,9 +811,9 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value) case PhysicalJoystick::JT_2600DAPTOR_RIGHT: if (axis < NUM_JOY_AXIS) myEvent.set(SA_Axis[int(Controller::Jack::Right)][axis], value); - break; // axis on right controller (1)*/ + break; // axis on right controller (1) default: - break; + break;*/ } } } @@ -987,8 +970,8 @@ ostream& operator<<(ostream& os, const PhysicalJoystickHandler& jh) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /*// Used by the Stelladaptor to send absolute axis values const Event::Type PhysicalJoystickHandler::SA_Axis[NUM_PORTS][NUM_JOY_AXIS] = { - { Event::SALeftAxis0Value, Event::SALeftAxis1Value }, - { Event::SARightAxis0Value, Event::SARightAxis1Value } + { Event::PaddleZeroAnalog, Event::PaddleOneAnalog }, + { Event::PaddleTwoAnalog, Event::PaddleThreeAnalog } }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Booster.cxx b/src/emucore/Booster.cxx index e446226f9..29f90e924 100644 --- a/src/emucore/Booster.cxx +++ b/src/emucore/Booster.cxx @@ -32,8 +32,8 @@ BoosterGrip::BoosterGrip(Jack jack, const Event& event, const System& system) myFireEvent = Event::JoystickZeroFire; myTriggerEvent = Event::JoystickZeroFire5; myBoosterEvent = Event::JoystickZeroFire9; - myXAxisValue = Event::SALeftAxis0Value; - myYAxisValue = Event::SALeftAxis1Value; + myXAxisValue = Event::PaddleZeroAnalog; + myYAxisValue = Event::PaddleOneAnalog; } else { @@ -44,8 +44,8 @@ BoosterGrip::BoosterGrip(Jack jack, const Event& event, const System& system) myFireEvent = Event::JoystickOneFire; myTriggerEvent = Event::JoystickOneFire5; myBoosterEvent = Event::JoystickOneFire9; - myXAxisValue = Event::SARightAxis0Value; - myYAxisValue = Event::SARightAxis1Value; + myXAxisValue = Event::PaddleTwoAnalog; + myYAxisValue = Event::PaddleThreeAnalog; } setPin(AnalogPin::Five, MAX_RESISTANCE); diff --git a/src/emucore/Driving.cxx b/src/emucore/Driving.cxx index 196728c41..6dadc22b3 100644 --- a/src/emucore/Driving.cxx +++ b/src/emucore/Driving.cxx @@ -35,16 +35,16 @@ Driving::Driving(Jack jack, const Event& event, const System& system) myCCWEvent = Event::JoystickZeroLeft; myCWEvent = Event::JoystickZeroRight; myFireEvent = Event::JoystickZeroFire; - myXAxisValue = Event::SALeftAxis0Value; - myYAxisValue = Event::SALeftAxis1Value; + myXAxisValue = Event::PaddleZeroAnalog; + myYAxisValue = Event::PaddleOneAnalog; } else { myCCWEvent = Event::JoystickOneLeft; myCWEvent = Event::JoystickOneRight; myFireEvent = Event::JoystickOneFire; - myXAxisValue = Event::SARightAxis0Value; - myYAxisValue = Event::SARightAxis1Value; + myXAxisValue = Event::PaddleTwoAnalog; + myYAxisValue = Event::PaddleThreeAnalog; } // Digital pins 3 and 4 are not connected diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index 8ebb1c998..88ace0790 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -68,9 +68,6 @@ class Event Combo1, Combo2, Combo3, Combo4, Combo5, Combo6, Combo7, Combo8, Combo9, Combo10, Combo11, Combo12, Combo13, Combo14, Combo15, Combo16, - SALeftAxis0Value, SALeftAxis1Value, - SARightAxis0Value, SARightAxis1Value, - MouseAxisXValue, MouseAxisYValue, MouseButtonLeftValue, MouseButtonRightValue, diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 0b1eec089..6e568a6de 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -331,10 +331,12 @@ void EventHandler::handleSystemEvent(SystemEvent e, int, int) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void EventHandler::handleEvent(Event::Type event, bool pressed, bool repeated) +void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { // Take care of special events that aren't part of the emulation core // or need to be preprocessed before passing them on + bool pressed = (value != 0); + switch(event) { //////////////////////////////////////////////////////////////////////// @@ -896,7 +898,7 @@ void EventHandler::handleEvent(Event::Type event, bool pressed, bool repeated) // Otherwise, pass it to the emulation core if (!repeated) - myEvent.set(event, pressed); + myEvent.set(event, value); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index 02152cf1a..73e82ebb7 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -141,7 +141,7 @@ class EventHandler @param pressed Pressed (true) or released (false) @param repeated Repeated key (true) or first press/release (false) */ - void handleEvent(Event::Type type, bool pressed = true, bool repeated = false); + void handleEvent(Event::Type type, Int32 value = 1, bool repeated = false); /** Handle events that must be processed each time a new console is diff --git a/src/emucore/Joystick.cxx b/src/emucore/Joystick.cxx index e6cf2f3aa..91af453b8 100644 --- a/src/emucore/Joystick.cxx +++ b/src/emucore/Joystick.cxx @@ -30,8 +30,8 @@ Joystick::Joystick(Jack jack, const Event& event, const System& system) myLeftEvent = Event::JoystickZeroLeft; myRightEvent = Event::JoystickZeroRight; myFireEvent = Event::JoystickZeroFire; - myXAxisValue = Event::SALeftAxis0Value; - myYAxisValue = Event::SALeftAxis1Value; + myXAxisValue = Event::PaddleZeroAnalog; + myYAxisValue = Event::PaddleOneAnalog; } else { @@ -40,8 +40,8 @@ Joystick::Joystick(Jack jack, const Event& event, const System& system) myLeftEvent = Event::JoystickOneLeft; myRightEvent = Event::JoystickOneRight; myFireEvent = Event::JoystickOneFire; - myXAxisValue = Event::SARightAxis0Value; - myYAxisValue = Event::SARightAxis1Value; + myXAxisValue = Event::PaddleTwoAnalog; + myYAxisValue = Event::PaddleThreeAnalog; } } diff --git a/src/emucore/Paddles.cxx b/src/emucore/Paddles.cxx index 326ac34e1..22be4e737 100644 --- a/src/emucore/Paddles.cxx +++ b/src/emucore/Paddles.cxx @@ -53,8 +53,8 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system, if(!swappaddle) // First paddle is 0, second is 1 { // These aren't affected by changes in axis orientation - myP0AxisValue = Event::SALeftAxis0Value; - myP1AxisValue = Event::SALeftAxis1Value; + myP0AxisValue = Event::PaddleZeroAnalog; + myP1AxisValue = Event::PaddleOneAnalog; myP0FireEvent1 = Event::PaddleZeroFire; myP0FireEvent2 = Event::JoystickZeroFire; myP1FireEvent1 = Event::PaddleOneFire; @@ -89,8 +89,8 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system, else // First paddle is 1, second is 0 { // These aren't affected by changes in axis orientation - myP0AxisValue = Event::SALeftAxis1Value; - myP1AxisValue = Event::SALeftAxis0Value; + myP0AxisValue = Event::PaddleOneAnalog; + myP1AxisValue = Event::PaddleZeroAnalog; myP0FireEvent1 = Event::PaddleOneFire; myP0FireEvent2 = Event::JoystickZeroFire9; myP1FireEvent1 = Event::PaddleZeroFire; @@ -128,8 +128,8 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system, if(!swappaddle) // First paddle is 2, second is 3 { // These aren't affected by changes in axis orientation - myP0AxisValue = Event::SARightAxis0Value; - myP1AxisValue = Event::SARightAxis1Value; + myP0AxisValue = Event::PaddleTwoAnalog; + myP1AxisValue = Event::PaddleThreeAnalog; myP0FireEvent1 = Event::PaddleTwoFire; myP0FireEvent2 = Event::JoystickOneFire; myP1FireEvent1 = Event::PaddleThreeFire; @@ -164,8 +164,8 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system, else // First paddle is 3, second is 2 { // These aren't affected by changes in axis orientation - myP0AxisValue = Event::SARightAxis1Value; - myP1AxisValue = Event::SARightAxis0Value; + myP0AxisValue = Event::PaddleThreeAnalog; + myP1AxisValue = Event::PaddleTwoAnalog; myP0FireEvent1 = Event::PaddleThreeFire; myP0FireEvent2 = Event::JoystickOneFire9; myP1FireEvent1 = Event::PaddleTwoFire;