OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/libgestures_glue/event_reader_libevdev_cros.h" | 5 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <libevdev/libevdev.h> | 8 #include <libevdev/libevdev.h> |
9 #include <linux/input.h> | 9 #include <linux/input.h> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... | |
30 int id, | 30 int id, |
31 InputDeviceType type, | 31 InputDeviceType type, |
32 const EventDeviceInfo& devinfo, | 32 const EventDeviceInfo& devinfo, |
33 scoped_ptr<Delegate> delegate) | 33 scoped_ptr<Delegate> delegate) |
34 : EventConverterEvdev(fd, path, id, type), | 34 : EventConverterEvdev(fd, path, id, type), |
35 has_keyboard_(devinfo.HasKeyboard()), | 35 has_keyboard_(devinfo.HasKeyboard()), |
36 has_mouse_(devinfo.HasMouse()), | 36 has_mouse_(devinfo.HasMouse()), |
37 has_touchpad_(devinfo.HasTouchpad()), | 37 has_touchpad_(devinfo.HasTouchpad()), |
38 has_caps_lock_led_(devinfo.HasLedEvent(LED_CAPSL)), | 38 has_caps_lock_led_(devinfo.HasLedEvent(LED_CAPSL)), |
39 delegate_(delegate.Pass()) { | 39 delegate_(delegate.Pass()) { |
40 // This class assumes it does not deal with internal keyboards. | |
41 CHECK(!has_keyboard_ || type != INPUT_DEVICE_INTERNAL); | |
spang
2015/03/11 21:12:26
DCHECK per the style guide.
| |
42 | |
40 memset(&evdev_, 0, sizeof(evdev_)); | 43 memset(&evdev_, 0, sizeof(evdev_)); |
41 evdev_.log = OnLogMessage; | 44 evdev_.log = OnLogMessage; |
42 evdev_.log_udata = this; | 45 evdev_.log_udata = this; |
43 evdev_.syn_report = OnSynReport; | 46 evdev_.syn_report = OnSynReport; |
44 evdev_.syn_report_udata = this; | 47 evdev_.syn_report_udata = this; |
45 evdev_.fd = fd; | 48 evdev_.fd = fd; |
46 | 49 |
47 memset(&evstate_, 0, sizeof(evstate_)); | 50 memset(&evstate_, 0, sizeof(evstate_)); |
48 evdev_.evstate = &evstate_; | 51 evdev_.evstate = &evstate_; |
49 Event_Init(&evdev_); | 52 Event_Init(&evdev_); |
(...skipping 30 matching lines...) Expand all Loading... | |
80 } | 83 } |
81 | 84 |
82 bool EventReaderLibevdevCros::HasTouchpad() const { | 85 bool EventReaderLibevdevCros::HasTouchpad() const { |
83 return has_touchpad_; | 86 return has_touchpad_; |
84 } | 87 } |
85 | 88 |
86 bool EventReaderLibevdevCros::HasCapsLockLed() const { | 89 bool EventReaderLibevdevCros::HasCapsLockLed() const { |
87 return has_caps_lock_led_; | 90 return has_caps_lock_led_; |
88 } | 91 } |
89 | 92 |
90 void EventReaderLibevdevCros::SetAllowedKeys( | |
91 scoped_ptr<std::set<DomCode>> allowed_keys) { | |
92 DCHECK(HasKeyboard()); | |
93 delegate_->SetAllowedKeys(allowed_keys.Pass()); | |
94 } | |
95 | |
96 void EventReaderLibevdevCros::AllowAllKeys() { | |
97 DCHECK(HasKeyboard()); | |
98 delegate_->AllowAllKeys(); | |
99 } | |
100 | |
101 void EventReaderLibevdevCros::OnStopped() { | 93 void EventReaderLibevdevCros::OnStopped() { |
102 delegate_->OnLibEvdevCrosStopped(&evdev_, &evstate_); | 94 delegate_->OnLibEvdevCrosStopped(&evdev_, &evstate_); |
103 } | 95 } |
104 | 96 |
105 // static | 97 // static |
106 void EventReaderLibevdevCros::OnSynReport(void* data, | 98 void EventReaderLibevdevCros::OnSynReport(void* data, |
107 EventStateRec* evstate, | 99 EventStateRec* evstate, |
108 struct timeval* tv) { | 100 struct timeval* tv) { |
109 EventReaderLibevdevCros* reader = static_cast<EventReaderLibevdevCros*>(data); | 101 EventReaderLibevdevCros* reader = static_cast<EventReaderLibevdevCros*>(data); |
110 if (reader->ignore_events_) | 102 if (reader->ignore_events_) |
(...skipping 12 matching lines...) Expand all Loading... | |
123 if (level >= LOGLEVEL_ERROR) | 115 if (level >= LOGLEVEL_ERROR) |
124 LOG(ERROR) << "libevdev: " << FormatLog(fmt, args); | 116 LOG(ERROR) << "libevdev: " << FormatLog(fmt, args); |
125 else if (level >= LOGLEVEL_WARNING) | 117 else if (level >= LOGLEVEL_WARNING) |
126 LOG(WARNING) << "libevdev: " << FormatLog(fmt, args); | 118 LOG(WARNING) << "libevdev: " << FormatLog(fmt, args); |
127 else | 119 else |
128 VLOG(3) << "libevdev: " << FormatLog(fmt, args); | 120 VLOG(3) << "libevdev: " << FormatLog(fmt, args); |
129 va_end(args); | 121 va_end(args); |
130 } | 122 } |
131 | 123 |
132 } // namespace ui | 124 } // namespace ui |
OLD | NEW |