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

Function loop

deps/SDL2/test/checkkeys.c:151–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151void
152loop()
153{
154 SDL_Event event;
155 /* Check for events */
156 /*SDL_WaitEvent(&event); emscripten does not like waiting*/
157
158 while (SDL_PollEvent(&event)) {
159 switch (event.type) {
160 case SDL_KEYDOWN:
161 case SDL_KEYUP:
162 PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
163 break;
164 case SDL_TEXTEDITING:
165 PrintText("EDIT", event.text.text);
166 break;
167 case SDL_TEXTINPUT:
168 PrintText("INPUT", event.text.text);
169 break;
170 case SDL_MOUSEBUTTONDOWN:
171 /* Left button quits the app, other buttons toggles text input */
172 if (event.button.button == SDL_BUTTON_LEFT) {
173 done = 1;
174 } else {
175 if (SDL_IsTextInputActive()) {
176 SDL_Log("Stopping text input\n");
177 SDL_StopTextInput();
178 } else {
179 SDL_Log("Starting text input\n");
180 SDL_StartTextInput();
181 }
182 }
183 break;
184 case SDL_QUIT:
185 done = 1;
186 break;
187 default:
188 break;
189 }
190 }
191#ifdef __EMSCRIPTEN__
192 if (done) {
193 emscripten_cancel_main_loop();
194 }
195#endif
196}
197
198int
199main(int argc, char *argv[])

Callers 1

mainFunction · 0.70

Calls 7

SDL_PollEventFunction · 0.85
PrintKeyFunction · 0.85
PrintTextFunction · 0.85
SDL_IsTextInputActiveFunction · 0.85
SDL_LogFunction · 0.85
SDL_StopTextInputFunction · 0.85
SDL_StartTextInputFunction · 0.85

Tested by

no test coverage detected