Revert GameController stuff

This commit is contained in:
wolfy852 2018-12-19 13:11:30 -06:00
parent f876a59ad2
commit fc3578c592
2 changed files with 11 additions and 53 deletions

View file

@ -193,12 +193,11 @@ static char returnWadPath[256];
*/ */
static void JoyReset(SDLJoyInfo_t *JoySet) static void JoyReset(SDLJoyInfo_t *JoySet)
{ {
if (JoySet->gamepad) if (JoySet->dev)
SDL_GameControllerClose(JoySet->gamepad); {
else if (JoySet->dev)
SDL_JoystickClose(JoySet->dev); SDL_JoystickClose(JoySet->dev);
}
JoySet->dev = NULL; JoySet->dev = NULL;
JoySet->gamepad = NULL;
JoySet->oldjoy = -1; JoySet->oldjoy = -1;
JoySet->axises = JoySet->buttons = JoySet->hats = JoySet->balls = 0; JoySet->axises = JoySet->buttons = JoySet->hats = JoySet->balls = 0;
//JoySet->scale //JoySet->scale
@ -1052,10 +1051,9 @@ static int joy_open(const char *fname)
{ {
int joyindex = atoi(fname); int joyindex = atoi(fname);
int num_joy = 0; int num_joy = 0;
int num_gc = 0;
int i; int i;
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0) if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
{ {
CONS_Printf(M_GetText("Joystick subsystem not started\n")); CONS_Printf(M_GetText("Joystick subsystem not started\n"));
return -1; return -1;
@ -1075,14 +1073,7 @@ static int joy_open(const char *fname)
{ {
CONS_Printf(M_GetText("Found %d joysticks on this system\n"), num_joy); CONS_Printf(M_GetText("Found %d joysticks on this system\n"), num_joy);
for (i = 0; i < num_joy; i++) for (i = 0; i < num_joy; i++)
{ CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickNameForIndex(i));
if (SDL_IsGameController(i))
{
num_gc++;
CONS_Printf("#%d/(%s) GC\n", i + 1, SDL_GameControllerNameForIndex(i));
}
CONS_Printf("#%d/(%s)\n", i + 1, SDL_JoystickNameForIndex(i));
}
if (num_joy < joyindex) if (num_joy < joyindex)
{ {
@ -1098,15 +1089,8 @@ static int joy_open(const char *fname)
return 0; return 0;
} }
} }
if (SDL_IsGameController(joyindex - 1))
{
JoyInfo.gamepad = SDL_GameControllerOpen(joyindex - 1);
JoyInfo.dev = SDL_GameControllerGetJoystick(JoyInfo.gamepad);
}
else
JoyInfo.dev = SDL_JoystickOpen(joyindex-1);
JoyInfo.guid = SDL_JoystickGetGUID(JoyInfo.dev); JoyInfo.dev = SDL_JoystickOpen(joyindex-1);
if (JoyInfo.dev == NULL) if (JoyInfo.dev == NULL)
{ {
@ -1115,13 +1099,7 @@ static int joy_open(const char *fname)
} }
else else
{ {
if (JoyInfo.gamepad) CONS_Printf(M_GetText("Joystick: %s\n"), SDL_JoystickName(JoyInfo.dev));
{
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); JoyInfo.axises = SDL_JoystickNumAxes(JoyInfo.dev);
if (JoyInfo.axises > JOYAXISSET*2) if (JoyInfo.axises > JOYAXISSET*2)
JoyInfo.axises = JOYAXISSET*2; JoyInfo.axises = JOYAXISSET*2;
@ -1994,10 +1972,10 @@ void I_InitJoystick(void)
if (M_CheckParm("-nojoy")) if (M_CheckParm("-nojoy"))
return; return;
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0) if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
{ {
CONS_Printf("Initing joy system\n"); CONS_Printf("Initing joy system\n");
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1) if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1)
{ {
CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError()); CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError());
return; return;
@ -2090,12 +2068,12 @@ static void I_ShutdownInput(void)
I_ShutdownJoystick(); I_ShutdownJoystick();
I_ShutdownJoystick2(); I_ShutdownJoystick2();
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == SDL_INIT_GAMECONTROLLER) if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
{ {
CONS_Printf("Shutting down joy system\n"); CONS_Printf("Shutting down joy system\n");
JoyReset(&JoyInfo3); JoyReset(&JoyInfo3);
JoyReset(&JoyInfo4); JoyReset(&JoyInfo4);
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
I_OutputMsg("I_Joystick: SDL's Joystick system has been shutdown\n"); I_OutputMsg("I_Joystick: SDL's Joystick system has been shutdown\n");
} }
} }
@ -2108,22 +2086,6 @@ 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)

View file

@ -39,10 +39,6 @@ typedef struct SDLJoyInfo_s
{ {
/// Joystick handle /// Joystick handle
SDL_Joystick *dev; SDL_Joystick *dev;
/// GameController handle
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