Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Commit

Permalink
Switch to SDL_GameController API and some fix for casting
Browse files Browse the repository at this point in the history
  • Loading branch information
atsb committed Sep 2, 2023
1 parent 80eb747 commit 9d3ccc8
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/SDL/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -3847,7 +3847,7 @@ char* utyGameSystemsPreInit(void)
utySet(SSA_MemoryHeap);
if (memStartup(utyMemoryHeap, MemoryHeapSize, utyGrowthHeapAlloc) != OKAY)
{
sprintf(errorString, "Error starting memory manager with heap size %u at 0x%x", MemoryHeapSize, (unsigned int)utyMemoryHeap);
sprintf(errorString, "Error starting memory manager with heap size %u at 0x%llx", MemoryHeapSize, (uint64_t)utyMemoryHeap);
return(errorString);
}
utySet(SSA_MemoryModule);
Expand Down Expand Up @@ -3948,35 +3948,28 @@ char *utyGameSystemsInit(void)
}
}

#if 0
// Joystick used for controlling the 3D camera view. It can be any old
// joystick but this is primarily intended to support devices used for
// 3D CAD applications which have more degrees of freedom (6) than typical
// joysticks (2). For example: 3Dconnexion's SpaceNavigator.
// http://www.3dconnexion.com/products/3a1d.php
if (!(sdlSubsystemFlags & SDL_INIT_JOYSTICK))
if (!(sdlSubsystemFlags & SDL_INIT_GAMECONTROLLER))
{
int joystick_i = 0;

if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1)
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1)
{
return "Unable to initialize SDL Joystick.";
return "Unable to initialize SDL GameController.";
}

for (joystick_i = 0; joystick_i < SDL_NumJoysticks(); ++joystick_i)
int numGameControllers = SDL_NumJoysticks();

for (int i = 0; i < numGameControllers; ++i)
{
if (strcmp(SDL_JoystickName(joystick_i), "SpaceNavigator") == 0)
if (SDL_IsGameController(i))
{
SDL_Joystick *joystick;

SDL_JoystickEventState(SDL_ENABLE);
joystick = SDL_JoystickOpen(joystick_i);
SDL_GameController *controller = SDL_GameControllerOpen(i);

dbgMessagef("SpaceNavigator found at index %d", joystick_i);
if (controller)
{
dbgMessagef("GameController found at index %d", i);
}
}
}
}
#endif

utyTimerDivisor = 1000 / UTY_TimerResolutionMax;
utySet(SSA_Timer);
Expand Down

0 comments on commit 9d3ccc8

Please sign in to comment.