Mercurial > sdl-ios-xcode
annotate src/video/wincommon/SDL_sysevents.c @ 4210:8f501bbc3bf1 SDL-1.2
Fixed bug #571.. I think. :)
It certainly can't hurt!
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 21 Sep 2009 07:59:44 +0000 |
parents | d7294b7c732d |
children | 429c8dd3175d |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
4159 | 3 Copyright (C) 1997-2009 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
179
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
1433
bb6839704ed6
SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
24 #define WIN32_LEAN_AND_MEAN |
bb6839704ed6
SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
25 #include <windows.h> |
0 | 26 |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
27 /* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */ |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
28 #ifndef WM_XBUTTONDOWN |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
29 #define WM_XBUTTONDOWN 0x020B |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
30 #endif |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
31 #ifndef WM_XBUTTONUP |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
32 #define WM_XBUTTONUP 0x020C |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
33 #endif |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
34 #ifndef GET_XBUTTON_WPARAM |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
35 #define GET_XBUTTON_WPARAM(w) (HIWORD(w)) |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
36 #endif |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
37 |
0 | 38 #include "SDL_events.h" |
39 #include "SDL_video.h" | |
40 #include "SDL_syswm.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
41 #include "../SDL_sysvideo.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
42 #include "../../events/SDL_sysevents.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
43 #include "../../events/SDL_events_c.h" |
0 | 44 #include "SDL_lowvideo.h" |
45 #include "SDL_syswm_c.h" | |
46 #include "SDL_main.h" | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
47 #include "SDL_loadso.h" |
0 | 48 |
49 #ifdef WMMSG_DEBUG | |
50 #include "wmmsg.h" | |
51 #endif | |
52 | |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
53 #include "../windib/SDL_gapidibvideo.h" |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
54 |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
55 #ifdef SDL_VIDEO_DRIVER_GAPI |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
56 #include "../gapi/SDL_gapivideo.h" |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
57 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
58 |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
59 #ifdef _WIN32_WCE |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
60 #define IsZoomed(HWND) 1 |
0 | 61 #define NO_GETKEYBOARDSTATE |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
62 #if _WIN32_WCE < 420 |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
63 #define NO_CHANGEDISPLAYSETTINGS |
0 | 64 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
65 #endif |
0 | 66 |
67 /* The window we use for everything... */ | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
68 #ifdef _WIN32_WCE |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
69 LPWSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
70 #else |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
71 LPSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
72 #endif |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
73 Uint32 SDL_Appstyle = 0; |
0 | 74 HINSTANCE SDL_Instance = NULL; |
75 HWND SDL_Window = NULL; | |
76 RECT SDL_bounds = {0, 0, 0, 0}; | |
833
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
829
diff
changeset
|
77 int SDL_windowX = 0; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
829
diff
changeset
|
78 int SDL_windowY = 0; |
0 | 79 int SDL_resizing = 0; |
80 int mouse_relative = 0; | |
81 int posted = 0; | |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
82 #ifndef NO_CHANGEDISPLAYSETTINGS |
1295
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1291
diff
changeset
|
83 DEVMODE SDL_desktop_mode; |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
84 DEVMODE SDL_fullscreen_mode; |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
85 #endif |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
86 WORD *gamma_saved = NULL; |
0 | 87 |
88 | |
89 /* Functions called by the message processing function */ | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
90 LONG (*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL; |
3992 | 91 void (*WIN_Activate)(_THIS, BOOL active, BOOL iconic); |
0 | 92 void (*WIN_RealizePalette)(_THIS); |
93 void (*WIN_PaletteChanged)(_THIS, HWND window); | |
94 void (*WIN_WinPAINT)(_THIS, HDC hdc); | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
95 extern void DIB_SwapGamma(_THIS); |
0 | 96 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
97 #ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
98 /* Variables and support functions for SDL_ToUnicode() */ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
99 static int codepage; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
100 static int Is9xME(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
101 static int GetCodePage(); |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
102 static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, BYTE *keystate, LPWSTR wchars, int wsize, UINT flags); |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
103 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
104 ToUnicodeFN SDL_ToUnicode = ToUnicode9xME; |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
105 #endif /* !NO_GETKEYBOARDSTATE */ |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
106 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
107 |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
108 #if defined(_WIN32_WCE) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
109 |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
110 //AdjustWindowRect is not available under WinCE 2003 |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
111 #define AdjustWindowRect(a,b,c) (AdjustWindowRectEx((a),(b),(c),0)) |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
112 |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
113 // dynamically load aygshell dll because we want SDL to work on HPC and be300 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
114 HINSTANCE aygshell = NULL; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
115 BOOL (WINAPI *SHFullScreen)(HWND hwndRequester, DWORD dwState) = 0; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
116 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
117 #define SHFS_SHOWTASKBAR 0x0001 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
118 #define SHFS_HIDETASKBAR 0x0002 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
119 #define SHFS_SHOWSIPBUTTON 0x0004 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
120 #define SHFS_HIDESIPBUTTON 0x0008 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
121 #define SHFS_SHOWSTARTICON 0x0010 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
122 #define SHFS_HIDESTARTICON 0x0020 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
123 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
124 static void LoadAygshell(void) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
125 { |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
126 if( !aygshell ) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
127 aygshell = SDL_LoadObject("aygshell.dll"); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
128 if( (aygshell != 0) && (SHFullScreen == 0) ) |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
129 { |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
130 SHFullScreen = (int (WINAPI *)(struct HWND__ *,unsigned long)) SDL_LoadFunction(aygshell, "SHFullScreen"); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
131 } |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
132 } |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
133 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
134 #endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
135 |
1523 | 136 /* JC 14 Mar 2006 |
137 This is used all over the place, in the windib driver and in the dx5 driver | |
138 So we may as well stick it here instead of having multiple copies scattered | |
139 about | |
140 */ | |
141 void WIN_FlushMessageQueue() | |
142 { | |
143 MSG msg; | |
144 while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { | |
145 if ( msg.message == WM_QUIT ) break; | |
146 TranslateMessage( &msg ); | |
147 DispatchMessage( &msg ); | |
148 } | |
149 } | |
150 | |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
151 static void SDL_RestoreGameMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
152 { |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
153 #ifdef _WIN32_WCE //Under ce we don't minimize, therefore no restore |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
154 |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
155 #ifdef SDL_VIDEO_DRIVER_GAPI |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
156 SDL_VideoDevice *this = current_video; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
157 if(SDL_strcmp(this->name, "gapi") == 0) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
158 { |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
159 if( this->hidden->gapiInfo->suspended ) |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
160 { |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
161 this->hidden->gapiInfo->suspended = 0; |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
162 } |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
163 } |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
164 #endif |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
165 |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
166 #else |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
167 ShowWindow(SDL_Window, SW_RESTORE); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
168 #endif |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
169 |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
170 #ifndef NO_CHANGEDISPLAYSETTINGS |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
171 #ifndef _WIN32_WCE |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
172 ChangeDisplaySettings(&SDL_fullscreen_mode, CDS_FULLSCREEN); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
173 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
174 #endif /* NO_CHANGEDISPLAYSETTINGS */ |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
175 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
176 static void SDL_RestoreDesktopMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
177 { |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
178 |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
179 #ifdef _WIN32_WCE |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
180 |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
181 #ifdef SDL_VIDEO_DRIVER_GAPI |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
182 SDL_VideoDevice *this = current_video; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
183 if(SDL_strcmp(this->name, "gapi") == 0) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
184 { |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
185 if( !this->hidden->gapiInfo->suspended ) |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
186 { |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
187 this->hidden->gapiInfo->suspended = 1; |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
188 } |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
189 } |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
190 #endif |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
191 |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
192 #else |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
193 /* WinCE does not have a taskbar, so minimizing is not convenient */ |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
194 ShowWindow(SDL_Window, SW_MINIMIZE); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
195 #endif |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
196 |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
197 #ifndef NO_CHANGEDISPLAYSETTINGS |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
198 #ifndef _WIN32_WCE |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
199 ChangeDisplaySettings(NULL, 0); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
200 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
201 #endif /* NO_CHANGEDISPLAYSETTINGS */ |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
202 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
203 |
0 | 204 #ifdef WM_MOUSELEAVE |
205 /* | |
206 Special code to handle mouse leave events - this sucks... | |
207 http://support.microsoft.com/support/kb/articles/q183/1/07.asp | |
208 | |
209 TrackMouseEvent() is only available on Win98 and WinNT. | |
210 _TrackMouseEvent() is available on Win95, but isn't yet in the mingw32 | |
211 development environment, and only works on systems that have had IE 3.0 | |
212 or newer installed on them (which is not the case with the base Win95). | |
213 Therefore, we implement our own version of _TrackMouseEvent() which | |
214 uses our own implementation if TrackMouseEvent() is not available. | |
215 */ | |
216 static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL; | |
217 | |
218 static VOID CALLBACK | |
219 TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) | |
220 { | |
221 RECT rect; | |
222 POINT pt; | |
223 | |
224 GetClientRect(hWnd, &rect); | |
225 MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2); | |
226 GetCursorPos(&pt); | |
227 if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) { | |
228 if ( !KillTimer(hWnd, idEvent) ) { | |
229 /* Error killing the timer! */ | |
230 } | |
231 PostMessage(hWnd, WM_MOUSELEAVE, 0, 0); | |
232 } | |
233 } | |
234 static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme) | |
235 { | |
236 if ( ptme->dwFlags == TME_LEAVE ) { | |
237 return SetTimer(ptme->hwndTrack, ptme->dwFlags, 100, | |
1456
84de7511f79f
Fixed a bunch of 64-bit compatibility problems
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
238 (TIMERPROC)TrackMouseTimerProc) != 0; |
0 | 239 } |
240 return FALSE; | |
241 } | |
242 #endif /* WM_MOUSELEAVE */ | |
243 | |
244 /* Function to retrieve the current keyboard modifiers */ | |
245 static void WIN_GetKeyboardState(void) | |
246 { | |
247 #ifndef NO_GETKEYBOARDSTATE | |
248 SDLMod state; | |
249 BYTE keyboard[256]; | |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
250 Uint8 *kstate = SDL_GetKeyState(NULL); |
0 | 251 |
252 state = KMOD_NONE; | |
253 if ( GetKeyboardState(keyboard) ) { | |
254 if ( keyboard[VK_LSHIFT] & 0x80) { | |
255 state |= KMOD_LSHIFT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
256 kstate[SDLK_LSHIFT] = SDL_PRESSED; |
0 | 257 } |
258 if ( keyboard[VK_RSHIFT] & 0x80) { | |
259 state |= KMOD_RSHIFT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
260 kstate[SDLK_RSHIFT] = SDL_PRESSED; |
0 | 261 } |
262 if ( keyboard[VK_LCONTROL] & 0x80) { | |
263 state |= KMOD_LCTRL; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
264 kstate[SDLK_LCTRL] = SDL_PRESSED; |
0 | 265 } |
266 if ( keyboard[VK_RCONTROL] & 0x80) { | |
267 state |= KMOD_RCTRL; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
268 kstate[SDLK_RCTRL] = SDL_PRESSED; |
0 | 269 } |
270 if ( keyboard[VK_LMENU] & 0x80) { | |
271 state |= KMOD_LALT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
272 kstate[SDLK_LALT] = SDL_PRESSED; |
0 | 273 } |
274 if ( keyboard[VK_RMENU] & 0x80) { | |
275 state |= KMOD_RALT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
276 kstate[SDLK_RALT] = SDL_PRESSED; |
0 | 277 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
278 if ( keyboard[VK_NUMLOCK] & 0x01) { |
0 | 279 state |= KMOD_NUM; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
280 kstate[SDLK_NUMLOCK] = SDL_PRESSED; |
0 | 281 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
282 if ( keyboard[VK_CAPITAL] & 0x01) { |
0 | 283 state |= KMOD_CAPS; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
284 kstate[SDLK_CAPSLOCK] = SDL_PRESSED; |
0 | 285 } |
286 } | |
287 SDL_SetModState(state); | |
288 #endif /* !NO_GETKEYBOARDSTATE */ | |
289 } | |
290 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
291 /* The main Win32 event handler |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
292 DJM: This is no longer static as (DX5/DIB)_CreateWindow needs it |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
293 */ |
1456
84de7511f79f
Fixed a bunch of 64-bit compatibility problems
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
294 LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
0 | 295 { |
296 SDL_VideoDevice *this = current_video; | |
297 static int mouse_pressed = 0; | |
298 #ifdef WMMSG_DEBUG | |
299 fprintf(stderr, "Received windows message: "); | |
300 if ( msg > MAX_WMMSG ) { | |
301 fprintf(stderr, "%d", msg); | |
302 } else { | |
303 fprintf(stderr, "%s", wmtab[msg]); | |
304 } | |
305 fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam); | |
306 #endif | |
307 switch (msg) { | |
308 | |
309 case WM_ACTIVATE: { | |
310 SDL_VideoDevice *this = current_video; | |
3992 | 311 BOOL active, minimized; |
0 | 312 Uint8 appstate; |
313 | |
314 minimized = HIWORD(wParam); | |
3992 | 315 active = (LOWORD(wParam) != WA_INACTIVE) && !minimized; |
316 if ( active ) { | |
0 | 317 /* Gain the following states */ |
318 appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS; | |
319 if ( this->input_grab != SDL_GRAB_OFF ) { | |
320 WIN_GrabInput(this, SDL_GRAB_ON); | |
321 } | |
322 if ( !(SDL_GetAppState()&SDL_APPINPUTFOCUS) ) { | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
323 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
324 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
325 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
326 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
327 SDL_RestoreGameMode(); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
328 } |
0 | 329 } |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
330 #if defined(_WIN32_WCE) |
3992 | 331 if ( WINDIB_FULLSCREEN() ) { |
332 LoadAygshell(); | |
333 if( SHFullScreen ) | |
334 SHFullScreen(SDL_Window, SHFS_HIDESTARTICON|SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON); | |
335 else | |
336 ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_HIDE); | |
337 } | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
338 #endif |
0 | 339 posted = SDL_PrivateAppActive(1, appstate); |
340 WIN_GetKeyboardState(); | |
341 } else { | |
342 /* Lose the following states */ | |
343 appstate = SDL_APPINPUTFOCUS; | |
344 if ( minimized ) { | |
345 appstate |= SDL_APPACTIVE; | |
346 } | |
347 if ( this->input_grab != SDL_GRAB_OFF ) { | |
348 WIN_GrabInput(this, SDL_GRAB_OFF); | |
349 } | |
350 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
351 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
352 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
353 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
354 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
355 SDL_RestoreDesktopMode(); |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
356 #if defined(_WIN32_WCE) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
357 LoadAygshell(); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
358 if( SHFullScreen ) |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
359 SHFullScreen(SDL_Window, SHFS_SHOWSTARTICON|SHFS_SHOWTASKBAR|SHFS_SHOWSIPBUTTON); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
360 else |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
361 ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_SHOW); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
362 #endif |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
363 } |
0 | 364 } |
365 posted = SDL_PrivateAppActive(0, appstate); | |
366 } | |
3992 | 367 WIN_Activate(this, active, minimized); |
0 | 368 return(0); |
369 } | |
370 break; | |
371 | |
372 case WM_MOUSEMOVE: { | |
373 | |
4169 | 374 #ifdef WM_MOUSELEAVE |
375 /* No need to handle SDL_APPMOUSEFOCUS when fullscreen */ | |
376 if ( SDL_VideoSurface && !FULLSCREEN() ) { | |
0 | 377 /* mouse has entered the window */ |
4169 | 378 |
379 if ( !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) { | |
0 | 380 TRACKMOUSEEVENT tme; |
381 | |
382 tme.cbSize = sizeof(tme); | |
383 tme.dwFlags = TME_LEAVE; | |
384 tme.hwndTrack = SDL_Window; | |
385 _TrackMouseEvent(&tme); | |
386 } | |
387 } | |
4169 | 388 #endif /* WM_MOUSELEAVE */ |
389 | |
390 /* Mouse motion is handled in DIB_PumpEvents or | |
391 * DX5_PumpEvents, depending on the video driver | |
392 * in use */ | |
393 | |
394 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | |
0 | 395 } |
396 return(0); | |
397 | |
398 #ifdef WM_MOUSELEAVE | |
399 case WM_MOUSELEAVE: { | |
400 | |
4169 | 401 /* No need to handle SDL_APPMOUSEFOCUS when fullscreen */ |
402 if ( SDL_VideoSurface && !FULLSCREEN() ) { | |
0 | 403 /* mouse has left the window */ |
404 /* or */ | |
405 /* Elvis has left the building! */ | |
406 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | |
407 } | |
408 } | |
409 return(0); | |
410 #endif /* WM_MOUSELEAVE */ | |
411 | |
412 case WM_LBUTTONDOWN: | |
413 case WM_LBUTTONUP: | |
414 case WM_MBUTTONDOWN: | |
415 case WM_MBUTTONUP: | |
416 case WM_RBUTTONDOWN: | |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
417 case WM_RBUTTONUP: |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
418 case WM_XBUTTONDOWN: |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
419 case WM_XBUTTONUP: { |
0 | 420 /* Mouse is handled by DirectInput when fullscreen */ |
4167 | 421 if ( SDL_VideoSurface && ! DINPUT() ) { |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
422 WORD xbuttonval = 0; |
0 | 423 Sint16 x, y; |
424 Uint8 button, state; | |
425 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
426 /* DJM: |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
427 We want the SDL window to take focus so that |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
428 it acts like a normal windows "component" |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
429 (e.g. gains keyboard focus on a mouse click). |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
430 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
431 SetFocus(SDL_Window); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
432 |
0 | 433 /* Figure out which button to use */ |
434 switch (msg) { | |
435 case WM_LBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
436 button = SDL_BUTTON_LEFT; |
0 | 437 state = SDL_PRESSED; |
438 break; | |
439 case WM_LBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
440 button = SDL_BUTTON_LEFT; |
0 | 441 state = SDL_RELEASED; |
442 break; | |
443 case WM_MBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
444 button = SDL_BUTTON_MIDDLE; |
0 | 445 state = SDL_PRESSED; |
446 break; | |
447 case WM_MBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
448 button = SDL_BUTTON_MIDDLE; |
0 | 449 state = SDL_RELEASED; |
450 break; | |
451 case WM_RBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
452 button = SDL_BUTTON_RIGHT; |
0 | 453 state = SDL_PRESSED; |
454 break; | |
455 case WM_RBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
456 button = SDL_BUTTON_RIGHT; |
0 | 457 state = SDL_RELEASED; |
458 break; | |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
459 case WM_XBUTTONDOWN: |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
460 xbuttonval = GET_XBUTTON_WPARAM(wParam); |
4113 | 461 button = SDL_BUTTON_X1 + xbuttonval - 1; |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
462 state = SDL_PRESSED; |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
463 break; |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
464 case WM_XBUTTONUP: |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
465 xbuttonval = GET_XBUTTON_WPARAM(wParam); |
4113 | 466 button = SDL_BUTTON_X1 + xbuttonval - 1; |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
467 state = SDL_RELEASED; |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
468 break; |
0 | 469 default: |
470 /* Eh? Unknown button? */ | |
471 return(0); | |
472 } | |
473 if ( state == SDL_PRESSED ) { | |
474 /* Grab mouse so we get up events */ | |
475 if ( ++mouse_pressed > 0 ) { | |
476 SetCapture(hwnd); | |
477 } | |
478 } else { | |
479 /* Release mouse after all up events */ | |
480 if ( --mouse_pressed <= 0 ) { | |
481 ReleaseCapture(); | |
482 mouse_pressed = 0; | |
483 } | |
484 } | |
485 posted = SDL_PrivateMouseButton( | |
4169 | 486 state, button, 0, 0); |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
487 |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
488 /* |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
489 * MSDN says: |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
490 * "Unlike the WM_LBUTTONUP, WM_MBUTTONUP, and WM_RBUTTONUP |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
491 * messages, an application should return TRUE from [an |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
492 * XBUTTON message] if it processes it. Doing so will allow |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
493 * software that simulates this message on Microsoft Windows |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
494 * systems earlier than Windows 2000 to determine whether |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
495 * the window procedure processed the message or called |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
496 * DefWindowProc to process it. |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
497 */ |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
498 if (xbuttonval > 0) |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
499 return(TRUE); |
0 | 500 } |
501 } | |
502 return(0); | |
503 | |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
504 |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
505 #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
506 case WM_MOUSEWHEEL: |
4167 | 507 if ( SDL_VideoSurface && ! DINPUT() ) { |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
508 int move = (short)HIWORD(wParam); |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
509 if ( move ) { |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
510 Uint8 button; |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
511 if ( move > 0 ) |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
512 button = SDL_BUTTON_WHEELUP; |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
513 else |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
514 button = SDL_BUTTON_WHEELDOWN; |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
515 posted = SDL_PrivateMouseButton( |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
516 SDL_PRESSED, button, 0, 0); |
332 | 517 posted |= SDL_PrivateMouseButton( |
518 SDL_RELEASED, button, 0, 0); | |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
519 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
520 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
521 return(0); |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
522 #endif |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
523 |
0 | 524 #ifdef WM_GETMINMAXINFO |
525 /* This message is sent as a way for us to "check" the values | |
526 * of a position change. If we don't like it, we can adjust | |
527 * the values before they are changed. | |
528 */ | |
529 case WM_GETMINMAXINFO: { | |
530 MINMAXINFO *info; | |
531 RECT size; | |
532 int x, y; | |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
533 int style; |
0 | 534 int width; |
535 int height; | |
536 | |
537 /* We don't want to clobber an internal resize */ | |
538 if ( SDL_resizing ) | |
539 return(0); | |
540 | |
541 /* We allow resizing with the SDL_RESIZABLE flag */ | |
542 if ( SDL_PublicSurface && | |
543 (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { | |
544 return(0); | |
545 } | |
546 | |
547 /* Get the current position of our window */ | |
548 GetWindowRect(SDL_Window, &size); | |
549 x = size.left; | |
550 y = size.top; | |
551 | |
552 /* Calculate current width and height of our window */ | |
553 size.top = 0; | |
554 size.left = 0; | |
555 if ( SDL_PublicSurface != NULL ) { | |
556 size.bottom = SDL_PublicSurface->h; | |
557 size.right = SDL_PublicSurface->w; | |
558 } else { | |
559 size.bottom = 0; | |
560 size.right = 0; | |
561 } | |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
562 |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
563 /* DJM - according to the docs for GetMenu(), the |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
564 return value is undefined if hwnd is a child window. |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
565 Aparently it's too difficult for MS to check |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
566 inside their function, so I have to do it here. |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
567 */ |
1480 | 568 style = GetWindowLong(hwnd, GWL_STYLE); |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
569 AdjustWindowRect( |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
570 &size, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
571 style, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
572 style & WS_CHILDWINDOW ? FALSE |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
573 : GetMenu(hwnd) != NULL); |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
574 |
0 | 575 width = size.right - size.left; |
576 height = size.bottom - size.top; | |
577 | |
578 /* Fix our size to the current size */ | |
579 info = (MINMAXINFO *)lParam; | |
580 info->ptMaxSize.x = width; | |
581 info->ptMaxSize.y = height; | |
582 info->ptMaxPosition.x = x; | |
583 info->ptMaxPosition.y = y; | |
584 info->ptMinTrackSize.x = width; | |
585 info->ptMinTrackSize.y = height; | |
586 info->ptMaxTrackSize.x = width; | |
587 info->ptMaxTrackSize.y = height; | |
588 } | |
589 return(0); | |
590 #endif /* WM_GETMINMAXINFO */ | |
591 | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
592 case WM_WINDOWPOSCHANGED: { |
0 | 593 SDL_VideoDevice *this = current_video; |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
594 int w, h; |
0 | 595 |
596 GetClientRect(SDL_Window, &SDL_bounds); | |
1290
c4a5a772c5d9
The event code was fine, and calculated the SDL_windowX/Y correctly.
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
597 ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds); |
c4a5a772c5d9
The event code was fine, and calculated the SDL_windowX/Y correctly.
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
598 ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1); |
1291
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
599 if ( !SDL_resizing && !IsZoomed(SDL_Window) && |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
600 SDL_PublicSurface && |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
601 !(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) { |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
602 SDL_windowX = SDL_bounds.left; |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
603 SDL_windowY = SDL_bounds.top; |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
604 } |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
605 w = SDL_bounds.right-SDL_bounds.left; |
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
606 h = SDL_bounds.bottom-SDL_bounds.top; |
0 | 607 if ( this->input_grab != SDL_GRAB_OFF ) { |
608 ClipCursor(&SDL_bounds); | |
609 } | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
610 if ( SDL_PublicSurface && |
0 | 611 (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
612 SDL_PrivateResize(w, h); |
0 | 613 } |
614 } | |
615 break; | |
616 | |
617 /* We need to set the cursor */ | |
618 case WM_SETCURSOR: { | |
619 Uint16 hittest; | |
620 | |
621 hittest = LOWORD(lParam); | |
622 if ( hittest == HTCLIENT ) { | |
623 SetCursor(SDL_hcursor); | |
624 return(TRUE); | |
625 } | |
626 } | |
627 break; | |
628 | |
629 /* We are about to get palette focus! */ | |
630 case WM_QUERYNEWPALETTE: { | |
631 WIN_RealizePalette(current_video); | |
632 return(TRUE); | |
633 } | |
634 break; | |
635 | |
636 /* Another application changed the palette */ | |
637 case WM_PALETTECHANGED: { | |
638 WIN_PaletteChanged(current_video, (HWND)wParam); | |
639 } | |
640 break; | |
641 | |
642 /* We were occluded, refresh our display */ | |
643 case WM_PAINT: { | |
644 HDC hdc; | |
645 PAINTSTRUCT ps; | |
646 | |
647 hdc = BeginPaint(SDL_Window, &ps); | |
648 if ( current_video->screen && | |
649 !(current_video->screen->flags & SDL_OPENGL) ) { | |
650 WIN_WinPAINT(current_video, hdc); | |
651 } | |
652 EndPaint(SDL_Window, &ps); | |
653 } | |
654 return(0); | |
655 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
656 /* DJM: Send an expose event in this case */ |
0 | 657 case WM_ERASEBKGND: { |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
658 posted = SDL_PrivateExpose(); |
0 | 659 } |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
660 return(0); |
0 | 661 |
662 case WM_CLOSE: { | |
663 if ( (posted = SDL_PrivateQuit()) ) | |
664 PostQuitMessage(0); | |
665 } | |
666 return(0); | |
667 | |
668 case WM_DESTROY: { | |
669 PostQuitMessage(0); | |
670 } | |
671 return(0); | |
672 | |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
673 #ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
674 case WM_INPUTLANGCHANGE: { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
675 codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
676 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
677 return(TRUE); |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
678 #endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
679 |
0 | 680 default: { |
681 /* Special handling by the video driver */ | |
682 if (HandleMessage) { | |
683 return(HandleMessage(current_video, | |
684 hwnd, msg, wParam, lParam)); | |
685 } | |
686 } | |
687 break; | |
688 } | |
689 return(DefWindowProc(hwnd, msg, wParam, lParam)); | |
690 } | |
691 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
692 /* Allow the application handle to be stored and retrieved later */ |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
693 static void *SDL_handle = NULL; |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
694 |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
695 void SDL_SetModuleHandle(void *handle) |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
696 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
697 SDL_handle = handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
698 } |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
699 void *SDL_GetModuleHandle(void) |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
700 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
701 void *handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
702 |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
703 if ( SDL_handle ) { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
704 handle = SDL_handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
705 } else { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
706 handle = GetModuleHandle(NULL); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
707 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
708 return(handle); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
709 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
710 |
0 | 711 /* This allows the SDL_WINDOWID hack */ |
1280
f61f045343d3
Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents:
1272
diff
changeset
|
712 BOOL SDL_windowid = FALSE; |
0 | 713 |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
714 static int app_registered = 0; |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
715 |
0 | 716 /* Register the class for this application -- exported for winmain.c */ |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
717 int SDL_RegisterApp(char *name, Uint32 style, void *hInst) |
0 | 718 { |
719 WNDCLASS class; | |
720 #ifdef WM_MOUSELEAVE | |
721 HMODULE handle; | |
722 #endif | |
723 | |
724 /* Only do this once... */ | |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
725 if ( app_registered ) { |
1498 | 726 ++app_registered; |
0 | 727 return(0); |
728 } | |
729 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
730 #ifndef CS_BYTEALIGNCLIENT |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
731 #define CS_BYTEALIGNCLIENT 0 |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
732 #endif |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
733 if ( ! name && ! SDL_Appname ) { |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
734 name = "SDL_app"; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
735 SDL_Appstyle = CS_BYTEALIGNCLIENT; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
736 SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
0 | 737 } |
738 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
739 if ( name ) { |
0 | 740 #ifdef _WIN32_WCE |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
741 /* WinCE uses the UNICODE version */ |
1505 | 742 SDL_Appname = SDL_iconv_utf8_ucs2(name); |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
743 #else |
4007 | 744 SDL_Appname = SDL_iconv_utf8_locale(name); |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
745 #endif /* _WIN32_WCE */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
746 SDL_Appstyle = style; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
747 SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
748 } |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
749 |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
750 /* Register the application class */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
751 class.hCursor = NULL; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
752 class.hIcon = LoadImage(SDL_Instance, SDL_Appname, |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
753 IMAGE_ICON, |
0 | 754 0, 0, LR_DEFAULTCOLOR); |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
13
diff
changeset
|
755 class.lpszMenuName = NULL; |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
756 class.lpszClassName = SDL_Appname; |
0 | 757 class.hbrBackground = NULL; |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
758 class.hInstance = SDL_Instance; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
759 class.style = SDL_Appstyle; |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
760 #if SDL_VIDEO_OPENGL |
0 | 761 class.style |= CS_OWNDC; |
762 #endif | |
763 class.lpfnWndProc = WinMessage; | |
764 class.cbWndExtra = 0; | |
765 class.cbClsExtra = 0; | |
766 if ( ! RegisterClass(&class) ) { | |
767 SDL_SetError("Couldn't register application class"); | |
768 return(-1); | |
769 } | |
770 | |
771 #ifdef WM_MOUSELEAVE | |
772 /* Get the version of TrackMouseEvent() we use */ | |
773 _TrackMouseEvent = NULL; | |
774 handle = GetModuleHandle("USER32.DLL"); | |
775 if ( handle ) { | |
776 _TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent"); | |
777 } | |
778 if ( _TrackMouseEvent == NULL ) { | |
779 _TrackMouseEvent = WIN_TrackMouseEvent; | |
780 } | |
781 #endif /* WM_MOUSELEAVE */ | |
782 | |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
783 #ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
784 /* Initialise variables for SDL_ToUnicode() */ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
785 codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
786 SDL_ToUnicode = Is9xME() ? ToUnicode9xME : ToUnicode; |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
787 #endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
788 |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
789 app_registered = 1; |
0 | 790 return(0); |
791 } | |
792 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
793 /* Unregisters the windowclass registered in SDL_RegisterApp above. */ |
1150
7d8e1925f35b
Typo that broke Windows builds.
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
794 void SDL_UnregisterApp() |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
795 { |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
796 WNDCLASS class; |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
797 |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
798 /* SDL_RegisterApp might not have been called before */ |
1498 | 799 if ( !app_registered ) { |
800 return; | |
801 } | |
802 --app_registered; | |
803 if ( app_registered == 0 ) { | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
804 /* Check for any registered window classes. */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
805 if ( GetClassInfo(SDL_Instance, SDL_Appname, &class) ) { |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
806 UnregisterClass(SDL_Appname, SDL_Instance); |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
807 } |
1498 | 808 SDL_free(SDL_Appname); |
809 SDL_Appname = NULL; | |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
810 } |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
811 } |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
812 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
813 #ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
814 /* JFP: Implementation of ToUnicode() that works on 9x/ME/2K/XP */ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
815 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
816 static int Is9xME() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
817 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
818 OSVERSIONINFO info; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
819 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
820 SDL_memset(&info, 0, sizeof(info)); |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
821 info.dwOSVersionInfoSize = sizeof(info); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
822 if (!GetVersionEx(&info)) { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
823 return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
824 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
825 return (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
826 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
827 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
828 static int GetCodePage() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
829 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
830 char buff[8]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
831 int lcid = MAKELCID(LOWORD(GetKeyboardLayout(0)), SORT_DEFAULT); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
832 int cp = GetACP(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
833 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
834 if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) { |
1341
d02b552e5304
Configure dynamically generates SDL_config.h
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
835 cp = SDL_atoi(buff); |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
836 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
837 return cp; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
838 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
839 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
840 static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, PBYTE keystate, LPWSTR wchars, int wsize, UINT flags) |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
841 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
842 BYTE chars[2]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
843 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
844 if (ToAsciiEx(vkey, scancode, keystate, (WORD*)chars, 0, GetKeyboardLayout(0)) == 1) { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
845 return MultiByteToWideChar(codepage, 0, chars, 1, wchars, wsize); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
846 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
847 return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
848 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
849 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
850 #endif /* !NO_GETKEYBOARDSTATE */ |