Input.cpp 19 KB

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