32 constexpr std::int32_t key_d = 0x1;
33 constexpr std::int32_t key_a = 0x2;
34 constexpr std::int32_t key_s = 0x4;
35 constexpr std::int32_t key_w = 0x8;
36 constexpr std::int32_t key_r = 0x40;
37 constexpr std::int32_t key_f = 0x80;
38 constexpr std::int32_t s_up = 1;
39 constexpr std::int32_t s_down = 2;
40 constexpr std::int32_t roll_up = -660;
41 constexpr std::int32_t roll_down = 660;
42 constexpr fp32 rc_scale = 660.0f;
46 const bool unlock_gesture =
47 input.s1 == s_down && input.s2 == s_down && pitch_wheel == roll_up;
48 if (unlock_gesture && !unlock_gesture_last_) {
50 command.arm_requested =
true;
52 unlock_gesture_last_ = unlock_gesture;
55 keyboard_mode_ =
true;
62 command.velocity.x =
static_cast<fp32>(bool(input.key & key_d))
63 -
static_cast<fp32>(
bool(input.key & key_a));
64 command.velocity.y =
static_cast<fp32>(bool(input.key & key_w))
65 -
static_cast<fp32>(
bool(input.key & key_s));
67 const bool rotate_pressed = input.key & key_r;
68 if (rotate_pressed && !rotate_pressed_last_) {
69 rotate_enabled_ = !rotate_enabled_;
71 rotate_pressed_last_ = rotate_pressed;
73 const bool friction_pressed = input.key & key_f;
74 if (friction_pressed && !friction_pressed_last_) {
75 friction_enabled_ = !friction_enabled_;
77 friction_pressed_last_ = friction_pressed;
79 command.rotate_speed = rotate_enabled_ ? 1.0f : 0.0f;
80 command.friction_enabled = friction_enabled_;
81 command.auto_aim = input.mouse_r || (input.s1 == s_down && input.s2 == s_up);
82 command.firing = input.mouse_l || pitch_wheel == roll_down;
83 if (!command.auto_aim) {
84 command.yaw_delta =
static_cast<fp32>(input.mouse_x) / 10000.0f;
85 command.pitch_delta =
static_cast<fp32>(input.mouse_y) / 10000.0f;
91 .x =
static_cast<fp32>(input.ch3) / rc_scale * 3.0f,
92 .y =
static_cast<fp32>(input.ch2) / rc_scale * 3.0f
94 command.yaw_delta =
static_cast<fp32>(input.ch0) / rc_scale / 200.0f;
95 command.pitch_target = std::clamp(
96 static_cast<fp32>(input.ch1) / rc_scale * 0.3f, -0.3f, 0.3f);
97 command.use_pitch_target =
true;
98 command.rotate_speed = input.s1 == s_up ? 1.0f : 0.0f;
99 command.friction_enabled = input.s2 == s_up;
100 command.auto_aim = input.s1 == s_down && input.s2 == s_up;
101 command.firing = pitch_wheel == roll_down;
102 friction_enabled_ = command.friction_enabled;