feat: New advanced joystick mode on radio, improvements to Companion and Simulator joystick support (#3111)

* Allow switches on the connected radio to control switches in the simulator via the joystick interface.

* Merge configurable radio joystick interface from banyaszg.

* Add two more 'axis' channels to companion.

* Fix 6POS from USB joystick to simulator.

* Reduce data size.

* Fix build error on B&W radios.

* Add 'Companion' button mode to work with the button logic in the Companion app.

* Build Companion joystick setup layout at runtime.
Change #define names for simulator joystick.
Allow 15 axes and 32 buttons.
Initial support for trim sliders.

* Remove custom joystick button type for companion - use 3 buttons per switch in companion to control simulator switch state.

* Fix joystick constructor calls parameters. Connect some radio joystick trims to simulator widgets.

* Restore 'companion' button type to reduce number of buttons needed. Make trims work via buttons in USB joystick.

* Connect joystick trim buttons to simulator widgets.

* Use companion source names for trims.

* Add encode / decode of usb joystick custom settings to Companion.

* Convert to lvgl layouts.
Update language files.

* Fix generated YAML storage files.

* Fix initialisation error when editing button channel. Cleanup code.

* Fix rebase.

* Fix refresh of joystick channel list view after editing an entry.
Companion joystick config window uses two columns.

* Fix vertical joystick inversion bug.
Change stick axis labels.

---------

Co-authored-by: Phil Mitchell <phil.a.mitchell@gmail.com>
This commit is contained in:
philmoz
2023-03-22 10:31:29 +10:00
committed by GitHub
co-authored by Phil Mitchell
parent a1178f83a6
commit 661657feca
81 changed files with 3501 additions and 572 deletions
+68 -1
View File
@@ -22,6 +22,10 @@
#include "opentx.h"
#include "mixer_scheduler.h"
#if defined(USBJ_EX)
#include "usb_joystick.h"
#endif
#if defined(CROSSFIRE)
#include "telemetry/crossfire.h"
#endif
@@ -153,6 +157,15 @@ enum MenuModelSetupItems {
#endif
ITEM_MODEL_SETUP_TRAINER_CHANNELS,
ITEM_MODEL_SETUP_TRAINER_PPM_PARAMS,
#if defined(USBJ_EX)
ITEM_MODEL_SETUP_USBJOYSTICK_LABEL,
ITEM_MODEL_SETUP_USBJOYSTICK_MODE,
ITEM_MODEL_SETUP_USBJOYSTICK_IF_MODE,
ITEM_MODEL_SETUP_USBJOYSTICK_CIRC_CUTOUT,
ITEM_MODEL_SETUP_USBJOYSTICK_CH_BUTTON,
ITEM_MODEL_SETUP_USBJOYSTICK_APPLY,
#endif
ITEM_MODEL_SETUP_LINES_COUNT
};
@@ -392,6 +405,25 @@ void onBluetoothConnectMenu(const char * result)
#include "common/stdlcd/model_setup_afhds3.cpp"
#endif
#if defined(USBJ_EX)
inline uint8_t USB_JOYSTICK_EXTROW()
{
return (usbJoystickExtMode() ? (uint8_t)0 : HIDDEN_ROW);
}
inline uint8_t USB_JOYSTICK_APPLYROW()
{
if(!usbJoystickExtMode()) return HIDDEN_ROW;
if(usbJoystickSettingsChanged()) return (uint8_t)0;
return READONLY_ROW;
}
#define USB_JOYSTICK_ROWS LABEL(USBJoystick), (uint8_t)0, USB_JOYSTICK_EXTROW(), \
USB_JOYSTICK_EXTROW(), USB_JOYSTICK_EXTROW(), USB_JOYSTICK_APPLYROW()
#else
#define USB_JOYSTICK_ROWS
#endif
void menuModelSetup(event_t event)
{
horzpos_t l_posHorz = menuHorizontalPosition;
@@ -470,7 +502,9 @@ void menuModelSetup(event_t event)
IF_ACCESS_MODULE_RF(EXTERNAL_MODULE, 0), // Receiver 2
IF_ACCESS_MODULE_RF(EXTERNAL_MODULE, 0), // Receiver 3
TRAINER_ROWS
TRAINER_ROWS,
USB_JOYSTICK_ROWS
});
MENU_CHECK(menuTabModel, MENU_MODEL_SETUP, ITEM_MODEL_SETUP_LINES_COUNT);
@@ -1768,6 +1802,39 @@ void menuModelSetup(event_t event)
modelSetupModulePxx2ReceiverLine(CURRENT_MODULE_EDITED(k), CURRENT_RECEIVER_EDITED(k), y, event, attr);
break;
#endif
#if defined(USBJ_EX)
case ITEM_MODEL_SETUP_USBJOYSTICK_LABEL:
lcdDrawTextAlignedLeft(y, STR_USBJOYSTICK_LABEL);
break;
case ITEM_MODEL_SETUP_USBJOYSTICK_MODE:
g_model.usbJoystickExtMode = editChoice(MODEL_SETUP_2ND_COLUMN, y, INDENT TR_USBJOYSTICK_EXTMODE, STR_VUSBJOYSTICK_EXTMODE, g_model.usbJoystickExtMode, 0, 1, attr, event);
break;
case ITEM_MODEL_SETUP_USBJOYSTICK_IF_MODE:
g_model.usbJoystickIfMode = editChoice(MODEL_SETUP_2ND_COLUMN, y, INDENT TR_USBJOYSTICK_IF_MODE, STR_VUSBJOYSTICK_IF_MODE, g_model.usbJoystickIfMode, 0, USBJOYS_LAST, attr, event);
break;
case ITEM_MODEL_SETUP_USBJOYSTICK_CIRC_CUTOUT:
g_model.usbJoystickCircularCut = editChoice(MODEL_SETUP_2ND_COLUMN, y, INDENT TR_USBJOYSTICK_CIRC_COUTOUT, STR_VUSBJOYSTICK_CIRC_COUTOUT, g_model.usbJoystickCircularCut, 0, 2, attr, event);
break;
case ITEM_MODEL_SETUP_USBJOYSTICK_CH_BUTTON:
lcdDrawText(INDENT_WIDTH, y, BUTTON(TR_USBJOYSTICK_SETTINGS), attr);
if (attr && event == EVT_KEY_FIRST(KEY_ENTER)) {
pushMenu(menuModelUSBJoystick);
}
break;
case ITEM_MODEL_SETUP_USBJOYSTICK_APPLY:
lcdDrawText(INDENT_WIDTH, y, BUTTON(TR_USBJOYSTICK_APPLY_CHANGES), attr);
if (attr && !READ_ONLY() && event == EVT_KEY_FIRST(KEY_ENTER)) {
killEvents(event);
onUSBJoystickModelChanged();
}
break;
#endif
}
}