Mercurial > sdl-ios-xcode
annotate src/video/win32/SDL_win32events.c @ 3599:0f958e527e5e
Updated to compile on Windows
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 24 Dec 2009 19:18:05 +0000 |
parents | 07c8339c95c6 |
children | 64ce267332c6 |
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 |
2859 | 3 Copyright (C) 1997-2009 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 |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
23 #if (_WIN32_WINNT < 0x0501) |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
24 #undef _WIN32_WINNT |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
25 #define _WIN32_WINNT 0x0501 |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
26 #endif |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
27 |
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
|
28 #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
|
29 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include "SDL_win32video.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
|
31 #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
|
32 #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
|
33 #include "../../events/SDL_events_c.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
|
34 |
c121d94672cb
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 /*#define WMMSG_DEBUG*/ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 #ifdef WMMSG_DEBUG |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
37 #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
|
38 #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
|
39 #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
|
40 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 /* 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
|
42 #define REPEATED_KEYMASK (1<<30) |
f537a293b3da
Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents:
2313
diff
changeset
|
43 #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
|
44 |
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
|
45 #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
|
46 |
2127
3bcc26b74e42
Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1951
diff
changeset
|
47 /* 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
|
48 #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
|
49 #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
|
50 #endif |
3bcc26b74e42
Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1951
diff
changeset
|
51 #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
|
52 #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
|
53 #endif |
3bcc26b74e42
Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1951
diff
changeset
|
54 #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
|
55 #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
|
56 #endif |
2733
264037dd3c7a
Fix for mingw compilation by Alam.
Edgar Simo <bobbens@gmail.com>
parents:
2726
diff
changeset
|
57 #ifndef WM_INPUT |
264037dd3c7a
Fix for mingw compilation by Alam.
Edgar Simo <bobbens@gmail.com>
parents:
2726
diff
changeset
|
58 #define WM_INPUT 0x00ff |
264037dd3c7a
Fix for mingw compilation by Alam.
Edgar Simo <bobbens@gmail.com>
parents:
2726
diff
changeset
|
59 #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
|
60 |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
61 extern HCTX *g_hCtx; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
62 extern HANDLE *mice; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
63 extern int total_mice; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
64 extern int tablet; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
65 int pressure = 0; /* the pressure reported by the tablet */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
66 |
2310
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
67 static WPARAM |
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
68 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
|
69 { |
2317
f537a293b3da
Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents:
2313
diff
changeset
|
70 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
|
71 BYTE scancode = (BYTE) ((lParam >> 16) & 0xFF); |
2317
f537a293b3da
Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents:
2313
diff
changeset
|
72 |
2310
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
73 /* 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
|
74 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
|
75 */ |
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
76 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
|
77 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
|
78 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
|
79 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
|
80 wParam = 'A' + i; |
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
81 break; |
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
82 } |
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
83 } |
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
84 } |
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
85 } |
2317
f537a293b3da
Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents:
2313
diff
changeset
|
86 |
f537a293b3da
Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents:
2313
diff
changeset
|
87 /* Keypad keys are a little trickier, we always scan for them. */ |
f537a293b3da
Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents:
2313
diff
changeset
|
88 for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) { |
f537a293b3da
Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents:
2313
diff
changeset
|
89 if (scancode == keypad_scancodes[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
|
90 wParam = VK_NUMPAD0 + i; |
2317
f537a293b3da
Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents:
2313
diff
changeset
|
91 break; |
f537a293b3da
Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents:
2313
diff
changeset
|
92 } |
f537a293b3da
Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents:
2313
diff
changeset
|
93 } |
f537a293b3da
Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents:
2313
diff
changeset
|
94 |
2310
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
95 return wParam; |
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
96 } |
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
97 |
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
|
98 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
|
99 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
|
100 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 SDL_WindowData *data; |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
102 RAWINPUT *raw; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
103 PACKET packet; |
3566 | 104 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
|
105 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
106 /* Send a SDL_SYSWMEVENT if the application wants them */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
107 if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
108 SDL_SysWMmsg wmmsg; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
109 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
110 SDL_VERSION(&wmmsg.version); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
111 wmmsg.hwnd = hwnd; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
112 wmmsg.msg = msg; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
113 wmmsg.wParam = wParam; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
114 wmmsg.lParam = lParam; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
115 SDL_SendSysWMEvent(&wmmsg); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
116 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
117 |
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
|
118 /* 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
|
119 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
|
120 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
|
121 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
|
122 } |
c121d94672cb
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 #ifdef WMMSG_DEBUG |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
124 { |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
125 FILE *log = fopen("wmmsg.txt", "a"); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
126 fprintf(log, "Received windows message: %p ", hwnd); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
127 if (msg > MAX_WMMSG) { |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
128 fprintf(log, "%d", msg); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
129 } else { |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
130 fprintf(log, "%s", wmtab[msg]); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
131 } |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
132 fprintf(log, " -- 0x%X, 0x%X\n", wParam, lParam); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
133 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
|
134 } |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
135 |
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
|
136 #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
|
137 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 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
|
139 |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
140 case WT_PACKET: |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
141 { |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
142 /* if we receive such data we need to update the pressure */ |
2726
f23ebf1ddac4
Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents:
2724
diff
changeset
|
143 SDL_VideoData *videodata = data->videodata; |
f23ebf1ddac4
Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents:
2724
diff
changeset
|
144 if (videodata->wintabDLL |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
3168
diff
changeset
|
145 && videodata->WTPacket((HCTX) lParam, (UINT) wParam, &packet)) { |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
146 SDL_ChangeEnd(tablet, (int) packet.pkCursor); |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
147 pressure = (int) packet.pkNormalPressure; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
148 } |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
149 } |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
150 break; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
151 |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
152 case WT_PROXIMITY: |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
153 { |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
154 /* checking where the proximity message showed up */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
155 int h_context = LOWORD(lParam); |
2724
0e2b65f32298
Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents:
2711
diff
changeset
|
156 POINT point; |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
157 GetCursorPos(&point); |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
158 ScreenToClient(hwnd, &point); |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
159 |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
160 /* are we in proximity or out of proximity */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
161 if (h_context == 0) { |
2724
0e2b65f32298
Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents:
2711
diff
changeset
|
162 SDL_SendProximity(tablet, point.x, point.y, SDL_PROXIMITYOUT); |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
163 } else { |
2724
0e2b65f32298
Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents:
2711
diff
changeset
|
164 SDL_SendProximity(tablet, point.x, point.y, SDL_PROXIMITYIN); |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
165 } |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
166 } |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
167 break; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
168 |
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
|
169 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
|
170 { |
c121d94672cb
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 if (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
|
172 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, 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
|
173 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
|
174 } 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
|
175 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_HIDDEN, 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
|
176 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
|
177 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 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
|
180 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 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
|
182 { |
c121d94672cb
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 int index; |
c121d94672cb
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 SDL_Keyboard *keyboard; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 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
|
186 |
c121d94672cb
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 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
|
188 index = data->videodata->keyboard; |
c121d94672cb
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 keyboard = SDL_GetKeyboard(index); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, |
c121d94672cb
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 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
|
193 SDL_SendWindowEvent(data->windowID, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 SDL_WINDOWEVENT_RESTORED, 0, 0); |
3139 | 195 #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
|
196 if (IsZoomed(hwnd)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 SDL_SendWindowEvent(data->windowID, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 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
|
199 } |
3139 | 200 #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
|
201 if (keyboard && keyboard->focus != data->windowID) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 SDL_SetKeyboardFocus(index, data->windowID); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 /* FIXME: Update keyboard state */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 } 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
|
206 if (keyboard && keyboard->focus == data->windowID) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 SDL_SetKeyboardFocus(index, 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
|
208 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 if (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
|
210 SDL_SendWindowEvent(data->windowID, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 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
|
212 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 } |
3566 | 215 returnCode = 0; |
216 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
|
217 |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3095
diff
changeset
|
218 /* WinCE has no RawInput, so we use the classic mouse events. |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3095
diff
changeset
|
219 In classic Win32 this is done by WM_INPUT |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3095
diff
changeset
|
220 */ |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3095
diff
changeset
|
221 #ifdef _WIN32_WCE |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3095
diff
changeset
|
222 case WM_MOUSEMOVE: |
3139 | 223 SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0); |
224 break; | |
225 | |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3095
diff
changeset
|
226 case WM_LBUTTONDOWN: |
3139 | 227 SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0); |
228 SDL_SendMouseButton(0, SDL_PRESSED, SDL_BUTTON_LEFT); | |
229 break; | |
230 | |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3095
diff
changeset
|
231 case WM_LBUTTONUP: |
3139 | 232 SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0); |
233 SDL_SendMouseButton(0, SDL_RELEASED, SDL_BUTTON_LEFT); | |
234 break; | |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3095
diff
changeset
|
235 #else /* _WIN32_WCE */ |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3095
diff
changeset
|
236 |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
237 case WM_INPUT: /* mouse events */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
238 { |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
239 LPBYTE lpb; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
240 const RAWINPUTHEADER *header; |
3260 | 241 int index = -1; |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
242 int i; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
243 int size = 0; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
244 const RAWMOUSE *raw_mouse = NULL; |
2724
0e2b65f32298
Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents:
2711
diff
changeset
|
245 POINT point; |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
246 USHORT flags; |
2974
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
247 int 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
|
248 |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3095
diff
changeset
|
249 /* we're collecting raw data to be able to identify the mouse (if there are several) */ |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
250 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
251 sizeof(RAWINPUTHEADER)); |
2766
5955b6550d7e
Fixed memory leak in raw mouse input processing.
Sam Lantinga <slouken@libsdl.org>
parents:
2733
diff
changeset
|
252 lpb = SDL_stack_alloc(BYTE, size); |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
253 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
254 sizeof(RAWINPUTHEADER)); |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
255 raw = (RAWINPUT *) lpb; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
256 header = &raw->header; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
257 flags = raw->data.mouse.usButtonFlags; |
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 |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
259 /* we're checking which mouse generated the event */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
260 for (i = 0; i < total_mice; ++i) { |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
261 if (mice[i] == header->hDevice) { |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
262 index = i; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
263 break; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
264 } |
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
|
265 } |
3260 | 266 if (index < 0) { |
267 /* New mouse? Should we dynamically update mouse list? */ | |
3566 | 268 returnCode = 0; |
269 break; | |
3260 | 270 } |
3139 | 271 |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
272 GetCursorPos(&point); |
2974
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
273 ScreenToClient(hwnd, &point); |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
274 |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
275 SDL_GetWindowSize(data->windowID, &w, &h); |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
276 if (point.x >= 0 && point.y >= 0 && point.x < w && point.y < h) { |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
277 SDL_SetMouseFocus(index, data->windowID); |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
278 } else { |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
279 SDL_SetMouseFocus(index, 0); |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
280 /* FIXME: Should we be doing anything else here? */ |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
281 break; |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
282 } |
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
|
283 |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
284 /* if the message was sent by a tablet we have to send also pressure */ |
2794
f7872b7a8732
Fixed mouse coordinate range on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2766
diff
changeset
|
285 if (index == tablet) { |
2724
0e2b65f32298
Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents:
2711
diff
changeset
|
286 SDL_SendMouseMotion(index, 0, point.x, point.y, pressure); |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
287 } else { |
2724
0e2b65f32298
Added Wacom API headers.
Sam Lantinga <slouken@libsdl.org>
parents:
2711
diff
changeset
|
288 SDL_SendMouseMotion(index, 0, point.x, point.y, 0); |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
289 } |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
290 /* we're sending mouse buttons messages to check up if sth changed */ |
2766
5955b6550d7e
Fixed memory leak in raw mouse input processing.
Sam Lantinga <slouken@libsdl.org>
parents:
2733
diff
changeset
|
291 if (flags & RI_MOUSE_LEFT_BUTTON_DOWN) { |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
292 SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_LEFT); |
2766
5955b6550d7e
Fixed memory leak in raw mouse input processing.
Sam Lantinga <slouken@libsdl.org>
parents:
2733
diff
changeset
|
293 } else if (flags & RI_MOUSE_LEFT_BUTTON_UP) { |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
294 SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_LEFT); |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
295 } |
2766
5955b6550d7e
Fixed memory leak in raw mouse input processing.
Sam Lantinga <slouken@libsdl.org>
parents:
2733
diff
changeset
|
296 if (flags & RI_MOUSE_MIDDLE_BUTTON_DOWN) { |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
297 SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_MIDDLE); |
2766
5955b6550d7e
Fixed memory leak in raw mouse input processing.
Sam Lantinga <slouken@libsdl.org>
parents:
2733
diff
changeset
|
298 } else if (flags & RI_MOUSE_MIDDLE_BUTTON_UP) { |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
299 SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_MIDDLE); |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
300 } |
2766
5955b6550d7e
Fixed memory leak in raw mouse input processing.
Sam Lantinga <slouken@libsdl.org>
parents:
2733
diff
changeset
|
301 if (flags & RI_MOUSE_RIGHT_BUTTON_DOWN) { |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
302 SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_RIGHT); |
2766
5955b6550d7e
Fixed memory leak in raw mouse input processing.
Sam Lantinga <slouken@libsdl.org>
parents:
2733
diff
changeset
|
303 } else if (flags & RI_MOUSE_RIGHT_BUTTON_UP) { |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
304 SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_RIGHT); |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
305 } |
2711
62e7af9b2b67
Added missing X1/X2 button support
Sam Lantinga <slouken@libsdl.org>
parents:
2710
diff
changeset
|
306 if (flags & RI_MOUSE_BUTTON_4_DOWN) { |
62e7af9b2b67
Added missing X1/X2 button support
Sam Lantinga <slouken@libsdl.org>
parents:
2710
diff
changeset
|
307 SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_X1); |
62e7af9b2b67
Added missing X1/X2 button support
Sam Lantinga <slouken@libsdl.org>
parents:
2710
diff
changeset
|
308 } else if (flags & RI_MOUSE_BUTTON_4_UP) { |
62e7af9b2b67
Added missing X1/X2 button support
Sam Lantinga <slouken@libsdl.org>
parents:
2710
diff
changeset
|
309 SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_X1); |
62e7af9b2b67
Added missing X1/X2 button support
Sam Lantinga <slouken@libsdl.org>
parents:
2710
diff
changeset
|
310 } |
62e7af9b2b67
Added missing X1/X2 button support
Sam Lantinga <slouken@libsdl.org>
parents:
2710
diff
changeset
|
311 if (flags & RI_MOUSE_BUTTON_5_DOWN) { |
62e7af9b2b67
Added missing X1/X2 button support
Sam Lantinga <slouken@libsdl.org>
parents:
2710
diff
changeset
|
312 SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_X2); |
62e7af9b2b67
Added missing X1/X2 button support
Sam Lantinga <slouken@libsdl.org>
parents:
2710
diff
changeset
|
313 } else if (flags & RI_MOUSE_BUTTON_5_UP) { |
62e7af9b2b67
Added missing X1/X2 button support
Sam Lantinga <slouken@libsdl.org>
parents:
2710
diff
changeset
|
314 SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_X2); |
62e7af9b2b67
Added missing X1/X2 button support
Sam Lantinga <slouken@libsdl.org>
parents:
2710
diff
changeset
|
315 } |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
316 if (flags & RI_MOUSE_WHEEL) { |
2975 | 317 SDL_SendMouseWheel(index, 0, |
2990 | 318 (short) raw->data.mouse.usButtonData); |
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
|
319 } |
2766
5955b6550d7e
Fixed memory leak in raw mouse input processing.
Sam Lantinga <slouken@libsdl.org>
parents:
2733
diff
changeset
|
320 SDL_stack_free(lpb); |
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
|
321 } |
3566 | 322 returnCode = 0; |
323 break; | |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3095
diff
changeset
|
324 #endif /* _WIN32_WCE */ |
3139 | 325 |
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
|
326 case WM_MOUSELEAVE: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 { |
2974
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
328 int i; |
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
|
329 |
2974
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
330 for (i = 0; i < SDL_GetNumMice(); ++i) { |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
331 SDL_Mouse *mouse = SDL_GetMouse(i); |
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
|
332 |
2974
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
333 if (mouse->focus == data->windowID) { |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
334 SDL_SetMouseFocus(i, 0); |
d2f68ec8c1d0
The mouse position is relative to the client window.
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
335 } |
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
|
336 } |
c121d94672cb
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 } |
3566 | 338 returnCode = 0; |
339 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
|
340 |
c121d94672cb
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 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
|
342 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
|
343 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 int index; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 |
c121d94672cb
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 /* Ignore repeated keys */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 if (lParam & REPEATED_KEYMASK) { |
3566 | 348 returnCode = 0; |
349 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
|
350 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 index = data->videodata->keyboard; |
2310
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
353 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
|
354 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 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
|
362 /* 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
|
363 { |
2308
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
364 Uint8 *state = SDL_GetKeyboardState(NULL); |
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
365 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
|
366 && (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
|
367 wParam = VK_LSHIFT; |
2308
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
368 } 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
|
369 && (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
|
370 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
|
371 } 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
|
372 /* Probably a key repeat */ |
3566 | 373 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
|
374 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 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
|
377 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 break; |
2313
012ec5192dfa
Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents:
2312
diff
changeset
|
383 case VK_RETURN: |
012ec5192dfa
Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents:
2312
diff
changeset
|
384 if (lParam & EXTENDED_KEYMASK) |
012ec5192dfa
Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents:
2312
diff
changeset
|
385 wParam = VK_ENTER; |
012ec5192dfa
Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents:
2312
diff
changeset
|
386 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
|
387 } |
2308
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
388 if (wParam < 256) { |
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
389 SDL_SendKeyboardKey(index, SDL_PRESSED, |
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
390 data->videodata->key_layout[wParam]); |
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
391 } |
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
|
392 } |
3566 | 393 returnCode = 0; |
394 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
|
395 |
c121d94672cb
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_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
|
397 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
|
398 { |
c121d94672cb
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 int index; |
c121d94672cb
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 |
c121d94672cb
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 index = data->videodata->keyboard; |
2310
2f31ce8f1149
Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...
Sam Lantinga <slouken@libsdl.org>
parents:
2309
diff
changeset
|
402 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
|
403 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
|
404 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
|
405 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
|
406 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
|
407 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
|
408 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
|
409 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
|
410 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
|
411 /* 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
|
412 { |
2308
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
413 Uint8 *state = SDL_GetKeyboardState(NULL); |
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
414 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
|
415 && !(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
|
416 wParam = VK_LSHIFT; |
2308
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
417 } 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
|
418 && !(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
|
419 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
|
420 } 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
|
421 /* Probably a key repeat */ |
3566 | 422 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
|
423 } |
c121d94672cb
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 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 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
|
426 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
|
427 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
|
428 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
|
429 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
|
430 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
|
431 break; |
2313
012ec5192dfa
Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents:
2312
diff
changeset
|
432 case VK_RETURN: |
012ec5192dfa
Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents:
2312
diff
changeset
|
433 if (lParam & EXTENDED_KEYMASK) |
012ec5192dfa
Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents:
2312
diff
changeset
|
434 wParam = VK_ENTER; |
012ec5192dfa
Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents:
2312
diff
changeset
|
435 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
|
436 } |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
437 |
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 /* 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
|
439 if (wParam == VK_SNAPSHOT |
2308
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
440 && SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PRINTSCREEN] == |
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
441 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
|
442 SDL_SendKeyboardKey(index, SDL_PRESSED, |
2308
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
443 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
|
444 } |
2308
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
445 if (wParam < 256) { |
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
446 SDL_SendKeyboardKey(index, SDL_RELEASED, |
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
447 data->videodata->key_layout[wParam]); |
514f7c1651fc
Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents:
2284
diff
changeset
|
448 } |
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
|
449 } |
3566 | 450 returnCode = 0; |
451 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
|
452 |
2309
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
453 case WM_CHAR: |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
454 { |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
455 char text[4]; |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
456 |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
457 /* Convert to UTF-8 and send it on... */ |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
458 if (wParam <= 0x7F) { |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
459 text[0] = (char) wParam; |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
460 text[1] = '\0'; |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
461 } else if (wParam <= 0x7FF) { |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
462 text[0] = 0xC0 | (char) ((wParam >> 6) & 0x1F); |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
463 text[1] = 0x80 | (char) (wParam & 0x3F); |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
464 text[2] = '\0'; |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
465 } else { |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
466 text[0] = 0xE0 | (char) ((wParam >> 12) & 0x0F); |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
467 text[1] = 0x80 | (char) ((wParam >> 6) & 0x3F); |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
468 text[2] = 0x80 | (char) (wParam & 0x3F); |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
469 text[3] = '\0'; |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
470 } |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
471 SDL_SendKeyboardText(data->videodata->keyboard, text); |
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
472 } |
3566 | 473 returnCode = 0; |
474 break; | |
2309
21591ae7355d
Implemented text input event for Win32
Sam Lantinga <slouken@libsdl.org>
parents:
2308
diff
changeset
|
475 |
2311
54e21acfec5a
Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents:
2310
diff
changeset
|
476 case WM_INPUTLANGCHANGE: |
54e21acfec5a
Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents:
2310
diff
changeset
|
477 { |
54e21acfec5a
Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents:
2310
diff
changeset
|
478 WIN_UpdateKeymap(data->videodata->keyboard); |
54e21acfec5a
Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents:
2310
diff
changeset
|
479 } |
3566 | 480 returnCode = 1; |
481 break; | |
2311
54e21acfec5a
Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents:
2310
diff
changeset
|
482 |
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 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
|
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 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
|
486 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
|
487 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
|
488 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
|
489 int style; |
3168 | 490 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
|
491 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 /* If we allow resizing, let the resize happen naturally */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 if (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_RESIZABLE) { |
3566 | 494 returnCode = 0; |
495 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
|
496 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 /* 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
|
499 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
|
500 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
|
501 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
|
502 |
c121d94672cb
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 /* Calculate current size 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
|
504 SDL_GetWindowSize(data->windowID, &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
|
505 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
|
506 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
|
507 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
|
508 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
|
509 |
3168 | 510 |
511 style = GetWindowLong(hwnd, GWL_STYLE); | |
512 #ifdef _WIN32_WCE | |
513 menu = FALSE; | |
514 #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
|
515 /* 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
|
516 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
|
517 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
|
518 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
|
519 */ |
3168 | 520 menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); |
521 #endif | |
522 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
|
523 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
|
524 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
|
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 /* 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
|
527 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
|
528 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
|
529 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
|
530 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
|
531 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
|
532 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
|
533 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
|
534 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
|
535 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
|
536 } |
3566 | 537 returnCode = 0; |
538 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
|
539 |
c121d94672cb
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 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
|
541 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 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
|
543 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
|
544 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
|
545 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
|
546 |
3256
83c87f2b2aab
Fixed bug where minimized windows get zero width/height
Sam Lantinga <slouken@libsdl.org>
parents:
3253
diff
changeset
|
547 if (!GetClientRect(hwnd, &rect) || |
83c87f2b2aab
Fixed bug where minimized windows get zero width/height
Sam Lantinga <slouken@libsdl.org>
parents:
3253
diff
changeset
|
548 (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
|
549 break; |
83c87f2b2aab
Fixed bug where minimized windows get zero width/height
Sam Lantinga <slouken@libsdl.org>
parents:
3253
diff
changeset
|
550 } |
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
|
551 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
|
552 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
|
553 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 window_flags = SDL_GetWindowFlags(data->windowID); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
555 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
|
556 (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
|
557 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
|
558 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
559 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
560 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
|
561 y = rect.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
|
562 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MOVED, 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
|
563 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
564 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
|
565 h = rect.bottom - rect.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
|
566 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESIZED, 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
|
567 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
|
568 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
569 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
|
570 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 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
|
572 { |
3076
085e46423377
Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents:
3032
diff
changeset
|
573 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
|
574 |
3076
085e46423377
Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents:
3032
diff
changeset
|
575 hittest = LOWORD(lParam); |
085e46423377
Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents:
3032
diff
changeset
|
576 if (hittest == HTCLIENT) { |
085e46423377
Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents:
3032
diff
changeset
|
577 /* 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
|
578 static HCURSOR cursor; |
085e46423377
Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents:
3032
diff
changeset
|
579 if (!cursor) { |
085e46423377
Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents:
3032
diff
changeset
|
580 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
|
581 } |
085e46423377
Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents:
3032
diff
changeset
|
582 SetCursor(cursor); |
3566 | 583 returnCode = TRUE; |
3076
085e46423377
Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents:
3032
diff
changeset
|
584 } |
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
|
585 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 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
|
587 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 /* We are about to get palette 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
|
589 case WM_QUERYNEWPALETTE: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 /* |
3566 | 592 WIN_RealizePalette(current_video); |
593 returnCode = TRUE; | |
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
|
594 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 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
|
597 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
598 /* Another application changed the palette */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
599 case WM_PALETTECHANGED: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 WIN_PaletteChanged(current_video, (HWND) 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
|
603 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 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
|
606 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
607 /* 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
|
608 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
|
609 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
610 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
|
611 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
|
612 ValidateRect(hwnd, &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
|
613 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_EXPOSED, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
614 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
|
615 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
616 } |
3566 | 617 returnCode = 0; |
618 break; | |
3095
75483112b97f
Date: Sat, 21 Mar 2009 19:41:52 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents:
3076
diff
changeset
|
619 |
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
|
620 /* 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
|
621 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
|
622 { |
c121d94672cb
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 } |
c121d94672cb
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 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
|
625 |
c121d94672cb
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 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
|
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 /* 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
|
629 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
|
630 (wParam & 0xFFF0) == SC_MONITORPOWER) { |
3032 | 631 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
|
632 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
|
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 } |
c121d94672cb
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 } |
c121d94672cb
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 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
|
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 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
|
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 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_CLOSE, 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
|
641 } |
3566 | 642 returnCode = 0; |
643 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
|
644 } |
3566 | 645 |
646 /* If there's a window proc, assume it's going to handle messages */ | |
647 if (data->wndproc) { | |
648 return CallWindowProc(data->wndproc, hwnd, msg, wParam, lParam); | |
649 } else if (returnCode >= 0) { | |
650 return returnCode; | |
651 } else { | |
652 return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); | |
653 } | |
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
|
654 } |
c121d94672cb
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 |
c121d94672cb
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 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
|
657 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
|
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 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
|
660 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
|
661 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
|
662 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
|
663 } |
c121d94672cb
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 } |
c121d94672cb
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 |
c121d94672cb
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 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
|
667 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
|
668 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
|
669 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
|
670 |
c121d94672cb
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 /* 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
|
672 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
|
673 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
|
674 { |
c121d94672cb
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 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
|
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 /* 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
|
678 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
|
679 ++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
|
680 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
|
681 } |
c121d94672cb
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 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
|
683 name = "SDL_app"; |
c121d94672cb
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 SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC); |
c121d94672cb
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 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
|
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 |
c121d94672cb
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 (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
|
689 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
|
690 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
|
691 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
|
692 } |
c121d94672cb
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 |
c121d94672cb
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 /* 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
|
695 class.hCursor = NULL; |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
696 class.hIcon = |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
697 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
|
698 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
|
699 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
|
700 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
|
701 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
|
702 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
|
703 class.style = SDL_Appstyle; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
704 class.lpfnWndProc = DefWindowProc; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
705 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
|
706 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
|
707 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
|
708 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
|
709 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
|
710 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
711 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
712 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
|
713 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
|
714 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
715 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
716 /* 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
|
717 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
|
718 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
|
719 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
720 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
|
721 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
722 /* 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
|
723 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
|
724 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
|
725 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
726 --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
|
727 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
|
728 /* 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
|
729 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
|
730 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
|
731 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
732 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
|
733 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
|
734 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
736 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
737 /* Sets an error message based on GetLastError() */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
738 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
|
739 WIN_SetError(const char *prefix) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
740 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
741 TCHAR buffer[1024]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
742 char *message; |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
743 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
744 buffer, SDL_arraysize(buffer), 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
|
745 message = WIN_StringToUTF8(buffer); |
3565 | 746 SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message); |
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
|
747 SDL_free(message); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
748 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
749 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
750 /* vi: set ts=4 sw=4 expandtab: */ |