Browse Source

Sub: Configure default joystick buttons

mission-4.1.18
Jacob Walser 8 years ago committed by Andrew Tridgell
parent
commit
b7e419cf9c
  1. 1
      ArduSub/Sub.h
  2. 30
      ArduSub/joystick.cpp

1
ArduSub/Sub.h

@ -779,6 +779,7 @@ private: @@ -779,6 +779,7 @@ private:
void handle_jsbutton_press(uint8_t button,bool shift=false,bool held=false);
void camera_tilt_smooth();
JSButton* get_button(uint8_t index);
void default_js_buttons(void);
void set_throttle_zero_flag(int16_t throttle_control);
void radio_passthrough_to_motors();
void init_barometer(bool full_calibration);

30
ArduSub/joystick.cpp

@ -26,6 +26,8 @@ namespace { @@ -26,6 +26,8 @@ namespace {
}
void Sub::init_joystick() {
default_js_buttons();
set_mode((control_mode_t)flight_modes[0].get(), MODE_REASON_TX_COMMAND); // Initialize flight mode
if(g.numGainSettings < 1) g.numGainSettings.set_and_save(1);
@ -406,3 +408,31 @@ void Sub::camera_tilt_smooth() { @@ -406,3 +408,31 @@ void Sub::camera_tilt_smooth() {
failsafe.rc_override_active = hal.rcin->set_overrides(channels, 10);
}
void Sub::default_js_buttons() {
JSButton::button_function_t defaults[16][2] = {
{JSButton::button_function_t::k_none, JSButton::button_function_t::k_none},
{JSButton::button_function_t::k_mode_1, JSButton::button_function_t::k_none},
{JSButton::button_function_t::k_mode_3, JSButton::button_function_t::k_none},
{JSButton::button_function_t::k_mode_2, JSButton::button_function_t::k_none},
{JSButton::button_function_t::k_disarm, JSButton::button_function_t::k_none},
{JSButton::button_function_t::k_shift, JSButton::button_function_t::k_none},
{JSButton::button_function_t::k_arm, JSButton::button_function_t::k_none},
{JSButton::button_function_t::k_mount_center, JSButton::button_function_t::k_none},
{JSButton::button_function_t::k_input_hold_toggle, JSButton::button_function_t::k_none},
{JSButton::button_function_t::k_mount_tilt_down, JSButton::button_function_t::k_none},
{JSButton::button_function_t::k_mount_tilt_up, JSButton::button_function_t::k_none},
{JSButton::button_function_t::k_gain_inc, JSButton::button_function_t::k_trim_pitch_dec},
{JSButton::button_function_t::k_gain_dec, JSButton::button_function_t::k_trim_pitch_inc},
{JSButton::button_function_t::k_lights1_dimmer, JSButton::button_function_t::k_trim_roll_dec},
{JSButton::button_function_t::k_lights1_brighter, JSButton::button_function_t::k_trim_roll_inc},
{JSButton::button_function_t::k_none, JSButton::button_function_t::k_none},
};
for(int i = 0; i < 16; i++) {
get_button(i)->set_default(defaults[i][0], defaults[i][1]);
}
}

Loading…
Cancel
Save