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

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

Issue 2805793002: ozone: evdev: Add gamepad support (Closed)
Patch Set: Support Gamepad in Ozone. Created 3 years, 8 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
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/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 420 }
421 421
422 bool EventDeviceInfo::HasTablet() const { 422 bool EventDeviceInfo::HasTablet() const {
423 return HasAbsXY() && HasPointer() && HasStylus(); 423 return HasAbsXY() && HasPointer() && HasStylus();
424 } 424 }
425 425
426 bool EventDeviceInfo::HasTouchscreen() const { 426 bool EventDeviceInfo::HasTouchscreen() const {
427 return HasAbsXY() && HasDirect(); 427 return HasAbsXY() && HasDirect();
428 } 428 }
429 429
430 bool EventDeviceInfo::HasGamepad() const {
431 if (!HasEventType(EV_KEY))
432 return false;
433
434 // If the device has gamepad button, it will be considered
435 // as a gamepad. Note: this WILL have false positives and false negatives. A
436 // concrete solution will use ID_INPUT_JOYSTICK with some patch remving false
spang 2017/04/21 05:38:46 typo: removing
jkwang 2017/04/25 21:16:41 Done.
437 // positives.
438 for (int key = BTN_JOYSTICK; key <= BTN_THUMBR; ++key)
spang 2017/05/03 22:00:37 Please add braces around all multiline blocks. The
jkwang 2017/05/05 00:07:45 Done.
439 if (HasKeyEvent(key))
440 return true;
441
442 return false;
443 }
444
430 EventDeviceInfo::LegacyAbsoluteDeviceType 445 EventDeviceInfo::LegacyAbsoluteDeviceType
431 EventDeviceInfo::ProbeLegacyAbsoluteDevice() const { 446 EventDeviceInfo::ProbeLegacyAbsoluteDevice() const {
432 if (!HasAbsXY()) 447 if (!HasAbsXY())
433 return LegacyAbsoluteDeviceType::LADT_NONE; 448 return LegacyAbsoluteDeviceType::LADT_NONE;
434 449
435 // Treat internal stylus devices as touchscreens. 450 // Treat internal stylus devices as touchscreens.
436 if (device_type_ == INPUT_DEVICE_INTERNAL && HasStylus()) 451 if (device_type_ == INPUT_DEVICE_INTERNAL && HasStylus())
437 return LegacyAbsoluteDeviceType::LADT_TOUCHSCREEN; 452 return LegacyAbsoluteDeviceType::LADT_TOUCHSCREEN;
438 453
439 if (HasStylus()) 454 if (HasStylus())
440 return LegacyAbsoluteDeviceType::LADT_TABLET; 455 return LegacyAbsoluteDeviceType::LADT_TABLET;
441 456
442 if (HasKeyEvent(BTN_TOOL_FINGER) && HasKeyEvent(BTN_TOUCH)) 457 if (HasKeyEvent(BTN_TOOL_FINGER) && HasKeyEvent(BTN_TOUCH))
443 return LegacyAbsoluteDeviceType::LADT_TOUCHPAD; 458 return LegacyAbsoluteDeviceType::LADT_TOUCHPAD;
444 459
445 if (HasKeyEvent(BTN_TOUCH)) 460 if (HasKeyEvent(BTN_TOUCH))
446 return LegacyAbsoluteDeviceType::LADT_TOUCHSCREEN; 461 return LegacyAbsoluteDeviceType::LADT_TOUCHSCREEN;
447 462
448 // ABS_Z mitigation for extra device on some Elo devices. 463 // ABS_Z mitigation for extra device on some Elo devices.
449 if (HasKeyEvent(BTN_LEFT) && !HasAbsEvent(ABS_Z)) 464 if (HasKeyEvent(BTN_LEFT) && !HasAbsEvent(ABS_Z))
450 return LegacyAbsoluteDeviceType::LADT_TOUCHSCREEN; 465 return LegacyAbsoluteDeviceType::LADT_TOUCHSCREEN;
451 466
452 return LegacyAbsoluteDeviceType::LADT_NONE; 467 return LegacyAbsoluteDeviceType::LADT_NONE;
453 } 468 }
454 469
455 } // namespace ui 470 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698