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

Function SDLTest_CommonEvent

deps/SDL2/src/test/SDL_test_common.c:1578–1907  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1576}
1577
1578void
1579SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done)
1580{
1581 int i;
1582 static SDL_MouseMotionEvent lastEvent;
1583
1584 if (state->verbose & VERBOSE_EVENT) {
1585 SDLTest_PrintEvent(event);
1586 }
1587
1588 switch (event->type) {
1589 case SDL_WINDOWEVENT:
1590 switch (event->window.event) {
1591 case SDL_WINDOWEVENT_CLOSE:
1592 {
1593 SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
1594 if (window) {
1595 for (i = 0; i < state->num_windows; ++i) {
1596 if (window == state->windows[i]) {
1597 if (state->targets[i]) {
1598 SDL_DestroyTexture(state->targets[i]);
1599 state->targets[i] = NULL;
1600 }
1601 if (state->renderers[i]) {
1602 SDL_DestroyRenderer(state->renderers[i]);
1603 state->renderers[i] = NULL;
1604 }
1605 SDL_DestroyWindow(state->windows[i]);
1606 state->windows[i] = NULL;
1607 break;
1608 }
1609 }
1610 }
1611 }
1612 break;
1613 }
1614 break;
1615 case SDL_KEYDOWN: {
1616 SDL_bool withControl = !!(event->key.keysym.mod & KMOD_CTRL);
1617 SDL_bool withShift = !!(event->key.keysym.mod & KMOD_SHIFT);
1618 SDL_bool withAlt = !!(event->key.keysym.mod & KMOD_ALT);
1619
1620 switch (event->key.keysym.sym) {
1621 /* Add hotkeys here */
1622 case SDLK_PRINTSCREEN: {
1623 SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
1624 if (window) {
1625 for (i = 0; i < state->num_windows; ++i) {
1626 if (window == state->windows[i]) {
1627 SDLTest_ScreenShot(state->renderers[i]);
1628 }
1629 }
1630 }
1631 }
1632 break;
1633 case SDLK_EQUALS:
1634 if (withControl) {
1635 /* Ctrl-+ double the size of the window */

Callers 15

loopFunction · 0.85
loopFunction · 0.85
loopFunction · 0.85
loopFunction · 0.85
loopFunction · 0.85
loopFunction · 0.85
loopFunction · 0.85
loopFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
loopFunction · 0.85
mainFunction · 0.85

Calls 15

SDLTest_PrintEventFunction · 0.85
SDL_GetWindowFromIDFunction · 0.85
SDL_DestroyTextureFunction · 0.85
SDL_DestroyRendererFunction · 0.85
SDL_DestroyWindowFunction · 0.85
SDLTest_ScreenShotFunction · 0.85
SDL_GetWindowSizeFunction · 0.85
SDL_SetWindowSizeFunction · 0.85
SDL_GetNumVideoDisplaysFunction · 0.85
SDL_LogFunction · 0.85
SDL_SetWindowPositionFunction · 0.85

Tested by

no test coverage detected