diff --git a/src/d_main.c b/src/d_main.c index d560427ed..0f0de321c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -37,6 +37,7 @@ #include "d_net.h" #include "f_finale.h" #include "g_game.h" +#include "g_input.h" #include "hu_stuff.h" #include "i_sound.h" #include "i_system.h" @@ -1848,6 +1849,9 @@ void D_SRB2Main(void) CONS_Printf("ST_Init(): Init status bar.\n"); ST_Init(); + if (!dedicated) + G_SetPlayerGamepadIndicatorToPlayerColor(); // no idea where else to throw it lol + // Set up splitscreen players before joining! if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm())) { diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c5156929d..b47ef6618 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -6083,6 +6083,8 @@ static void Color_OnChange(void) CV_StealthSetValue(&cv_playercolor, players[consoleplayer].skincolor); } + + G_SetPlayerGamepadIndicatorToPlayerColor(); } /** Sends a color change for the secondary splitscreen player, unless that diff --git a/src/g_input.c b/src/g_input.c index 536ea0c83..86094fbf8 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -14,11 +14,16 @@ #include "doomdef.h" #include "doomstat.h" #include "g_input.h" +#include "g_game.h" #include "keys.h" #include "hu_stuff.h" // need HUFONT start & end #include "d_net.h" #include "console.h" +#include "i_video.h" +#include "r_draw.h" +#include "v_video.h" + #define MAXMOUSESENSITIVITY 100 // sensitivity steps static CV_PossibleValue_t mousesens_cons_t[] = {{1, "MIN"}, {MAXMOUSESENSITIVITY, "MAX"}, {0, NULL}}; @@ -817,6 +822,20 @@ static const char *gamecontrolname[num_gamecontrols] = #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) +#include "k_kart.h" +// ehhhhhh ill maybe add splitscreen support eventually lol +void G_SetPlayerGamepadIndicatorToPlayerColor(void) +{ + UINT16 skincolor; + byteColor_t byte_color; + + skincolor = cv_playercolor.value; + + byte_color = V_GetColor(colortranslations[skincolor][8]).s; + + I_SetGamepadIndicatorColor(1, byte_color.red, byte_color.green, byte_color.blue); +} + // // Detach any keys associated to the given game control // - pass the pointer to the gamecontrol table for the player being edited diff --git a/src/g_input.h b/src/g_input.h index 635e1f64b..25b1dc119 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -130,6 +130,8 @@ extern INT32 gamecontrol4[num_gamecontrols][2]; // peace to my little coder fingers! // check a gamecontrol being active or not +void G_SetPlayerGamepadIndicatorToPlayerColor(void); + // remaps the input event to a game control. void G_MapEventsToControls(event_t *ev); diff --git a/src/i_video.h b/src/i_video.h index 708fde03c..553e3851a 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -139,6 +139,8 @@ UINT32 I_GetRefreshRate(void); boolean I_UseNativeKeyboard(void); +void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue); + #ifdef USE_FBO_OGL void RefreshOGLSDLSurface(void); void I_DownSample(void); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 3c57a78e0..45fef2509 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1529,6 +1529,23 @@ void I_StartupMouse(void) SDLdoUngrabMouse(); } +void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue) +{ +#if !(SDL_VERSION_ATLEAST(2,0,14)) + (void)device_id; +#else + I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher + + SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); + if (controller == NULL) + { + return; + } + + SDL_GameControllerSetLED(controller, red, green, blue); +#endif +} + // // I_OsPolling //