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