Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / events / ozone / evdev / event_device_info.h
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.
4
5 #ifndef UI_EVENTS_OZONE_EVDEV_EVENT_DEVICE_INFO_H_
6 #define UI_EVENTS_OZONE_EVDEV_EVENT_DEVICE_INFO_H_
7
8 #include <limits.h>
9 #include <linux/input.h>
10
11 #include "base/basictypes.h"
12 #include "ui/events/events_export.h"
13
14 #define EVDEV_LONG_BITS (CHAR_BIT * sizeof(long))
15 #define EVDEV_BITS_TO_LONGS(x) (((x) + EVDEV_LONG_BITS - 1) / EVDEV_LONG_BITS)
16
17 namespace ui {
18
19 // Device information for Linux input devices
20 //
21 // This stores and queries information about input devices; in
22 // particular it knows which events the device can generate.
23 class EVENTS_EXPORT EventDeviceInfo {
24  public:
25   EventDeviceInfo();
26   ~EventDeviceInfo();
27
28   // Initialize device information from an open device.
29   bool Initialize(int fd);
30
31   // Check events this device can generate.
32   bool HasEventType(unsigned int type) const;
33   bool HasKeyEvent(unsigned int code) const;
34   bool HasRelEvent(unsigned int code) const;
35   bool HasAbsEvent(unsigned int code) const;
36   bool HasMscEvent(unsigned int code) const;
37   bool HasSwEvent(unsigned int code) const;
38   bool HasLedEvent(unsigned int code) const;
39
40   // Properties of absolute axes.
41   int32 GetAbsMinimum(unsigned int code) const;
42   int32 GetAbsMaximum(unsigned int code) const;
43
44   // Check input device properties.
45   bool HasProp(unsigned int code) const;
46
47  private:
48   unsigned long ev_bits_[EVDEV_BITS_TO_LONGS(EV_CNT)];
49   unsigned long key_bits_[EVDEV_BITS_TO_LONGS(KEY_CNT)];
50   unsigned long rel_bits_[EVDEV_BITS_TO_LONGS(REL_CNT)];
51   unsigned long abs_bits_[EVDEV_BITS_TO_LONGS(ABS_CNT)];
52   unsigned long msc_bits_[EVDEV_BITS_TO_LONGS(MSC_CNT)];
53   unsigned long sw_bits_[EVDEV_BITS_TO_LONGS(SW_CNT)];
54   unsigned long led_bits_[EVDEV_BITS_TO_LONGS(LED_CNT)];
55   unsigned long prop_bits_[EVDEV_BITS_TO_LONGS(INPUT_PROP_CNT)];
56
57   struct input_absinfo abs_info_[ABS_CNT];
58
59   DISALLOW_COPY_AND_ASSIGN(EventDeviceInfo);
60 };
61
62 }  // namspace ui
63
64 #endif  // UI_EVENTS_OZONE_EVDEV_EVENT_DEVICE_INFO_H_