static int window_flags;
#endif
static SDL_Surface *vid_softsurface;
+static vid_mode_t desktop_mode;
/////////////////////////
// Input handling
}
#endif
-static keynum_t buttonremap[18] =
+static keynum_t buttonremap[] =
{
K_MOUSE1,
K_MOUSE3,
K_MOUSE2,
+#if SDL_MAJOR_VERSION == 1
+ // TODO Find out how SDL maps these buttons. It looks like we should
+ // still include these for sdl2? At least the button indexes don't
+ // differ between SDL1 and SDL2 for me, thus this array should stay the
+ // same (in X11 button order).
K_MWHEELUP,
K_MWHEELDOWN,
+#endif
K_MOUSE4,
K_MOUSE5,
K_MOUSE6,
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
if (!vid_touchscreen.integer)
- if (event.button.button <= 18)
+ if (event.button.button > 0 && event.button.button <= ARRAY_SIZE(buttonremap))
Key_Event( buttonremap[event.button.button - 1], 0, event.button.state == SDL_PRESSED );
break;
case SDL_JOYBUTTONDOWN:
{
SDL_FreeSurface(vid_softsurface);
vid_softsurface = SDL_CreateRGBSurface(SDL_SWSURFACE, vid.width, vid.height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
- vid.softpixels = (unsigned int *)vid_softsurface->pixels;
SDL_SetAlpha(vid_softsurface, 0, 255);
+ vid.softpixels = (unsigned int *)vid_softsurface->pixels;
if (vid.softdepthpixels)
free(vid.softdepthpixels);
vid.softdepthpixels = (unsigned int*)calloc(1, vid.width * vid.height * 4);
Con_DPrintf("SDL_Event: SDL_MOUSEBUTTONUP\n");
#endif
if (!vid_touchscreen.integer)
- if (event.button.button <= 18)
+ if (event.button.button > 0 && event.button.button <= ARRAY_SIZE(buttonremap))
Key_Event( buttonremap[event.button.button - 1], 0, event.button.state == SDL_PRESSED );
break;
+ case SDL_MOUSEWHEEL:
+ // TODO support wheel x direction.
+ i = event.wheel.y;
+ while (i > 0) {
+ --i;
+ Key_Event( K_MWHEELUP, 0, true );
+ Key_Event( K_MWHEELUP, 0, false );
+ }
+ while (i < 0) {
+ ++i;
+ Key_Event( K_MWHEELDOWN, 0, true );
+ Key_Event( K_MWHEELDOWN, 0, false );
+ }
+ break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
case SDL_JOYAXISMOTION:
{
SDL_FreeSurface(vid_softsurface);
vid_softsurface = SDL_CreateRGBSurface(SDL_SWSURFACE, vid.width, vid.height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
+ SDL_SetSurfaceBlendMode(vid_softsurface, SDL_BLENDMODE_NONE);
vid.softpixels = (unsigned int *)vid_softsurface->pixels;
if (vid.softdepthpixels)
free(vid.softdepthpixels);
// Knghtbrd: should do platform-specific extension string function here
vid_isfullscreen = false;
- if (mode->fullscreen) {
#if SDL_MAJOR_VERSION == 1
- SDL_VideoInfo *vi = SDL_GetVideoInfo();
- mode->width = vi->current_w;
- mode->height = vi->current_h;
- mode->bitsperpixel = vi->vfmt->BitsPerPixel;
- flags |= SDL_FULLSCREEN;
+ {
+ const SDL_VideoInfo *vi = SDL_GetVideoInfo();
+ desktop_mode.width = vi->current_w;
+ desktop_mode.height = vi->current_h;
+ desktop_mode.bpp = vi->vfmt->BitsPerPixel;
+ desktop_mode.pixelheight_num = 1;
+ desktop_mode.pixelheight_denom = 1; // SDL does not provide this
+ if (mode->fullscreen) {
+ if (vid_desktopfullscreen.integer)
+ {
+ mode->width = vi->current_w;
+ mode->height = vi->current_h;
+ mode->bitsperpixel = vi->vfmt->BitsPerPixel;
+ }
+ flags |= SDL_FULLSCREEN;
+ vid_isfullscreen = true;
+ }
+ }
#else
- if (vid_desktopfullscreen.integer)
- windowflags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
- else
- windowflags |= SDL_WINDOW_FULLSCREEN;
-#endif
- vid_isfullscreen = true;
+ {
+ if (mode->fullscreen) {
+ if (vid_desktopfullscreen.integer)
+ windowflags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
+ else
+ windowflags |= SDL_WINDOW_FULLSCREEN;
+ vid_isfullscreen = true;
+ }
}
+#endif
//flags |= SDL_HWSURFACE;
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
vid_isfullscreen = false;
if (mode->fullscreen) {
#if SDL_MAJOR_VERSION == 1
- SDL_VideoInfo *vi = SDL_GetVideoInfo();
+ const SDL_VideoInfo *vi = SDL_GetVideoInfo();
mode->width = vi->current_w;
mode->height = vi->current_h;
mode->bitsperpixel = vi->vfmt->BitsPerPixel;
}
#if SDL_MAJOR_VERSION == 1
SDL_SetAlpha(vid_softsurface, 0, 255);
+#else
+ SDL_SetSurfaceBlendMode(vid_softsurface, SDL_BLENDMODE_NONE);
#endif
vid.softpixels = (unsigned int *)vid_softsurface->pixels;
}
}
+vid_mode_t *VID_GetDesktopMode(void)
+{
+#if SDL_MAJOR_VERSION != 1
+ SDL_DisplayMode mode;
+ int bpp;
+ Uint32 rmask, gmask, bmask, amask;
+ SDL_GetDesktopDisplayMode(0, &mode);
+ SDL_PixelFormatEnumToMasks(mode.format, &bpp, &rmask, &gmask, &bmask, &amask);
+ desktop_mode.width = mode.w;
+ desktop_mode.height = mode.h;
+ desktop_mode.bpp = bpp;
+ desktop_mode.refreshrate = mode.refresh_rate;
+ desktop_mode.pixelheight_num = 1;
+ desktop_mode.pixelheight_denom = 1; // SDL does not provide this
+ // TODO check whether this actually works, or whether we do still need
+ // a read-window-size-after-entering-desktop-fullscreen hack for
+ // multiscreen setups.
+#endif
+ return &desktop_mode;
+}
+
size_t VID_ListModes(vid_mode_t *modes, size_t maxcount)
{
size_t k = 0;
continue;
modes[k].width = mode.w;
modes[k].height = mode.h;
+ // FIXME bpp?
modes[k].refreshrate = mode.refresh_rate;
modes[k].pixelheight_num = 1;
- modes[k].pixelheight_num = 1;
modes[k].pixelheight_denom = 1; // SDL does not provide this
k++;
}