From 03c5d7f1cf3e325e0dc0b41b89ffc17a54834af8 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Mon, 9 Sep 2024 10:28:20 +0200 Subject: [PATCH] changed buttonLast type (fixes #1043) --- src/common/PJoystickHandler.cxx | 8 ++++---- src/common/PhysicalJoystick.cxx | 1 - src/common/PhysicalJoystick.hxx | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index c3a70a271..d21bdef49 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -901,7 +901,7 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value) if(j) { - //int button = j->buttonLast[stick]; + //int button = j->buttonLast; switch(j->type) { @@ -945,7 +945,7 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value) void PhysicalJoystickHandler::handleRegularAxisEvent(const PhysicalJoystickPtr& j, int stick, int axis, int value) { - const int button = j->buttonLast[stick]; + const int button = j->buttonLast; if(myHandler.state() == EventHandlerState::EMULATION) { @@ -1025,7 +1025,7 @@ void PhysicalJoystickHandler::handleBtnEvent(int stick, int button, bool pressed if(j) { - j->buttonLast[stick] = pressed ? button : JOY_CTRL_NONE; + j->buttonLast = pressed ? button : JOY_CTRL_NONE; // Handle buttons which switch eventhandler state if(!pressed && myHandler.changeStateByEvent(j->joyMap.get(EventMode::kEmulationMode, button))) @@ -1052,7 +1052,7 @@ void PhysicalJoystickHandler::handleHatEvent(int stick, int hat, int value) if(j) { - const int button = j->buttonLast[stick]; + const int button = j->buttonLast; if(myHandler.state() == EventHandlerState::EMULATION) { diff --git a/src/common/PhysicalJoystick.cxx b/src/common/PhysicalJoystick.cxx index e1d8a2825..12771c051 100644 --- a/src/common/PhysicalJoystick.cxx +++ b/src/common/PhysicalJoystick.cxx @@ -47,7 +47,6 @@ void PhysicalJoystick::initialize(int index, string_view desc, numButtons = buttons; numHats = hats; axisLastValue.resize(numAxes, 0); - buttonLast.resize(numButtons, JOY_CTRL_NONE); // Erase the mappings eraseMap(EventMode::kMenuMode); diff --git a/src/common/PhysicalJoystick.hxx b/src/common/PhysicalJoystick.hxx index c312d2d52..d83c9bd06 100644 --- a/src/common/PhysicalJoystick.hxx +++ b/src/common/PhysicalJoystick.hxx @@ -81,7 +81,7 @@ class PhysicalJoystick Port port{Port::AUTO}; int numAxes{0}, numButtons{0}, numHats{0}; IntArray axisLastValue; - IntArray buttonLast; + int buttonLast{JOY_CTRL_NONE}; // Hashmaps of controller events JoyMap joyMap;