From f9cde1397635a3bb0808939b63744e39412f0e00 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Tue, 28 May 2024 17:57:47 +0200 Subject: [PATCH] rumble --- GameControllerHandler.cpp | 9 +++++++++ GameControllerHandler.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/GameControllerHandler.cpp b/GameControllerHandler.cpp index e95b907..c1e93b1 100644 --- a/GameControllerHandler.cpp +++ b/GameControllerHandler.cpp @@ -39,6 +39,8 @@ void GameControllerHandler::handleMessage(const std::string &message) { if (tokens[1] == "all" || tokens[1] == "gc") { if (tokens[2] == "stop proximity") { + if (!this->rumble) return; + std::vector args = Modelec::split(tokens[3], ","); double distance = stod(args[0]); Uint16 strength; @@ -60,6 +62,13 @@ void GameControllerHandler::handleMessage(const std::string &message) { if (tokens[2] == "ready") { this->sendMessage("gc;all;game mode;gc\n"); } + + if (tokens[2] == "start proximity") { + this->rumble = true; + } + else if (tokens[2] == "stop proximity") { + this->rumble = false; + } } } diff --git a/GameControllerHandler.h b/GameControllerHandler.h index ca3da2a..fe12126 100644 --- a/GameControllerHandler.h +++ b/GameControllerHandler.h @@ -28,4 +28,6 @@ private: SDL_GameController* controller; double lidarDectectionDistance = 0; + + bool rumble = true; };