ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/SDL/video_sdl.cpp
(Generate patch)

Comparing BasiliskII/src/SDL/video_sdl.cpp (file contents):
Revision 1.1 by gbeauche, 2004-06-23T13:47:20Z vs.
Revision 1.2 by gbeauche, 2004-06-23T22:37:33Z

# Line 32 | Line 32
32   *  - Force relative mode in Grab mode even if SDL provides absolute coordinates?
33   *  - Fullscreen mode
34   *  - Gamma tables support is likely to be broken here
35 + *  - Events processing is bound to the general emulation thread as SDL requires
36 + *    to PumpEvents() within the same thread as the one that called SetVideoMode().
37 + *    Besides, there can't seem to be a way to call SetVideoMode() from a child thread.
38   */
39  
40   #include "sysdeps.h"
# Line 102 | Line 105 | static int keycode_table[256];                                         // X
105   static int screen_depth;                                                        // Depth of current screen
106   static SDL_Color sdl_palette[256];                                      // Color palette to be used as CLUT and gamma table
107   static bool sdl_palette_changed = false;                        // Flag: Palette changed, redraw thread must set new colors
108 + static const int sdl_eventmask = SDL_MOUSEBUTTONDOWNMASK | SDL_MOUSEBUTTONUPMASK | SDL_MOUSEMOTIONMASK | SDL_KEYUPMASK | SDL_KEYDOWNMASK | SDL_VIDEOEXPOSEMASK | SDL_QUITMASK;
109  
110   // Mutex to protect palette
111   static SDL_mutex *sdl_palette_lock = NULL;
# Line 799 | Line 803 | void VideoQuitFullScreen(void)
803  
804   void VideoInterrupt(void)
805   {
806 +        // We must fill in the events queue in the same thread that did call SDL_SetVideoMode()
807 +        SDL_PumpEvents();
808 +
809          // Emergency quit requested? Then quit
810          if (emerg_quit)
811                  QuitEmulator();
# Line 1021 | Line 1028 | static int event2keycode(SDL_KeyboardEve
1028  
1029   static void handle_events(void)
1030   {
1031 <        SDL_Event event;
1032 <        while (SDL_PollEvent(&event)) {
1033 <                switch (event.type) {
1031 >        SDL_Event events[10];
1032 >        const int n_max_events = sizeof(events) / sizeof(events[0]);
1033 >        int n_events;
1034 >
1035 >        while ((n_events = SDL_PeepEvents(events, n_max_events, SDL_GETEVENT, sdl_eventmask)) > 0) {
1036 >                for (int i = 0; i < n_events; i++) {
1037 >                        SDL_Event const & event = events[i];
1038 >                        switch (event.type) {
1039  
1040                          // Mouse button
1041                          case SDL_MOUSEBUTTONDOWN: {
# Line 1123 | Line 1135 | static void handle_events(void)
1135                                  ADBKeyDown(0x7f);       // Power key
1136                                  ADBKeyUp(0x7f);
1137                                  break;
1138 +                        }
1139                  }
1140          }
1141   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines