Skip to content

Commit

Permalink
Changed brightness clamping code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pheazant committed Dec 30, 2023
1 parent df86e92 commit f52af83
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/common/gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit f52af83

Please sign in to comment.