| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdint.h> | 5 #include <stdint.h> |
| 6 #include <windowsx.h> | 6 #include <windowsx.h> |
| 7 | 7 |
| 8 #include "ui/events/event_constants.h" | 8 #include "ui/events/event_constants.h" |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 return modifiers; | 389 return modifiers; |
| 390 } | 390 } |
| 391 | 391 |
| 392 // Windows emulates mouse messages for touch events. | 392 // Windows emulates mouse messages for touch events. |
| 393 bool IsMouseEventFromTouch(UINT message) { | 393 bool IsMouseEventFromTouch(UINT message) { |
| 394 return (message >= WM_MOUSEFIRST) && (message <= WM_MOUSELAST) && | 394 return (message >= WM_MOUSEFIRST) && (message <= WM_MOUSELAST) && |
| 395 (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == | 395 (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == |
| 396 MOUSEEVENTF_FROMTOUCH; | 396 MOUSEEVENTF_FROMTOUCH; |
| 397 } | 397 } |
| 398 | 398 |
| 399 bool IsWindowsCursorHidden() { |
| 400 CURSORINFO c = {sizeof(CURSORINFO)}; |
| 401 if (GetCursorInfo(&c)) |
| 402 return !(c.flags & CURSOR_SHOWING); |
| 403 NOTREACHED(); |
| 404 return false; |
| 405 } |
| 406 |
| 399 // Conversion scan_code and LParam each other. | 407 // Conversion scan_code and LParam each other. |
| 400 // uint16_t scan_code: | 408 // uint16_t scan_code: |
| 401 // ui/events/keycodes/dom/keycode_converter_data.inc | 409 // ui/events/keycodes/dom/keycode_converter_data.inc |
| 402 // 0 - 15bits: represetns the scan code. | 410 // 0 - 15bits: represetns the scan code. |
| 403 // 28 - 30 bits (0xE000): represents whether this is an extended key or not. | 411 // 28 - 30 bits (0xE000): represents whether this is an extended key or not. |
| 404 // | 412 // |
| 405 // LPARAM lParam: | 413 // LPARAM lParam: |
| 406 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644984.aspx | 414 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644984.aspx |
| 407 // 16 - 23bits: represetns the scan code. | 415 // 16 - 23bits: represetns the scan code. |
| 408 // 24bit (0x0100): represents whether this is an extended key or not. | 416 // 24bit (0x0100): represents whether this is an extended key or not. |
| 409 uint16_t GetScanCodeFromLParam(LPARAM l_param) { | 417 uint16_t GetScanCodeFromLParam(LPARAM l_param) { |
| 410 uint16_t scan_code = ((l_param >> 16) & 0x00FF); | 418 uint16_t scan_code = ((l_param >> 16) & 0x00FF); |
| 411 if (l_param & (1 << 24)) | 419 if (l_param & (1 << 24)) |
| 412 scan_code |= 0xE000; | 420 scan_code |= 0xE000; |
| 413 return scan_code; | 421 return scan_code; |
| 414 } | 422 } |
| 415 | 423 |
| 416 LPARAM GetLParamFromScanCode(uint16_t scan_code) { | 424 LPARAM GetLParamFromScanCode(uint16_t scan_code) { |
| 417 LPARAM l_param = static_cast<LPARAM>(scan_code & 0x00FF) << 16; | 425 LPARAM l_param = static_cast<LPARAM>(scan_code & 0x00FF) << 16; |
| 418 if ((scan_code & 0xE000) == 0xE000) | 426 if ((scan_code & 0xE000) == 0xE000) |
| 419 l_param |= (1 << 24); | 427 l_param |= (1 << 24); |
| 420 return l_param; | 428 return l_param; |
| 421 } | 429 } |
| 422 | 430 |
| 423 } // namespace ui | 431 } // namespace ui |
| OLD | NEW |