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" |
11 | 11 |
12 #if !defined(EVIOCGMTSLOTS) | 12 #if !defined(EVIOCGMTSLOTS) |
13 #define EVIOCGMTSLOTS(len) _IOC(_IOC_READ, 'E', 0x0a, len) | 13 #define EVIOCGMTSLOTS(len) _IOC(_IOC_READ, 'E', 0x0a, len) |
14 #endif | 14 #endif |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 bool GetEventBits(int fd, unsigned int type, void* buf, unsigned int size) { | 20 bool GetEventBits(int fd, unsigned int type, void* buf, unsigned int size) { |
21 if (ioctl(fd, EVIOCGBIT(type, size), buf) < 0) { | 21 if (ioctl(fd, EVIOCGBIT(type, size), buf) < 0) { |
22 DLOG(ERROR) << "failed EVIOCGBIT(" << type << ", " << size << ") on fd " | 22 PLOG(ERROR) << "EVIOCGBIT(" << type << ", " << size << ") on fd " << fd; |
23 << fd; | |
24 return false; | 23 return false; |
25 } | 24 } |
26 | 25 |
27 return true; | 26 return true; |
28 } | 27 } |
29 | 28 |
30 bool GetPropBits(int fd, void* buf, unsigned int size) { | 29 bool GetPropBits(int fd, void* buf, unsigned int size) { |
31 if (ioctl(fd, EVIOCGPROP(size), buf) < 0) { | 30 if (ioctl(fd, EVIOCGPROP(size), buf) < 0) { |
32 DLOG(ERROR) << "failed EVIOCGPROP(" << size << ") on fd " << fd; | 31 PLOG(ERROR) << "EVIOCGPROP(" << size << ") on fd " << fd; |
33 return false; | 32 return false; |
34 } | 33 } |
35 | 34 |
36 return true; | 35 return true; |
37 } | 36 } |
38 | 37 |
39 bool GetAbsInfo(int fd, int code, struct input_absinfo* absinfo) { | 38 bool GetAbsInfo(int fd, int code, struct input_absinfo* absinfo) { |
40 if (ioctl(fd, EVIOCGABS(code), absinfo)) { | 39 if (ioctl(fd, EVIOCGABS(code), absinfo)) { |
41 DLOG(ERROR) << "failed EVIOCGABS(" << code << ") on fd " << fd; | 40 PLOG(ERROR) << "EVIOCGABS(" << code << ") on fd " << fd; |
42 return false; | 41 return false; |
43 } | 42 } |
44 return true; | 43 return true; |
45 } | 44 } |
46 | 45 |
47 // |request| needs to be the equivalent to: | 46 // |request| needs to be the equivalent to: |
48 // struct input_mt_request_layout { | 47 // struct input_mt_request_layout { |
49 // uint32_t code; | 48 // uint32_t code; |
50 // int32_t values[num_slots]; | 49 // int32_t values[num_slots]; |
51 // }; | 50 // }; |
52 // | 51 // |
53 // |size| is num_slots + 1 (for code). | 52 // |size| is num_slots + 1 (for code). |
54 bool GetSlotValues(int fd, int32_t* request, unsigned int size) { | 53 bool GetSlotValues(int fd, int32_t* request, unsigned int size) { |
55 size_t data_size = size * sizeof(*request); | 54 size_t data_size = size * sizeof(*request); |
56 | 55 |
57 if (ioctl(fd, EVIOCGMTSLOTS(data_size), request) < 0) { | 56 if (ioctl(fd, EVIOCGMTSLOTS(data_size), request) < 0) { |
58 DLOG(ERROR) << "failed EVIOCGMTSLOTS(" << request[0] << ") on fd " << fd; | 57 PLOG(ERROR) << "EVIOCGMTSLOTS(" << request[0] << ") on fd " << fd; |
59 return false; | 58 return false; |
60 } | 59 } |
61 | 60 |
62 return true; | 61 return true; |
63 } | 62 } |
64 | 63 |
65 void AssignBitset(const unsigned long* src, | 64 void AssignBitset(const unsigned long* src, |
66 size_t src_len, | 65 size_t src_len, |
67 unsigned long* dst, | 66 unsigned long* dst, |
68 size_t dst_len) { | 67 size_t dst_len) { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 if (HasKeyEvent(BTN_TOOL_FINGER) && HasKeyEvent(BTN_TOUCH)) | 362 if (HasKeyEvent(BTN_TOOL_FINGER) && HasKeyEvent(BTN_TOUCH)) |
364 return LegacyAbsoluteDeviceType::LADT_TOUCHPAD; | 363 return LegacyAbsoluteDeviceType::LADT_TOUCHPAD; |
365 | 364 |
366 if (HasKeyEvent(BTN_TOUCH)) | 365 if (HasKeyEvent(BTN_TOUCH)) |
367 return LegacyAbsoluteDeviceType::LADT_TOUCHSCREEN; | 366 return LegacyAbsoluteDeviceType::LADT_TOUCHSCREEN; |
368 | 367 |
369 return LegacyAbsoluteDeviceType::LADT_NONE; | 368 return LegacyAbsoluteDeviceType::LADT_NONE; |
370 } | 369 } |
371 | 370 |
372 } // namespace ui | 371 } // namespace ui |
OLD | NEW |