Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(669)

Side by Side Diff: ui/events/ozone/evdev/event_device_info.cc

Issue 150633005: evdev: Support device hotplug with udev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add TODOs Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/events/ozone/evdev/device_manager_udev.cc ('k') | ui/events/ozone/evdev/event_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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();
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
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
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/device_manager_udev.cc ('k') | ui/events/ozone/evdev/event_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698