diff --git a/src/common/PhysicalJoystick.cxx b/src/common/PhysicalJoystick.cxx index 3b977d058..88b4ddc32 100644 --- a/src/common/PhysicalJoystick.cxx +++ b/src/common/PhysicalJoystick.cxx @@ -30,19 +30,10 @@ PhysicalJoystick::PhysicalJoystick() name("None"), numAxes(0), numButtons(0), - numHats(0), - axisLastValue(nullptr), - buttonLast(nullptr) + numHats(0) { } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -PhysicalJoystick::~PhysicalJoystick() -{ - delete[] axisLastValue; - delete[] buttonLast; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystick::initialize(int index, const string& desc, int axes, int buttons, int hats, int /*balls*/) @@ -50,21 +41,11 @@ void PhysicalJoystick::initialize(int index, const string& desc, ID = index; name = desc; - // Dynamically create the various mapping arrays for this joystick, - // based on its specific attributes numAxes = axes; numButtons = buttons; numHats = hats; - axisLastValue = new int[numAxes]; - buttonLast = new int[numButtons]; - - // Erase the last button - for (int b = 0; b < numButtons; ++b) - buttonLast[b] = JOY_CTRL_NONE; - - // Erase the last axis value - for(int a = 0; a < numAxes; ++a) - axisLastValue[a] = 0; + 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 eead7901a..aceea9cd5 100644 --- a/src/common/PhysicalJoystick.hxx +++ b/src/common/PhysicalJoystick.hxx @@ -43,7 +43,6 @@ class PhysicalJoystick public: PhysicalJoystick(); - virtual ~PhysicalJoystick(); string getMap() const; bool setMap(const string& map); @@ -70,8 +69,8 @@ class PhysicalJoystick int ID; string name; int numAxes, numButtons, numHats; - int* axisLastValue; - int* buttonLast; + IntArray axisLastValue; + IntArray buttonLast; // Hashmaps of controller events JoyMap joyMap; @@ -84,6 +83,12 @@ class PhysicalJoystick << ", numbtns: " << s.numButtons << ", numhats: " << s.numHats; return os; } + + // Following constructors and assignment operators not supported + PhysicalJoystick(const PhysicalJoystick&) = delete; + PhysicalJoystick(PhysicalJoystick&&) = delete; + PhysicalJoystick& operator=(const PhysicalJoystick&) = delete; + PhysicalJoystick& operator=(PhysicalJoystick&&) = delete; }; #endif