Skip to content

Commit

Permalink
Merge pull request #577 from wheremyfoodat/hle-dsp
Browse files Browse the repository at this point in the history
Optimize gyro calculation
  • Loading branch information
wheremyfoodat authored Aug 14, 2024
2 parents 16cac4c + ff7e0f9 commit e756815
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions include/sdl_gyro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
namespace Gyro::SDL {
// Convert the rotation data we get from SDL sensor events to rotation data we can feed right to HID
// Returns [pitch, roll, yaw]
static glm::vec3 convertRotation(glm::vec3 rotation) {
// Flip axes
glm::vec3 ret = -rotation;
// Convert from radians/s to deg/s and scale by the gyroscope coefficient from the HID service
ret *= 180.f / std::numbers::pi;
ret *= HIDService::gyroscopeCoeff;

return ret;
static glm::vec3 convertRotation(glm::vec3 rotation) {
// Convert the rotation from rad/s to deg/s and scale by the gyroscope coefficient in HID
constexpr float scale = 180.f / std::numbers::pi * HIDService::gyroscopeCoeff;
// The axes are also inverted, so invert scale before the multiplication.
return rotation * -scale;
}
} // namespace Gyro::SDL

0 comments on commit e756815

Please sign in to comment.