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
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_OZONE_EVDEV_EVENT_DEVICE_INFO_H_
6 #define UI_EVENTS_OZONE_EVDEV_EVENT_DEVICE_INFO_H_
9 #include <linux/input.h>
13 #include "base/basictypes.h"
14 #include "ui/events/ozone/evdev/event_device_util.h"
15 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
17 // ABS_MT_SLOT isn't valid options for EVIOCGMTSLOTS ioctl.
18 #define EVDEV_ABS_MT_COUNT (ABS_MAX - ABS_MT_SLOT - 1)
22 // Input device types.
23 enum EVENTS_OZONE_EVDEV_EXPORT EventDeviceType
{
33 // Device information for Linux input devices
35 // This stores and queries information about input devices; in
36 // particular it knows which events the device can generate.
37 class EVENTS_OZONE_EVDEV_EXPORT EventDeviceInfo
{
42 // Initialize device information from an open device.
43 bool Initialize(int fd
);
45 // Check events this device can generate.
46 bool HasEventType(unsigned int type
) const;
47 bool HasKeyEvent(unsigned int code
) const;
48 bool HasRelEvent(unsigned int code
) const;
49 bool HasAbsEvent(unsigned int code
) const;
50 bool HasMscEvent(unsigned int code
) const;
51 bool HasSwEvent(unsigned int code
) const;
52 bool HasLedEvent(unsigned int code
) const;
54 // Properties of absolute axes.
55 int32
GetAbsMinimum(unsigned int code
) const;
56 int32
GetAbsMaximum(unsigned int code
) const;
57 int32
GetSlotValue(unsigned int code
, unsigned int slot
) const;
59 // Check input device properties.
60 bool HasProp(unsigned int code
) const;
62 // Has absolute X & Y axes (excludes MT)
63 bool HasAbsXY() const;
65 // Has MT absolute events
66 bool HasMTAbsXY() const;
68 // Has relative X & Y axes.
69 bool HasRelXY() const;
71 // Determine whether absolute device X/Y coordinates are mapped onto the
72 // screen. This is the case for touchscreens and tablets but not touchpads.
73 bool IsMappedToScreen() const;
75 // Determine whether there's a keyboard on this device.
76 bool HasKeyboard() const;
78 // Determine whether there's a mouse on this device.
79 bool HasMouse() const;
81 // Determine whether there's a touchpad on this device.
82 bool HasTouchpad() const;
85 // Return the slot vector in |slot_values_| for |code|.
86 const std::vector
<int32_t>& GetMtSlotsForCode(int code
) const;
88 unsigned long ev_bits_
[EVDEV_BITS_TO_LONGS(EV_CNT
)];
89 unsigned long key_bits_
[EVDEV_BITS_TO_LONGS(KEY_CNT
)];
90 unsigned long rel_bits_
[EVDEV_BITS_TO_LONGS(REL_CNT
)];
91 unsigned long abs_bits_
[EVDEV_BITS_TO_LONGS(ABS_CNT
)];
92 unsigned long msc_bits_
[EVDEV_BITS_TO_LONGS(MSC_CNT
)];
93 unsigned long sw_bits_
[EVDEV_BITS_TO_LONGS(SW_CNT
)];
94 unsigned long led_bits_
[EVDEV_BITS_TO_LONGS(LED_CNT
)];
95 unsigned long prop_bits_
[EVDEV_BITS_TO_LONGS(INPUT_PROP_CNT
)];
97 struct input_absinfo abs_info_
[ABS_CNT
];
99 // Store the values for the multi-touch properties for each slot.
100 std::vector
<int32_t> slot_values_
[EVDEV_ABS_MT_COUNT
];
102 DISALLOW_COPY_AND_ASSIGN(EventDeviceInfo
);
107 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_DEVICE_INFO_H_