sdlWindow.cpp 17 KB

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