19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Lesser General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2.1 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Lesser General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Lesser General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free Software 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h" 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 247891dd35fa2439a70f43ab8572778a398365bf24David 'Digit' Turner#define WIN32_LEAN_AND_MEAN 1 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <windows.h> 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */ 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef WM_XBUTTONDOWN 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define WM_XBUTTONDOWN 0x020B 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef WM_XBUTTONUP 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define WM_XBUTTONUP 0x020C 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef GET_XBUTTON_WPARAM 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define GET_XBUTTON_WPARAM(w) (HIWORD(w)) 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_events.h" 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_video.h" 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_syswm.h" 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_sysvideo.h" 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../../events/SDL_sysevents.h" 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../../events/SDL_events_c.h" 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_lowvideo.h" 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_syswm_c.h" 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_main.h" 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_loadso.h" 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef WMMSG_DEBUG 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "wmmsg.h" 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../windib/SDL_gapidibvideo.h" 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SDL_VIDEO_DRIVER_GAPI 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../gapi/SDL_gapivideo.h" 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef _WIN32_WCE 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define IsZoomed(HWND) 1 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define NO_GETKEYBOARDSTATE 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if _WIN32_WCE < 420 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define NO_CHANGEDISPLAYSETTINGS 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* The window we use for everything... */ 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef _WIN32_WCE 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallLPWSTR SDL_Appname = NULL; 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallLPSTR SDL_Appname = NULL; 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallUint32 SDL_Appstyle = 0; 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallHINSTANCE SDL_Instance = NULL; 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallHWND SDL_Window = NULL; 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallRECT SDL_bounds = {0, 0, 0, 0}; 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint SDL_windowX = 0; 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint SDL_windowY = 0; 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint SDL_resizing = 0; 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint mouse_relative = 0; 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint posted = 0; 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef NO_CHANGEDISPLAYSETTINGS 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallDEVMODE SDL_desktop_mode; 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallDEVMODE SDL_fullscreen_mode; 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallWORD *gamma_saved = NULL; 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Functions called by the message processing function */ 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallLONG (*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL; 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid (*WIN_Activate)(_THIS, BOOL active, BOOL iconic); 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid (*WIN_RealizePalette)(_THIS); 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid (*WIN_PaletteChanged)(_THIS, HWND window); 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid (*WIN_WinPAINT)(_THIS, HDC hdc); 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void DIB_SwapGamma(_THIS); 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef NO_GETKEYBOARDSTATE 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef _WIN64 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Variables and support functions for SDL_ToUnicode() */ 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int codepage; 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int Is9xME(); 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int GetCodePage(); 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, const BYTE *keystate, LPWSTR wchars, int wsize, UINT flags); 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallToUnicodeFN SDL_ToUnicode = ToUnicode9xME; 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* !NO_GETKEYBOARDSTATE */ 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(_WIN32_WCE) 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//AdjustWindowRect is not available under WinCE 2003 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define AdjustWindowRect(a,b,c) (AdjustWindowRectEx((a),(b),(c),0)) 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// dynamically load aygshell dll because we want SDL to work on HPC and be300 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallHINSTANCE aygshell = NULL; 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallBOOL (WINAPI *SHFullScreen)(HWND hwndRequester, DWORD dwState) = 0; 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SHFS_SHOWTASKBAR 0x0001 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SHFS_HIDETASKBAR 0x0002 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SHFS_SHOWSIPBUTTON 0x0004 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SHFS_HIDESIPBUTTON 0x0008 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SHFS_SHOWSTARTICON 0x0010 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SHFS_HIDESTARTICON 0x0020 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void LoadAygshell(void) 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if( !aygshell ) 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall aygshell = SDL_LoadObject("aygshell.dll"); 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if( (aygshell != 0) && (SHFullScreen == 0) ) 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SHFullScreen = (int (WINAPI *)(struct HWND__ *,unsigned long)) SDL_LoadFunction(aygshell, "SHFullScreen"); 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* JC 14 Mar 2006 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This is used all over the place, in the windib driver and in the dx5 driver 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall So we may as well stick it here instead of having multiple copies scattered 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall about 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid WIN_FlushMessageQueue() 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MSG msg; 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( msg.message == WM_QUIT ) break; 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TranslateMessage( &msg ); 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DispatchMessage( &msg ); 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void SDL_RestoreGameMode(void) 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef _WIN32_WCE //Under ce we don't minimize, therefore no restore 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SDL_VIDEO_DRIVER_GAPI 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VideoDevice *this = current_video; 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(SDL_strcmp(this->name, "gapi") == 0) 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if( this->hidden->gapiInfo->suspended ) 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->hidden->gapiInfo->suspended = 0; 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ShowWindow(SDL_Window, SW_RESTORE); 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef NO_CHANGEDISPLAYSETTINGS 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef _WIN32_WCE 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ChangeDisplaySettings(&SDL_fullscreen_mode, CDS_FULLSCREEN); 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* NO_CHANGEDISPLAYSETTINGS */ 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void SDL_RestoreDesktopMode(void) 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef _WIN32_WCE 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SDL_VIDEO_DRIVER_GAPI 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VideoDevice *this = current_video; 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(SDL_strcmp(this->name, "gapi") == 0) 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if( !this->hidden->gapiInfo->suspended ) 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->hidden->gapiInfo->suspended = 1; 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* WinCE does not have a taskbar, so minimizing is not convenient */ 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ShowWindow(SDL_Window, SW_MINIMIZE); 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef NO_CHANGEDISPLAYSETTINGS 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef _WIN32_WCE 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ChangeDisplaySettings(NULL, 0); 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* NO_CHANGEDISPLAYSETTINGS */ 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef WM_MOUSELEAVE 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Special code to handle mouse leave events - this sucks... 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall http://support.microsoft.com/support/kb/articles/q183/1/07.asp 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TrackMouseEvent() is only available on Win98 and WinNT. 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _TrackMouseEvent() is available on Win95, but isn't yet in the mingw32 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall development environment, and only works on systems that have had IE 3.0 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall or newer installed on them (which is not the case with the base Win95). 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Therefore, we implement our own version of _TrackMouseEvent() which 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall uses our own implementation if TrackMouseEvent() is not available. 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL; 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic VOID CALLBACK 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall union { RECT rect; POINT pt; } rectpt; /* prevent type-punning issue. */ 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall POINT pt; 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetClientRect(hWnd, &rectpt.rect); 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MapWindowPoints(hWnd, NULL, &rectpt.pt, 2); 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetCursorPos(&pt); 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( !PtInRect(&rectpt.rect, pt) || (WindowFromPoint(pt) != hWnd) ) { 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( !KillTimer(hWnd, idEvent) ) { 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Error killing the timer! */ 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PostMessage(hWnd, WM_MOUSELEAVE, 0, 0); 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme) 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ptme->dwFlags == TME_LEAVE ) { 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return SetTimer(ptme->hwndTrack, ptme->dwFlags, 100, 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (TIMERPROC)TrackMouseTimerProc) != 0; 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return FALSE; 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* WM_MOUSELEAVE */ 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint sysevents_mouse_pressed = 0; 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* The main Win32 event handler 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallDJM: This is no longer static as (DX5/DIB)_CreateWindow needs it 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallLRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VideoDevice *this = current_video; 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef WMMSG_DEBUG 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fprintf(stderr, "Received windows message: "); 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( msg > MAX_WMMSG ) { 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fprintf(stderr, "%d", msg); 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fprintf(stderr, "%s", wmtab[msg]); 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam); 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch (msg) { 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_ACTIVATE: { 2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VideoDevice *this = current_video; 2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall BOOL active, minimized; 2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 appstate; 2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall minimized = HIWORD(wParam); 2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall active = (LOWORD(wParam) != WA_INACTIVE) && !minimized; 2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( active ) { 2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Gain the following states */ 2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS; 2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( !(SDL_GetAppState() & SDL_APPINPUTFOCUS) ) { 2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( this->input_grab != SDL_GRAB_OFF ) { 2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WIN_GrabInput(this, SDL_GRAB_ON); 2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! DDRAW_FULLSCREEN() ) { 2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DIB_SwapGamma(this); 2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( WINDIB_FULLSCREEN() ) { 2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_RestoreGameMode(); 2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(_WIN32_WCE) 2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( WINDIB_FULLSCREEN() ) { 2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall LoadAygshell(); 2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if( SHFullScreen ) 2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SHFullScreen(SDL_Window, SHFS_HIDESTARTICON|SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON); 2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_HIDE); 2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall posted = SDL_PrivateAppActive(1, appstate); 2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Lose the following states */ 2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall appstate = SDL_APPINPUTFOCUS; 2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( minimized ) { 3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall appstate |= SDL_APPACTIVE; 3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { 3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( this->input_grab != SDL_GRAB_OFF ) { 3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WIN_GrabInput(this, SDL_GRAB_OFF); 3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! DDRAW_FULLSCREEN() ) { 3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DIB_SwapGamma(this); 3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( WINDIB_FULLSCREEN() ) { 3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall appstate |= SDL_APPMOUSEFOCUS; 3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_RestoreDesktopMode(); 3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* A fullscreen app gets hidden but will not get a minimize event */ 3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall appstate |= (SDL_APPACTIVE | SDL_APPMOUSEFOCUS); 3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(_WIN32_WCE) 3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall LoadAygshell(); 3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if( SHFullScreen ) 3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SHFullScreen(SDL_Window, SHFS_SHOWSTARTICON|SHFS_SHOWTASKBAR|SHFS_SHOWSIPBUTTON); 3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_SHOW); 3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall posted = SDL_PrivateAppActive(0, appstate); 3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WIN_Activate(this, active, minimized); 3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_MOUSEMOVE: { 3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef WM_MOUSELEAVE 3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_VideoSurface ) { 3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* mouse has entered the window */ 3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) { 3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TRACKMOUSEEVENT tme; 3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall tme.cbSize = sizeof(tme); 3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall tme.dwFlags = TME_LEAVE; 3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall tme.hwndTrack = SDL_Window; 3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _TrackMouseEvent(&tme); 3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* WM_MOUSELEAVE */ 3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Mouse motion is handled in DIB_PumpEvents or 3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * DX5_PumpEvents, depending on the video driver 3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * in use */ 3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); 3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef WM_MOUSELEAVE 3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_MOUSELEAVE: { 3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_VideoSurface ) { 3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* mouse has left the window */ 3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); 3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* WM_MOUSELEAVE */ 3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_LBUTTONDOWN: 3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_LBUTTONUP: 3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_MBUTTONDOWN: 3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_MBUTTONUP: 3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_RBUTTONDOWN: 3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_RBUTTONUP: 3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_XBUTTONDOWN: 3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_XBUTTONUP: { 3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Mouse is handled by DirectInput when fullscreen */ 3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_VideoSurface && ! DINPUT() ) { 3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WORD xbuttonval = 0; 3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 button, state; 3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int x, y; 3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* DJM: 3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall We want the SDL window to take focus so that 3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall it acts like a normal windows "component" 3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (e.g. gains keyboard focus on a mouse click). 3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetFocus(SDL_Window); 3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Figure out which button to use */ 3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch (msg) { 3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_LBUTTONDOWN: 3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall button = SDL_BUTTON_LEFT; 3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall state = SDL_PRESSED; 3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 3949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_LBUTTONUP: 3959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall button = SDL_BUTTON_LEFT; 3969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall state = SDL_RELEASED; 3979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 3989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_MBUTTONDOWN: 3999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall button = SDL_BUTTON_MIDDLE; 4009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall state = SDL_PRESSED; 4019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 4029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_MBUTTONUP: 4039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall button = SDL_BUTTON_MIDDLE; 4049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall state = SDL_RELEASED; 4059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 4069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_RBUTTONDOWN: 4079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall button = SDL_BUTTON_RIGHT; 4089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall state = SDL_PRESSED; 4099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 4109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_RBUTTONUP: 4119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall button = SDL_BUTTON_RIGHT; 4129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall state = SDL_RELEASED; 4139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 4149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_XBUTTONDOWN: 4159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall xbuttonval = GET_XBUTTON_WPARAM(wParam); 4169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall button = SDL_BUTTON_X1 + xbuttonval - 1; 4179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall state = SDL_PRESSED; 4189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 4199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_XBUTTONUP: 4209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall xbuttonval = GET_XBUTTON_WPARAM(wParam); 4219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall button = SDL_BUTTON_X1 + xbuttonval - 1; 4229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall state = SDL_RELEASED; 4239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 4249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default: 4259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Eh? Unknown button? */ 4269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 4279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( state == SDL_PRESSED ) { 4299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Grab mouse so we get up events */ 4309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ++sysevents_mouse_pressed > 0 ) { 4319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetCapture(hwnd); 4329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 4349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Release mouse after all up events */ 4359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( --sysevents_mouse_pressed <= 0 ) { 4369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ReleaseCapture(); 4379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sysevents_mouse_pressed = 0; 4389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( mouse_relative ) { 4419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* RJR: March 28, 2000 4429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall report internal mouse position if in relative mode */ 4439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall x = 0; y = 0; 4449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 4459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall x = (Sint16)LOWORD(lParam); 4469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall y = (Sint16)HIWORD(lParam); 4479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef _WIN32_WCE 4489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (SDL_VideoSurface) 4499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GapiTransform(this->hidden->userOrientation, 4509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallthis->hidden->hiresFix, &x, &y); 4519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 4529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall posted = SDL_PrivateMouseButton( 4549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall state, button, x, y); 4559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* 4579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * MSDN says: 4589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * "Unlike the WM_LBUTTONUP, WM_MBUTTONUP, and WM_RBUTTONUP 4599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * messages, an application should return TRUE from [an 4609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * XBUTTON message] if it processes it. Doing so will allow 4619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * software that simulates this message on Microsoft Windows 4629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * systems earlier than Windows 2000 to determine whether 4639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * the window procedure processed the message or called 4649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * DefWindowProc to process it. 4659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 4669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (xbuttonval > 0) 4679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(TRUE); 4689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 4719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) 4749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_MOUSEWHEEL: 4759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_VideoSurface && ! DINPUT() ) { 4769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int move = (short)HIWORD(wParam); 4779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( move ) { 4789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 button; 4799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( move > 0 ) 4809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall button = SDL_BUTTON_WHEELUP; 4819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 4829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall button = SDL_BUTTON_WHEELDOWN; 4839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall posted = SDL_PrivateMouseButton( 4849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PRESSED, button, 0, 0); 4859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall posted |= SDL_PrivateMouseButton( 4869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_RELEASED, button, 0, 0); 4879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 4909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 4919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef WM_GETMINMAXINFO 4939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* This message is sent as a way for us to "check" the values 4949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * of a position change. If we don't like it, we can adjust 4959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * the values before they are changed. 4969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 4979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_GETMINMAXINFO: { 4989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MINMAXINFO *info; 4999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RECT size; 5009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int x, y; 5019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int style; 5029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int width; 5039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int height; 5049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We don't want to clobber an internal resize */ 5069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_resizing ) 5079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 5089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We allow resizing with the SDL_RESIZABLE flag */ 5109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_PublicSurface && 5119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { 5129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 5139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Get the current position of our window */ 5169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetWindowRect(SDL_Window, &size); 5179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall x = size.left; 5189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall y = size.top; 5199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Calculate current width and height of our window */ 5219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall size.top = 0; 5229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall size.left = 0; 5239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_PublicSurface != NULL ) { 5249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall size.bottom = SDL_PublicSurface->h; 5259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall size.right = SDL_PublicSurface->w; 5269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 5279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall size.bottom = 0; 5289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall size.right = 0; 5299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* DJM - according to the docs for GetMenu(), the 5329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return value is undefined if hwnd is a child window. 5339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Aparently it's too difficult for MS to check 5349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall inside their function, so I have to do it here. 5359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 5369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall style = GetWindowLong(hwnd, GWL_STYLE); 5379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall AdjustWindowRect( 5389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &size, 5399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall style, 5409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall style & WS_CHILDWINDOW ? FALSE 5419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall : GetMenu(hwnd) != NULL); 5429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall width = size.right - size.left; 5449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall height = size.bottom - size.top; 5459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Fix our size to the current size */ 5479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info = (MINMAXINFO *)lParam; 5489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info->ptMaxSize.x = width; 5499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info->ptMaxSize.y = height; 5509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info->ptMaxPosition.x = x; 5519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info->ptMaxPosition.y = y; 5529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info->ptMinTrackSize.x = width; 5539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info->ptMinTrackSize.y = height; 5549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info->ptMaxTrackSize.x = width; 5559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info->ptMaxTrackSize.y = height; 5569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 5589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* WM_GETMINMAXINFO */ 5599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_WINDOWPOSCHANGING: { 5619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WINDOWPOS *windowpos = (WINDOWPOS*)lParam; 5629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* When menu is at the side or top, Windows likes 5649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall to try to reposition the fullscreen window when 5659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall changing video modes. 5669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 5679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( !SDL_resizing && 5689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PublicSurface && 5699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (SDL_PublicSurface->flags & SDL_FULLSCREEN) ) { 5709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall windowpos->x = 0; 5719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall windowpos->y = 0; 5729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 5759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_WINDOWPOSCHANGED: { 5779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VideoDevice *this = current_video; 5789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall POINT pt; 5799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int w, h; 5809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetClientRect(SDL_Window, &SDL_bounds); 5829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* avoiding type-punning here... */ 5849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall pt.x = SDL_bounds.left; 5859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall pt.y = SDL_bounds.top; 5869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ClientToScreen(SDL_Window, &pt); 5879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_bounds.left = pt.x; 5889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_bounds.top = pt.y; 5899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall pt.x = SDL_bounds.right; 5919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall pt.y = SDL_bounds.bottom; 5929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ClientToScreen(SDL_Window, &pt); 5939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_bounds.right = pt.x; 5949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_bounds.bottom = pt.y; 5959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( !SDL_resizing && !IsZoomed(SDL_Window) && 5979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PublicSurface && 5989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall !(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) { 5999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_windowX = SDL_bounds.left; 6009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_windowY = SDL_bounds.top; 6019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w = SDL_bounds.right-SDL_bounds.left; 6039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall h = SDL_bounds.bottom-SDL_bounds.top; 6049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( this->input_grab != SDL_GRAB_OFF ) { 6059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ClipCursor(&SDL_bounds); 6069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_PublicSurface && 6089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { 6099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PrivateResize(w, h); 6109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We need to set the cursor */ 6159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_SETCURSOR: { 6169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint16 hittest; 6179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall hittest = LOWORD(lParam); 6199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( hittest == HTCLIENT ) { 6209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetCursor(SDL_hcursor); 6219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(TRUE); 6229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We are about to get palette focus! */ 6279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_QUERYNEWPALETTE: { 6289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WIN_RealizePalette(current_video); 6299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(TRUE); 6309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Another application changed the palette */ 6349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_PALETTECHANGED: { 6359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WIN_PaletteChanged(current_video, (HWND)wParam); 6369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We were occluded, refresh our display */ 6409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_PAINT: { 6419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HDC hdc; 6429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PAINTSTRUCT ps; 6439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall hdc = BeginPaint(SDL_Window, &ps); 6459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( current_video->screen && 6469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall !(current_video->screen->flags & SDL_OPENGL) ) { 6479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WIN_WinPAINT(current_video, hdc); 6489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EndPaint(SDL_Window, &ps); 6509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 6529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* DJM: Send an expose event in this case */ 6549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_ERASEBKGND: { 6559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall posted = SDL_PrivateExpose(); 6569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 6589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_CLOSE: { 6609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (posted = SDL_PrivateQuit()) ) 6619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PostQuitMessage(0); 6629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 6649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_DESTROY: { 6669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PostQuitMessage(0); 6679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 6699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef NO_GETKEYBOARDSTATE 6719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case WM_INPUTLANGCHANGE: 6729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef _WIN64 6739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall codepage = GetCodePage(); 6749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 6759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(TRUE); 6769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 6779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default: { 6799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Special handling by the video driver */ 6809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (HandleMessage) { 6819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(HandleMessage(current_video, 6829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall hwnd, msg, wParam, lParam)); 6839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(DefWindowProc(hwnd, msg, wParam, lParam)); 6889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Allow the application handle to be stored and retrieved later */ 6919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void *SDL_handle = NULL; 6929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_SetModuleHandle(void *handle) 6949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 6959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_handle = handle; 6969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid *SDL_GetModuleHandle(void) 6989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 6999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void *handle; 7009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_handle ) { 7029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall handle = SDL_handle; 7039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 7049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall handle = GetModuleHandle(NULL); 7059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(handle); 7079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* This allows the SDL_WINDOWID hack */ 7109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallBOOL SDL_windowid = FALSE; 7119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int app_registered = 0; 7139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Register the class for this application -- exported for winmain.c */ 7159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint SDL_RegisterApp(char *name, Uint32 style, void *hInst) 7169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WNDCLASS class; 7189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef WM_MOUSELEAVE 7199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HMODULE handle; 7209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 7219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Only do this once... */ 7239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( app_registered ) { 7249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ++app_registered; 7259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 7269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef CS_BYTEALIGNCLIENT 7299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define CS_BYTEALIGNCLIENT 0 7309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 7319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! name && ! SDL_Appname ) { 7329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall name = "SDL_app"; 7339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Appstyle = CS_BYTEALIGNCLIENT; 7349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); 7359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( name ) { 7389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef _WIN32_WCE 7399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* WinCE uses the UNICODE version */ 7409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Appname = SDL_iconv_utf8_ucs2(name); 7419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 7429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Appname = SDL_iconv_utf8_locale(name); 7439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* _WIN32_WCE */ 7449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Appstyle = style; 7459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); 7469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Register the application class */ 7499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall class.hCursor = NULL; 7509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall class.hIcon = LoadImage(SDL_Instance, SDL_Appname, 7519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall IMAGE_ICON, 7529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0, 0, LR_DEFAULTCOLOR); 7539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall class.lpszMenuName = NULL; 7549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall class.lpszClassName = SDL_Appname; 7559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall class.hbrBackground = NULL; 7569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall class.hInstance = SDL_Instance; 7579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall class.style = SDL_Appstyle; 7589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL 7599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall class.style |= CS_OWNDC; 7609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 7619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall class.lpfnWndProc = WinMessage; 7629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall class.cbWndExtra = 0; 7639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall class.cbClsExtra = 0; 7649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! RegisterClass(&class) ) { 7659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("Couldn't register application class"); 7669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 7679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef WM_MOUSELEAVE 7709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Get the version of TrackMouseEvent() we use */ 7719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _TrackMouseEvent = NULL; 7729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall handle = GetModuleHandle("USER32.DLL"); 7739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( handle ) { 7749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent"); 7759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( _TrackMouseEvent == NULL ) { 7779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _TrackMouseEvent = WIN_TrackMouseEvent; 7789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* WM_MOUSELEAVE */ 7809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef NO_GETKEYBOARDSTATE 7829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef _WIN64 7839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Initialise variables for SDL_ToUnicode() */ 7849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall codepage = GetCodePage(); 7859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Cygwin headers don't match windows.h, so we have to cast around a 7879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const issue here... */ 7889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_ToUnicode = Is9xME() ? ToUnicode9xME : (ToUnicodeFN) ToUnicode; 7899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 7909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* NO_GETKEYBOARDSTATE */ 7919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall app_registered = 1; 7939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 7949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Unregisters the windowclass registered in SDL_RegisterApp above. */ 7979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_UnregisterApp() 7989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WNDCLASS class; 8009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* SDL_RegisterApp might not have been called before */ 8029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( !app_registered ) { 8039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 8049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall --app_registered; 8069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( app_registered == 0 ) { 8079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Check for any registered window classes. */ 8089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( GetClassInfo(SDL_Instance, SDL_Appname, &class) ) { 8099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall UnregisterClass(SDL_Appname, SDL_Instance); 8109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(SDL_Appname); 8129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Appname = NULL; 8139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 8159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef NO_GETKEYBOARDSTATE 8179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef _WIN64 8189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* JFP: Implementation of ToUnicode() that works on 9x/ME/2K/XP */ 8199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int Is9xME() 8219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 8229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSVERSIONINFO info; 8239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(&info, 0, sizeof(info)); 8259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info.dwOSVersionInfoSize = sizeof(info); 8269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!GetVersionEx(&info)) { 8279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 8289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); 8309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 8319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int GetCodePage() 8339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 8349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall char buff[8]; 8359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int lcid = MAKELCID(LOWORD(GetKeyboardLayout(0)), SORT_DEFAULT); 8369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int cp = GetACP(); 8379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) { 8399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall cp = SDL_atoi(buff); 8409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return cp; 8429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 8439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, const BYTE *keystate, LPWSTR wchars, int wsize, UINT flags) 8459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 8469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall BYTE chars[2]; 8479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* arg #3 should be const BYTE *, but cygwin lists it as PBYTE. */ 8499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (ToAsciiEx(vkey, scancode, (PBYTE) keystate, (WORD*)chars, 0, GetKeyboardLayout(0)) == 1) { 8509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return MultiByteToWideChar(codepage, 0, (LPCSTR) chars, 1, wchars, wsize); 8519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 8539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 8549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 8559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* !NO_GETKEYBOARDSTATE */ 856