Controller-gen should only return valid controllers.
This commit is contained in:
parent
0808fcb676
commit
3b4458caa8
1 changed files with 11 additions and 5 deletions
|
@ -7,7 +7,9 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
SDL_Init(SDL_INIT_JOYSTICK);
|
||||
|
||||
SDL_GameControllerAddMappingsFromFile("/storage/.config/SDL-GameControllerDB/gamecontrollerdb.txt");
|
||||
SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
|
||||
atexit(SDL_Quit);
|
||||
|
||||
int num_joysticks = SDL_NumJoysticks();
|
||||
|
@ -18,13 +20,17 @@ int main()
|
|||
if (js)
|
||||
{
|
||||
SDL_JoystickGUID guid = SDL_JoystickGetGUID(js);
|
||||
bool is_controller = SDL_IsGameController(i);
|
||||
|
||||
char guid_str[1024];
|
||||
SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str));
|
||||
const char* name = SDL_JoystickName(js);
|
||||
|
||||
printf("controlfolder=\"/storage/.config/gptokeyb\"\nESUDO=\"sudo\"\nESUDOKILL=\"-sudokill\"\nexport SDL_GAMECONTROLLERCONFIG_FILE=\"$controlfolder/gamecontrollerdb.txt\"\nSDLDBFILE=\"${SDL_GAMECONTROLLERCONFIG_FILE}\"\n[ -z \"${SDLDBFILE}\" ] && SDLDBFILE=\"${controlfolder}/gamecontrollerdb.txt\"\nSDLDBUSERFILE=\"/storage/.config/SDL-GameControllerDB/gamecontrollerdb.txt\"\nget_controls() {\nANALOGSTICKS=\"2\"\nDEVICE=\"%s\"\nparam_device=\"%s\"\n}\nGPTOKEYB=\"$controlfolder/gptokeyb $ESUDOKILL\"",
|
||||
guid_str, name);
|
||||
if (is_controller)
|
||||
{
|
||||
const char* name = SDL_JoystickName(js);
|
||||
|
||||
printf("controlfolder=\"/storage/.config/gptokeyb\"\nESUDO=\"sudo\"\nESUDOKILL=\"-sudokill\"\nexport SDL_GAMECONTROLLERCONFIG_FILE=\"$controlfolder/gamecontrollerdb.txt\"\nSDLDBFILE=\"${SDL_GAMECONTROLLERCONFIG_FILE}\"\n[ -z \"${SDLDBFILE}\" ] && SDLDBFILE=\"${controlfolder}/gamecontrollerdb.txt\"\nSDLDBUSERFILE=\"/storage/.config/SDL-GameControllerDB/gamecontrollerdb.txt\"\nget_controls() {\nANALOGSTICKS=\"2\"\nDEVICE=\"%s\"\nparam_device=\"%s\"\n}\nGPTOKEYB=\"$controlfolder/gptokeyb $ESUDOKILL\"",
|
||||
guid_str, name);
|
||||
}
|
||||
SDL_JoystickClose(js);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue