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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 142 } |
143 | 143 |
144 int32 EventDeviceInfo::GetAbsMinimum(unsigned int code) const { | 144 int32 EventDeviceInfo::GetAbsMinimum(unsigned int code) const { |
145 return abs_info_[code].minimum; | 145 return abs_info_[code].minimum; |
146 } | 146 } |
147 | 147 |
148 int32 EventDeviceInfo::GetAbsMaximum(unsigned int code) const { | 148 int32 EventDeviceInfo::GetAbsMaximum(unsigned int code) const { |
149 return abs_info_[code].maximum; | 149 return abs_info_[code].maximum; |
150 } | 150 } |
151 | 151 |
| 152 bool EventDeviceInfo::HasAbsXY() const { |
| 153 if (HasAbsEvent(ABS_X) && HasAbsEvent(ABS_Y)) |
| 154 return true; |
| 155 |
| 156 if (HasAbsEvent(ABS_MT_POSITION_X) && HasAbsEvent(ABS_MT_POSITION_Y)) |
| 157 return true; |
| 158 |
| 159 return false; |
| 160 } |
| 161 |
| 162 bool EventDeviceInfo::HasRelXY() const { |
| 163 return HasRelEvent(REL_X) && HasRelEvent(REL_Y); |
| 164 } |
| 165 |
| 166 bool EventDeviceInfo::IsMappedToScreen() const { |
| 167 // Device position is mapped directly to the screen. |
| 168 if (HasProp(INPUT_PROP_DIRECT)) |
| 169 return true; |
| 170 |
| 171 // Device position moves the cursor. |
| 172 if (HasProp(INPUT_PROP_POINTER)) |
| 173 return false; |
| 174 |
| 175 // Tablets are mapped to the screen. |
| 176 if (HasKeyEvent(BTN_TOOL_PEN) || HasKeyEvent(BTN_STYLUS) || |
| 177 HasKeyEvent(BTN_STYLUS2)) |
| 178 return true; |
| 179 |
| 180 // Touchpads are not mapped to the screen. |
| 181 if (HasKeyEvent(BTN_LEFT) || HasKeyEvent(BTN_MIDDLE) || |
| 182 HasKeyEvent(BTN_RIGHT) || HasKeyEvent(BTN_TOOL_FINGER)) |
| 183 return false; |
| 184 |
| 185 // Touchscreens are mapped to the screen. |
| 186 return true; |
| 187 } |
| 188 |
152 } // namespace ui | 189 } // namespace ui |
OLD | NEW |