mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 12:25:20 +03:00
Merge pull request #10095 from dkustec/disable_stick_commands_when_HID_is_in_use
This commit is contained in:
commit
c05cbd3792
4 changed files with 23 additions and 8 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue