From dedf11fdeba8621e939a9d1d8f4c99c42c737a12 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 21 Apr 2026 19:22:28 -0700 Subject: [PATCH] Cleanly shutdown aurora::input by telling all registered controllers to stop their rumble motors (#132) --- lib/aurora.cpp | 1 + lib/input.cpp | 10 ++++++++++ lib/input.hpp | 2 ++ 3 files changed, 13 insertions(+) diff --git a/lib/aurora.cpp b/lib/aurora.cpp index bf5904e..9151195 100644 --- a/lib/aurora.cpp +++ b/lib/aurora.cpp @@ -201,6 +201,7 @@ void shutdown() noexcept { gfx::shutdown(); webgpu::shutdown(); #endif + input::shutdown(); window::shutdown(); } diff --git a/lib/input.cpp b/lib/input.cpp index 9e46a0a..dbf70e1 100644 --- a/lib/input.cpp +++ b/lib/input.cpp @@ -156,4 +156,14 @@ void get_mouse_scroll(float* scrollX, float* scrollY) noexcept { *scrollY = g_MouseStatus.scrollY; } +void shutdown() noexcept { + // Upon shutdown we want to ensure all controllers are in a default state, so force all rumble supporting controllers + // to shut off their rumble motors. + for (const auto& controller : g_GameControllers) { + if (!controller.second.m_hasRumble) { + continue; + } + controller_rumble(controller.first, 0, 0, 0); + } +} } // namespace aurora::input diff --git a/lib/input.hpp b/lib/input.hpp index 2305262..edf9c95 100644 --- a/lib/input.hpp +++ b/lib/input.hpp @@ -56,4 +56,6 @@ extern absl::flat_hash_map g_GameControllers; void set_mouse_scroll(float scrollX, float scrollY) noexcept; void get_mouse_scroll(float* scrollX, float* scrollY) noexcept; + +void shutdown() noexcept; } // namespace aurora::input