Mercurial > sdl-ios-xcode
annotate src/video/wincommon/SDL_sysevents.c @ 4066:58a5055da431 SDL-1.2
More improvements for bug #373
Show the SDL cursor in the window and the arrow cursor outside the window.
This is also supposed to show the SDL cursor when activated, but that code
isn't working yet...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 14 Jul 2007 08:27:06 +0000 |
parents | f5794774970d |
children | 82dab719502e |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
3 Copyright (C) 1997-2006 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 | |
53 #ifdef _WIN32_WCE | |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
54 #include "../gapi/SDL_gapivideo.h" |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
55 |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
56 #define IsZoomed(HWND) 1 |
0 | 57 #define NO_GETKEYBOARDSTATE |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
58 #if _WIN32_WCE < 420 |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
59 #define NO_CHANGEDISPLAYSETTINGS |
0 | 60 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
61 #endif |
0 | 62 |
63 /* The window we use for everything... */ | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
64 #ifdef _WIN32_WCE |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
65 LPWSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
66 #else |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
67 LPSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
68 #endif |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
69 Uint32 SDL_Appstyle = 0; |
0 | 70 HINSTANCE SDL_Instance = NULL; |
71 HWND SDL_Window = NULL; | |
72 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
|
73 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
|
74 int SDL_windowY = 0; |
0 | 75 int SDL_resizing = 0; |
76 int mouse_relative = 0; | |
77 int posted = 0; | |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
78 #ifndef NO_CHANGEDISPLAYSETTINGS |
1295
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1291
diff
changeset
|
79 DEVMODE SDL_desktop_mode; |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
80 DEVMODE SDL_fullscreen_mode; |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
81 #endif |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
82 WORD *gamma_saved = NULL; |
0 | 83 |
84 | |
85 /* 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
|
86 LONG (*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL; |
3992 | 87 void (*WIN_Activate)(_THIS, BOOL active, BOOL iconic); |
0 | 88 void (*WIN_RealizePalette)(_THIS); |
89 void (*WIN_PaletteChanged)(_THIS, HWND window); | |
90 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
|
91 extern void DIB_SwapGamma(_THIS); |
0 | 92 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
93 #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
|
94 /* 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
|
95 static int codepage; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
96 static int Is9xME(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
97 static int GetCodePage(); |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
98 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
|
99 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
100 ToUnicodeFN SDL_ToUnicode = ToUnicode9xME; |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
101 #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
|
102 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
103 |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
104 #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
|
105 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
106 // 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
|
107 HINSTANCE aygshell = NULL; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
108 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
|
109 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
110 #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
|
111 #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
|
112 #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
|
113 #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
|
114 #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
|
115 #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
|
116 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
117 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
|
118 { |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
119 if( !aygshell ) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
120 aygshell = SDL_LoadObject("aygshell.dll"); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
121 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
|
122 { |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
123 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
|
124 } |
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 |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
127 /* for gapi landscape mode */ |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
128 static void GapiTransform(SDL_ScreenOrientation rotate, char hires, Sint16 *x, Sint16 *y) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
129 Sint16 rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
130 Sint16 rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
131 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
132 if (hires) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
133 *x = *x * 2; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
134 *y = *y * 2; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
135 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
136 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
137 switch(rotate) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
138 case SDL_ORIENTATION_UP: |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
139 { |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
140 /* this code needs testing on a real device! |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
141 So it will be enabled later */ |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
142 /* |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
143 #ifdef _WIN32_WCE |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
144 #if _WIN32_WCE >= 420 |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
145 // test device orientation |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
146 // FIXME: do not check every mouse message |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
147 DEVMODE settings; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
148 SDL_memset(&settings, 0, sizeof(DEVMODE)); |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
149 settings.dmSize = sizeof(DEVMODE); |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
150 settings.dmFields = DM_DISPLAYORIENTATION; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
151 ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL); |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
152 if( settings.dmOrientation == DMDO_90 ) |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
153 { |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
154 rotatedX = SDL_VideoSurface->h - *x; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
155 rotatedY = *y; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
156 *x = rotatedX; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
157 *y = rotatedY; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
158 } |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
159 #endif |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
160 #endif */ |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
161 } |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
162 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
163 case SDL_ORIENTATION_RIGHT: |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
164 if (!SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
165 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
166 rotatedX = SDL_VideoSurface->w - *y; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
167 rotatedY = *x; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
168 *x = rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
169 *y = rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
170 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
171 case SDL_ORIENTATION_LEFT: |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
172 if (!SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
173 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
174 rotatedX = *y; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
175 rotatedY = SDL_VideoSurface->h - *x; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
176 *x = rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
177 *y = rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
178 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
179 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
180 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
181 |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
182 #endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
183 |
1523 | 184 /* JC 14 Mar 2006 |
185 This is used all over the place, in the windib driver and in the dx5 driver | |
186 So we may as well stick it here instead of having multiple copies scattered | |
187 about | |
188 */ | |
189 void WIN_FlushMessageQueue() | |
190 { | |
191 MSG msg; | |
192 while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { | |
193 if ( msg.message == WM_QUIT ) break; | |
194 TranslateMessage( &msg ); | |
195 DispatchMessage( &msg ); | |
196 } | |
197 } | |
198 | |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
199 static void SDL_RestoreGameMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
200 { |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
201 #ifdef _WIN32_WCE |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
202 SDL_VideoDevice *this = current_video; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
203 if(SDL_strcmp(this->name, "gapi") == 0) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
204 { |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
205 if( this->hidden->suspended ) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
206 { |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
207 this->hidden->suspended = 0; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
208 } |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
209 } |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
210 #else |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
211 ShowWindow(SDL_Window, SW_RESTORE); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
212 #endif |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
213 |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
214 #ifndef NO_CHANGEDISPLAYSETTINGS |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
215 #ifndef _WIN32_WCE |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
216 ChangeDisplaySettings(&SDL_fullscreen_mode, CDS_FULLSCREEN); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
217 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
218 #endif /* NO_CHANGEDISPLAYSETTINGS */ |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
219 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
220 static void SDL_RestoreDesktopMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
221 { |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
222 |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
223 #ifdef _WIN32_WCE |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
224 SDL_VideoDevice *this = current_video; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
225 if(SDL_strcmp(this->name, "gapi") == 0) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
226 { |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
227 if( !this->hidden->suspended ) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
228 { |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
229 this->hidden->suspended = 1; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
230 } |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
231 } |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
232 #else |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
233 /* 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
|
234 ShowWindow(SDL_Window, SW_MINIMIZE); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
235 #endif |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
236 |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
237 #ifndef NO_CHANGEDISPLAYSETTINGS |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
238 #ifndef _WIN32_WCE |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
239 ChangeDisplaySettings(NULL, 0); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
240 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
241 #endif /* NO_CHANGEDISPLAYSETTINGS */ |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
242 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
243 |
0 | 244 #ifdef WM_MOUSELEAVE |
245 /* | |
246 Special code to handle mouse leave events - this sucks... | |
247 http://support.microsoft.com/support/kb/articles/q183/1/07.asp | |
248 | |
249 TrackMouseEvent() is only available on Win98 and WinNT. | |
250 _TrackMouseEvent() is available on Win95, but isn't yet in the mingw32 | |
251 development environment, and only works on systems that have had IE 3.0 | |
252 or newer installed on them (which is not the case with the base Win95). | |
253 Therefore, we implement our own version of _TrackMouseEvent() which | |
254 uses our own implementation if TrackMouseEvent() is not available. | |
255 */ | |
256 static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL; | |
257 | |
258 static VOID CALLBACK | |
259 TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) | |
260 { | |
261 RECT rect; | |
262 POINT pt; | |
263 | |
264 GetClientRect(hWnd, &rect); | |
265 MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2); | |
266 GetCursorPos(&pt); | |
267 if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) { | |
268 if ( !KillTimer(hWnd, idEvent) ) { | |
269 /* Error killing the timer! */ | |
270 } | |
271 PostMessage(hWnd, WM_MOUSELEAVE, 0, 0); | |
272 } | |
273 } | |
274 static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme) | |
275 { | |
276 if ( ptme->dwFlags == TME_LEAVE ) { | |
277 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
|
278 (TIMERPROC)TrackMouseTimerProc) != 0; |
0 | 279 } |
280 return FALSE; | |
281 } | |
282 #endif /* WM_MOUSELEAVE */ | |
283 | |
284 /* Function to retrieve the current keyboard modifiers */ | |
285 static void WIN_GetKeyboardState(void) | |
286 { | |
287 #ifndef NO_GETKEYBOARDSTATE | |
288 SDLMod state; | |
289 BYTE keyboard[256]; | |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
290 Uint8 *kstate = SDL_GetKeyState(NULL); |
0 | 291 |
292 state = KMOD_NONE; | |
293 if ( GetKeyboardState(keyboard) ) { | |
294 if ( keyboard[VK_LSHIFT] & 0x80) { | |
295 state |= KMOD_LSHIFT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
296 kstate[SDLK_LSHIFT] = SDL_PRESSED; |
0 | 297 } |
298 if ( keyboard[VK_RSHIFT] & 0x80) { | |
299 state |= KMOD_RSHIFT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
300 kstate[SDLK_RSHIFT] = SDL_PRESSED; |
0 | 301 } |
302 if ( keyboard[VK_LCONTROL] & 0x80) { | |
303 state |= KMOD_LCTRL; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
304 kstate[SDLK_LCTRL] = SDL_PRESSED; |
0 | 305 } |
306 if ( keyboard[VK_RCONTROL] & 0x80) { | |
307 state |= KMOD_RCTRL; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
308 kstate[SDLK_RCTRL] = SDL_PRESSED; |
0 | 309 } |
310 if ( keyboard[VK_LMENU] & 0x80) { | |
311 state |= KMOD_LALT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
312 kstate[SDLK_LALT] = SDL_PRESSED; |
0 | 313 } |
314 if ( keyboard[VK_RMENU] & 0x80) { | |
315 state |= KMOD_RALT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
316 kstate[SDLK_RALT] = SDL_PRESSED; |
0 | 317 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
318 if ( keyboard[VK_NUMLOCK] & 0x01) { |
0 | 319 state |= KMOD_NUM; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
320 kstate[SDLK_NUMLOCK] = SDL_PRESSED; |
0 | 321 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
322 if ( keyboard[VK_CAPITAL] & 0x01) { |
0 | 323 state |= KMOD_CAPS; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
324 kstate[SDLK_CAPSLOCK] = SDL_PRESSED; |
0 | 325 } |
326 } | |
327 SDL_SetModState(state); | |
328 #endif /* !NO_GETKEYBOARDSTATE */ | |
329 } | |
330 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
331 /* 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
|
332 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
|
333 */ |
1456
84de7511f79f
Fixed a bunch of 64-bit compatibility problems
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
334 LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
0 | 335 { |
336 SDL_VideoDevice *this = current_video; | |
337 static int mouse_pressed = 0; | |
338 static int in_window = 0; | |
339 #ifdef WMMSG_DEBUG | |
340 fprintf(stderr, "Received windows message: "); | |
341 if ( msg > MAX_WMMSG ) { | |
342 fprintf(stderr, "%d", msg); | |
343 } else { | |
344 fprintf(stderr, "%s", wmtab[msg]); | |
345 } | |
346 fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam); | |
347 #endif | |
348 switch (msg) { | |
349 | |
350 case WM_ACTIVATE: { | |
351 SDL_VideoDevice *this = current_video; | |
3992 | 352 BOOL active, minimized; |
0 | 353 Uint8 appstate; |
354 | |
355 minimized = HIWORD(wParam); | |
3992 | 356 active = (LOWORD(wParam) != WA_INACTIVE) && !minimized; |
357 if ( active ) { | |
0 | 358 /* Gain the following states */ |
359 appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS; | |
360 if ( this->input_grab != SDL_GRAB_OFF ) { | |
361 WIN_GrabInput(this, SDL_GRAB_ON); | |
362 } | |
363 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
|
364 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
365 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
366 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
367 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
368 SDL_RestoreGameMode(); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
369 } |
0 | 370 } |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
371 #if defined(_WIN32_WCE) |
3992 | 372 if ( WINDIB_FULLSCREEN() ) { |
373 LoadAygshell(); | |
374 if( SHFullScreen ) | |
375 SHFullScreen(SDL_Window, SHFS_HIDESTARTICON|SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON); | |
376 else | |
377 ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_HIDE); | |
378 } | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
379 #endif |
0 | 380 posted = SDL_PrivateAppActive(1, appstate); |
381 WIN_GetKeyboardState(); | |
382 } else { | |
383 /* Lose the following states */ | |
384 appstate = SDL_APPINPUTFOCUS; | |
385 if ( minimized ) { | |
386 appstate |= SDL_APPACTIVE; | |
387 } | |
388 if ( this->input_grab != SDL_GRAB_OFF ) { | |
389 WIN_GrabInput(this, SDL_GRAB_OFF); | |
390 } | |
391 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
|
392 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
393 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
394 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
395 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
396 SDL_RestoreDesktopMode(); |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
397 #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
|
398 LoadAygshell(); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
399 if( SHFullScreen ) |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
400 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
|
401 else |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
402 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
|
403 #endif |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
404 } |
0 | 405 } |
406 posted = SDL_PrivateAppActive(0, appstate); | |
407 } | |
3992 | 408 WIN_Activate(this, active, minimized); |
0 | 409 return(0); |
410 } | |
411 break; | |
412 | |
413 case WM_MOUSEMOVE: { | |
414 | |
415 /* Mouse is handled by DirectInput when fullscreen */ | |
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
416 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 417 Sint16 x, y; |
418 | |
419 /* mouse has entered the window */ | |
420 if ( ! in_window ) { | |
421 #ifdef WM_MOUSELEAVE | |
422 TRACKMOUSEEVENT tme; | |
423 | |
424 tme.cbSize = sizeof(tme); | |
425 tme.dwFlags = TME_LEAVE; | |
426 tme.hwndTrack = SDL_Window; | |
427 _TrackMouseEvent(&tme); | |
428 #endif /* WM_MOUSELEAVE */ | |
429 in_window = TRUE; | |
430 | |
431 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | |
432 } | |
433 | |
434 /* mouse has moved within the window */ | |
435 x = LOWORD(lParam); | |
436 y = HIWORD(lParam); | |
437 if ( mouse_relative ) { | |
438 POINT center; | |
439 center.x = (SDL_VideoSurface->w/2); | |
440 center.y = (SDL_VideoSurface->h/2); | |
441 x -= (Sint16)center.x; | |
442 y -= (Sint16)center.y; | |
443 if ( x || y ) { | |
444 ClientToScreen(SDL_Window, ¢er); | |
445 SetCursorPos(center.x, center.y); | |
446 posted = SDL_PrivateMouseMotion(0, 1, x, y); | |
447 } | |
448 } else { | |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
449 #ifdef _WIN32_WCE |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
450 if (SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
451 GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &x, &y); |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
452 #endif |
0 | 453 posted = SDL_PrivateMouseMotion(0, 0, x, y); |
454 } | |
455 } | |
456 } | |
457 return(0); | |
458 | |
459 #ifdef WM_MOUSELEAVE | |
460 case WM_MOUSELEAVE: { | |
461 | |
462 /* Mouse is handled by DirectInput when fullscreen */ | |
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
463 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 464 /* mouse has left the window */ |
465 /* or */ | |
466 /* Elvis has left the building! */ | |
467 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | |
468 } | |
829
77bca0665b69
Fixed mouse focus events after resetting video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
565
diff
changeset
|
469 in_window = FALSE; |
0 | 470 } |
471 return(0); | |
472 #endif /* WM_MOUSELEAVE */ | |
473 | |
474 case WM_LBUTTONDOWN: | |
475 case WM_LBUTTONUP: | |
476 case WM_MBUTTONDOWN: | |
477 case WM_MBUTTONUP: | |
478 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
|
479 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
|
480 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
|
481 case WM_XBUTTONUP: { |
0 | 482 /* Mouse is handled by DirectInput when fullscreen */ |
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
483 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
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
|
484 WORD xbuttonval = 0; |
0 | 485 Sint16 x, y; |
486 Uint8 button, state; | |
487 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
488 /* DJM: |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
489 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
|
490 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
|
491 (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
|
492 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
493 SetFocus(SDL_Window); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
494 |
0 | 495 /* Figure out which button to use */ |
496 switch (msg) { | |
497 case WM_LBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
498 button = SDL_BUTTON_LEFT; |
0 | 499 state = SDL_PRESSED; |
500 break; | |
501 case WM_LBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
502 button = SDL_BUTTON_LEFT; |
0 | 503 state = SDL_RELEASED; |
504 break; | |
505 case WM_MBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
506 button = SDL_BUTTON_MIDDLE; |
0 | 507 state = SDL_PRESSED; |
508 break; | |
509 case WM_MBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
510 button = SDL_BUTTON_MIDDLE; |
0 | 511 state = SDL_RELEASED; |
512 break; | |
513 case WM_RBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
514 button = SDL_BUTTON_RIGHT; |
0 | 515 state = SDL_PRESSED; |
516 break; | |
517 case WM_RBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
518 button = SDL_BUTTON_RIGHT; |
0 | 519 state = SDL_RELEASED; |
520 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
|
521 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
|
522 xbuttonval = GET_XBUTTON_WPARAM(wParam); |
4011
f5794774970d
Reverted mousewheel support in 1.2, since it breaks binary compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
4010
diff
changeset
|
523 button = SDL_BUTTON_WHEELDOWN + xbuttonval; |
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
|
524 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
|
525 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
|
526 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
|
527 xbuttonval = GET_XBUTTON_WPARAM(wParam); |
4011
f5794774970d
Reverted mousewheel support in 1.2, since it breaks binary compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
4010
diff
changeset
|
528 button = SDL_BUTTON_WHEELDOWN + xbuttonval; |
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
|
529 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
|
530 break; |
0 | 531 default: |
532 /* Eh? Unknown button? */ | |
533 return(0); | |
534 } | |
535 if ( state == SDL_PRESSED ) { | |
536 /* Grab mouse so we get up events */ | |
537 if ( ++mouse_pressed > 0 ) { | |
538 SetCapture(hwnd); | |
539 } | |
540 } else { | |
541 /* Release mouse after all up events */ | |
542 if ( --mouse_pressed <= 0 ) { | |
543 ReleaseCapture(); | |
544 mouse_pressed = 0; | |
545 } | |
546 } | |
547 if ( mouse_relative ) { | |
548 /* RJR: March 28, 2000 | |
549 report internal mouse position if in relative mode */ | |
550 x = 0; y = 0; | |
551 } else { | |
552 x = (Sint16)LOWORD(lParam); | |
553 y = (Sint16)HIWORD(lParam); | |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
554 #ifdef _WIN32_WCE |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
555 if (SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
556 GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &x, &y); |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
557 #endif |
0 | 558 } |
559 posted = SDL_PrivateMouseButton( | |
560 state, button, x, y); | |
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
|
561 |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
562 /* |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
563 * 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
|
564 * "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
|
565 * 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
|
566 * 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
|
567 * 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
|
568 * 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
|
569 * 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
|
570 * 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
|
571 */ |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
572 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
|
573 return(TRUE); |
0 | 574 } |
575 } | |
576 return(0); | |
577 | |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
578 |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
579 #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
|
580 case WM_MOUSEWHEEL: |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
581 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
582 int move = (short)HIWORD(wParam); |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
583 if ( move ) { |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
584 Uint8 button; |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
585 if ( move > 0 ) |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
586 button = SDL_BUTTON_WHEELUP; |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
587 else |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
588 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
|
589 posted = SDL_PrivateMouseButton( |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
590 SDL_PRESSED, button, 0, 0); |
332 | 591 posted |= SDL_PrivateMouseButton( |
592 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
|
593 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
594 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
595 return(0); |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
596 #endif |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
597 |
0 | 598 #ifdef WM_GETMINMAXINFO |
599 /* This message is sent as a way for us to "check" the values | |
600 * of a position change. If we don't like it, we can adjust | |
601 * the values before they are changed. | |
602 */ | |
603 case WM_GETMINMAXINFO: { | |
604 MINMAXINFO *info; | |
605 RECT size; | |
606 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
|
607 int style; |
0 | 608 int width; |
609 int height; | |
610 | |
611 /* We don't want to clobber an internal resize */ | |
612 if ( SDL_resizing ) | |
613 return(0); | |
614 | |
615 /* We allow resizing with the SDL_RESIZABLE flag */ | |
616 if ( SDL_PublicSurface && | |
617 (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { | |
618 return(0); | |
619 } | |
620 | |
621 /* Get the current position of our window */ | |
622 GetWindowRect(SDL_Window, &size); | |
623 x = size.left; | |
624 y = size.top; | |
625 | |
626 /* Calculate current width and height of our window */ | |
627 size.top = 0; | |
628 size.left = 0; | |
629 if ( SDL_PublicSurface != NULL ) { | |
630 size.bottom = SDL_PublicSurface->h; | |
631 size.right = SDL_PublicSurface->w; | |
632 } else { | |
633 size.bottom = 0; | |
634 size.right = 0; | |
635 } | |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
636 |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
637 /* 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
|
638 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
|
639 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
|
640 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
|
641 */ |
1480 | 642 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
|
643 AdjustWindowRect( |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
644 &size, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
645 style, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
646 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
|
647 : GetMenu(hwnd) != NULL); |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
648 |
0 | 649 width = size.right - size.left; |
650 height = size.bottom - size.top; | |
651 | |
652 /* Fix our size to the current size */ | |
653 info = (MINMAXINFO *)lParam; | |
654 info->ptMaxSize.x = width; | |
655 info->ptMaxSize.y = height; | |
656 info->ptMaxPosition.x = x; | |
657 info->ptMaxPosition.y = y; | |
658 info->ptMinTrackSize.x = width; | |
659 info->ptMinTrackSize.y = height; | |
660 info->ptMaxTrackSize.x = width; | |
661 info->ptMaxTrackSize.y = height; | |
662 } | |
663 return(0); | |
664 #endif /* WM_GETMINMAXINFO */ | |
665 | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
666 case WM_WINDOWPOSCHANGED: { |
0 | 667 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
|
668 int w, h; |
0 | 669 |
670 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
|
671 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
|
672 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
|
673 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
|
674 SDL_PublicSurface && |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
675 !(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
|
676 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
|
677 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
|
678 } |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
679 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
|
680 h = SDL_bounds.bottom-SDL_bounds.top; |
0 | 681 if ( this->input_grab != SDL_GRAB_OFF ) { |
682 ClipCursor(&SDL_bounds); | |
683 } | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
684 if ( SDL_PublicSurface && |
0 | 685 (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
|
686 SDL_PrivateResize(w, h); |
0 | 687 } |
688 } | |
689 break; | |
690 | |
691 /* We need to set the cursor */ | |
692 case WM_SETCURSOR: { | |
693 Uint16 hittest; | |
694 | |
695 hittest = LOWORD(lParam); | |
696 if ( hittest == HTCLIENT ) { | |
697 SetCursor(SDL_hcursor); | |
698 return(TRUE); | |
699 } | |
700 } | |
701 break; | |
702 | |
703 /* We are about to get palette focus! */ | |
704 case WM_QUERYNEWPALETTE: { | |
705 WIN_RealizePalette(current_video); | |
706 return(TRUE); | |
707 } | |
708 break; | |
709 | |
710 /* Another application changed the palette */ | |
711 case WM_PALETTECHANGED: { | |
712 WIN_PaletteChanged(current_video, (HWND)wParam); | |
713 } | |
714 break; | |
715 | |
716 /* We were occluded, refresh our display */ | |
717 case WM_PAINT: { | |
718 HDC hdc; | |
719 PAINTSTRUCT ps; | |
720 | |
721 hdc = BeginPaint(SDL_Window, &ps); | |
722 if ( current_video->screen && | |
723 !(current_video->screen->flags & SDL_OPENGL) ) { | |
724 WIN_WinPAINT(current_video, hdc); | |
725 } | |
726 EndPaint(SDL_Window, &ps); | |
727 } | |
728 return(0); | |
729 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
730 /* DJM: Send an expose event in this case */ |
0 | 731 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
|
732 posted = SDL_PrivateExpose(); |
0 | 733 } |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
734 return(0); |
0 | 735 |
736 case WM_CLOSE: { | |
737 if ( (posted = SDL_PrivateQuit()) ) | |
738 PostQuitMessage(0); | |
739 } | |
740 return(0); | |
741 | |
742 case WM_DESTROY: { | |
743 PostQuitMessage(0); | |
744 } | |
745 return(0); | |
746 | |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
747 #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
|
748 case WM_INPUTLANGCHANGE: { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
749 codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
750 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
751 return(TRUE); |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
752 #endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
753 |
0 | 754 default: { |
755 /* Special handling by the video driver */ | |
756 if (HandleMessage) { | |
757 return(HandleMessage(current_video, | |
758 hwnd, msg, wParam, lParam)); | |
759 } | |
760 } | |
761 break; | |
762 } | |
763 return(DefWindowProc(hwnd, msg, wParam, lParam)); | |
764 } | |
765 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
766 /* 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
|
767 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
|
768 |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
769 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
|
770 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
771 SDL_handle = handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
772 } |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
773 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
|
774 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
775 void *handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
776 |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
777 if ( SDL_handle ) { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
778 handle = SDL_handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
779 } else { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
780 handle = GetModuleHandle(NULL); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
781 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
782 return(handle); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
783 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
784 |
0 | 785 /* 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
|
786 BOOL SDL_windowid = FALSE; |
0 | 787 |
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
|
788 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
|
789 |
0 | 790 /* 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
|
791 int SDL_RegisterApp(char *name, Uint32 style, void *hInst) |
0 | 792 { |
793 WNDCLASS class; | |
794 #ifdef WM_MOUSELEAVE | |
795 HMODULE handle; | |
796 #endif | |
797 | |
798 /* 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
|
799 if ( app_registered ) { |
1498 | 800 ++app_registered; |
0 | 801 return(0); |
802 } | |
803 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
804 #ifndef CS_BYTEALIGNCLIENT |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
805 #define CS_BYTEALIGNCLIENT 0 |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
806 #endif |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
807 if ( ! name && ! SDL_Appname ) { |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
808 name = "SDL_app"; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
809 SDL_Appstyle = CS_BYTEALIGNCLIENT; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
810 SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
0 | 811 } |
812 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
813 if ( name ) { |
0 | 814 #ifdef _WIN32_WCE |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
815 /* WinCE uses the UNICODE version */ |
1505 | 816 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
|
817 #else |
4007 | 818 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
|
819 #endif /* _WIN32_WCE */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
820 SDL_Appstyle = style; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
821 SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
822 } |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
823 |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
824 /* Register the application class */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
825 class.hCursor = NULL; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
826 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
|
827 IMAGE_ICON, |
0 | 828 0, 0, LR_DEFAULTCOLOR); |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
13
diff
changeset
|
829 class.lpszMenuName = NULL; |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
830 class.lpszClassName = SDL_Appname; |
0 | 831 class.hbrBackground = NULL; |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
832 class.hInstance = SDL_Instance; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
833 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
|
834 #if SDL_VIDEO_OPENGL |
0 | 835 class.style |= CS_OWNDC; |
836 #endif | |
837 class.lpfnWndProc = WinMessage; | |
838 class.cbWndExtra = 0; | |
839 class.cbClsExtra = 0; | |
840 if ( ! RegisterClass(&class) ) { | |
841 SDL_SetError("Couldn't register application class"); | |
842 return(-1); | |
843 } | |
844 | |
845 #ifdef WM_MOUSELEAVE | |
846 /* Get the version of TrackMouseEvent() we use */ | |
847 _TrackMouseEvent = NULL; | |
848 handle = GetModuleHandle("USER32.DLL"); | |
849 if ( handle ) { | |
850 _TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent"); | |
851 } | |
852 if ( _TrackMouseEvent == NULL ) { | |
853 _TrackMouseEvent = WIN_TrackMouseEvent; | |
854 } | |
855 #endif /* WM_MOUSELEAVE */ | |
856 | |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
857 #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
|
858 /* 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
|
859 codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
860 SDL_ToUnicode = Is9xME() ? ToUnicode9xME : ToUnicode; |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
861 #endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
862 |
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
|
863 app_registered = 1; |
0 | 864 return(0); |
865 } | |
866 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
867 /* 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
|
868 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
|
869 { |
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
|
870 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
|
871 |
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
|
872 /* SDL_RegisterApp might not have been called before */ |
1498 | 873 if ( !app_registered ) { |
874 return; | |
875 } | |
876 --app_registered; | |
877 if ( app_registered == 0 ) { | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
878 /* Check for any registered window classes. */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
879 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
|
880 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
|
881 } |
1498 | 882 SDL_free(SDL_Appname); |
883 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
|
884 } |
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
|
885 } |
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
|
886 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
887 #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
|
888 /* 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
|
889 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
890 static int Is9xME() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
891 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
892 OSVERSIONINFO info; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
893 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
894 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
|
895 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
|
896 if (!GetVersionEx(&info)) { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
897 return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
898 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
899 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
|
900 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
901 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
902 static int GetCodePage() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
903 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
904 char buff[8]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
905 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
|
906 int cp = GetACP(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
907 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
908 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
|
909 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
|
910 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
911 return cp; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
912 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
913 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
914 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
|
915 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
916 BYTE chars[2]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
917 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
918 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
|
919 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
|
920 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
921 return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
922 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
923 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
924 #endif /* !NO_GETKEYBOARDSTATE */ |