Mercurial > sdl-ios-xcode
annotate src/video/windib/SDL_dibevents.c @ 1267:fdc7ef6ecab4
Correctly manage mouse relative motion
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Wed, 25 Jan 2006 20:36:21 +0000 |
parents | f3a3f1890b91 |
children | f61f045343d3 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
726
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
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 | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 #include <stdlib.h> | |
29 #include <stdio.h> | |
30 #include <windows.h> | |
31 | |
32 #include "SDL_events.h" | |
33 #include "SDL_error.h" | |
34 #include "SDL_syswm.h" | |
35 #include "SDL_sysevents.h" | |
36 #include "SDL_events_c.h" | |
37 #include "SDL_lowvideo.h" | |
38 #include "SDL_dibvideo.h" | |
39 #include "SDL_vkeys.h" | |
40 | |
41 #ifndef WM_APP | |
42 #define WM_APP 0x8000 | |
43 #endif | |
44 | |
45 #ifdef _WIN32_WCE | |
46 #define NO_GETKEYBOARDSTATE | |
47 #endif | |
48 | |
49 /* The translation table from a Microsoft VK keysym to a SDL keysym */ | |
50 static SDLKey VK_keymap[SDLK_LAST]; | |
51 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed); | |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
52 static BOOL prev_shiftstates[2]; |
0 | 53 |
54 /* Masks for processing the windows KEYDOWN and KEYUP messages */ | |
55 #define REPEATED_KEYMASK (1<<30) | |
56 #define EXTENDED_KEYMASK (1<<24) | |
57 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
58 /* DJM: If the user setup the window for us, we want to save his window proc, |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
59 and give him a chance to handle some messages. */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
60 static WNDPROC userWindowProc = NULL; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
61 |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
62 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
63 #ifdef _WIN32_WCE |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
64 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
65 WPARAM rotateKey(WPARAM key,SDL_ScreenOrientation direction) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
66 { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
67 if (direction != SDL_ORIENTATION_LEFT) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
68 return key; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
69 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
70 switch (key) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
71 case 0x26: /* up */ |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
72 return 0x27; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
73 case 0x27: /* right */ |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
74 return 0x28; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
75 case 0x28: /* down */ |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
76 return 0x25; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
77 case 0x25: /* left */ |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
78 return 0x26; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
79 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
80 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
81 return key; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
82 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
83 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
84 #endif |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
85 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
86 |
0 | 87 /* The main Win32 event handler */ |
88 LONG | |
89 DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |
90 { | |
91 extern int posted; | |
92 | |
93 switch (msg) { | |
94 case WM_SYSKEYDOWN: | |
95 case WM_KEYDOWN: { | |
96 SDL_keysym keysym; | |
97 | |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
98 #ifdef _WIN32_WCE |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
99 // Drop GAPI artefacts |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
100 if (wParam == 0x84 || wParam == 0x5B) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
101 return 0; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
102 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
103 // Rotate key if necessary |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
104 if (this->hidden->orientation != SDL_ORIENTATION_UP) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
105 wParam = rotateKey(wParam, this->hidden->orientation); |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
106 #endif |
0 | 107 /* Ignore repeated keys */ |
108 if ( lParam&REPEATED_KEYMASK ) { | |
109 return(0); | |
110 } | |
111 switch (wParam) { | |
112 case VK_CONTROL: | |
113 if ( lParam&EXTENDED_KEYMASK ) | |
114 wParam = VK_RCONTROL; | |
115 else | |
116 wParam = VK_LCONTROL; | |
117 break; | |
118 case VK_SHIFT: | |
119 /* EXTENDED trick doesn't work here */ | |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
120 if (!prev_shiftstates[0] && (GetKeyState(VK_LSHIFT) & 0x8000)) { |
558
2312d983e1fe
Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
121 wParam = VK_LSHIFT; |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
122 prev_shiftstates[0] = TRUE; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
123 } else if (!prev_shiftstates[1] && (GetKeyState(VK_RSHIFT) & 0x8000)) { |
558
2312d983e1fe
Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
124 wParam = VK_RSHIFT; |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
125 prev_shiftstates[1] = TRUE; |
558
2312d983e1fe
Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
126 } else { |
2312d983e1fe
Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
127 /* Huh? */ |
2312d983e1fe
Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
128 } |
0 | 129 break; |
130 case VK_MENU: | |
131 if ( lParam&EXTENDED_KEYMASK ) | |
132 wParam = VK_RMENU; | |
133 else | |
134 wParam = VK_LMENU; | |
135 break; | |
136 } | |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
137 #ifdef NO_GETKEYBOARDSTATE |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
138 /* this is the workaround for the missing ToAscii() and ToUnicode() in CE (not necessary at KEYUP!) */ |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
139 if ( SDL_TranslateUNICODE ) { |
140
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
140 MSG m; |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
141 |
140
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
142 m.hwnd = hwnd; |
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
143 m.message = msg; |
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
144 m.wParam = wParam; |
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
145 m.lParam = lParam; |
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
146 m.time = 0; |
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
147 if ( TranslateMessage(&m) && PeekMessage(&m, hwnd, 0, WM_USER, PM_NOREMOVE) && (m.message == WM_CHAR) ) { |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
148 GetMessage(&m, hwnd, 0, WM_USER); |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
149 wParam = m.wParam; |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
150 } |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
151 } |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
152 #endif /* NO_GETKEYBOARDSTATE */ |
0 | 153 posted = SDL_PrivateKeyboard(SDL_PRESSED, |
154 TranslateKey(wParam,HIWORD(lParam),&keysym,1)); | |
155 } | |
156 return(0); | |
157 | |
158 case WM_SYSKEYUP: | |
159 case WM_KEYUP: { | |
160 SDL_keysym keysym; | |
161 | |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
162 #ifdef _WIN32_WCE |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
163 // Drop GAPI artefacts |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
164 if (wParam == 0x84 || wParam == 0x5B) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
165 return 0; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
166 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
167 // Rotate key if necessary |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
168 if (this->hidden->orientation != SDL_ORIENTATION_UP) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
169 wParam = rotateKey(wParam, this->hidden->orientation); |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
170 #endif |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
171 |
0 | 172 switch (wParam) { |
173 case VK_CONTROL: | |
174 if ( lParam&EXTENDED_KEYMASK ) | |
175 wParam = VK_RCONTROL; | |
176 else | |
177 wParam = VK_LCONTROL; | |
178 break; | |
179 case VK_SHIFT: | |
180 /* EXTENDED trick doesn't work here */ | |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
181 if (prev_shiftstates[0] && !(GetKeyState(VK_LSHIFT) & 0x8000)) { |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
182 wParam = VK_LSHIFT; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
183 prev_shiftstates[0] = FALSE; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
184 } else if (prev_shiftstates[1] && !(GetKeyState(VK_RSHIFT) & 0x8000)) { |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
185 wParam = VK_RSHIFT; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
186 prev_shiftstates[1] = FALSE; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
187 } else { |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
188 /* Huh? */ |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
189 } |
0 | 190 break; |
191 case VK_MENU: | |
192 if ( lParam&EXTENDED_KEYMASK ) | |
193 wParam = VK_RMENU; | |
194 else | |
195 wParam = VK_LMENU; | |
196 break; | |
197 } | |
198 posted = SDL_PrivateKeyboard(SDL_RELEASED, | |
199 TranslateKey(wParam,HIWORD(lParam),&keysym,0)); | |
200 } | |
201 return(0); | |
202 | |
726
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
203 #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER) |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
204 case WM_SYSCOMMAND: { |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
205 if ((wParam&0xFFF0)==SC_SCREENSAVE || |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
206 (wParam&0xFFF0)==SC_MONITORPOWER) |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
207 return(0); |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
208 } |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
209 /* Fall through to default processing */ |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
210 #endif /* SC_SCREENSAVE && SC_MONITORPOWER */ |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
211 |
0 | 212 default: { |
213 /* Only post the event if we're watching for it */ | |
214 if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { | |
215 SDL_SysWMmsg wmmsg; | |
216 | |
217 SDL_VERSION(&wmmsg.version); | |
218 wmmsg.hwnd = hwnd; | |
219 wmmsg.msg = msg; | |
220 wmmsg.wParam = wParam; | |
221 wmmsg.lParam = lParam; | |
222 posted = SDL_PrivateSysWMEvent(&wmmsg); | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
223 |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
224 /* DJM: If the user isn't watching for private |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
225 messages in her SDL event loop, then pass it |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
226 along to any win32 specific window proc. |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
227 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
228 } else if (userWindowProc) { |
721
ab0656314eef
Date: Thu, 18 Sep 2003 14:24:35 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
572
diff
changeset
|
229 return CallWindowProc(userWindowProc, hwnd, msg, wParam, lParam); |
0 | 230 } |
231 } | |
232 break; | |
233 } | |
234 return(DefWindowProc(hwnd, msg, wParam, lParam)); | |
235 } | |
236 | |
237 void DIB_PumpEvents(_THIS) | |
238 { | |
239 MSG msg; | |
240 | |
523
c210010f50f4
Fixed windows event handling for ActiveX controls (thanks Huib-Jan!)
Sam Lantinga <slouken@libsdl.org>
parents:
515
diff
changeset
|
241 while ( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) { |
c210010f50f4
Fixed windows event handling for ActiveX controls (thanks Huib-Jan!)
Sam Lantinga <slouken@libsdl.org>
parents:
515
diff
changeset
|
242 if ( GetMessage(&msg, NULL, 0, 0) > 0 ) { |
0 | 243 DispatchMessage(&msg); |
244 } | |
245 } | |
246 } | |
247 | |
248 void DIB_InitOSKeymap(_THIS) | |
249 { | |
250 int i; | |
251 | |
252 /* Map the VK keysyms */ | |
253 for ( i=0; i<SDL_TABLESIZE(VK_keymap); ++i ) | |
254 VK_keymap[i] = SDLK_UNKNOWN; | |
255 | |
256 VK_keymap[VK_BACK] = SDLK_BACKSPACE; | |
257 VK_keymap[VK_TAB] = SDLK_TAB; | |
258 VK_keymap[VK_CLEAR] = SDLK_CLEAR; | |
259 VK_keymap[VK_RETURN] = SDLK_RETURN; | |
260 VK_keymap[VK_PAUSE] = SDLK_PAUSE; | |
261 VK_keymap[VK_ESCAPE] = SDLK_ESCAPE; | |
262 VK_keymap[VK_SPACE] = SDLK_SPACE; | |
263 VK_keymap[VK_APOSTROPHE] = SDLK_QUOTE; | |
264 VK_keymap[VK_COMMA] = SDLK_COMMA; | |
265 VK_keymap[VK_MINUS] = SDLK_MINUS; | |
266 VK_keymap[VK_PERIOD] = SDLK_PERIOD; | |
267 VK_keymap[VK_SLASH] = SDLK_SLASH; | |
268 VK_keymap[VK_0] = SDLK_0; | |
269 VK_keymap[VK_1] = SDLK_1; | |
270 VK_keymap[VK_2] = SDLK_2; | |
271 VK_keymap[VK_3] = SDLK_3; | |
272 VK_keymap[VK_4] = SDLK_4; | |
273 VK_keymap[VK_5] = SDLK_5; | |
274 VK_keymap[VK_6] = SDLK_6; | |
275 VK_keymap[VK_7] = SDLK_7; | |
276 VK_keymap[VK_8] = SDLK_8; | |
277 VK_keymap[VK_9] = SDLK_9; | |
278 VK_keymap[VK_SEMICOLON] = SDLK_SEMICOLON; | |
279 VK_keymap[VK_EQUALS] = SDLK_EQUALS; | |
280 VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET; | |
281 VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH; | |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
282 VK_keymap[VK_OEM_102] = SDLK_LESS; |
0 | 283 VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET; |
284 VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE; | |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
285 VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE; |
0 | 286 VK_keymap[VK_A] = SDLK_a; |
287 VK_keymap[VK_B] = SDLK_b; | |
288 VK_keymap[VK_C] = SDLK_c; | |
289 VK_keymap[VK_D] = SDLK_d; | |
290 VK_keymap[VK_E] = SDLK_e; | |
291 VK_keymap[VK_F] = SDLK_f; | |
292 VK_keymap[VK_G] = SDLK_g; | |
293 VK_keymap[VK_H] = SDLK_h; | |
294 VK_keymap[VK_I] = SDLK_i; | |
295 VK_keymap[VK_J] = SDLK_j; | |
296 VK_keymap[VK_K] = SDLK_k; | |
297 VK_keymap[VK_L] = SDLK_l; | |
298 VK_keymap[VK_M] = SDLK_m; | |
299 VK_keymap[VK_N] = SDLK_n; | |
300 VK_keymap[VK_O] = SDLK_o; | |
301 VK_keymap[VK_P] = SDLK_p; | |
302 VK_keymap[VK_Q] = SDLK_q; | |
303 VK_keymap[VK_R] = SDLK_r; | |
304 VK_keymap[VK_S] = SDLK_s; | |
305 VK_keymap[VK_T] = SDLK_t; | |
306 VK_keymap[VK_U] = SDLK_u; | |
307 VK_keymap[VK_V] = SDLK_v; | |
308 VK_keymap[VK_W] = SDLK_w; | |
309 VK_keymap[VK_X] = SDLK_x; | |
310 VK_keymap[VK_Y] = SDLK_y; | |
311 VK_keymap[VK_Z] = SDLK_z; | |
312 VK_keymap[VK_DELETE] = SDLK_DELETE; | |
313 | |
314 VK_keymap[VK_NUMPAD0] = SDLK_KP0; | |
315 VK_keymap[VK_NUMPAD1] = SDLK_KP1; | |
316 VK_keymap[VK_NUMPAD2] = SDLK_KP2; | |
317 VK_keymap[VK_NUMPAD3] = SDLK_KP3; | |
318 VK_keymap[VK_NUMPAD4] = SDLK_KP4; | |
319 VK_keymap[VK_NUMPAD5] = SDLK_KP5; | |
320 VK_keymap[VK_NUMPAD6] = SDLK_KP6; | |
321 VK_keymap[VK_NUMPAD7] = SDLK_KP7; | |
322 VK_keymap[VK_NUMPAD8] = SDLK_KP8; | |
323 VK_keymap[VK_NUMPAD9] = SDLK_KP9; | |
324 VK_keymap[VK_DECIMAL] = SDLK_KP_PERIOD; | |
325 VK_keymap[VK_DIVIDE] = SDLK_KP_DIVIDE; | |
326 VK_keymap[VK_MULTIPLY] = SDLK_KP_MULTIPLY; | |
327 VK_keymap[VK_SUBTRACT] = SDLK_KP_MINUS; | |
328 VK_keymap[VK_ADD] = SDLK_KP_PLUS; | |
329 | |
330 VK_keymap[VK_UP] = SDLK_UP; | |
331 VK_keymap[VK_DOWN] = SDLK_DOWN; | |
332 VK_keymap[VK_RIGHT] = SDLK_RIGHT; | |
333 VK_keymap[VK_LEFT] = SDLK_LEFT; | |
334 VK_keymap[VK_INSERT] = SDLK_INSERT; | |
335 VK_keymap[VK_HOME] = SDLK_HOME; | |
336 VK_keymap[VK_END] = SDLK_END; | |
337 VK_keymap[VK_PRIOR] = SDLK_PAGEUP; | |
338 VK_keymap[VK_NEXT] = SDLK_PAGEDOWN; | |
339 | |
340 VK_keymap[VK_F1] = SDLK_F1; | |
341 VK_keymap[VK_F2] = SDLK_F2; | |
342 VK_keymap[VK_F3] = SDLK_F3; | |
343 VK_keymap[VK_F4] = SDLK_F4; | |
344 VK_keymap[VK_F5] = SDLK_F5; | |
345 VK_keymap[VK_F6] = SDLK_F6; | |
346 VK_keymap[VK_F7] = SDLK_F7; | |
347 VK_keymap[VK_F8] = SDLK_F8; | |
348 VK_keymap[VK_F9] = SDLK_F9; | |
349 VK_keymap[VK_F10] = SDLK_F10; | |
350 VK_keymap[VK_F11] = SDLK_F11; | |
351 VK_keymap[VK_F12] = SDLK_F12; | |
352 VK_keymap[VK_F13] = SDLK_F13; | |
353 VK_keymap[VK_F14] = SDLK_F14; | |
354 VK_keymap[VK_F15] = SDLK_F15; | |
355 | |
356 VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK; | |
357 VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK; | |
358 VK_keymap[VK_SCROLL] = SDLK_SCROLLOCK; | |
359 VK_keymap[VK_RSHIFT] = SDLK_RSHIFT; | |
360 VK_keymap[VK_LSHIFT] = SDLK_LSHIFT; | |
361 VK_keymap[VK_RCONTROL] = SDLK_RCTRL; | |
362 VK_keymap[VK_LCONTROL] = SDLK_LCTRL; | |
363 VK_keymap[VK_RMENU] = SDLK_RALT; | |
364 VK_keymap[VK_LMENU] = SDLK_LALT; | |
365 VK_keymap[VK_RWIN] = SDLK_RSUPER; | |
366 VK_keymap[VK_LWIN] = SDLK_LSUPER; | |
367 | |
368 VK_keymap[VK_HELP] = SDLK_HELP; | |
369 #ifdef VK_PRINT | |
370 VK_keymap[VK_PRINT] = SDLK_PRINT; | |
371 #endif | |
372 VK_keymap[VK_SNAPSHOT] = SDLK_PRINT; | |
373 VK_keymap[VK_CANCEL] = SDLK_BREAK; | |
374 VK_keymap[VK_APPS] = SDLK_MENU; | |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
375 |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
376 prev_shiftstates[0] = FALSE; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
377 prev_shiftstates[1] = FALSE; |
0 | 378 } |
379 | |
380 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed) | |
381 { | |
382 /* Set the keysym information */ | |
383 keysym->scancode = (unsigned char) scancode; | |
384 keysym->sym = VK_keymap[vkey]; | |
385 keysym->mod = KMOD_NONE; | |
386 keysym->unicode = 0; | |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
387 if ( pressed && SDL_TranslateUNICODE ) { |
0 | 388 #ifdef NO_GETKEYBOARDSTATE |
389 /* Uh oh, better hope the vkey is close enough.. */ | |
390 keysym->unicode = vkey; | |
391 #else | |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
392 BYTE keystate[256]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
393 Uint16 wchars[2]; |
0 | 394 |
395 GetKeyboardState(keystate); | |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
396 if (SDL_ToUnicode(vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) == 1) |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
397 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
398 keysym->unicode = wchars[0]; |
0 | 399 } |
400 #endif /* NO_GETKEYBOARDSTATE */ | |
401 } | |
402 return(keysym); | |
403 } | |
404 | |
405 int DIB_CreateWindow(_THIS) | |
406 { | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
407 #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
408 wchar_t *SDL_windowid_t; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
409 #endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
410 |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
411 #ifndef CS_BYTEALIGNCLIENT |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
412 #define CS_BYTEALIGNCLIENT 0 |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
413 #endif |
0 | 414 SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); |
415 if ( SDL_windowid ) { | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
416 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
417 // wince 2.1 does not have strtol |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
418 #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
419 SDL_windowid_t = malloc((strlen(SDL_windowid) + 1) * sizeof(wchar_t)); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
420 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, SDL_windowid, -1, SDL_windowid_t, strlen(SDL_windowid) + 1); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
421 SDL_Window = (HWND)wcstol(SDL_windowid_t, NULL, 0); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
422 free(SDL_windowid_t); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
423 #else |
0 | 424 SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0); |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
425 #endif |
974
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
426 if ( SDL_Window == NULL ) { |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
427 SDL_SetError("Couldn't get user specified window"); |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
428 return(-1); |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
429 } |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
430 |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
431 /* DJM: we want all event's for the user specified |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
432 window to be handled by SDL. |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
433 */ |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
434 userWindowProc = (WNDPROC)GetWindowLong(SDL_Window, GWL_WNDPROC); |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
435 SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage); |
0 | 436 } else { |
437 SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, | |
438 (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX), | |
833
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
439 CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL); |
0 | 440 if ( SDL_Window == NULL ) { |
441 SDL_SetError("Couldn't create window"); | |
442 return(-1); | |
443 } | |
444 ShowWindow(SDL_Window, SW_HIDE); | |
445 } | |
446 return(0); | |
447 } | |
448 | |
449 void DIB_DestroyWindow(_THIS) | |
450 { | |
974
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
451 if ( SDL_windowid ) { |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
452 SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)userWindowProc); |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
453 } else { |
0 | 454 DestroyWindow(SDL_Window); |
455 } | |
456 } |