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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
/*
* 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"
#include <stdarg.h>
struct SynapticsFrontend {
/**
* Generic messaging call. Called by the core driver to output driver log
* messages.
*/
void (*Msg)(SynapticsPrivate *priv, enum MessageType type,
const char *format, va_list args);
/**
* Return the current time in milliseconds.
*/
unsigned int (*GetCurrentMillis)(void);
/**
* Post a button event of the given type.
*/
void (*ButtonEvent)(SynapticsPrivate *priv, int button, enum ButtonEventType press);
/**
* Post a motion event.
*/
void (*MotionEvent)(SynapticsPrivate *priv, int x, int y);
/**
* Post a scroll event.
*/
void (*ScrollEvent)(SynapticsPrivate *priv, unsigned int which,
double vert, double horiz);
/**
* Post a touch event for the given touchid of the given type.
*/
void (*TouchEvent)(SynapticsPrivate *priv, unsigned int touchid,
enum TouchEventType type, struct VMask *mask);
/**
* Set a timer to be called delay milliseconds after now. That timer should
* call the SynapticsTimerFunc when it fires.
*/
void (*SetTimer)(SynapticsPrivate *priv, unsigned int now, unsigned int delay);
};
/* Wrappers the drivers uses to call the matching frontend calls */
void SynapticsMsg(SynapticsPrivate *priv, enum MessageType type, const char *format, ...);
unsigned int SynapticsGetCurrentMillis(SynapticsPrivate *priv);
void SynapticsButtonEvent(SynapticsPrivate *priv, int button, enum ButtonEventType press);
void SynapticsMotionEvent(SynapticsPrivate *priv, int x, int y);
void SynapticsScrollEvent(SynapticsPrivate *priv, unsigned int which, double vert, double horiz);
void SynapticsTouchEvent(SynapticsPrivate *priv, unsigned int touchid,
enum TouchEventType type, struct VMask *mask);
void SynapticsSetTimer(SynapticsPrivate *priv, unsigned int now, unsigned int delay);
/**
* 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(struct SynapticsFrontend *frontend);
/**
* Deletes driver-associated memory regions.
* Implemented by: core
* @see SynapticsInitPrivate
*/
void SynapticsFreePrivate(SynapticsPrivate **private);
/**
* 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. Returns 1 on success or 0 on error.
* Call this before enabling the file descriptor.
* Implemented-by: core
*/
int SynapticsInitDevice(SynapticsPrivate *priv);
/**
* Enable the backend to start sending events. Returns 1 on success or 0 on
* error.
* Implemented-by: core
*/
int SynapticsEnableDevice(SynapticsPrivate *priv, int fd);
/**
* Disable the backend to stop sending events. Returns 1 on success or 0 on
* error.
* Implemented-by: core
*/
int SynapticsDisableDevice(SynapticsPrivate *priv, int fd);
/**
* Shut down the device. Call this after disabling the file descriptor.
* Implemented-by: core
*/
void SynapticsCloseDevice(SynapticsPrivate *priv);
/**
* Finish any device-specifi initialization, once the hardware has been
* queried and all non-default parameters have been set.
* Implemented-by: core
*/
void SynapticsFinishPreInit(SynapticsPrivate * priv);
/**
* Query the hardware for properties, dimensions, etc. Returns 1 on success
* or 0 on failure.
* Implemented-by: core
*/
Bool SynapticsQueryHardware(SynapticsPrivate *priv, int fd);
/**
* Given a protocol string and/or device file, return the backend protocol
* operations and the effectively used device.
* Implemented-by: core
*/
struct SynapticsProtocolOperations*
SynapticsGetDeviceProtocolOps(SynapticsPrivate *priv,
const char *proto,
const char *device,
char **used_device);
/**
* Driver-internal timer callback. Must be called from the front-end
* specific timer handler.
* Implemented-by: core
*/
unsigned int SynapticsTimerFunc(SynapticsPrivate *priv, unsigned int now);
extern struct VMask *vmask_new(int num_valuators);
extern void vmask_free(struct VMask **mask);
extern void vmask_set_range(struct VMask *mask,
int first_valuator,
int num_valuators,
const int *valuators);
extern void vmask_set(struct VMask *mask, int valuator, int data);
extern void vmask_set_double(struct VMask *mask, int valuator, double data);
extern void vmask_zero(struct VMask *mask);
extern int vmask_size(const struct VMask *mask);
extern int vmask_isset(const struct VMask *mask, int bit);
extern void vmask_unset(struct VMask *mask, int bit);
extern int vmask_num_valuators(const struct VMask *mask);
extern void vmask_copy(struct VMask *dest, const struct VMask *src);
extern int vmask_get(const struct VMask *mask, int valnum);
extern double vmask_get_double(const struct VMask *mask, int valnum);
extern Bool vmask_fetch(const struct VMask *mask, int valnum, int *val);
extern Bool vmask_fetch_double(const struct VMask *mask, int valnum, double *val);
#endif /* _SYNAPTICS_H_ */
|