Input.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #include "Context.h"
  24. #include "CoreEvents.h"
  25. #include "Graphics.h"
  26. #include "GraphicsEvents.h"
  27. #include "Input.h"
  28. #include "Log.h"
  29. #include "Profiler.h"
  30. #include <cstring>
  31. #ifndef USE_SDL
  32. #include <Windows.h>
  33. #else
  34. #include <SDL.h>
  35. #endif
  36. #include "DebugNew.h"
  37. OBJECTTYPESTATIC(Input);
  38. Input::Input(Context* context) :
  39. Object(context),
  40. clipCursor_(true),
  41. showCursor_(true),
  42. toggleFullscreen_(true),
  43. active_(false),
  44. minimized_(false),
  45. activated_(false),
  46. suppressNextChar_(false),
  47. initialized_(false)
  48. {
  49. // Zero the initial state
  50. mouseButtonDown_ = 0;
  51. mouseButtonPress_ = 0;
  52. lastMousePosition_ = IntVector2::ZERO;
  53. #ifndef USE_SDL
  54. SubscribeToEvent(E_WINDOWMESSAGE, HANDLER(Input, HandleWindowMessage));
  55. #endif
  56. SubscribeToEvent(E_SCREENMODE, HANDLER(Input, HandleScreenMode));
  57. SubscribeToEvent(E_BEGINFRAME, HANDLER(Input, HandleBeginFrame));
  58. // Try to initialize right now, but skip if screen mode is not yet set
  59. Initialize();
  60. }
  61. Input::~Input()
  62. {
  63. }
  64. void Input::Update()
  65. {
  66. PROFILE(UpdateInput);
  67. if (!graphics_)
  68. return;
  69. // Reset current state
  70. keyPress_.Clear();
  71. mouseButtonPress_ = 0;
  72. mouseMove_ = IntVector2::ZERO;
  73. mouseMoveWheel_ = 0;
  74. #ifndef USE_SDL
  75. // Pump Win32 events
  76. MSG msg;
  77. while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
  78. {
  79. TranslateMessage(&msg);
  80. DispatchMessage(&msg);
  81. }
  82. #else
  83. // Pump SDL events
  84. SDL_Event evt;
  85. SDL_PumpEvents();
  86. while (SDL_PollEvent(&evt))
  87. HandleSDLEvent(&evt);
  88. // Poll SDL activation state
  89. unsigned state = SDL_GetAppState();
  90. if ((state & (SDL_APPINPUTFOCUS | SDL_APPACTIVE)) == (SDL_APPINPUTFOCUS | SDL_APPACTIVE))
  91. {
  92. if (!active_)
  93. activated_ = true;
  94. }
  95. else
  96. {
  97. if (active_)
  98. MakeInactive();
  99. }
  100. #endif
  101. // Activate application now if necessary
  102. if (activated_)
  103. MakeActive();
  104. // Finally send the mouse move event if motion has been accumulated
  105. if (active_)
  106. {
  107. // Require the operating system cursor to be hidden first
  108. IntVector2 mousePos = GetMousePosition();
  109. mouseMove_ = (!showCursor_) ? mousePos - lastMousePosition_ : IntVector2::ZERO;
  110. // Recenter the mouse cursor manually if cursor clipping is in effect
  111. if ((clipCursor_) && (mouseMove_ != IntVector2::ZERO))
  112. {
  113. IntVector2 center(graphics_->GetWidth() / 2, graphics_->GetHeight() / 2);
  114. SetMousePosition(center);
  115. lastMousePosition_ = GetMousePosition();
  116. }
  117. else
  118. lastMousePosition_ = mousePos;
  119. if (mouseMove_ != IntVector2::ZERO)
  120. {
  121. using namespace MouseMove;
  122. VariantMap eventData;
  123. eventData[P_X] = lastMousePosition_.x_;
  124. eventData[P_Y] = lastMousePosition_.y_;
  125. eventData[P_DX] = mouseMove_.x_;
  126. eventData[P_DY] = mouseMove_.y_;
  127. eventData[P_BUTTONS] = mouseButtonDown_;
  128. eventData[P_QUALIFIERS] = GetQualifiers();
  129. eventData[P_CLIPCURSOR] = clipCursor_;
  130. SendEvent(E_MOUSEMOVE, eventData);
  131. }
  132. }
  133. }
  134. void Input::SetClipCursor(bool enable)
  135. {
  136. clipCursor_ = enable;
  137. if (!graphics_)
  138. return;
  139. if ((!graphics_->GetFullscreen()) && (active_) && (clipCursor_))
  140. {
  141. SetMousePosition(graphics_->GetWidth() / 2, graphics_->GetHeight() / 2);
  142. lastMousePosition_ = GetMousePosition();
  143. #ifndef USE_SDL
  144. RECT clipRect;
  145. GetWindowRect((HWND)graphics_->GetWindowHandle(), &clipRect);
  146. ClipCursor(&clipRect);
  147. #endif
  148. }
  149. else
  150. {
  151. if ((graphics_->GetFullscreen()) && (active_) && (clipCursor_))
  152. {
  153. SetMousePosition(graphics_->GetWidth() / 2, graphics_->GetHeight() / 2);
  154. lastMousePosition_ = GetMousePosition();
  155. }
  156. #ifndef USE_SDL
  157. ClipCursor(0);
  158. #endif
  159. }
  160. }
  161. void Input::SetToggleFullscreen(bool enable)
  162. {
  163. toggleFullscreen_ = enable;
  164. }
  165. void Input::SetMousePosition(const IntVector2& position)
  166. {
  167. if (!graphics_)
  168. return;
  169. #ifndef USE_SDL
  170. POINT point;
  171. point.x = position.x_;
  172. point.y = position.y_;
  173. ClientToScreen((HWND)graphics_->GetWindowHandle(), &point);
  174. SetCursorPos(point.x, point.y);
  175. #else
  176. SDL_WarpMouse(position.x_, position.y_);
  177. #endif
  178. }
  179. void Input::SetMousePosition(int x, int y)
  180. {
  181. SetMousePosition(IntVector2(x, y));
  182. }
  183. void Input::SuppressNextChar()
  184. {
  185. suppressNextChar_ = true;
  186. }
  187. bool Input::GetKeyDown(int key) const
  188. {
  189. return keyDown_.Contains(key);
  190. }
  191. bool Input::GetKeyPress(int key) const
  192. {
  193. return keyPress_.Contains(key);
  194. }
  195. IntVector2 Input::GetMousePosition() const
  196. {
  197. IntVector2 ret(0, 0);
  198. if (!graphics_)
  199. return ret;
  200. #ifndef USE_SDL
  201. POINT mouse;
  202. GetCursorPos(&mouse);
  203. ScreenToClient((HWND)graphics_->GetWindowHandle(), &mouse);
  204. ret.x_ = mouse.x;
  205. ret.y_ = mouse.y;
  206. #else
  207. SDL_GetMouseState(&ret.x_, &ret.y_);
  208. #endif
  209. return ret;
  210. }
  211. bool Input::GetMouseButtonDown(int button) const
  212. {
  213. return (mouseButtonDown_ & button) != 0;
  214. }
  215. bool Input::GetMouseButtonPress(int button) const
  216. {
  217. return (mouseButtonPress_ & button) != 0;
  218. }
  219. bool Input::GetQualifierDown(int qualifier) const
  220. {
  221. #ifndef USE_SDL
  222. if (qualifier == QUAL_SHIFT)
  223. return GetKeyDown(KEY_SHIFT);
  224. if (qualifier == QUAL_CTRL)
  225. return GetKeyDown(KEY_CTRL);
  226. if (qualifier == QUAL_ALT)
  227. return GetKeyDown(KEY_ALT);
  228. #else
  229. if (qualifier == QUAL_SHIFT)
  230. return GetKeyDown(KEY_LSHIFT) || GetKeyDown(KEY_RSHIFT);
  231. if (qualifier == QUAL_CTRL)
  232. return GetKeyDown(KEY_LCTRL) || GetKeyDown(KEY_RCTRL);
  233. if (qualifier == QUAL_ALT)
  234. return GetKeyDown(KEY_LALT) || GetKeyDown(KEY_RALT);
  235. #endif
  236. return false;
  237. }
  238. bool Input::GetQualifierPress(int qualifier) const
  239. {
  240. #ifndef USE_SDL
  241. if (qualifier == QUAL_SHIFT)
  242. return GetKeyPress(KEY_SHIFT);
  243. if (qualifier == QUAL_CTRL)
  244. return GetKeyPress(KEY_CTRL);
  245. if (qualifier == QUAL_ALT)
  246. return GetKeyPress(KEY_ALT);
  247. #else
  248. if (qualifier == QUAL_SHIFT)
  249. return GetKeyPress(KEY_LSHIFT) || GetKeyPress(KEY_RSHIFT);
  250. if (qualifier == QUAL_CTRL)
  251. return GetKeyPress(KEY_LCTRL) || GetKeyPress(KEY_RCTRL);
  252. if (qualifier == QUAL_ALT)
  253. return GetKeyPress(KEY_LALT) || GetKeyPress(KEY_RALT);
  254. #endif
  255. return false;
  256. }
  257. int Input::GetQualifiers() const
  258. {
  259. int ret = 0;
  260. if (GetQualifierDown(QUAL_SHIFT))
  261. ret |= QUAL_SHIFT;
  262. if (GetQualifierDown(QUAL_CTRL))
  263. ret |= QUAL_CTRL;
  264. if (GetQualifierDown(QUAL_ALT))
  265. ret |= QUAL_ALT;
  266. return ret;
  267. }
  268. void Input::Initialize()
  269. {
  270. Graphics* graphics = GetSubsystem<Graphics>();
  271. if ((!graphics) || (!graphics->IsInitialized()))
  272. return;
  273. graphics_ = graphics;
  274. #ifdef USE_SDL
  275. // Enable translated keyboard input
  276. SDL_EnableUNICODE(SDL_TRUE);
  277. #endif
  278. // Set the initial activation
  279. MakeActive();
  280. SetClipCursor(clipCursor_);
  281. SetCursorVisible(false);
  282. initialized_ = true;
  283. LOGINFO("Initialized input");
  284. }
  285. void Input::MakeActive()
  286. {
  287. if (!graphics_)
  288. return;
  289. ResetState();
  290. active_ = true;
  291. activated_ = false;
  292. // Re-establish mouse cursor clipping immediately in fullscreen. In windowed mode, require a mouse click inside the window
  293. // to not confuse with title bar drag
  294. if (graphics_->GetFullscreen())
  295. {
  296. SetClipCursor(clipCursor_);
  297. SetCursorVisible(false);
  298. }
  299. using namespace Activation;
  300. VariantMap eventData;
  301. eventData[P_ACTIVE] = active_;
  302. eventData[P_MINIMIZED] = minimized_;
  303. SendEvent(E_ACTIVATION, eventData);
  304. }
  305. void Input::MakeInactive()
  306. {
  307. if (!graphics_)
  308. return;
  309. ResetState();
  310. active_ = false;
  311. activated_ = false;
  312. // Free and show the mouse cursor
  313. #ifndef USE_SDL
  314. ReleaseCapture();
  315. ClipCursor(0);
  316. #endif
  317. SetCursorVisible(true);
  318. using namespace Activation;
  319. VariantMap eventData;
  320. eventData[P_ACTIVE] = active_;
  321. eventData[P_MINIMIZED] = minimized_;
  322. SendEvent(E_ACTIVATION, eventData);
  323. }
  324. void Input::ResetState()
  325. {
  326. keyDown_.Clear();
  327. keyPress_.Clear();
  328. // Use SetMouseButton() to reset the state so that mouse events will be sent properly
  329. SetMouseButton(MOUSEB_LEFT, false);
  330. SetMouseButton(MOUSEB_RIGHT, false);
  331. SetMouseButton(MOUSEB_MIDDLE, false);
  332. mouseMove_ = IntVector2::ZERO;
  333. mouseMoveWheel_ = 0;
  334. mouseButtonPress_ = 0;
  335. }
  336. void Input::SetMouseButton(int button, bool newState)
  337. {
  338. // If we are not active yet, do not react to the mouse button down
  339. if ((newState) && (!active_))
  340. return;
  341. // If we are still showing the cursor (waiting for a click inside window), hide it now and disregard this click
  342. if ((newState) && (showCursor_))
  343. {
  344. SetClipCursor(clipCursor_);
  345. SetCursorVisible(false);
  346. return;
  347. }
  348. if (newState)
  349. {
  350. if (!(mouseButtonDown_ & button))
  351. mouseButtonPress_ |= button;
  352. mouseButtonDown_ |= button;
  353. }
  354. else
  355. {
  356. if (!(mouseButtonDown_ & button))
  357. return;
  358. mouseButtonDown_ &= ~button;
  359. }
  360. using namespace MouseButtonDown;
  361. VariantMap eventData;
  362. eventData[P_BUTTON] = button;
  363. eventData[P_BUTTONS] = mouseButtonDown_;
  364. eventData[P_QUALIFIERS] = GetQualifiers();
  365. SendEvent(newState ? E_MOUSEBUTTONDOWN : E_MOUSEBUTTONUP, eventData);
  366. #ifndef USE_SDL
  367. // In non-clipped mode, while any of the mouse buttons are down, capture the mouse so that we get the button release reliably
  368. if ((graphics_) && (!clipCursor_))
  369. {
  370. if (mouseButtonDown_)
  371. SetCapture((HWND)graphics_->GetWindowHandle());
  372. else
  373. ReleaseCapture();
  374. }
  375. #endif
  376. }
  377. void Input::SetKey(int key, int scanCode, bool newState)
  378. {
  379. // If we are not active yet, do not react to the key down
  380. if ((newState) && (!active_))
  381. return;
  382. bool repeat = false;
  383. if (newState)
  384. {
  385. if (!keyDown_.Contains(key))
  386. {
  387. keyDown_.Insert(key);
  388. keyPress_.Insert(key);
  389. }
  390. else
  391. repeat = true;
  392. }
  393. else
  394. {
  395. if (!keyDown_.Erase(key))
  396. return;
  397. }
  398. using namespace KeyDown;
  399. VariantMap eventData;
  400. eventData[P_KEY] = key;
  401. eventData[P_SCANCODE] = scanCode;
  402. eventData[P_BUTTONS] = mouseButtonDown_;
  403. eventData[P_QUALIFIERS] = GetQualifiers();
  404. if (newState)
  405. eventData[P_REPEAT] = repeat;
  406. SendEvent(newState ? E_KEYDOWN : E_KEYUP, eventData);
  407. }
  408. void Input::SetMouseWheel(int delta)
  409. {
  410. // If we are not active yet, do not react to the wheel
  411. if (!active_)
  412. return;
  413. if (delta)
  414. {
  415. mouseMoveWheel_ += delta;
  416. using namespace MouseWheel;
  417. VariantMap eventData;
  418. eventData[P_WHEEL] = delta;
  419. eventData[P_BUTTONS] = mouseButtonDown_;
  420. eventData[P_QUALIFIERS] = GetQualifiers();
  421. SendEvent(E_MOUSEWHEEL, eventData);
  422. }
  423. }
  424. void Input::SetCursorVisible(bool enable)
  425. {
  426. if (!graphics_)
  427. return;
  428. #ifndef USE_SDL
  429. // When inactive, always show the cursor
  430. if (!active_)
  431. enable = true;
  432. if (showCursor_ == enable)
  433. return;
  434. ShowCursor(enable ? TRUE : FALSE);
  435. #else
  436. SDL_ShowCursor(enable ? SDL_TRUE : SDL_FALSE);
  437. #endif
  438. showCursor_ = enable;
  439. }
  440. #ifndef USE_SDL
  441. void Input::HandleWindowMessage(StringHash eventType, VariantMap& eventData)
  442. {
  443. using namespace WindowMessage;
  444. int msg = eventData[P_MSG].GetInt();
  445. int wParam = eventData[P_WPARAM].GetInt();
  446. int lParam = eventData[P_LPARAM].GetInt();
  447. switch (msg)
  448. {
  449. case WM_LBUTTONDOWN:
  450. SetMouseButton(MOUSEB_LEFT, true);
  451. eventData[P_HANDLED] = true;
  452. break;
  453. case WM_NCLBUTTONUP:
  454. case WM_LBUTTONUP:
  455. SetMouseButton(MOUSEB_LEFT, false);
  456. eventData[P_HANDLED] = true;
  457. break;
  458. case WM_RBUTTONDOWN:
  459. SetMouseButton(MOUSEB_RIGHT, true);
  460. eventData[P_HANDLED] = true;
  461. break;
  462. case WM_NCRBUTTONUP:
  463. case WM_RBUTTONUP:
  464. SetMouseButton(MOUSEB_RIGHT, false);
  465. eventData[P_HANDLED] = true;
  466. break;
  467. case WM_MBUTTONDOWN:
  468. SetMouseButton(MOUSEB_MIDDLE, true);
  469. eventData[P_HANDLED] = true;
  470. break;
  471. case WM_NCMBUTTONUP:
  472. case WM_MBUTTONUP:
  473. SetMouseButton(MOUSEB_MIDDLE, false);
  474. eventData[P_HANDLED] = true;
  475. break;
  476. case WM_MOUSEWHEEL:
  477. SetMouseWheel(wParam >> 16);
  478. eventData[P_HANDLED] = true;
  479. break;
  480. case WM_ACTIVATE:
  481. minimized_ = HIWORD(wParam) != 0;
  482. if (LOWORD(wParam) == WA_INACTIVE)
  483. MakeInactive();
  484. else
  485. {
  486. if (!minimized_)
  487. activated_ = true;
  488. }
  489. eventData[P_HANDLED] = true;
  490. break;
  491. case WM_KEYDOWN:
  492. SetKey(wParam, (lParam >> 16) & 255, true);
  493. eventData[P_HANDLED] = true;
  494. break;
  495. case WM_SYSKEYDOWN:
  496. SetKey(wParam, (lParam >> 16) & 255, true);
  497. if ((wParam == KEY_RETURN) && (toggleFullscreen_))
  498. graphics_->ToggleFullscreen();
  499. if (wParam != KEY_F4)
  500. eventData[P_HANDLED] = true;
  501. break;
  502. case WM_KEYUP:
  503. SetKey(wParam, (lParam >> 16) & 255, false);
  504. eventData[P_HANDLED] = true;
  505. break;
  506. case WM_SYSKEYUP:
  507. SetKey(wParam, (lParam >> 16) & 255, false);
  508. eventData[P_HANDLED] = true;
  509. break;
  510. case WM_CHAR:
  511. if (!suppressNextChar_)
  512. {
  513. using namespace Char;
  514. VariantMap keyEventData;
  515. keyEventData[P_CHAR] = wParam;
  516. keyEventData[P_BUTTONS] = mouseButtonDown_;
  517. keyEventData[P_QUALIFIERS] = GetQualifiers();
  518. SendEvent(E_CHAR, keyEventData);
  519. }
  520. suppressNextChar_ = false;
  521. eventData[P_HANDLED] = true;
  522. break;
  523. case WM_SETCURSOR:
  524. if ((lParam & 0xffff) == HTCLIENT)
  525. {
  526. SetCursorVisible(false);
  527. eventData[P_HANDLED] = true;
  528. }
  529. else
  530. SetCursorVisible(true);
  531. break;
  532. }
  533. }
  534. #else
  535. void Input::HandleSDLEvent(void* sdlEvent)
  536. {
  537. SDL_Event& evt = *static_cast<SDL_Event*>(sdlEvent);
  538. switch (evt.type)
  539. {
  540. case SDL_KEYDOWN:
  541. // Convert to uppercase to match Win32 virtual key codes
  542. SetKey(SDL_toupper(evt.key.keysym.sym), evt.key.keysym.scancode, true);
  543. // Check ALT-ENTER fullscreen toggle
  544. if ((evt.key.keysym.sym == KEY_RETURN) && ((GetKeyDown(KEY_LALT)) || (GetKeyDown(KEY_RALT))) && (toggleFullscreen_))
  545. graphics_->ToggleFullscreen();
  546. break;
  547. case SDL_KEYUP:
  548. SetKey(SDL_toupper(evt.key.keysym.sym), evt.key.keysym.scancode, false);
  549. break;
  550. case SDL_TEXTINPUT:
  551. // Convert back to Latin-1
  552. if (!suppressNextChar_)
  553. {
  554. unsigned char x = evt.text.text[0];
  555. unsigned char y = evt.text.text[1];
  556. int latin1 = 0;
  557. if (x < 0x80)
  558. latin1 = x;
  559. else if (x < 0xe0)
  560. latin1 = (y & 0x3f) | ((x & 0x1f) << 6);
  561. if ((latin1) && (latin1 < 256))
  562. {
  563. using namespace Char;
  564. VariantMap keyEventData;
  565. keyEventData[P_CHAR] = latin1;
  566. keyEventData[P_BUTTONS] = mouseButtonDown_;
  567. keyEventData[P_QUALIFIERS] = GetQualifiers();
  568. SendEvent(E_CHAR, keyEventData);
  569. }
  570. }
  571. else
  572. suppressNextChar_ = false;
  573. break;
  574. case SDL_MOUSEBUTTONDOWN:
  575. SetMouseButton(1 << (evt.button.button - 1), true);
  576. break;
  577. case SDL_MOUSEBUTTONUP:
  578. SetMouseButton(1 << (evt.button.button - 1), false);
  579. break;
  580. case SDL_MOUSEWHEEL:
  581. SetMouseWheel(evt.wheel.y);
  582. break;
  583. case SDL_QUIT:
  584. if (graphics_)
  585. graphics_->Close();
  586. break;
  587. }
  588. }
  589. #endif
  590. void Input::HandleScreenMode(StringHash eventType, VariantMap& eventData)
  591. {
  592. if (!initialized_)
  593. Initialize();
  594. // Screen mode change may affect the cursor clipping behaviour. Also re-center the cursor (if needed) to the new screen size,
  595. // so that there is no erroneous mouse move event
  596. else
  597. SetClipCursor(clipCursor_);
  598. }
  599. void Input::HandleBeginFrame(StringHash eventType, VariantMap& eventData)
  600. {
  601. // Update input right at the beginning of the frame
  602. if (initialized_)
  603. Update();
  604. }