aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceSDL.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/CIrrDeviceSDL.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 'libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceSDL.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceSDL.cpp1946
1 files changed, 973 insertions, 973 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceSDL.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceSDL.cpp
index 68e07e2..8811d22 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceSDL.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceSDL.cpp
@@ -1,973 +1,973 @@
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_SDL_DEVICE_ 7#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
8 8
9#include "CIrrDeviceSDL.h" 9#include "CIrrDeviceSDL.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#include "CTimer.h" 13#include "CTimer.h"
14#include "irrString.h" 14#include "irrString.h"
15#include "Keycodes.h" 15#include "Keycodes.h"
16#include "COSOperator.h" 16#include "COSOperator.h"
17#include <stdio.h> 17#include <stdio.h>
18#include <stdlib.h> 18#include <stdlib.h>
19#include "SIrrCreationParameters.h" 19#include "SIrrCreationParameters.h"
20#include <SDL/SDL_syswm.h> 20#include <SDL/SDL_syswm.h>
21#include <SDL/SDL_video.h> 21#include <SDL/SDL_video.h>
22 22
23#ifdef _MSC_VER 23#ifdef _MSC_VER
24#pragma comment(lib, "SDL.lib") 24#pragma comment(lib, "SDL.lib")
25#endif // _MSC_VER 25#endif // _MSC_VER
26 26
27namespace irr 27namespace irr
28{ 28{
29 namespace video 29 namespace video
30 { 30 {
31 31
32 #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ 32 #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
33 IVideoDriver* createDirectX8Driver(const irr::SIrrlichtCreationParameters& params, 33 IVideoDriver* createDirectX8Driver(const irr::SIrrlichtCreationParameters& params,
34 io::IFileSystem* io, HWND window); 34 io::IFileSystem* io, HWND window);
35 #endif 35 #endif
36 36
37 #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ 37 #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
38 IVideoDriver* createDirectX9Driver(const irr::SIrrlichtCreationParameters& params, 38 IVideoDriver* createDirectX9Driver(const irr::SIrrlichtCreationParameters& params,
39 io::IFileSystem* io, HWND window); 39 io::IFileSystem* io, HWND window);
40 #endif 40 #endif
41 41
42 #ifdef _IRR_COMPILE_WITH_OPENGL_ 42 #ifdef _IRR_COMPILE_WITH_OPENGL_
43 IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, 43 IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
44 io::IFileSystem* io, CIrrDeviceSDL* device); 44 io::IFileSystem* io, CIrrDeviceSDL* device);
45 #endif 45 #endif
46 } // end namespace video 46 } // end namespace video
47 47
48} // end namespace irr 48} // end namespace irr
49 49
50 50
51namespace irr 51namespace irr
52{ 52{
53 53
54//! constructor 54//! constructor
55CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) 55CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
56 : CIrrDeviceStub(param), 56 : CIrrDeviceStub(param),
57 Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_ANYFORMAT), 57 Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_ANYFORMAT),
58 MouseX(0), MouseY(0), MouseButtonStates(0), 58 MouseX(0), MouseY(0), MouseButtonStates(0),
59 Width(param.WindowSize.Width), Height(param.WindowSize.Height), 59 Width(param.WindowSize.Width), Height(param.WindowSize.Height),
60 Resizable(false), WindowHasFocus(false), WindowMinimized(false) 60 Resizable(false), WindowHasFocus(false), WindowMinimized(false)
61{ 61{
62 #ifdef _DEBUG 62 #ifdef _DEBUG
63 setDebugName("CIrrDeviceSDL"); 63 setDebugName("CIrrDeviceSDL");
64 #endif 64 #endif
65 65
66 // Initialize SDL... Timer for sleep, video for the obvious, and 66 // Initialize SDL... Timer for sleep, video for the obvious, and
67 // noparachute prevents SDL from catching fatal errors. 67 // noparachute prevents SDL from catching fatal errors.
68 if (SDL_Init( SDL_INIT_TIMER|SDL_INIT_VIDEO| 68 if (SDL_Init( SDL_INIT_TIMER|SDL_INIT_VIDEO|
69#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) 69#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
70 SDL_INIT_JOYSTICK| 70 SDL_INIT_JOYSTICK|
71#endif 71#endif
72 SDL_INIT_NOPARACHUTE ) < 0) 72 SDL_INIT_NOPARACHUTE ) < 0)
73 { 73 {
74 os::Printer::log( "Unable to initialize SDL!", SDL_GetError()); 74 os::Printer::log( "Unable to initialize SDL!", SDL_GetError());
75 Close = true; 75 Close = true;
76 } 76 }
77 77
78#if defined(_IRR_WINDOWS_) 78#if defined(_IRR_WINDOWS_)
79 SDL_putenv("SDL_VIDEODRIVER=directx"); 79 SDL_putenv("SDL_VIDEODRIVER=directx");
80#elif defined(_IRR_OSX_PLATFORM_) 80#elif defined(_IRR_OSX_PLATFORM_)
81 SDL_putenv("SDL_VIDEODRIVER=Quartz"); 81 SDL_putenv("SDL_VIDEODRIVER=Quartz");
82#else 82#else
83 SDL_putenv("SDL_VIDEODRIVER=x11"); 83 SDL_putenv("SDL_VIDEODRIVER=x11");
84#endif 84#endif
85// SDL_putenv("SDL_WINDOWID="); 85// SDL_putenv("SDL_WINDOWID=");
86 86
87 SDL_VERSION(&Info.version); 87 SDL_VERSION(&Info.version);
88 88
89 SDL_GetWMInfo(&Info); 89 SDL_GetWMInfo(&Info);
90 core::stringc sdlversion = "SDL Version "; 90 core::stringc sdlversion = "SDL Version ";
91 sdlversion += Info.version.major; 91 sdlversion += Info.version.major;
92 sdlversion += "."; 92 sdlversion += ".";
93 sdlversion += Info.version.minor; 93 sdlversion += Info.version.minor;
94 sdlversion += "."; 94 sdlversion += ".";
95 sdlversion += Info.version.patch; 95 sdlversion += Info.version.patch;
96 96
97 Operator = new COSOperator(sdlversion); 97 Operator = new COSOperator(sdlversion);
98 os::Printer::log(sdlversion.c_str(), ELL_INFORMATION); 98 os::Printer::log(sdlversion.c_str(), ELL_INFORMATION);
99 99
100 // create keymap 100 // create keymap
101 createKeyMap(); 101 createKeyMap();
102 // enable key to character translation 102 // enable key to character translation
103 SDL_EnableUNICODE(1); 103 SDL_EnableUNICODE(1);
104 104
105 (void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 105 (void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
106 106
107 if ( CreationParams.Fullscreen ) 107 if ( CreationParams.Fullscreen )
108 SDL_Flags |= SDL_FULLSCREEN; 108 SDL_Flags |= SDL_FULLSCREEN;
109 if (CreationParams.DriverType == video::EDT_OPENGL) 109 if (CreationParams.DriverType == video::EDT_OPENGL)
110 SDL_Flags |= SDL_OPENGL; 110 SDL_Flags |= SDL_OPENGL;
111 else if (CreationParams.Doublebuffer) 111 else if (CreationParams.Doublebuffer)
112 SDL_Flags |= SDL_DOUBLEBUF; 112 SDL_Flags |= SDL_DOUBLEBUF;
113 // create window 113 // create window
114 if (CreationParams.DriverType != video::EDT_NULL) 114 if (CreationParams.DriverType != video::EDT_NULL)
115 { 115 {
116 // create the window, only if we do not use the null device 116 // create the window, only if we do not use the null device
117 createWindow(); 117 createWindow();
118 } 118 }
119 119
120 // create cursor control 120 // create cursor control
121 CursorControl = new CCursorControl(this); 121 CursorControl = new CCursorControl(this);
122 122
123 // create driver 123 // create driver
124 createDriver(); 124 createDriver();
125 125
126 if (VideoDriver) 126 if (VideoDriver)
127 createGUIAndScene(); 127 createGUIAndScene();
128} 128}
129 129
130 130
131//! destructor 131//! destructor
132CIrrDeviceSDL::~CIrrDeviceSDL() 132CIrrDeviceSDL::~CIrrDeviceSDL()
133{ 133{
134#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) 134#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
135 const u32 numJoysticks = Joysticks.size(); 135 const u32 numJoysticks = Joysticks.size();
136 for (u32 i=0; i<numJoysticks; ++i) 136 for (u32 i=0; i<numJoysticks; ++i)
137 SDL_JoystickClose(Joysticks[i]); 137 SDL_JoystickClose(Joysticks[i]);
138#endif 138#endif
139 SDL_Quit(); 139 SDL_Quit();
140} 140}
141 141
142 142
143bool CIrrDeviceSDL::createWindow() 143bool CIrrDeviceSDL::createWindow()
144{ 144{
145 if ( Close ) 145 if ( Close )
146 return false; 146 return false;
147 147
148 if (CreationParams.DriverType == video::EDT_OPENGL) 148 if (CreationParams.DriverType == video::EDT_OPENGL)
149 { 149 {
150 if (CreationParams.Bits==16) 150 if (CreationParams.Bits==16)
151 { 151 {
152 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 ); 152 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 );
153 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 ); 153 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 );
154 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 ); 154 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 );
155 SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0 ); 155 SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0 );
156 } 156 }
157 else 157 else
158 { 158 {
159 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); 159 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
160 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); 160 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
161 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); 161 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
162 SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?8:0 ); 162 SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?8:0 );
163 } 163 }
164 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits); 164 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);
165 if (CreationParams.Doublebuffer) 165 if (CreationParams.Doublebuffer)
166 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); 166 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
167 if (CreationParams.Stereobuffer) 167 if (CreationParams.Stereobuffer)
168 SDL_GL_SetAttribute( SDL_GL_STEREO, 1 ); 168 SDL_GL_SetAttribute( SDL_GL_STEREO, 1 );
169 if (CreationParams.AntiAlias>1) 169 if (CreationParams.AntiAlias>1)
170 { 170 {
171 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); 171 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
172 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias ); 172 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias );
173 } 173 }
174 if ( !Screen ) 174 if ( !Screen )
175 Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags ); 175 Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
176 if ( !Screen && CreationParams.AntiAlias>1) 176 if ( !Screen && CreationParams.AntiAlias>1)
177 { 177 {
178 while (--CreationParams.AntiAlias>1) 178 while (--CreationParams.AntiAlias>1)
179 { 179 {
180 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias ); 180 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias );
181 Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags ); 181 Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
182 if (Screen) 182 if (Screen)
183 break; 183 break;
184 } 184 }
185 if ( !Screen ) 185 if ( !Screen )
186 { 186 {
187 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 0 ); 187 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 0 );
188 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 0 ); 188 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 0 );
189 Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags ); 189 Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
190 if (Screen) 190 if (Screen)
191 os::Printer::log("AntiAliasing disabled due to lack of support!" ); 191 os::Printer::log("AntiAliasing disabled due to lack of support!" );
192 } 192 }
193 } 193 }
194 } 194 }
195 else if ( !Screen ) 195 else if ( !Screen )
196 Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags ); 196 Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
197 197
198 if ( !Screen && CreationParams.Doublebuffer) 198 if ( !Screen && CreationParams.Doublebuffer)
199 { 199 {
200 // Try single buffer 200 // Try single buffer
201 if (CreationParams.DriverType == video::EDT_OPENGL) 201 if (CreationParams.DriverType == video::EDT_OPENGL)
202 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); 202 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
203 SDL_Flags &= ~SDL_DOUBLEBUF; 203 SDL_Flags &= ~SDL_DOUBLEBUF;
204 Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags ); 204 Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
205 } 205 }
206 if ( !Screen ) 206 if ( !Screen )
207 { 207 {
208 os::Printer::log( "Could not initialize display!" ); 208 os::Printer::log( "Could not initialize display!" );
209 return false; 209 return false;
210 } 210 }
211 211
212 return true; 212 return true;
213} 213}
214 214
215 215
216//! create the driver 216//! create the driver
217void CIrrDeviceSDL::createDriver() 217void CIrrDeviceSDL::createDriver()
218{ 218{
219 switch(CreationParams.DriverType) 219 switch(CreationParams.DriverType)
220 { 220 {
221 case video::EDT_DIRECT3D8: 221 case video::EDT_DIRECT3D8:
222 #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ 222 #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
223 223
224 VideoDriver = video::createDirectX8Driver(CreationParams, FileSystem, HWnd); 224 VideoDriver = video::createDirectX8Driver(CreationParams, FileSystem, HWnd);
225 if (!VideoDriver) 225 if (!VideoDriver)
226 { 226 {
227 os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR); 227 os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR);
228 } 228 }
229 #else 229 #else
230 os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR); 230 os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
231 #endif // _IRR_COMPILE_WITH_DIRECT3D_8_ 231 #endif // _IRR_COMPILE_WITH_DIRECT3D_8_
232 232
233 break; 233 break;
234 234
235 case video::EDT_DIRECT3D9: 235 case video::EDT_DIRECT3D9:
236 #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ 236 #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
237 237
238 VideoDriver = video::createDirectX9Driver(CreationParams, FileSystem, HWnd); 238 VideoDriver = video::createDirectX9Driver(CreationParams, FileSystem, HWnd);
239 if (!VideoDriver) 239 if (!VideoDriver)
240 { 240 {
241 os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR); 241 os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR);
242 } 242 }
243 #else 243 #else
244 os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR); 244 os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
245 #endif // _IRR_COMPILE_WITH_DIRECT3D_9_ 245 #endif // _IRR_COMPILE_WITH_DIRECT3D_9_
246 246
247 break; 247 break;
248 248
249 case video::EDT_SOFTWARE: 249 case video::EDT_SOFTWARE:
250 #ifdef _IRR_COMPILE_WITH_SOFTWARE_ 250 #ifdef _IRR_COMPILE_WITH_SOFTWARE_
251 VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); 251 VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
252 #else 252 #else
253 os::Printer::log("No Software driver support compiled in.", ELL_ERROR); 253 os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
254 #endif 254 #endif
255 break; 255 break;
256 256
257 case video::EDT_BURNINGSVIDEO: 257 case video::EDT_BURNINGSVIDEO:
258 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ 258 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
259 VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this); 259 VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
260 #else 260 #else
261 os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR); 261 os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR);
262 #endif 262 #endif
263 break; 263 break;
264 264
265 case video::EDT_OPENGL: 265 case video::EDT_OPENGL:
266 #ifdef _IRR_COMPILE_WITH_OPENGL_ 266 #ifdef _IRR_COMPILE_WITH_OPENGL_
267 VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this); 267 VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this);
268 #else 268 #else
269 os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); 269 os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
270 #endif 270 #endif
271 break; 271 break;
272 272
273 case video::EDT_NULL: 273 case video::EDT_NULL:
274 VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); 274 VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
275 break; 275 break;
276 276
277 default: 277 default:
278 os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); 278 os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
279 break; 279 break;
280 } 280 }
281} 281}
282 282
283 283
284//! runs the device. Returns false if device wants to be deleted 284//! runs the device. Returns false if device wants to be deleted
285bool CIrrDeviceSDL::run() 285bool CIrrDeviceSDL::run()
286{ 286{
287 os::Timer::tick(); 287 os::Timer::tick();
288 288
289 SEvent irrevent; 289 SEvent irrevent;
290 SDL_Event SDL_event; 290 SDL_Event SDL_event;
291 291
292 while ( !Close && SDL_PollEvent( &SDL_event ) ) 292 while ( !Close && SDL_PollEvent( &SDL_event ) )
293 { 293 {
294 switch ( SDL_event.type ) 294 switch ( SDL_event.type )
295 { 295 {
296 case SDL_MOUSEMOTION: 296 case SDL_MOUSEMOTION:
297 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; 297 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
298 irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; 298 irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
299 MouseX = irrevent.MouseInput.X = SDL_event.motion.x; 299 MouseX = irrevent.MouseInput.X = SDL_event.motion.x;
300 MouseY = irrevent.MouseInput.Y = SDL_event.motion.y; 300 MouseY = irrevent.MouseInput.Y = SDL_event.motion.y;
301 irrevent.MouseInput.ButtonStates = MouseButtonStates; 301 irrevent.MouseInput.ButtonStates = MouseButtonStates;
302 302
303 postEventFromUser(irrevent); 303 postEventFromUser(irrevent);
304 break; 304 break;
305 305
306 case SDL_MOUSEBUTTONDOWN: 306 case SDL_MOUSEBUTTONDOWN:
307 case SDL_MOUSEBUTTONUP: 307 case SDL_MOUSEBUTTONUP:
308 308
309 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; 309 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
310 irrevent.MouseInput.X = SDL_event.button.x; 310 irrevent.MouseInput.X = SDL_event.button.x;
311 irrevent.MouseInput.Y = SDL_event.button.y; 311 irrevent.MouseInput.Y = SDL_event.button.y;
312 312
313 irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; 313 irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
314 314
315 switch(SDL_event.button.button) 315 switch(SDL_event.button.button)
316 { 316 {
317 case SDL_BUTTON_LEFT: 317 case SDL_BUTTON_LEFT:
318 if (SDL_event.type == SDL_MOUSEBUTTONDOWN) 318 if (SDL_event.type == SDL_MOUSEBUTTONDOWN)
319 { 319 {
320 irrevent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; 320 irrevent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
321 MouseButtonStates |= irr::EMBSM_LEFT; 321 MouseButtonStates |= irr::EMBSM_LEFT;
322 } 322 }
323 else 323 else
324 { 324 {
325 irrevent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; 325 irrevent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;
326 MouseButtonStates &= !irr::EMBSM_LEFT; 326 MouseButtonStates &= !irr::EMBSM_LEFT;
327 } 327 }
328 break; 328 break;
329 329
330 case SDL_BUTTON_RIGHT: 330 case SDL_BUTTON_RIGHT:
331 if (SDL_event.type == SDL_MOUSEBUTTONDOWN) 331 if (SDL_event.type == SDL_MOUSEBUTTONDOWN)
332 { 332 {
333 irrevent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; 333 irrevent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN;
334 MouseButtonStates |= irr::EMBSM_RIGHT; 334 MouseButtonStates |= irr::EMBSM_RIGHT;
335 } 335 }
336 else 336 else
337 { 337 {
338 irrevent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP; 338 irrevent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP;
339 MouseButtonStates &= !irr::EMBSM_RIGHT; 339 MouseButtonStates &= !irr::EMBSM_RIGHT;
340 } 340 }
341 break; 341 break;
342 342
343 case SDL_BUTTON_MIDDLE: 343 case SDL_BUTTON_MIDDLE:
344 if (SDL_event.type == SDL_MOUSEBUTTONDOWN) 344 if (SDL_event.type == SDL_MOUSEBUTTONDOWN)
345 { 345 {
346 irrevent.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN; 346 irrevent.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN;
347 MouseButtonStates |= irr::EMBSM_MIDDLE; 347 MouseButtonStates |= irr::EMBSM_MIDDLE;
348 } 348 }
349 else 349 else
350 { 350 {
351 irrevent.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP; 351 irrevent.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP;
352 MouseButtonStates &= !irr::EMBSM_MIDDLE; 352 MouseButtonStates &= !irr::EMBSM_MIDDLE;
353 } 353 }
354 break; 354 break;
355 355
356 case SDL_BUTTON_WHEELUP: 356 case SDL_BUTTON_WHEELUP:
357 irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; 357 irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
358 irrevent.MouseInput.Wheel = 1.0f; 358 irrevent.MouseInput.Wheel = 1.0f;
359 break; 359 break;
360 360
361 case SDL_BUTTON_WHEELDOWN: 361 case SDL_BUTTON_WHEELDOWN:
362 irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; 362 irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
363 irrevent.MouseInput.Wheel = -1.0f; 363 irrevent.MouseInput.Wheel = -1.0f;
364 break; 364 break;
365 } 365 }
366 366
367 irrevent.MouseInput.ButtonStates = MouseButtonStates; 367 irrevent.MouseInput.ButtonStates = MouseButtonStates;
368 368
369 if (irrevent.MouseInput.Event != irr::EMIE_MOUSE_MOVED) 369 if (irrevent.MouseInput.Event != irr::EMIE_MOUSE_MOVED)
370 { 370 {
371 postEventFromUser(irrevent); 371 postEventFromUser(irrevent);
372 372
373 if ( irrevent.MouseInput.Event >= EMIE_LMOUSE_PRESSED_DOWN && irrevent.MouseInput.Event <= EMIE_MMOUSE_PRESSED_DOWN ) 373 if ( irrevent.MouseInput.Event >= EMIE_LMOUSE_PRESSED_DOWN && irrevent.MouseInput.Event <= EMIE_MMOUSE_PRESSED_DOWN )
374 { 374 {
375 u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y, irrevent.MouseInput.Event); 375 u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y, irrevent.MouseInput.Event);
376 if ( clicks == 2 ) 376 if ( clicks == 2 )
377 { 377 {
378 irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_DOUBLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN); 378 irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_DOUBLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
379 postEventFromUser(irrevent); 379 postEventFromUser(irrevent);
380 } 380 }
381 else if ( clicks == 3 ) 381 else if ( clicks == 3 )
382 { 382 {
383 irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_TRIPLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN); 383 irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_TRIPLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
384 postEventFromUser(irrevent); 384 postEventFromUser(irrevent);
385 } 385 }
386 } 386 }
387 } 387 }
388 break; 388 break;
389 389
390 case SDL_KEYDOWN: 390 case SDL_KEYDOWN:
391 case SDL_KEYUP: 391 case SDL_KEYUP:
392 { 392 {
393 SKeyMap mp; 393 SKeyMap mp;
394 mp.SDLKey = SDL_event.key.keysym.sym; 394 mp.SDLKey = SDL_event.key.keysym.sym;
395 s32 idx = KeyMap.binary_search(mp); 395 s32 idx = KeyMap.binary_search(mp);
396 396
397 EKEY_CODE key; 397 EKEY_CODE key;
398 if (idx == -1) 398 if (idx == -1)
399 key = (EKEY_CODE)0; 399 key = (EKEY_CODE)0;
400 else 400 else
401 key = (EKEY_CODE)KeyMap[idx].Win32Key; 401 key = (EKEY_CODE)KeyMap[idx].Win32Key;
402 402
403#ifdef _IRR_WINDOWS_API_ 403#ifdef _IRR_WINDOWS_API_
404 // handle alt+f4 in Windows, because SDL seems not to 404 // handle alt+f4 in Windows, because SDL seems not to
405 if ( (SDL_event.key.keysym.mod & KMOD_LALT) && key == KEY_F4) 405 if ( (SDL_event.key.keysym.mod & KMOD_LALT) && key == KEY_F4)
406 { 406 {
407 Close = true; 407 Close = true;
408 break; 408 break;
409 } 409 }
410#endif 410#endif
411 irrevent.EventType = irr::EET_KEY_INPUT_EVENT; 411 irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
412 irrevent.KeyInput.Char = SDL_event.key.keysym.unicode; 412 irrevent.KeyInput.Char = SDL_event.key.keysym.unicode;
413 irrevent.KeyInput.Key = key; 413 irrevent.KeyInput.Key = key;
414 irrevent.KeyInput.PressedDown = (SDL_event.type == SDL_KEYDOWN); 414 irrevent.KeyInput.PressedDown = (SDL_event.type == SDL_KEYDOWN);
415 irrevent.KeyInput.Shift = (SDL_event.key.keysym.mod & KMOD_SHIFT) != 0; 415 irrevent.KeyInput.Shift = (SDL_event.key.keysym.mod & KMOD_SHIFT) != 0;
416 irrevent.KeyInput.Control = (SDL_event.key.keysym.mod & KMOD_CTRL ) != 0; 416 irrevent.KeyInput.Control = (SDL_event.key.keysym.mod & KMOD_CTRL ) != 0;
417 postEventFromUser(irrevent); 417 postEventFromUser(irrevent);
418 } 418 }
419 break; 419 break;
420 420
421 case SDL_QUIT: 421 case SDL_QUIT:
422 Close = true; 422 Close = true;
423 break; 423 break;
424 424
425 case SDL_ACTIVEEVENT: 425 case SDL_ACTIVEEVENT:
426 if ((SDL_event.active.state == SDL_APPMOUSEFOCUS) || 426 if ((SDL_event.active.state == SDL_APPMOUSEFOCUS) ||
427 (SDL_event.active.state == SDL_APPINPUTFOCUS)) 427 (SDL_event.active.state == SDL_APPINPUTFOCUS))
428 WindowHasFocus = (SDL_event.active.gain==1); 428 WindowHasFocus = (SDL_event.active.gain==1);
429 else 429 else
430 if (SDL_event.active.state == SDL_APPACTIVE) 430 if (SDL_event.active.state == SDL_APPACTIVE)
431 WindowMinimized = (SDL_event.active.gain!=1); 431 WindowMinimized = (SDL_event.active.gain!=1);
432 break; 432 break;
433 433
434 case SDL_VIDEORESIZE: 434 case SDL_VIDEORESIZE:
435 if ((SDL_event.resize.w != (int)Width) || (SDL_event.resize.h != (int)Height)) 435 if ((SDL_event.resize.w != (int)Width) || (SDL_event.resize.h != (int)Height))
436 { 436 {
437 Width = SDL_event.resize.w; 437 Width = SDL_event.resize.w;
438 Height = SDL_event.resize.h; 438 Height = SDL_event.resize.h;
439 Screen = SDL_SetVideoMode( Width, Height, 0, SDL_Flags ); 439 Screen = SDL_SetVideoMode( Width, Height, 0, SDL_Flags );
440 if (VideoDriver) 440 if (VideoDriver)
441 VideoDriver->OnResize(core::dimension2d<u32>(Width, Height)); 441 VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
442 } 442 }
443 break; 443 break;
444 444
445 case SDL_USEREVENT: 445 case SDL_USEREVENT:
446 irrevent.EventType = irr::EET_USER_EVENT; 446 irrevent.EventType = irr::EET_USER_EVENT;
447 irrevent.UserEvent.UserData1 = *(reinterpret_cast<s32*>(&SDL_event.user.data1)); 447 irrevent.UserEvent.UserData1 = *(reinterpret_cast<s32*>(&SDL_event.user.data1));
448 irrevent.UserEvent.UserData2 = *(reinterpret_cast<s32*>(&SDL_event.user.data2)); 448 irrevent.UserEvent.UserData2 = *(reinterpret_cast<s32*>(&SDL_event.user.data2));
449 449
450 postEventFromUser(irrevent); 450 postEventFromUser(irrevent);
451 break; 451 break;
452 452
453 default: 453 default:
454 break; 454 break;
455 } // end switch 455 } // end switch
456 456
457 } // end while 457 } // end while
458 458
459#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) 459#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
460 // TODO: Check if the multiple open/close calls are too expensive, then 460 // TODO: Check if the multiple open/close calls are too expensive, then
461 // open/close in the constructor/destructor instead 461 // open/close in the constructor/destructor instead
462 462
463 // update joystick states manually 463 // update joystick states manually
464 SDL_JoystickUpdate(); 464 SDL_JoystickUpdate();
465 // we'll always send joystick input events... 465 // we'll always send joystick input events...
466 SEvent joyevent; 466 SEvent joyevent;
467 joyevent.EventType = EET_JOYSTICK_INPUT_EVENT; 467 joyevent.EventType = EET_JOYSTICK_INPUT_EVENT;
468 for (u32 i=0; i<Joysticks.size(); ++i) 468 for (u32 i=0; i<Joysticks.size(); ++i)
469 { 469 {
470 SDL_Joystick* joystick = Joysticks[i]; 470 SDL_Joystick* joystick = Joysticks[i];
471 if (joystick) 471 if (joystick)
472 { 472 {
473 int j; 473 int j;
474 // query all buttons 474 // query all buttons
475 const int numButtons = core::min_(SDL_JoystickNumButtons(joystick), 32); 475 const int numButtons = core::min_(SDL_JoystickNumButtons(joystick), 32);
476 joyevent.JoystickEvent.ButtonStates=0; 476 joyevent.JoystickEvent.ButtonStates=0;
477 for (j=0; j<numButtons; ++j) 477 for (j=0; j<numButtons; ++j)
478 joyevent.JoystickEvent.ButtonStates |= (SDL_JoystickGetButton(joystick, j)<<j); 478 joyevent.JoystickEvent.ButtonStates |= (SDL_JoystickGetButton(joystick, j)<<j);
479 479
480 // query all axes, already in correct range 480 // query all axes, already in correct range
481 const int numAxes = core::min_(SDL_JoystickNumAxes(joystick), SEvent::SJoystickEvent::NUMBER_OF_AXES); 481 const int numAxes = core::min_(SDL_JoystickNumAxes(joystick), SEvent::SJoystickEvent::NUMBER_OF_AXES);
482 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X]=0; 482 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X]=0;
483 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y]=0; 483 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y]=0;
484 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z]=0; 484 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z]=0;
485 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_R]=0; 485 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_R]=0;
486 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_U]=0; 486 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_U]=0;
487 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_V]=0; 487 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_V]=0;
488 for (j=0; j<numAxes; ++j) 488 for (j=0; j<numAxes; ++j)
489 joyevent.JoystickEvent.Axis[j] = SDL_JoystickGetAxis(joystick, j); 489 joyevent.JoystickEvent.Axis[j] = SDL_JoystickGetAxis(joystick, j);
490 490
491 // we can only query one hat, SDL only supports 8 directions 491 // we can only query one hat, SDL only supports 8 directions
492 if (SDL_JoystickNumHats(joystick)>0) 492 if (SDL_JoystickNumHats(joystick)>0)
493 { 493 {
494 switch (SDL_JoystickGetHat(joystick, 0)) 494 switch (SDL_JoystickGetHat(joystick, 0))
495 { 495 {
496 case SDL_HAT_UP: 496 case SDL_HAT_UP:
497 joyevent.JoystickEvent.POV=0; 497 joyevent.JoystickEvent.POV=0;
498 break; 498 break;
499 case SDL_HAT_RIGHTUP: 499 case SDL_HAT_RIGHTUP:
500 joyevent.JoystickEvent.POV=4500; 500 joyevent.JoystickEvent.POV=4500;
501 break; 501 break;
502 case SDL_HAT_RIGHT: 502 case SDL_HAT_RIGHT:
503 joyevent.JoystickEvent.POV=9000; 503 joyevent.JoystickEvent.POV=9000;
504 break; 504 break;
505 case SDL_HAT_RIGHTDOWN: 505 case SDL_HAT_RIGHTDOWN:
506 joyevent.JoystickEvent.POV=13500; 506 joyevent.JoystickEvent.POV=13500;
507 break; 507 break;
508 case SDL_HAT_DOWN: 508 case SDL_HAT_DOWN:
509 joyevent.JoystickEvent.POV=18000; 509 joyevent.JoystickEvent.POV=18000;
510 break; 510 break;
511 case SDL_HAT_LEFTDOWN: 511 case SDL_HAT_LEFTDOWN:
512 joyevent.JoystickEvent.POV=22500; 512 joyevent.JoystickEvent.POV=22500;
513 break; 513 break;
514 case SDL_HAT_LEFT: 514 case SDL_HAT_LEFT:
515 joyevent.JoystickEvent.POV=27000; 515 joyevent.JoystickEvent.POV=27000;
516 break; 516 break;
517 case SDL_HAT_LEFTUP: 517 case SDL_HAT_LEFTUP:
518 joyevent.JoystickEvent.POV=31500; 518 joyevent.JoystickEvent.POV=31500;
519 break; 519 break;
520 case SDL_HAT_CENTERED: 520 case SDL_HAT_CENTERED:
521 default: 521 default:
522 joyevent.JoystickEvent.POV=65535; 522 joyevent.JoystickEvent.POV=65535;
523 break; 523 break;
524 } 524 }
525 } 525 }
526 else 526 else
527 { 527 {
528 joyevent.JoystickEvent.POV=65535; 528 joyevent.JoystickEvent.POV=65535;
529 } 529 }
530 530
531 // we map the number directly 531 // we map the number directly
532 joyevent.JoystickEvent.Joystick=static_cast<u8>(i); 532 joyevent.JoystickEvent.Joystick=static_cast<u8>(i);
533 // now post the event 533 // now post the event
534 postEventFromUser(joyevent); 534 postEventFromUser(joyevent);
535 // and close the joystick 535 // and close the joystick
536 } 536 }
537 } 537 }
538#endif 538#endif
539 return !Close; 539 return !Close;
540} 540}
541 541
542//! Activate any joysticks, and generate events for them. 542//! Activate any joysticks, and generate events for them.
543bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo) 543bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
544{ 544{
545#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) 545#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
546 joystickInfo.clear(); 546 joystickInfo.clear();
547 547
548 // we can name up to 256 different joysticks 548 // we can name up to 256 different joysticks
549 const int numJoysticks = core::min_(SDL_NumJoysticks(), 256); 549 const int numJoysticks = core::min_(SDL_NumJoysticks(), 256);
550 Joysticks.reallocate(numJoysticks); 550 Joysticks.reallocate(numJoysticks);
551 joystickInfo.reallocate(numJoysticks); 551 joystickInfo.reallocate(numJoysticks);
552 552
553 int joystick = 0; 553 int joystick = 0;
554 for (; joystick<numJoysticks; ++joystick) 554 for (; joystick<numJoysticks; ++joystick)
555 { 555 {
556 Joysticks.push_back(SDL_JoystickOpen(joystick)); 556 Joysticks.push_back(SDL_JoystickOpen(joystick));
557 SJoystickInfo info; 557 SJoystickInfo info;
558 558
559 info.Joystick = joystick; 559 info.Joystick = joystick;
560 info.Axes = SDL_JoystickNumAxes(Joysticks[joystick]); 560 info.Axes = SDL_JoystickNumAxes(Joysticks[joystick]);
561 info.Buttons = SDL_JoystickNumButtons(Joysticks[joystick]); 561 info.Buttons = SDL_JoystickNumButtons(Joysticks[joystick]);
562 info.Name = SDL_JoystickName(joystick); 562 info.Name = SDL_JoystickName(joystick);
563 info.PovHat = (SDL_JoystickNumHats(Joysticks[joystick]) > 0) 563 info.PovHat = (SDL_JoystickNumHats(Joysticks[joystick]) > 0)
564 ? SJoystickInfo::POV_HAT_PRESENT : SJoystickInfo::POV_HAT_ABSENT; 564 ? SJoystickInfo::POV_HAT_PRESENT : SJoystickInfo::POV_HAT_ABSENT;
565 565
566 joystickInfo.push_back(info); 566 joystickInfo.push_back(info);
567 } 567 }
568 568
569 for(joystick = 0; joystick < (int)joystickInfo.size(); ++joystick) 569 for(joystick = 0; joystick < (int)joystickInfo.size(); ++joystick)
570 { 570 {
571 char logString[256]; 571 char logString[256];
572 (void)sprintf(logString, "Found joystick %d, %d axes, %d buttons '%s'", 572 (void)sprintf(logString, "Found joystick %d, %d axes, %d buttons '%s'",
573 joystick, joystickInfo[joystick].Axes, 573 joystick, joystickInfo[joystick].Axes,
574 joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str()); 574 joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str());
575 os::Printer::log(logString, ELL_INFORMATION); 575 os::Printer::log(logString, ELL_INFORMATION);
576 } 576 }
577 577
578 return true; 578 return true;
579 579
580#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ 580#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
581 581
582 return false; 582 return false;
583} 583}
584 584
585 585
586 586
587//! pause execution temporarily 587//! pause execution temporarily
588void CIrrDeviceSDL::yield() 588void CIrrDeviceSDL::yield()
589{ 589{
590 SDL_Delay(0); 590 SDL_Delay(0);
591} 591}
592 592
593 593
594//! pause execution for a specified time 594//! pause execution for a specified time
595void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer) 595void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer)
596{ 596{
597 const bool wasStopped = Timer ? Timer->isStopped() : true; 597 const bool wasStopped = Timer ? Timer->isStopped() : true;
598 if (pauseTimer && !wasStopped) 598 if (pauseTimer && !wasStopped)
599 Timer->stop(); 599 Timer->stop();
600 600
601 SDL_Delay(timeMs); 601 SDL_Delay(timeMs);
602 602
603 if (pauseTimer && !wasStopped) 603 if (pauseTimer && !wasStopped)
604 Timer->start(); 604 Timer->start();
605} 605}
606 606
607 607
608//! sets the caption of the window 608//! sets the caption of the window
609void CIrrDeviceSDL::setWindowCaption(const wchar_t* text) 609void CIrrDeviceSDL::setWindowCaption(const wchar_t* text)
610{ 610{
611 core::stringc textc = text; 611 core::stringc textc = text;
612 SDL_WM_SetCaption( textc.c_str( ), textc.c_str( ) ); 612 SDL_WM_SetCaption( textc.c_str( ), textc.c_str( ) );
613} 613}
614 614
615 615
616//! presents a surface in the client area 616//! presents a surface in the client area
617bool CIrrDeviceSDL::present(video::IImage* surface, void* windowId, core::rect<s32>* srcClip) 617bool CIrrDeviceSDL::present(video::IImage* surface, void* windowId, core::rect<s32>* srcClip)
618{ 618{
619 SDL_Surface *sdlSurface = SDL_CreateRGBSurfaceFrom( 619 SDL_Surface *sdlSurface = SDL_CreateRGBSurfaceFrom(
620 surface->lock(), surface->getDimension().Width, surface->getDimension().Height, 620 surface->lock(), surface->getDimension().Width, surface->getDimension().Height,
621 surface->getBitsPerPixel(), surface->getPitch(), 621 surface->getBitsPerPixel(), surface->getPitch(),
622 surface->getRedMask(), surface->getGreenMask(), surface->getBlueMask(), surface->getAlphaMask()); 622 surface->getRedMask(), surface->getGreenMask(), surface->getBlueMask(), surface->getAlphaMask());
623 if (!sdlSurface) 623 if (!sdlSurface)
624 return false; 624 return false;
625 SDL_SetAlpha(sdlSurface, 0, 0); 625 SDL_SetAlpha(sdlSurface, 0, 0);
626 SDL_SetColorKey(sdlSurface, 0, 0); 626 SDL_SetColorKey(sdlSurface, 0, 0);
627 sdlSurface->format->BitsPerPixel=surface->getBitsPerPixel(); 627 sdlSurface->format->BitsPerPixel=surface->getBitsPerPixel();
628 sdlSurface->format->BytesPerPixel=surface->getBytesPerPixel(); 628 sdlSurface->format->BytesPerPixel=surface->getBytesPerPixel();
629 if ((surface->getColorFormat()==video::ECF_R8G8B8) || 629 if ((surface->getColorFormat()==video::ECF_R8G8B8) ||
630 (surface->getColorFormat()==video::ECF_A8R8G8B8)) 630 (surface->getColorFormat()==video::ECF_A8R8G8B8))
631 { 631 {
632 sdlSurface->format->Rloss=0; 632 sdlSurface->format->Rloss=0;
633 sdlSurface->format->Gloss=0; 633 sdlSurface->format->Gloss=0;
634 sdlSurface->format->Bloss=0; 634 sdlSurface->format->Bloss=0;
635 sdlSurface->format->Rshift=16; 635 sdlSurface->format->Rshift=16;
636 sdlSurface->format->Gshift=8; 636 sdlSurface->format->Gshift=8;
637 sdlSurface->format->Bshift=0; 637 sdlSurface->format->Bshift=0;
638 if (surface->getColorFormat()==video::ECF_R8G8B8) 638 if (surface->getColorFormat()==video::ECF_R8G8B8)
639 { 639 {
640 sdlSurface->format->Aloss=8; 640 sdlSurface->format->Aloss=8;
641 sdlSurface->format->Ashift=32; 641 sdlSurface->format->Ashift=32;
642 } 642 }
643 else 643 else
644 { 644 {
645 sdlSurface->format->Aloss=0; 645 sdlSurface->format->Aloss=0;
646 sdlSurface->format->Ashift=24; 646 sdlSurface->format->Ashift=24;
647 } 647 }
648 } 648 }
649 else if (surface->getColorFormat()==video::ECF_R5G6B5) 649 else if (surface->getColorFormat()==video::ECF_R5G6B5)
650 { 650 {
651 sdlSurface->format->Rloss=3; 651 sdlSurface->format->Rloss=3;
652 sdlSurface->format->Gloss=2; 652 sdlSurface->format->Gloss=2;
653 sdlSurface->format->Bloss=3; 653 sdlSurface->format->Bloss=3;
654 sdlSurface->format->Aloss=8; 654 sdlSurface->format->Aloss=8;
655 sdlSurface->format->Rshift=11; 655 sdlSurface->format->Rshift=11;
656 sdlSurface->format->Gshift=5; 656 sdlSurface->format->Gshift=5;
657 sdlSurface->format->Bshift=0; 657 sdlSurface->format->Bshift=0;
658 sdlSurface->format->Ashift=16; 658 sdlSurface->format->Ashift=16;
659 } 659 }
660 else if (surface->getColorFormat()==video::ECF_A1R5G5B5) 660 else if (surface->getColorFormat()==video::ECF_A1R5G5B5)
661 { 661 {
662 sdlSurface->format->Rloss=3; 662 sdlSurface->format->Rloss=3;
663 sdlSurface->format->Gloss=3; 663 sdlSurface->format->Gloss=3;
664 sdlSurface->format->Bloss=3; 664 sdlSurface->format->Bloss=3;
665 sdlSurface->format->Aloss=7; 665 sdlSurface->format->Aloss=7;
666 sdlSurface->format->Rshift=10; 666 sdlSurface->format->Rshift=10;
667 sdlSurface->format->Gshift=5; 667 sdlSurface->format->Gshift=5;
668 sdlSurface->format->Bshift=0; 668 sdlSurface->format->Bshift=0;
669 sdlSurface->format->Ashift=15; 669 sdlSurface->format->Ashift=15;
670 } 670 }
671 671
672 SDL_Surface* scr = (SDL_Surface* )windowId; 672 SDL_Surface* scr = (SDL_Surface* )windowId;
673 if (!scr) 673 if (!scr)
674 scr = Screen; 674 scr = Screen;
675 if (scr) 675 if (scr)
676 { 676 {
677 if (srcClip) 677 if (srcClip)
678 { 678 {
679 SDL_Rect sdlsrcClip; 679 SDL_Rect sdlsrcClip;
680 sdlsrcClip.x = srcClip->UpperLeftCorner.X; 680 sdlsrcClip.x = srcClip->UpperLeftCorner.X;
681 sdlsrcClip.y = srcClip->UpperLeftCorner.Y; 681 sdlsrcClip.y = srcClip->UpperLeftCorner.Y;
682 sdlsrcClip.w = srcClip->getWidth(); 682 sdlsrcClip.w = srcClip->getWidth();
683 sdlsrcClip.h = srcClip->getHeight(); 683 sdlsrcClip.h = srcClip->getHeight();
684 SDL_BlitSurface(sdlSurface, &sdlsrcClip, scr, NULL); 684 SDL_BlitSurface(sdlSurface, &sdlsrcClip, scr, NULL);
685 } 685 }
686 else 686 else
687 SDL_BlitSurface(sdlSurface, NULL, scr, NULL); 687 SDL_BlitSurface(sdlSurface, NULL, scr, NULL);
688 SDL_Flip(scr); 688 SDL_Flip(scr);
689 } 689 }
690 690
691 SDL_FreeSurface(sdlSurface); 691 SDL_FreeSurface(sdlSurface);
692 surface->unlock(); 692 surface->unlock();
693 return (scr != 0); 693 return (scr != 0);
694} 694}
695 695
696 696
697//! notifies the device that it should close itself 697//! notifies the device that it should close itself
698void CIrrDeviceSDL::closeDevice() 698void CIrrDeviceSDL::closeDevice()
699{ 699{
700 Close = true; 700 Close = true;
701} 701}
702 702
703 703
704//! \return Pointer to a list with all video modes supported 704//! \return Pointer to a list with all video modes supported
705video::IVideoModeList* CIrrDeviceSDL::getVideoModeList() 705video::IVideoModeList* CIrrDeviceSDL::getVideoModeList()
706{ 706{
707 if (!VideoModeList.getVideoModeCount()) 707 if (!VideoModeList.getVideoModeCount())
708 { 708 {
709 // enumerate video modes. 709 // enumerate video modes.
710 const SDL_VideoInfo *vi = SDL_GetVideoInfo(); 710 const SDL_VideoInfo *vi = SDL_GetVideoInfo();
711 SDL_Rect **modes = SDL_ListModes(vi->vfmt, SDL_Flags); 711 SDL_Rect **modes = SDL_ListModes(vi->vfmt, SDL_Flags);
712 if (modes != 0) 712 if (modes != 0)
713 { 713 {
714 if (modes == (SDL_Rect **)-1) 714 if (modes == (SDL_Rect **)-1)
715 os::Printer::log("All modes available.\n"); 715 os::Printer::log("All modes available.\n");
716 else 716 else
717 { 717 {
718 for (u32 i=0; modes[i]; ++i) 718 for (u32 i=0; modes[i]; ++i)
719 VideoModeList.addMode(core::dimension2d<u32>(modes[i]->w, modes[i]->h), vi->vfmt->BitsPerPixel); 719 VideoModeList.addMode(core::dimension2d<u32>(modes[i]->w, modes[i]->h), vi->vfmt->BitsPerPixel);
720 } 720 }
721 } 721 }
722 } 722 }
723 723
724 return &VideoModeList; 724 return &VideoModeList;
725} 725}
726 726
727 727
728//! Sets if the window should be resizable in windowed mode. 728//! Sets if the window should be resizable in windowed mode.
729void CIrrDeviceSDL::setResizable(bool resize) 729void CIrrDeviceSDL::setResizable(bool resize)
730{ 730{
731 if (resize != Resizable) 731 if (resize != Resizable)
732 { 732 {
733 if (resize) 733 if (resize)
734 SDL_Flags |= SDL_RESIZABLE; 734 SDL_Flags |= SDL_RESIZABLE;
735 else 735 else
736 SDL_Flags &= ~SDL_RESIZABLE; 736 SDL_Flags &= ~SDL_RESIZABLE;
737 Screen = SDL_SetVideoMode( 0, 0, 0, SDL_Flags ); 737 Screen = SDL_SetVideoMode( 0, 0, 0, SDL_Flags );
738 Resizable = resize; 738 Resizable = resize;
739 } 739 }
740} 740}
741 741
742 742
743//! Minimizes window if possible 743//! Minimizes window if possible
744void CIrrDeviceSDL::minimizeWindow() 744void CIrrDeviceSDL::minimizeWindow()
745{ 745{
746 SDL_WM_IconifyWindow(); 746 SDL_WM_IconifyWindow();
747} 747}
748 748
749 749
750//! Maximize window 750//! Maximize window
751void CIrrDeviceSDL::maximizeWindow() 751void CIrrDeviceSDL::maximizeWindow()
752{ 752{
753 // do nothing 753 // do nothing
754} 754}
755 755
756 756
757//! Restore original window size 757//! Restore original window size
758void CIrrDeviceSDL::restoreWindow() 758void CIrrDeviceSDL::restoreWindow()
759{ 759{
760 // do nothing 760 // do nothing
761} 761}
762 762
763 763
764//! returns if window is active. if not, nothing need to be drawn 764//! returns if window is active. if not, nothing need to be drawn
765bool CIrrDeviceSDL::isWindowActive() const 765bool CIrrDeviceSDL::isWindowActive() const
766{ 766{
767 return (WindowHasFocus && !WindowMinimized); 767 return (WindowHasFocus && !WindowMinimized);
768} 768}
769 769
770 770
771//! returns if window has focus. 771//! returns if window has focus.
772bool CIrrDeviceSDL::isWindowFocused() const 772bool CIrrDeviceSDL::isWindowFocused() const
773{ 773{
774 return WindowHasFocus; 774 return WindowHasFocus;
775} 775}
776 776
777 777
778//! returns if window is minimized. 778//! returns if window is minimized.
779bool CIrrDeviceSDL::isWindowMinimized() const 779bool CIrrDeviceSDL::isWindowMinimized() const
780{ 780{
781 return WindowMinimized; 781 return WindowMinimized;
782} 782}
783 783
784 784
785//! Set the current Gamma Value for the Display 785//! Set the current Gamma Value for the Display
786bool CIrrDeviceSDL::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) 786bool CIrrDeviceSDL::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast )
787{ 787{
788 /* 788 /*
789 // todo: Gamma in SDL takes ints, what does Irrlicht use? 789 // todo: Gamma in SDL takes ints, what does Irrlicht use?
790 return (SDL_SetGamma(red, green, blue) != -1); 790 return (SDL_SetGamma(red, green, blue) != -1);
791 */ 791 */
792 return false; 792 return false;
793} 793}
794 794
795//! Get the current Gamma Value for the Display 795//! Get the current Gamma Value for the Display
796bool CIrrDeviceSDL::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) 796bool CIrrDeviceSDL::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast )
797{ 797{
798/* brightness = 0.f; 798/* brightness = 0.f;
799 contrast = 0.f; 799 contrast = 0.f;
800 return (SDL_GetGamma(&red, &green, &blue) != -1);*/ 800 return (SDL_GetGamma(&red, &green, &blue) != -1);*/
801 return false; 801 return false;
802} 802}
803 803
804//! returns color format of the window. 804//! returns color format of the window.
805video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const 805video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const
806{ 806{
807 if (Screen) 807 if (Screen)
808 { 808 {
809 if (Screen->format->BitsPerPixel==16) 809 if (Screen->format->BitsPerPixel==16)
810 { 810 {
811 if (Screen->format->Amask != 0) 811 if (Screen->format->Amask != 0)
812 return video::ECF_A1R5G5B5; 812 return video::ECF_A1R5G5B5;
813 else 813 else
814 return video::ECF_R5G6B5; 814 return video::ECF_R5G6B5;
815 } 815 }
816 else 816 else
817 { 817 {
818 if (Screen->format->Amask != 0) 818 if (Screen->format->Amask != 0)
819 return video::ECF_A8R8G8B8; 819 return video::ECF_A8R8G8B8;
820 else 820 else
821 return video::ECF_R8G8B8; 821 return video::ECF_R8G8B8;
822 } 822 }
823 } 823 }
824 else 824 else
825 return CIrrDeviceStub::getColorFormat(); 825 return CIrrDeviceStub::getColorFormat();
826} 826}
827 827
828 828
829void CIrrDeviceSDL::createKeyMap() 829void CIrrDeviceSDL::createKeyMap()
830{ 830{
831 // I don't know if this is the best method to create 831 // I don't know if this is the best method to create
832 // the lookuptable, but I'll leave it like that until 832 // the lookuptable, but I'll leave it like that until
833 // I find a better version. 833 // I find a better version.
834 834
835 KeyMap.reallocate(105); 835 KeyMap.reallocate(105);
836 836
837 // buttons missing 837 // buttons missing
838 838
839 KeyMap.push_back(SKeyMap(SDLK_BACKSPACE, KEY_BACK)); 839 KeyMap.push_back(SKeyMap(SDLK_BACKSPACE, KEY_BACK));
840 KeyMap.push_back(SKeyMap(SDLK_TAB, KEY_TAB)); 840 KeyMap.push_back(SKeyMap(SDLK_TAB, KEY_TAB));
841 KeyMap.push_back(SKeyMap(SDLK_CLEAR, KEY_CLEAR)); 841 KeyMap.push_back(SKeyMap(SDLK_CLEAR, KEY_CLEAR));
842 KeyMap.push_back(SKeyMap(SDLK_RETURN, KEY_RETURN)); 842 KeyMap.push_back(SKeyMap(SDLK_RETURN, KEY_RETURN));
843 843
844 // combined modifiers missing 844 // combined modifiers missing
845 845
846 KeyMap.push_back(SKeyMap(SDLK_PAUSE, KEY_PAUSE)); 846 KeyMap.push_back(SKeyMap(SDLK_PAUSE, KEY_PAUSE));
847 KeyMap.push_back(SKeyMap(SDLK_CAPSLOCK, KEY_CAPITAL)); 847 KeyMap.push_back(SKeyMap(SDLK_CAPSLOCK, KEY_CAPITAL));
848 848
849 // asian letter keys missing 849 // asian letter keys missing
850 850
851 KeyMap.push_back(SKeyMap(SDLK_ESCAPE, KEY_ESCAPE)); 851 KeyMap.push_back(SKeyMap(SDLK_ESCAPE, KEY_ESCAPE));
852 852
853 // asian letter keys missing 853 // asian letter keys missing
854 854
855 KeyMap.push_back(SKeyMap(SDLK_SPACE, KEY_SPACE)); 855 KeyMap.push_back(SKeyMap(SDLK_SPACE, KEY_SPACE));
856 KeyMap.push_back(SKeyMap(SDLK_PAGEUP, KEY_PRIOR)); 856 KeyMap.push_back(SKeyMap(SDLK_PAGEUP, KEY_PRIOR));
857 KeyMap.push_back(SKeyMap(SDLK_PAGEDOWN, KEY_NEXT)); 857 KeyMap.push_back(SKeyMap(SDLK_PAGEDOWN, KEY_NEXT));
858 KeyMap.push_back(SKeyMap(SDLK_END, KEY_END)); 858 KeyMap.push_back(SKeyMap(SDLK_END, KEY_END));
859 KeyMap.push_back(SKeyMap(SDLK_HOME, KEY_HOME)); 859 KeyMap.push_back(SKeyMap(SDLK_HOME, KEY_HOME));
860 KeyMap.push_back(SKeyMap(SDLK_LEFT, KEY_LEFT)); 860 KeyMap.push_back(SKeyMap(SDLK_LEFT, KEY_LEFT));
861 KeyMap.push_back(SKeyMap(SDLK_UP, KEY_UP)); 861 KeyMap.push_back(SKeyMap(SDLK_UP, KEY_UP));
862 KeyMap.push_back(SKeyMap(SDLK_RIGHT, KEY_RIGHT)); 862 KeyMap.push_back(SKeyMap(SDLK_RIGHT, KEY_RIGHT));
863 KeyMap.push_back(SKeyMap(SDLK_DOWN, KEY_DOWN)); 863 KeyMap.push_back(SKeyMap(SDLK_DOWN, KEY_DOWN));
864 864
865 // select missing 865 // select missing
866 KeyMap.push_back(SKeyMap(SDLK_PRINT, KEY_PRINT)); 866 KeyMap.push_back(SKeyMap(SDLK_PRINT, KEY_PRINT));
867 // execute missing 867 // execute missing
868 KeyMap.push_back(SKeyMap(SDLK_PRINT, KEY_SNAPSHOT)); 868 KeyMap.push_back(SKeyMap(SDLK_PRINT, KEY_SNAPSHOT));
869 869
870 KeyMap.push_back(SKeyMap(SDLK_INSERT, KEY_INSERT)); 870 KeyMap.push_back(SKeyMap(SDLK_INSERT, KEY_INSERT));
871 KeyMap.push_back(SKeyMap(SDLK_DELETE, KEY_DELETE)); 871 KeyMap.push_back(SKeyMap(SDLK_DELETE, KEY_DELETE));
872 KeyMap.push_back(SKeyMap(SDLK_HELP, KEY_HELP)); 872 KeyMap.push_back(SKeyMap(SDLK_HELP, KEY_HELP));
873 873
874 KeyMap.push_back(SKeyMap(SDLK_0, KEY_KEY_0)); 874 KeyMap.push_back(SKeyMap(SDLK_0, KEY_KEY_0));
875 KeyMap.push_back(SKeyMap(SDLK_1, KEY_KEY_1)); 875 KeyMap.push_back(SKeyMap(SDLK_1, KEY_KEY_1));
876 KeyMap.push_back(SKeyMap(SDLK_2, KEY_KEY_2)); 876 KeyMap.push_back(SKeyMap(SDLK_2, KEY_KEY_2));
877 KeyMap.push_back(SKeyMap(SDLK_3, KEY_KEY_3)); 877 KeyMap.push_back(SKeyMap(SDLK_3, KEY_KEY_3));
878 KeyMap.push_back(SKeyMap(SDLK_4, KEY_KEY_4)); 878 KeyMap.push_back(SKeyMap(SDLK_4, KEY_KEY_4));
879 KeyMap.push_back(SKeyMap(SDLK_5, KEY_KEY_5)); 879 KeyMap.push_back(SKeyMap(SDLK_5, KEY_KEY_5));
880 KeyMap.push_back(SKeyMap(SDLK_6, KEY_KEY_6)); 880 KeyMap.push_back(SKeyMap(SDLK_6, KEY_KEY_6));
881 KeyMap.push_back(SKeyMap(SDLK_7, KEY_KEY_7)); 881 KeyMap.push_back(SKeyMap(SDLK_7, KEY_KEY_7));
882 KeyMap.push_back(SKeyMap(SDLK_8, KEY_KEY_8)); 882 KeyMap.push_back(SKeyMap(SDLK_8, KEY_KEY_8));
883 KeyMap.push_back(SKeyMap(SDLK_9, KEY_KEY_9)); 883 KeyMap.push_back(SKeyMap(SDLK_9, KEY_KEY_9));
884 884
885 KeyMap.push_back(SKeyMap(SDLK_a, KEY_KEY_A)); 885 KeyMap.push_back(SKeyMap(SDLK_a, KEY_KEY_A));
886 KeyMap.push_back(SKeyMap(SDLK_b, KEY_KEY_B)); 886 KeyMap.push_back(SKeyMap(SDLK_b, KEY_KEY_B));
887 KeyMap.push_back(SKeyMap(SDLK_c, KEY_KEY_C)); 887 KeyMap.push_back(SKeyMap(SDLK_c, KEY_KEY_C));
888 KeyMap.push_back(SKeyMap(SDLK_d, KEY_KEY_D)); 888 KeyMap.push_back(SKeyMap(SDLK_d, KEY_KEY_D));
889 KeyMap.push_back(SKeyMap(SDLK_e, KEY_KEY_E)); 889 KeyMap.push_back(SKeyMap(SDLK_e, KEY_KEY_E));
890 KeyMap.push_back(SKeyMap(SDLK_f, KEY_KEY_F)); 890 KeyMap.push_back(SKeyMap(SDLK_f, KEY_KEY_F));
891 KeyMap.push_back(SKeyMap(SDLK_g, KEY_KEY_G)); 891 KeyMap.push_back(SKeyMap(SDLK_g, KEY_KEY_G));
892 KeyMap.push_back(SKeyMap(SDLK_h, KEY_KEY_H)); 892 KeyMap.push_back(SKeyMap(SDLK_h, KEY_KEY_H));
893 KeyMap.push_back(SKeyMap(SDLK_i, KEY_KEY_I)); 893 KeyMap.push_back(SKeyMap(SDLK_i, KEY_KEY_I));
894 KeyMap.push_back(SKeyMap(SDLK_j, KEY_KEY_J)); 894 KeyMap.push_back(SKeyMap(SDLK_j, KEY_KEY_J));
895 KeyMap.push_back(SKeyMap(SDLK_k, KEY_KEY_K)); 895 KeyMap.push_back(SKeyMap(SDLK_k, KEY_KEY_K));
896 KeyMap.push_back(SKeyMap(SDLK_l, KEY_KEY_L)); 896 KeyMap.push_back(SKeyMap(SDLK_l, KEY_KEY_L));
897 KeyMap.push_back(SKeyMap(SDLK_m, KEY_KEY_M)); 897 KeyMap.push_back(SKeyMap(SDLK_m, KEY_KEY_M));
898 KeyMap.push_back(SKeyMap(SDLK_n, KEY_KEY_N)); 898 KeyMap.push_back(SKeyMap(SDLK_n, KEY_KEY_N));
899 KeyMap.push_back(SKeyMap(SDLK_o, KEY_KEY_O)); 899 KeyMap.push_back(SKeyMap(SDLK_o, KEY_KEY_O));
900 KeyMap.push_back(SKeyMap(SDLK_p, KEY_KEY_P)); 900 KeyMap.push_back(SKeyMap(SDLK_p, KEY_KEY_P));
901 KeyMap.push_back(SKeyMap(SDLK_q, KEY_KEY_Q)); 901 KeyMap.push_back(SKeyMap(SDLK_q, KEY_KEY_Q));
902 KeyMap.push_back(SKeyMap(SDLK_r, KEY_KEY_R)); 902 KeyMap.push_back(SKeyMap(SDLK_r, KEY_KEY_R));
903 KeyMap.push_back(SKeyMap(SDLK_s, KEY_KEY_S)); 903 KeyMap.push_back(SKeyMap(SDLK_s, KEY_KEY_S));
904 KeyMap.push_back(SKeyMap(SDLK_t, KEY_KEY_T)); 904 KeyMap.push_back(SKeyMap(SDLK_t, KEY_KEY_T));
905 KeyMap.push_back(SKeyMap(SDLK_u, KEY_KEY_U)); 905 KeyMap.push_back(SKeyMap(SDLK_u, KEY_KEY_U));
906 KeyMap.push_back(SKeyMap(SDLK_v, KEY_KEY_V)); 906 KeyMap.push_back(SKeyMap(SDLK_v, KEY_KEY_V));
907 KeyMap.push_back(SKeyMap(SDLK_w, KEY_KEY_W)); 907 KeyMap.push_back(SKeyMap(SDLK_w, KEY_KEY_W));
908 KeyMap.push_back(SKeyMap(SDLK_x, KEY_KEY_X)); 908 KeyMap.push_back(SKeyMap(SDLK_x, KEY_KEY_X));
909 KeyMap.push_back(SKeyMap(SDLK_y, KEY_KEY_Y)); 909 KeyMap.push_back(SKeyMap(SDLK_y, KEY_KEY_Y));
910 KeyMap.push_back(SKeyMap(SDLK_z, KEY_KEY_Z)); 910 KeyMap.push_back(SKeyMap(SDLK_z, KEY_KEY_Z));
911 911
912 KeyMap.push_back(SKeyMap(SDLK_LSUPER, KEY_LWIN)); 912 KeyMap.push_back(SKeyMap(SDLK_LSUPER, KEY_LWIN));
913 KeyMap.push_back(SKeyMap(SDLK_RSUPER, KEY_RWIN)); 913 KeyMap.push_back(SKeyMap(SDLK_RSUPER, KEY_RWIN));
914 // apps missing 914 // apps missing
915 KeyMap.push_back(SKeyMap(SDLK_POWER, KEY_SLEEP)); //?? 915 KeyMap.push_back(SKeyMap(SDLK_POWER, KEY_SLEEP)); //??
916 916
917 KeyMap.push_back(SKeyMap(SDLK_KP0, KEY_NUMPAD0)); 917 KeyMap.push_back(SKeyMap(SDLK_KP0, KEY_NUMPAD0));
918 KeyMap.push_back(SKeyMap(SDLK_KP1, KEY_NUMPAD1)); 918 KeyMap.push_back(SKeyMap(SDLK_KP1, KEY_NUMPAD1));
919 KeyMap.push_back(SKeyMap(SDLK_KP2, KEY_NUMPAD2)); 919 KeyMap.push_back(SKeyMap(SDLK_KP2, KEY_NUMPAD2));
920 KeyMap.push_back(SKeyMap(SDLK_KP3, KEY_NUMPAD3)); 920 KeyMap.push_back(SKeyMap(SDLK_KP3, KEY_NUMPAD3));
921 KeyMap.push_back(SKeyMap(SDLK_KP4, KEY_NUMPAD4)); 921 KeyMap.push_back(SKeyMap(SDLK_KP4, KEY_NUMPAD4));
922 KeyMap.push_back(SKeyMap(SDLK_KP5, KEY_NUMPAD5)); 922 KeyMap.push_back(SKeyMap(SDLK_KP5, KEY_NUMPAD5));
923 KeyMap.push_back(SKeyMap(SDLK_KP6, KEY_NUMPAD6)); 923 KeyMap.push_back(SKeyMap(SDLK_KP6, KEY_NUMPAD6));
924 KeyMap.push_back(SKeyMap(SDLK_KP7, KEY_NUMPAD7)); 924 KeyMap.push_back(SKeyMap(SDLK_KP7, KEY_NUMPAD7));
925 KeyMap.push_back(SKeyMap(SDLK_KP8, KEY_NUMPAD8)); 925 KeyMap.push_back(SKeyMap(SDLK_KP8, KEY_NUMPAD8));
926 KeyMap.push_back(SKeyMap(SDLK_KP9, KEY_NUMPAD9)); 926 KeyMap.push_back(SKeyMap(SDLK_KP9, KEY_NUMPAD9));
927 KeyMap.push_back(SKeyMap(SDLK_KP_MULTIPLY, KEY_MULTIPLY)); 927 KeyMap.push_back(SKeyMap(SDLK_KP_MULTIPLY, KEY_MULTIPLY));
928 KeyMap.push_back(SKeyMap(SDLK_KP_PLUS, KEY_ADD)); 928 KeyMap.push_back(SKeyMap(SDLK_KP_PLUS, KEY_ADD));
929// KeyMap.push_back(SKeyMap(SDLK_KP_, KEY_SEPARATOR)); 929// KeyMap.push_back(SKeyMap(SDLK_KP_, KEY_SEPARATOR));
930 KeyMap.push_back(SKeyMap(SDLK_KP_MINUS, KEY_SUBTRACT)); 930 KeyMap.push_back(SKeyMap(SDLK_KP_MINUS, KEY_SUBTRACT));
931 KeyMap.push_back(SKeyMap(SDLK_KP_PERIOD, KEY_DECIMAL)); 931 KeyMap.push_back(SKeyMap(SDLK_KP_PERIOD, KEY_DECIMAL));
932 KeyMap.push_back(SKeyMap(SDLK_KP_DIVIDE, KEY_DIVIDE)); 932 KeyMap.push_back(SKeyMap(SDLK_KP_DIVIDE, KEY_DIVIDE));
933 933
934 KeyMap.push_back(SKeyMap(SDLK_F1, KEY_F1)); 934 KeyMap.push_back(SKeyMap(SDLK_F1, KEY_F1));
935 KeyMap.push_back(SKeyMap(SDLK_F2, KEY_F2)); 935 KeyMap.push_back(SKeyMap(SDLK_F2, KEY_F2));
936 KeyMap.push_back(SKeyMap(SDLK_F3, KEY_F3)); 936 KeyMap.push_back(SKeyMap(SDLK_F3, KEY_F3));
937 KeyMap.push_back(SKeyMap(SDLK_F4, KEY_F4)); 937 KeyMap.push_back(SKeyMap(SDLK_F4, KEY_F4));
938 KeyMap.push_back(SKeyMap(SDLK_F5, KEY_F5)); 938 KeyMap.push_back(SKeyMap(SDLK_F5, KEY_F5));
939 KeyMap.push_back(SKeyMap(SDLK_F6, KEY_F6)); 939 KeyMap.push_back(SKeyMap(SDLK_F6, KEY_F6));
940 KeyMap.push_back(SKeyMap(SDLK_F7, KEY_F7)); 940 KeyMap.push_back(SKeyMap(SDLK_F7, KEY_F7));
941 KeyMap.push_back(SKeyMap(SDLK_F8, KEY_F8)); 941 KeyMap.push_back(SKeyMap(SDLK_F8, KEY_F8));
942 KeyMap.push_back(SKeyMap(SDLK_F9, KEY_F9)); 942 KeyMap.push_back(SKeyMap(SDLK_F9, KEY_F9));
943 KeyMap.push_back(SKeyMap(SDLK_F10, KEY_F10)); 943 KeyMap.push_back(SKeyMap(SDLK_F10, KEY_F10));
944 KeyMap.push_back(SKeyMap(SDLK_F11, KEY_F11)); 944 KeyMap.push_back(SKeyMap(SDLK_F11, KEY_F11));
945 KeyMap.push_back(SKeyMap(SDLK_F12, KEY_F12)); 945 KeyMap.push_back(SKeyMap(SDLK_F12, KEY_F12));
946 KeyMap.push_back(SKeyMap(SDLK_F13, KEY_F13)); 946 KeyMap.push_back(SKeyMap(SDLK_F13, KEY_F13));
947 KeyMap.push_back(SKeyMap(SDLK_F14, KEY_F14)); 947 KeyMap.push_back(SKeyMap(SDLK_F14, KEY_F14));
948 KeyMap.push_back(SKeyMap(SDLK_F15, KEY_F15)); 948 KeyMap.push_back(SKeyMap(SDLK_F15, KEY_F15));
949 // no higher F-keys 949 // no higher F-keys
950 950
951 KeyMap.push_back(SKeyMap(SDLK_NUMLOCK, KEY_NUMLOCK)); 951 KeyMap.push_back(SKeyMap(SDLK_NUMLOCK, KEY_NUMLOCK));
952 KeyMap.push_back(SKeyMap(SDLK_SCROLLOCK, KEY_SCROLL)); 952 KeyMap.push_back(SKeyMap(SDLK_SCROLLOCK, KEY_SCROLL));
953 KeyMap.push_back(SKeyMap(SDLK_LSHIFT, KEY_LSHIFT)); 953 KeyMap.push_back(SKeyMap(SDLK_LSHIFT, KEY_LSHIFT));
954 KeyMap.push_back(SKeyMap(SDLK_RSHIFT, KEY_RSHIFT)); 954 KeyMap.push_back(SKeyMap(SDLK_RSHIFT, KEY_RSHIFT));
955 KeyMap.push_back(SKeyMap(SDLK_LCTRL, KEY_LCONTROL)); 955 KeyMap.push_back(SKeyMap(SDLK_LCTRL, KEY_LCONTROL));
956 KeyMap.push_back(SKeyMap(SDLK_RCTRL, KEY_RCONTROL)); 956 KeyMap.push_back(SKeyMap(SDLK_RCTRL, KEY_RCONTROL));
957 KeyMap.push_back(SKeyMap(SDLK_LALT, KEY_LMENU)); 957 KeyMap.push_back(SKeyMap(SDLK_LALT, KEY_LMENU));
958 KeyMap.push_back(SKeyMap(SDLK_RALT, KEY_RMENU)); 958 KeyMap.push_back(SKeyMap(SDLK_RALT, KEY_RMENU));
959 959
960 KeyMap.push_back(SKeyMap(SDLK_PLUS, KEY_PLUS)); 960 KeyMap.push_back(SKeyMap(SDLK_PLUS, KEY_PLUS));
961 KeyMap.push_back(SKeyMap(SDLK_COMMA, KEY_COMMA)); 961 KeyMap.push_back(SKeyMap(SDLK_COMMA, KEY_COMMA));
962 KeyMap.push_back(SKeyMap(SDLK_MINUS, KEY_MINUS)); 962 KeyMap.push_back(SKeyMap(SDLK_MINUS, KEY_MINUS));
963 KeyMap.push_back(SKeyMap(SDLK_PERIOD, KEY_PERIOD)); 963 KeyMap.push_back(SKeyMap(SDLK_PERIOD, KEY_PERIOD));
964 964
965 // some special keys missing 965 // some special keys missing
966 966
967 KeyMap.sort(); 967 KeyMap.sort();
968} 968}
969 969
970} // end namespace irr 970} // end namespace irr
971 971
972#endif // _IRR_COMPILE_WITH_SDL_DEVICE_ 972#endif // _IRR_COMPILE_WITH_SDL_DEVICE_
973 973