Home | History | Annotate | Line # | Download | only in wsmoused
wsmoused.h revision 1.6
      1 /* $NetBSD: wsmoused.h,v 1.6 2004/01/05 12:01:52 jmmv Exp $ */
      2 
      3 /*
      4  * Copyright (c) 2002, 2003 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 #include <stdbool.h>
     36 
     37 #define IS_MOTION_EVENT(type) (((type) == WSCONS_EVENT_MOUSE_DELTA_X) || \
     38                                ((type) == WSCONS_EVENT_MOUSE_DELTA_Y) || \
     39                                ((type) == WSCONS_EVENT_MOUSE_DELTA_Z))
     40 #define IS_BUTTON_EVENT(type) (((type) == WSCONS_EVENT_MOUSE_UP) || \
     41                                ((type) == WSCONS_EVENT_MOUSE_DOWN))
     42 
     43 struct mouse {
     44 	int   m_devfd;          /* File descriptor of wsmouse device */
     45 	int   m_fifofd;         /* File descriptor of fifo */
     46 	int   m_statfd;         /* File descriptor of wscons status device */
     47 	char *m_devname;        /* File name of wsmouse device */
     48 	char *m_fifoname;       /* File name of fifo */
     49 	int   m_disabled;       /* Whether if the mouse is disabled or not */
     50 };
     51 
     52 struct mode_bootstrap {
     53 	char  *mb_name;
     54 	int  (*mb_startup)(struct mouse *);
     55 	int  (*mb_cleanup)(void);
     56 	void (*mb_wsmouse_event)(struct wscons_event);
     57 	void (*mb_wscons_event)(struct wscons_event, bool);
     58 	void (*mb_poll_timeout)(void);
     59 };
     60 
     61 struct prop {
     62 	char *p_name;
     63 	char *p_value;
     64 };
     65 
     66 #define MAX_EVENTS	10
     67 #define MAX_BLOCKS	10
     68 #define MAX_PROPS	100
     69 #define BLOCK_GLOBAL	1
     70 #define BLOCK_MODE	2
     71 #define BLOCK_EVENT	3
     72 struct block {
     73 	char *b_name;
     74 	int b_type;
     75 	int b_prop_count;
     76 	int b_child_count;
     77 	struct prop *b_prop[MAX_BLOCKS];
     78 	struct block *b_child[MAX_BLOCKS];
     79 	struct block *b_parent;
     80 };
     81 
     82 /* Prototypes for wsmoused.c */
     83 void log_err(int, const char *, ...);
     84 void log_errx(int, const char *, ...);
     85 void log_info(const char *, ...);
     86 void log_warn(const char *, ...);
     87 void log_warnx(const char *, ...);
     88 
     89 /* Prototypes for config.c */
     90 struct prop *prop_new(void);
     91 void prop_free(struct prop *);
     92 struct block *block_new(int);
     93 void block_free(struct block *);
     94 void block_add_prop(struct block *, struct prop *);
     95 void block_add_child(struct block *, struct block *);
     96 char *block_get_propval(struct block *, const char *, char *);
     97 int block_get_propval_int(struct block *, const char *, int);
     98 struct block *config_get_mode(const char *);
     99 void config_read(const char *, int);
    100 void config_free(void);
    101 
    102 #endif /* _WSMOUSED_WSMOUSED_H */
    103