Disable stick commands when HID is active and USB is connected
Moved to shared code and cms.c refactoring Added missing line endings and comments Passing tests - defines added Added missing definition Added check for USE_USB_CDC_HID in cmsUpdate Code refactoring and condition change Remove unnecessary include Disable stick commands when HID is active and USB is connected cdcDeviceIsMayBeActive refactored Disable stick commands when HID is active and USB is connected
This commit is contained in:
parent
968e72fae8
commit
60cc80825a
|
@ -61,22 +61,16 @@
|
|||
#include "flight/mixer.h"
|
||||
|
||||
#include "io/rcdevice_cam.h"
|
||||
#include "io/usb_cdc_hid.h"
|
||||
|
||||
#include "pg/pg.h"
|
||||
#include "pg/pg_ids.h"
|
||||
#include "pg/rx.h"
|
||||
#ifdef USE_USB_CDC_HID
|
||||
#include "pg/usb.h"
|
||||
#endif
|
||||
|
||||
#include "osd/osd.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
|
||||
#ifdef USE_USB_CDC_HID
|
||||
#include "sensors/battery.h"
|
||||
#endif
|
||||
|
||||
// DisplayPort management
|
||||
|
||||
#ifndef CMS_MAX_DEVICE
|
||||
|
@ -1202,7 +1196,7 @@ static void cmsUpdate(uint32_t currentTimeUs)
|
|||
|| rcdeviceInMenu
|
||||
#endif
|
||||
#ifdef USE_USB_CDC_HID
|
||||
|| (getBatteryCellCount() == 0 && usbDevConfig()->type == COMPOSITE)
|
||||
|| cdcDeviceIsMayBeActive() // If this target is used as a joystick, we should leave here.
|
||||
#endif
|
||||
) {
|
||||
return;
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "flight/failsafe.h"
|
||||
|
||||
#include "io/beeper.h"
|
||||
#include "io/usb_cdc_hid.h"
|
||||
#include "io/dashboard.h"
|
||||
#include "io/gps.h"
|
||||
#include "io/vtx_control.h"
|
||||
|
@ -228,6 +229,13 @@ void processRcStickPositions()
|
|||
}
|
||||
doNotRepeat = true;
|
||||
|
||||
#ifdef USE_USB_CDC_HID
|
||||
// If this target is used as a joystick, we should leave here.
|
||||
if (cdcDeviceIsMayBeActive()) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// actions during not armed
|
||||
|
||||
if (rcSticks == THR_LO + YAW_LO + PIT_LO + ROL_CE) {
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef USE_USB_CDC_HID
|
||||
|
@ -28,6 +31,10 @@
|
|||
|
||||
#include "rx/rx.h"
|
||||
|
||||
#include "pg/usb.h"
|
||||
|
||||
#include "sensors/battery.h"
|
||||
|
||||
//TODO: Make it platform independent in the future
|
||||
#if defined(STM32F4)
|
||||
#include "vcpf4/usbd_cdc_vcp.h"
|
||||
|
@ -75,4 +82,9 @@ void sendRcDataToHid(void)
|
|||
# error "MCU does not support USB HID."
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cdcDeviceIsMayBeActive()
|
||||
{
|
||||
return usbDevConfig()->type == COMPOSITE && usbIsConnected() && (getBatteryState() == BATTERY_NOT_PRESENT || batteryConfig()->voltageMeterSource == VOLTAGE_METER_NONE);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -21,3 +21,4 @@
|
|||
#pragma once
|
||||
|
||||
void sendRcDataToHid(void);
|
||||
bool cdcDeviceIsMayBeActive();
|
||||
|
|
Loading…
Reference in New Issue