From bce432eff650f3cea0316f694ff3231107d522a4 Mon Sep 17 00:00:00 2001 From: Gregory Dymarek Date: Fri, 22 Apr 2016 22:34:34 +0100 Subject: [PATCH] Cleanup --- src/Joystick/Joystick.cc | 6 +++--- src/Joystick/JoystickAndroid.cc | 16 ++++++++-------- src/VehicleSetup/SetupView.qml | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Joystick/Joystick.cc b/src/Joystick/Joystick.cc index 0e1abea40..a320cb273 100644 --- a/src/Joystick/Joystick.cc +++ b/src/Joystick/Joystick.cc @@ -89,7 +89,7 @@ void Joystick::run(void) open(); while (!_exitThread) { - update(); + update(); // Update axes for (int axisIndex=0; axisIndex<_axisCount; axisIndex++) { @@ -143,9 +143,9 @@ void Joystick::run(void) // We only send the buttons the firmwware has reserved int reservedButtonCount = _activeVehicle->manualControlReservedButtonCount(); - if (reservedButtonCount == -1) { + if (reservedButtonCount == -1) reservedButtonCount = _buttonCount; - } + quint16 newButtonBits = 0; // New set of button which are down quint16 buttonPressedBits = 0; // Buttons pressed for manualControl signal diff --git a/src/Joystick/JoystickAndroid.cc b/src/Joystick/JoystickAndroid.cc index 3de7ce4ca..14bdcf9b8 100644 --- a/src/Joystick/JoystickAndroid.cc +++ b/src/Joystick/JoystickAndroid.cc @@ -49,20 +49,20 @@ JoystickAndroid::JoystickAndroid(const QString& name, int id, MultiVehicleManage axisValue = new int[_axisCount]; axisCode = new int[_axisCount]; for (i=0;i<_axisCount;i++) { - QAndroidJniObject range = rangeListNative.callObjectMethod("get", "()Landroid/view/InputDevice/MotionRange;"); - if (range.isValid()) - axisCode[i] = range.callMethod("getAxis"); - axisValue[i] = 0; + QAndroidJniObject range = rangeListNative.callObjectMethod("get", "()Landroid/view/InputDevice/MotionRange;"); + if (range.isValid()) + axisCode[i] = range.callMethod("getAxis"); + axisValue[i] = 0; } - qDebug() << "joystick constructor:" << _name; + _axisCount = 4; + qDebug() << "axis:" <<_axisCount << "buttons:" <<_buttonCount; QtAndroidPrivate::registerGenericMotionEventListener(this); QtAndroidPrivate::registerKeyEventListener(this); } JoystickAndroid::~JoystickAndroid() { - qDebug() << "joystick destructor" << _name; delete btnCode; delete axisCode; @@ -150,11 +150,11 @@ bool JoystickAndroid::update(void) } bool JoystickAndroid::getButton(int i) { - return btnValue[ btnCode[i] ]; + return btnValue[ i ]; } int JoystickAndroid::getAxis(int i) { - return axisValue[ axisCode[i] ]; + return axisValue[ i ]; } diff --git a/src/VehicleSetup/SetupView.qml b/src/VehicleSetup/SetupView.qml index 18e50da45..a5713a8e8 100644 --- a/src/VehicleSetup/SetupView.qml +++ b/src/VehicleSetup/SetupView.qml @@ -279,6 +279,7 @@ Rectangle { setupComplete: joystickManager.activeJoystick ? joystickManager.activeJoystick.calibrated : false exclusiveGroup: setupButtonGroup visible: _fullParameterVehicleAvailable && joystickManager.joysticks.length != 0 + //visible: true text: "Joystick" onClicked: showJoystickPanel() -- 2.22.0