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 namespace ui { | 12 namespace ui { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 bool GetEventBits(int fd, unsigned int type, void* buf, unsigned int size) { | 16 bool GetEventBits(int fd, unsigned int type, void* buf, unsigned int size) { |
17 base::ThreadRestrictions::AssertIOAllowed(); | |
rjkroege
2014/01/30 22:18:09
for ozone, it would be really nice to have a "only
spang
2014/01/31 17:33:00
Should that go in base::ThreadRestrictions?
I thi
| |
18 | |
19 if (ioctl(fd, EVIOCGBIT(type, size), buf) < 0) { | 17 if (ioctl(fd, EVIOCGBIT(type, size), buf) < 0) { |
20 DLOG(ERROR) << "failed EVIOCGBIT(" << type << ", " << size << ") on fd " | 18 DLOG(ERROR) << "failed EVIOCGBIT(" << type << ", " << size << ") on fd " |
21 << fd; | 19 << fd; |
22 return false; | 20 return false; |
23 } | 21 } |
24 | 22 |
25 return true; | 23 return true; |
26 } | 24 } |
27 | 25 |
28 bool GetPropBits(int fd, void* buf, unsigned int size) { | 26 bool GetPropBits(int fd, void* buf, unsigned int size) { |
29 base::ThreadRestrictions::AssertIOAllowed(); | |
30 | |
31 if (ioctl(fd, EVIOCGPROP(size), buf) < 0) { | 27 if (ioctl(fd, EVIOCGPROP(size), buf) < 0) { |
32 DLOG(ERROR) << "failed EVIOCGPROP(" << size << ") on fd " << fd; | 28 DLOG(ERROR) << "failed EVIOCGPROP(" << size << ") on fd " << fd; |
33 return false; | 29 return false; |
34 } | 30 } |
35 | 31 |
36 return true; | 32 return true; |
37 } | 33 } |
38 | 34 |
39 bool BitIsSet(const unsigned long* bits, unsigned int bit) { | 35 bool BitIsSet(const unsigned long* bits, unsigned int bit) { |
40 return (bits[bit / EVDEV_LONG_BITS] & (1UL << (bit % EVDEV_LONG_BITS))); | 36 return (bits[bit / EVDEV_LONG_BITS] & (1UL << (bit % EVDEV_LONG_BITS))); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 return BitIsSet(led_bits_, code); | 121 return BitIsSet(led_bits_, code); |
126 } | 122 } |
127 | 123 |
128 bool EventDeviceInfo::HasProp(unsigned int code) const { | 124 bool EventDeviceInfo::HasProp(unsigned int code) const { |
129 if (code > INPUT_PROP_MAX) | 125 if (code > INPUT_PROP_MAX) |
130 return false; | 126 return false; |
131 return BitIsSet(prop_bits_, code); | 127 return BitIsSet(prop_bits_, code); |
132 } | 128 } |
133 | 129 |
134 } // namespace ui | 130 } // namespace ui |
OLD | NEW |