Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_device_info.h" | 5 #include "ui/events/ozone/evdev/event_device_info.h" |
| 6 | 6 |
| 7 #include <linux/input.h> | 7 #include <linux/input.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 | 226 |
| 227 // Touchpads are not mapped to the screen. | 227 // Touchpads are not mapped to the screen. |
| 228 if (HasKeyEvent(BTN_LEFT) || HasKeyEvent(BTN_MIDDLE) || | 228 if (HasKeyEvent(BTN_LEFT) || HasKeyEvent(BTN_MIDDLE) || |
| 229 HasKeyEvent(BTN_RIGHT) || HasKeyEvent(BTN_TOOL_FINGER)) | 229 HasKeyEvent(BTN_RIGHT) || HasKeyEvent(BTN_TOOL_FINGER)) |
| 230 return false; | 230 return false; |
| 231 | 231 |
| 232 // Touchscreens are mapped to the screen. | 232 // Touchscreens are mapped to the screen. |
| 233 return true; | 233 return true; |
| 234 } | 234 } |
| 235 | 235 |
| 236 bool EventDeviceInfo::HasKeyboard() const { | |
| 237 if (!HasEventType(EV_KEY)) | |
| 238 return false; | |
| 239 | |
| 240 // Check first 31 keys: If we have all of them, consider it a full | |
| 241 // keyboard. This is exactly what udev does for ID_INPUT_KEYBOARD. | |
| 242 for (int key = KEY_ESC; key <= KEY_D; ++key) | |
|
sadrul
2014/12/11 15:41:37
{}?
| |
| 243 if (!HasKeyEvent(key)) | |
| 244 return false; | |
| 245 | |
| 246 return true; | |
| 247 } | |
| 248 | |
| 236 const std::vector<int32_t>& EventDeviceInfo::GetMtSlotsForCode(int code) const { | 249 const std::vector<int32_t>& EventDeviceInfo::GetMtSlotsForCode(int code) const { |
| 237 int index = code - ABS_MT_SLOT - 1; | 250 int index = code - ABS_MT_SLOT - 1; |
| 238 DCHECK_LE(0, index) << code << " is not a valid multi-touch code"; | 251 DCHECK_LE(0, index) << code << " is not a valid multi-touch code"; |
| 239 DCHECK_LT(index, EVDEV_ABS_MT_COUNT) | 252 DCHECK_LT(index, EVDEV_ABS_MT_COUNT) |
| 240 << code << " is not a valid multi-touch code"; | 253 << code << " is not a valid multi-touch code"; |
| 241 return slot_values_[index]; | 254 return slot_values_[index]; |
| 242 } | 255 } |
| 243 | 256 |
| 244 } // namespace ui | 257 } // namespace ui |
| OLD | NEW |