summaryrefslogtreecommitdiff
path: root/src/synaptics.h
blob: e637e1ab91fe1cc6dc516f763a7a9c031c8ff187 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * Permission to use, copy, modify, distribute, and sell this software
 * and its documentation for any purpose is hereby granted without
 * fee, provided that the above copyright notice appear in all copies
 * and that both that copyright notice and this permission notice
 * appear in supporting documentation, and that the name of Red Hat
 * not be used in advertising or publicity pertaining to distribution
 * of the software without specific, written prior permission.  Red
 * Hat makes no representations about the suitability of this software
 * for any purpose.  It is provided "as is" without express or implied
 * warranty.
 *
 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef	_SYNAPTICS_H_
#define _SYNAPTICS_H_

#include "synproto.h"
#include "synapticsstr.h"

/**
 * Generic messaging call. Called by the core driver to output driver log
 * messages.
 * Implemented by: front-end
 */
void SynapticsMsg(SynapticsPrivate *priv, enum MessageType type, const char *format, ...);

/**
 * Initialises the driver-internal structs. Must be the first call to the
 * driver core, subsequent calls must use the memory region returned.
 * Implemented by: core
 * @see SynapticsFreePrivate
 */
SynapticsPrivate * SynapticsInitPrivate(void);
/**
 * Deletes driver-associated memory regions.
 * Implemented by: core
 * @see SynapticsInitPrivate
 */
void SynapticsFreePrivate(SynapticsPrivate **private);
void SynapticsReset(SynapticsPrivate * priv);
/**
 * Callback for data available on device file descriptor. Reads data and
 * posts events to the frontend.
 * Implemented by: core
 */
void SynapticsReadInput(SynapticsPrivate *priv, int fd);
/**
 * Initialise device-internal structs and get the device ready for sending
 * events.
 * Call this before enabling the file descriptor.
 * Implemented-by: core
 */
Bool SynapticsInitDevice(SynapticsPrivate *priv);
/**
 * Shut down the device. Call this after disabling the file descriptor.
 * Implemented-by: core
 */
void SynapticsCloseDevice(SynapticsPrivate *priv);
/**
 * Set a timer to be called delay milliseconds after now. That timer should
 * call the SynapticsTimerFunc when it fires.
 * Implemented-by: frontend
 */
void SynapticsSetTimer(SynapticsPrivate *priv, unsigned int now, unsigned int delay);
void CalculateScalingCoeffs(SynapticsPrivate * priv);
Bool SynapticsQueryHardware(SynapticsPrivate *priv, int fd);
struct SynapticsProtocolOperations*
SynapticsGetDeviceProtocolOps(SynapticsPrivate *priv,
                              const char *proto,
                              const char *device,
                              char **used_device);
unsigned int SynapticsTimerFunc(SynapticsPrivate *priv, unsigned int now);
/**
 * Return the current time in milliseconds.
 */
unsigned int SynapticsGetCurrentMillis(void);

/**
 * Post a button event of the given type.
 * Implemented-by: frontend
 */
void SynapticsButtonEvent(SynapticsPrivate *priv, int button, enum ButtonEventType press);

/**
 * Post a motion event.
 * Implemented-by: frontend
 */
void SynapticsMotionEvent(SynapticsPrivate *priv, int x, int y);

/**
 * Post a scroll event.
 * Implemented-by: frontend
 */
void SynapticsScrollEvent(SynapticsPrivate *priv, VMask *mask);

/**
 * Post a touch event for the given touchid of the given type.
 * Implemented-by: frontend
 */
void SynapticsTouchEvent(SynapticsPrivate *priv, unsigned int touchid,
                         enum TouchEventType type, VMask *mask);

extern VMask *vmask_new(int num_valuators);
extern void vmask_free(VMask **mask);
extern void vmask_set_range(VMask *mask,
                            int first_valuator,
                            int num_valuators,
                            const int *valuators);
extern void vmask_set(VMask *mask, int valuator, int data);
extern void vmask_set_double(VMask *mask, int valuator, double data);
extern void vmask_zero(VMask *mask);
extern int vmask_size(const VMask *mask);
extern int vmask_isset(const VMask *mask, int bit);
extern void vmask_unset(VMask *mask, int bit);
extern int vmask_num_valuators(const VMask *mask);
extern void vmask_copy(VMask *dest, const VMask *src);
extern int vmask_get(const VMask *mask, int valnum);
extern double vmask_get_double(const VMask *mask, int valnum);
extern Bool vmask_fetch(const VMask *mask, int valnum, int *val);
extern Bool vmask_fetch_double(const VMask *mask, int valnum, double *val);

#endif                          /* _SYNAPTICS_H_ */