Skip to content

Patch - clamp mouse integrator #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ int main() {
vtm_pos_x += ref->ref_data.kbm_interaction.mouse_speed_x * 0.05 * delta;
vtm_pos_y += ref->ref_data.kbm_interaction.mouse_speed_y * 0.05 * delta;

// clamp mouse y to the pitch limits from config
float pitch_min = config->set_reference_limits[4][0][0];
float pitch_max = config->set_reference_limits[4][0][1];
if (dr16_pos_y < pitch_min) { dr16_pos_y = pitch_min; }
if (dr16_pos_y > pitch_max) { dr16_pos_y = pitch_max; }

float chassis_vel_x = 0;
float chassis_vel_y = 0;
float chassis_pos_x = 0;
Expand All @@ -214,7 +220,7 @@ int main() {
float chassis_spin = dr16.get_wheel() * 25;
float pitch_target = 1.57
+ -dr16.get_r_stick_y() * 0.3
+ dr16_pos_y
+ dr16_pos_y - ((pitch_min + pitch_max) / 2)
+ vtm_pos_y;
float yaw_target = -dr16.get_r_stick_x() * 1.5
- dr16_pos_x
Expand Down