Subversion Repositories shark

Rev

Rev 720 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
105 pj 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
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/**
22
 ------------
23
 CVS :        $Id: mouse.h,v 1.1 2003-03-24 10:54:17 pj Exp $
24
 
25
 File:        $File$
26
 Revision:    $Revision: 1.1 $
27
 Last update: $Date: 2003-03-24 10:54:17 $
28
 ------------
29
 
30
**/
31
 
32
/**
33
 ------------
34
 CVS :        $Id: mouse.h,v 1.1 2003-03-24 10:54:17 pj Exp $
35
 
36
 File:        $File$
37
 Revision:    $Revision: 1.1 $
38
 Last update: $Date: 2003-03-24 10:54:17 $
39
 ------------
40
 
41
 Author:        Gerardo Lamastra
42
 Date:  9/5/96
43
 
44
**/
45
 
46
/*
47
 * Copyright (C) 2000 Paolo Gai
48
 *
49
 * This program is free software; you can redistribute it and/or modify
50
 * it under the terms of the GNU General Public License as published by
51
 * the Free Software Foundation; either version 2 of the License, or
52
 * (at your option) any later version.
53
 *
54
 * This program is distributed in the hope that it will be useful,
55
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
56
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57
 * GNU General Public License for more details.
58
 *
59
 * You should have received a copy of the GNU General Public License
60
 * along with this program; if not, write to the Free Software
61
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
62
 *
63
 */
64
 
65
/* Revision:    1.0.1                                           */
66
/* -- added support for PS/2 mouse                              */
67
/* -- changed mouse_init()                                      */
68
 
69
/* By Massy:
70
 * -- added support for mouse cursor (pointer)
71
 * -- interface changed
72
 */
73
 
74
#ifndef __MOUSE_H__
75
#define __MOUSE_H__
76
 
77
#include <kernel/const.h>
78
 
79
#ifndef __SCOM_H__
80
#include <drivers/scom.h>
81
#endif
82
 
83
#include "ll/sys/cdefs.h"
84
 
85
__BEGIN_DECLS
86
 
87
/* mouse buttons constant */  
88
#define MOUSE_RBUTT     1
89
#define MOUSE_CBUTT     2
90
#define MOUSE_LBUTT     4
91
 
92
/* the mouse event struct */
93
typedef struct {
94
  int x,y;        /* mouse position */
95
  int dx,dy;      /* distance covered by mouse */
96
  int buttons;    /* buttons flags */
97
} MOUSE_EVT;
98
 
99
/* macros to test mouse buttons */
100
#define isLeftButton(m)    ((m).buttons & MOUSE_LBUTT)
101
#define isRightButton(m)   ((m).buttons & MOUSE_RBUTT)
102
#define isCentralButton(m) ((m).buttons & MOUSE_CBUTT)
103
 
104
/* user mouse handler */
105
typedef void (*MOUSE_HANDLER)(MOUSE_EVT*);
106
 
107
/* mouse types */
108
/* (run examples/mfind.c for a description)*/
109
#define MSMOUSE     0x00
110
#define MSPMOUSE    0x01
111
#define MSPLRMOUSE  0x02
112
#define BAREMOUSE   0x03
113
#define MSCMOUSE    0x04
114
#define SUNMOUSE    0x05
115
#define MMMOUSE     0x06
116
#define LOGIMOUSE   0x07
117
#define PS2MOUSE    0x08
118
#define NOMOUSE     0xff
119
 
120
/*
121
 * mouse initialization
122
 */
123
 
124
#define MOUSE_DEFAULT (DWORD)-1
125
 
126
/* the MOUSE_PARMS structure used by mouse_init() */
127
typedef struct mouse_parms {
128
  TASK_MODEL *tm;
129
  int   type;            /* mouse types (constants above) */
130
  /* for serial mouse */
131
  int   port;            /* serial port (i.e. COM1, ...)  */  
132
} MOUSE_PARMS;
133
 
134
/* the default values for the MOUSE_PARMS structure */
135
#define BASE_MOUSE {(TASK_MODEL *)MOUSE_DEFAULT,MOUSE_DEFAULT,MOUSE_DEFAULT}
136
 
