| 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 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| 11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 12 #include "ui/events/devices/stylus_state.h" | 12 #include "ui/events/devices/stylus_state.h" |
| 13 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
| 14 #include "ui/events/event_utils.h" | 14 #include "ui/events/event_utils.h" |
| 15 #include "ui/events/keycodes/dom/keycode_converter.h" | 15 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 16 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" | 16 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
| 17 #include "ui/events/ozone/evdev/keyboard_util_evdev.h" | 17 #include "ui/events/ozone/evdev/keyboard_util_evdev.h" |
| 18 #include "ui/events/ozone/evdev/scoped_input_device.h" |
| 18 | 19 |
| 19 namespace ui { | 20 namespace ui { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // Values for EV_KEY. | 24 // Values for EV_KEY. |
| 24 const int kKeyReleaseValue = 0; | 25 const int kKeyReleaseValue = 0; |
| 25 const int kKeyRepeatValue = 2; | 26 const int kKeyRepeatValue = 2; |
| 26 | 27 |
| 27 // Values for the EV_SW code. | 28 // Values for the EV_SW code. |
| 28 const int kSwitchStylusInserted = 15; | 29 const int kSwitchStylusInserted = 15; |
| 29 | 30 |
| 30 } // namespace | 31 } // namespace |
| 31 | 32 |
| 32 EventConverterEvdevImpl::EventConverterEvdevImpl( | 33 EventConverterEvdevImpl::EventConverterEvdevImpl( |
| 33 int fd, | 34 ScopedInputDevice fd, |
| 34 base::FilePath path, | 35 base::FilePath path, |
| 35 int id, | 36 int id, |
| 36 const EventDeviceInfo& devinfo, | 37 const EventDeviceInfo& devinfo, |
| 37 CursorDelegateEvdev* cursor, | 38 CursorDelegateEvdev* cursor, |
| 38 DeviceEventDispatcherEvdev* dispatcher) | 39 DeviceEventDispatcherEvdev* dispatcher) |
| 39 : EventConverterEvdev(fd, | 40 : EventConverterEvdev(fd.get(), |
| 40 path, | 41 path, |
| 41 id, | 42 id, |
| 42 devinfo.device_type(), | 43 devinfo.device_type(), |
| 43 devinfo.name(), | 44 devinfo.name(), |
| 44 devinfo.vendor_id(), | 45 devinfo.vendor_id(), |
| 45 devinfo.product_id()), | 46 devinfo.product_id()), |
| 47 input_device_fd_(std::move(fd)), |
| 46 has_keyboard_(devinfo.HasKeyboard()), | 48 has_keyboard_(devinfo.HasKeyboard()), |
| 47 has_touchpad_(devinfo.HasTouchpad()), | 49 has_touchpad_(devinfo.HasTouchpad()), |
| 48 has_caps_lock_led_(devinfo.HasLedEvent(LED_CAPSL)), | 50 has_caps_lock_led_(devinfo.HasLedEvent(LED_CAPSL)), |
| 49 cursor_(cursor), | 51 cursor_(cursor), |
| 50 dispatcher_(dispatcher) { | 52 dispatcher_(dispatcher) {} |
| 51 } | |
| 52 | 53 |
| 53 EventConverterEvdevImpl::~EventConverterEvdevImpl() { | 54 EventConverterEvdevImpl::~EventConverterEvdevImpl() { |
| 54 DCHECK(!enabled_); | 55 DCHECK(!enabled_); |
| 55 close(fd_); | |
| 56 } | 56 } |
| 57 | 57 |
| 58 void EventConverterEvdevImpl::OnFileCanReadWithoutBlocking(int fd) { | 58 void EventConverterEvdevImpl::OnFileCanReadWithoutBlocking(int fd) { |
| 59 TRACE_EVENT1("evdev", "EventConverterEvdevImpl::OnFileCanReadWithoutBlocking", | 59 TRACE_EVENT1("evdev", "EventConverterEvdevImpl::OnFileCanReadWithoutBlocking", |
| 60 "fd", fd); | 60 "fd", fd); |
| 61 | 61 |
| 62 input_event inputs[4]; | 62 input_event inputs[4]; |
| 63 ssize_t read_size = read(fd, inputs, sizeof(inputs)); | 63 ssize_t read_size = read(fd, inputs, sizeof(inputs)); |
| 64 if (read_size < 0) { | 64 if (read_size < 0) { |
| 65 if (errno == EINTR || errno == EAGAIN) | 65 if (errno == EINTR || errno == EAGAIN) |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 dispatcher_->DispatchMouseMoveEvent( | 251 dispatcher_->DispatchMouseMoveEvent( |
| 252 MouseMoveEventParams(input_device_.id, EF_NONE, cursor_->GetLocation(), | 252 MouseMoveEventParams(input_device_.id, EF_NONE, cursor_->GetLocation(), |
| 253 PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), | 253 PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), |
| 254 TimeTicksFromInputEvent(input))); | 254 TimeTicksFromInputEvent(input))); |
| 255 | 255 |
| 256 x_offset_ = 0; | 256 x_offset_ = 0; |
| 257 y_offset_ = 0; | 257 y_offset_ = 0; |
| 258 } | 258 } |
| 259 | 259 |
| 260 } // namespace ui | 260 } // namespace ui |
| OLD | NEW |