Input.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2012 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 "StringUtils.h"
  31. #include <cstring>
  32. #ifndef USE_OPENGL
  33. #include <windows.h>
  34. #else
  35. #include <GraphicsImpl.h>
  36. #endif
  37. #include "DebugNew.h"
  38. #ifndef USE_OPENGL
  39. /// Convert the virtual key code & scan code if necessary. Return non-zero if key should be posted
  40. int ConvertKeyCode(unsigned wParam, unsigned lParam)
  41. {
  42. unsigned scanCode = (lParam >> 16) & 0x1ff;
  43. // Recognize left/right qualifier key from the scan code
  44. switch (wParam)
  45. {
  46. case VK_SHIFT:
  47. if (scanCode == 54)
  48. return KEY_RSHIFT;
  49. else
  50. return KEY_LSHIFT;
  51. break;
  52. case VK_CONTROL:
  53. // Control might not be a real key, as Windows posts it whenever Alt-Gr is pressed (inspired by GLFW)
  54. {
  55. MSG nextMsg;
  56. DWORD msgTime = GetMessageTime();
  57. if (PeekMessage(&nextMsg, NULL, 0, 0, PM_NOREMOVE))
  58. {
  59. if ((nextMsg.message == WM_KEYDOWN || nextMsg.message == WM_SYSKEYDOWN) && nextMsg.wParam == VK_MENU &&
  60. (nextMsg.lParam & 0x01000000) != 0 && nextMsg.time == msgTime)
  61. return 0;
  62. }
  63. if (scanCode & 0x100)
  64. return KEY_RCTRL;
  65. else
  66. return KEY_LCTRL;
  67. }
  68. break;
  69. case VK_MENU:
  70. if (scanCode & 0x100)
  71. return KEY_RALT;
  72. else
  73. return KEY_LALT;
  74. default:
  75. return wParam;
  76. }
  77. }
  78. #endif
  79. OBJECTTYPESTATIC(Input);
  80. Input::Input(Context* context) :
  81. Object(context),
  82. showCursor_(true),
  83. toggleFullscreen_(true),
  84. active_(false),
  85. minimized_(false),
  86. activated_(false),
  87. suppressNextChar_(false),
  88. suppressNextMouseMove_(false),
  89. initialized_(false)
  90. {
  91. // Zero the initial state
  92. mouseButtonDown_ = 0;
  93. ResetState();
  94. #ifndef USE_OPENGL
  95. SubscribeToEvent(E_WINDOWMESSAGE, HANDLER(Input, HandleWindowMessage));
  96. #endif
  97. SubscribeToEvent(E_SCREENMODE, HANDLER(Input, HandleScreenMode));
  98. SubscribeToEvent(E_BEGINFRAME, HANDLER(Input, HandleBeginFrame));
  99. // Try to initialize right now, but skip if screen mode is not yet set
  100. Initialize();
  101. }
  102. Input::~Input()
  103. {
  104. }
  105. void Input::Update()
  106. {
  107. PROFILE(UpdateInput);
  108. if (!graphics_ || !graphics_->IsInitialized())
  109. return;
  110. // Reset input accumulation for this frame
  111. keyPress_.Clear();
  112. mouseButtonPress_ = 0;
  113. mouseMove_ = IntVector2::ZERO;
  114. mouseMoveWheel_ = 0;
  115. #ifndef USE_OPENGL
  116. // Pump Win32 events
  117. MSG msg;
  118. while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
  119. {
  120. TranslateMessage(&msg);
  121. DispatchMessage(&msg);
  122. }
  123. #else
  124. // Pump GLFW events
  125. glfwPollEvents();
  126. // Check for input inactivation
  127. if (active_ && !glfwGetWindowParam(graphics_->GetWindowHandle(), GLFW_ACTIVE))
  128. MakeInactive();
  129. #endif
  130. // Activate input now if necessary
  131. if (activated_)
  132. MakeActive();
  133. // Finally send the mouse move event if motion has been accumulated
  134. if (active_)
  135. {
  136. #ifndef USE_OPENGL
  137. IntVector2 mousePos = GetCursorPosition();
  138. mouseMove_ = mousePos - lastCursorPosition_;
  139. // Recenter the mouse cursor manually if it moved
  140. if (mouseMove_ != IntVector2::ZERO)
  141. {
  142. IntVector2 center(graphics_->GetWidth() / 2, graphics_->GetHeight() / 2);
  143. SetCursorPosition(center);
  144. lastCursorPosition_ = GetCursorPosition();
  145. }
  146. else
  147. lastCursorPosition_ = mousePos;
  148. #else
  149. IntVector2 mousePos = GetCursorPosition();
  150. mouseMove_ = mousePos - lastCursorPosition_;
  151. lastCursorPosition_ = mousePos;
  152. #endif
  153. if (mouseMove_ != IntVector2::ZERO && suppressNextMouseMove_)
  154. {
  155. mouseMove_ = IntVector2::ZERO;
  156. suppressNextMouseMove_ = false;
  157. }
  158. if (mouseMove_ != IntVector2::ZERO)
  159. {
  160. using namespace MouseMove;
  161. VariantMap eventData;
  162. eventData[P_DX] = mouseMove_.x_;
  163. eventData[P_DY] = mouseMove_.y_;
  164. eventData[P_BUTTONS] = mouseButtonDown_;
  165. eventData[P_QUALIFIERS] = GetQualifiers();
  166. SendEvent(E_MOUSEMOVE, eventData);
  167. }
  168. }
  169. }
  170. void Input::SetToggleFullscreen(bool enable)
  171. {
  172. toggleFullscreen_ = enable;
  173. }
  174. void Input::SuppressNextChar()
  175. {
  176. suppressNextChar_ = true;
  177. }
  178. bool Input::GetKeyDown(int key) const
  179. {
  180. return keyDown_.Contains(key);
  181. }
  182. bool Input::GetKeyPress(int key) const
  183. {
  184. return keyPress_.Contains(key);
  185. }
  186. bool Input::GetMouseButtonDown(int button) const
  187. {
  188. return (mouseButtonDown_ & button) != 0;
  189. }
  190. bool Input::GetMouseButtonPress(int button) const
  191. {
  192. return (mouseButtonPress_ & button) != 0;
  193. }
  194. bool Input::GetQualifierDown(int qualifier) const
  195. {
  196. if (qualifier == QUAL_SHIFT)
  197. return GetKeyDown(KEY_LSHIFT) || GetKeyDown(KEY_RSHIFT);
  198. if (qualifier == QUAL_CTRL)
  199. return GetKeyDown(KEY_LCTRL) || GetKeyDown(KEY_RCTRL);
  200. if (qualifier == QUAL_ALT)
  201. return GetKeyDown(KEY_LALT) || GetKeyDown(KEY_RALT);
  202. return false;
  203. }
  204. bool Input::GetQualifierPress(int qualifier) const
  205. {
  206. if (qualifier == QUAL_SHIFT)
  207. return GetKeyPress(KEY_LSHIFT) || GetKeyPress(KEY_RSHIFT);
  208. if (qualifier == QUAL_CTRL)
  209. return GetKeyPress(KEY_LCTRL) || GetKeyPress(KEY_RCTRL);
  210. if (qualifier == QUAL_ALT)
  211. return GetKeyPress(KEY_LALT) || GetKeyPress(KEY_RALT);
  212. return false;
  213. }
  214. int Input::GetQualifiers() const
  215. {
  216. int ret = 0;
  217. if (GetQualifierDown(QUAL_SHIFT))
  218. ret |= QUAL_SHIFT;
  219. if (GetQualifierDown(QUAL_CTRL))
  220. ret |= QUAL_CTRL;
  221. if (GetQualifierDown(QUAL_ALT))
  222. ret |= QUAL_ALT;
  223. return ret;
  224. }
  225. void Input::Initialize()
  226. {
  227. Graphics* graphics = GetSubsystem<Graphics>();
  228. if (!graphics || !graphics->IsInitialized())
  229. return;
  230. graphics_ = graphics;
  231. // Set the initial activation
  232. activated_ = true;
  233. initialized_ = true;
  234. LOGINFO("Initialized input");
  235. }
  236. void Input::MakeActive()
  237. {
  238. if (!graphics_ || !graphics_->IsInitialized())
  239. return;
  240. ResetState();
  241. active_ = true;
  242. activated_ = false;
  243. // Re-establish mouse cursor clipping as necessary
  244. #ifndef USE_OPENGL
  245. SetClipCursor(true);
  246. SetCursorVisible(false);
  247. #else
  248. glfwSetInputMode(graphics_->GetWindowHandle(), GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED);
  249. lastCursorPosition_ = GetCursorPosition();
  250. suppressNextMouseMove_ = true;
  251. #endif
  252. using namespace Activation;
  253. VariantMap eventData;
  254. eventData[P_ACTIVE] = active_;
  255. eventData[P_MINIMIZED] = minimized_;
  256. SendEvent(E_ACTIVATION, eventData);
  257. }
  258. void Input::MakeInactive()
  259. {
  260. if (!graphics_ || !graphics_->IsInitialized())
  261. return;
  262. ResetState();
  263. active_ = false;
  264. activated_ = false;
  265. // Free and show the mouse cursor
  266. #ifndef USE_OPENGL
  267. ReleaseCapture();
  268. ClipCursor(0);
  269. SetCursorVisible(true);
  270. #else
  271. glfwSetInputMode(graphics_->GetWindowHandle(), GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
  272. #endif
  273. using namespace Activation;
  274. VariantMap eventData;
  275. eventData[P_ACTIVE] = active_;
  276. eventData[P_MINIMIZED] = minimized_;
  277. SendEvent(E_ACTIVATION, eventData);
  278. }
  279. void Input::ResetState()
  280. {
  281. keyDown_.Clear();
  282. keyPress_.Clear();
  283. // Use SetMouseButton() to reset the state so that mouse events will be sent properly
  284. SetMouseButton(MOUSEB_LEFT, false);
  285. SetMouseButton(MOUSEB_RIGHT, false);
  286. SetMouseButton(MOUSEB_MIDDLE, false);
  287. mouseMove_ = IntVector2::ZERO;
  288. mouseMoveWheel_ = 0;
  289. mouseButtonPress_ = 0;
  290. }
  291. void Input::SetMouseButton(int button, bool newState)
  292. {
  293. // In GLFW mode, activate by a left-click inside the window
  294. #ifdef USE_OPENGL
  295. if (graphics_ && initialized_)
  296. {
  297. if (glfwGetWindowParam(graphics_->GetWindowHandle(), GLFW_ACTIVE) && !active_ && newState && button == MOUSEB_LEFT)
  298. activated_ = true;
  299. }
  300. #endif
  301. // If we are not active yet, do not react to the mouse button down
  302. if (newState && !active_)
  303. return;
  304. if (newState)
  305. {
  306. if (!(mouseButtonDown_ & button))
  307. mouseButtonPress_ |= button;
  308. mouseButtonDown_ |= button;
  309. }
  310. else
  311. {
  312. if (!(mouseButtonDown_ & button))
  313. return;
  314. mouseButtonDown_ &= ~button;
  315. }
  316. using namespace MouseButtonDown;
  317. VariantMap eventData;
  318. eventData[P_BUTTON] = button;
  319. eventData[P_BUTTONS] = mouseButtonDown_;
  320. eventData[P_QUALIFIERS] = GetQualifiers();
  321. SendEvent(newState ? E_MOUSEBUTTONDOWN : E_MOUSEBUTTONUP, eventData);
  322. }
  323. void Input::SetKey(int key, bool newState)
  324. {
  325. // If we are not active yet, do not react to the key down
  326. if (newState && !active_)
  327. return;
  328. bool repeat = false;
  329. if (newState)
  330. {
  331. if (!keyDown_.Contains(key))
  332. {
  333. keyDown_.Insert(key);
  334. keyPress_.Insert(key);
  335. }
  336. else
  337. repeat = true;
  338. }
  339. else
  340. {
  341. if (!keyDown_.Erase(key))
  342. return;
  343. }
  344. using namespace KeyDown;
  345. VariantMap eventData;
  346. eventData[P_KEY] = key;
  347. eventData[P_BUTTONS] = mouseButtonDown_;
  348. eventData[P_QUALIFIERS] = GetQualifiers();
  349. if (newState)
  350. eventData[P_REPEAT] = repeat;
  351. SendEvent(newState ? E_KEYDOWN : E_KEYUP, eventData);
  352. if (key == KEY_RETURN && newState && !repeat && toggleFullscreen_ && (GetKeyDown(KEY_LALT) || GetKeyDown(KEY_RALT)))
  353. graphics_->ToggleFullscreen();
  354. }
  355. void Input::SetMouseWheel(int delta)
  356. {
  357. // If we are not active yet, do not react to the wheel
  358. if (!active_)
  359. return;
  360. if (delta)
  361. {
  362. mouseMoveWheel_ += delta;
  363. using namespace MouseWheel;
  364. VariantMap eventData;
  365. eventData[P_WHEEL] = delta;
  366. eventData[P_BUTTONS] = mouseButtonDown_;
  367. eventData[P_QUALIFIERS] = GetQualifiers();
  368. SendEvent(E_MOUSEWHEEL, eventData);
  369. }
  370. }
  371. #ifndef USE_OPENGL
  372. void Input::SetClipCursor(bool enable)
  373. {
  374. if (!graphics_)
  375. return;
  376. if (!graphics_->GetFullscreen() && active_ && enable)
  377. {
  378. SetCursorPosition(IntVector2(graphics_->GetWidth() / 2, graphics_->GetHeight() / 2));
  379. lastCursorPosition_ = GetCursorPosition();
  380. RECT clipRect;
  381. GetWindowRect((HWND)graphics_->GetWindowHandle(), &clipRect);
  382. ClipCursor(&clipRect);
  383. }
  384. else
  385. {
  386. if (graphics_->GetFullscreen() && active_ && enable)
  387. {
  388. SetCursorPosition(IntVector2(graphics_->GetWidth() / 2, graphics_->GetHeight() / 2));
  389. lastCursorPosition_ = GetCursorPosition();
  390. }
  391. ClipCursor(0);
  392. }
  393. }
  394. void Input::SetCursorPosition(const IntVector2& position)
  395. {
  396. if (!graphics_)
  397. return;
  398. POINT point;
  399. point.x = position.x_;
  400. point.y = position.y_;
  401. ClientToScreen((HWND)graphics_->GetWindowHandle(), &point);
  402. SetCursorPos(point.x, point.y);
  403. }
  404. void Input::SetCursorVisible(bool enable)
  405. {
  406. if (!graphics_)
  407. return;
  408. // When inactive, always show the cursor
  409. if (!active_)
  410. enable = true;
  411. if (showCursor_ == enable)
  412. return;
  413. ShowCursor(enable ? TRUE : FALSE);
  414. showCursor_ = enable;
  415. }
  416. void Input::HandleWindowMessage(StringHash eventType, VariantMap& eventData)
  417. {
  418. using namespace WindowMessage;
  419. int msg = eventData[P_MSG].GetInt();
  420. int wParam = eventData[P_WPARAM].GetInt();
  421. int lParam = eventData[P_LPARAM].GetInt();
  422. int keyCode;
  423. switch (msg)
  424. {
  425. case WM_LBUTTONDOWN:
  426. SetMouseButton(MOUSEB_LEFT, true);
  427. eventData[P_HANDLED] = true;
  428. break;
  429. case WM_NCLBUTTONUP:
  430. case WM_LBUTTONUP:
  431. SetMouseButton(MOUSEB_LEFT, false);
  432. eventData[P_HANDLED] = true;
  433. break;
  434. case WM_RBUTTONDOWN:
  435. SetMouseButton(MOUSEB_RIGHT, true);
  436. eventData[P_HANDLED] = true;
  437. break;
  438. case WM_NCRBUTTONUP:
  439. case WM_RBUTTONUP:
  440. SetMouseButton(MOUSEB_RIGHT, false);
  441. eventData[P_HANDLED] = true;
  442. break;
  443. case WM_MBUTTONDOWN:
  444. SetMouseButton(MOUSEB_MIDDLE, true);
  445. eventData[P_HANDLED] = true;
  446. break;
  447. case WM_NCMBUTTONUP:
  448. case WM_MBUTTONUP:
  449. SetMouseButton(MOUSEB_MIDDLE, false);
  450. eventData[P_HANDLED] = true;
  451. break;
  452. case WM_MOUSEWHEEL:
  453. SetMouseWheel(wParam >> 16);
  454. eventData[P_HANDLED] = true;
  455. break;
  456. case WM_ACTIVATE:
  457. minimized_ = HIWORD(wParam) != 0;
  458. if (LOWORD(wParam) == WA_INACTIVE)
  459. MakeInactive();
  460. else
  461. {
  462. if (!minimized_ && graphics_->GetFullscreen())
  463. activated_ = true;
  464. }
  465. eventData[P_HANDLED] = true;
  466. break;
  467. case WM_KEYDOWN:
  468. keyCode = ConvertKeyCode(wParam, lParam);
  469. if (keyCode)
  470. SetKey(keyCode, true);
  471. eventData[P_HANDLED] = true;
  472. break;
  473. case WM_SYSKEYDOWN:
  474. keyCode = ConvertKeyCode(wParam, lParam);
  475. if (keyCode)
  476. SetKey(keyCode, true);
  477. if (keyCode != KEY_F4)
  478. eventData[P_HANDLED] = true;
  479. break;
  480. case WM_KEYUP:
  481. case WM_SYSKEYUP:
  482. keyCode = ConvertKeyCode(wParam, lParam);
  483. if (keyCode)
  484. SetKey(keyCode, false);
  485. eventData[P_HANDLED] = true;
  486. break;
  487. case WM_CHAR:
  488. if (!suppressNextChar_)
  489. {
  490. using namespace Char;
  491. VariantMap keyEventData;
  492. keyEventData[P_CHAR] = wParam;
  493. keyEventData[P_BUTTONS] = mouseButtonDown_;
  494. keyEventData[P_QUALIFIERS] = GetQualifiers();
  495. SendEvent(E_CHAR, keyEventData);
  496. }
  497. suppressNextChar_ = false;
  498. eventData[P_HANDLED] = true;
  499. break;
  500. }
  501. }
  502. #else
  503. Input* GetInputInstance(GLFWwindow window)
  504. {
  505. Context* context = GetWindowContext(window);
  506. if (context)
  507. return context->GetSubsystem<Input>();
  508. else
  509. return 0;
  510. }
  511. void KeyCallback(GLFWwindow window, int key, int action)
  512. {
  513. Input* instance = GetInputInstance(window);
  514. if (!instance)
  515. return;
  516. instance->SetKey(key, action & GLFW_PRESS);
  517. }
  518. void CharCallback(GLFWwindow window, int key)
  519. {
  520. Input* instance = GetInputInstance(window);
  521. if (!instance)
  522. return;
  523. using namespace Char;
  524. VariantMap keyEventData;
  525. keyEventData[P_CHAR] = key;
  526. keyEventData[P_BUTTONS] = instance->mouseButtonDown_;
  527. keyEventData[P_QUALIFIERS] = instance->GetQualifiers();
  528. instance->SendEvent(E_CHAR, keyEventData);
  529. }
  530. void MouseButtonCallback(GLFWwindow window, int button, int action)
  531. {
  532. Input* instance = GetInputInstance(window);
  533. if (!instance)
  534. return;
  535. instance->SetMouseButton(1 << button, action == GLFW_PRESS);
  536. }
  537. void MouseScrollCallback(GLFWwindow window, int x, int y)
  538. {
  539. Input* instance = GetInputInstance(window);
  540. if (!instance)
  541. return;
  542. instance->SetMouseWheel(y);
  543. }
  544. #endif
  545. IntVector2 Input::GetCursorPosition() const
  546. {
  547. IntVector2 ret = lastCursorPosition_;
  548. if (!graphics_ || !graphics_->IsInitialized())
  549. return ret;
  550. #ifndef USE_OPENGL
  551. POINT mouse;
  552. GetCursorPos(&mouse);
  553. ScreenToClient((HWND)graphics_->GetWindowHandle(), &mouse);
  554. ret.x_ = mouse.x;
  555. ret.y_ = mouse.y;
  556. #else
  557. glfwGetMousePos(graphics_->GetWindowHandle(), &ret.x_, &ret.y_);
  558. #endif
  559. return ret;
  560. }
  561. void Input::HandleScreenMode(StringHash eventType, VariantMap& eventData)
  562. {
  563. // Reset input state on subsequent initializations
  564. if (!initialized_)
  565. Initialize();
  566. else
  567. ResetState();
  568. // Screen mode change may affect the cursor clipping behaviour. Also re-center the cursor (if needed) to the new screen size,
  569. // so that there is no erroneous mouse move event
  570. #ifndef USE_OPENGL
  571. SetClipCursor(true);
  572. #else
  573. // Re-enable GLFW callbacks each time the window has been recreated
  574. GLFWwindow window = graphics_->GetWindowHandle();
  575. glfwSetInputMode(window, GLFW_KEY_REPEAT, GL_TRUE);
  576. glfwSetKeyCallback(&KeyCallback);
  577. glfwSetCharCallback(&CharCallback);
  578. glfwSetMouseButtonCallback(&MouseButtonCallback);
  579. glfwSetScrollCallback(&MouseScrollCallback);
  580. lastCursorPosition_ = GetCursorPosition();
  581. activated_ = true;
  582. #endif
  583. }
  584. void Input::HandleBeginFrame(StringHash eventType, VariantMap& eventData)
  585. {
  586. // Update input right at the beginning of the frame
  587. if (initialized_)
  588. Update();
  589. }