| 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/event_converter_evdev_impl.h" | 5 #include "ui/events/ozone/evdev/event_converter_evdev_impl.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 "ui/events/event.h" | 10 #include "ui/events/event.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 if (down == key_state_.test(key)) | 171 if (down == key_state_.test(key)) |
| 172 return; | 172 return; |
| 173 | 173 |
| 174 // Apply key filter (releases for previously pressed keys are excepted). | 174 // Apply key filter (releases for previously pressed keys are excepted). |
| 175 if (down && blocked_keys_.test(key)) | 175 if (down && blocked_keys_.test(key)) |
| 176 return; | 176 return; |
| 177 | 177 |
| 178 // State transition: !(down) -> (down) | 178 // State transition: !(down) -> (down) |
| 179 key_state_.set(key, down); | 179 key_state_.set(key, down); |
| 180 | 180 |
| 181 dispatcher_->DispatchKeyEvent(KeyEventParams(id_, key, down, timestamp)); | 181 dispatcher_->DispatchKeyEvent( |
| 182 KeyEventParams(input_device_.id, key, down, timestamp)); |
| 182 } | 183 } |
| 183 | 184 |
| 184 void EventConverterEvdevImpl::ReleaseKeys() { | 185 void EventConverterEvdevImpl::ReleaseKeys() { |
| 185 base::TimeDelta timestamp = ui::EventTimeForNow(); | 186 base::TimeDelta timestamp = ui::EventTimeForNow(); |
| 186 for (int key = 0; key < KEY_CNT; ++key) | 187 for (int key = 0; key < KEY_CNT; ++key) |
| 187 OnKeyChange(key, false /* down */, timestamp); | 188 OnKeyChange(key, false /* down */, timestamp); |
| 188 } | 189 } |
| 189 | 190 |
| 190 void EventConverterEvdevImpl::ReleaseMouseButtons() { | 191 void EventConverterEvdevImpl::ReleaseMouseButtons() { |
| 191 base::TimeDelta timestamp = ui::EventTimeForNow(); | 192 base::TimeDelta timestamp = ui::EventTimeForNow(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 216 code = BTN_BACK; | 217 code = BTN_BACK; |
| 217 else if (code == BTN_EXTRA) | 218 else if (code == BTN_EXTRA) |
| 218 code = BTN_FORWARD; | 219 code = BTN_FORWARD; |
| 219 | 220 |
| 220 int button_offset = code - BTN_MOUSE; | 221 int button_offset = code - BTN_MOUSE; |
| 221 if (mouse_button_state_.test(button_offset) == down) | 222 if (mouse_button_state_.test(button_offset) == down) |
| 222 return; | 223 return; |
| 223 | 224 |
| 224 mouse_button_state_.set(button_offset, down); | 225 mouse_button_state_.set(button_offset, down); |
| 225 | 226 |
| 226 dispatcher_->DispatchMouseButtonEvent( | 227 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams( |
| 227 MouseButtonEventParams(id_, cursor_->GetLocation(), code, down, | 228 input_device_.id, cursor_->GetLocation(), code, down, |
| 228 /* allow_remap */ true, timestamp)); | 229 /* allow_remap */ true, timestamp)); |
| 229 } | 230 } |
| 230 | 231 |
| 231 void EventConverterEvdevImpl::FlushEvents(const input_event& input) { | 232 void EventConverterEvdevImpl::FlushEvents(const input_event& input) { |
| 232 if (!cursor_ || (x_offset_ == 0 && y_offset_ == 0)) | 233 if (!cursor_ || (x_offset_ == 0 && y_offset_ == 0)) |
| 233 return; | 234 return; |
| 234 | 235 |
| 235 cursor_->MoveCursor(gfx::Vector2dF(x_offset_, y_offset_)); | 236 cursor_->MoveCursor(gfx::Vector2dF(x_offset_, y_offset_)); |
| 236 | 237 |
| 237 dispatcher_->DispatchMouseMoveEvent(MouseMoveEventParams( | 238 dispatcher_->DispatchMouseMoveEvent( |
| 238 id_, cursor_->GetLocation(), TimeDeltaFromInputEvent(input))); | 239 MouseMoveEventParams(input_device_.id, cursor_->GetLocation(), |
| 240 TimeDeltaFromInputEvent(input))); |
| 239 | 241 |
| 240 x_offset_ = 0; | 242 x_offset_ = 0; |
| 241 y_offset_ = 0; | 243 y_offset_ = 0; |
| 242 } | 244 } |
| 243 | 245 |
| 244 } // namespace ui | 246 } // namespace ui |
| OLD | NEW |