Subversion Repositories shark

Rev

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