#ifndef NO_SDL #include "SDL.h" #endif /* return ascii key value or -1 */ int u8g_sdl_get_key(void) { #ifndef NO_SDL SDL_Event event; /* http://www.libsdl.org/cgi/docwiki.cgi/SDL_PollEvent */ if ( SDL_PollEvent(&event) != 0 ) { switch (event.type) { case SDL_QUIT: exit(0); break; case SDL_KEYDOWN: switch( event.key.keysym.sym ) { /* /usr/include/SDL/SDL_keysym.h */ case SDLK_a: return 'a'; case SDLK_b: return 'b'; case SDLK_c: return 'c'; case SDLK_d: return 'd'; case SDLK_e: return 'e'; case SDLK_f: return 'f'; case SDLK_g: return 'g'; case SDLK_h: return 'h'; case SDLK_i: return 'i'; case SDLK_j: return 'j'; case SDLK_k: return 'k'; case SDLK_l: return 'l'; case SDLK_m: return 'm'; case SDLK_n: return 'n'; case SDLK_o: return 'o'; case SDLK_p: return 'p'; case SDLK_q: return 'q'; case SDLK_r: return 'r'; case SDLK_s: return 's'; case SDLK_t: return 't'; case SDLK_u: return 'u'; case SDLK_v: return 'v'; case SDLK_w: return 'w'; case SDLK_x: return 'x'; case SDLK_y: return 'y'; case SDLK_z: return 'z'; case SDLK_SPACE: return ' '; case SDLK_UP: return 273; case SDLK_DOWN: return 274; case SDLK_RIGHT: return 275; case SDLK_LEFT: return 276; default: return 0; } } } #endif return -1; }