Rev 538 | Rev 549 | 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; |
||
58 | int xmin; |
||
59 | int ymin; |
||
60 | int xmax; |
||
61 | int ymax; |
||
62 | int threshold; |
||
63 | } MOUSE_PARMS; |
||
64 | |||
65 | #define MOUSE_DEFAULT (DWORD)-1 |
||
66 | |||
67 | /* the default values for the MOUSE_PARMS structure */ |
||
68 | #define BASE_MOUSE {(TASK_MODEL *)MOUSE_DEFAULT, \ |
||
69 | (int)MOUSE_DEFAULT, \ |
||
70 | (int)MOUSE_DEFAULT, \ |
||
71 | (int)MOUSE_DEFAULT, \ |
||
72 | (int)MOUSE_DEFAULT, \ |
||
73 | (int)MOUSE_DEFAULT} |
||
74 | |||
75 | /* to change the MOUSE_PARMS struct */ |
||
76 | #define mouse_default_parms(s) (s).tm = (TASK_MODEL *)MOUSE_DEFAULT, \ |
||
77 | (s).xmin = (int)MOUSE_DEFAULT, \ |
||
78 | (s).xmin = (int)MOUSE_DEFAULT, \ |
||
79 | (s).xmin = (int)MOUSE_DEFAULT, \ |
||
80 | (s).xmin = (int)MOUSE_DEFAULT, \ |
||
81 | (s).xmin = (int)MOUSE_DEFAULT |
||
82 | |||
83 | #define mouse_def_task(s,m) (s).tm = (TASK_MODEL *)(m) |
||
84 | #define mouse_def_thresh(s,v) (s).threshold = (v) |
||
85 | #define mouse_def_xmin(s,v) (s).xmin = (v) |
||
86 | #define mouse_def_ymin(s,v) (s).ymin = (v) |
||
87 | #define mouse_def_xmax(s,v) (s).xmax = (v) |
||
88 | #define mouse_def_ymax(s,v) (s).ymax = (v) |
||
89 | |||
519 | mauro | 90 | /* user mouse handler */ |
91 | typedef void (*MOUSE_HANDLER)(MOUSE_EVT*); |
||
92 | |||
523 | mauro | 93 | /* |
94 | * user mouse interface |
||
95 | */ |
||
96 | int MOUSE26_init(MOUSE_PARMS *s); |
||
97 | int MOUSE26_close(void); |
||
98 | |||
99 | void mouse_enable(void); |
||
100 | void mouse_disable(void); |
||
101 | void mouse_getpos(int *x, int *y, int *z, unsigned long *buttons); |
||
102 | void mouse_setpos(int x, int y, int z); |
||
103 | void mouse_getlimit(int *xmin, int *ymin, int *xmax, int *ymax); |
||
104 | int mouse_setlimit(int xmin, int ymin, int xmax, int ymax); |
||
105 | int mouse_getthreshold(void); |
||
106 | int mouse_setthreshold(int t); |
||
107 | void mouse_hook(MOUSE_HANDLER h); |
||
519 | mauro | 108 | |
538 | mauro | 109 | |
110 | /* |
||
111 | * |
||
112 | * mouse autocursor management |
||
113 | * |
||
114 | */ |
||
115 | |||
116 | /* commands for mouse_grxcursor() & mouse_txtcursor() */ |
||
117 | #define DISABLE 0x00 |
||
118 | #define ENABLE 0x01 |
||
119 | |||
120 | /* flags for mouse_grxcursor() & mouse_txtcursor() (to use with '|') */ |
||
121 | #define WITHOUTSEM 0x10 |
||
122 | #define AUTOOFF 0x20 |
||
123 | |||
124 | /* mask to extrac the status from autocursormode */ |
||
125 | #define STATUSMASK 0x0f |
||
126 | |||
127 | /* flags for autocursormode (there are some other flags into mouse.h) */ |
||
128 | #define GRXCURSOR 0x100 |
||
129 | #define TXTCURSOR 0x200 |
||
130 | |||
131 | /* dimensions of the grx shape */ |
||
132 | #define MOUSESHAPEDX 16 |
||
133 | #define MOUSESHAPEDY 16 |
||
134 | |||
135 | /* hot-spot of the grx image (coordinates of the center's shape, zero-based) */ |
||
136 | #define MOUSEHOTSPOTX 3 |
||
137 | #define MOUSEHOTSPOTY 1 |
||
138 | |||
139 | /* those macros can be used to set the correct mouse_limit() when |
||
140 | * the graphics autocursor is enable (to avoid wrong shape position because |
||
141 | * there is not graphics clip functions) |
||
142 | */ |
||
143 | #define XMINLIMIT(dimx,dimy) (MOUSEHOTSPOTX) |
||
144 | #define XMAXLIMIT(dimx,dimy) ((dimx)-MOUSESHAPEDX+MOUSEHOTSPOTX) |
||
145 | #define YMINLIMIT(dimx,dimy) (MOUSEHOTSPOTY) |
||
146 | #define YMAXLIMIT(dimx,dimy) ((dimy)-MOUSESHAPEDY+MOUSEHOTSPOTY) |
||
147 | |||
148 | #define mouse_grxlimit(dimx,dimy) mouse_limit(\ |
||
149 | XMINLIMIT(dimx,dimy), \ |
||
150 | YMINLIMIT(dimx,dimy), \ |
||
151 | XMAXLIMIT(dimx,dimy), \ |
||
152 | YMAXLIMIT(dimx,dimy) \ |
||
153 | ) |
||
154 | |||
155 | /* these are used to select the mouse shape */ |
||
156 | int mouse_txtshape(DWORD img); |
||
157 | int mouse_grxshape(BYTE *shape, BYTE *mask, int bpp_in); |
||
158 | |||
159 | /* enable/disable mouse pointer */ |
||
160 | /* (return <0 on error) */ |
||
161 | /* (for the cmd parameter see above) */ |
||
162 | int mouse_grxcursor(int cmd, int bpp); |
||
163 | int mouse_txtcursor(int cmd); |
||
164 | |||
165 | /* mouse on/off (or show/hide) */ |
||
166 | void (*mouse_on)(void); |
||
167 | void (*mouse_off)(void); |
||
168 | |||
523 | mauro | 169 | #ifdef __cplusplus |
170 | }; |
||
519 | mauro | 171 | #endif |
172 | |||
523 | mauro | 173 | #endif |
174 |