mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
# Conflicts: # libs/SDL2/COPYING.txt # libs/SDL2/WhatsNew.txt # libs/SDL2/docs/README-android.md # libs/SDL2/docs/README-linux.md # libs/SDL2/i686-w64-mingw32/bin/SDL2.dll # libs/SDL2/i686-w64-mingw32/bin/sdl2-config # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_assert.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_atomic.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_audio.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_bits.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_blendmode.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_clipboard.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_config.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_cpuinfo.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_egl.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_endian.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_error.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_events.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_filesystem.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gamecontroller.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gesture.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_haptic.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_hints.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_joystick.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keyboard.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keycode.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_loadso.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_log.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_main.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_messagebox.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mouse.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mutex.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_name.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengl.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles2.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_pixels.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_platform.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_power.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_quit.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rect.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_render.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_revision.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rwops.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_scancode.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_sensor.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_shape.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_stdinc.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_surface.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_system.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_syswm.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_assert.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_common.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_compare.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_crc32.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_font.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_fuzzer.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_harness.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_images.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_log.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_md5.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_memory.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_random.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_thread.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_timer.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_touch.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_types.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_version.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_video.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_vulkan.h # libs/SDL2/i686-w64-mingw32/include/SDL2/begin_code.h # libs/SDL2/i686-w64-mingw32/include/SDL2/close_code.h # libs/SDL2/i686-w64-mingw32/lib/libSDL2.a # libs/SDL2/i686-w64-mingw32/lib/libSDL2.dll.a # libs/SDL2/i686-w64-mingw32/lib/libSDL2.la # libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.a # libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.la # libs/SDL2/i686-w64-mingw32/lib/libSDL2main.a # libs/SDL2/i686-w64-mingw32/lib/libSDL2main.la # libs/SDL2/i686-w64-mingw32/lib/pkgconfig/sdl2.pc # libs/SDL2/test/Makefile.in # libs/SDL2/test/Makefile.os2 # libs/SDL2/test/checkkeys.c # libs/SDL2/test/configure.ac # libs/SDL2/test/controllermap.c # libs/SDL2/test/loopwave.c # libs/SDL2/test/loopwavequeue.c # libs/SDL2/test/testatomic.c # libs/SDL2/test/testaudiocapture.c # libs/SDL2/test/testaudiohotplug.c # libs/SDL2/test/testaudioinfo.c # libs/SDL2/test/testautomation.c # libs/SDL2/test/testbounds.c # libs/SDL2/test/testcustomcursor.c # libs/SDL2/test/testdisplayinfo.c # libs/SDL2/test/testdraw2.c # libs/SDL2/test/testdrawchessboard.c # libs/SDL2/test/testdropfile.c # libs/SDL2/test/testerror.c # libs/SDL2/test/testfile.c # libs/SDL2/test/testfilesystem.c # libs/SDL2/test/testgamecontroller.c # libs/SDL2/test/testgesture.c # libs/SDL2/test/testgl2.c # libs/SDL2/test/testgles.c # libs/SDL2/test/testgles2.c # libs/SDL2/test/testhotplug.c # libs/SDL2/test/testiconv.c # libs/SDL2/test/testime.c # libs/SDL2/test/testintersections.c # libs/SDL2/test/testjoystick.c # libs/SDL2/test/testkeys.c # libs/SDL2/test/testloadso.c # libs/SDL2/test/testlock.c # libs/SDL2/test/testmessage.c # libs/SDL2/test/testmultiaudio.c # libs/SDL2/test/testnative.c # libs/SDL2/test/testnative.h # libs/SDL2/test/testnativew32.c # libs/SDL2/test/testnativex11.c # libs/SDL2/test/testoverlay2.c # libs/SDL2/test/testplatform.c # libs/SDL2/test/testpower.c # libs/SDL2/test/testqsort.c # libs/SDL2/test/testrelative.c # libs/SDL2/test/testrendercopyex.c # libs/SDL2/test/testrendertarget.c # libs/SDL2/test/testresample.c # libs/SDL2/test/testrumble.c # libs/SDL2/test/testscale.c # libs/SDL2/test/testsem.c # libs/SDL2/test/testsensor.c # libs/SDL2/test/testshader.c # libs/SDL2/test/testshape.c # libs/SDL2/test/testsprite2.c # libs/SDL2/test/testspriteminimal.c # libs/SDL2/test/teststreaming.c # libs/SDL2/test/testthread.c # libs/SDL2/test/testtimer.c # libs/SDL2/test/testver.c # libs/SDL2/test/testviewport.c # libs/SDL2/test/testvulkan.c # libs/SDL2/test/testwm2.c # libs/SDL2/test/testyuv.c # libs/SDL2/test/testyuv_cvt.c # libs/SDL2/test/testyuv_cvt.h # libs/SDL2/test/torturethread.c # libs/SDL2/x86_64-w64-mingw32/bin/SDL2.dll # libs/SDL2/x86_64-w64-mingw32/bin/sdl2-config # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_assert.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_atomic.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_audio.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_bits.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_blendmode.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_clipboard.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_config.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_cpuinfo.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_egl.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_endian.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_error.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_events.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_filesystem.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gamecontroller.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gesture.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_haptic.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_hints.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_joystick.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keyboard.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keycode.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_loadso.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_log.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_main.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_messagebox.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mouse.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mutex.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_name.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengl.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles2.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_pixels.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_platform.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_power.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_quit.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rect.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_render.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_revision.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rwops.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_scancode.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_sensor.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_shape.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_stdinc.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_surface.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_system.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_syswm.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_assert.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_common.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_compare.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_crc32.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_font.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_fuzzer.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_harness.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_images.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_log.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_md5.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_memory.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_random.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_thread.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_timer.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_touch.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_types.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_version.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_video.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_vulkan.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/begin_code.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/close_code.h # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.a # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.dll.a # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.la # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.a # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.la # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.a # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.la # libs/SDL2/x86_64-w64-mingw32/lib/pkgconfig/sdl2.pc
258 lines
6.5 KiB
C
258 lines
6.5 KiB
C
/*
|
|
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
warranty. In no event will the authors be held liable for any damages
|
|
arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
including commercial applications, and to alter it and redistribute it
|
|
freely.
|
|
*/
|
|
|
|
/* Simple program: Loop, watching keystrokes
|
|
Note that you need to call SDL_PollEvent() or SDL_WaitEvent() to
|
|
pump the event loop and catch keystrokes.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#ifdef __EMSCRIPTEN__
|
|
#include <emscripten/emscripten.h>
|
|
#endif
|
|
|
|
#include "SDL.h"
|
|
|
|
int done;
|
|
|
|
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
|
static void
|
|
quit(int rc)
|
|
{
|
|
SDL_Quit();
|
|
exit(rc);
|
|
}
|
|
|
|
static void
|
|
print_string(char **text, size_t *maxlen, const char *fmt, ...)
|
|
{
|
|
int len;
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
len = SDL_vsnprintf(*text, *maxlen, fmt, ap);
|
|
if (len > 0) {
|
|
*text += len;
|
|
if ( ((size_t) len) < *maxlen ) {
|
|
*maxlen -= (size_t) len;
|
|
} else {
|
|
*maxlen = 0;
|
|
}
|
|
}
|
|
va_end(ap);
|
|
}
|
|
|
|
static void
|
|
print_modifiers(char **text, size_t *maxlen)
|
|
{
|
|
int mod;
|
|
print_string(text, maxlen, " modifiers:");
|
|
mod = SDL_GetModState();
|
|
if (!mod) {
|
|
print_string(text, maxlen, " (none)");
|
|
return;
|
|
}
|
|
if (mod & KMOD_LSHIFT)
|
|
print_string(text, maxlen, " LSHIFT");
|
|
if (mod & KMOD_RSHIFT)
|
|
print_string(text, maxlen, " RSHIFT");
|
|
if (mod & KMOD_LCTRL)
|
|
print_string(text, maxlen, " LCTRL");
|
|
if (mod & KMOD_RCTRL)
|
|
print_string(text, maxlen, " RCTRL");
|
|
if (mod & KMOD_LALT)
|
|
print_string(text, maxlen, " LALT");
|
|
if (mod & KMOD_RALT)
|
|
print_string(text, maxlen, " RALT");
|
|
if (mod & KMOD_LGUI)
|
|
print_string(text, maxlen, " LGUI");
|
|
if (mod & KMOD_RGUI)
|
|
print_string(text, maxlen, " RGUI");
|
|
if (mod & KMOD_NUM)
|
|
print_string(text, maxlen, " NUM");
|
|
if (mod & KMOD_CAPS)
|
|
print_string(text, maxlen, " CAPS");
|
|
if (mod & KMOD_MODE)
|
|
print_string(text, maxlen, " MODE");
|
|
if (mod & KMOD_SCROLL)
|
|
print_string(text, maxlen, " SCROLL");
|
|
}
|
|
|
|
static void
|
|
PrintModifierState()
|
|
{
|
|
char message[512];
|
|
char *spot;
|
|
size_t left;
|
|
|
|
spot = message;
|
|
left = sizeof(message);
|
|
|
|
print_modifiers(&spot, &left);
|
|
SDL_Log("Initial state:%s\n", message);
|
|
}
|
|
|
|
static void
|
|
PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
|
|
{
|
|
char message[512];
|
|
char *spot;
|
|
size_t left;
|
|
|
|
spot = message;
|
|
left = sizeof(message);
|
|
|
|
/* Print the keycode, name and state */
|
|
if (sym->sym) {
|
|
print_string(&spot, &left,
|
|
"Key %s: scancode %d = %s, keycode 0x%08X = %s ",
|
|
pressed ? "pressed " : "released",
|
|
sym->scancode,
|
|
SDL_GetScancodeName(sym->scancode),
|
|
sym->sym, SDL_GetKeyName(sym->sym));
|
|
} else {
|
|
print_string(&spot, &left,
|
|
"Unknown Key (scancode %d = %s) %s ",
|
|
sym->scancode,
|
|
SDL_GetScancodeName(sym->scancode),
|
|
pressed ? "pressed " : "released");
|
|
}
|
|
print_modifiers(&spot, &left);
|
|
if (repeat) {
|
|
print_string(&spot, &left, " (repeat)");
|
|
}
|
|
SDL_Log("%s\n", message);
|
|
}
|
|
|
|
static void
|
|
PrintText(const char *eventtype, const char *text)
|
|
{
|
|
const char *spot;
|
|
char expanded[1024];
|
|
|
|
expanded[0] = '\0';
|
|
for ( spot = text; *spot; ++spot )
|
|
{
|
|
size_t length = SDL_strlen(expanded);
|
|
SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot);
|
|
}
|
|
SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text);
|
|
}
|
|
|
|
void
|
|
loop()
|
|
{
|
|
SDL_Event event;
|
|
/* Check for events */
|
|
/*SDL_WaitEvent(&event); emscripten does not like waiting*/
|
|
|
|
while (SDL_PollEvent(&event)) {
|
|
switch (event.type) {
|
|
case SDL_KEYDOWN:
|
|
case SDL_KEYUP:
|
|
PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
|
|
break;
|
|
case SDL_TEXTEDITING:
|
|
PrintText("EDIT", event.text.text);
|
|
break;
|
|
case SDL_TEXTINPUT:
|
|
PrintText("INPUT", event.text.text);
|
|
break;
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
/* Left button quits the app, other buttons toggles text input */
|
|
if (event.button.button == SDL_BUTTON_LEFT) {
|
|
done = 1;
|
|
} else {
|
|
if (SDL_IsTextInputActive()) {
|
|
SDL_Log("Stopping text input\n");
|
|
SDL_StopTextInput();
|
|
} else {
|
|
SDL_Log("Starting text input\n");
|
|
SDL_StartTextInput();
|
|
}
|
|
}
|
|
break;
|
|
case SDL_QUIT:
|
|
done = 1;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
#ifdef __EMSCRIPTEN__
|
|
if (done) {
|
|
emscripten_cancel_main_loop();
|
|
}
|
|
#endif
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
SDL_Window *window;
|
|
SDL_Renderer *renderer;
|
|
|
|
/* Enable standard application logging */
|
|
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
|
|
|
/* Initialize SDL */
|
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
|
return (1);
|
|
}
|
|
|
|
/* Set 640x480 video mode */
|
|
window = SDL_CreateWindow("CheckKeys Test",
|
|
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
|
640, 480, 0);
|
|
if (!window) {
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n",
|
|
SDL_GetError());
|
|
quit(2);
|
|
}
|
|
|
|
/* On wayland, no window will actually show until something has
|
|
actually been displayed.
|
|
*/
|
|
renderer = SDL_CreateRenderer(window, -1, 0);
|
|
SDL_RenderPresent(renderer);
|
|
|
|
#if __IPHONEOS__
|
|
/* Creating the context creates the view, which we need to show keyboard */
|
|
SDL_GL_CreateContext(window);
|
|
#endif
|
|
|
|
SDL_StartTextInput();
|
|
|
|
/* Print initial modifier state */
|
|
SDL_PumpEvents();
|
|
PrintModifierState();
|
|
|
|
/* Watch keystrokes */
|
|
done = 0;
|
|
|
|
#ifdef __EMSCRIPTEN__
|
|
emscripten_set_main_loop(loop, 0, 1);
|
|
#else
|
|
while (!done) {
|
|
loop();
|
|
}
|
|
#endif
|
|
|
|
SDL_Quit();
|
|
return (0);
|
|
}
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|