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
6 #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
\r
8 #include "CIrrDeviceSDL.h"
\r
9 #include "IEventReceiver.h"
\r
10 #include "IGUIElement.h"
\r
11 #include "IGUIEnvironment.h"
\r
14 #include "irrString.h"
\r
15 #include "Keycodes.h"
\r
16 #include "COSOperator.h"
\r
19 #include "SIrrCreationParameters.h"
\r
20 #include <SDL_video.h>
\r
22 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
23 #ifdef _IRR_COMPILE_WITH_OGLES2_
\r
24 #include "CEGLManager.h"
\r
26 #include <emscripten.h>
\r
29 #ifdef _IRR_COMPILE_WITH_OPENGL_
\r
30 #include "CSDLManager.h"
\r
33 static int SDLDeviceInstances = 0;
\r
39 #ifdef _IRR_COMPILE_WITH_OPENGL_
\r
40 IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
\r
42 static IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager)
\r
44 os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
\r
49 #ifdef ENABLE_OPENGL3
\r
50 IVideoDriver* createOpenGL3Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
\r
52 static IVideoDriver* createOpenGL3Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager)
\r
54 os::Printer::log("No OpenGL 3 support compiled in.", ELL_ERROR);
\r
59 static IVideoDriver* createOpenGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager)
\r
61 return createOpenGL3Driver(params, io, contextManager);
\r
64 #ifdef _IRR_COMPILE_WITH_WEBGL1_
\r
65 IVideoDriver* createWebGL1Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
\r
67 static IVideoDriver* createWebGL1Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager)
\r
69 os::Printer::log("No WebGL 1 support compiled in.", ELL_ERROR);
\r
73 } // end namespace video
\r
75 } // end namespace irr
\r
80 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
81 EM_BOOL CIrrDeviceSDL::MouseUpDownCallback(int eventType, const EmscriptenMouseEvent * event, void* userData)
\r
83 // We need this callback so far only because otherwise "emscripten_request_pointerlock" calls will
\r
84 // fail as their request are infinitely deferred.
\r
85 // Not exactly certain why, maybe SDL does catch those mouse-events otherwise and not pass them on.
\r
89 EM_BOOL CIrrDeviceSDL::MouseEnterCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
\r
91 CIrrDeviceSDL * This = static_cast<CIrrDeviceSDL*>(userData);
\r
95 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
\r
96 irrevent.MouseInput.Event = irr::EMIE_MOUSE_ENTER_CANVAS;
\r
97 This->MouseX = irrevent.MouseInput.X = mouseEvent->canvasX;
\r
98 This->MouseY = irrevent.MouseInput.Y = mouseEvent->canvasY;
\r
99 This->MouseXRel = mouseEvent->movementX; // should be 0 I guess? Or can it enter while pointer is locked()?
\r
100 This->MouseYRel = mouseEvent->movementY;
\r
101 irrevent.MouseInput.ButtonStates = This->MouseButtonStates; // TODO: not correct, but couldn't figure out the bitset of mouseEvent->buttons yet.
\r
102 irrevent.MouseInput.Shift = mouseEvent->shiftKey;
\r
103 irrevent.MouseInput.Control = mouseEvent->ctrlKey;
\r
105 This->postEventFromUser(irrevent);
\r
110 EM_BOOL CIrrDeviceSDL::MouseLeaveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
\r
112 CIrrDeviceSDL * This = static_cast<CIrrDeviceSDL*>(userData);
\r
116 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
\r
117 irrevent.MouseInput.Event = irr::EMIE_MOUSE_LEAVE_CANVAS;
\r
118 This->MouseX = irrevent.MouseInput.X = mouseEvent->canvasX;
\r
119 This->MouseY = irrevent.MouseInput.Y = mouseEvent->canvasY;
\r
120 This->MouseXRel = mouseEvent->movementX; // should be 0 I guess? Or can it enter while pointer is locked()?
\r
121 This->MouseYRel = mouseEvent->movementY;
\r
122 irrevent.MouseInput.ButtonStates = This->MouseButtonStates; // TODO: not correct, but couldn't figure out the bitset of mouseEvent->buttons yet.
\r
123 irrevent.MouseInput.Shift = mouseEvent->shiftKey;
\r
124 irrevent.MouseInput.Control = mouseEvent->ctrlKey;
\r
126 This->postEventFromUser(irrevent);
\r
133 bool CIrrDeviceSDL::keyIsKnownSpecial(EKEY_CODE key)
\r
137 // keys which are known to have safe special character interpretation
\r
138 // could need changes over time (removals and additions!)
\r
194 int CIrrDeviceSDL::findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key) {
\r
195 // SDL in-place ORs values with no character representation with 1<<30
\r
196 // https://wiki.libsdl.org/SDL2/SDLKeycodeLookup
\r
197 if (assumedChar & (1<<30))
\r
212 return assumedChar;
\r
216 void CIrrDeviceSDL::resetReceiveTextInputEvents() {
\r
217 gui::IGUIElement *elem = GUIEnvironment->getFocus();
\r
218 if (elem && elem->acceptsIME())
\r
219 SDL_StartTextInput();
\r
221 SDL_StopTextInput();
\r
225 CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
\r
226 : CIrrDeviceStub(param),
\r
227 Window((SDL_Window*)param.WindowId), SDL_Flags(0),
\r
228 MouseX(0), MouseY(0), MouseXRel(0), MouseYRel(0), MouseButtonStates(0),
\r
229 Width(param.WindowSize.Width), Height(param.WindowSize.Height),
\r
230 Resizable(param.WindowResizable == 1 ? true : false)
\r
233 setDebugName("CIrrDeviceSDL");
\r
236 if ( ++SDLDeviceInstances == 1 )
\r
238 u32 flags = SDL_INIT_TIMER | SDL_INIT_EVENTS;
\r
239 if (CreationParams.DriverType != video::EDT_NULL)
\r
240 flags |= SDL_INIT_VIDEO;
\r
241 #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
\r
242 flags |= SDL_INIT_JOYSTICK;
\r
244 if (SDL_Init(flags) < 0)
\r
246 os::Printer::log( "Unable to initialize SDL!", SDL_GetError());
\r
251 os::Printer::log("SDL initialized", ELL_INFORMATION);
\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 if (CreationParams.Fullscreen) {
\r
348 SDL_Flags |= SDL_WINDOW_FULLSCREEN;
\r
351 SDL_Flags |= SDL_WINDOW_RESIZABLE;
\r
352 if (CreationParams.WindowMaximized)
\r
353 SDL_Flags |= SDL_WINDOW_MAXIMIZED;
\r
355 SDL_Flags |= SDL_WINDOW_OPENGL;
\r
357 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
358 if ( Width != 0 || Height != 0 )
\r
359 emscripten_set_canvas_size( Width, Height);
\r
363 emscripten_get_canvas_size(&w, &h, &fs);
\r
368 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
\r
369 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
\r
370 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
\r
371 SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?8:0 );
\r
373 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);
\r
374 SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0);
\r
375 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, CreationParams.Doublebuffer ? 1 : 0);
\r
377 if (CreationParams.AntiAlias>1)
\r
379 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
\r
380 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias );
\r
384 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
\r
385 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
\r
388 SDL_CreateWindowAndRenderer(0, 0, SDL_Flags, &Window, &Renderer); // 0,0 will use the canvas size
\r
392 // "#canvas" is for the opengl context
\r
393 emscripten_set_mousedown_callback("#canvas", (void*)this, true, MouseUpDownCallback);
\r
394 emscripten_set_mouseup_callback("#canvas", (void*)this, true, MouseUpDownCallback);
\r
395 emscripten_set_mouseenter_callback("#canvas", (void*)this, false, MouseEnterCallback);
\r
396 emscripten_set_mouseleave_callback("#canvas", (void*)this, false, MouseLeaveCallback);
\r
399 #else // !_IRR_EMSCRIPTEN_PLATFORM_
\r
403 switch (CreationParams.DriverType) {
\r
404 case video::EDT_OPENGL:
\r
405 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
\r
406 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
\r
408 case video::EDT_OPENGL3:
\r
409 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
\r
410 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
\r
411 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
\r
413 case video::EDT_OGLES1:
\r
414 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
\r
415 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
\r
416 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
\r
418 case video::EDT_OGLES2:
\r
419 case video::EDT_WEBGL1:
\r
420 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
\r
421 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
\r
422 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
\r
428 SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG | SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG);
\r
431 if (CreationParams.Bits == 16) {
\r
432 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
\r
433 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
\r
434 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
\r
435 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 1 : 0);
\r
437 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
\r
438 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
\r
439 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
\r
440 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 8 : 0);
\r
442 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);
\r
443 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, CreationParams.Doublebuffer);
\r
444 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0);
\r
445 SDL_GL_SetAttribute(SDL_GL_STEREO, CreationParams.Stereobuffer);
\r
446 if (CreationParams.AntiAlias > 1) {
\r
447 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
\r
448 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias);
\r
451 Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
\r
453 os::Printer::log("Could not create window...", SDL_GetError(), ELL_WARNING);
\r
455 if (!Window && CreationParams.AntiAlias > 1) {
\r
456 while (--CreationParams.AntiAlias > 1) {
\r
457 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias);
\r
458 Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
\r
463 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
\r
464 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
\r
465 Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
\r
467 os::Printer::log("AntiAliasing disabled due to lack of support!", ELL_WARNING);
\r
471 if ( !Window && CreationParams.Doublebuffer)
\r
473 // Try single buffer
\r
474 if (CreationParams.DriverType == video::EDT_OPENGL)
\r
475 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
\r
476 Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
\r
480 os::Printer::log("Could not initialize display", SDL_GetError(), ELL_ERROR);
\r
484 Context = SDL_GL_CreateContext(Window);
\r
486 os::Printer::log("Could not initialize context", SDL_GetError(), ELL_ERROR);
\r
487 SDL_DestroyWindow(Window);
\r
492 #endif // !_IRR_EMSCRIPTEN_PLATFORM_
\r
496 //! create the driver
\r
497 void CIrrDeviceSDL::createDriver()
\r
499 if (CreationParams.DriverType == video::EDT_NULL) {
\r
500 VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
\r
504 ContextManager = new video::CSDLManager(this);
\r
505 switch(CreationParams.DriverType)
\r
507 case video::EDT_OPENGL: VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager); break;
\r
508 case video::EDT_OPENGL3: VideoDriver = video::createOpenGL3Driver(CreationParams, FileSystem, ContextManager); break;
\r
509 case video::EDT_OGLES2: VideoDriver = video::createOpenGLES2Driver(CreationParams, FileSystem, ContextManager); break;
\r
510 case video::EDT_WEBGL1: VideoDriver = video::createWebGL1Driver(CreationParams, FileSystem, ContextManager); break;
\r
514 os::Printer::log("Could not create video driver", ELL_ERROR);
\r
518 //! runs the device. Returns false if device wants to be deleted
\r
519 bool CIrrDeviceSDL::run()
\r
524 SDL_Event SDL_event;
\r
526 while ( !Close && SDL_PollEvent( &SDL_event ) )
\r
528 // os::Printer::log("event: ", core::stringc((int)SDL_event.type).c_str(), ELL_INFORMATION); // just for debugging
\r
530 switch ( SDL_event.type )
\r
532 case SDL_MOUSEMOTION: {
\r
533 SDL_Keymod keymod = SDL_GetModState();
\r
535 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
\r
536 irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
\r
537 MouseX = irrevent.MouseInput.X = SDL_event.motion.x;
\r
538 MouseY = irrevent.MouseInput.Y = SDL_event.motion.y;
\r
539 MouseXRel = SDL_event.motion.xrel;
\r
540 MouseYRel = SDL_event.motion.yrel;
\r
541 irrevent.MouseInput.ButtonStates = MouseButtonStates;
\r
542 irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
\r
543 irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
\r
545 postEventFromUser(irrevent);
\r
548 case SDL_MOUSEWHEEL: {
\r
549 SDL_Keymod keymod = SDL_GetModState();
\r
551 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
\r
552 irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
\r
553 irrevent.MouseInput.Wheel = static_cast<float>(SDL_event.wheel.y);
\r
554 irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
\r
555 irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
\r
556 irrevent.MouseInput.X = MouseX;
\r
557 irrevent.MouseInput.Y = MouseY;
\r
559 postEventFromUser(irrevent);
\r
562 case SDL_MOUSEBUTTONDOWN:
\r
563 case SDL_MOUSEBUTTONUP: {
\r
564 SDL_Keymod keymod = SDL_GetModState();
\r
566 irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
\r
567 irrevent.MouseInput.X = SDL_event.button.x;
\r
568 irrevent.MouseInput.Y = SDL_event.button.y;
\r
569 irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
\r
570 irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
\r
572 irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
\r
575 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
576 // Handle mouselocking in emscripten in Windowed mode.
\r
577 // In fullscreen SDL will handle it.
\r
578 // The behavior we want windowed is - when the canvas was clicked then
\r
579 // we will lock the mouse-pointer if it should be invisible.
\r
580 // For security reasons this will be delayed until the next mouse-up event.
\r
581 // We do not pass on this event as we don't want the activation click to do anything.
\r
582 if ( SDL_event.type == SDL_MOUSEBUTTONDOWN && !isFullscreen() )
\r
584 EmscriptenPointerlockChangeEvent pointerlockStatus; // let's hope that test is not expensive ...
\r
585 if ( emscripten_get_pointerlock_status(&pointerlockStatus) == EMSCRIPTEN_RESULT_SUCCESS )
\r
587 if ( CursorControl->isVisible() && pointerlockStatus.isActive )
\r
589 emscripten_exit_pointerlock();
\r
592 else if ( !CursorControl->isVisible() && !pointerlockStatus.isActive )
\r
594 emscripten_request_pointerlock(0, true);
\r
601 switch(SDL_event.button.button)
\r
603 case SDL_BUTTON_LEFT:
\r
604 if (SDL_event.type == SDL_MOUSEBUTTONDOWN)
\r
606 irrevent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
\r
607 MouseButtonStates |= irr::EMBSM_LEFT;
\r
611 irrevent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;
\r
612 MouseButtonStates &= ~irr::EMBSM_LEFT;
\r
616 case SDL_BUTTON_RIGHT:
\r
617 if (SDL_event.type == SDL_MOUSEBUTTONDOWN)
\r
619 irrevent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN;
\r
620 MouseButtonStates |= irr::EMBSM_RIGHT;
\r
624 irrevent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP;
\r
625 MouseButtonStates &= ~irr::EMBSM_RIGHT;
\r
629 case SDL_BUTTON_MIDDLE:
\r
630 if (SDL_event.type == SDL_MOUSEBUTTONDOWN)
\r
632 irrevent.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN;
\r
633 MouseButtonStates |= irr::EMBSM_MIDDLE;
\r
637 irrevent.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP;
\r
638 MouseButtonStates &= ~irr::EMBSM_MIDDLE;
\r
643 irrevent.MouseInput.ButtonStates = MouseButtonStates;
\r
645 if (irrevent.MouseInput.Event != irr::EMIE_MOUSE_MOVED)
\r
647 postEventFromUser(irrevent);
\r
649 if ( irrevent.MouseInput.Event >= EMIE_LMOUSE_PRESSED_DOWN && irrevent.MouseInput.Event <= EMIE_MMOUSE_PRESSED_DOWN )
\r
651 u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y, irrevent.MouseInput.Event);
\r
654 irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_DOUBLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
\r
655 postEventFromUser(irrevent);
\r
657 else if ( clicks == 3 )
\r
659 irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_TRIPLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
\r
660 postEventFromUser(irrevent);
\r
667 case SDL_TEXTINPUT:
\r
669 irrevent.EventType = irr::EET_STRING_INPUT_EVENT;
\r
670 irrevent.StringInput.Str = new core::stringw();
\r
671 irr::core::multibyteToWString(*irrevent.StringInput.Str, SDL_event.text.text);
\r
672 postEventFromUser(irrevent);
\r
673 delete irrevent.StringInput.Str;
\r
674 irrevent.StringInput.Str = NULL;
\r
682 mp.SDLKey = SDL_event.key.keysym.sym;
\r
683 s32 idx = KeyMap.binary_search(mp);
\r
687 key = (EKEY_CODE)0;
\r
689 key = (EKEY_CODE)KeyMap[idx].Win32Key;
\r
691 // Make sure to only input special characters if something is in focus, as SDL_TEXTINPUT handles normal unicode already
\r
692 if (SDL_IsTextInputActive() && !keyIsKnownSpecial(key) && (SDL_event.key.keysym.mod & KMOD_CTRL) == 0)
\r
695 #ifdef _IRR_WINDOWS_API_
\r
696 // handle alt+f4 in Windows, because SDL seems not to
\r
697 if ( (SDL_event.key.keysym.mod & KMOD_LALT) && key == KEY_F4)
\r
703 irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
\r
704 irrevent.KeyInput.Key = key;
\r
705 irrevent.KeyInput.PressedDown = (SDL_event.type == SDL_KEYDOWN);
\r
706 irrevent.KeyInput.Shift = (SDL_event.key.keysym.mod & KMOD_SHIFT) != 0;
\r
707 irrevent.KeyInput.Control = (SDL_event.key.keysym.mod & KMOD_CTRL ) != 0;
\r
708 irrevent.KeyInput.Char = findCharToPassToIrrlicht(mp.SDLKey, key);
\r
709 postEventFromUser(irrevent);
\r
717 case SDL_WINDOWEVENT:
\r
718 switch (SDL_event.window.event)
\r
720 case SDL_WINDOWEVENT_RESIZED:
\r
721 if ((SDL_event.window.data1 != (int)Width) || (SDL_event.window.data2 != (int)Height))
\r
723 Width = SDL_event.window.data1;
\r
724 Height = SDL_event.window.data2;
\r
726 VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
\r
731 case SDL_USEREVENT:
\r
732 irrevent.EventType = irr::EET_USER_EVENT;
\r
733 irrevent.UserEvent.UserData1 = reinterpret_cast<uintptr_t>(SDL_event.user.data1);
\r
734 irrevent.UserEvent.UserData2 = reinterpret_cast<uintptr_t>(SDL_event.user.data2);
\r
736 postEventFromUser(irrevent);
\r
742 resetReceiveTextInputEvents();
\r
745 #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
\r
746 // TODO: Check if the multiple open/close calls are too expensive, then
\r
747 // open/close in the constructor/destructor instead
\r
749 // update joystick states manually
\r
750 SDL_JoystickUpdate();
\r
751 // we'll always send joystick input events...
\r
753 joyevent.EventType = EET_JOYSTICK_INPUT_EVENT;
\r
754 for (u32 i=0; i<Joysticks.size(); ++i)
\r
756 SDL_Joystick* joystick = Joysticks[i];
\r
760 // query all buttons
\r
761 const int numButtons = core::min_(SDL_JoystickNumButtons(joystick), 32);
\r
762 joyevent.JoystickEvent.ButtonStates=0;
\r
763 for (j=0; j<numButtons; ++j)
\r
764 joyevent.JoystickEvent.ButtonStates |= (SDL_JoystickGetButton(joystick, j)<<j);
\r
766 // query all axes, already in correct range
\r
767 const int numAxes = core::min_(SDL_JoystickNumAxes(joystick), (int)SEvent::SJoystickEvent::NUMBER_OF_AXES);
\r
768 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X]=0;
\r
769 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y]=0;
\r
770 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z]=0;
\r
771 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_R]=0;
\r
772 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_U]=0;
\r
773 joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_V]=0;
\r
774 for (j=0; j<numAxes; ++j)
\r
775 joyevent.JoystickEvent.Axis[j] = SDL_JoystickGetAxis(joystick, j);
\r
777 // we can only query one hat, SDL only supports 8 directions
\r
778 if (SDL_JoystickNumHats(joystick)>0)
\r
780 switch (SDL_JoystickGetHat(joystick, 0))
\r
783 joyevent.JoystickEvent.POV=0;
\r
785 case SDL_HAT_RIGHTUP:
\r
786 joyevent.JoystickEvent.POV=4500;
\r
788 case SDL_HAT_RIGHT:
\r
789 joyevent.JoystickEvent.POV=9000;
\r
791 case SDL_HAT_RIGHTDOWN:
\r
792 joyevent.JoystickEvent.POV=13500;
\r
795 joyevent.JoystickEvent.POV=18000;
\r
797 case SDL_HAT_LEFTDOWN:
\r
798 joyevent.JoystickEvent.POV=22500;
\r
801 joyevent.JoystickEvent.POV=27000;
\r
803 case SDL_HAT_LEFTUP:
\r
804 joyevent.JoystickEvent.POV=31500;
\r
806 case SDL_HAT_CENTERED:
\r
808 joyevent.JoystickEvent.POV=65535;
\r
814 joyevent.JoystickEvent.POV=65535;
\r
817 // we map the number directly
\r
818 joyevent.JoystickEvent.Joystick=static_cast<u8>(i);
\r
819 // now post the event
\r
820 postEventFromUser(joyevent);
\r
821 // and close the joystick
\r
828 //! Activate any joysticks, and generate events for them.
\r
829 bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
\r
831 #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
\r
832 joystickInfo.clear();
\r
834 // we can name up to 256 different joysticks
\r
835 const int numJoysticks = core::min_(SDL_NumJoysticks(), 256);
\r
836 Joysticks.reallocate(numJoysticks);
\r
837 joystickInfo.reallocate(numJoysticks);
\r
840 for (; joystick<numJoysticks; ++joystick)
\r
842 Joysticks.push_back( SDL_JoystickOpen(joystick));
\r
843 SJoystickInfo info;
\r
845 info.Joystick = joystick;
\r
846 info.Axes = SDL_JoystickNumAxes(Joysticks[joystick]);
\r
847 info.Buttons = SDL_JoystickNumButtons(Joysticks[joystick]);
\r
848 info.Name = SDL_JoystickName(Joysticks[joystick]);
\r
849 info.PovHat = (SDL_JoystickNumHats(Joysticks[joystick]) > 0)
\r
850 ? SJoystickInfo::POV_HAT_PRESENT : SJoystickInfo::POV_HAT_ABSENT;
\r
852 joystickInfo.push_back(info);
\r
855 for(joystick = 0; joystick < (int)joystickInfo.size(); ++joystick)
\r
857 char logString[256];
\r
858 snprintf_irr(logString, sizeof(logString), "Found joystick %d, %d axes, %d buttons '%s'",
\r
859 joystick, joystickInfo[joystick].Axes,
\r
860 joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str());
\r
861 os::Printer::log(logString, ELL_INFORMATION);
\r
866 #endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
\r
871 void CIrrDeviceSDL::SwapWindow()
\r
873 SDL_GL_SwapWindow(Window);
\r
878 //! pause execution temporarily
\r
879 void CIrrDeviceSDL::yield()
\r
885 //! pause execution for a specified time
\r
886 void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer)
\r
888 const bool wasStopped = Timer ? Timer->isStopped() : true;
\r
889 if (pauseTimer && !wasStopped)
\r
894 if (pauseTimer && !wasStopped)
\r
899 //! sets the caption of the window
\r
900 void CIrrDeviceSDL::setWindowCaption(const wchar_t* text)
\r
902 core::stringc textc;
\r
903 core::wStringToMultibyte(textc, text);
\r
904 SDL_SetWindowTitle(Window, textc.c_str());
\r
908 //! notifies the device that it should close itself
\r
909 void CIrrDeviceSDL::closeDevice()
\r
915 //! Sets if the window should be resizable in windowed mode.
\r
916 void CIrrDeviceSDL::setResizable(bool resize)
\r
918 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
919 os::Printer::log("Resizable not available on the web." , ELL_WARNING);
\r
921 #else // !_IRR_EMSCRIPTEN_PLATFORM_
\r
922 if (resize != Resizable) {
\r
924 SDL_Flags |= SDL_WINDOW_RESIZABLE;
\r
926 SDL_Flags &= ~SDL_WINDOW_RESIZABLE;
\r
929 SDL_SetWindowResizable(Window, (SDL_bool)resize);
\r
931 Resizable = resize;
\r
933 #endif // !_IRR_EMSCRIPTEN_PLATFORM_
\r
937 //! Minimizes window if possible
\r
938 void CIrrDeviceSDL::minimizeWindow()
\r
941 SDL_MinimizeWindow(Window);
\r
945 //! Maximize window
\r
946 void CIrrDeviceSDL::maximizeWindow()
\r
949 SDL_MaximizeWindow(Window);
\r
952 //! Get the position of this window on screen
\r
953 core::position2di CIrrDeviceSDL::getWindowPosition()
\r
955 return core::position2di(-1, -1);
\r
959 //! Restore original window size
\r
960 void CIrrDeviceSDL::restoreWindow()
\r
963 SDL_RestoreWindow(Window);
\r
966 bool CIrrDeviceSDL::isWindowMaximized() const
\r
968 return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_MAXIMIZED) != 0;
\r
971 bool CIrrDeviceSDL::isFullscreen() const
\r
973 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
974 return SDL_GetWindowFlags(0) == SDL_WINDOW_FULLSCREEN;
\r
977 return CIrrDeviceStub::isFullscreen();
\r
982 //! returns if window is active. if not, nothing need to be drawn
\r
983 bool CIrrDeviceSDL::isWindowActive() const
\r
985 #ifdef _IRR_EMSCRIPTEN_PLATFORM_
\r
986 // Hidden test only does something in some browsers (when tab in background or window is minimized)
\r
987 // In other browsers code automatically doesn't seem to be called anymore.
\r
988 EmscriptenVisibilityChangeEvent emVisibility;
\r
989 if ( emscripten_get_visibility_status(&emVisibility) == EMSCRIPTEN_RESULT_SUCCESS)
\r
991 if ( emVisibility.hidden )
\r
995 const u32 windowFlags = SDL_GetWindowFlags(Window);
\r
996 return windowFlags & SDL_WINDOW_SHOWN && windowFlags & SDL_WINDOW_INPUT_FOCUS;
\r
1000 //! returns if window has focus.
\r
1001 bool CIrrDeviceSDL::isWindowFocused() const
\r
1003 return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_INPUT_FOCUS) != 0;
\r
1007 //! returns if window is minimized.
\r
1008 bool CIrrDeviceSDL::isWindowMinimized() const
\r
1010 return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_MINIMIZED) != 0;
\r
1014 //! returns color format of the window.
\r
1015 video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const
\r
1019 SDL_Surface *surface = SDL_GetWindowSurface(Window);
\r
1020 if (surface->format->BitsPerPixel == 16)
\r
1022 if (surface->format->Amask != 0)
\r
1023 return video::ECF_A1R5G5B5;
\r
1025 return video::ECF_R5G6B5;
\r
1029 if (surface->format->Amask != 0)
\r
1030 return video::ECF_A8R8G8B8;
\r
1032 return video::ECF_R8G8B8;
\r
1036 return CIrrDeviceStub::getColorFormat();
\r
1040 void CIrrDeviceSDL::createKeyMap()
\r
1042 // I don't know if this is the best method to create
\r
1043 // the lookuptable, but I'll leave it like that until
\r
1044 // I find a better version.
\r
1046 KeyMap.reallocate(105);
\r
1048 // buttons missing
\r
1050 KeyMap.push_back(SKeyMap(SDLK_BACKSPACE, KEY_BACK));
\r
1051 KeyMap.push_back(SKeyMap(SDLK_TAB, KEY_TAB));
\r
1052 KeyMap.push_back(SKeyMap(SDLK_CLEAR, KEY_CLEAR));
\r
1053 KeyMap.push_back(SKeyMap(SDLK_RETURN, KEY_RETURN));
\r
1055 // combined modifiers missing
\r
1057 KeyMap.push_back(SKeyMap(SDLK_PAUSE, KEY_PAUSE));
\r
1058 KeyMap.push_back(SKeyMap(SDLK_CAPSLOCK, KEY_CAPITAL));
\r
1060 // asian letter keys missing
\r
1062 KeyMap.push_back(SKeyMap(SDLK_ESCAPE, KEY_ESCAPE));
\r
1064 // asian letter keys missing
\r
1066 KeyMap.push_back(SKeyMap(SDLK_SPACE, KEY_SPACE));
\r
1067 KeyMap.push_back(SKeyMap(SDLK_PAGEUP, KEY_PRIOR));
\r
1068 KeyMap.push_back(SKeyMap(SDLK_PAGEDOWN, KEY_NEXT));
\r
1069 KeyMap.push_back(SKeyMap(SDLK_END, KEY_END));
\r
1070 KeyMap.push_back(SKeyMap(SDLK_HOME, KEY_HOME));
\r
1071 KeyMap.push_back(SKeyMap(SDLK_LEFT, KEY_LEFT));
\r
1072 KeyMap.push_back(SKeyMap(SDLK_UP, KEY_UP));
\r
1073 KeyMap.push_back(SKeyMap(SDLK_RIGHT, KEY_RIGHT));
\r
1074 KeyMap.push_back(SKeyMap(SDLK_DOWN, KEY_DOWN));
\r
1077 KeyMap.push_back(SKeyMap(SDLK_PRINTSCREEN, KEY_PRINT));
\r
1078 // execute missing
\r
1079 KeyMap.push_back(SKeyMap(SDLK_PRINTSCREEN, KEY_SNAPSHOT));
\r
1081 KeyMap.push_back(SKeyMap(SDLK_INSERT, KEY_INSERT));
\r
1082 KeyMap.push_back(SKeyMap(SDLK_DELETE, KEY_DELETE));
\r
1083 KeyMap.push_back(SKeyMap(SDLK_HELP, KEY_HELP));
\r
1085 KeyMap.push_back(SKeyMap(SDLK_0, KEY_KEY_0));
\r
1086 KeyMap.push_back(SKeyMap(SDLK_1, KEY_KEY_1));
\r
1087 KeyMap.push_back(SKeyMap(SDLK_2, KEY_KEY_2));
\r
1088 KeyMap.push_back(SKeyMap(SDLK_3, KEY_KEY_3));
\r
1089 KeyMap.push_back(SKeyMap(SDLK_4, KEY_KEY_4));
\r
1090 KeyMap.push_back(SKeyMap(SDLK_5, KEY_KEY_5));
\r
1091 KeyMap.push_back(SKeyMap(SDLK_6, KEY_KEY_6));
\r
1092 KeyMap.push_back(SKeyMap(SDLK_7, KEY_KEY_7));
\r
1093 KeyMap.push_back(SKeyMap(SDLK_8, KEY_KEY_8));
\r
1094 KeyMap.push_back(SKeyMap(SDLK_9, KEY_KEY_9));
\r
1096 KeyMap.push_back(SKeyMap(SDLK_a, KEY_KEY_A));
\r
1097 KeyMap.push_back(SKeyMap(SDLK_b, KEY_KEY_B));
\r
1098 KeyMap.push_back(SKeyMap(SDLK_c, KEY_KEY_C));
\r
1099 KeyMap.push_back(SKeyMap(SDLK_d, KEY_KEY_D));
\r
1100 KeyMap.push_back(SKeyMap(SDLK_e, KEY_KEY_E));
\r
1101 KeyMap.push_back(SKeyMap(SDLK_f, KEY_KEY_F));
\r
1102 KeyMap.push_back(SKeyMap(SDLK_g, KEY_KEY_G));
\r
1103 KeyMap.push_back(SKeyMap(SDLK_h, KEY_KEY_H));
\r
1104 KeyMap.push_back(SKeyMap(SDLK_i, KEY_KEY_I));
\r
1105 KeyMap.push_back(SKeyMap(SDLK_j, KEY_KEY_J));
\r
1106 KeyMap.push_back(SKeyMap(SDLK_k, KEY_KEY_K));
\r
1107 KeyMap.push_back(SKeyMap(SDLK_l, KEY_KEY_L));
\r
1108 KeyMap.push_back(SKeyMap(SDLK_m, KEY_KEY_M));
\r
1109 KeyMap.push_back(SKeyMap(SDLK_n, KEY_KEY_N));
\r
1110 KeyMap.push_back(SKeyMap(SDLK_o, KEY_KEY_O));
\r
1111 KeyMap.push_back(SKeyMap(SDLK_p, KEY_KEY_P));
\r
1112 KeyMap.push_back(SKeyMap(SDLK_q, KEY_KEY_Q));
\r
1113 KeyMap.push_back(SKeyMap(SDLK_r, KEY_KEY_R));
\r
1114 KeyMap.push_back(SKeyMap(SDLK_s, KEY_KEY_S));
\r
1115 KeyMap.push_back(SKeyMap(SDLK_t, KEY_KEY_T));
\r
1116 KeyMap.push_back(SKeyMap(SDLK_u, KEY_KEY_U));
\r
1117 KeyMap.push_back(SKeyMap(SDLK_v, KEY_KEY_V));
\r
1118 KeyMap.push_back(SKeyMap(SDLK_w, KEY_KEY_W));
\r
1119 KeyMap.push_back(SKeyMap(SDLK_x, KEY_KEY_X));
\r
1120 KeyMap.push_back(SKeyMap(SDLK_y, KEY_KEY_Y));
\r
1121 KeyMap.push_back(SKeyMap(SDLK_z, KEY_KEY_Z));
\r
1123 KeyMap.push_back(SKeyMap(SDLK_LGUI, KEY_LWIN));
\r
1124 KeyMap.push_back(SKeyMap(SDLK_RGUI, KEY_RWIN));
\r
1126 KeyMap.push_back(SKeyMap(SDLK_POWER, KEY_SLEEP)); //??
\r
1128 KeyMap.push_back(SKeyMap(SDLK_KP_0, KEY_NUMPAD0));
\r
1129 KeyMap.push_back(SKeyMap(SDLK_KP_1, KEY_NUMPAD1));
\r
1130 KeyMap.push_back(SKeyMap(SDLK_KP_2, KEY_NUMPAD2));
\r
1131 KeyMap.push_back(SKeyMap(SDLK_KP_3, KEY_NUMPAD3));
\r
1132 KeyMap.push_back(SKeyMap(SDLK_KP_4, KEY_NUMPAD4));
\r
1133 KeyMap.push_back(SKeyMap(SDLK_KP_5, KEY_NUMPAD5));
\r
1134 KeyMap.push_back(SKeyMap(SDLK_KP_6, KEY_NUMPAD6));
\r
1135 KeyMap.push_back(SKeyMap(SDLK_KP_7, KEY_NUMPAD7));
\r
1136 KeyMap.push_back(SKeyMap(SDLK_KP_8, KEY_NUMPAD8));
\r
1137 KeyMap.push_back(SKeyMap(SDLK_KP_9, KEY_NUMPAD9));
\r
1138 KeyMap.push_back(SKeyMap(SDLK_KP_MULTIPLY, KEY_MULTIPLY));
\r
1139 KeyMap.push_back(SKeyMap(SDLK_KP_PLUS, KEY_ADD));
\r
1140 // KeyMap.push_back(SKeyMap(SDLK_KP_, KEY_SEPARATOR));
\r
1141 KeyMap.push_back(SKeyMap(SDLK_KP_MINUS, KEY_SUBTRACT));
\r
1142 KeyMap.push_back(SKeyMap(SDLK_KP_PERIOD, KEY_DECIMAL));
\r
1143 KeyMap.push_back(SKeyMap(SDLK_KP_DIVIDE, KEY_DIVIDE));
\r
1145 KeyMap.push_back(SKeyMap(SDLK_F1, KEY_F1));
\r
1146 KeyMap.push_back(SKeyMap(SDLK_F2, KEY_F2));
\r
1147 KeyMap.push_back(SKeyMap(SDLK_F3, KEY_F3));
\r
1148 KeyMap.push_back(SKeyMap(SDLK_F4, KEY_F4));
\r
1149 KeyMap.push_back(SKeyMap(SDLK_F5, KEY_F5));
\r
1150 KeyMap.push_back(SKeyMap(SDLK_F6, KEY_F6));
\r
1151 KeyMap.push_back(SKeyMap(SDLK_F7, KEY_F7));
\r
1152 KeyMap.push_back(SKeyMap(SDLK_F8, KEY_F8));
\r
1153 KeyMap.push_back(SKeyMap(SDLK_F9, KEY_F9));
\r
1154 KeyMap.push_back(SKeyMap(SDLK_F10, KEY_F10));
\r
1155 KeyMap.push_back(SKeyMap(SDLK_F11, KEY_F11));
\r
1156 KeyMap.push_back(SKeyMap(SDLK_F12, KEY_F12));
\r
1157 KeyMap.push_back(SKeyMap(SDLK_F13, KEY_F13));
\r
1158 KeyMap.push_back(SKeyMap(SDLK_F14, KEY_F14));
\r
1159 KeyMap.push_back(SKeyMap(SDLK_F15, KEY_F15));
\r
1160 // no higher F-keys
\r
1162 KeyMap.push_back(SKeyMap(SDLK_NUMLOCKCLEAR, KEY_NUMLOCK));
\r
1163 KeyMap.push_back(SKeyMap(SDLK_SCROLLLOCK, KEY_SCROLL));
\r
1164 KeyMap.push_back(SKeyMap(SDLK_LSHIFT, KEY_LSHIFT));
\r
1165 KeyMap.push_back(SKeyMap(SDLK_RSHIFT, KEY_RSHIFT));
\r
1166 KeyMap.push_back(SKeyMap(SDLK_LCTRL, KEY_LCONTROL));
\r
1167 KeyMap.push_back(SKeyMap(SDLK_RCTRL, KEY_RCONTROL));
\r
1168 KeyMap.push_back(SKeyMap(SDLK_LALT, KEY_LMENU));
\r
1169 KeyMap.push_back(SKeyMap(SDLK_RALT, KEY_RMENU));
\r
1171 KeyMap.push_back(SKeyMap(SDLK_PLUS, KEY_PLUS));
\r
1172 KeyMap.push_back(SKeyMap(SDLK_COMMA, KEY_COMMA));
\r
1173 KeyMap.push_back(SKeyMap(SDLK_MINUS, KEY_MINUS));
\r
1174 KeyMap.push_back(SKeyMap(SDLK_PERIOD, KEY_PERIOD));
\r
1176 // some special keys missing
\r
1181 void CIrrDeviceSDL::CCursorControl::initCursors()
\r
1183 Cursors.reserve(gui::ECI_COUNT);
\r
1185 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW)); // ECI_NORMAL
\r
1186 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR)); // ECI_CROSS
\r
1187 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND)); // ECI_HAND
\r
1188 Cursors.emplace_back(nullptr); // ECI_HELP
\r
1189 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM)); // ECI_IBEAM
\r
1190 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO)); // ECI_NO
\r
1191 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT)); // ECI_WAIT
\r
1192 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL)); // ECI_SIZEALL
\r
1193 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW)); // ECI_SIZENESW
\r
1194 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE)); // ECI_SIZENWSE
\r
1195 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS)); // ECI_SIZENS
\r
1196 Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE)); // ECI_SIZEWE
\r
1197 Cursors.emplace_back(nullptr); // ECI_UP
\r
1200 } // end namespace irr
\r
1202 #endif // _IRR_COMPILE_WITH_SDL_DEVICE_
\r