1#ifndef _INPUT_MT_H
2#define _INPUT_MT_H
3
4
5
6
7
8
9
10
11
12
13
14#include <linux/input.h>
15
16#define TRKID_MAX 0xffff
17
18#define INPUT_MT_POINTER 0x0001
19#define INPUT_MT_DIRECT 0x0002
20#define INPUT_MT_DROP_UNUSED 0x0004
21#define INPUT_MT_TRACK 0x0008
22#define INPUT_MT_SEMI_MT 0x0010
23
24
25
26
27
28
29
30struct input_mt_slot {
31 int abs[ABS_MT_LAST - ABS_MT_FIRST + 1];
32 unsigned int frame;
33 unsigned int key;
34};
35
36
37
38
39
40
41
42
43
44
45
46struct input_mt {
47 int trkid;
48 int num_slots;
49 int slot;
50 unsigned int flags;
51 unsigned int frame;
52 int *red;
53 struct input_mt_slot slots[];
54};
55
56static inline void input_mt_set_value(struct input_mt_slot *slot,
57 unsigned code, int value)
58{
59 slot->abs[code - ABS_MT_FIRST] = value;
60}
61
62static inline int input_mt_get_value(const struct input_mt_slot *slot,
63 unsigned code)
64{
65 return slot->abs[code - ABS_MT_FIRST];
66}
67
68static inline bool input_mt_is_active(const struct input_mt_slot *slot)
69{
70 return input_mt_get_value(slot, ABS_MT_TRACKING_ID) >= 0;
71}
72
73static inline bool input_mt_is_used(const struct input_mt *mt,
74 const struct input_mt_slot *slot)
75{
76 return slot->frame == mt->frame;
77}
78
79int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots,
80 unsigned int flags);
81void input_mt_destroy_slots(struct input_dev *dev);
82
83static inline int input_mt_new_trkid(struct input_mt *mt)
84{
85 return mt->trkid++ & TRKID_MAX;
86}
87
88static inline void input_mt_slot(struct input_dev *dev, int slot)
89{
90 input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
91}
92
93static inline bool input_is_mt_value(int axis)
94{
95 return axis >= ABS_MT_FIRST && axis <= ABS_MT_LAST;
96}
97
98static inline bool input_is_mt_axis(int axis)
99{
100 return axis == ABS_MT_SLOT || input_is_mt_value(axis);
101}
102
103void input_mt_report_slot_state(struct input_dev *dev,
104 unsigned int tool_type, bool active);
105
106void input_mt_report_finger_count(struct input_dev *dev, int count);
107void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count);
108
109void input_mt_sync_frame(struct input_dev *dev);
110
111
112
113
114
115
116struct input_mt_pos {
117 s16 x, y;
118};
119
120int input_mt_assign_slots(struct input_dev *dev, int *slots,
121 const struct input_mt_pos *pos, int num_pos,
122 int dmax);
123
124int input_mt_get_slot_by_key(struct input_dev *dev, int key);
125
126#endif
127