Mercurial > sdl-ios-xcode
annotate src/video/wincommon/SDL_sysevents.c @ 4167:a6f635e5eaa6 SDL-1.2
Fixed bug #611
From Tim Angus 2008-08-12 11:18:06
I'm one of the maintainers of ioquake3.org, an updated version of the
Quake 3 engine. Relatively recently, we moved ioq3 to use SDL as a
replacement for 95% of the platform specific code that was there. On the
whole it's doing a great job but unfortunately since the move we've been
getting complaints about the quality of the mouse input on the Windows
platform to the point where for many the game is unplayable. Put in
other terms, the current stable SDL 1.2 is basically not fit for purpose
if you need high quality mouse input as you do in a first person shooter.
Over the weekend I decided to pull my finger out and actually figure out
what's going on. There are basically two major problems. Firstly, when
using the "windib" driver, mouse input is gathered via the WM_MOUSEMOVE
message. Googling for this indicates that often this is known to result
in "spurious" and/or "missing" mouse movement events; this is the
primary cause of the poor mouse input. The second problem is that the
"directx" driver does not work at all in combination with OpenGL meaning
that you can't use DirectInput if your application also uses OpenGL. In
other words you're locked into using the "windib" driver and its poor
mouse input.
In order to address these problems I've done the following:
* Remove WM_MOUSEMOVE based motion event generation and replace with
calls to GetCursorPos which seems much more reliable. In order to
achieve this I've moved mouse motion out into a separate function that
is called once per DIB_PumpEvents.
* Remove the restriction on the "directx" driver being inoperable in
combination with OpenGL. There is a bug for this issues that I've
hijacked to a certain extent
(http://bugzilla.libsdl.org/show_bug.cgi?id=265). I'm the first to admit
I don't really understand why this restriction is there in the first
place. The commit message for the bug fix that introduced this
restriction (r581) isn't very elaborate and I couldn't see any other bug
tracking the issue. If anyone has more information on the bug that was
avoided by r581 it would be helpful as I/someone could then look into
addressing the problem without disabling the "directx" driver.
* I've also removed the restriction on not being allowed to use
DirectInput in windowed mode. I couldn't see any reason for this, at
least not from our perspective. I have my suspicions that it'll be
something like matching up the cursor with the mouse coordinates...
* I bumped up the DirectInput API used to version 7 in order to get
access to mouse buttons 4-7. I've had to inject a little bit of the DX7
headers into SDL there as the MinGW ones aren't up to date in this respect.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 02 Apr 2009 04:43:36 +0000 |
parents | 3b7fc3416601 |
children | 27c0db0fbfad |
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 |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
134 /* 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
|
135 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
|
136 Sint16 rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
137 Sint16 rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
138 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
139 if (hires) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
140 *x = *x * 2; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
141 *y = *y * 2; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
142 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
143 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
144 switch(rotate) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
145 case SDL_ORIENTATION_UP: |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
146 { |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
147 /* 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
|
148 So it will be enabled later */ |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
149 /* |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
150 #ifdef _WIN32_WCE |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
151 #if _WIN32_WCE >= 420 |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
152 // test device orientation |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
153 // 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
|
154 DEVMODE settings; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
155 SDL_memset(&settings, 0, sizeof(DEVMODE)); |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
156 settings.dmSize = sizeof(DEVMODE); |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
157 settings.dmFields = DM_DISPLAYORIENTATION; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
158 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
|
159 if( settings.dmOrientation == DMDO_90 ) |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
160 { |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
161 rotatedX = SDL_VideoSurface->h - *x; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
162 rotatedY = *y; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
163 *x = rotatedX; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
164 *y = rotatedY; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
165 } |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
166 #endif |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
167 #endif */ |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
168 } |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
169 break; |
4157
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
170 // FIXME: Older version used just SDL_VideoSurface->(w, h) |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
171 // w and h are "clipped" while x and y are "raw", which caused |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
172 // x in former and y in latter case to be clipped in a wrong direction, |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
173 // thus offsetting the coordinate on 2 x clip pixels |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
174 // (like, 128 for 640 -> 512 clipping). |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
175 // We will now try to extract and use raw values. |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
176 // The way to do that RIGHT is do (orientation-dependent) clipping before |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
177 // doing this transform, but it's hardly possible. |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
178 |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
179 // SEE SDL_mouse.c /ClipOffset to understand these calculations. |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
180 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
|
181 if (!SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
182 break; |
4157
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
183 rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/ |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
184 SDL_VideoSurface->format->BytesPerPixel)) |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
185 + SDL_VideoSurface->w - *y; |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
186 rotatedY = *x; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
187 *x = rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
188 *y = rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
189 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
190 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
|
191 if (!SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
192 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
193 rotatedX = *y; |
4157
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
194 rotatedY = (2 * (SDL_VideoSurface->offset/SDL_VideoSurface->pitch)) |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
195 + SDL_VideoSurface->h - *x; |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
196 *x = rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
197 *y = rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
198 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
199 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
200 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
201 |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
202 #endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
203 |
1523 | 204 /* JC 14 Mar 2006 |
205 This is used all over the place, in the windib driver and in the dx5 driver | |
206 So we may as well stick it here instead of having multiple copies scattered | |
207 about | |
208 */ | |
209 void WIN_FlushMessageQueue() | |
210 { | |
211 MSG msg; | |
212 while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { | |
213 if ( msg.message == WM_QUIT ) break; | |
214 TranslateMessage( &msg ); | |
215 DispatchMessage( &msg ); | |
216 } | |
217 } | |
218 | |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
219 static void SDL_RestoreGameMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
220 { |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
221 #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
|
222 |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
223 #ifdef SDL_VIDEO_DRIVER_GAPI |
1497
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 { |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
227 if( this->hidden->gapiInfo->suspended ) |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
228 { |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
229 this->hidden->gapiInfo->suspended = 0; |
1497
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 } |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
232 #endif |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
233 |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
234 #else |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
235 ShowWindow(SDL_Window, SW_RESTORE); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
236 #endif |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
237 |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
238 #ifndef NO_CHANGEDISPLAYSETTINGS |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
239 #ifndef _WIN32_WCE |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
240 ChangeDisplaySettings(&SDL_fullscreen_mode, CDS_FULLSCREEN); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
241 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
242 #endif /* NO_CHANGEDISPLAYSETTINGS */ |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
243 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
244 static void SDL_RestoreDesktopMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
245 { |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
246 |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
247 #ifdef _WIN32_WCE |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
248 |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
249 #ifdef SDL_VIDEO_DRIVER_GAPI |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
250 SDL_VideoDevice *this = current_video; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
251 if(SDL_strcmp(this->name, "gapi") == 0) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
252 { |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
253 if( !this->hidden->gapiInfo->suspended ) |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
254 { |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
255 this->hidden->gapiInfo->suspended = 1; |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
256 } |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
257 } |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
258 #endif |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
259 |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
260 #else |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
261 /* 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
|
262 ShowWindow(SDL_Window, SW_MINIMIZE); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
263 #endif |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
264 |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
265 #ifndef NO_CHANGEDISPLAYSETTINGS |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
266 #ifndef _WIN32_WCE |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
267 ChangeDisplaySettings(NULL, 0); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
268 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
269 #endif /* NO_CHANGEDISPLAYSETTINGS */ |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
270 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
271 |
0 | 272 #ifdef WM_MOUSELEAVE |
273 /* | |
274 Special code to handle mouse leave events - this sucks... | |
275 http://support.microsoft.com/support/kb/articles/q183/1/07.asp | |
276 | |
277 TrackMouseEvent() is only available on Win98 and WinNT. | |
278 _TrackMouseEvent() is available on Win95, but isn't yet in the mingw32 | |
279 development environment, and only works on systems that have had IE 3.0 | |
280 or newer installed on them (which is not the case with the base Win95). | |
281 Therefore, we implement our own version of _TrackMouseEvent() which | |
282 uses our own implementation if TrackMouseEvent() is not available. | |
283 */ | |
284 static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL; | |
285 | |
286 static VOID CALLBACK | |
287 TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) | |
288 { | |
289 RECT rect; | |
290 POINT pt; | |
291 | |
292 GetClientRect(hWnd, &rect); | |
293 MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2); | |
294 GetCursorPos(&pt); | |
295 if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) { | |
296 if ( !KillTimer(hWnd, idEvent) ) { | |
297 /* Error killing the timer! */ | |
298 } | |
299 PostMessage(hWnd, WM_MOUSELEAVE, 0, 0); | |
300 } | |
301 } | |
302 static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme) | |
303 { | |
304 if ( ptme->dwFlags == TME_LEAVE ) { | |
305 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
|
306 (TIMERPROC)TrackMouseTimerProc) != 0; |
0 | 307 } |
308 return FALSE; | |
309 } | |
310 #endif /* WM_MOUSELEAVE */ | |
311 | |
312 /* Function to retrieve the current keyboard modifiers */ | |
313 static void WIN_GetKeyboardState(void) | |
314 { | |
315 #ifndef NO_GETKEYBOARDSTATE | |
316 SDLMod state; | |
317 BYTE keyboard[256]; | |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
318 Uint8 *kstate = SDL_GetKeyState(NULL); |
0 | 319 |
320 state = KMOD_NONE; | |
321 if ( GetKeyboardState(keyboard) ) { | |
322 if ( keyboard[VK_LSHIFT] & 0x80) { | |
323 state |= KMOD_LSHIFT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
324 kstate[SDLK_LSHIFT] = SDL_PRESSED; |
0 | 325 } |
326 if ( keyboard[VK_RSHIFT] & 0x80) { | |
327 state |= KMOD_RSHIFT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
328 kstate[SDLK_RSHIFT] = SDL_PRESSED; |
0 | 329 } |
330 if ( keyboard[VK_LCONTROL] & 0x80) { | |
331 state |= KMOD_LCTRL; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
332 kstate[SDLK_LCTRL] = SDL_PRESSED; |
0 | 333 } |
334 if ( keyboard[VK_RCONTROL] & 0x80) { | |
335 state |= KMOD_RCTRL; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
336 kstate[SDLK_RCTRL] = SDL_PRESSED; |
0 | 337 } |
338 if ( keyboard[VK_LMENU] & 0x80) { | |
339 state |= KMOD_LALT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
340 kstate[SDLK_LALT] = SDL_PRESSED; |
0 | 341 } |
342 if ( keyboard[VK_RMENU] & 0x80) { | |
343 state |= KMOD_RALT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
344 kstate[SDLK_RALT] = SDL_PRESSED; |
0 | 345 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
346 if ( keyboard[VK_NUMLOCK] & 0x01) { |
0 | 347 state |= KMOD_NUM; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
348 kstate[SDLK_NUMLOCK] = SDL_PRESSED; |
0 | 349 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
350 if ( keyboard[VK_CAPITAL] & 0x01) { |
0 | 351 state |= KMOD_CAPS; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
352 kstate[SDLK_CAPSLOCK] = SDL_PRESSED; |
0 | 353 } |
354 } | |
355 SDL_SetModState(state); | |
356 #endif /* !NO_GETKEYBOARDSTATE */ | |
357 } | |
358 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
359 /* 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
|
360 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
|
361 */ |
1456
84de7511f79f
Fixed a bunch of 64-bit compatibility problems
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
362 LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
0 | 363 { |
364 SDL_VideoDevice *this = current_video; | |
365 static int mouse_pressed = 0; | |
366 #ifdef WMMSG_DEBUG | |
367 fprintf(stderr, "Received windows message: "); | |
368 if ( msg > MAX_WMMSG ) { | |
369 fprintf(stderr, "%d", msg); | |
370 } else { | |
371 fprintf(stderr, "%s", wmtab[msg]); | |
372 } | |
373 fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam); | |
374 #endif | |
375 switch (msg) { | |
376 | |
377 case WM_ACTIVATE: { | |
378 SDL_VideoDevice *this = current_video; | |
3992 | 379 BOOL active, minimized; |
0 | 380 Uint8 appstate; |
381 | |
382 minimized = HIWORD(wParam); | |
3992 | 383 active = (LOWORD(wParam) != WA_INACTIVE) && !minimized; |
384 if ( active ) { | |
0 | 385 /* Gain the following states */ |
386 appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS; | |
387 if ( this->input_grab != SDL_GRAB_OFF ) { | |
388 WIN_GrabInput(this, SDL_GRAB_ON); | |
389 } | |
390 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
|
391 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
392 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
393 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
394 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
395 SDL_RestoreGameMode(); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
396 } |
0 | 397 } |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
398 #if defined(_WIN32_WCE) |
3992 | 399 if ( WINDIB_FULLSCREEN() ) { |
400 LoadAygshell(); | |
401 if( SHFullScreen ) | |
402 SHFullScreen(SDL_Window, SHFS_HIDESTARTICON|SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON); | |
403 else | |
404 ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_HIDE); | |
405 } | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
406 #endif |
0 | 407 posted = SDL_PrivateAppActive(1, appstate); |
408 WIN_GetKeyboardState(); | |
409 } else { | |
410 /* Lose the following states */ | |
411 appstate = SDL_APPINPUTFOCUS; | |
412 if ( minimized ) { | |
413 appstate |= SDL_APPACTIVE; | |
414 } | |
415 if ( this->input_grab != SDL_GRAB_OFF ) { | |
416 WIN_GrabInput(this, SDL_GRAB_OFF); | |
417 } | |
418 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
|
419 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
420 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
421 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
422 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
423 SDL_RestoreDesktopMode(); |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
424 #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
|
425 LoadAygshell(); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
426 if( SHFullScreen ) |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
427 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
|
428 else |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
429 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
|
430 #endif |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
431 } |
0 | 432 } |
433 posted = SDL_PrivateAppActive(0, appstate); | |
434 } | |
3992 | 435 WIN_Activate(this, active, minimized); |
0 | 436 return(0); |
437 } | |
438 break; | |
439 | |
440 case WM_MOUSEMOVE: { | |
441 | |
442 /* 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
|
443 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 444 Sint16 x, y; |
445 | |
446 /* mouse has entered the window */ | |
447 if ( ! in_window ) { | |
448 #ifdef WM_MOUSELEAVE | |
449 TRACKMOUSEEVENT tme; | |
450 | |
451 tme.cbSize = sizeof(tme); | |
452 tme.dwFlags = TME_LEAVE; | |
453 tme.hwndTrack = SDL_Window; | |
454 _TrackMouseEvent(&tme); | |
455 #endif /* WM_MOUSELEAVE */ | |
456 in_window = TRUE; | |
457 | |
458 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | |
459 } | |
460 | |
461 /* mouse has moved within the window */ | |
462 x = LOWORD(lParam); | |
463 y = HIWORD(lParam); | |
464 if ( mouse_relative ) { | |
465 POINT center; | |
466 center.x = (SDL_VideoSurface->w/2); | |
467 center.y = (SDL_VideoSurface->h/2); | |
468 x -= (Sint16)center.x; | |
469 y -= (Sint16)center.y; | |
470 if ( x || y ) { | |
471 ClientToScreen(SDL_Window, ¢er); | |
472 SetCursorPos(center.x, center.y); | |
473 posted = SDL_PrivateMouseMotion(0, 1, x, y); | |
474 } | |
475 } else { | |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
476 #ifdef SDL_VIDEO_DRIVER_GAPI |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
477 if (SDL_VideoSurface && this->hidden->gapiInfo) |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
478 GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &x, &y); |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
479 #endif |
0 | 480 posted = SDL_PrivateMouseMotion(0, 0, x, y); |
481 } | |
482 } | |
483 } | |
484 return(0); | |
485 | |
486 #ifdef WM_MOUSELEAVE | |
487 case WM_MOUSELEAVE: { | |
488 | |
489 /* 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
|
490 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 491 /* mouse has left the window */ |
492 /* or */ | |
493 /* Elvis has left the building! */ | |
494 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | |
495 } | |
829
77bca0665b69
Fixed mouse focus events after resetting video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
565
diff
changeset
|
496 in_window = FALSE; |
0 | 497 } |
498 return(0); | |
499 #endif /* WM_MOUSELEAVE */ | |
500 | |
501 case WM_LBUTTONDOWN: | |
502 case WM_LBUTTONUP: | |
503 case WM_MBUTTONDOWN: | |
504 case WM_MBUTTONUP: | |
505 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
|
506 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
|
507 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
|
508 case WM_XBUTTONUP: { |
0 | 509 /* Mouse is handled by DirectInput when fullscreen */ |
4167 | 510 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
|
511 WORD xbuttonval = 0; |
0 | 512 Sint16 x, y; |
513 Uint8 button, state; | |
514 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
515 /* DJM: |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
516 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
|
517 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
|
518 (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
|
519 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
520 SetFocus(SDL_Window); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
521 |
0 | 522 /* Figure out which button to use */ |
523 switch (msg) { | |
524 case WM_LBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
525 button = SDL_BUTTON_LEFT; |
0 | 526 state = SDL_PRESSED; |
527 break; | |
528 case WM_LBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
529 button = SDL_BUTTON_LEFT; |
0 | 530 state = SDL_RELEASED; |
531 break; | |
532 case WM_MBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
533 button = SDL_BUTTON_MIDDLE; |
0 | 534 state = SDL_PRESSED; |
535 break; | |
536 case WM_MBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
537 button = SDL_BUTTON_MIDDLE; |
0 | 538 state = SDL_RELEASED; |
539 break; | |
540 case WM_RBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
541 button = SDL_BUTTON_RIGHT; |
0 | 542 state = SDL_PRESSED; |
543 break; | |
544 case WM_RBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
545 button = SDL_BUTTON_RIGHT; |
0 | 546 state = SDL_RELEASED; |
547 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
|
548 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
|
549 xbuttonval = GET_XBUTTON_WPARAM(wParam); |
4113 | 550 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
|
551 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
|
552 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
|
553 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
|
554 xbuttonval = GET_XBUTTON_WPARAM(wParam); |
4113 | 555 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
|
556 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
|
557 break; |
0 | 558 default: |
559 /* Eh? Unknown button? */ | |
560 return(0); | |
561 } | |
562 if ( state == SDL_PRESSED ) { | |
563 /* Grab mouse so we get up events */ | |
564 if ( ++mouse_pressed > 0 ) { | |
565 SetCapture(hwnd); | |
566 } | |
567 } else { | |
568 /* Release mouse after all up events */ | |
569 if ( --mouse_pressed <= 0 ) { | |
570 ReleaseCapture(); | |
571 mouse_pressed = 0; | |
572 } | |
573 } | |
574 if ( mouse_relative ) { | |
575 /* RJR: March 28, 2000 | |
576 report internal mouse position if in relative mode */ | |
577 x = 0; y = 0; | |
578 } else { | |
579 x = (Sint16)LOWORD(lParam); | |
580 y = (Sint16)HIWORD(lParam); | |
4162
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
581 #ifdef SDL_VIDEO_DRIVER_GAPI |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
582 if (SDL_VideoSurface && this->hidden->gapiInfo) |
3b7fc3416601
GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
4159
diff
changeset
|
583 GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &x, &y); |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
584 #endif |
0 | 585 } |
586 posted = SDL_PrivateMouseButton( | |
587 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
|
588 |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
589 /* |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
590 * 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
|
591 * "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
|
592 * 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
|
593 * 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
|
594 * 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
|
595 * 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
|
596 * 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
|
597 * 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
|
598 */ |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
599 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
|
600 return(TRUE); |
0 | 601 } |
602 } | |
603 return(0); | |
604 | |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
605 |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
606 #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
|
607 case WM_MOUSEWHEEL: |
4167 | 608 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
|
609 int move = (short)HIWORD(wParam); |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
610 if ( move ) { |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
611 Uint8 button; |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
612 if ( move > 0 ) |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
613 button = SDL_BUTTON_WHEELUP; |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
614 else |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
615 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
|
616 posted = SDL_PrivateMouseButton( |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
617 SDL_PRESSED, button, 0, 0); |
332 | 618 posted |= SDL_PrivateMouseButton( |
619 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
|
620 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
621 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
622 return(0); |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
623 #endif |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
624 |
0 | 625 #ifdef WM_GETMINMAXINFO |
626 /* This message is sent as a way for us to "check" the values | |
627 * of a position change. If we don't like it, we can adjust | |
628 * the values before they are changed. | |
629 */ | |
630 case WM_GETMINMAXINFO: { | |
631 MINMAXINFO *info; | |
632 RECT size; | |
633 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
|
634 int style; |
0 | 635 int width; |
636 int height; | |
637 | |
638 /* We don't want to clobber an internal resize */ | |
639 if ( SDL_resizing ) | |
640 return(0); | |
641 | |
642 /* We allow resizing with the SDL_RESIZABLE flag */ | |
643 if ( SDL_PublicSurface && | |
644 (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { | |
645 return(0); | |
646 } | |
647 | |
648 /* Get the current position of our window */ | |
649 GetWindowRect(SDL_Window, &size); | |
650 x = size.left; | |
651 y = size.top; | |
652 | |
653 /* Calculate current width and height of our window */ | |
654 size.top = 0; | |
655 size.left = 0; | |
656 if ( SDL_PublicSurface != NULL ) { | |
657 size.bottom = SDL_PublicSurface->h; | |
658 size.right = SDL_PublicSurface->w; | |
659 } else { | |
660 size.bottom = 0; | |
661 size.right = 0; | |
662 } | |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
663 |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
664 /* 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
|
665 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
|
666 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
|
667 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
|
668 */ |
1480 | 669 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
|
670 AdjustWindowRect( |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
671 &size, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
672 style, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
673 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
|
674 : GetMenu(hwnd) != NULL); |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
675 |
0 | 676 width = size.right - size.left; |
677 height = size.bottom - size.top; | |
678 | |
679 /* Fix our size to the current size */ | |
680 info = (MINMAXINFO *)lParam; | |
681 info->ptMaxSize.x = width; | |
682 info->ptMaxSize.y = height; | |
683 info->ptMaxPosition.x = x; | |
684 info->ptMaxPosition.y = y; | |
685 info->ptMinTrackSize.x = width; | |
686 info->ptMinTrackSize.y = height; | |
687 info->ptMaxTrackSize.x = width; | |
688 info->ptMaxTrackSize.y = height; | |
689 } | |
690 return(0); | |
691 #endif /* WM_GETMINMAXINFO */ | |
692 | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
693 case WM_WINDOWPOSCHANGED: { |
0 | 694 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
|
695 int w, h; |
0 | 696 |
697 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
|
698 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
|
699 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
|
700 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
|
701 SDL_PublicSurface && |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
702 !(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
|
703 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
|
704 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
|
705 } |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
706 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
|
707 h = SDL_bounds.bottom-SDL_bounds.top; |
0 | 708 if ( this->input_grab != SDL_GRAB_OFF ) { |
709 ClipCursor(&SDL_bounds); | |
710 } | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
711 if ( SDL_PublicSurface && |
0 | 712 (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
|
713 SDL_PrivateResize(w, h); |
0 | 714 } |
715 } | |
716 break; | |
717 | |
718 /* We need to set the cursor */ | |
719 case WM_SETCURSOR: { | |
720 Uint16 hittest; | |
721 | |
722 hittest = LOWORD(lParam); | |
723 if ( hittest == HTCLIENT ) { | |
724 SetCursor(SDL_hcursor); | |
725 return(TRUE); | |
726 } | |
727 } | |
728 break; | |
729 | |
730 /* We are about to get palette focus! */ | |
731 case WM_QUERYNEWPALETTE: { | |
732 WIN_RealizePalette(current_video); | |
733 return(TRUE); | |
734 } | |
735 break; | |
736 | |
737 /* Another application changed the palette */ | |
738 case WM_PALETTECHANGED: { | |
739 WIN_PaletteChanged(current_video, (HWND)wParam); | |
740 } | |
741 break; | |
742 | |
743 /* We were occluded, refresh our display */ | |
744 case WM_PAINT: { | |
745 HDC hdc; | |
746 PAINTSTRUCT ps; | |
747 | |
748 hdc = BeginPaint(SDL_Window, &ps); | |
749 if ( current_video->screen && | |
750 !(current_video->screen->flags & SDL_OPENGL) ) { | |
751 WIN_WinPAINT(current_video, hdc); | |
752 } | |
753 EndPaint(SDL_Window, &ps); | |
754 } | |
755 return(0); | |
756 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
757 /* DJM: Send an expose event in this case */ |
0 | 758 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
|
759 posted = SDL_PrivateExpose(); |
0 | 760 } |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
761 return(0); |
0 | 762 |
763 case WM_CLOSE: { | |
764 if ( (posted = SDL_PrivateQuit()) ) | |
765 PostQuitMessage(0); | |
766 } | |
767 return(0); | |
768 | |
769 case WM_DESTROY: { | |
770 PostQuitMessage(0); | |
771 } | |
772 return(0); | |
773 | |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
774 #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
|
775 case WM_INPUTLANGCHANGE: { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
776 codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
777 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
778 return(TRUE); |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
779 #endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
780 |
0 | 781 default: { |
782 /* Special handling by the video driver */ | |
783 if (HandleMessage) { | |
784 return(HandleMessage(current_video, | |
785 hwnd, msg, wParam, lParam)); | |
786 } | |
787 } | |
788 break; | |
789 } | |
790 return(DefWindowProc(hwnd, msg, wParam, lParam)); | |
791 } | |
792 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
793 /* 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
|
794 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
|
795 |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
796 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
|
797 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
798 SDL_handle = handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
799 } |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
800 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
|
801 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
802 void *handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
803 |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
804 if ( SDL_handle ) { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
805 handle = SDL_handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
806 } else { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
807 handle = GetModuleHandle(NULL); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
808 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
809 return(handle); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
810 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
811 |
0 | 812 /* 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
|
813 BOOL SDL_windowid = FALSE; |
0 | 814 |
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
|
815 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
|
816 |
0 | 817 /* 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
|
818 int SDL_RegisterApp(char *name, Uint32 style, void *hInst) |
0 | 819 { |
820 WNDCLASS class; | |
821 #ifdef WM_MOUSELEAVE | |
822 HMODULE handle; | |
823 #endif | |
824 | |
825 /* 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
|
826 if ( app_registered ) { |
1498 | 827 ++app_registered; |
0 | 828 return(0); |
829 } | |
830 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
831 #ifndef CS_BYTEALIGNCLIENT |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
832 #define CS_BYTEALIGNCLIENT 0 |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
833 #endif |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
834 if ( ! name && ! SDL_Appname ) { |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
835 name = "SDL_app"; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
836 SDL_Appstyle = CS_BYTEALIGNCLIENT; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
837 SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
0 | 838 } |
839 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
840 if ( name ) { |
0 | 841 #ifdef _WIN32_WCE |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
842 /* WinCE uses the UNICODE version */ |
1505 | 843 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
|
844 #else |
4007 | 845 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
|
846 #endif /* _WIN32_WCE */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
847 SDL_Appstyle = style; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
848 SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
849 } |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
850 |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
851 /* Register the application class */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
852 class.hCursor = NULL; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
853 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
|
854 IMAGE_ICON, |
0 | 855 0, 0, LR_DEFAULTCOLOR); |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
13
diff
changeset
|
856 class.lpszMenuName = NULL; |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
857 class.lpszClassName = SDL_Appname; |
0 | 858 class.hbrBackground = NULL; |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
859 class.hInstance = SDL_Instance; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
860 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
|
861 #if SDL_VIDEO_OPENGL |
0 | 862 class.style |= CS_OWNDC; |
863 #endif | |
864 class.lpfnWndProc = WinMessage; | |
865 class.cbWndExtra = 0; | |
866 class.cbClsExtra = 0; | |
867 if ( ! RegisterClass(&class) ) { | |
868 SDL_SetError("Couldn't register application class"); | |
869 return(-1); | |
870 } | |
871 | |
872 #ifdef WM_MOUSELEAVE | |
873 /* Get the version of TrackMouseEvent() we use */ | |
874 _TrackMouseEvent = NULL; | |
875 handle = GetModuleHandle("USER32.DLL"); | |
876 if ( handle ) { | |
877 _TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent"); | |
878 } | |
879 if ( _TrackMouseEvent == NULL ) { | |
880 _TrackMouseEvent = WIN_TrackMouseEvent; | |
881 } | |
882 #endif /* WM_MOUSELEAVE */ | |
883 | |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
884 #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
|
885 /* 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
|
886 codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
887 SDL_ToUnicode = Is9xME() ? ToUnicode9xME : ToUnicode; |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
888 #endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
889 |
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
|
890 app_registered = 1; |
0 | 891 return(0); |
892 } | |
893 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
894 /* 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
|
895 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
|
896 { |
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
|
897 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
|
898 |
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
|
899 /* SDL_RegisterApp might not have been called before */ |
1498 | 900 if ( !app_registered ) { |
901 return; | |
902 } | |
903 --app_registered; | |
904 if ( app_registered == 0 ) { | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
905 /* Check for any registered window classes. */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
906 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
|
907 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
|
908 } |
1498 | 909 SDL_free(SDL_Appname); |
910 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
|
911 } |
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
|
912 } |
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
|
913 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
914 #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
|
915 /* 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
|
916 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
917 static int Is9xME() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
918 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
919 OSVERSIONINFO info; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
920 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
921 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
|
922 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
|
923 if (!GetVersionEx(&info)) { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
924 return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
925 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
926 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
|
927 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
928 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
929 static int GetCodePage() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
930 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
931 char buff[8]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
932 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
|
933 int cp = GetACP(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
934 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
935 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
|
936 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
|
937 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
938 return cp; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
939 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
940 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
941 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
|
942 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
943 BYTE chars[2]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
944 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
945 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
|
946 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
|
947 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
948 return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
949 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
950 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
951 #endif /* !NO_GETKEYBOARDSTATE */ |