mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-28 21:31:04 +00:00
I_NumGameControllers, print GameController mapping, and store joystick GUID in JoyInfo
This commit is contained in:
parent
ca2475ac3e
commit
f876a59ad2
2 changed files with 23 additions and 0 deletions
|
@ -1106,6 +1106,8 @@ static int joy_open(const char *fname)
|
||||||
else
|
else
|
||||||
JoyInfo.dev = SDL_JoystickOpen(joyindex-1);
|
JoyInfo.dev = SDL_JoystickOpen(joyindex-1);
|
||||||
|
|
||||||
|
JoyInfo.guid = SDL_JoystickGetGUID(JoyInfo.dev);
|
||||||
|
|
||||||
if (JoyInfo.dev == NULL)
|
if (JoyInfo.dev == NULL)
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText("Couldn't open joystick: %s\n"), SDL_GetError());
|
CONS_Printf(M_GetText("Couldn't open joystick: %s\n"), SDL_GetError());
|
||||||
|
@ -1114,7 +1116,10 @@ static int joy_open(const char *fname)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (JoyInfo.gamepad)
|
if (JoyInfo.gamepad)
|
||||||
|
{
|
||||||
CONS_Printf(M_GetText("Game Controller: %s\n"), SDL_GameControllerName(JoyInfo.gamepad));
|
CONS_Printf(M_GetText("Game Controller: %s\n"), SDL_GameControllerName(JoyInfo.gamepad));
|
||||||
|
CONS_Printf(M_GetText("Mapping: %s\n"), SDL_GameControllerMapping(JoyInfo.gamepad));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
CONS_Printf(M_GetText("Joystick: %s\n"), SDL_JoystickName(JoyInfo.dev));
|
CONS_Printf(M_GetText("Joystick: %s\n"), SDL_JoystickName(JoyInfo.dev));
|
||||||
JoyInfo.axises = SDL_JoystickNumAxes(JoyInfo.dev);
|
JoyInfo.axises = SDL_JoystickNumAxes(JoyInfo.dev);
|
||||||
|
@ -2103,6 +2108,22 @@ INT32 I_NumJoys(void)
|
||||||
return numjoy;
|
return numjoy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INT32 I_NumGameControllers(void)
|
||||||
|
{
|
||||||
|
INT32 numgc = 0;
|
||||||
|
INT32 numjoy = I_NumJoys();
|
||||||
|
INT32 i;
|
||||||
|
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == SDL_INIT_GAMECONTROLLER)
|
||||||
|
{
|
||||||
|
for (i = 0; i < numjoy; i++)
|
||||||
|
{
|
||||||
|
if (SDL_IsGameController(i))
|
||||||
|
numgc++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return numgc;
|
||||||
|
}
|
||||||
|
|
||||||
static char joyname[255]; // MAX_PATH; joystick name is straight from the driver
|
static char joyname[255]; // MAX_PATH; joystick name is straight from the driver
|
||||||
|
|
||||||
const char *I_GetJoyName(INT32 joyindex)
|
const char *I_GetJoyName(INT32 joyindex)
|
||||||
|
|
|
@ -41,6 +41,8 @@ typedef struct SDLJoyInfo_s
|
||||||
SDL_Joystick *dev;
|
SDL_Joystick *dev;
|
||||||
/// GameController handle
|
/// GameController handle
|
||||||
SDL_GameController *gamepad;
|
SDL_GameController *gamepad;
|
||||||
|
/// Joystick GUID
|
||||||
|
SDL_JoystickGUID guid;
|
||||||
/// number of old joystick
|
/// number of old joystick
|
||||||
int oldjoy;
|
int oldjoy;
|
||||||
/// number of axies
|
/// number of axies
|
||||||
|
|
Loading…
Reference in a new issue