mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
Input: MT - Add in-kernel tracking
With the INPUT_MT_TRACK flag set, the function input_mt_assign_slots() can be used to match a new set of contacts against the currently used slots. The algorithm used is based on Lagrange relaxation, and performs very well in practice; slower than mtdev for a few corner cases, but faster in most commonly occuring cases. Tested-by: Benjamin Tissoires <benjamin.tissoires@enac.fr> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
This commit is contained in:
parent
55e49089f4
commit
7c1a87897c
2 changed files with 163 additions and 2 deletions
|
@ -18,6 +18,8 @@
|
|||
#define INPUT_MT_POINTER 0x0001 /* pointer device, e.g. trackpad */
|
||||
#define INPUT_MT_DIRECT 0x0002 /* direct device, e.g. touchscreen */
|
||||
#define INPUT_MT_DROP_UNUSED 0x0004 /* drop contacts not seen in frame */
|
||||
#define INPUT_MT_TRACK 0x0008 /* use in-kernel tracking */
|
||||
|
||||
/**
|
||||
* struct input_mt_slot - represents the state of an input MT slot
|
||||
* @abs: holds current values of ABS_MT axes for this slot
|
||||
|
@ -35,6 +37,7 @@ struct input_mt_slot {
|
|||
* @slot: MT slot currently being transmitted
|
||||
* @flags: input_mt operation flags
|
||||
* @frame: increases every time input_mt_sync_frame() is called
|
||||
* @red: reduced cost matrix for in-kernel tracking
|
||||
* @slots: array of slots holding current values of tracked contacts
|
||||
*/
|
||||
struct input_mt {
|
||||
|
@ -43,6 +46,7 @@ struct input_mt {
|
|||
int slot;
|
||||
unsigned int flags;
|
||||
unsigned int frame;
|
||||
int *red;
|
||||
struct input_mt_slot slots[];
|
||||
};
|
||||
|
||||
|
@ -58,6 +62,11 @@ static inline int input_mt_get_value(const struct input_mt_slot *slot,
|
|||
return slot->abs[code - ABS_MT_FIRST];
|
||||
}
|
||||
|
||||
static inline bool input_mt_is_active(const struct input_mt_slot *slot)
|
||||
{
|
||||
return input_mt_get_value(slot, ABS_MT_TRACKING_ID) >= 0;
|
||||
}
|
||||
|
||||
int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots,
|
||||
unsigned int flags);
|
||||
void input_mt_destroy_slots(struct input_dev *dev);
|
||||
|
@ -90,4 +99,16 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count);
|
|||
|
||||
void input_mt_sync_frame(struct input_dev *dev);
|
||||
|
||||
/**
|
||||
* struct input_mt_pos - contact position
|
||||
* @x: horizontal coordinate
|
||||
* @y: vertical coordinate
|
||||
*/
|
||||
struct input_mt_pos {
|
||||
s16 x, y;
|
||||
};
|
||||
|
||||
int input_mt_assign_slots(struct input_dev *dev, int *slots,
|
||||
const struct input_mt_pos *pos, int num_pos);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue