0001
0002 #ifndef _INPUT_MT_H
0003 #define _INPUT_MT_H
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/input.h>
0012
0013 #define TRKID_MAX 0xffff
0014
0015 #define INPUT_MT_POINTER 0x0001
0016 #define INPUT_MT_DIRECT 0x0002
0017 #define INPUT_MT_DROP_UNUSED 0x0004
0018 #define INPUT_MT_TRACK 0x0008
0019 #define INPUT_MT_SEMI_MT 0x0010
0020
0021
0022
0023
0024
0025
0026
0027 struct input_mt_slot {
0028 int abs[ABS_MT_LAST - ABS_MT_FIRST + 1];
0029 unsigned int frame;
0030 unsigned int key;
0031 };
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 struct input_mt {
0044 int trkid;
0045 int num_slots;
0046 int slot;
0047 unsigned int flags;
0048 unsigned int frame;
0049 int *red;
0050 struct input_mt_slot slots[];
0051 };
0052
0053 static inline void input_mt_set_value(struct input_mt_slot *slot,
0054 unsigned code, int value)
0055 {
0056 slot->abs[code - ABS_MT_FIRST] = value;
0057 }
0058
0059 static inline int input_mt_get_value(const struct input_mt_slot *slot,
0060 unsigned code)
0061 {
0062 return slot->abs[code - ABS_MT_FIRST];
0063 }
0064
0065 static inline bool input_mt_is_active(const struct input_mt_slot *slot)
0066 {
0067 return input_mt_get_value(slot, ABS_MT_TRACKING_ID) >= 0;
0068 }
0069
0070 static inline bool input_mt_is_used(const struct input_mt *mt,
0071 const struct input_mt_slot *slot)
0072 {
0073 return slot->frame == mt->frame;
0074 }
0075
0076 int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots,
0077 unsigned int flags);
0078 void input_mt_destroy_slots(struct input_dev *dev);
0079
0080 static inline int input_mt_new_trkid(struct input_mt *mt)
0081 {
0082 return mt->trkid++ & TRKID_MAX;
0083 }
0084
0085 static inline void input_mt_slot(struct input_dev *dev, int slot)
0086 {
0087 input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
0088 }
0089
0090 static inline bool input_is_mt_value(int axis)
0091 {
0092 return axis >= ABS_MT_FIRST && axis <= ABS_MT_LAST;
0093 }
0094
0095 static inline bool input_is_mt_axis(int axis)
0096 {
0097 return axis == ABS_MT_SLOT || input_is_mt_value(axis);
0098 }
0099
0100 bool input_mt_report_slot_state(struct input_dev *dev,
0101 unsigned int tool_type, bool active);
0102
0103 static inline void input_mt_report_slot_inactive(struct input_dev *dev)
0104 {
0105 input_mt_report_slot_state(dev, 0, false);
0106 }
0107
0108 void input_mt_report_finger_count(struct input_dev *dev, int count);
0109 void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count);
0110 void input_mt_drop_unused(struct input_dev *dev);
0111
0112 void input_mt_sync_frame(struct input_dev *dev);
0113
0114
0115
0116
0117
0118
0119 struct input_mt_pos {
0120 s16 x, y;
0121 };
0122
0123 int input_mt_assign_slots(struct input_dev *dev, int *slots,
0124 const struct input_mt_pos *pos, int num_pos,
0125 int dmax);
0126
0127 int input_mt_get_slot_by_key(struct input_dev *dev, int key);
0128
0129 #endif