aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.cpp
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.cpp
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to '')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.cpp1736
1 files changed, 868 insertions, 868 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.cpp
index 7fa2c27..35c38e6 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.cpp
@@ -1,868 +1,868 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt 1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine". 2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h
4 4
5#include "IrrCompileConfig.h" 5#include "IrrCompileConfig.h"
6 6
7#ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ 7#ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
8 8
9#include "CIrrDeviceWinCE.h" 9#include "CIrrDeviceWinCE.h"
10#include "IEventReceiver.h" 10#include "IEventReceiver.h"
11#include "irrList.h" 11#include "irrList.h"
12#include "os.h" 12#include "os.h"
13 13
14#include "CTimer.h" 14#include "CTimer.h"
15#include "irrString.h" 15#include "irrString.h"
16#include "COSOperator.h" 16#include "COSOperator.h"
17#include "dimension2d.h" 17#include "dimension2d.h"
18#include <winuser.h> 18#include <winuser.h>
19#include "irrlicht.h" 19#include "irrlicht.h"
20 20
21#ifdef _MSC_VER 21#ifdef _MSC_VER
22 #pragma comment (lib, "aygshell.lib") 22 #pragma comment (lib, "aygshell.lib")
23#endif 23#endif
24 24
25 25
26namespace irr 26namespace irr
27{ 27{
28 namespace video 28 namespace video
29 { 29 {
30 #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ 30 #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
31 IVideoDriver* createDirectX8Driver(const irr::SIrrlichtCreationParameters& params, 31 IVideoDriver* createDirectX8Driver(const irr::SIrrlichtCreationParameters& params,
32 io::IFileSystem* io, HWND window); 32 io::IFileSystem* io, HWND window);
33 #endif 33 #endif
34 34
35 #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ 35 #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
36 IVideoDriver* createDirectX9Driver(const irr::SIrrlichtCreationParameters& params, 36 IVideoDriver* createDirectX9Driver(const irr::SIrrlichtCreationParameters& params,
37 io::IFileSystem* io, HWND window); 37 io::IFileSystem* io, HWND window);
38 #endif 38 #endif
39 39
40 #ifdef _IRR_COMPILE_WITH_OPENGL_ 40 #ifdef _IRR_COMPILE_WITH_OPENGL_
41 IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, this); 41 IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, this);
42 #endif 42 #endif
43 } 43 }
44} // end namespace irr 44} // end namespace irr
45 45
46 46
47 47
48struct SEnvMapper 48struct SEnvMapper
49{ 49{
50 HWND hWnd; 50 HWND hWnd;
51 irr::CIrrDeviceWinCE* irrDev; 51 irr::CIrrDeviceWinCE* irrDev;
52}; 52};
53 53
54irr::core::list<SEnvMapper> EnvMap; 54irr::core::list<SEnvMapper> EnvMap;
55 55
56SEnvMapper* getEnvMapperFromHWnd(HWND hWnd) 56SEnvMapper* getEnvMapperFromHWnd(HWND hWnd)
57{ 57{
58 irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin(); 58 irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin();
59 for (; it!= EnvMap.end(); ++it) 59 for (; it!= EnvMap.end(); ++it)
60 if ((*it).hWnd == hWnd) 60 if ((*it).hWnd == hWnd)
61 return &(*it); 61 return &(*it);
62 62
63 return 0; 63 return 0;
64} 64}
65 65
66irr::CIrrDeviceWinCE* getDeviceFromHWnd(HWND hWnd) 66irr::CIrrDeviceWinCE* getDeviceFromHWnd(HWND hWnd)
67{ 67{
68 irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin(); 68 irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin();
69 for (; it!= EnvMap.end(); ++it) 69 for (; it!= EnvMap.end(); ++it)
70 if ((*it).hWnd == hWnd) 70 if ((*it).hWnd == hWnd)
71 return (*it).irrDev; 71 return (*it).irrDev;
72 72
73 return 0; 73 return 0;
74} 74}
75 75
76 76
77LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 77LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
78{ 78{
79 #ifndef WM_MOUSEWHEEL 79 #ifndef WM_MOUSEWHEEL
80 #define WM_MOUSEWHEEL 0x020A 80 #define WM_MOUSEWHEEL 0x020A
81 #endif 81 #endif
82 #ifndef WHEEL_DELTA 82 #ifndef WHEEL_DELTA
83 #define WHEEL_DELTA 120 83 #define WHEEL_DELTA 120
84 #endif 84 #endif
85 85
86 irr::CIrrDeviceWinCE* dev = 0; 86 irr::CIrrDeviceWinCE* dev = 0;
87 irr::SEvent event; 87 irr::SEvent event;
88 SEnvMapper* envm = 0; 88 SEnvMapper* envm = 0;
89 89
90 //BYTE allKeys[256]; 90 //BYTE allKeys[256];
91 91
92 static irr::s32 ClickCount=0; 92 static irr::s32 ClickCount=0;
93 if (GetCapture() != hWnd && ClickCount > 0) 93 if (GetCapture() != hWnd && ClickCount > 0)
94 ClickCount = 0; 94 ClickCount = 0;
95 95
96 switch (message) 96 switch (message)
97 { 97 {
98 case WM_PAINT: 98 case WM_PAINT:
99 { 99 {
100 PAINTSTRUCT ps; 100 PAINTSTRUCT ps;
101 BeginPaint(hWnd, &ps); 101 BeginPaint(hWnd, &ps);
102 EndPaint(hWnd, &ps); 102 EndPaint(hWnd, &ps);
103 } 103 }
104 return 0; 104 return 0;
105 105
106 case WM_ERASEBKGND: 106 case WM_ERASEBKGND:
107 return 0; 107 return 0;
108 108
109 case WM_SETCURSOR: 109 case WM_SETCURSOR:
110 envm = getEnvMapperFromHWnd(hWnd); 110 envm = getEnvMapperFromHWnd(hWnd);
111 if (envm && !envm->irrDev->getWin32CursorControl()->isVisible()) 111 if (envm && !envm->irrDev->getWin32CursorControl()->isVisible())
112 { 112 {
113 SetCursor(NULL); 113 SetCursor(NULL);
114 return 0; 114 return 0;
115 } 115 }
116 break; 116 break;
117 117
118 case WM_MOUSEWHEEL: 118 case WM_MOUSEWHEEL:
119 event.EventType = irr::EET_MOUSE_INPUT_EVENT; 119 event.EventType = irr::EET_MOUSE_INPUT_EVENT;
120 event.MouseInput.Wheel = ((irr::f32)((short)HIWORD(wParam))) / (irr::f32)WHEEL_DELTA; 120 event.MouseInput.Wheel = ((irr::f32)((short)HIWORD(wParam))) / (irr::f32)WHEEL_DELTA;
121 event.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; 121 event.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
122 122
123 POINT p; // fixed by jox 123 POINT p; // fixed by jox
124 p.x = 0; p.y = 0; 124 p.x = 0; p.y = 0;
125 ClientToScreen(hWnd, &p); 125 ClientToScreen(hWnd, &p);
126 event.MouseInput.X = LOWORD(lParam) - p.x; 126 event.MouseInput.X = LOWORD(lParam) - p.x;
127 event.MouseInput.Y = HIWORD(lParam) - p.y; 127 event.MouseInput.Y = HIWORD(lParam) - p.y;
128 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); 128 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0);
129 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); 129 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0);
130 // left and right mouse buttons 130 // left and right mouse buttons
131 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); 131 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON);
132 // middle and extra buttons 132 // middle and extra buttons
133 if (wParam & MK_MBUTTON) 133 if (wParam & MK_MBUTTON)
134 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; 134 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE;
135 135
136 dev = getDeviceFromHWnd(hWnd); 136 dev = getDeviceFromHWnd(hWnd);
137 if (dev) 137 if (dev)
138 dev->postEventFromUser(event); 138 dev->postEventFromUser(event);
139 break; 139 break;
140 140
141 case WM_LBUTTONDOWN: 141 case WM_LBUTTONDOWN:
142 ClickCount++; 142 ClickCount++;
143 SetCapture(hWnd); 143 SetCapture(hWnd);
144 event.EventType = irr::EET_MOUSE_INPUT_EVENT; 144 event.EventType = irr::EET_MOUSE_INPUT_EVENT;
145 event.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; 145 event.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
146 event.MouseInput.X = (short)LOWORD(lParam); 146 event.MouseInput.X = (short)LOWORD(lParam);
147 event.MouseInput.Y = (short)HIWORD(lParam); 147 event.MouseInput.Y = (short)HIWORD(lParam);
148 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); 148 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0);
149 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); 149 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0);
150 // left and right mouse buttons 150 // left and right mouse buttons
151 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); 151 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON);
152 // middle and extra buttons 152 // middle and extra buttons
153 if (wParam & MK_MBUTTON) 153 if (wParam & MK_MBUTTON)
154 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; 154 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE;
155 155
156 dev = getDeviceFromHWnd(hWnd); 156 dev = getDeviceFromHWnd(hWnd);
157 if (dev) 157 if (dev)
158 dev->postEventFromUser(event); 158 dev->postEventFromUser(event);
159 return 0; 159 return 0;
160 160
161 case WM_LBUTTONUP: 161 case WM_LBUTTONUP:
162 ClickCount--; 162 ClickCount--;
163 if (ClickCount<1) 163 if (ClickCount<1)
164 { 164 {
165 ClickCount=0; 165 ClickCount=0;
166 ReleaseCapture(); 166 ReleaseCapture();
167 } 167 }
168 event.EventType = irr::EET_MOUSE_INPUT_EVENT; 168 event.EventType = irr::EET_MOUSE_INPUT_EVENT;
169 event.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; 169 event.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;
170 event.MouseInput.X = (short)LOWORD(lParam); 170 event.MouseInput.X = (short)LOWORD(lParam);
171 event.MouseInput.Y = (short)HIWORD(lParam); 171 event.MouseInput.Y = (short)HIWORD(lParam);
172 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); 172 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0);
173 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); 173 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0);
174 // left and right mouse buttons 174 // left and right mouse buttons
175 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); 175 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON);
176 // middle and extra buttons 176 // middle and extra buttons
177 if (wParam & MK_MBUTTON) 177 if (wParam & MK_MBUTTON)
178 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; 178 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE;
179 179
180 dev = getDeviceFromHWnd(hWnd); 180 dev = getDeviceFromHWnd(hWnd);
181 if (dev) 181 if (dev)
182 dev->postEventFromUser(event); 182 dev->postEventFromUser(event);
183 return 0; 183 return 0;
184 184
185 case WM_RBUTTONDOWN: 185 case WM_RBUTTONDOWN:
186 ClickCount++; 186 ClickCount++;
187 SetCapture(hWnd); 187 SetCapture(hWnd);
188 event.EventType = irr::EET_MOUSE_INPUT_EVENT; 188 event.EventType = irr::EET_MOUSE_INPUT_EVENT;
189 event.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; 189 event.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN;
190 event.MouseInput.X = (short)LOWORD(lParam); 190 event.MouseInput.X = (short)LOWORD(lParam);
191 event.MouseInput.Y = (short)HIWORD(lParam); 191 event.MouseInput.Y = (short)HIWORD(lParam);
192 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); 192 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0);
193 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); 193 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0);
194 // left and right mouse buttons 194 // left and right mouse buttons
195 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); 195 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON);
196 // middle and extra buttons 196 // middle and extra buttons
197 if (wParam & MK_MBUTTON) 197 if (wParam & MK_MBUTTON)
198 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; 198 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE;
199 199
200 dev = getDeviceFromHWnd(hWnd); 200 dev = getDeviceFromHWnd(hWnd);
201 if (dev) 201 if (dev)
202 dev->postEventFromUser(event); 202 dev->postEventFromUser(event);
203 return 0; 203 return 0;
204 204
205 case WM_RBUTTONUP: 205 case WM_RBUTTONUP:
206 ClickCount--; 206 ClickCount--;
207 if (ClickCount<1) 207 if (ClickCount<1)
208 { 208 {
209 ClickCount=0; 209 ClickCount=0;
210 ReleaseCapture(); 210 ReleaseCapture();
211 } 211 }
212 event.EventType = irr::EET_MOUSE_INPUT_EVENT; 212 event.EventType = irr::EET_MOUSE_INPUT_EVENT;
213 event.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP; 213 event.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP;
214 event.MouseInput.X = (short)LOWORD(lParam); 214 event.MouseInput.X = (short)LOWORD(lParam);
215 event.MouseInput.Y = (short)HIWORD(lParam); 215 event.MouseInput.Y = (short)HIWORD(lParam);
216 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); 216 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0);
217 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); 217 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0);
218 // left and right mouse buttons 218 // left and right mouse buttons
219 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); 219 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON);
220 // middle and extra buttons 220 // middle and extra buttons
221 if (wParam & MK_MBUTTON) 221 if (wParam & MK_MBUTTON)
222 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; 222 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE;
223 223
224 dev = getDeviceFromHWnd(hWnd); 224 dev = getDeviceFromHWnd(hWnd);
225 if (dev) 225 if (dev)
226 dev->postEventFromUser(event); 226 dev->postEventFromUser(event);
227 return 0; 227 return 0;
228 228
229 case WM_MBUTTONDOWN: 229 case WM_MBUTTONDOWN:
230 ClickCount++; 230 ClickCount++;
231 SetCapture(hWnd); 231 SetCapture(hWnd);
232 event.EventType = irr::EET_MOUSE_INPUT_EVENT; 232 event.EventType = irr::EET_MOUSE_INPUT_EVENT;
233 event.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN; 233 event.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN;
234 event.MouseInput.X = (short)LOWORD(lParam); 234 event.MouseInput.X = (short)LOWORD(lParam);
235 event.MouseInput.Y = (short)HIWORD(lParam); 235 event.MouseInput.Y = (short)HIWORD(lParam);
236 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); 236 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0);
237 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); 237 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0);
238 // left and right mouse buttons 238 // left and right mouse buttons
239 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); 239 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON);
240 // middle and extra buttons 240 // middle and extra buttons
241 if (wParam & MK_MBUTTON) 241 if (wParam & MK_MBUTTON)
242 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; 242 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE;
243 243
244 dev = getDeviceFromHWnd(hWnd); 244 dev = getDeviceFromHWnd(hWnd);
245 if (dev) 245 if (dev)
246 dev->postEventFromUser(event); 246 dev->postEventFromUser(event);
247 return 0; 247 return 0;
248 248
249 case WM_MBUTTONUP: 249 case WM_MBUTTONUP:
250 ClickCount--; 250 ClickCount--;
251 if (ClickCount<1) 251 if (ClickCount<1)
252 { 252 {
253 ClickCount=0; 253 ClickCount=0;
254 ReleaseCapture(); 254 ReleaseCapture();
255 } 255 }
256 event.EventType = irr::EET_MOUSE_INPUT_EVENT; 256 event.EventType = irr::EET_MOUSE_INPUT_EVENT;
257 event.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP; 257 event.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP;
258 event.MouseInput.X = (short)LOWORD(lParam); 258 event.MouseInput.X = (short)LOWORD(lParam);
259 event.MouseInput.Y = (short)HIWORD(lParam); 259 event.MouseInput.Y = (short)HIWORD(lParam);
260 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); 260 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0);
261 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); 261 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0);
262 // left and right mouse buttons 262 // left and right mouse buttons
263 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); 263 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON);
264 // middle and extra buttons 264 // middle and extra buttons
265 if (wParam & MK_MBUTTON) 265 if (wParam & MK_MBUTTON)
266 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; 266 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE;
267 267
268 dev = getDeviceFromHWnd(hWnd); 268 dev = getDeviceFromHWnd(hWnd);
269 if (dev) 269 if (dev)
270 dev->postEventFromUser(event); 270 dev->postEventFromUser(event);
271 return 0; 271 return 0;
272 272
273 case WM_MOUSEMOVE: 273 case WM_MOUSEMOVE:
274 event.EventType = irr::EET_MOUSE_INPUT_EVENT; 274 event.EventType = irr::EET_MOUSE_INPUT_EVENT;
275 event.MouseInput.Event = irr::EMIE_MOUSE_MOVED; 275 event.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
276 event.MouseInput.X = (short)LOWORD(lParam); 276 event.MouseInput.X = (short)LOWORD(lParam);
277 event.MouseInput.Y = (short)HIWORD(lParam); 277 event.MouseInput.Y = (short)HIWORD(lParam);
278 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); 278 event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0);
279 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); 279 event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0);
280 // left and right mouse buttons 280 // left and right mouse buttons
281 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); 281 event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON);
282 // middle and extra buttons 282 // middle and extra buttons
283 if (wParam & MK_MBUTTON) 283 if (wParam & MK_MBUTTON)
284 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; 284 event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE;
285 285
286 dev = getDeviceFromHWnd(hWnd); 286 dev = getDeviceFromHWnd(hWnd);
287 if (dev) 287 if (dev)
288 dev->postEventFromUser(event); 288 dev->postEventFromUser(event);
289 289
290 return 0; 290 return 0;
291 291
292 case WM_SYSKEYDOWN: 292 case WM_SYSKEYDOWN:
293 case WM_SYSKEYUP: 293 case WM_SYSKEYUP:
294 case WM_KEYDOWN: 294 case WM_KEYDOWN:
295 case WM_KEYUP: 295 case WM_KEYUP:
296 { 296 {
297 event.EventType = irr::EET_KEY_INPUT_EVENT; 297 event.EventType = irr::EET_KEY_INPUT_EVENT;
298 event.KeyInput.Key = (irr::EKEY_CODE)wParam; 298 event.KeyInput.Key = (irr::EKEY_CODE)wParam;
299 event.KeyInput.PressedDown = (message==WM_KEYDOWN || message == WM_SYSKEYDOWN); 299 event.KeyInput.PressedDown = (message==WM_KEYDOWN || message == WM_SYSKEYDOWN);
300 dev = getDeviceFromHWnd(hWnd); 300 dev = getDeviceFromHWnd(hWnd);
301/* 301/*
302 WORD KeyAsc=0; 302 WORD KeyAsc=0;
303 GetKeyboardState(allKeys); 303 GetKeyboardState(allKeys);
304 ToAscii(wParam,lParam,allKeys,&KeyAsc,0); 304 ToAscii(wParam,lParam,allKeys,&KeyAsc,0);
305*/ 305*/
306// event.KeyInput.Shift = ((allKeys[VK_SHIFT] & 0x80)!=0); 306// event.KeyInput.Shift = ((allKeys[VK_SHIFT] & 0x80)!=0);
307// event.KeyInput.Control = ((allKeys[VK_CONTROL] & 0x80)!=0); 307// event.KeyInput.Control = ((allKeys[VK_CONTROL] & 0x80)!=0);
308// event.KeyInput.Char = (KeyAsc & 0x00ff); //KeyAsc >= 0 ? KeyAsc : 0; 308// event.KeyInput.Char = (KeyAsc & 0x00ff); //KeyAsc >= 0 ? KeyAsc : 0;
309 309
310 if (dev) 310 if (dev)
311 dev->postEventFromUser(event); 311 dev->postEventFromUser(event);
312 312
313 return 0; 313 return 0;
314 } 314 }
315 315
316 case WM_SIZE: 316 case WM_SIZE:
317 { 317 {
318 // resize 318 // resize
319 dev = getDeviceFromHWnd(hWnd); 319 dev = getDeviceFromHWnd(hWnd);
320 if (dev) 320 if (dev)
321 dev->OnResized(); 321 dev->OnResized();
322 } 322 }
323 return 0; 323 return 0;
324 324
325 case WM_DESTROY: 325 case WM_DESTROY:
326 PostQuitMessage(0); 326 PostQuitMessage(0);
327 return 0; 327 return 0;
328 328
329 } 329 }
330 330
331 return DefWindowProc(hWnd, message, wParam, lParam); 331 return DefWindowProc(hWnd, message, wParam, lParam);
332} 332}
333 333
334namespace irr 334namespace irr
335{ 335{
336 336
337//! constructor 337//! constructor
338CIrrDeviceWinCE::CIrrDeviceWinCE(const SIrrlichtCreationParameters& params) 338CIrrDeviceWinCE::CIrrDeviceWinCE(const SIrrlichtCreationParameters& params)
339: CIrrDeviceStub(params), HWnd(0), 339: CIrrDeviceStub(params), HWnd(0),
340 Win32CursorControl(0), ChangedToFullScreen(false), Resized(false), 340 Win32CursorControl(0), ChangedToFullScreen(false), Resized(false),
341 ExternalWindow(false) 341 ExternalWindow(false)
342{ 342{
343 #ifdef _DEBUG 343 #ifdef _DEBUG
344 setDebugName("CIrrDeviceWinCE"); 344 setDebugName("CIrrDeviceWinCE");
345 #endif 345 #endif
346 346
347 core::stringc winversion; 347 core::stringc winversion;
348 getWindowsVersion(winversion); 348 getWindowsVersion(winversion);
349 Operator = new COSOperator(winversion); 349 Operator = new COSOperator(winversion);
350 os::Printer::log(winversion.c_str(), ELL_INFORMATION); 350 os::Printer::log(winversion.c_str(), ELL_INFORMATION);
351 351
352 HINSTANCE hInstance = GetModuleHandle(0); 352 HINSTANCE hInstance = GetModuleHandle(0);
353 353
354 // create the window only if we do not use the null device 354 // create the window only if we do not use the null device
355 if (!CreationParams.WindowId && (CreationParams.DriverType != video::EDT_NULL)) 355 if (!CreationParams.WindowId && (CreationParams.DriverType != video::EDT_NULL))
356 { 356 {
357 const wchar_t* ClassName = L"CIrrDeviceWinCE"; 357 const wchar_t* ClassName = L"CIrrDeviceWinCE";
358 358
359 // Register Class 359 // Register Class
360 WNDCLASS wc; 360 WNDCLASS wc;
361 wc.style = CS_HREDRAW | CS_VREDRAW; 361 wc.style = CS_HREDRAW | CS_VREDRAW;
362 wc.lpfnWndProc = WndProc; 362 wc.lpfnWndProc = WndProc;
363 wc.cbClsExtra = 0; 363 wc.cbClsExtra = 0;
364 wc.cbWndExtra = 0; 364 wc.cbWndExtra = 0;
365 wc.hInstance = hInstance; 365 wc.hInstance = hInstance;
366 wc.hIcon = NULL; 366 wc.hIcon = NULL;
367 wc.hCursor = LoadCursor(NULL, IDC_ARROW); 367 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
368 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); 368 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
369 wc.lpszMenuName = 0; 369 wc.lpszMenuName = 0;
370 wc.lpszClassName = ClassName; 370 wc.lpszClassName = ClassName;
371 371
372 // if there is an icon, load it 372 // if there is an icon, load it
373 wc.hIcon = (HICON)LoadImageW(hInstance, L"irrlicht.ico", IMAGE_ICON, 0,0, 0); 373 wc.hIcon = (HICON)LoadImageW(hInstance, L"irrlicht.ico", IMAGE_ICON, 0,0, 0);
374 374
375 RegisterClass(&wc); 375 RegisterClass(&wc);
376 376
377 // calculate client size 377 // calculate client size
378 378
379 RECT clientSize; 379 RECT clientSize;
380 clientSize.top = 0; 380 clientSize.top = 0;
381 clientSize.left = 0; 381 clientSize.left = 0;
382 clientSize.right = CreationParams.WindowSize.Width; 382 clientSize.right = CreationParams.WindowSize.Width;
383 clientSize.bottom = CreationParams.WindowSize.Height; 383 clientSize.bottom = CreationParams.WindowSize.Height;
384 384
385 DWORD style = WS_POPUP; 385 DWORD style = WS_POPUP;
386 386
387 if (!CreationParams.Fullscreen) 387 if (!CreationParams.Fullscreen)
388 style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; 388 style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
389 389
390 AdjustWindowRectEx(&clientSize, style, FALSE, 0); 390 AdjustWindowRectEx(&clientSize, style, FALSE, 0);
391 391
392 const s32 realWidth = clientSize.right - clientSize.left; 392 const s32 realWidth = clientSize.right - clientSize.left;
393 const s32 realHeight = clientSize.bottom - clientSize.top; 393 const s32 realHeight = clientSize.bottom - clientSize.top;
394 394
395 const s32 windowLeft = core::s32_max ( 0, (GetSystemMetrics(SM_CXSCREEN) - realWidth) >> 1 ); 395 const s32 windowLeft = core::s32_max ( 0, (GetSystemMetrics(SM_CXSCREEN) - realWidth) >> 1 );
396 const s32 windowTop = core::s32_max ( 0, (GetSystemMetrics(SM_CYSCREEN) - realHeight) >> 1 ); 396 const s32 windowTop = core::s32_max ( 0, (GetSystemMetrics(SM_CYSCREEN) - realHeight) >> 1 );
397 397
398 // create window 398 // create window
399 399
400 HWnd = CreateWindowW( ClassName, L"", style, windowLeft, windowTop, 400 HWnd = CreateWindowW( ClassName, L"", style, windowLeft, windowTop,
401 realWidth, realHeight, NULL, NULL, hInstance, NULL); 401 realWidth, realHeight, NULL, NULL, hInstance, NULL);
402 402
403 ShowWindow(HWnd , SW_SHOW); 403 ShowWindow(HWnd , SW_SHOW);
404 UpdateWindow(HWnd); 404 UpdateWindow(HWnd);
405 405
406 // fix ugly ATI driver bugs. Thanks to ariaci 406 // fix ugly ATI driver bugs. Thanks to ariaci
407 MoveWindow(HWnd, windowLeft, windowTop, realWidth, realHeight, TRUE); 407 MoveWindow(HWnd, windowLeft, windowTop, realWidth, realHeight, TRUE);
408 } 408 }
409 else if (CreationParams.WindowId) 409 else if (CreationParams.WindowId)
410 { 410 {
411 // attach external window 411 // attach external window
412 HWnd = static_cast<HWND>(CreationParams.WindowId); 412 HWnd = static_cast<HWND>(CreationParams.WindowId);
413 RECT r; 413 RECT r;
414 GetWindowRect(HWnd, &r); 414 GetWindowRect(HWnd, &r);
415 CreationParams.WindowSize.Width = r.right - r.left; 415 CreationParams.WindowSize.Width = r.right - r.left;
416 CreationParams.WindowSize.Height = r.bottom - r.top; 416 CreationParams.WindowSize.Height = r.bottom - r.top;
417 CreationParams.Fullscreen = false; 417 CreationParams.Fullscreen = false;
418 ExternalWindow = true; 418 ExternalWindow = true;
419 } 419 }
420 420
421 // create cursor control 421 // create cursor control
422 422
423 Win32CursorControl = new CCursorControl(CreationParams.WindowSize, HWnd, CreationParams.Fullscreen); 423 Win32CursorControl = new CCursorControl(CreationParams.WindowSize, HWnd, CreationParams.Fullscreen);
424 CursorControl = Win32CursorControl; 424 CursorControl = Win32CursorControl;
425 425
426 // create driver 426 // create driver
427 427
428 createDriver(); 428 createDriver();
429 429
430 if (VideoDriver) 430 if (VideoDriver)
431 createGUIAndScene(); 431 createGUIAndScene();
432 432
433 // register environment 433 // register environment
434 434
435 SEnvMapper em; 435 SEnvMapper em;
436 em.irrDev = this; 436 em.irrDev = this;
437 em.hWnd = HWnd; 437 em.hWnd = HWnd;
438 EnvMap.push_back(em); 438 EnvMap.push_back(em);
439 439
440 // set this as active window 440 // set this as active window
441 SetActiveWindow(HWnd); 441 SetActiveWindow(HWnd);
442 SetForegroundWindow(HWnd); 442 SetForegroundWindow(HWnd);
443} 443}
444 444
445 445
446//! destructor 446//! destructor
447CIrrDeviceWinCE::~CIrrDeviceWinCE() 447CIrrDeviceWinCE::~CIrrDeviceWinCE()
448{ 448{
449 // unregister environment 449 // unregister environment
450 450
451 if (ChangedToFullScreen) 451 if (ChangedToFullScreen)
452 SHFullScreen(HWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON); 452 SHFullScreen(HWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
453 453
454 irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin(); 454 irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin();
455 for (; it!= EnvMap.end(); ++it) 455 for (; it!= EnvMap.end(); ++it)
456 if ((*it).hWnd == HWnd) 456 if ((*it).hWnd == HWnd)
457 { 457 {
458 EnvMap.erase(it); 458 EnvMap.erase(it);
459 break; 459 break;
460 } 460 }
461} 461}
462 462
463 463
464//! create the driver 464//! create the driver
465void CIrrDeviceWinCE::createDriver() 465void CIrrDeviceWinCE::createDriver()
466{ 466{
467 switch(CreationParams.DriverType) 467 switch(CreationParams.DriverType)
468 { 468 {
469 case video::EDT_DIRECT3D8: 469 case video::EDT_DIRECT3D8:
470 #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ 470 #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
471 VideoDriver = video::createDirectX8Driver(CreationParams, FileSystem, HWnd); 471 VideoDriver = video::createDirectX8Driver(CreationParams, FileSystem, HWnd);
472 if (!VideoDriver) 472 if (!VideoDriver)
473 { 473 {
474 os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR); 474 os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR);
475 } 475 }
476 #else 476 #else
477 os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR); 477 os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
478 #endif // _IRR_COMPILE_WITH_DIRECT3D_8_ 478 #endif // _IRR_COMPILE_WITH_DIRECT3D_8_
479 479
480 break; 480 break;
481 481
482 case video::EDT_DIRECT3D9: 482 case video::EDT_DIRECT3D9:
483 #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ 483 #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
484 VideoDriver = video::createDirectX9Driver(CreationParams, FileSystem, HWnd); 484 VideoDriver = video::createDirectX9Driver(CreationParams, FileSystem, HWnd);
485 if (!VideoDriver) 485 if (!VideoDriver)
486 { 486 {
487 os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR); 487 os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR);
488 } 488 }
489 #else 489 #else
490 os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR); 490 os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
491 #endif // _IRR_COMPILE_WITH_DIRECT3D_9_ 491 #endif // _IRR_COMPILE_WITH_DIRECT3D_9_
492 492
493 break; 493 break;
494 494
495 case video::EDT_OPENGL: 495 case video::EDT_OPENGL:
496 496
497 #ifdef _IRR_COMPILE_WITH_OPENGL_ 497 #ifdef _IRR_COMPILE_WITH_OPENGL_
498 if (CreationParams.Fullscreen) 498 if (CreationParams.Fullscreen)
499 switchToFullScreen(); 499 switchToFullScreen();
500 VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem); 500 VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem);
501 if (!VideoDriver) 501 if (!VideoDriver)
502 { 502 {
503 os::Printer::log("Could not create OpenGL driver.", ELL_ERROR); 503 os::Printer::log("Could not create OpenGL driver.", ELL_ERROR);
504 } 504 }
505 #else 505 #else
506 os::Printer::log("OpenGL driver was not compiled in.", ELL_ERROR); 506 os::Printer::log("OpenGL driver was not compiled in.", ELL_ERROR);
507 #endif 507 #endif
508 break; 508 break;
509 509
510 case video::EDT_SOFTWARE: 510 case video::EDT_SOFTWARE:
511 511
512 #ifdef _IRR_COMPILE_WITH_SOFTWARE_ 512 #ifdef _IRR_COMPILE_WITH_SOFTWARE_
513 if (CreationParams.Fullscreen) 513 if (CreationParams.Fullscreen)
514 switchToFullScreen(); 514 switchToFullScreen();
515 VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); 515 VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
516 #else 516 #else
517 os::Printer::log("Software driver was not compiled in.", ELL_ERROR); 517 os::Printer::log("Software driver was not compiled in.", ELL_ERROR);
518 #endif 518 #endif
519 519
520 break; 520 break;
521 521
522 case video::EDT_BURNINGSVIDEO: 522 case video::EDT_BURNINGSVIDEO:
523 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ 523 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
524 if (CreationParams.Fullscreen) 524 if (CreationParams.Fullscreen)
525 switchToFullScreen(); 525 switchToFullScreen();
526 VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this); 526 VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
527 #else 527 #else
528 os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR); 528 os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR);
529 #endif 529 #endif
530 break; 530 break;
531 531
532 case video::EDT_NULL: 532 case video::EDT_NULL:
533 // create null driver 533 // create null driver
534 VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); 534 VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
535 break; 535 break;
536 536
537 default: 537 default:
538 os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); 538 os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
539 break; 539 break;
540 } 540 }
541} 541}
542 542
543 543
544//! runs the device. Returns false if device wants to be deleted 544//! runs the device. Returns false if device wants to be deleted
545bool CIrrDeviceWinCE::run() 545bool CIrrDeviceWinCE::run()
546{ 546{
547 os::Timer::tick(); 547 os::Timer::tick();
548 548
549 MSG msg; 549 MSG msg;
550 550
551 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 551 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
552 { 552 {
553 TranslateMessage(&msg); 553 TranslateMessage(&msg);
554 554
555 if (ExternalWindow && msg.hwnd == HWnd) 555 if (ExternalWindow && msg.hwnd == HWnd)
556 WndProc(HWnd, msg.message, msg.wParam, msg.lParam); 556 WndProc(HWnd, msg.message, msg.wParam, msg.lParam);
557 else 557 else
558 DispatchMessage(&msg); 558 DispatchMessage(&msg);
559 559
560 if (msg.message == WM_QUIT) 560 if (msg.message == WM_QUIT)
561 Close = true; 561 Close = true;
562 } 562 }
563 563
564 if (!Close) 564 if (!Close)
565 resizeIfNecessary(); 565 resizeIfNecessary();
566 566
567 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; 567 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
568 return !Close; 568 return !Close;
569} 569}
570 570
571 571
572//! Pause the current process for the minimum time allowed only to allow other processes to execute 572//! Pause the current process for the minimum time allowed only to allow other processes to execute
573void CIrrDeviceWinCE::yield() 573void CIrrDeviceWinCE::yield()
574{ 574{
575 Sleep(1); 575 Sleep(1);
576} 576}
577 577
578 578
579//! Pause execution and let other processes to run for a specified amount of time. 579//! Pause execution and let other processes to run for a specified amount of time.
580void CIrrDeviceWinCE::sleep(u32 timeMs, bool pauseTimer) 580void CIrrDeviceWinCE::sleep(u32 timeMs, bool pauseTimer)
581{ 581{
582 const bool wasStopped = Timer ? Timer->isStopped() : true; 582 const bool wasStopped = Timer ? Timer->isStopped() : true;
583 if (pauseTimer && !wasStopped) 583 if (pauseTimer && !wasStopped)
584 Timer->stop(); 584 Timer->stop();
585 585
586 Sleep(timeMs); 586 Sleep(timeMs);
587 587
588 if (pauseTimer && !wasStopped) 588 if (pauseTimer && !wasStopped)
589 Timer->start(); 589 Timer->start();
590} 590}
591 591
592 592
593void CIrrDeviceWinCE::resizeIfNecessary() 593void CIrrDeviceWinCE::resizeIfNecessary()
594{ 594{
595 if (!Resized) 595 if (!Resized)
596 return; 596 return;
597 597
598 RECT r; 598 RECT r;
599 GetClientRect(HWnd, &r); 599 GetClientRect(HWnd, &r);
600 600
601 char tmp[255]; 601 char tmp[255];
602 602
603 if (r.right < 2 || r.bottom < 2) 603 if (r.right < 2 || r.bottom < 2)
604 { 604 {
605 sprintf(tmp, "Ignoring resize operation to (%ld %ld)", r.right, r.bottom); 605 sprintf(tmp, "Ignoring resize operation to (%ld %ld)", r.right, r.bottom);
606 os::Printer::log(tmp); 606 os::Printer::log(tmp);
607 } 607 }
608 else 608 else
609 { 609 {
610 sprintf(tmp, "Resizing window (%ld %ld)", r.right, r.bottom); 610 sprintf(tmp, "Resizing window (%ld %ld)", r.right, r.bottom);
611 os::Printer::log(tmp); 611 os::Printer::log(tmp);
612 612
613 getVideoDriver()->OnResize(irr::core::dimension2d<irr::u32>(r.right, r.bottom)); 613 getVideoDriver()->OnResize(irr::core::dimension2d<irr::u32>(r.right, r.bottom));
614 getWin32CursorControl()->OnResize(getVideoDriver()->getScreenSize()); 614 getWin32CursorControl()->OnResize(getVideoDriver()->getScreenSize());
615 } 615 }
616 616
617 Resized = false; 617 Resized = false;
618} 618}
619 619
620 620
621//! sets the caption of the window 621//! sets the caption of the window
622void CIrrDeviceWinCE::setWindowCaption(const wchar_t* text) 622void CIrrDeviceWinCE::setWindowCaption(const wchar_t* text)
623{ 623{
624 SetWindowTextW(HWnd, text); 624 SetWindowTextW(HWnd, text);
625} 625}
626 626
627 627
628#if !defined(BITMAPV4HEADER) 628#if !defined(BITMAPV4HEADER)
629typedef struct { 629typedef struct {
630 DWORD bV4Size; 630 DWORD bV4Size;
631 LONG bV4Width; 631 LONG bV4Width;
632 LONG bV4Height; 632 LONG bV4Height;
633 WORD bV4Planes; 633 WORD bV4Planes;
634 WORD bV4BitCount; 634 WORD bV4BitCount;
635 DWORD bV4V4Compression; 635 DWORD bV4V4Compression;
636 DWORD bV4SizeImage; 636 DWORD bV4SizeImage;
637 LONG bV4XPelsPerMeter; 637 LONG bV4XPelsPerMeter;
638 LONG bV4YPelsPerMeter; 638 LONG bV4YPelsPerMeter;
639 DWORD bV4ClrUsed; 639 DWORD bV4ClrUsed;
640 DWORD bV4ClrImportant; 640 DWORD bV4ClrImportant;
641 DWORD bV4RedMask; 641 DWORD bV4RedMask;
642 DWORD bV4GreenMask; 642 DWORD bV4GreenMask;
643 DWORD bV4BlueMask; 643 DWORD bV4BlueMask;
644 DWORD bV4AlphaMask; 644 DWORD bV4AlphaMask;
645 DWORD bV4CSType; 645 DWORD bV4CSType;
646 DWORD un[9]; 646 DWORD un[9];
647} BITMAPV4HEADER, *PBITMAPV4HEADER; 647} BITMAPV4HEADER, *PBITMAPV4HEADER;
648#endif 648#endif
649 649
650 650
651//! presents a surface in the client area 651//! presents a surface in the client area
652bool CIrrDeviceWinCE::present(video::IImage* image, void* windowId, core::rect<s32>* src) 652bool CIrrDeviceWinCE::present(video::IImage* image, void* windowId, core::rect<s32>* src)
653{ 653{
654 HWND hwnd = HWnd; 654 HWND hwnd = HWnd;
655 if ( windowId ) 655 if ( windowId )
656 hwnd = (HWND)windowId; 656 hwnd = (HWND)windowId;
657 657
658 HDC dc = GetDC(hwnd); 658 HDC dc = GetDC(hwnd);
659 659
660 if ( dc ) 660 if ( dc )
661 { 661 {
662 RECT rect; 662 RECT rect;
663 GetClientRect(hwnd, &rect); 663 GetClientRect(hwnd, &rect);
664 const void* memory = (const void *)image->lock(); 664 const void* memory = (const void *)image->lock();
665 665
666 BITMAPV4HEADER bi; 666 BITMAPV4HEADER bi;
667 memset (&bi, 0, sizeof(bi)); 667 memset (&bi, 0, sizeof(bi));
668 bi.bV4Size = sizeof(BITMAPINFOHEADER); 668 bi.bV4Size = sizeof(BITMAPINFOHEADER);
669 bi.bV4BitCount = image->getBitsPerPixel(); 669 bi.bV4BitCount = image->getBitsPerPixel();
670 bi.bV4Planes = 1; 670 bi.bV4Planes = 1;
671 bi.bV4Width = image->getDimension().Width; 671 bi.bV4Width = image->getDimension().Width;
672 bi.bV4Height = 0 - image->getDimension().Height; 672 bi.bV4Height = 0 - image->getDimension().Height;
673 bi.bV4V4Compression = BI_BITFIELDS; 673 bi.bV4V4Compression = BI_BITFIELDS;
674 bi.bV4AlphaMask = image->getAlphaMask (); 674 bi.bV4AlphaMask = image->getAlphaMask ();
675 bi.bV4RedMask = image->getRedMask (); 675 bi.bV4RedMask = image->getRedMask ();
676 bi.bV4GreenMask = image->getGreenMask(); 676 bi.bV4GreenMask = image->getGreenMask();
677 bi.bV4BlueMask = image->getBlueMask(); 677 bi.bV4BlueMask = image->getBlueMask();
678 678
679 int r = 0; 679 int r = 0;
680 if ( src ) 680 if ( src )
681 { 681 {
682 r = StretchDIBits(dc, 0,0, rect.right, rect.bottom, 682 r = StretchDIBits(dc, 0,0, rect.right, rect.bottom,
683 src->UpperLeftCorner.X, src->UpperLeftCorner.Y, 683 src->UpperLeftCorner.X, src->UpperLeftCorner.Y,
684 src->getWidth(), src->getHeight(), 684 src->getWidth(), src->getHeight(),
685 memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY); 685 memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY);
686 } 686 }
687 else 687 else
688 { 688 {
689 r = StretchDIBits(dc, 0,0, rect.right, rect.bottom, 689 r = StretchDIBits(dc, 0,0, rect.right, rect.bottom,
690 0, 0, image->getDimension().Width, image->getDimension().Height, 690 0, 0, image->getDimension().Width, image->getDimension().Height,
691 memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY); 691 memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY);
692 } 692 }
693 693
694 image->unlock(); 694 image->unlock();
695 695
696 ReleaseDC(hwnd, dc); 696 ReleaseDC(hwnd, dc);
697 } 697 }
698 return true; 698 return true;
699} 699}
700 700
701 701
702//! notifies the device that it should close itself 702//! notifies the device that it should close itself
703void CIrrDeviceWinCE::closeDevice() 703void CIrrDeviceWinCE::closeDevice()
704{ 704{
705 MSG msg; 705 MSG msg;
706 PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); 706 PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
707 PostQuitMessage(0); 707 PostQuitMessage(0);
708 PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); 708 PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
709 if (!ExternalWindow) 709 if (!ExternalWindow)
710 { 710 {
711 DestroyWindow(HWnd); 711 DestroyWindow(HWnd);
712 const fschar_t* ClassName = __TEXT("CIrrDeviceWin32"); 712 const fschar_t* ClassName = __TEXT("CIrrDeviceWin32");
713 HINSTANCE hInstance = GetModuleHandle(0); 713 HINSTANCE hInstance = GetModuleHandle(0);
714 UnregisterClass(ClassName, hInstance); 714 UnregisterClass(ClassName, hInstance);
715 } 715 }
716 Close=true; 716 Close=true;
717} 717}
718 718
719 719
720//! returns if window is active. if not, nothing need to be drawn 720//! returns if window is active. if not, nothing need to be drawn
721bool CIrrDeviceWinCE::isWindowActive() const 721bool CIrrDeviceWinCE::isWindowActive() const
722{ 722{
723 bool ret = (GetActiveWindow() == HWnd); 723 bool ret = (GetActiveWindow() == HWnd);
724 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; 724 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
725 return ret; 725 return ret;
726} 726}
727 727
728 728
729//! returns if window has focus 729//! returns if window has focus
730bool CIrrDeviceWinCE::isWindowFocused() const 730bool CIrrDeviceWinCE::isWindowFocused() const
731{ 731{
732 bool ret = (GetFocus() == HWnd); 732 bool ret = (GetFocus() == HWnd);
733 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; 733 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
734 return ret; 734 return ret;
735} 735}
736 736
737 737
738//! returns if window is minimized 738//! returns if window is minimized
739bool CIrrDeviceWinCE::isWindowMinimized() const 739bool CIrrDeviceWinCE::isWindowMinimized() const
740{ 740{
741#if 0 741#if 0
742 WINDOWPLACEMENT plc; 742 WINDOWPLACEMENT plc;
743 plc.length=sizeof(WINDOWPLACEMENT); 743 plc.length=sizeof(WINDOWPLACEMENT);
744 bool ret=false; 744 bool ret=false;
745 if (GetWindowPlacement(HWnd,&plc)) 745 if (GetWindowPlacement(HWnd,&plc))
746 ret=(plc.showCmd & SW_SHOWMINIMIZED); 746 ret=(plc.showCmd & SW_SHOWMINIMIZED);
747 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; 747 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
748 return ret; 748 return ret;
749#endif 749#endif
750 return false; 750 return false;
751} 751}
752 752
753 753
754//! switches to fullscreen 754//! switches to fullscreen
755bool CIrrDeviceWinCE::switchToFullScreen() 755bool CIrrDeviceWinCE::switchToFullScreen()
756{ 756{
757 ChangedToFullScreen = SHFullScreen(HWnd, SHFS_HIDESIPBUTTON | SHFS_HIDETASKBAR) != 0; 757 ChangedToFullScreen = SHFullScreen(HWnd, SHFS_HIDESIPBUTTON | SHFS_HIDETASKBAR) != 0;
758 return ChangedToFullScreen; 758 return ChangedToFullScreen;
759} 759}
760 760
761 761
762//! returns the win32 cursor control 762//! returns the win32 cursor control
763CIrrDeviceWinCE::CCursorControl* CIrrDeviceWinCE::getWin32CursorControl() 763CIrrDeviceWinCE::CCursorControl* CIrrDeviceWinCE::getWin32CursorControl()
764{ 764{
765 return Win32CursorControl; 765 return Win32CursorControl;
766} 766}
767 767
768 768
769//! Return pointer to a list with all video modes supported by the gfx adapter. 769//! Return pointer to a list with all video modes supported by the gfx adapter.
770/** \return Pointer to video modes list */ 770/** \return Pointer to video modes list */
771video::IVideoModeList* CIrrDeviceWinCE::getVideoModeList() 771video::IVideoModeList* CIrrDeviceWinCE::getVideoModeList()
772{ 772{
773 if (!VideoModeList.getVideoModeCount()) 773 if (!VideoModeList.getVideoModeCount())
774 { 774 {
775 // enumerate video modes. 775 // enumerate video modes.
776 DWORD i=0; 776 DWORD i=0;
777 DEVMODE mode; 777 DEVMODE mode;
778 memset(&mode, 0, sizeof(mode)); 778 memset(&mode, 0, sizeof(mode));
779 mode.dmSize = sizeof(mode); 779 mode.dmSize = sizeof(mode);
780 780
781 while (EnumDisplaySettings(NULL, i, &mode)) 781 while (EnumDisplaySettings(NULL, i, &mode))
782 { 782 {
783 VideoModeList.addMode(core::dimension2d<u32>(mode.dmPelsWidth, mode.dmPelsHeight), 783 VideoModeList.addMode(core::dimension2d<u32>(mode.dmPelsWidth, mode.dmPelsHeight),
784 mode.dmBitsPerPel); 784 mode.dmBitsPerPel);
785 785
786 ++i; 786 ++i;
787 } 787 }
788 788
789 if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode)) 789 if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode))
790 VideoModeList.setDesktop(mode.dmBitsPerPel, core::dimension2d<u32>(mode.dmPelsWidth, mode.dmPelsHeight)); 790 VideoModeList.setDesktop(mode.dmBitsPerPel, core::dimension2d<u32>(mode.dmPelsWidth, mode.dmPelsHeight));
791 } 791 }
792 792
793 return &VideoModeList; 793 return &VideoModeList;
794} 794}
795 795
796 796
797void CIrrDeviceWinCE::getWindowsVersion(core::stringc& out) 797void CIrrDeviceWinCE::getWindowsVersion(core::stringc& out)
798{ 798{
799 out = "WinCE"; 799 out = "WinCE";
800} 800}
801 801
802 802
803//! Notifies the device, that it has been resized 803//! Notifies the device, that it has been resized
804void CIrrDeviceWinCE::OnResized() 804void CIrrDeviceWinCE::OnResized()
805{ 805{
806 Resized = true; 806 Resized = true;
807} 807}
808 808
809 809
810//! Sets if the window should be resizable in windowed mode. 810//! Sets if the window should be resizable in windowed mode.
811void CIrrDeviceWinCE::setResizable(bool resize) 811void CIrrDeviceWinCE::setResizable(bool resize)
812{ 812{
813 if (ExternalWindow || !getVideoDriver() || CreationParams.Fullscreen) 813 if (ExternalWindow || !getVideoDriver() || CreationParams.Fullscreen)
814 return; 814 return;
815 815
816 LONG style = WS_POPUP; 816 LONG style = WS_POPUP;
817 817
818 if (!resize) 818 if (!resize)
819 style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; 819 style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
820 else 820 else
821 style = WS_THICKFRAME | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX; 821 style = WS_THICKFRAME | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX;
822 822
823 if (!SetWindowLong(HWnd, GWL_STYLE, style)) 823 if (!SetWindowLong(HWnd, GWL_STYLE, style))
824 os::Printer::log("Could not change window style."); 824 os::Printer::log("Could not change window style.");
825 825
826 RECT clientSize; 826 RECT clientSize;
827 clientSize.top = 0; 827 clientSize.top = 0;
828 clientSize.left = 0; 828 clientSize.left = 0;
829 clientSize.right = getVideoDriver()->getScreenSize().Width; 829 clientSize.right = getVideoDriver()->getScreenSize().Width;
830 clientSize.bottom = getVideoDriver()->getScreenSize().Height; 830 clientSize.bottom = getVideoDriver()->getScreenSize().Height;
831 831
832 AdjustWindowRectEx(&clientSize, style, FALSE, 0); 832 AdjustWindowRectEx(&clientSize, style, FALSE, 0);
833 833
834 const s32 realWidth = clientSize.right - clientSize.left; 834 const s32 realWidth = clientSize.right - clientSize.left;
835 const s32 realHeight = clientSize.bottom - clientSize.top; 835 const s32 realHeight = clientSize.bottom - clientSize.top;
836 836
837 const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; 837 const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
838 const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; 838 const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;
839 839
840 SetWindowPos(HWnd, HWND_TOP, windowLeft, windowTop, realWidth, realHeight, 840 SetWindowPos(HWnd, HWND_TOP, windowLeft, windowTop, realWidth, realHeight,
841 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_SHOWWINDOW); 841 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_SHOWWINDOW);
842} 842}
843 843
844 844
845//! Minimizes the window. 845//! Minimizes the window.
846void CIrrDeviceWinCE::minimizeWindow() 846void CIrrDeviceWinCE::minimizeWindow()
847{ 847{
848 // do nothing 848 // do nothing
849} 849}
850 850
851//! Maximize window 851//! Maximize window
852void CIrrDeviceWinCE::maximizeWindow() 852void CIrrDeviceWinCE::maximizeWindow()
853{ 853{
854 // do nothing 854 // do nothing
855} 855}
856 856
857 857
858//! Restore original window size 858//! Restore original window size
859void CIrrDeviceWinCE::restoreWindow() 859void CIrrDeviceWinCE::restoreWindow()
860{ 860{
861 // do nothing 861 // do nothing
862} 862}
863 863
864 864
865} // end namespace 865} // end namespace
866 866
867#endif // _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ 867#endif // _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
868 868