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