Input.cpp 19 KB

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