X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=vid_sdl.c;h=c87dbe7454a845502ef786a1ed9db24aa417a531;hb=201979c976cb28bd0971dec669b9f34302eb42f6;hp=50513fe6e24bddb6881005882cd0adfe3740b0f5;hpb=aa33d8f8642530f7f266d6cde1422f95aa74b2be;p=xonotic%2Fdarkplaces.git diff --git a/vid_sdl.c b/vid_sdl.c index 50513fe6..c87dbe74 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#undef WIN32_LEAN_AND_MEAN //hush a warning, SDL.h redefines this #include #include @@ -23,6 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Tell startup code that we have a client int cl_available = true; + +qboolean vid_supportrefreshrate = false; + static qboolean vid_usingmouse; static qboolean vid_isfullscreen; @@ -251,6 +255,28 @@ static int Sys_EventFilter( SDL_Event *event ) #endif } +static keynum_t buttonremap[18] = +{ + K_MOUSE1, + K_MOUSE3, + K_MOUSE2, + K_MWHEELUP, + K_MWHEELDOWN, + K_MOUSE4, + K_MOUSE5, + K_MOUSE6, + K_MOUSE7, + K_MOUSE8, + K_MOUSE9, + K_MOUSE10, + K_MOUSE11, + K_MOUSE12, + K_MOUSE13, + K_MOUSE14, + K_MOUSE15, + K_MOUSE16, +}; + void Sys_SendKeyEvents( void ) { SDL_Event event; @@ -274,18 +300,12 @@ void Sys_SendKeyEvents( void ) } break; case SDL_MOUSEBUTTONDOWN: - if( event.button.button == SDL_BUTTON_MIDDLE ) - event.button.button = SDL_BUTTON_RIGHT; - else if( event.button.button == SDL_BUTTON_RIGHT ) - event.button.button = SDL_BUTTON_MIDDLE; - Key_Event( K_MOUSE1 + event.button.button - 1, 0, true ); + if (event.button.button <= 18) + Key_Event( buttonremap[event.button.button - 1], 0, true ); break; case SDL_MOUSEBUTTONUP: - if( event.button.button == SDL_BUTTON_MIDDLE ) - event.button.button = SDL_BUTTON_RIGHT; - else if( event.button.button == SDL_BUTTON_RIGHT ) - event.button.button = SDL_BUTTON_MIDDLE; - Key_Event( K_MOUSE1 + event.button.button - 1, 0, false ); + if (event.button.button <= 18) + Key_Event( buttonremap[event.button.button - 1], 0, false ); break; } } @@ -305,7 +325,7 @@ static int Sys_EventFilter( SDL_Event *event ); void VID_Init (void) { if (SDL_Init(SDL_INIT_VIDEO) < 0) - Sys_Error ("Failed to init video: %s\n", SDL_GetError()); + Sys_Error ("Failed to init video: %s", SDL_GetError()); vid_isfullscreen = false; } @@ -327,7 +347,12 @@ static void VID_SetCaption() return; icon = LoadIcon( GetModuleHandle( NULL ), MAKEINTRESOURCE( IDI_ICON1 ) ); - SetClassLong( info.window, GCL_HICON, (LONG) icon ); +#ifndef _W64 //If Windows 64bit data types don't exist +#define SetClassLongPtr SetClassLong +#define GCLP_HICON GCL_HICON +#define LONG_PTR LONG +#endif + SetClassLongPtr( info.window, GCLP_HICON, (LONG_PTR)icon ); } #else static void VID_SetCaption() @@ -346,7 +371,7 @@ static void VID_OutputVersion() version->major, version->minor, version->patch ); } -int VID_InitMode(int fullscreen, int width, int height, int bpp) +int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate) { int i; int flags = SDL_OPENGL; @@ -458,7 +483,7 @@ int VID_GetGamma (unsigned short *ramps) return !SDL_GetGammaRamp( ramps, ramps + 256, ramps + 512); } -void VID_Finish (void) +void VID_Finish (qboolean allowmousegrab) { Uint8 appstate; qboolean vid_usemouse; @@ -470,13 +495,15 @@ void VID_Finish (void) //react on appstate changes appstate = SDL_GetAppState(); - if( !( appstate & SDL_APPMOUSEFOCUS ) || !( appstate & SDL_APPINPUTFOCUS ) ) + vid_hidden = !(appstate & SDL_APPACTIVE); + + if( vid_hidden || !( appstate & SDL_APPMOUSEFOCUS ) || !( appstate & SDL_APPINPUTFOCUS ) ) vid_activewindow = false; else vid_activewindow = true; vid_usemouse = false; - if( vid_mouse.integer && !key_consoleactive && !cls.demoplayback ) + if( allowmousegrab && vid_mouse.integer && !key_consoleactive && !cls.demoplayback ) vid_usemouse = true; if( vid_isfullscreen ) vid_usemouse = true;