137
/* to change the MOUSE_PARMS struct */
138
#define mouse_default_parms(s)        (s).tm = (TASK_MODEL *)MOUSE_DEFAULT, \
139
                                      (s).type = MOUSE_DEFAULT,             \
140
                                      (s).port = MOUSE_DEFAULT
141
#define mouse_def_ms(s,p)             (s).type=MSMOUSE;    (s).port=(p)
142
#define mouse_def_msplus(s,p)         (s).type=MSPMOUSE;   (s).port=(p)
143
#define mouse_def_mspluslr(s,p)       (s).type=MSPLRMOUSE; (s).port=(p)
144
#define mouse_def_bare(s,p)           (s).type=BAREMOUSE;  (s).port=(p)
145
#define mouse_def_msc(s,p)            (s).type=MSCMOUSE;   (s).port=(p)
146
#define mouse_def_sun(s,p)            (s).type=SUNMOUSE;   (s).port=(p)
147
#define mouse_def_mm(s,p)             (s).type=MMMOUSE;    (s).port=(p)
148
#define mouse_def_logi(s,p)           (s).type=LOGIMOUSE;  (s).port=(p)
149
#define mouse_def_ps2(s)              (s).type=PS2MOUSE
150
#define mouse_def_task(s,m)           (s).tm=(m)
151
 
152
/*
153
 * user mouse interface
154
 */
155
 
156
int  mouse_init(MOUSE_PARMS *s);
157
void mouse_enable(void);
158
void mouse_disable(void);
159
void mouse_get(int *x,int *y,BYTE *button);
160
void mouse_position(int x,int y);
161
void mouse_limit(int x1,int y1,int x2,int y2);
162
void mouse_threshold(unsigned t);
163
void mouse_hook(MOUSE_HANDLER h);
164
void mouse_end(void);
165
 
166
/*
167
 *
168
 * mouse autocursor management
169
 *
170
 */
171
 
172
/* commands for mouse_grxcursor() & mouse_txtcursor() */
173
#define DISABLE   0x00
174
#define ENABLE    0x01
175
 
176
/* flags for mouse_grxcursor() & mouse_txtcursor() (to use with '|') */
177
#define WITHOUTSEM 0x10
178
#define AUTOOFF    0x20
179
 
180
/* dimensions of the grx shape */
181
#define MOUSESHAPEDX 16
182
#define MOUSESHAPEDY 16
183
 
184
/* hot-spot of the grx image (coordinates of the center's shape, zero-based) */
185
#define MOUSEHOTSPOTX 3
186
#define MOUSEHOTSPOTY 1
187
 
188
/* those macros can be used to set the correct mouse_limit() when
189
 * the graphics autocursor is enable (to avoid wrong shape position because
190
 * there is not graphics clip functions)
191
 */
192
#define XMINLIMIT(dimx,dimy) (MOUSEHOTSPOTX)
193
#define XMAXLIMIT(dimx,dimy) ((dimx)-MOUSESHAPEDX+MOUSEHOTSPOTX)
194
#define YMINLIMIT(dimx,dimy) (MOUSEHOTSPOTY)
195
#define YMAXLIMIT(dimx,dimy) ((dimy)-MOUSESHAPEDY+MOUSEHOTSPOTY)
196
 
197
#define mouse_grxlimit(dimx,dimy) mouse_limit(\
198
XMINLIMIT(dimx,dimy), \
199
YMINLIMIT(dimx,dimy), \
200
XMAXLIMIT(dimx,dimy), \
201
YMAXLIMIT(dimx,dimy)  \
202
)
203
 
204
/* these are used to select the mouse shape */
205
int mouse_txtshape(DWORD img);
206
int mouse_grxshape(BYTE *shape,BYTE *mask);
207
 
208
/* enable/disable mouse pointer */
209
/* (return <0 on error) */
210
/* (for the cmd parameter see above) */
211
int mouse_grxcursor(int cmd);
212
int mouse_txtcursor(int cmd);
213
 
214
/* mouse on/off (or show/hide) */
215
void (*mouse_on)(void);
216
void (*mouse_off)(void);
217
 
218
__END_DECLS
219
#endif