MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / SDL_GameControllerClose

Function SDL_GameControllerClose

deps/SDL2/src/joystick/SDL_gamecontroller.c:1947–1987  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1945}
1946
1947void
1948SDL_GameControllerClose(SDL_GameController * gamecontroller)
1949{
1950 SDL_GameController *gamecontrollerlist, *gamecontrollerlistprev;
1951
1952 if (!gamecontroller)
1953 return;
1954
1955 SDL_LockJoysticks();
1956
1957 /* First decrement ref count */
1958 if (--gamecontroller->ref_count > 0) {
1959 SDL_UnlockJoysticks();
1960 return;
1961 }
1962
1963 SDL_JoystickClose(gamecontroller->joystick);
1964
1965 gamecontrollerlist = SDL_gamecontrollers;
1966 gamecontrollerlistprev = NULL;
1967 while (gamecontrollerlist) {
1968 if (gamecontroller == gamecontrollerlist) {
1969 if (gamecontrollerlistprev) {
1970 /* unlink this entry */
1971 gamecontrollerlistprev->next = gamecontrollerlist->next;
1972 } else {
1973 SDL_gamecontrollers = gamecontroller->next;
1974 }
1975 break;
1976 }
1977 gamecontrollerlistprev = gamecontrollerlist;
1978 gamecontrollerlist = gamecontrollerlist->next;
1979 }
1980
1981 SDL_free(gamecontroller->bindings);
1982 SDL_free(gamecontroller->last_match_axis);
1983 SDL_free(gamecontroller->last_hat_mask);
1984 SDL_free(gamecontroller);
1985
1986 SDL_UnlockJoysticks();
1987}
1988
1989
1990/*

Callers 2

mainFunction · 0.85
SDL_GameControllerQuitFunction · 0.85

Calls 4

SDL_LockJoysticksFunction · 0.85
SDL_UnlockJoysticksFunction · 0.85
SDL_JoystickCloseFunction · 0.85
SDL_freeFunction · 0.85

Tested by 1

mainFunction · 0.68