feat(radio,cpn): Updates for new joystick system (#3400)
* 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>
This commit is contained in:
@@ -670,13 +670,15 @@ void SimulatorWidget::setupJoysticks()
|
||||
#ifdef JOYSTICKS
|
||||
bool joysticksEnabled = false;
|
||||
|
||||
if (g.jsSupport() && g.jsCtrl() > -1) {
|
||||
if (g.jsSupport()) {
|
||||
if (!joystick)
|
||||
joystick = new Joystick(this, SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT, false, SDL_JOYSTICK_DEFAULT_AUTOREPEAT_DELAY);
|
||||
else
|
||||
joystick->close();
|
||||
|
||||
if (joystick && joystick->open(g.jsCtrl())) {
|
||||
int stick = joystick->findCurrent(g.currentProfile().jsName());
|
||||
|
||||
if (joystick && joystick->open(stick)) {
|
||||
int numAxes = std::min(joystick->numAxes, MAX_JS_AXES);
|
||||
for (int j=0; j<numAxes; j++) {
|
||||
joystick->sensitivities[j] = 0;
|
||||
@@ -860,8 +862,8 @@ void SimulatorWidget::onjoystickAxisValueChanged(int axis, int value)
|
||||
{
|
||||
#ifdef JOYSTICKS
|
||||
static const int ttlSticks = 4;
|
||||
static const int ttlKnobs = Boards::getCapability(m_board, Board::Pots);
|
||||
static const int ttlFaders = Boards::getCapability(m_board, Board::Sliders);
|
||||
const int ttlKnobs = Boards::getCapability(m_board, Board::Pots);
|
||||
const int ttlFaders = Boards::getCapability(m_board, Board::Sliders);
|
||||
static const int valueRange = 1024;
|
||||
|
||||
if (!joystick || axis >= MAX_JS_AXES)
|
||||
@@ -916,9 +918,6 @@ void SimulatorWidget::onjoystickButtonValueChanged(int button, bool state)
|
||||
|
||||
int btn = g.jsButton[button].button_idx();
|
||||
|
||||
if (g.jsButton[button].button_inv())
|
||||
state = !state;
|
||||
|
||||
int swtch = btn & JS_BUTTON_SWITCH_MASK;
|
||||
|
||||
if (swtch < ttlSwitches) {
|
||||
|
||||
Reference in New Issue
Block a user