@@ -42,7 +42,7 @@ typedef struct
42
42
43
43
struct Quaternion
44
44
{
45
- float x , y , z , w ;
45
+ float x , y , z , w ;
46
46
};
47
47
48
48
static const Vector3 debug_cube_vertices [] = {
@@ -227,15 +227,15 @@ void DrawAccelerometerDebugArrow(SDL_Renderer *renderer, const Quaternion *gyro_
227
227
SDL_FPoint accel_screen = ProjectVec3ToRect (& rotated_accel , bounds );
228
228
229
229
/* Draw the line from origin to the rotated accelerometer vector */
230
- SDL_SetRenderDrawColor (renderer , GYRO_COLOR_ORANGE );
230
+ SDL_SetRenderDrawColor (renderer , GYRO_COLOR_ORANGE );
231
231
SDL_RenderLine (renderer , origin_screen .x , origin_screen .y , accel_screen .x , accel_screen .y );
232
232
233
233
const float head_width = 4.0f ;
234
234
SDL_FRect arrow_head_rect ;
235
- arrow_head_rect .x = accel_screen .x - head_width * 0.5f ;
235
+ arrow_head_rect .x = accel_screen .x - head_width * 0.5f ;
236
236
arrow_head_rect .y = accel_screen .y - head_width * 0.5f ;
237
- arrow_head_rect .w = head_width ;
238
- arrow_head_rect .h = head_width ;
237
+ arrow_head_rect .w = head_width ;
238
+ arrow_head_rect .h = head_width ;
239
239
SDL_RenderRect (renderer , & arrow_head_rect );
240
240
241
241
/* Restore current color */
@@ -1024,7 +1024,7 @@ void SetGyroDisplayArea(GyroDisplay *ctx, const SDL_FRect *area)
1024
1024
}
1025
1025
1026
1026
SDL_copyp (& ctx -> area , area );
1027
-
1027
+
1028
1028
/* Place the reset button to the bottom right of the gyro display area.*/
1029
1029
SDL_FRect reset_button_area ;
1030
1030
reset_button_area .w = SDL_max (MINIMUM_BUTTON_WIDTH , GetGamepadButtonLabelWidth (ctx -> reset_gyro_button ) + 2 * BUTTON_PADDING );
@@ -1611,8 +1611,7 @@ void RenderGamepadDisplay(GamepadDisplay *ctx, SDL_Gamepad *gamepad)
1611
1611
has_gyro = SDL_GamepadHasSensor (gamepad , SDL_SENSOR_GYRO );
1612
1612
1613
1613
if (has_accel || has_gyro ) {
1614
- const float gyro_sensor_rate = has_gyro ? SDL_GetGamepadSensorDataRate (gamepad , SDL_SENSOR_GYRO ) : 0 ;
1615
- const int SENSOR_UPDATE_INTERVAL_MS = gyro_sensor_rate > 0.0f ? (int )( 1000.0f / gyro_sensor_rate ) : 100 ;
1614
+ const int SENSOR_UPDATE_INTERVAL_MS = 100 ;
1616
1615
Uint64 now = SDL_GetTicks ();
1617
1616
1618
1617
if (now >= ctx -> last_sensor_update + SENSOR_UPDATE_INTERVAL_MS ) {
@@ -1622,6 +1621,7 @@ void RenderGamepadDisplay(GamepadDisplay *ctx, SDL_Gamepad *gamepad)
1622
1621
if (has_gyro ) {
1623
1622
SDL_GetGamepadSensorData (gamepad , SDL_SENSOR_GYRO , ctx -> gyro_data , SDL_arraysize (ctx -> gyro_data ));
1624
1623
}
1624
+ ctx -> last_sensor_update = now ;
1625
1625
}
1626
1626
1627
1627
if (has_accel ) {
@@ -1637,10 +1637,9 @@ void RenderGamepadDisplay(GamepadDisplay *ctx, SDL_Gamepad *gamepad)
1637
1637
SDLTest_DrawString (ctx -> renderer , x + center - SDL_strlen (text ) * FONT_CHARACTER_SIZE , y , text );
1638
1638
SDL_snprintf (text , sizeof (text ), "[%.2f,%.2f,%.2f]%s/s" , ctx -> gyro_data [0 ] * RAD_TO_DEG , ctx -> gyro_data [1 ] * RAD_TO_DEG , ctx -> gyro_data [2 ] * RAD_TO_DEG , DEGREE_UTF8 );
1639
1639
SDLTest_DrawString (ctx -> renderer , x + center + 2.0f , y , text );
1640
-
1641
1640
1642
- /* Display a smoothed version of the above for the sake of turntable tests */
1643
1641
1642
+ /* Display the testcontroller tool's evaluation of drift. This is also useful to get an average rate of turn in calibrated turntable tests. */
1644
1643
if (ctx -> gyro_drift_correction_data [0 ] != 0.0f && ctx -> gyro_drift_correction_data [2 ] != 0.0f && ctx -> gyro_drift_correction_data [2 ] != 0.0f )
1645
1644
{
1646
1645
y += ctx -> button_height + 2.0f ;
@@ -1652,7 +1651,7 @@ void RenderGamepadDisplay(GamepadDisplay *ctx, SDL_Gamepad *gamepad)
1652
1651
1653
1652
}
1654
1653
1655
- ctx -> last_sensor_update = now ;
1654
+
1656
1655
}
1657
1656
}
1658
1657
SDL_free (mapping );
@@ -1782,7 +1781,7 @@ void RenderGyroDriftCalibrationButton(GyroDisplay *ctx, GamepadDisplay *gamepad_
1782
1781
1783
1782
/* Drift progress bar */
1784
1783
/* Demonstrate how far we are through the drift progress, and how it resets when there's "high noise", i.e if flNoiseFraction == 1.0f */
1785
- SDL_FRect progress_bar_rect ;
1784
+ SDL_FRect progress_bar_rect ;
1786
1785
progress_bar_rect .x = recalibrate_button_area .x + BUTTON_PADDING ;
1787
1786
progress_bar_rect .y = recalibrate_button_area .y + recalibrate_button_area .h * 0.5f + BUTTON_PADDING * 0.5f ;
1788
1787
progress_bar_rect .w = recalibrate_button_area .w - BUTTON_PADDING * 2.0f ;
@@ -1798,7 +1797,7 @@ void RenderGyroDriftCalibrationButton(GyroDisplay *ctx, GamepadDisplay *gamepad_
1798
1797
1799
1798
/* Set the color based on the drift calibration progress fraction */
1800
1799
SDL_SetRenderDrawColor (ctx -> renderer , GYRO_COLOR_GREEN ); /* red when too much noise, green when low noise*/
1801
-
1800
+
1802
1801
/* Now draw the bars with the filled, then empty rectangles */
1803
1802
SDL_RenderFillRect (ctx -> renderer , & progress_bar_fill ); /* draw the filled rectangle*/
1804
1803
SDL_SetRenderDrawColor (ctx -> renderer , 100 , 100 , 100 , 255 ); /* gray box*/
@@ -1830,12 +1829,12 @@ float RenderEulerReadout(GyroDisplay *ctx, GamepadDisplay *gamepad_display )
1830
1829
1831
1830
/* Yaw Readout */
1832
1831
log_y += new_line_height ;
1833
- SDL_snprintf (text , sizeof (text ), "Yaw: %6.2f%s" , ctx -> euler_displacement_angles [1 ], DEGREE_UTF8 );
1832
+ SDL_snprintf (text , sizeof (text ), " Yaw: %6.2f%s" , ctx -> euler_displacement_angles [1 ], DEGREE_UTF8 );
1834
1833
SDLTest_DrawString (ctx -> renderer , log_gyro_euler_text_x + 2.0f , log_y , text );
1835
1834
1836
1835
/* Roll Readout */
1837
1836
log_y += new_line_height ;
1838
- SDL_snprintf (text , sizeof (text ), "Roll: %6.2f%s" , ctx -> euler_displacement_angles [2 ], DEGREE_UTF8 );
1837
+ SDL_snprintf (text , sizeof (text ), " Roll: %6.2f%s" , ctx -> euler_displacement_angles [2 ], DEGREE_UTF8 );
1839
1838
SDLTest_DrawString (ctx -> renderer , log_gyro_euler_text_x + 2.0f , log_y , text );
1840
1839
1841
1840
return log_y + new_line_height ; /* Return the next y position for further rendering */
@@ -1907,7 +1906,7 @@ void RenderGyroDisplay(GyroDisplay *ctx, GamepadDisplay *gamepadElements, SDL_Ga
1907
1906
if (bHasCachedDriftSolution ) {
1908
1907
float bottom = RenderEulerReadout (ctx , gamepadElements );
1909
1908
RenderGyroGizmo (ctx , gamepad , bottom );
1910
-
1909
+
1911
1910
}
1912
1911
SDL_SetRenderDrawColor (ctx -> renderer , r , g , b , a );
1913
1912
}
0 commit comments