Mercurial > sdl-ios-xcode
annotate src/video/win32/SDL_win32events.c @ 3770:81b649bad6d2 gsoc2008_manymouse
Implementation finished
author | Szymon Wilczek <kazeuser@gmail.com> |
---|---|
date | Thu, 31 Jul 2008 14:41:48 +0000 |
parents | 1b87a8beab9d |
children | 8cc36a399a12 |
rev | line source |
---|---|
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
1 /* |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
4 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
7 License as published by the Free Software Foundation; either |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
9 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
13 Lesser General Public License for more details. |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
14 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
18 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
19 Sam Lantinga |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
20 slouken@libsdl.org |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
21 */ |
3768 | 22 |
23 #if (_WIN32_WINNT < 0x0501) | |
24 #undef _WIN32_WINNT | |
25 #define _WIN32_WINNT 0x0501 | |
26 #endif | |
27 | |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
28 #include "SDL_config.h" |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
29 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
30 #include "SDL_win32video.h" |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
31 #include "SDL_syswm.h" |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
32 #include "SDL_vkeys.h" |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
33 #include "../../events/SDL_events_c.h" |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
34 #include <wintab.h> |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
35 #define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
36 #define PACKETMODE 0 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
37 #include <pktdef.h> |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
38 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
39 /*#define WMMSG_DEBUG*/ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
40 #ifdef WMMSG_DEBUG |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
41 #include <stdio.h> |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
42 #include "wmmsg.h" |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
43 #endif |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
44 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
45 /* Masks for processing the windows KEYDOWN and KEYUP messages */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
46 #define REPEATED_KEYMASK (1<<30) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
47 #define EXTENDED_KEYMASK (1<<24) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
48 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
49 #define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
50 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
51 /* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
52 #ifndef WM_XBUTTONDOWN |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
53 #define WM_XBUTTONDOWN 0x020B |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
54 #endif |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
55 #ifndef WM_XBUTTONUP |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
56 #define WM_XBUTTONUP 0x020C |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
57 #endif |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
58 #ifndef GET_XBUTTON_WPARAM |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
59 #define GET_XBUTTON_WPARAM(w) (HIWORD(w)) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
60 #endif |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
61 |
3768 | 62 extern HCTX* g_hCtx; |
63 extern HANDLE* mice; | |
64 extern int total_mice; | |
3770
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
65 extern int tablet; |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
66 |
3768 | 67 int pressure=0; |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
68 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
69 static WPARAM |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
70 RemapVKEY(WPARAM wParam, LPARAM lParam) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
71 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
72 int i; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
73 BYTE scancode = (BYTE) ((lParam >> 16) & 0xFF); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
74 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
75 /* Windows remaps alphabetic keys based on current layout. |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
76 We try to provide USB scancodes, so undo this mapping. |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
77 */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
78 if (wParam >= 'A' && wParam <= 'Z') { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
79 if (scancode != alpha_scancodes[wParam - 'A']) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
80 for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
81 if (scancode == alpha_scancodes[i]) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
82 wParam = 'A' + i; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
83 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
84 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
85 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
86 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
87 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
88 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
89 /* Keypad keys are a little trickier, we always scan for them. */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
90 for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
91 if (scancode == keypad_scancodes[i]) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
92 wParam = VK_NUMPAD0 + i; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
93 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
94 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
95 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
96 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
97 return wParam; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
98 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
99 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
100 LRESULT CALLBACK |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
101 WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
102 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
103 SDL_WindowData *data; |
3768 | 104 RAWINPUT* raw; |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
105 PACKET packet; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
106 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
107 /* Send a SDL_SYSWMEVENT if the application wants them */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
108 if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
109 SDL_SysWMmsg wmmsg; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
110 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
111 SDL_VERSION(&wmmsg.version); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
112 wmmsg.hwnd = hwnd; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
113 wmmsg.msg = msg; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
114 wmmsg.wParam = wParam; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
115 wmmsg.lParam = lParam; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
116 SDL_SendSysWMEvent(&wmmsg); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
117 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
118 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
119 /* Get the window data for the window */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
120 data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData")); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
121 if (!data) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
122 return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
123 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
124 #ifdef WMMSG_DEBUG |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
125 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
126 FILE *log = fopen("wmmsg.txt", "a"); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
127 fprintf(log, "Received windows message: %p ", hwnd); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
128 if (msg > MAX_WMMSG) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
129 fprintf(log, "%d", msg); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
130 } else { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
131 fprintf(log, "%s", wmtab[msg]); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
132 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
133 fprintf(log, " -- 0x%X, 0x%X\n", wParam, lParam); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
134 fclose(log); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
135 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
136 #endif |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
137 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
138 switch (msg) { |
3768 | 139 case WT_PACKET: |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
140 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
141 if (WTPacket((HCTX)lParam, wParam, &packet)) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
142 { |
3768 | 143 pressure=(int)packet.pkNormalPressure; |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
144 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
145 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
146 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
147 case WT_PROXIMITY: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
148 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
149 int h_context=LOWORD(lParam); |
3770
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
150 LPPOINT point; |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
151 GetCursorPos(&point); |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
152 ScreenToClient(hwnd, &point); |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
153 if(h_context==0) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
154 { |
3770
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
155 SDL_SendProximity(tablet, (int)(&point->x),(int)(&point->y), SDL_PROXIMITYOUT); |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
156 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
157 else |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
158 { |
3770
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
159 SDL_SendProximity(tablet, (int)(&point->x),(int)(&point->y), SDL_PROXIMITYIN); |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
160 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
161 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
162 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
163 case WM_SHOWWINDOW: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
164 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
165 if (wParam) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
166 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, 0, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
167 0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
168 } else { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
169 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_HIDDEN, 0, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
170 0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
171 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
172 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
173 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
174 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
175 case WM_ACTIVATE: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
176 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
177 int index; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
178 SDL_Keyboard *keyboard; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
179 BOOL minimized; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
180 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
181 minimized = HIWORD(wParam); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
182 index = data->videodata->keyboard; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
183 keyboard = SDL_GetKeyboard(index); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
184 if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
185 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
186 0, 0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
187 SDL_SendWindowEvent(data->windowID, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
188 SDL_WINDOWEVENT_RESTORED, 0, 0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
189 if (IsZoomed(hwnd)) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
190 SDL_SendWindowEvent(data->windowID, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
191 SDL_WINDOWEVENT_MAXIMIZED, 0, 0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
192 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
193 if (keyboard && keyboard->focus != data->windowID) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
194 SDL_SetKeyboardFocus(index, data->windowID); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
195 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
196 /* FIXME: Update keyboard state */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
197 } else { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
198 if (keyboard && keyboard->focus == data->windowID) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
199 SDL_SetKeyboardFocus(index, 0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
200 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
201 if (minimized) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
202 SDL_SendWindowEvent(data->windowID, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
203 SDL_WINDOWEVENT_MINIMIZED, 0, 0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
204 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
205 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
206 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
207 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
208 break; |
3768 | 209 case WM_INPUT: |
210 { | |
211 LPBYTE lpb; | |
212 int w, h; | |
213 const RAWINPUTHEADER *header; | |
214 int index; | |
215 int i; | |
216 int size=0; | |
217 SDL_Mouse *mouse; | |
218 const RAWMOUSE *raw_mouse=NULL; | |
219 LPPOINT point; | |
220 USHORT flags; | |
221 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, sizeof (RAWINPUTHEADER)); | |
222 lpb = SDL_malloc(size*sizeof(LPBYTE)); | |
223 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, sizeof (RAWINPUTHEADER)); | |
224 raw = (RAWINPUT *) lpb; | |
225 header = &raw->header; | |
226 flags=raw->data.mouse.usButtonFlags; | |
227 for(i=0;i<total_mice;++i) | |
228 { | |
229 if(mice[i]==header->hDevice) | |
230 { | |
231 index=i; | |
232 break; | |
233 } | |
234 } | |
235 mouse = SDL_GetMouse(index); | |
236 GetCursorPos(&point); | |
237 ScreenToClient(hwnd, &point); | |
238 SDL_GetWindowSize(data->windowID, &w, &h); | |
239 SDL_UpdateCoordinates(w,h); | |
3770
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
240 if(i==tablet) |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
241 { |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
242 SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),pressure); |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
243 } |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
244 else |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
245 { |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
246 SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),0); |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
247 } |
3768 | 248 if(flags & RI_MOUSE_BUTTON_1_DOWN) |
249 { | |
250 SDL_SendMouseButton(index,SDL_PRESSED,SDL_BUTTON_LEFT); | |
251 } | |
252 else if(flags & RI_MOUSE_BUTTON_1_UP) | |
253 { | |
254 SDL_SendMouseButton(index,SDL_RELEASED,SDL_BUTTON_LEFT); | |
255 } | |
256 if(flags & RI_MOUSE_BUTTON_2_DOWN) | |
257 { | |
258 SDL_SendMouseButton(index,SDL_PRESSED,SDL_BUTTON_MIDDLE); | |
259 } | |
260 else if(flags & RI_MOUSE_BUTTON_2_UP) | |
261 { | |
262 SDL_SendMouseButton(index,SDL_RELEASED,SDL_BUTTON_MIDDLE); | |
263 } | |
264 if(flags & RI_MOUSE_BUTTON_3_DOWN) | |
265 { | |
266 SDL_SendMouseButton(index,SDL_PRESSED,SDL_BUTTON_RIGHT); | |
267 } | |
268 else if(flags & RI_MOUSE_BUTTON_3_UP) | |
269 { | |
270 SDL_SendMouseButton(index,SDL_RELEASED,SDL_BUTTON_RIGHT); | |
271 } | |
3770
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
272 if(flags & RI_MOUSE_WHEEL) |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
273 { |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
274 if(raw->data.mouse.usButtonData!=0) |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
275 { |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
276 SDL_SendMouseWheel(index, 0, raw->data.mouse.usButtonData); |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
277 } |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
278 } |
3768 | 279 } |
280 return(0); | |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
281 case WM_MOUSELEAVE: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
282 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
283 int index; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
284 SDL_Mouse *mouse; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
285 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
286 index = data->videodata->mouse; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
287 mouse = SDL_GetMouse(index); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
288 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
289 if (mouse->focus == data->windowID) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
290 SDL_SetMouseFocus(index, 0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
291 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
292 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
293 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
294 case WM_SYSKEYDOWN: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
295 case WM_KEYDOWN: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
296 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
297 int index; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
298 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
299 /* Ignore repeated keys */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
300 if (lParam & REPEATED_KEYMASK) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
301 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
302 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
303 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
304 index = data->videodata->keyboard; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
305 wParam = RemapVKEY(wParam, lParam); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
306 switch (wParam) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
307 case VK_CONTROL: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
308 if (lParam & EXTENDED_KEYMASK) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
309 wParam = VK_RCONTROL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
310 else |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
311 wParam = VK_LCONTROL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
312 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
313 case VK_SHIFT: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
314 /* EXTENDED trick doesn't work here */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
315 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
316 Uint8 *state = SDL_GetKeyboardState(NULL); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
317 if (state[SDL_SCANCODE_LSHIFT] == SDL_RELEASED |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
318 && (GetKeyState(VK_LSHIFT) & 0x8000)) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
319 wParam = VK_LSHIFT; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
320 } else if (state[SDL_SCANCODE_RSHIFT] == SDL_RELEASED |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
321 && (GetKeyState(VK_RSHIFT) & 0x8000)) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
322 wParam = VK_RSHIFT; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
323 } else { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
324 /* Probably a key repeat */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
325 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
326 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
327 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
328 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
329 case VK_MENU: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
330 if (lParam & EXTENDED_KEYMASK) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
331 wParam = VK_RMENU; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
332 else |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
333 wParam = VK_LMENU; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
334 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
335 case VK_RETURN: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
336 if (lParam & EXTENDED_KEYMASK) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
337 wParam = VK_ENTER; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
338 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
339 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
340 if (wParam < 256) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
341 SDL_SendKeyboardKey(index, SDL_PRESSED, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
342 data->videodata->key_layout[wParam]); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
343 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
344 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
345 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
346 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
347 case WM_SYSKEYUP: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
348 case WM_KEYUP: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
349 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
350 int index; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
351 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
352 index = data->videodata->keyboard; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
353 wParam = RemapVKEY(wParam, lParam); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
354 switch (wParam) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
355 case VK_CONTROL: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
356 if (lParam & EXTENDED_KEYMASK) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
357 wParam = VK_RCONTROL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
358 else |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
359 wParam = VK_LCONTROL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
360 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
361 case VK_SHIFT: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
362 /* EXTENDED trick doesn't work here */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
363 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
364 Uint8 *state = SDL_GetKeyboardState(NULL); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
365 if (state[SDL_SCANCODE_LSHIFT] == SDL_PRESSED |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
366 && !(GetKeyState(VK_LSHIFT) & 0x8000)) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
367 wParam = VK_LSHIFT; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
368 } else if (state[SDL_SCANCODE_RSHIFT] == SDL_PRESSED |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
369 && !(GetKeyState(VK_RSHIFT) & 0x8000)) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
370 wParam = VK_RSHIFT; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
371 } else { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
372 /* Probably a key repeat */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
373 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
374 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
375 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
376 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
377 case VK_MENU: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
378 if (lParam & EXTENDED_KEYMASK) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
379 wParam = VK_RMENU; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
380 else |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
381 wParam = VK_LMENU; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
382 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
383 case VK_RETURN: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
384 if (lParam & EXTENDED_KEYMASK) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
385 wParam = VK_ENTER; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
386 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
387 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
388 /* Windows only reports keyup for print screen */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
389 if (wParam == VK_SNAPSHOT |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
390 && SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PRINTSCREEN] == |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
391 SDL_RELEASED) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
392 SDL_SendKeyboardKey(index, SDL_PRESSED, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
393 data->videodata->key_layout[wParam]); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
394 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
395 if (wParam < 256) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
396 SDL_SendKeyboardKey(index, SDL_RELEASED, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
397 data->videodata->key_layout[wParam]); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
398 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
399 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
400 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
401 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
402 case WM_CHAR: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
403 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
404 char text[4]; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
405 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
406 /* Convert to UTF-8 and send it on... */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
407 if (wParam <= 0x7F) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
408 text[0] = (char) wParam; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
409 text[1] = '\0'; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
410 } else if (wParam <= 0x7FF) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
411 text[0] = 0xC0 | (char) ((wParam >> 6) & 0x1F); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
412 text[1] = 0x80 | (char) (wParam & 0x3F); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
413 text[2] = '\0'; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
414 } else { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
415 text[0] = 0xE0 | (char) ((wParam >> 12) & 0x0F); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
416 text[1] = 0x80 | (char) ((wParam >> 6) & 0x3F); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
417 text[2] = 0x80 | (char) (wParam & 0x3F); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
418 text[3] = '\0'; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
419 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
420 SDL_SendKeyboardText(data->videodata->keyboard, text); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
421 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
422 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
423 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
424 case WM_INPUTLANGCHANGE: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
425 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
426 WIN_UpdateKeymap(data->videodata->keyboard); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
427 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
428 return (1); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
429 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
430 case WM_GETMINMAXINFO: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
431 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
432 MINMAXINFO *info; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
433 RECT size; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
434 int x, y; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
435 int w, h; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
436 int style; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
437 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
438 /* If we allow resizing, let the resize happen naturally */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
439 if (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_RESIZABLE) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
440 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
441 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
442 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
443 /* Get the current position of our window */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
444 GetWindowRect(hwnd, &size); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
445 x = size.left; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
446 y = size.top; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
447 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
448 /* Calculate current size of our window */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
449 SDL_GetWindowSize(data->windowID, &w, &h); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
450 size.top = 0; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
451 size.left = 0; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
452 size.bottom = h; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
453 size.right = w; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
454 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
455 /* DJM - according to the docs for GetMenu(), the |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
456 return value is undefined if hwnd is a child window. |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
457 Aparently it's too difficult for MS to check |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
458 inside their function, so I have to do it here. |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
459 */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
460 style = GetWindowLong(hwnd, GWL_STYLE); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
461 AdjustWindowRect(&size, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
462 style, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
463 style & WS_CHILDWINDOW ? FALSE : GetMenu(hwnd) != |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
464 NULL); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
465 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
466 w = size.right - size.left; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
467 h = size.bottom - size.top; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
468 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
469 /* Fix our size to the current size */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
470 info = (MINMAXINFO *) lParam; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
471 info->ptMaxSize.x = w; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
472 info->ptMaxSize.y = h; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
473 info->ptMaxPosition.x = x; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
474 info->ptMaxPosition.y = y; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
475 info->ptMinTrackSize.x = w; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
476 info->ptMinTrackSize.y = h; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
477 info->ptMaxTrackSize.x = w; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
478 info->ptMaxTrackSize.y = h; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
479 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
480 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
481 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
482 case WM_WINDOWPOSCHANGED: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
483 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
484 RECT rect; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
485 int x, y; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
486 int w, h; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
487 Uint32 window_flags; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
488 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
489 GetClientRect(hwnd, &rect); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
490 ClientToScreen(hwnd, (LPPOINT) & rect); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
491 ClientToScreen(hwnd, (LPPOINT) & rect + 1); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
492 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
493 window_flags = SDL_GetWindowFlags(data->windowID); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
494 if ((window_flags & SDL_WINDOW_INPUT_GRABBED) && |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
495 (window_flags & SDL_WINDOW_INPUT_FOCUS)) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
496 ClipCursor(&rect); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
497 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
498 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
499 x = rect.left; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
500 y = rect.top; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
501 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MOVED, x, y); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
502 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
503 w = rect.right - rect.left; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
504 h = rect.bottom - rect.top; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
505 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESIZED, w, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
506 h); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
507 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
508 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
509 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
510 case WM_SETCURSOR: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
511 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
512 /* |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
513 Uint16 hittest; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
514 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
515 hittest = LOWORD(lParam); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
516 if (hittest == HTCLIENT) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
517 SetCursor(SDL_hcursor); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
518 return (TRUE); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
519 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
520 */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
521 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
522 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
523 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
524 /* We are about to get palette focus! */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
525 case WM_QUERYNEWPALETTE: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
526 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
527 /* |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
528 WIN_RealizePalette(current_video); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
529 return (TRUE); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
530 */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
531 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
532 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
533 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
534 /* Another application changed the palette */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
535 case WM_PALETTECHANGED: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
536 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
537 /* |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
538 WIN_PaletteChanged(current_video, (HWND) wParam); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
539 */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
540 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
541 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
542 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
543 /* We were occluded, refresh our display */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
544 case WM_PAINT: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
545 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
546 RECT rect; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
547 if (GetUpdateRect(hwnd, &rect, FALSE)) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
548 ValidateRect(hwnd, &rect); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
549 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_EXPOSED, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
550 0, 0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
551 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
552 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
553 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
554 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
555 /* We'll do our own drawing, prevent flicker */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
556 case WM_ERASEBKGND: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
557 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
558 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
559 return (1); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
560 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
561 case WM_SYSCOMMAND: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
562 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
563 /* Don't start the screensaver or blank the monitor in fullscreen apps */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
564 if ((wParam & 0xFFF0) == SC_SCREENSAVE || |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
565 (wParam & 0xFFF0) == SC_MONITORPOWER) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
566 if (SDL_GetWindowFlags(data->windowID) & |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
567 SDL_WINDOW_FULLSCREEN) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
568 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
569 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
570 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
571 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
572 break; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
573 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
574 case WM_CLOSE: |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
575 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
576 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_CLOSE, 0, 0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
577 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
578 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
579 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
580 return CallWindowProc(data->wndproc, hwnd, msg, wParam, lParam); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
581 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
582 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
583 void |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
584 WIN_PumpEvents(_THIS) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
585 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
586 MSG msg; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
587 |
3768 | 588 while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) { |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
589 TranslateMessage(&msg); |
3768 | 590 DispatchMessageA(&msg); |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
591 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
592 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
593 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
594 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
595 static int app_registered = 0; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
596 LPTSTR SDL_Appname = NULL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
597 Uint32 SDL_Appstyle = 0; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
598 HINSTANCE SDL_Instance = NULL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
599 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
600 /* Register the class for this application */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
601 int |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
602 SDL_RegisterApp(char *name, Uint32 style, void *hInst) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
603 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
604 WNDCLASS class; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
605 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
606 /* Only do this once... */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
607 if (app_registered) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
608 ++app_registered; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
609 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
610 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
611 if (!name && !SDL_Appname) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
612 name = "SDL_app"; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
613 SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
614 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
615 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
616 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
617 if (name) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
618 SDL_Appname = WIN_UTF8ToString(name); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
619 SDL_Appstyle = style; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
620 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
621 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
622 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
623 /* Register the application class */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
624 class.hCursor = NULL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
625 class.hIcon = LoadImage(SDL_Instance, SDL_Appname, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
626 IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
627 class.lpszMenuName = NULL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
628 class.lpszClassName = SDL_Appname; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
629 class.hbrBackground = NULL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
630 class.hInstance = SDL_Instance; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
631 class.style = SDL_Appstyle; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
632 class.lpfnWndProc = DefWindowProc; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
633 class.cbWndExtra = 0; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
634 class.cbClsExtra = 0; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
635 if (!RegisterClass(&class)) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
636 SDL_SetError("Couldn't register application class"); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
637 return (-1); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
638 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
639 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
640 app_registered = 1; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
641 return (0); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
642 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
643 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
644 /* Unregisters the windowclass registered in SDL_RegisterApp above. */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
645 void |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
646 SDL_UnregisterApp() |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
647 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
648 WNDCLASS class; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
649 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
650 /* SDL_RegisterApp might not have been called before */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
651 if (!app_registered) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
652 return; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
653 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
654 --app_registered; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
655 if (app_registered == 0) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
656 /* Check for any registered window classes. */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
657 if (GetClassInfo(SDL_Instance, SDL_Appname, &class)) { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
658 UnregisterClass(SDL_Appname, SDL_Instance); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
659 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
660 SDL_free(SDL_Appname); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
661 SDL_Appname = NULL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
662 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
663 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
664 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
665 /* Sets an error message based on GetLastError() */ |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
666 void |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
667 WIN_SetError(const char *prefix) |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
668 { |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
669 TCHAR buffer[1024]; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
670 char *message; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
671 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
672 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
673 NULL, |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
674 GetLastError(), 0, buffer, SDL_arraysize(buffer), NULL); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
675 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
676 message = WIN_StringToUTF8(buffer); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
677 SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ":" : "", message); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
678 SDL_free(message); |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
679 } |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
680 |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
2324
diff
changeset
|
681 /* vi: set ts=4 sw=4 expandtab: */ |
3770
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3768
diff
changeset
|
682 |