From f52af83e467c095d8be570b95961c2a08f62e7c8 Mon Sep 17 00:00:00 2001 From: Pheazant Date: Fri, 29 Dec 2023 23:29:45 -0500 Subject: [PATCH] Changed brightness clamping code. --- src/common/gfx.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/gfx.cpp b/src/common/gfx.cpp index fa561df4..d506096b 100644 --- a/src/common/gfx.cpp +++ b/src/common/gfx.cpp @@ -643,7 +643,8 @@ void gfx_setjoystickteamcolor(SDL_Joystick * joystick, unsigned short team, floa { #ifdef USE_SDL2 uint8_t r = 0, g = 0, b = 0; + brightness = max(0.f, min(1.f, brightness)); gfx.getPalette().copyColorSchemeTo(team, 0, 5, r, g, b); - SDL_JoystickSetLED(joystick, std::clamp((int)(brightness * r), 0, 255), std::clamp((int)(brightness * g), 0, 255), std::clamp((int)(brightness * b), 0, 255)); + SDL_JoystickSetLED(joystick, (Uint8)(brightness * r), (Uint8)(brightness * g), (Uint8)(brightness * b)); #endif }