1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/events/event.h"
6 #include "ui/events/event_constants.h"
7 #include "ui/events/event_utils.h"
11 void UpdateDeviceList() { NOTIMPLEMENTED(); }
13 base::TimeDelta
EventTimeFromNative(const base::NativeEvent
& native_event
) {
14 const ui::Event
* event
= static_cast<const ui::Event
*>(native_event
);
15 return event
->time_stamp();
18 int EventFlagsFromNative(const base::NativeEvent
& native_event
) {
19 const ui::Event
* event
= static_cast<const ui::Event
*>(native_event
);
20 return event
->flags();
23 EventType
EventTypeFromNative(const base::NativeEvent
& native_event
) {
24 const ui::Event
* event
= static_cast<const ui::Event
*>(native_event
);
28 gfx::Point
EventSystemLocationFromNative(
29 const base::NativeEvent
& native_event
) {
30 const ui::LocatedEvent
* e
=
31 static_cast<const ui::LocatedEvent
*>(native_event
);
32 DCHECK(e
->IsMouseEvent() || e
->IsTouchEvent() || e
->IsGestureEvent() ||
37 gfx::Point
EventLocationFromNative(const base::NativeEvent
& native_event
) {
38 return EventSystemLocationFromNative(native_event
);
41 int GetChangedMouseButtonFlagsFromNative(
42 const base::NativeEvent
& native_event
) {
43 const ui::MouseEvent
* event
=
44 static_cast<const ui::MouseEvent
*>(native_event
);
45 DCHECK(event
->IsMouseEvent());
46 return event
->changed_button_flags();
49 KeyboardCode
KeyboardCodeFromNative(const base::NativeEvent
& native_event
) {
50 const ui::KeyEvent
* event
= static_cast<const ui::KeyEvent
*>(native_event
);
51 DCHECK(event
->IsKeyEvent());
52 return event
->key_code();
55 const char* CodeFromNative(const base::NativeEvent
& native_event
) {
56 const ui::KeyEvent
* event
= static_cast<const ui::KeyEvent
*>(native_event
);
57 DCHECK(event
->IsKeyEvent());
58 return event
->code().c_str();
61 uint32
PlatformKeycodeFromNative(const base::NativeEvent
& native_event
) {
62 const ui::KeyEvent
* event
= static_cast<const ui::KeyEvent
*>(native_event
);
63 DCHECK(event
->IsKeyEvent());
64 return event
->platform_keycode();
67 gfx::Vector2d
GetMouseWheelOffset(const base::NativeEvent
& native_event
) {
68 const ui::MouseWheelEvent
* event
=
69 static_cast<const ui::MouseWheelEvent
*>(native_event
);
70 DCHECK(event
->type() == ET_MOUSEWHEEL
);
71 return event
->offset();
74 base::NativeEvent
CopyNativeEvent(const base::NativeEvent
& event
) {
78 void ReleaseCopiedNativeEvent(const base::NativeEvent
& event
) {
81 void ClearTouchIdIfReleased(const base::NativeEvent
& xev
) {
84 int GetTouchId(const base::NativeEvent
& native_event
) {
85 const ui::TouchEvent
* event
=
86 static_cast<const ui::TouchEvent
*>(native_event
);
87 DCHECK(event
->IsTouchEvent());
88 return event
->touch_id();
91 float GetTouchRadiusX(const base::NativeEvent
& native_event
) {
92 const ui::TouchEvent
* event
=
93 static_cast<const ui::TouchEvent
*>(native_event
);
94 DCHECK(event
->IsTouchEvent());
95 return event
->radius_x();
98 float GetTouchRadiusY(const base::NativeEvent
& native_event
) {
99 const ui::TouchEvent
* event
=
100 static_cast<const ui::TouchEvent
*>(native_event
);
101 DCHECK(event
->IsTouchEvent());
102 return event
->radius_y();
105 float GetTouchAngle(const base::NativeEvent
& native_event
) {
106 const ui::TouchEvent
* event
=
107 static_cast<const ui::TouchEvent
*>(native_event
);
108 DCHECK(event
->IsTouchEvent());
109 return event
->rotation_angle();
112 float GetTouchForce(const base::NativeEvent
& native_event
) {
113 const ui::TouchEvent
* event
=
114 static_cast<const ui::TouchEvent
*>(native_event
);
115 DCHECK(event
->IsTouchEvent());
116 return event
->force();
119 bool GetScrollOffsets(const base::NativeEvent
& native_event
,
122 float* x_offset_ordinal
,
123 float* y_offset_ordinal
,
129 bool GetFlingData(const base::NativeEvent
& native_event
,
139 bool GetGestureTimes(const base::NativeEvent
& native_event
,
147 int GetModifiersFromKeyState() {