* Reduce RAM usage for advanced joystick system on radio: - Don't allocate memory blocks unless joystick mode is being used. Support multiple radio joystick configurations in Companion: - Save configured joystick settings by joystick name in Companion settings. - Save last joystick name used in each profile. - Reload joystick settings by name when profile is changed. * Only show configuration for used axes and buttons in Companion. Send actual number of configured joystick buttons from radio in USB packet. * Fix issue where USB joystick not recognised if no buttons configured. * Fix compiler warnings. * Remove debugging. * Fix crash in Companion. * Change channel 8 to type 'dial', workaround for Linux mapping issue. --------- Co-authored-by: Phil Mitchell <phil.a.mitchell@gmail.com>
83 lines
2.0 KiB
C++
83 lines
2.0 KiB
C++
/*
|
|
* Copyright (C) OpenTX
|
|
*
|
|
* Based on code named
|
|
* th9x - http://code.google.com/p/th9x
|
|
* er9x - http://code.google.com/p/er9x
|
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
|
*
|
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#ifndef _JOYSTICKDIALOG_H_
|
|
#define _JOYSTICKDIALOG_H_
|
|
|
|
#include <QtWidgets>
|
|
#include "appdata.h"
|
|
#include "joystick.h"
|
|
|
|
class QCheckBox;
|
|
class QComboBox;
|
|
class QSlider;
|
|
|
|
enum JSButtonFlag {
|
|
JS_BUTTON_TOGGLE = 0x1000,
|
|
JS_BUTTON_3POS_UP = 0x2000,
|
|
JS_BUTTON_3POS_DN = 0x4000,
|
|
JS_BUTTON_TYPE_MASK = 0xF000,
|
|
JS_BUTTON_SWITCH_MASK = 0x1F
|
|
};
|
|
|
|
namespace Ui {
|
|
class joystickDialog;
|
|
}
|
|
|
|
class joystickDialog : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit joystickDialog(QWidget *parent = 0);
|
|
~joystickDialog();
|
|
Joystick *joystick;
|
|
|
|
private:
|
|
Ui::joystickDialog *ui;
|
|
int jscal[MAX_JS_AXES][3];
|
|
QCheckBox * invert[MAX_JS_AXES];
|
|
QComboBox * sticks[MAX_JS_AXES + MAX_JS_BUTTONS];
|
|
QSlider * sliders[MAX_JS_AXES + MAX_JS_BUTTONS];
|
|
int step;
|
|
int numAxes;
|
|
int numButtons;
|
|
bool started;
|
|
|
|
void loadGrid();
|
|
|
|
private slots:
|
|
void populateSourceCombo(QComboBox * cb);
|
|
void populateButtonCombo(QComboBox * cb);
|
|
bool loadJoysticks();
|
|
void joystickOpen(int stick);
|
|
void joystickSetEnabled(bool enable);
|
|
void onjoystickAxisValueChanged(int axis, int value);
|
|
void onjoystickButtonValueChanged(int button, bool state);
|
|
void loadStep();
|
|
void on_backButton_clicked();
|
|
void on_nextButton_clicked();
|
|
void on_cancelButton_clicked();
|
|
void on_okButton_clicked();
|
|
|
|
};
|
|
|
|
#endif // _JOYSTICKDIALOG_H_
|