Changes in emu/sdl.c [7cc6ac0:caff491] in buchla-emu


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • emu/sdl.c

    r7cc6ac0 rcaff491  
    1818#include <all.h>
    1919
    20 int32_t sdl_verbose = 0;
     20int32_t sdl_verbose = false;
    2121
    2222#define ver(...) _ver(sdl_verbose, 0, __VA_ARGS__)
    2323#define ver2(...) _ver(sdl_verbose, 1, __VA_ARGS__)
    2424#define ver3(...) _ver(sdl_verbose, 2, __VA_ARGS__)
    25 
    26 typedef void (*sdl_func_t)(void);
    27 
    28 static sdl_func_t sdl_funcs[] = {
    29         ser_sdl
    30 };
    3125
    3226void sdl_init(void)
     
    3832
    3933        SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_VERBOSE);
    40 
    41         if (SDLNet_Init() < 0) {
    42                 fail("SDLNet_Init() failed: %s", SDLNet_GetError());
    43         }
    4434
    4535        if (TTF_Init() < 0) {
     
    5444{
    5545        TTF_Quit();
    56         SDLNet_Quit();
    5746        SDL_Quit();
    5847}
    59 
    60 void sdl_loop(void)
    61 {
    62         inf("entering SDL loop");
    63 
    64 #if defined EMU_LINUX
    65         SDL_Scancode down = SDL_SCANCODE_UNKNOWN;
    66 #endif
    67 
    68         while (SDL_AtomicGet(&run) != 0) {
    69                 for (int32_t i = 0; i < ARRAY_COUNT(sdl_funcs); ++i) {
    70                         sdl_funcs[i]();
    71                 }
    72 
    73                 SDL_Event ev;
    74 
    75                 while (SDL_PollEvent(&ev) > 0) {
    76 #if defined EMU_LINUX
    77                         // Work around duplicate key-down events on Linux.
    78 
    79                         if (ev.type == SDL_KEYDOWN) {
    80                                 if (down == ev.key.keysym.scancode) {
    81                                         continue;
    82                                 }
    83 
    84                                 down = ev.key.keysym.scancode;
    85                         }
    86                         else if (ev.type == SDL_KEYUP) {
    87                                 down = SDL_SCANCODE_UNKNOWN;
    88                         }
    89 #endif
    90 
    91                         if (ev.type == SDL_QUIT ||
    92                                         (ev.type == SDL_KEYDOWN && ev.key.keysym.sym == SDLK_ESCAPE)) {
    93                                 ver("quit");
    94                                 SDL_AtomicSet(&run, 0);
    95                                 continue;
    96                         }
    97 
    98                         if (ev.type == SDL_TEXTINPUT) {
    99                                 ser_text(&ev.text);
    100                                 continue;
    101                         }
    102 
    103                         if (ev.type == SDL_KEYDOWN) {
    104                                 ser_key(&ev.key);
    105                                 continue;
    106                         }
    107 
    108                         SDL_Delay(50);
    109                 }
    110         }
    111 
    112         inf("leaving SDL loop");
    113 }
Note: See TracChangeset for help on using the changeset viewer.