1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

Merge pull request #10095 from dkustec/disable_stick_commands_when_HID_is_in_use

This commit is contained in:
Michael Keller 2020-08-29 16:07:20 +12:00 committed by GitHub
commit c05cbd3792
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 8 deletions

View file

@ -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;

View file

@ -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) {

View file

@ -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

View file

@ -21,3 +21,4 @@
#pragma once
void sendRcDataToHid(void);
bool cdcDeviceIsMayBeActive();