| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/events/ozone/evdev/tablet_event_converter_evdev.h" | 5 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <linux/input.h> | 8 #include <linux/input.h> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 for (int i = 0; i < count; ++i) { | 61 for (int i = 0; i < count; ++i) { |
| 62 const input_event& input = inputs[i]; | 62 const input_event& input = inputs[i]; |
| 63 switch (input.type) { | 63 switch (input.type) { |
| 64 case EV_KEY: | 64 case EV_KEY: |
| 65 ConvertKeyEvent(input); | 65 ConvertKeyEvent(input); |
| 66 break; | 66 break; |
| 67 case EV_ABS: | 67 case EV_ABS: |
| 68 ConvertAbsEvent(input); | 68 ConvertAbsEvent(input); |
| 69 break; | 69 break; |
| 70 case EV_SYN: | 70 case EV_SYN: |
| 71 FlushEvents(); | 71 FlushEvents(input); |
| 72 break; | 72 break; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 void TabletEventConverterEvdev::ConvertKeyEvent(const input_event& input) { | 77 void TabletEventConverterEvdev::ConvertKeyEvent(const input_event& input) { |
| 78 // Only handle other events if we have a stylus in proximity | 78 // Only handle other events if we have a stylus in proximity |
| 79 if (input.code >= BTN_TOOL_PEN && input.code <= BTN_TOOL_LENS) { | 79 if (input.code >= BTN_TOOL_PEN && input.code <= BTN_TOOL_LENS) { |
| 80 if (input.value == 1) | 80 if (input.value == 1) |
| 81 stylus_ = input.code; | 81 stylus_ = input.code; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return; | 138 return; |
| 139 | 139 |
| 140 if (abs_value_dirty_) { | 140 if (abs_value_dirty_) { |
| 141 UpdateCursor(); | 141 UpdateCursor(); |
| 142 abs_value_dirty_ = false; | 142 abs_value_dirty_ = false; |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool down = input.value; | 145 bool down = input.value; |
| 146 | 146 |
| 147 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams( | 147 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams( |
| 148 id_, cursor_->GetLocation(), button, down, false /* allow_remap */)); | 148 id_, cursor_->GetLocation(), button, down, false /* allow_remap */, |
| 149 TimeDeltaFromInputEvent(input))); |
| 149 } | 150 } |
| 150 | 151 |
| 151 void TabletEventConverterEvdev::FlushEvents() { | 152 void TabletEventConverterEvdev::FlushEvents(const input_event& input) { |
| 152 if (!cursor_) | 153 if (!cursor_) |
| 153 return; | 154 return; |
| 154 | 155 |
| 155 // Prevent propagation of invalid data on stylus lift off | 156 // Prevent propagation of invalid data on stylus lift off |
| 156 if (stylus_ == 0) { | 157 if (stylus_ == 0) { |
| 157 abs_value_dirty_ = false; | 158 abs_value_dirty_ = false; |
| 158 return; | 159 return; |
| 159 } | 160 } |
| 160 | 161 |
| 161 if (!abs_value_dirty_) | 162 if (!abs_value_dirty_) |
| 162 return; | 163 return; |
| 163 | 164 |
| 164 UpdateCursor(); | 165 UpdateCursor(); |
| 165 | 166 |
| 166 dispatcher_->DispatchMouseMoveEvent( | 167 dispatcher_->DispatchMouseMoveEvent(MouseMoveEventParams( |
| 167 MouseMoveEventParams(id_, cursor_->GetLocation())); | 168 id_, cursor_->GetLocation(), TimeDeltaFromInputEvent(input))); |
| 168 | 169 |
| 169 abs_value_dirty_ = false; | 170 abs_value_dirty_ = false; |
| 170 } | 171 } |
| 171 | 172 |
| 172 } // namespace ui | 173 } // namespace ui |
| OLD | NEW |