xref: /netbsd/usr.sbin/wsmoused/wsmoused.h (revision 8f09a924)
1 /* $NetBSD: wsmoused.h,v 1.10 2021/11/24 14:34:51 uwe Exp $ */
2 
3 /*
4  * Copyright (c) 2002, 2003, 2004 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Julio M. Merino Vidal.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. The name authors may not be used to endorse or promote products
16  *    derived from this software without specific prior written
17  *    permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
20  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _WSMOUSED_WSMOUSED_H
33 #define _WSMOUSED_WSMOUSED_H
34 
35 #define IS_MOTION_EVENT(type) (((type) == WSCONS_EVENT_MOUSE_DELTA_X) || \
36                                ((type) == WSCONS_EVENT_MOUSE_DELTA_Y) || \
37                                ((type) == WSCONS_EVENT_MOUSE_DELTA_Z) || \
38                                ((type) == WSCONS_EVENT_MOUSE_DELTA_W) || \
39                                ((type) == WSCONS_EVENT_MOUSE_ABSOLUTE_X) || \
40                                ((type) == WSCONS_EVENT_MOUSE_ABSOLUTE_Y) || \
41                                ((type) == WSCONS_EVENT_MOUSE_ABSOLUTE_Z) || \
42                                ((type) == WSCONS_EVENT_MOUSE_ABSOLUTE_W))
43 
44 #define IS_BUTTON_EVENT(type) (((type) == WSCONS_EVENT_MOUSE_UP) || \
45                                ((type) == WSCONS_EVENT_MOUSE_DOWN))
46 
47 struct mouse {
48 	int   m_devfd;          /* File descriptor of wsmouse device */
49 	int   m_fifofd;         /* File descriptor of fifo */
50 	int   m_statfd;         /* File descriptor of wscons status device */
51 	char *m_devname;        /* File name of wsmouse device */
52 	char *m_fifoname;       /* File name of fifo */
53 	int   m_disabled;       /* Whether if the mouse is disabled or not */
54 
55 	/* support for absolute position events */
56 	int m_doabs;
57 	struct wsmouse_calibcoords m_calib;
58 };
59 
60 struct mode_bootstrap {
61 	char  *mb_name;
62 	int  (*mb_startup)(struct mouse *);
63 	int  (*mb_cleanup)(void);
64 	void (*mb_wsmouse_event)(struct wscons_event);
65 	void (*mb_wscons_event)(struct wscons_event, int);
66 	void (*mb_poll_timeout)(void);
67 };
68 
69 struct prop {
70 	char *p_name;
71 	char *p_value;
72 };
73 
74 #define MAX_EVENTS	10
75 #define MAX_BLOCKS	10
76 #define MAX_PROPS	100
77 #define BLOCK_GLOBAL	1
78 #define BLOCK_MODE	2
79 #define BLOCK_EVENT	3
80 struct block {
81 	char *b_name;
82 	int b_type;
83 	int b_prop_count;
84 	int b_child_count;
85 	struct prop *b_prop[MAX_PROPS];
86 	struct block *b_child[MAX_BLOCKS];
87 	struct block *b_parent;
88 };
89 
90 /* Prototypes for wsmoused.c */
91 void log_err(int, const char *, ...);
92 void log_errx(int, const char *, ...);
93 void log_info(const char *, ...);
94 void log_warn(const char *, ...);
95 void log_warnx(const char *, ...);
96 
97 /* Prototypes for config.c */
98 struct prop *prop_new(void);
99 void prop_free(struct prop *);
100 struct block *block_new(int);
101 void block_free(struct block *);
102 void block_add_prop(struct block *, struct prop *);
103 void block_add_child(struct block *, struct block *);
104 char *block_get_propval(struct block *, const char *, char *);
105 int block_get_propval_int(struct block *, const char *, int);
106 struct block *config_get_mode(const char *);
107 void config_read(const char *, int);
108 void config_free(void);
109 
110 #endif /* _WSMOUSED_WSMOUSED_H */
111