Subversion Repositories shark

Rev

Rev 547 | Rev 553 | 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
/* Glue Layer Header Linux Input Driver*/
23
 
24
#ifndef __SHARK_MOUSE26_H__
25
#define __SHARK_MOUSE26_H__
26
 
523 mauro 27
#include <kernel/const.h>
28
#include <kernel/model.h>
29
 
30
#ifdef __cplusplus
31
extern "C" {
32
#endif
33
 
519 mauro 34
/* mouse buttons constant */  
35
#define MOUSE_RBUTT     1
36
#define MOUSE_CBUTT     2
37
#define MOUSE_LBUTT     4
38
 
39
/* the mouse event struct */
40
typedef struct {
41
        int x, y, z;            /* mouse position */
523 mauro 42
        int dx, dy, dz;         /* distance covered by mouse */
43
        unsigned long buttons;  /* buttons flags */
519 mauro 44
} MOUSE_EVT;
45
 
46
/* macros to test mouse buttons */
523 mauro 47
#define isLeftButton(b)         ((b) & MOUSE_LBUTT)
48
#define isRightButton(b)        ((b) & MOUSE_RBUTT)
49
#define isCentralButton(b)      ((b) & MOUSE_CBUTT)
519 mauro 50
 
523 mauro 51
/*
52
 * mouse initialization
53
 */
54
 
55
/* the MOUSE_PARMS structure used by MOUSE26_init() */
56
typedef struct mouse_parms {
57
        TASK_MODEL *tm;
549 mauro 58
        int x0, y0, z0;
523 mauro 59
        int xmin;
60
        int ymin;
61
        int xmax;
62
        int ymax;
63
        int threshold;
64
} MOUSE_PARMS;
65
 
66
#define MOUSE_DEFAULT (DWORD)-1
67
 
68
/* the default values for the MOUSE_PARMS structure */
69
#define BASE_MOUSE {(TASK_MODEL *)MOUSE_DEFAULT, \
70
                    (int)MOUSE_DEFAULT, \
71
                    (int)MOUSE_DEFAULT, \
72
                    (int)MOUSE_DEFAULT, \
73
                    (int)MOUSE_DEFAULT, \
549 mauro 74
                    (int)MOUSE_DEFAULT, \
75
                    (int)MOUSE_DEFAULT, \
76
                    (int)MOUSE_DEFAULT, \
523 mauro 77
                    (int)MOUSE_DEFAULT}
78
 
79
/* to change the MOUSE_PARMS struct */
80
#define mouse_default_parms(s)  (s).tm = (TASK_MODEL *)MOUSE_DEFAULT, \
549 mauro 81
                                (s).x0 = (int)MOUSE_DEFAULT, \
82
                                (s).y0 = (int)MOUSE_DEFAULT, \
83
                                (s).z0 = (int)MOUSE_DEFAULT, \
523 mauro 84
                                (s).xmin = (int)MOUSE_DEFAULT, \
549 mauro 85
                                (s).xmax = (int)MOUSE_DEFAULT, \
86
                                (s).ymin = (int)MOUSE_DEFAULT, \
87
                                (s).ymax = (int)MOUSE_DEFAULT, \
88
                                (s).threshold = (int)MOUSE_DEFAULT
523 mauro 89
 
90
#define mouse_def_task(s,m)     (s).tm = (TASK_MODEL *)(m)
549 mauro 91
#define mouse_def_threshold(s,v)        (s).threshold = (v)
523 mauro 92
#define mouse_def_xmin(s,v)     (s).xmin = (v)
93
#define mouse_def_ymin(s,v)     (s).ymin = (v)
94
#define mouse_def_xmax(s,v)     (s).xmax = (v)
95
#define mouse_def_ymax(s,v)     (s).ymax = (v)
549 mauro 96
#define mouse_def_x0(s,v)       (s).x0 = (v)
97
#define mouse_def_y0(s,v)       (s).y0 = (v)
98
#define mouse_def_z0(s,v)       (s).y0 = (v)
523 mauro 99
 
