Rev 1618 | Details | Compare with Previous | 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 | ------------ |
||
720 | giacomo | 23 | CVS : $Id: mouse.h,v 1.2 2004-06-02 13:54:52 giacomo Exp $ |
105 | pj | 24 | |
25 | File: $File$ |
||
720 | giacomo | 26 | Revision: $Revision: 1.2 $ |
27 | Last update: $Date: 2004-06-02 13:54:52 $ |
||
105 | pj | 28 | ------------ |
29 | |||
30 | **/ |
||
31 | |||
32 | /** |
||
33 | ------------ |
||
720 | giacomo | 34 | CVS : $Id: mouse.h,v 1.2 2004-06-02 13:54:52 giacomo Exp $ |
105 | pj | 35 | |
36 | File: $File$ |
||
720 | giacomo | 37 | Revision: $Revision: 1.2 $ |
38 | Last update: $Date: 2004-06-02 13:54:52 $ |
||
105 | pj | 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 | |||
1621 | fabio | 79 | #include <arch/sys/cdefs.h> |
105 | pj | 80 | |
81 | __BEGIN_DECLS |
||
82 | |||
83 | /* mouse buttons constant */ |
||
84 | #define MOUSE_RBUTT 1 |
||
85 | #define MOUSE_CBUTT 2 |
||
86 | #define MOUSE_LBUTT 4 |
||
87 | |||
88 | /* the mouse event struct */ |
||
89 | typedef struct { |
||
90 | int x,y; /* mouse position */ |
||
91 | int dx,dy; /* distance covered by mouse */ |
||
92 | int buttons; /* buttons flags */ |
||
93 | } MOUSE_EVT; |
||
94 | |||
95 | /* macros to test mouse buttons */ |
||
96 | #define isLeftButton(m) ((m).buttons & MOUSE_LBUTT) |
||
97 | #define isRightButton(m) ((m).buttons & MOUSE_RBUTT) |
||
98 | #define isCentralButton(m) ((m).buttons & MOUSE_CBUTT) |
||
99 | |||
100 | /* user mouse handler */ |
||
101 | typedef void (*MOUSE_HANDLER)(MOUSE_EVT*); |
||
102 | |||
103 | /* mouse types */ |
||
104 | /* (run examples/mfind.c for a description)*/ |
||
105 | #define MSMOUSE 0x00 |
||
106 | #define MSPMOUSE 0x01 |
||
107 | #define MSPLRMOUSE 0x02 |
||
108 | #define BAREMOUSE 0x03 |
||
109 | #define MSCMOUSE 0x04 |
||
110 | #define SUNMOUSE 0x05 |
||
111 | #define MMMOUSE 0x06 |
||
112 | #define LOGIMOUSE 0x07 |
||
113 | #define PS2MOUSE 0x08 |
||
114 | #define NOMOUSE 0xff |
||
115 | |||
116 | /* |
||
117 | * mouse initialization |
||
118 | */ |
||
119 | |||
120 | #define MOUSE_DEFAULT (DWORD)-1 |
||
121 | |||
122 | /* the MOUSE_PARMS structure used by mouse_init() */ |
||
123 | typedef struct mouse_parms { |
||
124 | TASK_MODEL *tm; |
||
125 | int type; /* mouse types (constants above) */ |
||
126 | /* for serial mouse */ |
||
127 | int port; /* serial port (i.e. COM1, ...) */ |
||
128 | } MOUSE_PARMS; |
||
129 | |||
130 | /* the default values for the MOUSE_PARMS structure */ |
||
131 | #define BASE_MOUSE {(TASK_MODEL *)MOUSE_DEFAULT,MOUSE_DEFAULT,MOUSE_DEFAULT} |
||
132 | |||
133 | /* to change the MOUSE_PARMS struct */ |
||
134 | #define mouse_default_parms(s) (s).tm = (TASK_MODEL *)MOUSE_DEFAULT, \ |
||
135 | (s).type = MOUSE_DEFAULT, \ |
||
136 | (s).port = MOUSE_DEFAULT |
||
137 | #define mouse_def_ms(s,p) (s).type=MSMOUSE; (s).port=(p) |
||
138 | #define mouse_def_msplus(s,p) (s).type=MSPMOUSE; (s).port=(p) |
||
139 | #define mouse_def_mspluslr(s,p) (s).type=MSPLRMOUSE; (s).port=(p) |
||
140 | #define mouse_def_bare(s,p) (s).type=BAREMOUSE; (s).port=(p) |
||
141 | #define mouse_def_msc(s,p) (s).type=MSCMOUSE; (s).port=(p) |
||
142 | #define mouse_def_sun(s,p) (s).type=SUNMOUSE; (s).port=(p) |
||
143 | #define mouse_def_mm(s,p) (s).type=MMMOUSE; (s).port=(p) |
||
144 | #define mouse_def_logi(s,p) (s).type=LOGIMOUSE; (s).port=(p) |
||
145 | #define mouse_def_ps2(s) (s).type=PS2MOUSE |
||
146 | #define mouse_def_task(s,m) (s).tm=(m) |
||
147 | |||
148 | /* |
||
149 | * user mouse interface |
||
150 | */ |
||
151 | |||
152 | int mouse_init(MOUSE_PARMS *s); |
||
153 | void mouse_enable(void); |
||
154 | void mouse_disable(void); |
||
155 | void mouse_get(int *x,int *y,BYTE *button); |
||
156 | void mouse_position(int x,int y); |
||
157 | void mouse_limit(int x1,int y1,int x2,int y2); |
||
158 | void mouse_threshold(unsigned t); |
||
159 | void mouse_hook(MOUSE_HANDLER h); |
||
160 | void mouse_end(void); |
||
161 | |||
162 | /* |
||
163 | * |
||
164 | * mouse autocursor management |
||
165 | * |
||
166 | */ |
||
167 | |||
168 | /* commands for mouse_grxcursor() & mouse_txtcursor() */ |
||
169 | #define DISABLE 0x00 |
||
170 | #define ENABLE 0x01 |
||
171 | |||
172 | /* flags for mouse_grxcursor() & mouse_txtcursor() (to use with '|') */ |
||
173 | #define WITHOUTSEM 0x10 |
||
174 | #define AUTOOFF 0x20 |
||
175 | |||
176 | /* dimensions of the grx shape */ |
||
177 | #define MOUSESHAPEDX 16 |
||
178 | #define MOUSESHAPEDY 16 |
||
179 | |||
180 | /* hot-spot of the grx image (coordinates of the center's shape, zero-based) */ |
||
181 | #define MOUSEHOTSPOTX 3 |
||
182 | #define MOUSEHOTSPOTY 1 |
||
183 | |||
184 | /* those macros can be used to set the correct mouse_limit() when |
||
185 | * the graphics autocursor is enable (to avoid wrong shape position because |
||
186 | * there is not graphics clip functions) |
||
187 | */ |
||
188 | #define XMINLIMIT(dimx,dimy) (MOUSEHOTSPOTX) |
||
189 | #define XMAXLIMIT(dimx,dimy) ((dimx)-MOUSESHAPEDX+MOUSEHOTSPOTX) |
||
190 | #define YMINLIMIT(dimx,dimy) (MOUSEHOTSPOTY) |
||
191 | #define YMAXLIMIT(dimx,dimy) ((dimy)-MOUSESHAPEDY+MOUSEHOTSPOTY) |
||
192 | |||
193 | #define mouse_grxlimit(dimx,dimy) mouse_limit(\ |
||
194 | XMINLIMIT(dimx,dimy), \ |
||
195 | YMINLIMIT(dimx,dimy), \ |
||
196 | XMAXLIMIT(dimx,dimy), \ |
||
197 | YMAXLIMIT(dimx,dimy) \ |
||
198 | ) |
||
199 | |||
200 | /* these are used to select the mouse shape */ |
||
201 | int mouse_txtshape(DWORD img); |
||
202 | int mouse_grxshape(BYTE *shape,BYTE *mask); |
||
203 | |||
204 | /* enable/disable mouse pointer */ |
||
205 | /* (return <0 on error) */ |
||
206 | /* (for the cmd parameter see above) */ |
||
207 | int mouse_grxcursor(int cmd); |
||
208 | int mouse_txtcursor(int cmd); |
||
209 | |||
210 | /* mouse on/off (or show/hide) */ |
||
211 | void (*mouse_on)(void); |
||
212 | void (*mouse_off)(void); |
||
213 | |||
214 | __END_DECLS |
||
215 | #endif |