| 412 | |
| 413 | #ifdef OPENHD_TELEMETRY_SDL_FOR_JOYSTICK_FOUND |
| 414 | void GroundTelemetry::enable_joystick() { |
| 415 | if (m_rc_joystick_sender != nullptr) { |
| 416 | m_console->warn("Joy already enabled"); |
| 417 | return; |
| 418 | } |
| 419 | auto cb = [this](std::array<uint16_t, 18> channels) { |
| 420 | // Dirty - we want the message both in the GCS station for debugging BUT |
| 421 | // need to perform some annoying workaround for ARDUPILOT in regard to the |
| 422 | // SYS id. Which is why we send the same data as 2 different messages to the |
| 423 | // air unit(FC) and to the GCS stations, and the message for the air unit |
| 424 | // has the "wrong" source sys id so to say See |
| 425 | // https://github.com/ArduPilot/ardupilot/blob/master/libraries/GCS_MAVLink/GCS_Common.cpp#L3507 |
| 426 | // and https://github.com/ArduPilot/ardupilot/issues/1515 |
| 427 | auto msg_for_air = |
| 428 | rc_channels_override_from_array(QOPENHD_SYS_ID, 1, channels, 0, 0); |
| 429 | send_messages_air_unit({msg_for_air}); |
| 430 | // to the GCS stations |
| 431 | auto msg_for_gcs = |
| 432 | rc_channels_override_from_array(OHD_SYS_ID_GROUND, 0, channels, 0, 0); |
| 433 | send_messages_ground_station_clients({msg_for_gcs}); |
| 434 | }; |
| 435 | auto mapping_parsed = openhd::convert_string_to_channel_mapping_or_default( |
| 436 | m_gnd_settings->get_settings().rc_channel_mapping); |
| 437 | m_rc_joystick_sender = std::make_unique<RcJoystickSender>( |
| 438 | cb, m_gnd_settings->get_settings().rc_over_joystick_update_rate_hz, |
| 439 | mapping_parsed); |
| 440 | m_console->info("Joystick enabled"); |
| 441 | } |
| 442 | void GroundTelemetry::disable_joystick() { |
| 443 | if (m_rc_joystick_sender == nullptr) { |
| 444 | m_console->warn("Joy already disabled"); |
nothing calls this directly
no test coverage detected