Input.cpp 19 KB

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