xref: /openbsd-src/sys/dev/hid/hidmtvar.h (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /* $OpenBSD: hidmtvar.h,v 1.1 2016/01/20 01:26:00 jcs Exp $ */
2 /*
3  * Copyright (c) 2016 joshua stein <jcs@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 struct hidmt_input {
19 	int32_t			usage;
20 	struct hid_location	loc;
21 	SIMPLEQ_ENTRY(hidmt_input) entry;
22 };
23 
24 struct hidmt_contact {
25 	int		x;
26 	int		y;
27 	int		width;
28 	int		height;
29 	int		tip;
30 	int		confidence;
31 	int		contactid;
32 
33 	int		seen;
34 };
35 
36 struct hidmt {
37 	int		sc_enabled;
38 	uint32_t	sc_flags;
39 #define HIDMT_REVY	0x0001	/* Y-axis is reversed ("natural" scrolling) */
40 
41 	struct device	*sc_device;
42 	int		(*hidev_get_report)(struct device *, int, int, void *,
43 			    int);
44 	int		(*hidev_set_report)(struct device *, int, int, void *,
45 			    int);
46 
47 	int		sc_rep_input;
48 	int		sc_rep_input_size;
49 	int		sc_rep_config;
50 	int		sc_rep_cap;
51 
52 	SIMPLEQ_HEAD(, hidmt_input) sc_inputs;
53 
54 	struct device	*sc_wsmousedev;
55 	int		sc_wsmode;
56 
57 	int		sc_clickpad;
58 	int		sc_num_contacts;
59 #define HIDMT_MAX_CONTACTS	5
60 	int		sc_minx, sc_maxx;
61 	int		sc_miny, sc_maxy;
62 
63 	struct hidmt_contact sc_contacts[HIDMT_MAX_CONTACTS];
64 	int		sc_button;
65 
66 	int		last_x, last_y;
67 };
68 
69 int	hidmt_set_input_mode(struct hidmt *, int);
70 #define HIDMT_INPUT_MODE_MT	0x3
71 
72 void	hidmt_attach(struct hidmt *, const struct wsmouse_accessops *);
73 int	hidmt_detach(struct hidmt *, int);
74 void	hidmt_disable(struct hidmt *);
75 int	hidmt_enable(struct hidmt *);
76 void	hidmt_input(struct hidmt *, uint8_t *, u_int);
77 int	hidmt_ioctl(struct hidmt *, u_long, caddr_t, int, struct proc *);
78 int	hidmt_setup(struct device *, struct hidmt *, void *, int);
79