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

Function main

deps/SDL2/Xcode-iOS/Demos/src/keyboard.c:213–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213int
214main(int argc, char *argv[])
215{
216 SDL_Window *window;
217 SDL_Event event; /* last event received */
218 SDL_Scancode scancode; /* scancode of last key we pushed */
219 int width;
220 int height;
221 int done;
222 SDL_Rect textrect;
223
224 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
225 printf("Error initializing SDL: %s", SDL_GetError());
226 }
227 /* create window */
228 window = SDL_CreateWindow("iOS keyboard test", 0, 0, 0, 0, SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
229 /* create renderer */
230 renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
231
232 SDL_GetWindowSize(window, &width, &height);
233 SDL_RenderSetLogicalSize(renderer, width, height);
234
235 /* load up our font */
236 loadFont();
237
238 /* Show onscreen keyboard */
239#ifdef TEST_INPUT_RECT
240 textrect.x = 0;
241 textrect.y = height - GLYPH_SIZE_IMAGE;
242 textrect.w = width;
243 textrect.h = GLYPH_SIZE_IMAGE;
244 SDL_SetTextInputRect(&textrect);
245#endif
246 SDL_StartTextInput();
247
248 done = 0;
249 while (!done) {
250 while (SDL_PollEvent(&event)) {
251 switch (event.type) {
252 case SDL_QUIT:
253 done = 1;
254 break;
255 case SDL_WINDOWEVENT:
256 if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
257 width = event.window.data1;
258 height = event.window.data2;
259 SDL_RenderSetLogicalSize(renderer, width, height);
260#ifdef TEST_INPUT_RECT
261 textrect.x = 0;
262 textrect.y = height - GLYPH_SIZE_IMAGE;
263 textrect.w = width;
264 textrect.h = GLYPH_SIZE_IMAGE;
265 SDL_SetTextInputRect(&textrect);
266#endif
267 }
268 break;
269 case SDL_KEYDOWN:
270 if (event.key.keysym.scancode == SDL_SCANCODE_BACKSPACE) {

Callers

nothing calls this directly

Calls 15

SDL_InitFunction · 0.85
SDL_GetErrorFunction · 0.85
SDL_CreateWindowFunction · 0.85
SDL_CreateRendererFunction · 0.85
SDL_GetWindowSizeFunction · 0.85
SDL_RenderSetLogicalSizeFunction · 0.85
loadFontFunction · 0.85
SDL_SetTextInputRectFunction · 0.85
SDL_StartTextInputFunction · 0.85
SDL_PollEventFunction · 0.85
keyToGlyphIndexFunction · 0.85
SDL_IsTextInputActiveFunction · 0.85

Tested by

no test coverage detected