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 <windowsx.h> | 5 #include <windowsx.h> |
6 | 6 |
7 #include "ui/events/event_constants.h" | 7 #include "ui/events/event_constants.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 382 |
383 // Windows emulates mouse messages for touch events. | 383 // Windows emulates mouse messages for touch events. |
384 bool IsMouseEventFromTouch(UINT message) { | 384 bool IsMouseEventFromTouch(UINT message) { |
385 return (message >= WM_MOUSEFIRST) && (message <= WM_MOUSELAST) && | 385 return (message >= WM_MOUSEFIRST) && (message <= WM_MOUSELAST) && |
386 (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == | 386 (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == |
387 MOUSEEVENTF_FROMTOUCH; | 387 MOUSEEVENTF_FROMTOUCH; |
388 } | 388 } |
389 | 389 |
390 // Conversion scan_code and LParam each other. | 390 // Conversion scan_code and LParam each other. |
391 // uint16 scan_code: | 391 // uint16 scan_code: |
392 // ui/events/keycodes/dom4/keycode_converter_data.h | 392 // ui/events/keycodes/dom/keycode_converter_data.inc |
393 // 0 - 15bits: represetns the scan code. | 393 // 0 - 15bits: represetns the scan code. |
394 // 28 - 30 bits (0xE000): represents whether this is an extended key or not. | 394 // 28 - 30 bits (0xE000): represents whether this is an extended key or not. |
395 // | 395 // |
396 // LPARAM lParam: | 396 // LPARAM lParam: |
397 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644984.aspx | 397 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644984.aspx |
398 // 16 - 23bits: represetns the scan code. | 398 // 16 - 23bits: represetns the scan code. |
399 // 24bit (0x0100): represents whether this is an extended key or not. | 399 // 24bit (0x0100): represents whether this is an extended key or not. |
400 uint16 GetScanCodeFromLParam(LPARAM l_param) { | 400 uint16 GetScanCodeFromLParam(LPARAM l_param) { |
401 uint16 scan_code = ((l_param >> 16) & 0x00FF); | 401 uint16 scan_code = ((l_param >> 16) & 0x00FF); |
402 if (l_param & (1 << 24)) | 402 if (l_param & (1 << 24)) |
403 scan_code |= 0xE000; | 403 scan_code |= 0xE000; |
404 return scan_code; | 404 return scan_code; |
405 } | 405 } |
406 | 406 |
407 LPARAM GetLParamFromScanCode(uint16 scan_code) { | 407 LPARAM GetLParamFromScanCode(uint16 scan_code) { |
408 LPARAM l_param = static_cast<LPARAM>(scan_code & 0x00FF) << 16; | 408 LPARAM l_param = static_cast<LPARAM>(scan_code & 0x00FF) << 16; |
409 if ((scan_code & 0xE000) == 0xE000) | 409 if ((scan_code & 0xE000) == 0xE000) |
410 l_param |= (1 << 24); | 410 l_param |= (1 << 24); |
411 return l_param; | 411 return l_param; |
412 } | 412 } |
413 | 413 |
414 } // namespace ui | 414 } // namespace ui |
OLD | NEW |