From 3097c14a24dc9c9d218a790724c44c1d0f1ec464 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 30 Jun 2006 05:42:49 +0000 Subject: [PATCH] Cleaned up a bunch of warnings, started adding Win32 event support --- include/SDL_config_win32.h | 13 ++----- include/SDL_video.h | 12 +++++++ src/SDL_compat.c | 11 +++--- src/audio/SDL_mixer_MMX_VC.c | 55 +++++++++++++++++++++-------- src/events/SDL_events_c.h | 5 --- src/events/SDL_keyboard.c | 2 -- src/events/SDL_keyboard_c.h | 3 ++ src/events/SDL_mouse.c | 5 +-- src/events/SDL_windowevents_c.h | 34 ++++++++++++++++++ src/video/SDL_blit_A.c | 8 +++-- src/video/SDL_renderer_sw.c | 8 ++--- src/video/SDL_surface.c | 1 - src/video/SDL_sysvideo.h | 11 +++--- src/video/SDL_video.c | 24 +++++-------- src/video/dummy/SDL_nullrender.c | 3 +- src/video/dummy/SDL_nullvideo.c | 11 ++---- src/video/dummy/SDL_nullvideo.h | 11 ------ src/video/win32/SDL_win32keyboard.c | 38 ++++++++++++++++++++ src/video/win32/SDL_win32keyboard.h | 31 ++++++++++++++++ src/video/win32/SDL_win32mouse.c | 38 ++++++++++++++++++++ src/video/win32/SDL_win32mouse.h | 31 ++++++++++++++++ src/video/win32/SDL_win32video.c | 16 +++++---- src/video/win32/SDL_win32video.h | 8 +++-- src/video/win32/SDL_win32window.c | 8 +++-- src/video/win32/SDL_win32window.h | 2 +- 25 files changed, 283 insertions(+), 106 deletions(-) create mode 100644 src/events/SDL_windowevents_c.h create mode 100644 src/video/win32/SDL_win32keyboard.c create mode 100644 src/video/win32/SDL_win32keyboard.h create mode 100644 src/video/win32/SDL_win32mouse.c create mode 100644 src/video/win32/SDL_win32mouse.h diff --git a/include/SDL_config_win32.h b/include/SDL_config_win32.h index 487a228cd..4fbf7dc27 100644 --- a/include/SDL_config_win32.h +++ b/include/SDL_config_win32.h @@ -133,7 +133,7 @@ typedef unsigned int uintptr_t; #ifdef _WIN32_WCE #define SDL_JOYSTICK_DISABLED 1 #else -#define SDL_JOYSTICK_DINPUT 1 +#define SDL_JOYSTICK_WINMM 1 #endif /* Enable various shared object loading systems */ @@ -150,17 +150,8 @@ typedef unsigned int uintptr_t; #endif /* Enable various video drivers */ -#ifdef _WIN32_WCE -#define SDL_VIDEO_DRIVER_GAPI 1 -#endif -#ifndef _WIN32_WCE -#define SDL_VIDEO_DRIVER_DDRAW 1 -#endif #define SDL_VIDEO_DRIVER_DUMMY 1 -#ifndef _WIN32_WCE -#define SDL_VIDEO_DRIVER_GLSDL 1 -#endif -#define SDL_VIDEO_DRIVER_WINDIB 1 +#define SDL_VIDEO_DRIVER_WIN32 1 /* Enable OpenGL support */ #ifndef _WIN32_WCE diff --git a/include/SDL_video.h b/include/SDL_video.h index ce03db1a3..2dcf07e2b 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -717,6 +717,18 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_WindowID windowID, */ extern DECLSPEC int SDLCALL SDL_GetWindowGrab(SDL_WindowID windowID); +/** + * \fn SDL_bool SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo * info) + * + * \brief Get driver specific information about a window. + * + * \note Include SDL_syswm.h for the declaration of SDL_SysWMinfo. + */ +struct SDL_SysWMinfo; +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_WindowID windowID, + struct SDL_SysWMinfo + *info); + /** * \fn void SDL_DestroyWindow(SDL_WindowID windowID) * diff --git a/src/SDL_compat.c b/src/SDL_compat.c index 8ebdcd257..04ec3e89a 100644 --- a/src/SDL_compat.c +++ b/src/SDL_compat.c @@ -26,6 +26,7 @@ #include "SDL.h" #include "SDL_syswm.h" +#include "video/SDL_sysvideo.h" #include "video/SDL_pixels_c.h" @@ -94,7 +95,7 @@ SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) if (!mode->format) { return bpp; } - if (SDL_BITSPERPIXEL(mode->format) >= bpp) { + if (SDL_BITSPERPIXEL(mode->format) >= (Uint32) bpp) { actual_bpp = SDL_BITSPERPIXEL(mode->format); } } @@ -118,6 +119,7 @@ SDL_ListModes(SDL_PixelFormat * format, Uint32 flags) /* Memory leak, but this is a compatibility function, who cares? */ nmodes = 0; + modes = NULL; for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { const SDL_DisplayMode *mode = SDL_GetDisplayMode(i); if (!mode->w || !mode->h) { @@ -243,6 +245,7 @@ SDL_VideoPaletteChanged(void *userdata, SDL_Palette * palette) if (userdata == SDL_VideoSurface) { return SDL_SetDisplayPalette(palette->colors, 0, palette->ncolors); } + return 0; } SDL_Surface * @@ -251,11 +254,9 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) int (*filter) (SDL_Event * event); const SDL_DisplayMode *desktop_mode; SDL_DisplayMode mode; - int i; Uint32 window_flags; Uint32 desktop_format; Uint32 desired_format; - Uint32 texture_format; Uint32 surface_flags; if (!SDL_GetVideoDevice()) { @@ -641,6 +642,7 @@ int SDL_WM_IconifyWindow(void) { SDL_MinimizeWindow(SDL_VideoWindow); + return 0; } int @@ -695,7 +697,7 @@ int SDL_SetPalette(SDL_Surface * surface, int flags, const SDL_Color * colors, int firstcolor, int ncolors) { - SDL_SetColors(surface, colors, firstcolor, ncolors); + return SDL_SetColors(surface, colors, firstcolor, ncolors); } int @@ -1333,6 +1335,7 @@ SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect) return -1; } SDL_RenderPresent(); + return 0; } void diff --git a/src/audio/SDL_mixer_MMX_VC.c b/src/audio/SDL_mixer_MMX_VC.c index ad2726af6..203b21f9b 100644 --- a/src/audio/SDL_mixer_MMX_VC.c +++ b/src/audio/SDL_mixer_MMX_VC.c @@ -40,14 +40,19 @@ void SDL_MixAudio_MMX_S16_VC(char *dst, char *src, unsigned int nSize, int volume) { + /* *INDENT-OFF* */ __asm { - - push edi push esi push ebx mov edi, dst // edi = dst + push edi + push esi + push ebx + mov edi, dst // edi = dst mov esi, src // esi = src mov eax, volume // eax = volume mov ebx, nSize // ebx = size shr ebx, 4 // process 16 bytes per iteration = 8 samples - jz endS16 pxor mm0, mm0 movd mm0, eax //%%eax,%%mm0 + jz endS16 + pxor mm0, mm0 + movd mm0, eax //%%eax,%%mm0 movq mm1, mm0 //%%mm0,%%mm1 psllq mm0, 16 //$16,%%mm0 por mm0, mm1 //%%mm1,%%mm0 @@ -58,13 +63,14 @@ SDL_MixAudio_MMX_S16_VC(char *dst, char *src, unsigned int nSize, int volume) #ifndef __WATCOMC__ align 16 #endif - mixloopS16:movq mm1,[esi] //(%%esi),%%mm1\n" // mm1 = a|b|c|d - movq mm2, mm1 //%%mm1,%%mm2\n" // mm2 = a|b|c|d + mixloopS16: + movq mm1,[esi] //(%%esi),%%mm1\n" // mm1 = a|b|c|d + movq mm2, mm1 //%%mm1,%%mm2\n" // mm2 = a|b|c|d movq mm4,[esi + 8] //8(%%esi),%%mm4\n" // mm4 = e|f|g|h // pre charger le buffer dst dans mm7 - movq mm7,[edi] //(%%edi),%%mm7\n" // mm7 = dst[0]" + movq mm7,[edi] //(%%edi),%%mm7\n" // mm7 = dst[0]" // multiplier par le volume - pmullw mm1, mm0 //%%mm0,%%mm1\n" // mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) + pmullw mm1, mm0 //%%mm0,%%mm1\n" // mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) pmulhw mm2, mm0 //%%mm0,%%mm2\n" // mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v) movq mm5, mm4 //%%mm4,%%mm5\n" // mm5 = e|f|g|h pmullw mm4, mm0 //%%mm0,%%mm4\n" // mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v) @@ -78,7 +84,7 @@ SDL_MixAudio_MMX_S16_VC(char *dst, char *src, unsigned int nSize, int volume) // pre charger le buffer dst dans mm5 movq mm5,[edi + 8] //8(%%edi),%%mm5\n" // mm5 = dst[1] // diviser par 128 - psrad mm1, 7 //$7,%%mm1\n" // mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME + psrad mm1, 7 //$7,%%mm1\n" // mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME add esi, 16 //$16,%%esi\n" psrad mm3, 7 //$7,%%mm3\n" // mm3 = c*v/128|d*v/128 psrad mm4, 7 //$7,%%mm4\n" // mm4 = e*v/128|f*v/128 @@ -93,8 +99,14 @@ SDL_MixAudio_MMX_S16_VC(char *dst, char *src, unsigned int nSize, int volume) movq[edi + 8], mm6 //%%mm6,8(%%edi)\n" add edi, 16 //$16,%%edi\n" dec ebx //%%ebx\n" - jnz mixloopS16 ends16:emms pop ebx pop esi pop edi} - + jnz mixloopS16 + ends16: + emms + pop ebx + pop esi + pop edi + } + /* *INDENT-ON* */ } //////////////////////////////////////////////// @@ -104,9 +116,13 @@ SDL_MixAudio_MMX_S16_VC(char *dst, char *src, unsigned int nSize, int volume) void SDL_MixAudio_MMX_S8_VC(char *dst, char *src, unsigned int nSize, int volume) { + /* *INDENT-OFF* */ _asm { - push edi push esi push ebx mov edi, dst //movl %0,%%edi // edi = dst + push edi + push esi + push ebx + mov edi, dst //%0,%%edi // edi = dst mov esi, src //%1,%%esi // esi = src mov eax, volume //%3,%%eax // eax = volume movd mm0, eax //%%eax,%%mm0 @@ -124,15 +140,16 @@ SDL_MixAudio_MMX_S8_VC(char *dst, char *src, unsigned int nSize, int volume) #ifndef __WATCOMC__ align 16 #endif - mixloopS8:pxor mm2, mm2 //%%mm2,%%mm2 // mm2 = 0 + mixloopS8: + pxor mm2, mm2 //%%mm2,%%mm2 // mm2 = 0 movq mm1,[esi] //(%%esi),%%mm1 // mm1 = a|b|c|d|e|f|g|h - movq mm3, mm1 //%%mm1,%%mm3 // mm3 = a|b|c|d|e|f|g|h + movq mm3, mm1 //%%mm1,%%mm3 // mm3 = a|b|c|d|e|f|g|h // on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0 pcmpgtb mm2, mm1 //%%mm1,%%mm2 // mm2 = 11111111|00000000|00000000.... punpckhbw mm1, mm2 //%%mm2,%%mm1 // mm1 = 0|a|0|b|0|c|0|d punpcklbw mm3, mm2 //%%mm2,%%mm3 // mm3 = 0|e|0|f|0|g|0|h movq mm2,[edi] //(%%edi),%%mm2 // mm2 = destination - pmullw mm1, mm0 //%%mm0,%%mm1 // mm1 = v*a|v*b|v*c|v*d + pmullw mm1, mm0 //%%mm0,%%mm1 // mm1 = v*a|v*b|v*c|v*d add esi, 8 //$8,%%esi pmullw mm3, mm0 //%%mm0,%%mm3 // mm3 = v*e|v*f|v*g|v*h psraw mm1, 7 //$7,%%mm1 // mm1 = v*a/128|v*b/128|v*c/128|v*d/128 @@ -142,8 +159,16 @@ SDL_MixAudio_MMX_S8_VC(char *dst, char *src, unsigned int nSize, int volume) movq[edi], mm3 //%%mm3,(%%edi) // store back to ram add edi, 8 //$8,%%edi dec ebx //%%ebx - jnz mixloopS8 endS8:emms pop ebx pop esi pop edi} + jnz mixloopS8 + endS8: + emms + pop ebx + pop esi + pop edi + } + /* *INDENT-ON* */ } #endif /* SDL_ASSEMBLY_ROUTINES */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/events/SDL_events_c.h b/src/events/SDL_events_c.h index 37fd34eee..65ea64738 100644 --- a/src/events/SDL_events_c.h +++ b/src/events/SDL_events_c.h @@ -39,11 +39,6 @@ extern int SDL_QuitInit(void); extern int SDL_SendQuit(void); extern void SDL_QuitQuit(void); -extern int SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent, - int data1, int data2); - -extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message); - /* The event filter function */ extern SDL_EventFilter SDL_EventOK; diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index c79104dab..686698cb3 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -291,8 +291,6 @@ int SDL_AddKeyboard(const SDL_Keyboard * keyboard, int index) { SDL_Keyboard **keyboards; - SDL_Cursor *cursor; - int selected_keyboard; /* Add the keyboard to the list of keyboards */ if (index < 0 || index >= SDL_num_keyboards || SDL_keyboards[index]) { diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h index af4a20bcb..d0baa4403 100644 --- a/src/events/SDL_keyboard_c.h +++ b/src/events/SDL_keyboard_c.h @@ -24,6 +24,9 @@ #ifndef _SDL_keyboard_c_h #define _SDL_keyboard_c_h +#include "SDL_keysym.h" +#include "SDL_events.h" + typedef struct SDL_Keyboard SDL_Keyboard; struct SDL_Keyboard diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 9e3dee9d4..d01af5cb7 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -53,7 +53,6 @@ int SDL_AddMouse(const SDL_Mouse * mouse, int index) { SDL_Mouse **mice; - SDL_Cursor *cursor; int selected_mouse; /* Add the mouse to the list of mice */ @@ -398,9 +397,7 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, return NULL; } for (y = 0; y < h; ++y) { - pixel = - (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch + - x * 4); + pixel = (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch); for (x = 0; x < w; ++x) { if ((x % 8) == 0) { datab = *data++; diff --git a/src/events/SDL_windowevents_c.h b/src/events/SDL_windowevents_c.h new file mode 100644 index 000000000..dfd2ed8a7 --- /dev/null +++ b/src/events/SDL_windowevents_c.h @@ -0,0 +1,34 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_windowevents_c_h +#define _SDL_windowevents_c_h + +extern int SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent, + int data1, int data2); + +extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message); + +#endif /* _SDL_windowevents_c_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index fe6df5fb0..0ab05eeda 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -617,7 +617,9 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) __m64 src1, dst1, mm_alpha, mm_zero, dmask; mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ - multmask = ~(0xFFFFi 64 << (ashift * 2)); + /* *INDENT-OFF* */ + multmask = ~(0xFFFFI64 << (ashift * 2)); + /* *INDENT-ON* */ dmask = *(__m64 *) & multmask; /* dst alpha mask -> dmask */ while (height--) { @@ -1753,7 +1755,9 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) __m64 src1, dst1, mm_alpha, mm_zero, dmask; mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ - multmask = ~(0xFFFFi 64 << (ashift * 2)); + /* *INDENT-OFF* */ + multmask = ~(0xFFFFI64 << (ashift * 2)); + /* *INDENT-ON* */ dmask = *(__m64 *) & multmask; /* dst alpha mask -> dmask */ while (height--) { diff --git a/src/video/SDL_renderer_sw.c b/src/video/SDL_renderer_sw.c index e6f57846c..6dbf24fc1 100644 --- a/src/video/SDL_renderer_sw.c +++ b/src/video/SDL_renderer_sw.c @@ -54,8 +54,8 @@ static void SDL_SW_DirtyTexture(SDL_Renderer * renderer, const SDL_Rect * rects); static void SDL_SW_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static void SDL_SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 color); +static int SDL_SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 color); static int SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_Rect * dstrect, int blendMode, @@ -355,7 +355,7 @@ SDL_SW_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture) } } -static void +static int SDL_SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 color) { @@ -369,7 +369,7 @@ SDL_SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, b = (Uint8) (color & 0xFF); color = SDL_MapRGBA(data->target->format, r, g, b, a); - SDL_FillRect(data->target, &real_rect, color); + return SDL_FillRect(data->target, &real_rect, color); } static int diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index c029605b0..2fe1622f0 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -39,7 +39,6 @@ SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { - SDL_Surface *screen; SDL_Surface *surface; /* FIXME!! */ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 941cdd244..b74719836 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -25,9 +25,6 @@ #define _SDL_sysvideo_h #include "SDL_mouse.h" -#define SDL_PROTOTYPES_ONLY -#include "SDL_syswm.h" -#undef SDL_PROTOTYPES_ONLY /* The SDL video driver */ @@ -78,8 +75,8 @@ struct SDL_Renderer int numrects, const SDL_Rect * rects); void (*SelectRenderTexture) (SDL_Renderer * renderer, SDL_Texture * texture); - void (*RenderFill) (SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 color); + int (*RenderFill) (SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 color); int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_Rect * dstrect, int blendMode, int scaleMode); @@ -208,7 +205,7 @@ struct SDL_VideoDevice /* Get some platform dependent window information */ SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window, - SDL_SysWMinfo * info); + struct SDL_SysWMinfo * info); /* Reverse the effects VideoInit() -- called if VideoInit() fails or if the application is shutting down the video subsystem. @@ -300,7 +297,7 @@ struct SDL_VideoDevice /* * * */ /* Data private to this driver */ - struct SDL_PrivateVideoData *hidden; + void *driverdata; struct SDL_PrivateGLData *gl_data; /* * * */ diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index f64119790..10a9a9289 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -177,8 +177,6 @@ SDL_VideoInit(const char *driver_name, Uint32 flags) SDL_VideoDevice *video; int index; int i; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; /* Toggle the event thread flags, based on OS requirements */ #if defined(MUST_THREAD_EVENTS) @@ -524,7 +522,7 @@ SDL_SetDisplayMode(const SDL_DisplayMode * mode) { SDL_VideoDisplay *display; SDL_DisplayMode display_mode; - int i, ncolors; + int ncolors; if (!_this) { SDL_SetError("Video subsystem has not been initialized"); @@ -600,14 +598,13 @@ SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors) SDL_SetError("Video subsystem has not been initialized"); return -1; } - if (!SDL_CurrentDisplay.palette) { + palette = SDL_CurrentDisplay.palette; + if (!palette) { SDL_SetError("Display mode does not have a palette"); return -1; } - status = - SDL_SetPaletteColors(SDL_CurrentDisplay.palette, colors, firstcolor, - ncolors); + status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors); if (_this->SetDisplayPalette) { if (_this->SetDisplayPalette(_this, palette) < 0) { @@ -1222,7 +1219,6 @@ SDL_CreateTextureFromSurface(Uint32 format, int access, SDL_Surface * surface) SDL_TextureID textureID; Uint32 surface_flags = surface->flags; SDL_PixelFormat *fmt = surface->format; - Uint32 colorkey; Uint8 alpha; SDL_Rect bounds; SDL_Surface dst; @@ -1328,10 +1324,6 @@ SDL_CreateTextureFromSurface(Uint32 format, int access, SDL_Surface * surface) SDL_LowerBlit(surface, &bounds, &dst, &bounds); /* Clean up the original surface */ - if ((surface_flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - Uint32 cflags = surface_flags & (SDL_SRCCOLORKEY | SDL_RLEACCELOK); - SDL_SetColorKey(surface, cflags, colorkey); - } if ((surface_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { Uint32 aflags = surface_flags & (SDL_SRCALPHA | SDL_RLEACCELOK); if (fmt->Amask) { @@ -1524,7 +1516,7 @@ SDL_UnlockTexture(SDL_TextureID textureID) if (!renderer->UnlockTexture) { return; } - return renderer->UnlockTexture(renderer, texture); + renderer->UnlockTexture(renderer, texture); } void @@ -1585,7 +1577,7 @@ SDL_RenderFill(const SDL_Rect * rect, Uint32 color) rect = &full_rect; } - renderer->RenderFill(renderer, rect, color); + return renderer->RenderFill(renderer, rect, color); } int @@ -1598,7 +1590,7 @@ SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, SDL_Rect full_dstrect; if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) { - return; + return -1; } renderer = SDL_CurrentDisplay.current_renderer; @@ -2042,7 +2034,7 @@ SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask) #endif SDL_bool -SDL_GetWindowWMInfo(SDL_WindowID windowID, SDL_SysWMinfo * info) +SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo *info) { SDL_Window *window = SDL_GetWindowFromID(windowID); diff --git a/src/video/dummy/SDL_nullrender.c b/src/video/dummy/SDL_nullrender.c index ee6badebd..fb8d0592d 100644 --- a/src/video/dummy/SDL_nullrender.c +++ b/src/video/dummy/SDL_nullrender.c @@ -50,7 +50,7 @@ SDL_RenderDriver SDL_DUMMY_RenderDriver = { SDL_TextureBlendMode_None, SDL_TextureScaleMode_None, 0, - {}, + {0}, 0, 0} }; @@ -67,7 +67,6 @@ SDL_DUMMY_CreateRenderer(SDL_Window * window, Uint32 flags) SDL_DisplayMode *displayMode = &display->current_mode; SDL_Renderer *renderer; SDL_DUMMY_RenderData *data; - int i, n; int bpp; Uint32 Rmask, Gmask, Bmask, Amask; diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index 03cf894cd..721ddf6b4 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -69,7 +69,6 @@ DUMMY_Available(void) static void DUMMY_DeleteDevice(SDL_VideoDevice * device) { - SDL_free(device->hidden); SDL_free(device); } @@ -79,20 +78,14 @@ DUMMY_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); - if (device) { - SDL_memset(device, 0, (sizeof *device)); - device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc((sizeof *device->hidden)); - } - if ((device == NULL) || (device->hidden == NULL)) { + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { SDL_OutOfMemory(); if (device) { SDL_free(device); } return (0); } - SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = DUMMY_VideoInit; diff --git a/src/video/dummy/SDL_nullvideo.h b/src/video/dummy/SDL_nullvideo.h index b597a5dc1..378ad29f6 100644 --- a/src/video/dummy/SDL_nullvideo.h +++ b/src/video/dummy/SDL_nullvideo.h @@ -26,17 +26,6 @@ #include "../SDL_sysvideo.h" -/* Hidden "this" pointer for the video functions */ -#define _THIS SDL_VideoDevice *_this - - -/* Private display data */ - -struct SDL_PrivateVideoData -{ - int unused; -}; - #endif /* _SDL_nullvideo_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32keyboard.c b/src/video/win32/SDL_win32keyboard.c new file mode 100644 index 000000000..a383b259d --- /dev/null +++ b/src/video/win32/SDL_win32keyboard.c @@ -0,0 +1,38 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_win32video.h" + +#include "../../events/SDL_keyboard_c.h" + +void +WIN_AddKeyboard(_THIS) +{ + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_Keyboard keyboard; + + SDL_zero(keyboard); + data->keyboard = SDL_AddKeyboard(&keyboard, -1); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32keyboard.h b/src/video/win32/SDL_win32keyboard.h new file mode 100644 index 000000000..232ba8a10 --- /dev/null +++ b/src/video/win32/SDL_win32keyboard.h @@ -0,0 +1,31 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_win32keyboard_h +#define _SDL_win32keyboard_h + +extern void WIN_AddKeyboard(_THIS); + +#endif /* _SDL_win32keyboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32mouse.c b/src/video/win32/SDL_win32mouse.c new file mode 100644 index 000000000..d4c268edb --- /dev/null +++ b/src/video/win32/SDL_win32mouse.c @@ -0,0 +1,38 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_win32video.h" + +#include "../../events/SDL_mouse_c.h" + +void +WIN_AddMouse(_THIS) +{ + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + SDL_Mouse mouse; + + SDL_zero(mouse); + data->mouse = SDL_AddMouse(&mouse, -1); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32mouse.h b/src/video/win32/SDL_win32mouse.h new file mode 100644 index 000000000..1a79fe85e --- /dev/null +++ b/src/video/win32/SDL_win32mouse.h @@ -0,0 +1,31 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_win32mouse_h +#define _SDL_win32mouse_h + +extern void WIN_AddMouse(_THIS); + +#endif /* _SDL_win32mouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32video.c b/src/video/win32/SDL_win32video.c index a230fb5b0..5c2fe35e3 100644 --- a/src/video/win32/SDL_win32video.c +++ b/src/video/win32/SDL_win32video.c @@ -21,6 +21,7 @@ */ #include "SDL_config.h" +#include "SDL_main.h" #include "SDL_video.h" #include "SDL_mouse.h" #include "../SDL_sysvideo.h" @@ -47,7 +48,7 @@ static void WIN_DeleteDevice(SDL_VideoDevice * device) { SDL_UnregisterApp(); - SDL_free(device->hidden); + SDL_free(device->driverdata); SDL_free(device); } @@ -59,20 +60,18 @@ WIN_CreateDevice(int devindex) SDL_RegisterApp(NULL, 0, NULL); /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device) { - SDL_memset(device, 0, (sizeof *device)); - device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc((sizeof *device->hidden)); + device->driverdata = + (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); } - if ((device == NULL) || (device->hidden == NULL)) { + if (!device || !device->driverdata) { SDL_OutOfMemory(); if (device) { SDL_free(device); } return NULL; } - SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = WIN_VideoInit; @@ -118,6 +117,9 @@ WIN_VideoInit(_THIS) SDL_zero(mode); SDL_AddDisplayMode(0, &mode); + WIN_AddKeyboard(_this); + WIN_AddMouse(_this); + /* We're done! */ return 0; } diff --git a/src/video/win32/SDL_win32video.h b/src/video/win32/SDL_win32video.h index 17272a6ff..3bebc5ed2 100644 --- a/src/video/win32/SDL_win32video.h +++ b/src/video/win32/SDL_win32video.h @@ -31,6 +31,8 @@ #include #include "SDL_win32events.h" +#include "SDL_win32keyboard.h" +#include "SDL_win32mouse.h" #include "SDL_win32window.h" #ifdef UNICODE @@ -43,9 +45,11 @@ /* Private display data */ -struct SDL_PrivateVideoData +typedef struct { -}; + int mouse; + int keyboard; +} SDL_VideoData; #endif /* _SDL_win32video_h */ diff --git a/src/video/win32/SDL_win32window.c b/src/video/win32/SDL_win32window.c index ec5f55b66..773bad14f 100644 --- a/src/video/win32/SDL_win32window.c +++ b/src/video/win32/SDL_win32window.c @@ -25,6 +25,9 @@ #include "SDL_win32video.h" +/* This is included after SDL_win32video.h, which includes windows.h */ +#include "SDL_syswm.h" + static int SetupWindowData(SDL_Window * window, HWND hwnd, BOOL created) @@ -59,6 +62,8 @@ SetupWindowData(SDL_Window * window, HWND hwnd, BOOL created) /* Fill in the SDL window with the window data */ { POINT point; + point.x = 0; + point.y = 0; if (ClientToScreen(hwnd, &point)) { window->x = point.x; window->y = point.y; @@ -385,8 +390,6 @@ SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) { HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; -/* FIXME! */ -#if 0 if (info->version.major <= SDL_MAJOR_VERSION) { info->window = hwnd; /* FIXME! */ @@ -397,7 +400,6 @@ WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) SDL_MAJOR_VERSION, SDL_MINOR_VERSION); return SDL_FALSE; } -#endif } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32window.h b/src/video/win32/SDL_win32window.h index 6134e2c58..70b861c6b 100644 --- a/src/video/win32/SDL_win32window.h +++ b/src/video/win32/SDL_win32window.h @@ -49,7 +49,7 @@ extern void WIN_RestoreWindow(_THIS, SDL_Window * window); extern void WIN_SetWindowGrab(_THIS, SDL_Window * window); extern void WIN_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window * window, - SDL_SysWMinfo * info); + struct SDL_SysWMinfo *info); #endif /* _SDL_win32window_h */