| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/gamepad_event_converter_evdev.h" | 5 #include "ui/events/ozone/evdev/gamepad_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 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if (abs_info.fuzz == 0) { | 125 if (abs_info.fuzz == 0) { |
| 126 abs_info.fuzz = abs_info.flat * 0.25f; | 126 abs_info.fuzz = abs_info.flat * 0.25f; |
| 127 } | 127 } |
| 128 mapper_(EV_ABS, code, &mapped_type, &mapped_code); | 128 mapper_(EV_ABS, code, &mapped_type, &mapped_code); |
| 129 axes_[code] = Axis(abs_info, mapped_type, mapped_code); | 129 axes_[code] = Axis(abs_info, mapped_type, mapped_code); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 GamepadEventConverterEvdev::~GamepadEventConverterEvdev() { | 134 GamepadEventConverterEvdev::~GamepadEventConverterEvdev() { |
| 135 DCHECK(!enabled_); | 135 DCHECK(!IsEnabled()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 bool GamepadEventConverterEvdev::HasGamepad() const { | 138 bool GamepadEventConverterEvdev::HasGamepad() const { |
| 139 return true; | 139 return true; |
| 140 } | 140 } |
| 141 | 141 |
| 142 void GamepadEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { | 142 void GamepadEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { |
| 143 TRACE_EVENT1("evdev", | 143 TRACE_EVENT1("evdev", |
| 144 "GamepadEventConverterEvdev::OnFileCanReadWithoutBlocking", "fd", | 144 "GamepadEventConverterEvdev::OnFileCanReadWithoutBlocking", "fd", |
| 145 fd); | 145 fd); |
| 146 while (true) { | 146 while (true) { |
| 147 input_event input; | 147 input_event input; |
| 148 ssize_t read_size = read(fd, &input, sizeof(input)); | 148 ssize_t read_size = read(fd, &input, sizeof(input)); |
| 149 if (read_size != sizeof(input)) { | 149 if (read_size != sizeof(input)) { |
| 150 if (errno == EINTR || errno == EAGAIN) | 150 if (errno == EINTR || errno == EAGAIN) |
| 151 return; | 151 return; |
| 152 if (errno != ENODEV) | 152 if (errno != ENODEV) |
| 153 PLOG(ERROR) << "error reading device " << path_.value(); | 153 PLOG(ERROR) << "error reading device " << path_.value(); |
| 154 Stop(); | 154 Stop(); |
| 155 return; | 155 return; |
| 156 } | 156 } |
| 157 | 157 |
| 158 if (!enabled_) | 158 if (!IsEnabled()) |
| 159 return; | 159 return; |
| 160 | 160 |
| 161 ProcessEvent(input); | 161 ProcessEvent(input); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 void GamepadEventConverterEvdev::OnDisabled() { | 164 void GamepadEventConverterEvdev::OnDisabled() { |
| 165 ResetGamepad(); | 165 ResetGamepad(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void GamepadEventConverterEvdev::ProcessEvent(const input_event& evdev_ev) { | 168 void GamepadEventConverterEvdev::ProcessEvent(const input_event& evdev_ev) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 308 |
| 309 void GamepadEventConverterEvdev::OnSync(const base::TimeTicks& timestamp) { | 309 void GamepadEventConverterEvdev::OnSync(const base::TimeTicks& timestamp) { |
| 310 if (will_send_frame_) { | 310 if (will_send_frame_) { |
| 311 GamepadEvent event(input_device_.id, GamepadEventType::FRAME, 0, 0, | 311 GamepadEvent event(input_device_.id, GamepadEventType::FRAME, 0, 0, |
| 312 timestamp); | 312 timestamp); |
| 313 dispatcher_->DispatchGamepadEvent(event); | 313 dispatcher_->DispatchGamepadEvent(event); |
| 314 will_send_frame_ = false; | 314 will_send_frame_ = false; |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 } // namespace ui | 317 } // namespace ui |
| OLD | NEW |