}
#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);
vid_isfullscreen = false;
#if SDL_MAJOR_VERSION == 1
{
- SDL_VideoInfo *vi = SDL_GetVideoInfo();
+ const SDL_VideoInfo *vi = SDL_GetVideoInfo();
desktop_mode.width = vi->current_w;
desktop_mode.height = vi->current_h;
desktop_mode.bpp = vi->vfmt->BitsPerPixel;
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;
Uint32 rmask, gmask, bmask, amask;
SDL_GetDesktopDisplayMode(0, &mode);
SDL_PixelFormatEnumToMasks(mode.format, &bpp, &rmask, &gmask, &bmask, &amask);
- modes[k].width = mode.w;
- modes[k].height = mode.h;
- modes[k].bpp = bpp;
- modes[k].refreshrate = mode.refreshrate;
- modes[k].pixelheight_num = 1;
- modes[k].pixelheight_denom = 1; // SDL does not provide this
+ 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;
}