519 mauro 100
/* user mouse handler */
101
typedef void (*MOUSE_HANDLER)(MOUSE_EVT*);
102
 
523 mauro 103
/*
104
 * user mouse interface
105
 */
549 mauro 106
int  MOUSE26_installed(void);
523 mauro 107
int  MOUSE26_init(MOUSE_PARMS *s);
108
int  MOUSE26_close(void);
109
 
110
void mouse_enable(void);
111
void mouse_disable(void);
549 mauro 112
void mouse_getposition(int *x, int *y, int *z, unsigned long *buttons);
113
void mouse_setposition(int  x, int  y, int z);
114
void mouse_getlimits(int *xmin, int *ymin, int *xmax, int *ymax);
115
int  mouse_setlimits(int  xmin, int  ymin, int  xmax, int  ymax);
523 mauro 116
int  mouse_getthreshold(void);
117
int  mouse_setthreshold(int t);
118
void mouse_hook(MOUSE_HANDLER h);
519 mauro 119
 
538 mauro 120
 
121
/*
122
 *
123
 * mouse autocursor management
124
 *
125
 */
126
 
127
/* commands for mouse_grxcursor() & mouse_txtcursor() */
128
#define DISABLE   0x00
129
#define ENABLE    0x01
130
 
131
/* flags for mouse_grxcursor() & mouse_txtcursor() (to use with '|') */
132
#define WITHOUTSEM 0x10
133
#define AUTOOFF    0x20
134
 
135
/* mask to extrac the status from autocursormode */
136
#define STATUSMASK 0x0f
137
 
138
/* flags for autocursormode (there are some other flags into mouse.h) */
139
#define GRXCURSOR 0x100
140
#define TXTCURSOR 0x200
141
 
142
/* dimensions of the grx shape */
143
#define MOUSESHAPEDX 16
144
#define MOUSESHAPEDY 16
145
 
146
/* hot-spot of the grx image (coordinates of the center's shape, zero-based) */
147
#define MOUSEHOTSPOTX 3
148
#define MOUSEHOTSPOTY 1
149
 
150
/* those macros can be used to set the correct mouse_limit() when
151
 * the graphics autocursor is enable (to avoid wrong shape position because
152
 * there is not graphics clip functions)
153
 */
154
#define XMINLIMIT(dimx,dimy) (MOUSEHOTSPOTX)
155
#define XMAXLIMIT(dimx,dimy) ((dimx)-MOUSESHAPEDX+MOUSEHOTSPOTX)
156
#define YMINLIMIT(dimx,dimy) (MOUSEHOTSPOTY)
157
#define YMAXLIMIT(dimx,dimy) ((dimy)-MOUSESHAPEDY+MOUSEHOTSPOTY)
158
 
549 mauro 159
#define mouse_grxlimits(dimx,dimy) mouse_setlimits(\
538 mauro 160
        XMINLIMIT(dimx,dimy), \
161
        YMINLIMIT(dimx,dimy), \
162
        XMAXLIMIT(dimx,dimy), \
163
        YMAXLIMIT(dimx,dimy)  \
164
)
165
 
166
/* these are used to select the mouse shape */
167
int mouse_txtshape(DWORD img);
168
int mouse_grxshape(BYTE *shape, BYTE *mask, int bpp_in);
169
 
170
/* enable/disable mouse pointer */
171
/* (return <0 on error) */
172
/* (for the cmd parameter see above) */
173
int mouse_grxcursor(int cmd, int bpp);
174
int mouse_txtcursor(int cmd);
175
 
176
/* mouse on/off (or show/hide) */
177
void (*mouse_on)(void);
178
void (*mouse_off)(void);
179
 
523 mauro 180
#ifdef __cplusplus
181
};
519 mauro 182
#endif
183
 
523 mauro 184
#endif
185