Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mt.h
Go to the documentation of this file.
1 #ifndef _INPUT_MT_H
2 #define _INPUT_MT_H
3 
4 /*
5  * Input Multitouch Library
6  *
7  * Copyright (c) 2010 Henrik Rydberg
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License version 2 as published by
11  * the Free Software Foundation.
12  */
13 
14 #include <linux/input.h>
15 
16 #define TRKID_MAX 0xffff
17 
18 #define INPUT_MT_POINTER 0x0001 /* pointer device, e.g. trackpad */
19 #define INPUT_MT_DIRECT 0x0002 /* direct device, e.g. touchscreen */
20 #define INPUT_MT_DROP_UNUSED 0x0004 /* drop contacts not seen in frame */
21 #define INPUT_MT_TRACK 0x0008 /* use in-kernel tracking */
22 
29 struct input_mt_slot {
31  unsigned int frame;
32  unsigned int key;
33 };
34 
45 struct input_mt {
46  int trkid;
47  int num_slots;
48  int slot;
49  unsigned int flags;
50  unsigned int frame;
51  int *red;
52  struct input_mt_slot slots[];
53 };
54 
55 static inline void input_mt_set_value(struct input_mt_slot *slot,
56  unsigned code, int value)
57 {
58  slot->abs[code - ABS_MT_FIRST] = value;
59 }
60 
61 static inline int input_mt_get_value(const struct input_mt_slot *slot,
62  unsigned code)
63 {
64  return slot->abs[code - ABS_MT_FIRST];
65 }
66 
67 static inline bool input_mt_is_active(const struct input_mt_slot *slot)
68 {
69  return input_mt_get_value(slot, ABS_MT_TRACKING_ID) >= 0;
70 }
71 
72 int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots,
73  unsigned int flags);
74 void input_mt_destroy_slots(struct input_dev *dev);
75 
76 static inline int input_mt_new_trkid(struct input_mt *mt)
77 {
78  return mt->trkid++ & TRKID_MAX;
79 }
80 
81 static inline void input_mt_slot(struct input_dev *dev, int slot)
82 {
83  input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
84 }
85 
86 static inline bool input_is_mt_value(int axis)
87 {
88  return axis >= ABS_MT_FIRST && axis <= ABS_MT_LAST;
89 }
90 
91 static inline bool input_is_mt_axis(int axis)
92 {
93  return axis == ABS_MT_SLOT || input_is_mt_value(axis);
94 }
95 
96 void input_mt_report_slot_state(struct input_dev *dev,
97  unsigned int tool_type, bool active);
98 
99 void input_mt_report_finger_count(struct input_dev *dev, int count);
100 void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count);
101 
102 void input_mt_sync_frame(struct input_dev *dev);
103 
109 struct input_mt_pos {
110  s16 x, y;
111 };
112 
113 int input_mt_assign_slots(struct input_dev *dev, int *slots,
114  const struct input_mt_pos *pos, int num_pos);
115 
116 int input_mt_get_slot_by_key(struct input_dev *dev, int key);
117 
118 #endif