From a78c51ac14cc80d83b8d0efada5578f54346a818 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Wed, 15 May 2024 16:00:40 +0200 Subject: [PATCH] rumble --- GameControllerHandler.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/GameControllerHandler.h b/GameControllerHandler.h index 48abd63..44d50f5 100644 --- a/GameControllerHandler.h +++ b/GameControllerHandler.h @@ -42,9 +42,17 @@ public: if (tokens[2] == "stop proximity") { std::vector args = Utils::split(tokens[3], ","); int distance = stoi(args[0]); + double angle = stod(args[1]); + Uint16 strength = 0xFFFF; if (distance < 200) { + // Ajuster la force en fonction de la distance strength = static_cast((200 - distance) * 0xFFFF / 200); + + // Ajuster la force en fonction de l'angle + // Plus l'angle s'éloigne de 0, plus la force sera forte + double angleFactor = std::abs(std::sin(angle)); // L'angle est fourni en radians + strength *= angleFactor; } if (SDL_GameControllerRumble(controller, strength, strength, 1000) != 0) {