annotate src/video/windows/SDL_windowsevents.c @ 5284:96a22141cf86 tip

Changed output directory of Universal libSDL.a for iOS to respect build configurations. Template generator was updated to reflect these changes as well.
author Eric Wing <ewing . public |-at-| gmail . com>
date Sat, 12 Feb 2011 21:52:30 -0800
parents b530ef003506
children
rev   line source
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
5267
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5152
diff changeset
3 Copyright (C) 1997-2011 Sam Lantinga
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
22
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 #include "SDL_config.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24
5062
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
25 #include "SDL_windowsvideo.h"
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
26 #include "SDL_windowsshape.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #include "SDL_syswm.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include "SDL_vkeys.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #include "../../events/SDL_events_c.h"
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
30 #include "../../events/SDL_touch_c.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31
4650
7ad7a473b086 More fixes for windows. Disabled tablet code.
jimtla
parents: 4429
diff changeset
32
7ad7a473b086 More fixes for windows. Disabled tablet code.
jimtla
parents: 4429
diff changeset
33
4868
d6adaafcfb10 Fixed compiling with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 4862
diff changeset
34 /*#define WMMSG_DEBUG*/
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #ifdef WMMSG_DEBUG
4650
7ad7a473b086 More fixes for windows. Disabled tablet code.
jimtla
parents: 4429
diff changeset
36 #include <stdio.h>
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #include "wmmsg.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #endif
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 /* Masks for processing the windows KEYDOWN and KEYUP messages */
2317
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2313
diff changeset
41 #define REPEATED_KEYMASK (1<<30)
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2313
diff changeset
42 #define EXTENDED_KEYMASK (1<<24)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43
2324
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2317
diff changeset
44 #define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */
2313
012ec5192dfa Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents: 2312
diff changeset
45
2127
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
46 /* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
47 #ifndef WM_XBUTTONDOWN
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
48 #define WM_XBUTTONDOWN 0x020B
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
49 #endif
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
50 #ifndef WM_XBUTTONUP
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
51 #define WM_XBUTTONUP 0x020C
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
52 #endif
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
53 #ifndef GET_XBUTTON_WPARAM
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
54 #define GET_XBUTTON_WPARAM(w) (HIWORD(w))
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
55 #endif
2733
264037dd3c7a Fix for mingw compilation by Alam.
Edgar Simo <bobbens@gmail.com>
parents: 2726
diff changeset
56 #ifndef WM_INPUT
264037dd3c7a Fix for mingw compilation by Alam.
Edgar Simo <bobbens@gmail.com>
parents: 2726
diff changeset
57 #define WM_INPUT 0x00ff
264037dd3c7a Fix for mingw compilation by Alam.
Edgar Simo <bobbens@gmail.com>
parents: 2726
diff changeset
58 #endif
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
59 #ifndef WM_TOUCH
4868
d6adaafcfb10 Fixed compiling with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 4862
diff changeset
60 #define WM_TOUCH 0x0240
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
61 #endif
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
62
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63
2310
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
64 static WPARAM
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
65 RemapVKEY(WPARAM wParam, LPARAM lParam)
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
66 {
2317
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2313
diff changeset
67 int i;
2324
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2317
diff changeset
68 BYTE scancode = (BYTE) ((lParam >> 16) & 0xFF);
2317
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2313
diff changeset
69
2310
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
70 /* Windows remaps alphabetic keys based on current layout.
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
71 We try to provide USB scancodes, so undo this mapping.
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
72 */
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
73 if (wParam >= 'A' && wParam <= 'Z') {
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2310
diff changeset
74 if (scancode != alpha_scancodes[wParam - 'A']) {
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2310
diff changeset
75 for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2310
diff changeset
76 if (scancode == alpha_scancodes[i]) {
2310
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
77 wParam = 'A' + i;
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
78 break;
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
79 }
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
80 }
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
81 }
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
82 }
2317
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2313
diff changeset
83
3700
076c12750bc4 Fixed bug #743
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
84 /* Keypad keys are a little trickier, we always scan for them.
076c12750bc4 Fixed bug #743
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
85 Keypad arrow keys have the same scancode as normal arrow keys,
076c12750bc4 Fixed bug #743
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
86 except they don't have the extended bit (0x1000000) set.
076c12750bc4 Fixed bug #743
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
87 */
076c12750bc4 Fixed bug #743
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
88 if (!(lParam & 0x1000000)) {
4561
e4b2b7207f79 Fixed remapping the Delete key and detecting the keypad Delete key.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
89 if (wParam == VK_DELETE) {
e4b2b7207f79 Fixed remapping the Delete key and detecting the keypad Delete key.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
90 wParam = VK_DECIMAL;
e4b2b7207f79 Fixed remapping the Delete key and detecting the keypad Delete key.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
91 } else {
e4b2b7207f79 Fixed remapping the Delete key and detecting the keypad Delete key.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
92 for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
e4b2b7207f79 Fixed remapping the Delete key and detecting the keypad Delete key.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
93 if (scancode == keypad_scancodes[i]) {
e4b2b7207f79 Fixed remapping the Delete key and detecting the keypad Delete key.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
94 wParam = VK_NUMPAD0 + i;
e4b2b7207f79 Fixed remapping the Delete key and detecting the keypad Delete key.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
95 break;
e4b2b7207f79 Fixed remapping the Delete key and detecting the keypad Delete key.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
96 }
3700
076c12750bc4 Fixed bug #743
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
97 }
2317
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2313
diff changeset
98 }
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2313
diff changeset
99 }
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2313
diff changeset
100
2310
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
101 return wParam;
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
102 }
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
103
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 LRESULT CALLBACK
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 SDL_WindowData *data;
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
108 LRESULT returnCode = -1;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
110 /* Send a SDL_SYSWMEVENT if the application wants them */
4429
faa9fc8e7f67 General improvements for user custom event registration
Sam Lantinga <slouken@libsdl.org>
parents: 3700
diff changeset
111 if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
112 SDL_SysWMmsg wmmsg;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
113
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
114 SDL_VERSION(&wmmsg.version);
4900
69d9db65f248 Merged the Windows custom window system hooks into the union used by X11.
Sam Lantinga <slouken@libsdl.org>
parents: 4868
diff changeset
115 wmmsg.subsystem = SDL_SYSWM_WINDOWS;
5056
8b7988f42fcb Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents: 5049
diff changeset
116 wmmsg.msg.win.hwnd = hwnd;
8b7988f42fcb Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents: 5049
diff changeset
117 wmmsg.msg.win.msg = msg;
8b7988f42fcb Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents: 5049
diff changeset
118 wmmsg.msg.win.wParam = wParam;
8b7988f42fcb Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents: 5049
diff changeset
119 wmmsg.msg.win.lParam = lParam;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
120 SDL_SendSysWMEvent(&wmmsg);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
121 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
122
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 /* Get the window data for the window */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData"));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 if (!data) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 }
4650
7ad7a473b086 More fixes for windows. Disabled tablet code.
jimtla
parents: 4429
diff changeset
128
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 #ifdef WMMSG_DEBUG
4650
7ad7a473b086 More fixes for windows. Disabled tablet code.
jimtla
parents: 4429
diff changeset
130 {
7ad7a473b086 More fixes for windows. Disabled tablet code.
jimtla
parents: 4429
diff changeset
131 FILE *log = fopen("wmmsg.txt", "a");
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
132 fprintf(log, "Received windows message: %p ", hwnd);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
133 if (msg > MAX_WMMSG) {
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
134 fprintf(log, "%d", msg);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
135 } else {
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
136 fprintf(log, "%s", wmtab[msg]);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
137 }
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
138 fprintf(log, " -- 0x%X, 0x%X\n", wParam, lParam);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
139 fclose(log);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 }
4868
d6adaafcfb10 Fixed compiling with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 4862
diff changeset
141 #endif
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
142
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4746
diff changeset
143 if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata))
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4746
diff changeset
144 return 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 switch (msg) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 case WM_SHOWWINDOW:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 if (wParam) {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
151 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 } else {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
153 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 case WM_ACTIVATE:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 BOOL minimized;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 minimized = HIWORD(wParam);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
164 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
165 SDL_SendWindowEvent(data->window,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 SDL_WINDOWEVENT_RESTORED, 0, 0);
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3102
diff changeset
167 #ifndef _WIN32_WCE /* WinCE misses IsZoomed() */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 if (IsZoomed(hwnd)) {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
169 SDL_SendWindowEvent(data->window,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3102
diff changeset
172 #endif
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
173 if (SDL_GetKeyboardFocus() != data->window) {
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
174 SDL_SetKeyboardFocus(data->window);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 }
4504
9faebccfefb3 Amazingly the Windows code is almost identical to the Mac OS X code. :)
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
176 /*
9faebccfefb3 Amazingly the Windows code is almost identical to the Mac OS X code. :)
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
177 * FIXME: Update keyboard state
9faebccfefb3 Amazingly the Windows code is almost identical to the Mac OS X code. :)
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
178 */
9faebccfefb3 Amazingly the Windows code is almost identical to the Mac OS X code. :)
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
179 WIN_CheckClipboardUpdate(data->videodata);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 } else {
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
181 if (SDL_GetKeyboardFocus() == data->window) {
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
182 SDL_SetKeyboardFocus(NULL);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 if (minimized) {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
185 SDL_SendWindowEvent(data->window,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 SDL_WINDOWEVENT_MINIMIZED, 0, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
190 returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
191 break;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192
4470
a5878b271b74 Fixed mouse focus window reporting
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
193 case WM_MOUSEMOVE:
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3095
diff changeset
194 #ifdef _WIN32_WCE
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
195 /* transform coords for VGA, WVGA... */
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
196 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
197 SDL_VideoData *videodata = data->videodata;
5142
57851a238c8f Removed more partially functional renderers
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
198 if(videodata->CoordTransform) {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
199 POINT pt;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
200 pt.x = LOWORD(lParam);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
201 pt.y = HIWORD(lParam);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
202 videodata->CoordTransform(data->window, &pt);
5142
57851a238c8f Removed more partially functional renderers
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
203 SDL_SendMouseMotion(data->window, 0, pt.x, pt.y);
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
204 break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
205 }
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
206 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4565
diff changeset
207 #endif
4484
9322f7db8603 Cleaned up the mouse window focus handling: you always pass in the relative window when sending a mouse event.
Sam Lantinga <slouken@libsdl.org>
parents: 4470
diff changeset
208 SDL_SendMouseMotion(data->window, 0, LOWORD(lParam), HIWORD(lParam));
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3102
diff changeset
209 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3102
diff changeset
210
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3095
diff changeset
211 case WM_LBUTTONDOWN:
4484
9322f7db8603 Cleaned up the mouse window focus handling: you always pass in the relative window when sending a mouse event.
Sam Lantinga <slouken@libsdl.org>
parents: 4470
diff changeset
212 SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_LEFT);
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3102
diff changeset
213 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3102
diff changeset
214
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3095
diff changeset
215 case WM_LBUTTONUP:
4484
9322f7db8603 Cleaned up the mouse window focus handling: you always pass in the relative window when sending a mouse event.
Sam Lantinga <slouken@libsdl.org>
parents: 4470
diff changeset
216 SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_LEFT);
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3102
diff changeset
217 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3102
diff changeset
218
5049
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
219 case WM_RBUTTONDOWN:
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
220 SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_RIGHT);
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
221 break;
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
222
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
223 case WM_RBUTTONUP:
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
224 SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_RIGHT);
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
225 break;
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
226
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
227 case WM_MBUTTONDOWN:
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
228 SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_MIDDLE);
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
229 break;
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
230
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
231 case WM_MBUTTONUP:
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
232 SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_MIDDLE);
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
233 break;
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
234
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
235 case WM_XBUTTONDOWN:
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
236 SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_X1 + GET_XBUTTON_WPARAM(wParam) - 1);
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
237 returnCode = TRUE;
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
238 break;
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
239
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
240 case WM_XBUTTONUP:
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
241 SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_X1 + GET_XBUTTON_WPARAM(wParam) - 1);
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
242 returnCode = TRUE;
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
243 break;
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
244
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
245 case WM_MOUSEWHEEL:
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
246 {
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
247 int motion = (short) HIWORD(wParam);
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
248
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
249 SDL_SendMouseWheel(data->window, 0, motion);
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
250 break;
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
251 }
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
252
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
253 #ifdef WM_MOUSELEAVE
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
254 /* FIXME: Do we need the SDL 1.2 hack to generate WM_MOUSELEAVE now? */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 case WM_MOUSELEAVE:
4470
a5878b271b74 Fixed mouse focus window reporting
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
256 if (SDL_GetMouseFocus() == data->window) {
a5878b271b74 Fixed mouse focus window reporting
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
257 SDL_SetMouseFocus(NULL);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
259 returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
260 break;
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
261 #endif /* WM_MOUSELEAVE */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 case WM_SYSKEYDOWN:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 case WM_KEYDOWN:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 {
2310
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
266 wParam = RemapVKEY(wParam, lParam);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 switch (wParam) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 case VK_CONTROL:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 if (lParam & EXTENDED_KEYMASK)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 wParam = VK_RCONTROL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 else
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 wParam = VK_LCONTROL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 case VK_SHIFT:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 /* EXTENDED trick doesn't work here */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 {
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
277 Uint8 *state = SDL_GetKeyboardState(NULL);
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
278 if (state[SDL_SCANCODE_LSHIFT] == SDL_RELEASED
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 && (GetKeyState(VK_LSHIFT) & 0x8000)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 wParam = VK_LSHIFT;
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
281 } else if (state[SDL_SCANCODE_RSHIFT] == SDL_RELEASED
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 && (GetKeyState(VK_RSHIFT) & 0x8000)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 wParam = VK_RSHIFT;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 /* Probably a key repeat */
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
286 wParam = 256;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 case VK_MENU:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 if (lParam & EXTENDED_KEYMASK)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 wParam = VK_RMENU;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 else
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 wParam = VK_LMENU;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 break;
2313
012ec5192dfa Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents: 2312
diff changeset
296 case VK_RETURN:
012ec5192dfa Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents: 2312
diff changeset
297 if (lParam & EXTENDED_KEYMASK)
012ec5192dfa Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents: 2312
diff changeset
298 wParam = VK_ENTER;
012ec5192dfa Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents: 2312
diff changeset
299 break;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 }
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
301 if (wParam < 256) {
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
302 SDL_SendKeyboardKey(SDL_PRESSED,
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
303 data->videodata->key_layout[wParam]);
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
304 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
306 returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
307 break;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 case WM_SYSKEYUP:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 case WM_KEYUP:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 {
2310
2f31ce8f1149 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents: 2309
diff changeset
312 wParam = RemapVKEY(wParam, lParam);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 switch (wParam) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 case VK_CONTROL:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 if (lParam & EXTENDED_KEYMASK)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 wParam = VK_RCONTROL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 else
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 wParam = VK_LCONTROL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 case VK_SHIFT:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 /* EXTENDED trick doesn't work here */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 {
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
323 Uint8 *state = SDL_GetKeyboardState(NULL);
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
324 if (state[SDL_SCANCODE_LSHIFT] == SDL_PRESSED
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 wParam = VK_LSHIFT;
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
327 } else if (state[SDL_SCANCODE_RSHIFT] == SDL_PRESSED
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 wParam = VK_RSHIFT;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 /* Probably a key repeat */
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
332 wParam = 256;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 case VK_MENU:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 if (lParam & EXTENDED_KEYMASK)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 wParam = VK_RMENU;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 else
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 wParam = VK_LMENU;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 break;
2313
012ec5192dfa Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents: 2312
diff changeset
342 case VK_RETURN:
012ec5192dfa Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents: 2312
diff changeset
343 if (lParam & EXTENDED_KEYMASK)
012ec5192dfa Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents: 2312
diff changeset
344 wParam = VK_ENTER;
012ec5192dfa Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents: 2312
diff changeset
345 break;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 }
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
347
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 /* Windows only reports keyup for print screen */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 if (wParam == VK_SNAPSHOT
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
350 && SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PRINTSCREEN] ==
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
351 SDL_RELEASED) {
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
352 SDL_SendKeyboardKey(SDL_PRESSED,
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
353 data->videodata->key_layout[wParam]);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 }
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
355 if (wParam < 256) {
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
356 SDL_SendKeyboardKey(SDL_RELEASED,
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
357 data->videodata->key_layout[wParam]);
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
358 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
360 returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
361 break;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362
2309
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
363 case WM_CHAR:
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
364 {
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
365 char text[4];
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
366
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
367 /* Convert to UTF-8 and send it on... */
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
368 if (wParam <= 0x7F) {
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
369 text[0] = (char) wParam;
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
370 text[1] = '\0';
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
371 } else if (wParam <= 0x7FF) {
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
372 text[0] = 0xC0 | (char) ((wParam >> 6) & 0x1F);
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
373 text[1] = 0x80 | (char) (wParam & 0x3F);
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
374 text[2] = '\0';
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
375 } else {
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
376 text[0] = 0xE0 | (char) ((wParam >> 12) & 0x0F);
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
377 text[1] = 0x80 | (char) ((wParam >> 6) & 0x3F);
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
378 text[2] = 0x80 | (char) (wParam & 0x3F);
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
379 text[3] = '\0';
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
380 }
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
381 SDL_SendKeyboardText(text);
2309
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
382 }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
383 returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
384 break;
2309
21591ae7355d Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents: 2308
diff changeset
385
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
386 #ifdef WM_INPUTLANGCHANGE
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2310
diff changeset
387 case WM_INPUTLANGCHANGE:
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2310
diff changeset
388 {
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
389 WIN_UpdateKeymap();
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2310
diff changeset
390 }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
391 returnCode = 1;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
392 break;
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
393 #endif /* WM_INPUTLANGCHANGE */
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2310
diff changeset
394
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
395 #ifdef WM_GETMINMAXINFO
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 case WM_GETMINMAXINFO:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 MINMAXINFO *info;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 RECT size;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 int x, y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 int w, h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 int style;
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
403 BOOL menu;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 /* If we allow resizing, let the resize happen naturally */
4788
0bfda420c936 Put in a couple of fixes that I realized hadn't gotten done when I wrote out the SCRUM stuff in TODO. Added SCRUM listings in TODO.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4429
diff changeset
406 if(SDL_IsShapedWindow(data->window))
4815
93402b9dd20c Added Andreas's patch to fix my silly C++-style errors.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4788
diff changeset
407 Win32_ResizeWindowShape(data->window);
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
408 if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
409 returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
410 break;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 /* Get the current position of our window */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 GetWindowRect(hwnd, &size);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 x = size.left;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 y = size.top;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 /* Calculate current size of our window */
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
419 SDL_GetWindowSize(data->window, &w, &h);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 size.top = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 size.left = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 size.bottom = h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 size.right = w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
425
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
426 style = GetWindowLong(hwnd, GWL_STYLE);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
427 #ifdef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
428 menu = FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
429 #else
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 /* DJM - according to the docs for GetMenu(), the
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 return value is undefined if hwnd is a child window.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 Aparently it's too difficult for MS to check
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 inside their function, so I have to do it here.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 */
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
435 menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
436 #endif
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
437 AdjustWindowRectEx(&size, style, menu, 0);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 w = size.right - size.left;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 h = size.bottom - size.top;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 /* Fix our size to the current size */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 info = (MINMAXINFO *) lParam;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 info->ptMaxSize.x = w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 info->ptMaxSize.y = h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 info->ptMaxPosition.x = x;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 info->ptMaxPosition.y = y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 info->ptMinTrackSize.x = w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 info->ptMinTrackSize.y = h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 info->ptMaxTrackSize.x = w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 info->ptMaxTrackSize.y = h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
452 returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
453 break;
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
454 #endif /* WM_GETMINMAXINFO */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 case WM_WINDOWPOSCHANGED:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 RECT rect;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 int x, y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 int w, h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 Uint32 window_flags;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462
3256
83c87f2b2aab Fixed bug where minimized windows get zero width/height
Sam Lantinga <slouken@libsdl.org>
parents: 3253
diff changeset
463 if (!GetClientRect(hwnd, &rect) ||
83c87f2b2aab Fixed bug where minimized windows get zero width/height
Sam Lantinga <slouken@libsdl.org>
parents: 3253
diff changeset
464 (rect.right == rect.left && rect.bottom == rect.top)) {
83c87f2b2aab Fixed bug where minimized windows get zero width/height
Sam Lantinga <slouken@libsdl.org>
parents: 3253
diff changeset
465 break;
83c87f2b2aab Fixed bug where minimized windows get zero width/height
Sam Lantinga <slouken@libsdl.org>
parents: 3253
diff changeset
466 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 ClientToScreen(hwnd, (LPPOINT) & rect);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 ClientToScreen(hwnd, (LPPOINT) & rect + 1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
470 window_flags = SDL_GetWindowFlags(data->window);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 if ((window_flags & SDL_WINDOW_INPUT_GRABBED) &&
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 (window_flags & SDL_WINDOW_INPUT_FOCUS)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 ClipCursor(&rect);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 x = rect.left;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 y = rect.top;
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
478 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, x, y);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480 w = rect.right - rect.left;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 h = rect.bottom - rect.top;
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
482 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, w,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 h);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 case WM_SETCURSOR:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 {
3076
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
489 Uint16 hittest;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490
3076
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
491 hittest = LOWORD(lParam);
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
492 if (hittest == HTCLIENT) {
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
493 /* FIXME: Implement the cursor API */
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
494 static HCURSOR cursor;
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
495 if (!cursor) {
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
496 cursor = LoadCursor(NULL, IDC_ARROW);
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
497 }
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
498 SetCursor(cursor);
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
499 returnCode = TRUE;
3076
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
500 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 /* We were occluded, refresh our display */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 case WM_PAINT:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 RECT rect;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 if (GetUpdateRect(hwnd, &rect, FALSE)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 ValidateRect(hwnd, &rect);
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
510 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 0, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
514 returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
515 break;
3095
75483112b97f Date: Sat, 21 Mar 2009 19:41:52 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 3076
diff changeset
516
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 /* We'll do our own drawing, prevent flicker */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 case WM_ERASEBKGND:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521 return (1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
523 #if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 case WM_SYSCOMMAND:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
525 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
526 /* Don't start the screensaver or blank the monitor in fullscreen apps */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
527 if ((wParam & 0xFFF0) == SC_SCREENSAVE ||
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 (wParam & 0xFFF0) == SC_MONITORPOWER) {
3032
77c3e67f0740 Fixed Visual C++ build
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
529 if (SDL_GetVideoDevice()->suspend_screensaver) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530 return (0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 break;
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
535 #endif /* System has screensaver support */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537 case WM_CLOSE:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
539 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
541 returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
542 break;
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
543
4650
7ad7a473b086 More fixes for windows. Disabled tablet code.
jimtla
parents: 4429
diff changeset
544 case WM_TOUCH:
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
545 {
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
546 UINT i, num_inputs = LOWORD(wParam);
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
547 PTOUCHINPUT inputs = SDL_stack_alloc(TOUCHINPUT, num_inputs);
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
548 if (data->videodata->GetTouchInputInfo((HTOUCHINPUT)lParam, num_inputs, inputs, sizeof(TOUCHINPUT))) {
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
549 RECT rect;
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
550 float x, y;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
551
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
552 if (!GetClientRect(hwnd, &rect) ||
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
553 (rect.right == rect.left && rect.bottom == rect.top)) {
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
554 break;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
555 }
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
556 ClientToScreen(hwnd, (LPPOINT) & rect);
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
557 ClientToScreen(hwnd, (LPPOINT) & rect + 1);
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
558 rect.top *= 100;
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
559 rect.left *= 100;
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
560 rect.bottom *= 100;
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
561 rect.right *= 100;
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
562
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
563 for (i = 0; i < num_inputs; ++i) {
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
564 PTOUCHINPUT input = &inputs[i];
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
565
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
566 SDL_TouchID touchId = (SDL_TouchID)input->hSource;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
567 if (!SDL_GetTouch(touchId)) {
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
568 SDL_Touch touch;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
569
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
570 touch.id = touchId;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
571 touch.x_min = 0;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
572 touch.x_max = 1;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
573 touch.native_xres = touch.x_max - touch.x_min;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
574 touch.y_min = 0;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
575 touch.y_max = 1;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
576 touch.native_yres = touch.y_max - touch.y_min;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
577 touch.pressure_min = 0;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
578 touch.pressure_max = 1;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
579 touch.native_pressureres = touch.pressure_max - touch.pressure_min;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
580
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
581 if (SDL_AddTouch(&touch, "") < 0) {
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
582 continue;
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
583 }
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
584 }
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
585
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
586 // Get the normalized coordinates for the window
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
587 x = (float)(input->x - rect.left)/(rect.right - rect.left);
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
588 y = (float)(input->y - rect.top)/(rect.bottom - rect.top);
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
589
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
590 if (input->dwFlags & TOUCHEVENTF_DOWN) {
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
591 SDL_SendFingerDown(touchId, input->dwID, SDL_TRUE, x, y, 1);
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
592 }
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
593 if (input->dwFlags & TOUCHEVENTF_MOVE) {
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
594 SDL_SendTouchMotion(touchId, input->dwID, SDL_FALSE, x, y, 1);
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
595 }
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
596 if (input->dwFlags & TOUCHEVENTF_UP) {
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
597 SDL_SendFingerDown(touchId, input->dwID, SDL_FALSE, x, y, 1);
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
598 }
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
599 }
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
600 }
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
601 SDL_stack_free(inputs);
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
602
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
603 data->videodata->CloseTouchInputHandle((HTOUCHINPUT)lParam);
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
604 return 0;
4650
7ad7a473b086 More fixes for windows. Disabled tablet code.
jimtla
parents: 4429
diff changeset
605 }
7ad7a473b086 More fixes for windows. Disabled tablet code.
jimtla
parents: 4429
diff changeset
606 break;
7ad7a473b086 More fixes for windows. Disabled tablet code.
jimtla
parents: 4429
diff changeset
607 }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
608
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
609 /* If there's a window proc, assume it's going to handle messages */
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
610 if (data->wndproc) {
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
611 return CallWindowProc(data->wndproc, hwnd, msg, wParam, lParam);
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
612 } else if (returnCode >= 0) {
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
613 return returnCode;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
614 } else {
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
615 return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
616 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
617 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
618
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
619 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
620 WIN_PumpEvents(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
621 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622 MSG msg;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
624 TranslateMessage(&msg);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
625 DispatchMessage(&msg);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
626 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 static int app_registered = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630 LPTSTR SDL_Appname = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
631 Uint32 SDL_Appstyle = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
632 HINSTANCE SDL_Instance = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
634 /* Register the class for this application */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
635 int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
636 SDL_RegisterApp(char *name, Uint32 style, void *hInst)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638 WNDCLASS class;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
639
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
640 /* Only do this once... */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
641 if (app_registered) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
642 ++app_registered;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
643 return (0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
644 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
645 if (!name && !SDL_Appname) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
646 name = "SDL_app";
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
647 #if defined(CS_BYTEALIGNCLIENT) || defined(CS_OWNDC)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC);
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
649 #endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
650 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
651 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
652
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
653 if (name) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
654 SDL_Appname = WIN_UTF8ToString(name);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
655 SDL_Appstyle = style;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
656 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
657 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
659 /* Register the application class */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
660 class.hCursor = NULL;
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
661 class.hIcon =
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
662 LoadImage(SDL_Instance, SDL_Appname, IMAGE_ICON, 0, 0,
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
663 LR_DEFAULTCOLOR);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 class.lpszMenuName = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
665 class.lpszClassName = SDL_Appname;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
666 class.hbrBackground = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
667 class.hInstance = SDL_Instance;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
668 class.style = SDL_Appstyle;
4733
983eb9d5ed31 Change SDL to not use DefWindowProc as the window class' window procedure.
dewyatt
parents: 4429
diff changeset
669 class.lpfnWndProc = WIN_WindowProc;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
670 class.cbWndExtra = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
671 class.cbClsExtra = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
672 if (!RegisterClass(&class)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
673 SDL_SetError("Couldn't register application class");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
674 return (-1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
675 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
676
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
677 app_registered = 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
678 return (0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
679 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
680
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
681 /* Unregisters the windowclass registered in SDL_RegisterApp above. */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
682 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
683 SDL_UnregisterApp()
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
685 WNDCLASS class;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
686
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
687 /* SDL_RegisterApp might not have been called before */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
688 if (!app_registered) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
689 return;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
690 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
691 --app_registered;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
692 if (app_registered == 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
693 /* Check for any registered window classes. */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
694 if (GetClassInfo(SDL_Instance, SDL_Appname, &class)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
695 UnregisterClass(SDL_Appname, SDL_Instance);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
696 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
697 SDL_free(SDL_Appname);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
698 SDL_Appname = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
699 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
700 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
701
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
702 /* vi: set ts=4 sw=4 expandtab: */