| 291 | } |
| 292 | |
| 293 | void JoystickReader::write_matching_button(std::array<uint16_t, 18>& rc_data, |
| 294 | const Uint8 button, bool up) { |
| 295 | // The mavlink rc channels override message has more than enough "channels" |
| 296 | // anyways. |
| 297 | // However, we could optimize here putting multiple buttons (aka bool) into |
| 298 | // one channel |
| 299 | const int channel_index = |
| 300 | JoystickReader::N_CHANNELS_RESERVED_FOR_AXES + button; |
| 301 | if (channel_index < rc_data.size()) { |
| 302 | rc_data[channel_index] = up ? JoystickReader::VALUE_BUTTON_UP |
| 303 | : JoystickReader::VALUE_BUTTON_DOWN; |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | #endif // OPENHD_TELEMETRY_SDL_FOR_JOYSTICK_FOUND |