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