Subversion Repositories shark

Rev

Rev 523 | Rev 547 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
519 mauro 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   Mauro Marinoni      <mauro.marinoni@unipv.it>
13
 *
14
 *
15
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
16
 *
17
 * http://www.sssup.it
18
 * http://retis.sssup.it
19
 * http://shark.sssup.it
20
 */
21
 
22
/*
23
 * Copyright (C) 2000 Paolo Gai
24
 *
25
 * This program is free software; you can redistribute it and/or modify
26
 * it under the terms of the GNU General Public License as published by
27
 * the Free Software Foundation; either version 2 of the License, or
28
 * (at your option) any later version.
29
 *
30
 * This program is distributed in the hope that it will be useful,
31
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33
 * GNU General Public License for more details.
34
 *
35
 * You should have received a copy of the GNU General Public License
36
 * along with this program; if not, write to the Free Software
37
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
38
 *
39
 */
40
 
41
/* Glue Layer Header Linux Input Driver*/
42
 
43
#ifndef __SHARK_MOUSE26_H__
44
#define __SHARK_MOUSE26_H__
45
 
523 mauro 46
#include <kernel/const.h>
47
#include <kernel/model.h>
48
 
49
#ifdef __cplusplus
50
extern "C" {
51
#endif
52
 
519 mauro 53
/* mouse buttons constant */  
54
#define MOUSE_RBUTT     1
55
#define MOUSE_CBUTT     2
56
#define MOUSE_LBUTT     4
57
 
58
/* the mouse event struct */
59
typedef struct {
60
        int x, y, z;            /* mouse position */
523 mauro 61
        int dx, dy, dz;         /* distance covered by mouse */
62
        unsigned long buttons;  /* buttons flags */
519 mauro 63
} MOUSE_EVT;
64
 
65
/* macros to test mouse buttons */
523 mauro 66
#define isLeftButton(b)         ((b) & MOUSE_LBUTT)
67
#define isRightButton(b)        ((b) & MOUSE_RBUTT)
68
#define isCentralButton(b)      ((b) & MOUSE_CBUTT)
519 mauro 69
 
523 mauro 70
/*
71
 * mouse initialization
72
 */
73
 
74
/* the MOUSE_PARMS structure used by MOUSE26_init() */
75
typedef struct mouse_parms {
76
        TASK_MODEL *tm;
77
        int xmin;
78
        int ymin;
79
        int xmax;
80
        int ymax;
81
        int threshold;
82
} MOUSE_PARMS;
83
 
84
#define MOUSE_DEFAULT (DWORD)-1
85
 
86
/* the default values for the MOUSE_PARMS structure */
87
#define BASE_MOUSE {(TASK_MODEL *)MOUSE_DEFAULT, \
88
                    (int)MOUSE_DEFAULT, \
89
                    (int)MOUSE_DEFAULT, \
90
                    (int)MOUSE_DEFAULT, \
91
                    (int)MOUSE_DEFAULT, \
92
                    (int)MOUSE_DEFAULT}
93
 
94
/* to change the MOUSE_PARMS struct */
95
#define mouse_default_parms(s)  (s).tm = (TASK_MODEL *)MOUSE_DEFAULT, \
96
                                (s).xmin = (int)MOUSE_DEFAULT, \
97
                                (s).xmin = (int)MOUSE_DEFAULT, \
98
                                (s).xmin = (int)MOUSE_DEFAULT, \
99
                                (s).xmin = (int)MOUSE_DEFAULT, \
100
                                (s).xmin = (int)MOUSE_DEFAULT
101
 
102
#define mouse_def_task(s,m)     (s).tm = (TASK_MODEL *)(m)
103
#define mouse_def_thresh(s,v)   (s).threshold = (v)
104
#define mouse_def_xmin(s,v)     (s).xmin = (v)
105
#define mouse_def_ymin(s,v)     (s).ymin = (v)
106
#define mouse_def_xmax(s,v)     (s).xmax = (v)
107
#define mouse_def_ymax(s,v)     (s).ymax = (v)
108
 
519 mauro 109
/* user mouse handler */
110
typedef void (*MOUSE_HANDLER)(MOUSE_EVT*);
111
 
523 mauro 112
/*
113
 * user mouse interface
114
 */
115
int  MOUSE26_init(MOUSE_PARMS *s);
116
int  MOUSE26_close(void);
117
 
118
void mouse_enable(void);
119
void mouse_disable(void);
120
void mouse_getpos(int *x, int *y, int *z, unsigned long *buttons);
121
void mouse_setpos(int  x, int  y, int z);
122
void mouse_getlimit(int *xmin, int *ymin, int *xmax, int *ymax);
123
int  mouse_setlimit(int  xmin, int  ymin, int  xmax, int  ymax);
124
int  mouse_getthreshold(void);
125
int  mouse_setthreshold(int t);
126
void mouse_hook(MOUSE_HANDLER h);
519 mauro 127
 
538 mauro 128
 
129
/*
130
 *
131
 * mouse autocursor management
132
 *
133
 */
134
 
135
/* commands for mouse_grxcursor() & mouse_txtcursor() */
136
#define DISABLE   0x00
137
#define ENABLE    0x01
138
 
139
/* flags for mouse_grxcursor() & mouse_txtcursor() (to use with '|') */
140
#define WITHOUTSEM 0x10
141
#define AUTOOFF    0x20
142
 
143
/* mask to extrac the status from autocursormode */
144
#define STATUSMASK 0x0f
145
 
146
/* flags for autocursormode (there are some other flags into mouse.h) */
147
#define GRXCURSOR 0x100
148
#define TXTCURSOR 0x200
149
 
150
/* dimensions of the grx shape */
151
#define MOUSESHAPEDX 16
152
#define MOUSESHAPEDY 16
153
 
154
/* hot-spot of the grx image (coordinates of the center's shape, zero-based) */
155
#define MOUSEHOTSPOTX 3
156
#define MOUSEHOTSPOTY 1
157
 
158
/* those macros can be used to set the correct mouse_limit() when
159
 * the graphics autocursor is enable (to avoid wrong shape position because
160
 * there is not graphics clip functions)
161
 */
162
#define XMINLIMIT(dimx,dimy) (MOUSEHOTSPOTX)
163
#define XMAXLIMIT(dimx,dimy) ((dimx)-MOUSESHAPEDX+MOUSEHOTSPOTX)
164
#define YMINLIMIT(dimx,dimy) (MOUSEHOTSPOTY)
165
#define YMAXLIMIT(dimx,dimy) ((dimy)-MOUSESHAPEDY+MOUSEHOTSPOTY)
166
 
167
#define mouse_grxlimit(dimx,dimy) mouse_limit(\
168
        XMINLIMIT(dimx,dimy), \
169
        YMINLIMIT(dimx,dimy), \
170
        XMAXLIMIT(dimx,dimy), \
171
        YMAXLIMIT(dimx,dimy)  \
172
)
173
 
174
/* these are used to select the mouse shape */
175
int mouse_txtshape(DWORD img);
176
int mouse_grxshape(BYTE *shape, BYTE *mask, int bpp_in);
177
 
178
/* enable/disable mouse pointer */
179
/* (return <0 on error) */
180
/* (for the cmd parameter see above) */
181
int mouse_grxcursor(int cmd, int bpp);
182
int mouse_txtcursor(int cmd);
183
 
184
/* mouse on/off (or show/hide) */
185
void (*mouse_on)(void);
186
void (*mouse_off)(void);
187
 
523 mauro 188
#ifdef __cplusplus
189
};
519 mauro 190
#endif
191
 
523 mauro 192
#endif
193