1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #include "IrrCompileConfig.h"
\r
7 #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
\r
9 #include "CIrrDeviceSDL.h"
\r
10 #include "IEventReceiver.h"
\r
11 #include "IGUIElement.h"
\r
12 #include "IGUIEnvironment.h"
\r
15 #include "irrString.h"
\r
16 #include "Keycodes.h"
\r
17 #include "COSOperator.h"
\r
20 #include "SIrrCreationParameters.h"
\r
21 #include <SDL_video.h>
\r
23 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
24 #ifdef _IRR_COMPILE_WITH_OGLES2_
\r
25 #include "CEGLManager.h"
\r
27 #include <emscripten.h>
\r
30 #ifdef _IRR_COMPILE_WITH_OPENGL_
\r
31 #include "CSDLManager.h"
\r
34 static int SDLDeviceInstances = 0;
\r
40 #ifdef _IRR_COMPILE_WITH_OPENGL_
\r
41 IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
\r
44 #ifdef _IRR_COMPILE_WITH_OGLES2_
\r
45 IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
\r
48 #ifdef _IRR_COMPILE_WITH_WEBGL1_
\r
49 IVideoDriver* createWebGL1Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
\r
51 } // end namespace video
\r
53 } // end namespace irr
\r
58 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
59 EM_BOOL CIrrDeviceSDL::MouseUpDownCallback(int eventType, const EmscriptenMouseEvent * event, void* userData)
\r
61 // We need this callback so far only because otherwise "emscripten_request_pointerlock" calls will
\r
62 // fail as their request are infinitely deferred.
\r
63 // Not exactly certain why, maybe SDL does catch those mouse-events otherwise and not pass them on.
\r
67 EM_BOOL CIrrDeviceSDL::MouseEnterCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
\r
69 CIrrDeviceSDL * This = static_cast<CIrrDeviceSDL*>(userData);
\r
73 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
\r
74 irrevent.MouseInput.Event = irr::EMIE_MOUSE_ENTER_CANVAS;
\r
75 This->MouseX = irrevent.MouseInput.X = mouseEvent->canvasX;
\r
76 This->MouseY = irrevent.MouseInput.Y = mouseEvent->canvasY;
\r
77 This->MouseXRel = mouseEvent->movementX; // should be 0 I guess? Or can it enter while pointer is locked()?
\r
78 This->MouseYRel = mouseEvent->movementY;
\r
79 irrevent.MouseInput.ButtonStates = This->MouseButtonStates; // TODO: not correct, but couldn't figure out the bitset of mouseEvent->buttons yet.
\r
80 irrevent.MouseInput.Shift = mouseEvent->shiftKey;
\r
81 irrevent.MouseInput.Control = mouseEvent->ctrlKey;
\r
83 This->postEventFromUser(irrevent);
\r
88 EM_BOOL CIrrDeviceSDL::MouseLeaveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
\r
90 CIrrDeviceSDL * This = static_cast<CIrrDeviceSDL*>(userData);
\r
94 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
\r
95 irrevent.MouseInput.Event = irr::EMIE_MOUSE_LEAVE_CANVAS;
\r
96 This->MouseX = irrevent.MouseInput.X = mouseEvent->canvasX;
\r
97 This->MouseY = irrevent.MouseInput.Y = mouseEvent->canvasY;
\r
98 This->MouseXRel = mouseEvent->movementX; // should be 0 I guess? Or can it enter while pointer is locked()?
\r
99 This->MouseYRel = mouseEvent->movementY;
\r
100 irrevent.MouseInput.ButtonStates = This->MouseButtonStates; // TODO: not correct, but couldn't figure out the bitset of mouseEvent->buttons yet.
\r
101 irrevent.MouseInput.Shift = mouseEvent->shiftKey;
\r
102 irrevent.MouseInput.Control = mouseEvent->ctrlKey;
\r
104 This->postEventFromUser(irrevent);
\r
111 bool CIrrDeviceSDL::keyIsKnownSpecial(EKEY_CODE key)
\r
115 // keys which are known to have safe special character interpretation
\r
116 // could need changes over time (removals and additions!)
\r
172 int CIrrDeviceSDL::findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key) {
\r
173 // SDL in-place ORs values with no character representation with 1<<30
\r
174 // https://wiki.libsdl.org/SDL2/SDLKeycodeLookup
\r
175 if (assumedChar & (1<<30))
\r
190 return assumedChar;
\r
194 void CIrrDeviceSDL::resetReceiveTextInputEvents() {
\r
195 gui::IGUIElement *elem = GUIEnvironment->getFocus();
\r
196 if (elem && elem->acceptsIME())
\r
197 SDL_StartTextInput();
\r
199 SDL_StopTextInput();
\r
203 CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
\r
204 : CIrrDeviceStub(param),
\r
205 Window((SDL_Window*)param.WindowId), SDL_Flags(0),
\r
206 MouseX(0), MouseY(0), MouseXRel(0), MouseYRel(0), MouseButtonStates(0),
\r
207 Width(param.WindowSize.Width), Height(param.WindowSize.Height),
\r
208 Resizable(param.WindowResizable == 1 ? true : false)
\r
211 setDebugName("CIrrDeviceSDL");
\r
214 if ( ++SDLDeviceInstances == 1 )
\r
216 u32 flags = SDL_INIT_TIMER | SDL_INIT_EVENTS;
\r
217 if (CreationParams.DriverType != video::EDT_NULL)
\r
218 flags |= SDL_INIT_VIDEO;
\r
219 #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
\r
220 flags |= SDL_INIT_JOYSTICK;
\r
222 if (SDL_Init(flags) < 0)
\r
224 os::Printer::log( "Unable to initialize SDL!", SDL_GetError());
\r
229 os::Printer::log("SDL initialized", ELL_INFORMATION);
\r
236 if (CreationParams.Fullscreen) {
\r
237 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
238 SDL_Flags |= SDL_WINDOW_FULLSCREEN;
\r
240 SDL_Flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
\r
244 SDL_Flags |= SDL_WINDOW_RESIZABLE;
\r
245 if (CreationParams.WindowMaximized)
\r
246 SDL_Flags |= SDL_WINDOW_MAXIMIZED;
\r
248 if (CreationParams.DriverType == video::EDT_OPENGL)
\r
250 SDL_Flags |= SDL_WINDOW_OPENGL;
\r
251 if (!CreationParams.Doublebuffer)
\r
252 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
\r
254 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
255 SDL_Flags |= SDL_WINDOW_OPENGL;
\r
256 #endif //_IRR_EMSCRIPTEN_PLATFORM_
\r
259 if (CreationParams.DriverType != video::EDT_NULL)
\r
261 // create the window, only if we do not use the null device
\r
266 SDL_VERSION(&Info.version);
\r
268 #ifndef _IRR_EMSCRIPTEN_PLATFORM_
\r
269 SDL_GetWindowWMInfo(Window,&Info);
\r
270 #endif //_IRR_EMSCRIPTEN_PLATFORM_
\r
271 core::stringc sdlversion = "SDL Version ";
\r
272 sdlversion += Info.version.major;
\r
274 sdlversion += Info.version.minor;
\r
276 sdlversion += Info.version.patch;
\r
278 Operator = new COSOperator(sdlversion);
\r
279 if (SDLDeviceInstances == 1) {
\r
280 os::Printer::log(sdlversion.c_str(), ELL_INFORMATION);
\r
283 // create cursor control
\r
284 CursorControl = new CCursorControl(this);
\r
290 createGUIAndScene();
\r
291 VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
\r
297 CIrrDeviceSDL::~CIrrDeviceSDL()
\r
299 if ( --SDLDeviceInstances == 0 )
\r
301 #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
\r
302 const u32 numJoysticks = Joysticks.size();
\r
303 for (u32 i=0; i<numJoysticks; ++i)
\r
304 SDL_JoystickClose(Joysticks[i]);
\r
308 SDL_GL_MakeCurrent(Window, NULL);
\r
309 SDL_GL_DeleteContext(Context);
\r
310 SDL_DestroyWindow(Window);
\r
314 os::Printer::log("Quit SDL", ELL_INFORMATION);
\r
318 void CIrrDeviceSDL::logAttributes()
\r
320 core::stringc sdl_attr("SDL attribs:");
\r
322 if ( SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value ) == 0 )
\r
323 sdl_attr += core::stringc(" r:") + core::stringc(value);
\r
324 if ( SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value ) == 0 )
\r
325 sdl_attr += core::stringc(" g:") + core::stringc(value);
\r
326 if ( SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value ) == 0 )
\r
327 sdl_attr += core::stringc(" b:") + core::stringc(value);
\r
328 if ( SDL_GL_GetAttribute( SDL_GL_ALPHA_SIZE, &value ) == 0 )
\r
329 sdl_attr += core::stringc(" a:") + core::stringc(value);
\r
331 if ( SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value) == 0 )
\r
332 sdl_attr += core::stringc(" depth:") + core::stringc(value);
\r
333 if ( SDL_GL_GetAttribute( SDL_GL_STENCIL_SIZE, &value ) == 0 )
\r
334 sdl_attr += core::stringc(" stencil:") + core::stringc(value);
\r
335 if ( SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value ) == 0 )
\r
336 sdl_attr += core::stringc(" doublebuf:") + core::stringc(value);
\r
337 if ( SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value ) == 0 )
\r
338 sdl_attr += core::stringc(" aa:") + core::stringc(value);
\r
339 if ( SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value ) == 0 )
\r
340 sdl_attr += core::stringc(" aa-samples:") + core::stringc(value);
\r
342 os::Printer::log(sdl_attr.c_str());
\r
345 bool CIrrDeviceSDL::createWindow()
\r
347 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
348 if ( Width != 0 || Height != 0 )
\r
349 emscripten_set_canvas_size( Width, Height);
\r
353 emscripten_get_canvas_size(&w, &h, &fs);
\r
358 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
\r
359 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
\r
360 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
\r
361 SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?8:0 );
\r
363 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);
\r
364 SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0);
\r
365 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, CreationParams.Doublebuffer ? 1 : 0);
\r
367 if (CreationParams.AntiAlias>1)
\r
369 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
\r
370 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias );
\r
374 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
\r
375 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
\r
378 SDL_CreateWindowAndRenderer(0, 0, SDL_Flags, &Window, &Renderer); // 0,0 will use the canvas size
\r
382 // "#canvas" is for the opengl context
\r
383 emscripten_set_mousedown_callback("#canvas", (void*)this, true, MouseUpDownCallback);
\r
384 emscripten_set_mouseup_callback("#canvas", (void*)this, true, MouseUpDownCallback);
\r
385 emscripten_set_mouseenter_callback("#canvas", (void*)this, false, MouseEnterCallback);
\r
386 emscripten_set_mouseleave_callback("#canvas", (void*)this, false, MouseLeaveCallback);
\r
389 #else // !_IRR_EMSCRIPTEN_PLATFORM_
\r
393 if (CreationParams.DriverType == video::EDT_OPENGL) {
\r
394 if (CreationParams.Bits == 16) {
\r
395 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 4);
\r
396 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 4);
\r
397 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 4);
\r
398 SDL_GL_SetAttribute(
\r
399 SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 1 : 0);
\r
401 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
\r
402 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
\r
403 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
\r
404 SDL_GL_SetAttribute(
\r
405 SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 8 : 0);
\r
407 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);
\r
408 if (CreationParams.Doublebuffer)
\r
409 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
\r
410 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0);
\r
411 if (CreationParams.Stereobuffer)
\r
412 SDL_GL_SetAttribute(SDL_GL_STEREO, 1);
\r
413 if (CreationParams.AntiAlias > 1) {
\r
414 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
\r
415 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias);
\r
418 Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
\r
419 if (!Window && CreationParams.AntiAlias > 1) {
\r
420 while (--CreationParams.AntiAlias > 1) {
\r
421 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias);
\r
422 Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
\r
427 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
\r
428 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
\r
429 Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
\r
431 os::Printer::log("AntiAliasing disabled due to lack of support!");
\r
437 Context = SDL_GL_CreateContext(Window);
\r
439 } else if (!Window)
\r
440 Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
\r
442 if ( !Window && CreationParams.Doublebuffer)
\r
444 // Try single buffer
\r
445 if (CreationParams.DriverType == video::EDT_OPENGL)
\r
446 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
\r
447 Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
\r
451 os::Printer::log( "Could not initialize display!" );
\r
456 #endif // !_IRR_EMSCRIPTEN_PLATFORM_
\r
460 //! create the driver
\r
461 void CIrrDeviceSDL::createDriver()
\r
463 switch(CreationParams.DriverType)
\r
465 case video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS:
\r
466 os::Printer::log("DIRECT3D8 Driver is no longer supported in Irrlicht. Try another one.", ELL_ERROR);
\r
469 case video::EDT_DIRECT3D9:
\r
470 #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
\r
471 os::Printer::log("SDL device does not support DIRECT3D9 driver. Try another one.", ELL_ERROR);
\r
473 os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
\r
474 #endif // _IRR_COMPILE_WITH_DIRECT3D_9_
\r
478 case video::EDT_OPENGL:
\r
479 #ifdef _IRR_COMPILE_WITH_OPENGL_
\r
480 ContextManager = new video::CSDLManager(this);
\r
481 VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager);
\r
483 os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
\r
487 case video::EDT_OGLES2:
\r
488 #if defined(_IRR_COMPILE_WITH_OGLES2_) && defined(_IRR_EMSCRIPTEN_PLATFORM_)
\r
490 video::SExposedVideoData data;
\r
492 ContextManager = new video::CEGLManager();
\r
493 ContextManager->initialize(CreationParams, data);
\r
495 VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager);
\r
498 os::Printer::log("No OpenGL-ES2 support compiled in.", ELL_ERROR);
\r
502 case video::EDT_WEBGL1:
\r
503 #if defined(_IRR_COMPILE_WITH_WEBGL1_) && defined(_IRR_EMSCRIPTEN_PLATFORM_)
\r
505 video::SExposedVideoData data;
\r
507 ContextManager = new video::CEGLManager();
\r
508 ContextManager->initialize(CreationParams, data);
\r
510 VideoDriver = video::createWebGL1Driver(CreationParams, FileSystem, ContextManager);
\r
513 os::Printer::log("No WebGL1 support compiled in.", ELL_ERROR);
\r
517 case video::EDT_NULL:
\r
518 VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
\r
522 os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
\r
526 // In case we got the size from the canvas
\r
527 if ( VideoDriver && CreationParams.WindowSize.Width == 0 && CreationParams.WindowSize.Height == 0 && Width > 0 && Height > 0 )
\r
529 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
530 SDL_CreateWindowAndRenderer(Width, Height, SDL_Flags, &Window, &Renderer);
\r
531 #else //_IRR_EMSCRIPTEN_PLATFORM_
\r
532 Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
\r
533 #endif //_IRR_EMSCRIPTEN_PLATFOR
\r
534 VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
\r
539 //! runs the device. Returns false if device wants to be deleted
\r
540 bool CIrrDeviceSDL::run()
\r
545 SDL_Event SDL_event;
\r
547 while ( !Close && SDL_PollEvent( &SDL_event ) )
\r
549 // os::Printer::log("event: ", core::stringc((int)SDL_event.type).c_str(), ELL_INFORMATION); // just for debugging
\r
551 switch ( SDL_event.type )
\r
553 case SDL_MOUSEMOTION: {
\r
554 SDL_Keymod keymod = SDL_GetModState();
\r
556 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
\r
557 irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
\r
558 MouseX = irrevent.MouseInput.X = SDL_event.motion.x;
\r
559 MouseY = irrevent.MouseInput.Y = SDL_event.motion.y;
\r
560 MouseXRel = SDL_event.motion.xrel;
\r
561 MouseYRel = SDL_event.motion.yrel;
\r
562 irrevent.MouseInput.ButtonStates = MouseButtonStates;
\r
563 irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
\r
564 irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
\r
566 postEventFromUser(irrevent);
\r
569 case SDL_MOUSEWHEEL: {
\r
570 SDL_Keymod keymod = SDL_GetModState();
\r
572 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
\r
573 irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
\r
574 irrevent.MouseInput.Wheel = static_cast<float>(SDL_event.wheel.y);
\r
575 irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
\r
576 irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
\r
577 irrevent.MouseInput.X = MouseX;
\r
578 irrevent.MouseInput.Y = MouseY;
\r
580 postEventFromUser(irrevent);
\r
583 case SDL_MOUSEBUTTONDOWN:
\r
584 case SDL_MOUSEBUTTONUP: {
\r
585 SDL_Keymod keymod = SDL_GetModState();
\r
587 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
\r
588 irrevent.MouseInput.X = SDL_event.button.x;
\r
589 irrevent.MouseInput.Y = SDL_event.button.y;
\r
590 irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
\r
591 irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
\r
593 irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
\r
596 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
597 // Handle mouselocking in emscripten in Windowed mode.
\r
598 // In fullscreen SDL will handle it.
\r
599 // The behavior we want windowed is - when the canvas was clicked then
\r
600 // we will lock the mouse-pointer if it should be invisible.
\r
601 // For security reasons this will be delayed until the next mouse-up event.
\r
602 // We do not pass on this event as we don't want the activation click to do anything.
\r
603 if ( SDL_event.type == SDL_MOUSEBUTTONDOWN && !isFullscreen() )
\r
605 EmscriptenPointerlockChangeEvent pointerlockStatus; // let's hope that test is not expensive ...
\r
606 if ( emscripten_get_pointerlock_status(&pointerlockStatus) == EMSCRIPTEN_RESULT_SUCCESS )
\r
608 if ( CursorControl->isVisible() && pointerlockStatus.isActive )
\r
610 emscripten_exit_pointerlock();
\r
613 else if ( !CursorControl->isVisible() && !pointerlockStatus.isActive )
\r
615 emscripten_request_pointerlock(0, true);
\r
622 switch(SDL_event.button.button)
\r
624 case SDL_BUTTON_LEFT:
\r
625 if (SDL_event.type == SDL_MOUSEBUTTONDOWN)
\r
627 irrevent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
\r
628 MouseButtonStates |= irr::EMBSM_LEFT;
\r
632 irrevent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;
\r
633 MouseButtonStates &= ~irr::EMBSM_LEFT;
\r
637 case SDL_BUTTON_RIGHT:
\r
638 if (SDL_event.type == SDL_MOUSEBUTTONDOWN)
\r
640 irrevent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN;
\r
641 MouseButtonStates |= irr::EMBSM_RIGHT;
\r
645 irrevent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP;
\r
646 MouseButtonStates &= ~irr::EMBSM_RIGHT;
\r
650 case SDL_BUTTON_MIDDLE:
\r
651 if (SDL_event.type == SDL_MOUSEBUTTONDOWN)
\r
653 irrevent.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN;
\r
654 MouseButtonStates |= irr::EMBSM_MIDDLE;
\r
658 irrevent.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP;
\r
659 MouseButtonStates &= ~irr::EMBSM_MIDDLE;
\r
664 irrevent.MouseInput.ButtonStates = MouseButtonStates;
\r
666 if (irrevent.MouseInput.Event != irr::EMIE_MOUSE_MOVED)
\r
668 postEventFromUser(irrevent);
\r
670 if ( irrevent.MouseInput.Event >= EMIE_LMOUSE_PRESSED_DOWN && irrevent.MouseInput.Event <= EMIE_MMOUSE_PRESSED_DOWN )
\r
672 u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y, irrevent.MouseInput.Event);
\r
675 irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_DOUBLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
\r
676 postEventFromUser(irrevent);
\r
678 else if ( clicks == 3 )
\r
680 irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_TRIPLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
\r
681 postEventFromUser(irrevent);
\r
688 case SDL_TEXTINPUT:
\r
690 irrevent.EventType = irr::EET_STRING_INPUT_EVENT;
\r
691 irrevent.StringInput.Str = new core::stringw();
\r
692 irr::core::multibyteToWString(*irrevent.StringInput.Str, SDL_event.text.text);
\r
693 postEventFromUser(irrevent);
\r
694 delete irrevent.StringInput.Str;
\r
695 irrevent.StringInput.Str = NULL;
\r
703 mp.SDLKey = SDL_event.key.keysym.sym;
\r
704 s32 idx = KeyMap.binary_search(mp);
\r
708 key = (EKEY_CODE)0;
\r
710 key = (EKEY_CODE)KeyMap[idx].Win32Key;
\r
712 // Make sure to only input special characters if something is in focus, as SDL_TEXTINPUT handles normal unicode already
\r
713 if (SDL_IsTextInputActive() && !keyIsKnownSpecial(key) && (SDL_event.key.keysym.mod & KMOD_CTRL) == 0)
\r
716 #ifdef _IRR_WINDOWS_API_
\r
717 // handle alt+f4 in Windows, because SDL seems not to
\r
718 if ( (SDL_event.key.keysym.mod & KMOD_LALT) && key == KEY_F4)
\r
724 irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
\r
725 irrevent.KeyInput.Key = key;
\r
726 irrevent.KeyInput.PressedDown = (SDL_event.type == SDL_KEYDOWN);
\r
727 irrevent.KeyInput.Shift = (SDL_event.key.keysym.mod & KMOD_SHIFT) != 0;
\r
728 irrevent.KeyInput.Control = (SDL_event.key.keysym.mod & KMOD_CTRL ) != 0;
\r
729 irrevent.KeyInput.Char = findCharToPassToIrrlicht(mp.SDLKey, key);
\r
730 postEventFromUser(irrevent);
\r
738 case SDL_WINDOWEVENT:
\r
739 switch (SDL_event.window.event)
\r
741 case SDL_WINDOWEVENT_RESIZED:
\r
742 if ((SDL_event.window.data1 != (int)Width) || (SDL_event.window.data2 != (int)Height))
\r
744 Width = SDL_event.window.data1;
\r
745 Height = SDL_event.window.data2;
\r
747 VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
\r
752 case SDL_USEREVENT:
\r
753 irrevent.EventType = irr::EET_USER_EVENT;
\r
754 irrevent.UserEvent.UserData1 = reinterpret_cast<uintptr_t>(SDL_event.user.data1);
\r
755 irrevent.UserEvent.UserData2 = reinterpret_cast<uintptr_t>(SDL_event.user.data2);
\r
757 postEventFromUser(irrevent);
\r
763 resetReceiveTextInputEvents();
\r
766 #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
\r
767 // TODO: Check if the multiple open/close calls are too expensive, then
\r
768 // open/close in the constructor/destructor instead
\r
770 // update joystick states manually
\r
771 SDL_JoystickUpdate();
\r
772 // we'll always send joystick input events...
\r
774 joyevent.EventType = EET_JOYSTICK_INPUT_EVENT;
\r
775 for (u32 i=0; i<Joysticks.size(); ++i)
\r
777 SDL_Joystick* joystick = Joysticks[i];
\r
781 // query all buttons
\r
782 const int numButtons = core::min_(SDL_JoystickNumButtons(joystick), 32);
\r
783 joyevent.JoystickEvent.ButtonStates=0;
\r
784 for (j=0; j<numButtons; ++j)
\r
785 joyevent.JoystickEvent.ButtonStates |= (SDL_JoystickGetButton(joystick, j)<<j);
\r
787 // query all axes, already in correct range
\r
788 const int numAxes = core::min_(SDL_JoystickNumAxes(joystick), (int)SEvent::SJoystickEvent::NUMBER_OF_AXES);
\r
789 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X]=0;
\r
790 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y]=0;
\r
791 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z]=0;
\r
792 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_R]=0;
\r
793 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_U]=0;
\r
794 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_V]=0;
\r
795 for (j=0; j<numAxes; ++j)
\r
796 joyevent.JoystickEvent.Axis[j] = SDL_JoystickGetAxis(joystick, j);
\r
798 // we can only query one hat, SDL only supports 8 directions
\r
799 if (SDL_JoystickNumHats(joystick)>0)
\r
801 switch (SDL_JoystickGetHat(joystick, 0))
\r
804 joyevent.JoystickEvent.POV=0;
\r
806 case SDL_HAT_RIGHTUP:
\r
807 joyevent.JoystickEvent.POV=4500;
\r
809 case SDL_HAT_RIGHT:
\r
810 joyevent.JoystickEvent.POV=9000;
\r
812 case SDL_HAT_RIGHTDOWN:
\r
813 joyevent.JoystickEvent.POV=13500;
\r
816 joyevent.JoystickEvent.POV=18000;
\r
818 case SDL_HAT_LEFTDOWN:
\r
819 joyevent.JoystickEvent.POV=22500;
\r
822 joyevent.JoystickEvent.POV=27000;
\r
824 case SDL_HAT_LEFTUP:
\r
825 joyevent.JoystickEvent.POV=31500;
\r
827 case SDL_HAT_CENTERED:
\r
829 joyevent.JoystickEvent.POV=65535;
\r
835 joyevent.JoystickEvent.POV=65535;
\r
838 // we map the number directly
\r
839 joyevent.JoystickEvent.Joystick=static_cast<u8>(i);
\r
840 // now post the event
\r
841 postEventFromUser(joyevent);
\r
842 // and close the joystick
\r
849 //! Activate any joysticks, and generate events for them.
\r
850 bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
\r
852 #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
\r
853 joystickInfo.clear();
\r
855 // we can name up to 256 different joysticks
\r
856 const int numJoysticks = core::min_(SDL_NumJoysticks(), 256);
\r
857 Joysticks.reallocate(numJoysticks);
\r
858 joystickInfo.reallocate(numJoysticks);
\r
861 for (; joystick<numJoysticks; ++joystick)
\r
863 Joysticks.push_back( SDL_JoystickOpen(joystick));
\r
864 SJoystickInfo info;
\r
866 info.Joystick = joystick;
\r
867 info.Axes = SDL_JoystickNumAxes(Joysticks[joystick]);
\r
868 info.Buttons = SDL_JoystickNumButtons(Joysticks[joystick]);
\r
869 info.Name = SDL_JoystickName(Joysticks[joystick]);
\r
870 info.PovHat = (SDL_JoystickNumHats(Joysticks[joystick]) > 0)
\r
871 ? SJoystickInfo::POV_HAT_PRESENT : SJoystickInfo::POV_HAT_ABSENT;
\r
873 joystickInfo.push_back(info);
\r
876 for(joystick = 0; joystick < (int)joystickInfo.size(); ++joystick)
\r
878 char logString[256];
\r
879 snprintf_irr(logString, sizeof(logString), "Found joystick %d, %d axes, %d buttons '%s'",
\r
880 joystick, joystickInfo[joystick].Axes,
\r
881 joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str());
\r
882 os::Printer::log(logString, ELL_INFORMATION);
\r
887 #endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
\r
892 void CIrrDeviceSDL::SwapWindow()
\r
894 SDL_GL_SwapWindow(Window);
\r
899 //! pause execution temporarily
\r
900 void CIrrDeviceSDL::yield()
\r
906 //! pause execution for a specified time
\r
907 void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer)
\r
909 const bool wasStopped = Timer ? Timer->isStopped() : true;
\r
910 if (pauseTimer && !wasStopped)
\r
915 if (pauseTimer && !wasStopped)
\r
920 //! sets the caption of the window
\r
921 void CIrrDeviceSDL::setWindowCaption(const wchar_t* text)
\r
923 core::stringc textc;
\r
924 core::wStringToMultibyte(textc, text);
\r
925 SDL_SetWindowTitle(Window, textc.c_str());
\r
929 //! notifies the device that it should close itself
\r
930 void CIrrDeviceSDL::closeDevice()
\r
936 //! Sets if the window should be resizable in windowed mode.
\r
937 void CIrrDeviceSDL::setResizable(bool resize)
\r
939 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
940 os::Printer::log("Resizable not available on the web." , ELL_WARNING);
\r
942 #else // !_IRR_EMSCRIPTEN_PLATFORM_
\r
943 if (resize != Resizable) {
\r
945 SDL_Flags |= SDL_WINDOW_RESIZABLE;
\r
947 SDL_Flags &= ~SDL_WINDOW_RESIZABLE;
\r
950 SDL_SetWindowResizable(Window, (SDL_bool)resize);
\r
952 Resizable = resize;
\r
954 #endif // !_IRR_EMSCRIPTEN_PLATFORM_
\r
958 //! Minimizes window if possible
\r
959 void CIrrDeviceSDL::minimizeWindow()
\r
962 SDL_MinimizeWindow(Window);
\r
966 //! Maximize window
\r
967 void CIrrDeviceSDL::maximizeWindow()
\r
970 SDL_MaximizeWindow(Window);
\r
973 //! Get the position of this window on screen
\r
974 core::position2di CIrrDeviceSDL::getWindowPosition()
\r
976 return core::position2di(-1, -1);
\r
980 //! Restore original window size
\r
981 void CIrrDeviceSDL::restoreWindow()
\r
984 SDL_RestoreWindow(Window);
\r
987 bool CIrrDeviceSDL::isWindowMaximized() const
\r
989 return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_MAXIMIZED) != 0;
\r
992 bool CIrrDeviceSDL::isFullscreen() const
\r
994 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
995 return SDL_GetWindowFlags(0) == SDL_WINDOW_FULLSCREEN;
\r
998 return CIrrDeviceStub::isFullscreen();
\r
1003 //! returns if window is active. if not, nothing need to be drawn
\r
1004 bool CIrrDeviceSDL::isWindowActive() const
\r
1006 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
1007 // Hidden test only does something in some browsers (when tab in background or window is minimized)
\r
1008 // In other browsers code automatically doesn't seem to be called anymore.
\r
1009 EmscriptenVisibilityChangeEvent emVisibility;
\r
1010 if ( emscripten_get_visibility_status(&emVisibility) == EMSCRIPTEN_RESULT_SUCCESS)
\r
1012 if ( emVisibility.hidden )
\r
1016 const u32 windowFlags = SDL_GetWindowFlags(Window);
\r
1017 return windowFlags & SDL_WINDOW_SHOWN && windowFlags & SDL_WINDOW_INPUT_FOCUS;
\r
1021 //! returns if window has focus.
\r
1022 bool CIrrDeviceSDL::isWindowFocused() const
\r
1024 return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_INPUT_FOCUS) != 0;
\r
1028 //! returns if window is minimized.
\r
1029 bool CIrrDeviceSDL::isWindowMinimized() const
\r
1031 return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_MINIMIZED) != 0;
\r
1035 //! returns color format of the window.
\r
1036 video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const
\r
1040 SDL_Surface *surface = SDL_GetWindowSurface(Window);
\r
1041 if (surface->format->BitsPerPixel == 16)
\r
1043 if (surface->format->Amask != 0)
\r
1044 return video::ECF_A1R5G5B5;
\r
1046 return video::ECF_R5G6B5;
\r
1050 if (surface->format->Amask != 0)
\r
1051 return video::ECF_A8R8G8B8;
\r
1053 return video::ECF_R8G8B8;
\r
1057 return CIrrDeviceStub::getColorFormat();
\r
1061 void CIrrDeviceSDL::createKeyMap()
\r
1063 // I don't know if this is the best method to create
\r
1064 // the lookuptable, but I'll leave it like that until
\r
1065 // I find a better version.
\r
1067 KeyMap.reallocate(105);
\r
1069 // buttons missing
\r
1071 KeyMap.push_back(SKeyMap(SDLK_BACKSPACE, KEY_BACK));
\r
1072 KeyMap.push_back(SKeyMap(SDLK_TAB, KEY_TAB));
\r
1073 KeyMap.push_back(SKeyMap(SDLK_CLEAR, KEY_CLEAR));
\r
1074 KeyMap.push_back(SKeyMap(SDLK_RETURN, KEY_RETURN));
\r
1076 // combined modifiers missing
\r
1078 KeyMap.push_back(SKeyMap(SDLK_PAUSE, KEY_PAUSE));
\r
1079 KeyMap.push_back(SKeyMap(SDLK_CAPSLOCK, KEY_CAPITAL));
\r
1081 // asian letter keys missing
\r
1083 KeyMap.push_back(SKeyMap(SDLK_ESCAPE, KEY_ESCAPE));
\r
1085 // asian letter keys missing
\r
1087 KeyMap.push_back(SKeyMap(SDLK_SPACE, KEY_SPACE));
\r
1088 KeyMap.push_back(SKeyMap(SDLK_PAGEUP, KEY_PRIOR));
\r
1089 KeyMap.push_back(SKeyMap(SDLK_PAGEDOWN, KEY_NEXT));
\r
1090 KeyMap.push_back(SKeyMap(SDLK_END, KEY_END));
\r
1091 KeyMap.push_back(SKeyMap(SDLK_HOME, KEY_HOME));
\r
1092 KeyMap.push_back(SKeyMap(SDLK_LEFT, KEY_LEFT));
\r
1093 KeyMap.push_back(SKeyMap(SDLK_UP, KEY_UP));
\r
1094 KeyMap.push_back(SKeyMap(SDLK_RIGHT, KEY_RIGHT));
\r
1095 KeyMap.push_back(SKeyMap(SDLK_DOWN, KEY_DOWN));
\r
1098 KeyMap.push_back(SKeyMap(SDLK_PRINTSCREEN, KEY_PRINT));
\r
1099 // execute missing
\r
1100 KeyMap.push_back(SKeyMap(SDLK_PRINTSCREEN, KEY_SNAPSHOT));
\r
1102 KeyMap.push_back(SKeyMap(SDLK_INSERT, KEY_INSERT));
\r
1103 KeyMap.push_back(SKeyMap(SDLK_DELETE, KEY_DELETE));
\r
1104 KeyMap.push_back(SKeyMap(SDLK_HELP, KEY_HELP));
\r
1106 KeyMap.push_back(SKeyMap(SDLK_0, KEY_KEY_0));
\r
1107 KeyMap.push_back(SKeyMap(SDLK_1, KEY_KEY_1));
\r
1108 KeyMap.push_back(SKeyMap(SDLK_2, KEY_KEY_2));
\r
1109 KeyMap.push_back(SKeyMap(SDLK_3, KEY_KEY_3));
\r
1110 KeyMap.push_back(SKeyMap(SDLK_4, KEY_KEY_4));
\r
1111 KeyMap.push_back(SKeyMap(SDLK_5, KEY_KEY_5));
\r
1112 KeyMap.push_back(SKeyMap(SDLK_6, KEY_KEY_6));
\r
1113 KeyMap.push_back(SKeyMap(SDLK_7, KEY_KEY_7));
\r
1114 KeyMap.push_back(SKeyMap(SDLK_8, KEY_KEY_8));
\r
1115 KeyMap.push_back(SKeyMap(SDLK_9, KEY_KEY_9));
\r
1117 KeyMap.push_back(SKeyMap(SDLK_a, KEY_KEY_A));
\r
1118 KeyMap.push_back(SKeyMap(SDLK_b, KEY_KEY_B));
\r
1119 KeyMap.push_back(SKeyMap(SDLK_c, KEY_KEY_C));
\r
1120 KeyMap.push_back(SKeyMap(SDLK_d, KEY_KEY_D));
\r
1121 KeyMap.push_back(SKeyMap(SDLK_e, KEY_KEY_E));
\r
1122 KeyMap.push_back(SKeyMap(SDLK_f, KEY_KEY_F));
\r
1123 KeyMap.push_back(SKeyMap(SDLK_g, KEY_KEY_G));
\r
1124 KeyMap.push_back(SKeyMap(SDLK_h, KEY_KEY_H));
\r
1125 KeyMap.push_back(SKeyMap(SDLK_i, KEY_KEY_I));
\r
1126 KeyMap.push_back(SKeyMap(SDLK_j, KEY_KEY_J));
\r
1127 KeyMap.push_back(SKeyMap(SDLK_k, KEY_KEY_K));
\r
1128 KeyMap.push_back(SKeyMap(SDLK_l, KEY_KEY_L));
\r
1129 KeyMap.push_back(SKeyMap(SDLK_m, KEY_KEY_M));
\r
1130 KeyMap.push_back(SKeyMap(SDLK_n, KEY_KEY_N));
\r
1131 KeyMap.push_back(SKeyMap(SDLK_o, KEY_KEY_O));
\r
1132 KeyMap.push_back(SKeyMap(SDLK_p, KEY_KEY_P));
\r
1133 KeyMap.push_back(SKeyMap(SDLK_q, KEY_KEY_Q));
\r
1134 KeyMap.push_back(SKeyMap(SDLK_r, KEY_KEY_R));
\r
1135 KeyMap.push_back(SKeyMap(SDLK_s, KEY_KEY_S));
\r
1136 KeyMap.push_back(SKeyMap(SDLK_t, KEY_KEY_T));
\r
1137 KeyMap.push_back(SKeyMap(SDLK_u, KEY_KEY_U));
\r
1138 KeyMap.push_back(SKeyMap(SDLK_v, KEY_KEY_V));
\r
1139 KeyMap.push_back(SKeyMap(SDLK_w, KEY_KEY_W));
\r
1140 KeyMap.push_back(SKeyMap(SDLK_x, KEY_KEY_X));
\r
1141 KeyMap.push_back(SKeyMap(SDLK_y, KEY_KEY_Y));
\r
1142 KeyMap.push_back(SKeyMap(SDLK_z, KEY_KEY_Z));
\r
1144 KeyMap.push_back(SKeyMap(SDLK_LGUI, KEY_LWIN));
\r
1145 KeyMap.push_back(SKeyMap(SDLK_RGUI, KEY_RWIN));
\r
1147 KeyMap.push_back(SKeyMap(SDLK_POWER, KEY_SLEEP)); //??
\r
1149 KeyMap.push_back(SKeyMap(SDLK_KP_0, KEY_NUMPAD0));
\r
1150 KeyMap.push_back(SKeyMap(SDLK_KP_1, KEY_NUMPAD1));
\r
1151 KeyMap.push_back(SKeyMap(SDLK_KP_2, KEY_NUMPAD2));
\r
1152 KeyMap.push_back(SKeyMap(SDLK_KP_3, KEY_NUMPAD3));
\r
1153 KeyMap.push_back(SKeyMap(SDLK_KP_4, KEY_NUMPAD4));
\r
1154 KeyMap.push_back(SKeyMap(SDLK_KP_5, KEY_NUMPAD5));
\r
1155 KeyMap.push_back(SKeyMap(SDLK_KP_6, KEY_NUMPAD6));
\r
1156 KeyMap.push_back(SKeyMap(SDLK_KP_7, KEY_NUMPAD7));
\r
1157 KeyMap.push_back(SKeyMap(SDLK_KP_8, KEY_NUMPAD8));
\r
1158 KeyMap.push_back(SKeyMap(SDLK_KP_9, KEY_NUMPAD9));
\r
1159 KeyMap.push_back(SKeyMap(SDLK_KP_MULTIPLY, KEY_MULTIPLY));
\r
1160 KeyMap.push_back(SKeyMap(SDLK_KP_PLUS, KEY_ADD));
\r
1161 // KeyMap.push_back(SKeyMap(SDLK_KP_, KEY_SEPARATOR));
\r
1162 KeyMap.push_back(SKeyMap(SDLK_KP_MINUS, KEY_SUBTRACT));
\r
1163 KeyMap.push_back(SKeyMap(SDLK_KP_PERIOD, KEY_DECIMAL));
\r
1164 KeyMap.push_back(SKeyMap(SDLK_KP_DIVIDE, KEY_DIVIDE));
\r
1166 KeyMap.push_back(SKeyMap(SDLK_F1, KEY_F1));
\r
1167 KeyMap.push_back(SKeyMap(SDLK_F2, KEY_F2));
\r
1168 KeyMap.push_back(SKeyMap(SDLK_F3, KEY_F3));
\r
1169 KeyMap.push_back(SKeyMap(SDLK_F4, KEY_F4));
\r
1170 KeyMap.push_back(SKeyMap(SDLK_F5, KEY_F5));
\r
1171 KeyMap.push_back(SKeyMap(SDLK_F6, KEY_F6));
\r
1172 KeyMap.push_back(SKeyMap(SDLK_F7, KEY_F7));
\r
1173 KeyMap.push_back(SKeyMap(SDLK_F8, KEY_F8));
\r
1174 KeyMap.push_back(SKeyMap(SDLK_F9, KEY_F9));
\r
1175 KeyMap.push_back(SKeyMap(SDLK_F10, KEY_F10));
\r
1176 KeyMap.push_back(SKeyMap(SDLK_F11, KEY_F11));
\r
1177 KeyMap.push_back(SKeyMap(SDLK_F12, KEY_F12));
\r
1178 KeyMap.push_back(SKeyMap(SDLK_F13, KEY_F13));
\r
1179 KeyMap.push_back(SKeyMap(SDLK_F14, KEY_F14));
\r
1180 KeyMap.push_back(SKeyMap(SDLK_F15, KEY_F15));
\r
1181 // no higher F-keys
\r
1183 KeyMap.push_back(SKeyMap(SDLK_NUMLOCKCLEAR, KEY_NUMLOCK));
\r
1184 KeyMap.push_back(SKeyMap(SDLK_SCROLLLOCK, KEY_SCROLL));
\r
1185 KeyMap.push_back(SKeyMap(SDLK_LSHIFT, KEY_LSHIFT));
\r
1186 KeyMap.push_back(SKeyMap(SDLK_RSHIFT, KEY_RSHIFT));
\r
1187 KeyMap.push_back(SKeyMap(SDLK_LCTRL, KEY_LCONTROL));
\r
1188 KeyMap.push_back(SKeyMap(SDLK_RCTRL, KEY_RCONTROL));
\r
1189 KeyMap.push_back(SKeyMap(SDLK_LALT, KEY_LMENU));
\r
1190 KeyMap.push_back(SKeyMap(SDLK_RALT, KEY_RMENU));
\r
1192 KeyMap.push_back(SKeyMap(SDLK_PLUS, KEY_PLUS));
\r
1193 KeyMap.push_back(SKeyMap(SDLK_COMMA, KEY_COMMA));
\r
1194 KeyMap.push_back(SKeyMap(SDLK_MINUS, KEY_MINUS));
\r
1195 KeyMap.push_back(SKeyMap(SDLK_PERIOD, KEY_PERIOD));
\r
1197 // some special keys missing
\r
1202 void CIrrDeviceSDL::CCursorControl::initCursors()
\r
1204 Cursors.reserve(gui::ECI_COUNT);
\r
1206 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW)); // ECI_NORMAL
\r
1207 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR)); // ECI_CROSS
\r
1208 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND)); // ECI_HAND
\r
1209 Cursors.emplace_back(nullptr); // ECI_HELP
\r
1210 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM)); // ECI_IBEAM
\r
1211 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO)); // ECI_NO
\r
1212 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT)); // ECI_WAIT
\r
1213 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL)); // ECI_SIZEALL
\r
1214 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW)); // ECI_SIZENESW
\r
1215 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE)); // ECI_SIZENWSE
\r
1216 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS)); // ECI_SIZENS
\r
1217 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE)); // ECI_SIZEWE
\r
1218 Cursors.emplace_back(nullptr); // ECI_UP
\r
1221 } // end namespace irr
\r
1223 #endif // _IRR_COMPILE_WITH_SDL_DEVICE_
\r