XenevaOS
Loading...
Searching...
No Matches
mt.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-only */
2#ifndef _INPUT_MT_H
3#define _INPUT_MT_H
4
5/*
6 * Input Multitouch Library
7 *
8 * Copyright (c) 2010 Henrik Rydberg
9 */
10
11#include <linux/input.h>
12
13#define TRKID_MAX 0xffff
14
15#define INPUT_MT_POINTER 0x0001 /* pointer device, e.g. trackpad */
16#define INPUT_MT_DIRECT 0x0002 /* direct device, e.g. touchscreen */
17#define INPUT_MT_DROP_UNUSED 0x0004 /* drop contacts not seen in frame */
18#define INPUT_MT_TRACK 0x0008 /* use in-kernel tracking */
19#define INPUT_MT_SEMI_MT 0x0010 /* semi-mt device, finger count handled manually */
20#define INPUT_MT_TOTAL_FORCE 0x0020 /* calculate total force from slots pressure */
21
30 unsigned int frame;
31 unsigned int key;
32};
33
44struct input_mt {
45 int trkid;
47 int slot;
48 unsigned int flags;
49 unsigned int frame;
50 int *red;
52};
53
54static inline void input_mt_set_value(struct input_mt_slot *slot,
55 unsigned code, int value)
56{
57 slot->abs[code - ABS_MT_FIRST] = value;
58}
59
60static inline int input_mt_get_value(const struct input_mt_slot *slot,
61 unsigned code)
62{
63 return slot->abs[code - ABS_MT_FIRST];
64}
65
66static inline bool input_mt_is_active(const struct input_mt_slot *slot)
67{
68 return input_mt_get_value(slot, ABS_MT_TRACKING_ID) >= 0;
69}
70
71static inline bool input_mt_is_used(const struct input_mt *mt,
72 const struct input_mt_slot *slot)
73{
74 return slot->frame == mt->frame;
75}
76
77int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots,
78 unsigned int flags);
79void input_mt_destroy_slots(struct input_dev *dev);
80
81static inline int input_mt_new_trkid(struct input_mt *mt)
82{
83 return mt->trkid++ & TRKID_MAX;
84}
85
86static inline void input_mt_slot(struct input_dev *dev, int slot)
87{
89}
90
91static inline bool input_is_mt_value(int axis)
92{
93 return axis >= ABS_MT_FIRST && axis <= ABS_MT_LAST;
94}
95
96static inline bool input_is_mt_axis(int axis)
97{
98 return axis == ABS_MT_SLOT || input_is_mt_value(axis);
99}
100
101bool input_mt_report_slot_state(struct input_dev *dev,
102 unsigned int tool_type, bool active);
103
104static inline void input_mt_report_slot_inactive(struct input_dev *dev)
105{
107}
108
109void input_mt_report_finger_count(struct input_dev *dev, int count);
110void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count);
111void input_mt_drop_unused(struct input_dev *dev);
112
113void input_mt_sync_frame(struct input_dev *dev);
114
122};
123
124int input_mt_assign_slots(struct input_dev *dev, int *slots,
125 const struct input_mt_pos *pos, int num_pos,
126 int dmax);
127
128int input_mt_get_slot_by_key(struct input_dev *dev, int key);
129
130#endif
#define __counted_by(m)
Definition stddef.h:64
uint8_t flags
Definition virtio.h:0
const struct device * dev
Definition drm_print.h:519
#define ABS_MT_SLOT
Definition input-event-codes.h:908
#define ABS_MT_TRACKING_ID
Definition input-event-codes.h:918
#define EV_ABS
Definition input-event-codes.h:42
#define ABS_MT_LAST
Definition input.h:14
#define ABS_MT_FIRST
Definition input.h:13
int16_t s16
Definition kernel.h:19
int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, unsigned int flags)
void input_mt_drop_unused(struct input_dev *dev)
void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
void input_mt_destroy_slots(struct input_dev *dev)
#define TRKID_MAX
Definition mt.h:13
int input_mt_get_slot_by_key(struct input_dev *dev, int key)
int input_mt_assign_slots(struct input_dev *dev, int *slots, const struct input_mt_pos *pos, int num_pos, int dmax)
void input_mt_sync_frame(struct input_dev *dev)
void input_mt_report_finger_count(struct input_dev *dev, int count)
bool input_mt_report_slot_state(struct input_dev *dev, unsigned int tool_type, bool active)
Definition input.h:28
Definition mt.h:120
s16 x
Definition mt.h:121
s16 y
Definition mt.h:121
Definition mt.h:28
int abs[ABS_MT_LAST - ABS_MT_FIRST+1]
Definition mt.h:29
unsigned int key
Definition mt.h:31
unsigned int frame
Definition mt.h:30
Definition mt.h:44
int num_slots
Definition mt.h:46
int trkid
Definition mt.h:45
unsigned int flags
Definition mt.h:48
int slot
Definition mt.h:47
int * red
Definition mt.h:50
unsigned int frame
Definition mt.h:49