xref: /openbsd/sys/dev/hid/hidmsvar.h (revision cdf25420)
1 /*	$OpenBSD: hidmsvar.h,v 1.3 2023/08/12 20:47:06 miod Exp $ */
2 /*	$NetBSD: ums.c,v 1.60 2003/03/11 16:44:00 augustss Exp $	*/
3 
4 /*
5  * Copyright (c) 1998 The NetBSD Foundation, Inc.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to The NetBSD Foundation
9  * by Lennart Augustsson (lennart@augustsson.net) at
10  * Carlstedt Research & Technology.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #define MAX_BUTTONS	31	/* must not exceed size of sc_buttons */
35 
36 struct tsscale {
37 	int	minx, maxx;
38 	int	miny, maxy;
39 	int 	minz, maxz;
40 	int 	minw, maxw;
41 	int	swapxy;
42 	int	resx, resy;
43 };
44 
45 struct hidms {
46 	struct device	*sc_device;
47 	struct device	*sc_wsmousedev;
48 
49 	int		sc_enabled;
50 	int		sc_flags;	/* device configuration */
51 #define HIDMS_SPUR_BUT_UP	0x0001	/* spurious button up events */
52 #define HIDMS_Z			0x0002	/* Z direction available */
53 #define HIDMS_REVZ		0x0004	/* Z-axis is reversed */
54 #define HIDMS_W			0x0008	/* W direction available */
55 #define HIDMS_REVW		0x0010	/* W-axis is reversed */
56 #define HIDMS_LEADINGBYTE	0x0020	/* Unknown leading byte */
57 #define HIDMS_ABSX		0x0040	/* X-axis is absolute */
58 #define HIDMS_ABSY		0x0080	/* Y-axis is absolute */
59 #define HIDMS_TIP		0x0100	/* Tip switch on a digitiser pen */
60 #define HIDMS_BARREL		0x0200	/* Barrel switch on a digitiser pen */
61 #define HIDMS_ERASER		0x0400	/* Eraser switch on a digitiser pen */
62 #define HIDMS_MS_BAD_CLASS	0x0800	/* Mouse doesn't identify properly */
63 #define HIDMS_VENDOR_BUTTONS	0x1000	/* extra buttons in vendor page */
64 #define HIDMS_SEC_BARREL	0x2000	/* Secondary Barrel switch on a digitiser pen */
65 #define HIDMS_WACOM_SETUP	0x4000	/* Requires Wacom-style setup */
66 
67 	int		sc_num_buttons;
68 	u_int32_t	sc_buttons;	/* mouse button status */
69 
70 	/* Wacom-specific fields */
71 	int 		sc_num_pad_buttons;
72 	int 		sc_num_stylus_buttons;
73 
74 	/* locators */
75 	struct hid_location sc_loc_x;
76 	struct hid_location sc_loc_y;
77 	struct hid_location sc_loc_z;
78 	struct hid_location sc_loc_w;
79 	struct hid_location sc_loc_btn[MAX_BUTTONS];
80 
81 	struct tsscale	sc_tsscale;
82 	int		sc_rawmode;
83 };
84 
85 void	hidms_attach(struct hidms *, const struct wsmouse_accessops *);
86 int	hidms_detach(struct hidms *, int);
87 void	hidms_disable(struct hidms *);
88 int	hidms_enable(struct hidms *);
89 void	hidms_input(struct hidms *, uint8_t *, u_int);
90 int	hidms_ioctl(struct hidms *, u_long, caddr_t, int, struct proc *);
91 int	hidms_setup(struct device *, struct hidms *, uint32_t, int, void *,
92 	    int);
93