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 bool IsCharFromNative(const base::NativeEvent
& native_event
) {
68 const ui::KeyEvent
* event
= static_cast<const ui::KeyEvent
*>(native_event
);
69 DCHECK(event
->IsKeyEvent());
70 return event
->is_char();
73 uint32
WindowsKeycodeFromNative(const base::NativeEvent
& native_event
) {
78 uint16
TextFromNative(const base::NativeEvent
& native_event
) {
83 uint16
UnmodifiedTextFromNative(const base::NativeEvent
& native_event
) {
88 gfx::Vector2d
GetMouseWheelOffset(const base::NativeEvent
& native_event
) {
89 const ui::MouseWheelEvent
* event
=
90 static_cast<const ui::MouseWheelEvent
*>(native_event
);
91 DCHECK(event
->type() == ET_MOUSEWHEEL
);
92 return event
->offset();
95 base::NativeEvent
CopyNativeEvent(const base::NativeEvent
& event
) {
99 void ReleaseCopiedNativeEvent(const base::NativeEvent
& event
) {
102 void IncrementTouchIdRefCount(const base::NativeEvent
& event
) {
105 void ClearTouchIdIfReleased(const base::NativeEvent
& xev
) {
108 int GetTouchId(const base::NativeEvent
& native_event
) {
109 const ui::TouchEvent
* event
=
110 static_cast<const ui::TouchEvent
*>(native_event
);
111 DCHECK(event
->IsTouchEvent());
112 return event
->touch_id();
115 float GetTouchRadiusX(const base::NativeEvent
& native_event
) {
116 const ui::TouchEvent
* event
=
117 static_cast<const ui::TouchEvent
*>(native_event
);
118 DCHECK(event
->IsTouchEvent());
119 return event
->radius_x();
122 float GetTouchRadiusY(const base::NativeEvent
& native_event
) {
123 const ui::TouchEvent
* event
=
124 static_cast<const ui::TouchEvent
*>(native_event
);
125 DCHECK(event
->IsTouchEvent());
126 return event
->radius_y();
129 float GetTouchAngle(const base::NativeEvent
& native_event
) {
130 const ui::TouchEvent
* event
=
131 static_cast<const ui::TouchEvent
*>(native_event
);
132 DCHECK(event
->IsTouchEvent());
133 return event
->rotation_angle();
136 float GetTouchForce(const base::NativeEvent
& native_event
) {
137 const ui::TouchEvent
* event
=
138 static_cast<const ui::TouchEvent
*>(native_event
);
139 DCHECK(event
->IsTouchEvent());
140 return event
->force();
143 bool GetScrollOffsets(const base::NativeEvent
& native_event
,
146 float* x_offset_ordinal
,
147 float* y_offset_ordinal
,
153 bool GetFlingData(const base::NativeEvent
& native_event
,
159 const ui::ScrollEvent
* event
=
160 static_cast<const ui::ScrollEvent
*>(native_event
);
161 DCHECK(event
->IsScrollEvent());
163 *vx
= event
->x_offset();
165 *vy
= event
->y_offset();
167 *vx_ordinal
= event
->x_offset_ordinal();
169 *vy_ordinal
= event
->y_offset_ordinal();
171 *is_cancel
= event
->type() == ET_SCROLL_FLING_CANCEL
;
176 int GetModifiersFromKeyState() {