mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 21:01: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
|
||||
JoyInfo.dev = SDL_JoystickOpen(joyindex-1);
|
||||
|
||||
JoyInfo.guid = SDL_JoystickGetGUID(JoyInfo.dev);
|
||||
|
||||
if (JoyInfo.dev == NULL)
|
||||
{
|
||||
CONS_Printf(M_GetText("Couldn't open joystick: %s\n"), SDL_GetError());
|
||||
|
@ -1114,7 +1116,10 @@ static int joy_open(const char *fname)
|
|||
else
|
||||
{
|
||||
if (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
|
||||
CONS_Printf(M_GetText("Joystick: %s\n"), SDL_JoystickName(JoyInfo.dev));
|
||||
JoyInfo.axises = SDL_JoystickNumAxes(JoyInfo.dev);
|
||||
|
@ -2103,6 +2108,22 @@ INT32 I_NumJoys(void)
|
|||
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
|
||||
|
||||
const char *I_GetJoyName(INT32 joyindex)
|
||||
|
|
|
@ -41,6 +41,8 @@ typedef struct SDLJoyInfo_s
|
|||
SDL_Joystick *dev;
|
||||
/// GameController handle
|
||||
SDL_GameController *gamepad;
|
||||
/// Joystick GUID
|
||||
SDL_JoystickGUID guid;
|
||||
/// number of old joystick
|
||||
int oldjoy;
|
||||
/// number of axies
|
||||
|
|
Loading…
Reference in a new issue