sdlWindow.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "math/mMath.h"
  23. #include "gfx/gfxStructs.h"
  24. #include "windowManager/sdl/sdlWindow.h"
  25. #include "windowManager/sdl/sdlWindowMgr.h"
  26. #include "windowManager/sdl/sdlCursorController.h"
  27. #include "platformSDL/sdlInput.h"
  28. #include "platform/platformInput.h"
  29. #include "gfx/gfxDevice.h"
  30. #ifdef TORQUE_OS_LINUX
  31. #define SDL_VIDEO_DRIVER_X11 // TODO SDL
  32. #endif
  33. #include "SDL.h"
  34. #include "SDL_syswm.h"
  35. #define SCREENSAVER_QUERY_DENY 0 // Disable screensaver
  36. #ifndef IDI_ICON1
  37. #define IDI_ICON1 107
  38. #endif
  39. namespace
  40. {
  41. U32 getTorqueModFromSDL(U16 mod)
  42. {
  43. U32 ret = 0;
  44. if (mod & KMOD_LSHIFT)
  45. {
  46. ret |= SI_LSHIFT;
  47. ret |= SI_SHIFT;
  48. }
  49. if (mod & KMOD_RSHIFT)
  50. {
  51. ret |= SI_RSHIFT;
  52. ret |= SI_SHIFT;
  53. }
  54. if (mod & KMOD_LCTRL)
  55. {
  56. ret |= SI_LCTRL;
  57. ret |= SI_CTRL;
  58. }
  59. if (mod & KMOD_RCTRL)
  60. {
  61. ret |= SI_RCTRL;
  62. ret |= SI_CTRL;
  63. }
  64. if (mod & KMOD_LALT)
  65. {
  66. ret |= SI_LALT;
  67. ret |= SI_ALT;
  68. }
  69. if (mod & KMOD_RALT)
  70. {
  71. ret |= SI_RALT;
  72. ret |= SI_ALT;
  73. }
  74. // NOTE: For MacOS, this will treat command as Left or Right CTRL
  75. if (mod & KMOD_LGUI)
  76. {
  77. ret |= SI_LCTRL;
  78. ret |= SI_CTRL;
  79. }
  80. if (mod & KMOD_RGUI)
  81. {
  82. ret |= SI_RCTRL;
  83. ret |= SI_CTRL;
  84. }
  85. return ret;
  86. }
  87. }
  88. PlatformWindowSDL::PlatformWindowSDL():
  89. mOwningManager(NULL),
  90. mNextWindow(NULL),
  91. mWindowHandle(NULL),
  92. mOldParent(NULL),
  93. mDevice(NULL),
  94. mTarget(NULL),
  95. mPosition(0,0),
  96. mMouseLocked(false),
  97. mShouldLockMouse(false),
  98. mSuppressReset(false),
  99. mMenuHandle(NULL),
  100. mClosing(false)
  101. {
  102. mCursorController = new PlatformCursorControllerSDL( this );
  103. mVideoMode.bitDepth = 32;
  104. mVideoMode.fullScreen = false;
  105. mVideoMode.refreshRate = 60;
  106. mVideoMode.resolution.set(800,600);
  107. }
  108. PlatformWindowSDL::~PlatformWindowSDL()
  109. {
  110. // delete our sdl handle..
  111. SDL_DestroyWindow(mWindowHandle);
  112. // unlink ourselves from the window list...
  113. AssertFatal(mOwningManager, "PlatformWindowSDL::~PlatformWindowSDL - orphan window, cannot unlink!");
  114. mOwningManager->unlinkWindow(this);
  115. }
  116. GFXDevice * PlatformWindowSDL::getGFXDevice()
  117. {
  118. return mDevice;
  119. }
  120. GFXWindowTarget * PlatformWindowSDL::getGFXTarget()
  121. {
  122. return mTarget;
  123. }
  124. const GFXVideoMode & PlatformWindowSDL::getVideoMode()
  125. {
  126. return mVideoMode;
  127. }
  128. void* PlatformWindowSDL::getSystemWindow(const WindowSystem system)
  129. {
  130. SDL_SysWMinfo info;
  131. SDL_VERSION(&info.version);
  132. SDL_GetWindowWMInfo(mWindowHandle,&info);
  133. #ifdef TORQUE_OS_WIN
  134. if( system == WindowSystem_Windows && info.subsystem == SDL_SYSWM_WINDOWS)
  135. return info.info.win.window;
  136. #endif
  137. #if defined(TORQUE_OS_LINUX)
  138. if( system == WindowSystem_X11 && info.subsystem == SDL_SYSWM_X11)
  139. return (void*)info.info.x11.window;
  140. #endif
  141. AssertFatal(0, "");
  142. return NULL;
  143. }
  144. void PlatformWindowSDL::_setVideoMode( const GFXVideoMode &mode )
  145. {
  146. mVideoMode = mode;
  147. mSuppressReset = true;
  148. S32 newDisplay = Con::getIntVariable("pref::Video::deviceId", 0);
  149. // Set our window to have the right style based on the mode
  150. if(mode.fullScreen && !Platform::getWebDeployment() && !mOffscreenRender)
  151. {
  152. SDL_Rect rect_sdl;
  153. // Move the window onto the correct monitor before setting fullscreen
  154. if (0 == SDL_GetDisplayBounds(newDisplay, &rect_sdl))
  155. {
  156. SDL_SetWindowPosition(mWindowHandle, rect_sdl.x, rect_sdl.y);
  157. }
  158. setSize(mode.resolution);
  159. SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN);
  160. // When switching to Fullscreen, reset device after setting style
  161. if(mTarget.isValid())
  162. mTarget->resetMode();
  163. }
  164. else
  165. {
  166. // Reset device *first*, so that when we call setSize() and let it
  167. // access the monitor settings, it won't end up with our fullscreen
  168. // geometry that is just about to change.
  169. if(mTarget.isValid())
  170. mTarget->resetMode();
  171. if (!mOffscreenRender)
  172. {
  173. SDL_SetWindowFullscreen( mWindowHandle, 0);
  174. }
  175. // Restore the window to it's original size/position before applying changes
  176. SDL_RestoreWindow(mWindowHandle);
  177. // pref::Video::deviceMode values 0-windowed, 1-borderless, 2-fullscreen
  178. bool hasBorder = (0 == Con::getIntVariable("pref::Video::deviceMode", 0));
  179. SDL_SetWindowBordered(mWindowHandle, hasBorder ? SDL_TRUE : SDL_FALSE);
  180. setSize(mode.resolution);
  181. SDL_SetWindowPosition(mWindowHandle, SDL_WINDOWPOS_CENTERED_DISPLAY(newDisplay), SDL_WINDOWPOS_CENTERED_DISPLAY(newDisplay));
  182. if (hasBorder && Con::getBoolVariable("pref::Video::isMaximized", false))
  183. SDL_MaximizeWindow(mWindowHandle);
  184. }
  185. mSuppressReset = false;
  186. }
  187. bool PlatformWindowSDL::clearFullscreen()
  188. {
  189. return true;
  190. }
  191. bool PlatformWindowSDL::isFullscreen()
  192. {
  193. U32 flags = SDL_GetWindowFlags( mWindowHandle );
  194. if( flags & SDL_WINDOW_FULLSCREEN || flags & SDL_WINDOW_FULLSCREEN_DESKTOP )
  195. return true;
  196. return false;
  197. }
  198. void PlatformWindowSDL::_setFullscreen(const bool fullscreen)
  199. {
  200. if( isFullscreen() )
  201. return;
  202. if(fullscreen && !mOffscreenRender)
  203. {
  204. Con::printf("PlatformWindowSDL::setFullscreen (full) enter");
  205. SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN);
  206. }
  207. else
  208. {
  209. Con::printf("PlatformWindowSDL::setFullscreen (windowed) enter");
  210. if (!mOffscreenRender)
  211. {
  212. SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN_DESKTOP);
  213. }
  214. setSize(mVideoMode.resolution);
  215. }
  216. Con::printf("PlatformWindowSDL::setFullscreen exit");
  217. }
  218. bool PlatformWindowSDL::setCaption( const char *cap )
  219. {
  220. SDL_SetWindowTitle(mWindowHandle, cap);
  221. return true;
  222. }
  223. const char * PlatformWindowSDL::getCaption()
  224. {
  225. return StringTable->insert( SDL_GetWindowTitle(mWindowHandle) );
  226. }
  227. void PlatformWindowSDL::setFocus()
  228. {
  229. SDL_RaiseWindow(mWindowHandle);
  230. }
  231. void PlatformWindowSDL::setClientExtent( const Point2I newExtent )
  232. {
  233. Point2I oldExtent = getClientExtent();
  234. if (oldExtent == newExtent)
  235. return;
  236. SDL_SetWindowSize(mWindowHandle, newExtent.x, newExtent.y);
  237. }
  238. const Point2I PlatformWindowSDL::getClientExtent()
  239. {
  240. // Fetch Client Rect from Windows
  241. Point2I size;
  242. SDL_GetWindowSize(mWindowHandle, &size.x, &size.y);
  243. return size;
  244. }
  245. void PlatformWindowSDL::setBounds( const RectI &newBounds )
  246. {
  247. // TODO SDL
  248. }
  249. const RectI PlatformWindowSDL::getBounds() const
  250. {
  251. // TODO SDL
  252. return RectI(0, 0, 0, 0);
  253. }
  254. void PlatformWindowSDL::setPosition( const Point2I newPosition )
  255. {
  256. SDL_SetWindowPosition( mWindowHandle, newPosition.x, newPosition.y );
  257. }
  258. const Point2I PlatformWindowSDL::getPosition()
  259. {
  260. Point2I position;
  261. SDL_GetWindowPosition( mWindowHandle, &position.x, &position.y );
  262. // Return position
  263. return position;
  264. }
  265. Point2I PlatformWindowSDL::clientToScreen( const Point2I& pos )
  266. {
  267. Point2I position;
  268. SDL_GetWindowPosition( mWindowHandle, &position.x, &position.y );
  269. return pos + position;
  270. }
  271. Point2I PlatformWindowSDL::screenToClient( const Point2I& pos )
  272. {
  273. Point2I position;
  274. SDL_GetWindowPosition( mWindowHandle, &position.x, &position.y );
  275. return pos - position;
  276. }
  277. void PlatformWindowSDL::centerWindow()
  278. {
  279. int sizeX, sizeY;
  280. SDL_GetWindowSize(mWindowHandle, &sizeX, &sizeY);
  281. SDL_DisplayMode mode;
  282. SDL_GetDesktopDisplayMode(0, &mode);
  283. U32 posX = (mode.w/2) - (sizeX/2);
  284. U32 posY = (mode.h/2) - (sizeY/2);
  285. SDL_SetWindowPosition( mWindowHandle, posX, posY);
  286. }
  287. bool PlatformWindowSDL::setSize( const Point2I &newSize )
  288. {
  289. SDL_SetWindowSize(mWindowHandle, newSize.x, newSize.y);
  290. return true;
  291. }
  292. bool PlatformWindowSDL::isOpen()
  293. {
  294. return mWindowHandle;
  295. }
  296. bool PlatformWindowSDL::isVisible()
  297. {
  298. // Is the window open and visible, ie. not minimized?
  299. if(!mWindowHandle)
  300. return false;
  301. if (mOffscreenRender)
  302. return true;
  303. U32 flags = SDL_GetWindowFlags( mWindowHandle );
  304. if( flags & SDL_WINDOW_SHOWN)
  305. return true;
  306. return false;
  307. }
  308. bool PlatformWindowSDL::isFocused()
  309. {
  310. if (mOffscreenRender)
  311. return true;
  312. U32 flags = SDL_GetWindowFlags( mWindowHandle );
  313. if( flags & SDL_WINDOW_INPUT_FOCUS || flags & SDL_WINDOW_INPUT_GRABBED || flags & SDL_WINDOW_MOUSE_FOCUS )
  314. return true;
  315. return false;
  316. }
  317. bool PlatformWindowSDL::isMinimized()
  318. {
  319. if (mOffscreenRender)
  320. return false;
  321. U32 flags = SDL_GetWindowFlags( mWindowHandle );
  322. if( flags & SDL_WINDOW_MINIMIZED)
  323. return true;
  324. return false;
  325. }
  326. bool PlatformWindowSDL::isMaximized()
  327. {
  328. if (mOffscreenRender)
  329. return true;
  330. U32 flags = SDL_GetWindowFlags( mWindowHandle );
  331. if( flags & SDL_WINDOW_MAXIMIZED)
  332. return true;
  333. return false;
  334. }
  335. WindowId PlatformWindowSDL::getWindowId()
  336. {
  337. return mWindowId;
  338. }
  339. void PlatformWindowSDL::minimize()
  340. {
  341. if (mOffscreenRender)
  342. return;
  343. SDL_MinimizeWindow( mWindowHandle );
  344. }
  345. void PlatformWindowSDL::maximize()
  346. {
  347. if (mOffscreenRender)
  348. return;
  349. SDL_MaximizeWindow( mWindowHandle );
  350. }
  351. void PlatformWindowSDL::restore()
  352. {
  353. if (mOffscreenRender)
  354. return;
  355. SDL_RestoreWindow( mWindowHandle );
  356. }
  357. void PlatformWindowSDL::hide()
  358. {
  359. if (mOffscreenRender)
  360. return;
  361. SDL_HideWindow( mWindowHandle );
  362. }
  363. void PlatformWindowSDL::show()
  364. {
  365. if (mOffscreenRender)
  366. return;
  367. SDL_ShowWindow( mWindowHandle );
  368. }
  369. void PlatformWindowSDL::close()
  370. {
  371. delete this;
  372. }
  373. void PlatformWindowSDL::defaultRender()
  374. {
  375. // TODO SDL
  376. }
  377. void PlatformWindowSDL::_triggerMouseLocationNotify(const SDL_Event& evt)
  378. {
  379. U32 mods = getTorqueModFromSDL(SDL_GetModState());
  380. if(!mMouseLocked)
  381. mouseEvent.trigger(getWindowId(), mods, evt.motion.x, evt.motion.y, false);
  382. else
  383. mouseEvent.trigger(getWindowId(), mods, evt.motion.xrel, evt.motion.yrel, true);
  384. }
  385. void PlatformWindowSDL::_triggerMouseWheelNotify(const SDL_Event& evt)
  386. {
  387. U32 mods = getTorqueModFromSDL(SDL_GetModState());
  388. S32 wheelDelta = Con::getIntVariable("$pref::Input::MouseWheelSpeed", 120);
  389. wheelEvent.trigger(getWindowId(), mods, evt.wheel.x * wheelDelta, evt.wheel.y * wheelDelta);
  390. }
  391. void PlatformWindowSDL::_triggerMouseButtonNotify(const SDL_Event& event)
  392. {
  393. S32 action = (event.type == SDL_MOUSEBUTTONDOWN) ? SI_MAKE : SI_BREAK;
  394. S32 button = -1;
  395. switch (event.button.button)
  396. {
  397. case SDL_BUTTON_LEFT:
  398. button = 0;
  399. break;
  400. case SDL_BUTTON_RIGHT:
  401. button = 1;
  402. break;
  403. case SDL_BUTTON_MIDDLE:
  404. button = 2;
  405. break;
  406. case SDL_BUTTON_X1:
  407. button = 3;
  408. break;
  409. case SDL_BUTTON_X2:
  410. button = 4;
  411. break;
  412. default:
  413. return;
  414. }
  415. U32 mod = getTorqueModFromSDL( SDL_GetModState() );
  416. buttonEvent.trigger(getWindowId(), mod, action, button );
  417. }
  418. void PlatformWindowSDL::_triggerKeyNotify(const SDL_Event& evt)
  419. {
  420. U32 inputAction = IA_MAKE;
  421. SDL_Keysym tKey = evt.key.keysym;
  422. if(evt.type == SDL_KEYUP)
  423. {
  424. inputAction = IA_BREAK;
  425. }
  426. if(evt.key.repeat)
  427. {
  428. inputAction = IA_REPEAT;
  429. }
  430. U32 torqueModifiers = getTorqueModFromSDL(evt.key.keysym.mod);
  431. U32 torqueKey = KeyMapSDL::getTorqueScanCodeFromSDL(tKey.scancode);
  432. if(tKey.scancode)
  433. {
  434. keyEvent.trigger(getWindowId(), torqueModifiers, inputAction, torqueKey);
  435. //Con::printf("Key %d : %d", tKey.sym, inputAction);
  436. if (inputAction == IA_MAKE && SDL_IsTextInputActive())
  437. {
  438. // We have to check if we already have a first responder active.
  439. // We don't want to type the character if it actually creates another responder!
  440. if (mWindowInputGenerator->lastKeyWasGlobalActionMap())
  441. {
  442. // Turn off Text input, and the next frame turn it back on. This tells SDL
  443. // to not generate a text event for this global action map key.
  444. SDL_StopTextInput();
  445. mOwningManager->updateSDLTextInputState(PlatformWindowManagerSDL::KeyboardInputState::TEXT_INPUT);
  446. }
  447. }
  448. }
  449. }
  450. void PlatformWindowSDL::_triggerTextNotify(const SDL_Event& evt)
  451. {
  452. U32 mod = getTorqueModFromSDL( SDL_GetModState() );
  453. if( !evt.text.text[1] ) // get a char
  454. {
  455. U16 wchar = evt.text.text[0];
  456. charEvent.trigger(getWindowId(), mod, wchar );
  457. //Con::printf("Char: %c", wchar);
  458. return;
  459. }
  460. else // get a wchar string
  461. {
  462. const dsize_t len = strlen(evt.text.text);
  463. U16 wchar[16] = {};
  464. dMemcpy(wchar, evt.text.text, sizeof(char)*len);
  465. for(int i = 0; i < 16; ++i)
  466. {
  467. if( !wchar[i] )
  468. return;
  469. charEvent.trigger(getWindowId(), mod, wchar[i] );
  470. }
  471. }
  472. }
  473. void PlatformWindowSDL::_updateMonitorFromMove(const SDL_Event& evt)
  474. {
  475. SDL_Rect sdlRect;
  476. S32 monitorCount = SDL_GetNumVideoDisplays();
  477. for (S32 index = 0; index < monitorCount; ++index)
  478. {
  479. if (0 == SDL_GetDisplayBounds(index, &sdlRect))
  480. {
  481. if ((evt.window.data1 >= sdlRect.x) && (evt.window.data1 < (sdlRect.x + sdlRect.w)) &&
  482. (evt.window.data2 >= sdlRect.y) && (evt.window.data2 < (sdlRect.y + sdlRect.h)))
  483. {
  484. Con::setIntVariable("pref::Video::deviceId", index);
  485. return;
  486. }
  487. }
  488. }
  489. }
  490. void PlatformWindowSDL::_processSDLEvent(SDL_Event &evt)
  491. {
  492. switch(evt.type)
  493. {
  494. case SDL_KEYDOWN:
  495. case SDL_KEYUP:
  496. {
  497. _triggerKeyNotify(evt);
  498. break;
  499. }
  500. case SDL_TEXTINPUT:
  501. {
  502. _triggerTextNotify(evt);
  503. break;
  504. }
  505. case SDL_MOUSEWHEEL:
  506. {
  507. _triggerMouseWheelNotify(evt);
  508. break;
  509. }
  510. case SDL_MOUSEMOTION:
  511. {
  512. _triggerMouseLocationNotify(evt);
  513. break;
  514. }
  515. case SDL_MOUSEBUTTONDOWN:
  516. case SDL_MOUSEBUTTONUP:
  517. {
  518. _triggerMouseButtonNotify(evt);
  519. break;
  520. }
  521. case SDL_WINDOWEVENT:
  522. {
  523. if (!mClosing)
  524. {
  525. switch (evt.window.event)
  526. {
  527. case SDL_WINDOWEVENT_FOCUS_GAINED:
  528. appEvent.trigger(getWindowId(), GainFocus);
  529. break;
  530. case SDL_WINDOWEVENT_FOCUS_LOST:
  531. appEvent.trigger(getWindowId(), LoseFocus);
  532. break;
  533. case SDL_WINDOWEVENT_MOVED:
  534. {
  535. _updateMonitorFromMove(evt);
  536. break;
  537. }
  538. case SDL_WINDOWEVENT_RESIZED:
  539. {
  540. int width, height;
  541. SDL_GetWindowSize(mWindowHandle, &width, &height);
  542. mVideoMode.resolution.set(width, height);
  543. getGFXTarget()->resetMode();
  544. resizeEvent.trigger(getWindowId(), width, height);
  545. getScreenResChangeSignal().trigger(this, true);
  546. break;
  547. }
  548. case SDL_WINDOWEVENT_CLOSE:
  549. {
  550. appEvent.trigger(getWindowId(), WindowClose);
  551. mClosing = true;
  552. }
  553. case SDL_WINDOWEVENT_MINIMIZED:
  554. break;
  555. case SDL_WINDOWEVENT_MAXIMIZED:
  556. Con::setBoolVariable("pref::Video::isMaximized", true);
  557. break;
  558. case SDL_WINDOWEVENT_RESTORED:
  559. Con::setBoolVariable("pref::Video::isMaximized", false);
  560. break;
  561. default:
  562. break;
  563. }
  564. }
  565. }
  566. }
  567. }
  568. //-----------------------------------------------------------------------------
  569. // Mouse Locking
  570. //-----------------------------------------------------------------------------
  571. void PlatformWindowSDL::setMouseLocked( bool enable )
  572. {
  573. if (mOffscreenRender)
  574. return;
  575. mMouseLocked = enable;
  576. SDL_SetWindowGrab( mWindowHandle, SDL_bool(enable) );
  577. SDL_SetRelativeMouseMode( SDL_bool(enable) );
  578. }
  579. const UTF16 *PlatformWindowSDL::getWindowClassName()
  580. {
  581. // TODO SDL
  582. static String str("WindowClassName");
  583. return str.utf16();
  584. }
  585. const UTF16 *PlatformWindowSDL::getCurtainWindowClassName()
  586. {
  587. // TODO SDL
  588. static String str("CurtainWindowClassName");
  589. return str.utf16();
  590. }
  591. void PlatformWindowSDL::setKeyboardTranslation(const bool enabled)
  592. {
  593. mEnableKeyboardTranslation = enabled;
  594. // Flag for update. Let SDL know what kind of input state we are changing to.
  595. if (enabled)
  596. mOwningManager->updateSDLTextInputState(PlatformWindowManagerSDL::KeyboardInputState::TEXT_INPUT);
  597. else
  598. mOwningManager->updateSDLTextInputState(PlatformWindowManagerSDL::KeyboardInputState::RAW_INPUT);
  599. }