6 UI_MouseInfo *decode_m;
\r
8 uchar mcursor_pattern0[24][24] = {
\r
9 ".**.....................",
\r
10 "*O**....................",
\r
11 "*OO**...................",
\r
12 "*OOO**..................",
\r
13 "*OOOO**.................",
\r
14 "*OOOOO**................",
\r
15 "*OOOOOO**...............",
\r
16 "*OOOOOOO**..............",
\r
17 "*OOOOOOOO**.............",
\r
18 "*OOOOOOOOO**............",
\r
19 "*OOOOOOOOOO**...........",
\r
20 "*OOOOOOOOOOO**..........",
\r
21 "*OOOOOOOOOOOO**.........",
\r
22 "*OOOOOOOOOOOOO**........",
\r
23 "*OOOOOOOOOOOOOO**.......",
\r
24 "*OOOOOOOOOOOOOOO**......",
\r
25 "*OOOOOOOOOOOOOOOO**.....",
\r
26 "*OOOOOO*************....",
\r
27 "*OOOOO**................",
\r
28 "*OOOO**.................",
\r
29 "*OOO**..................",
\r
30 "*OO**...................",
\r
31 "*O**....................",
\r
32 "***.....................",
\r
35 void Initialise_Mouse(DATA_FIFO *sendto, uint offset, UI_MouseInfo *decode)
\r
38 offset_data_m = offset;
\r
40 Emergency_Out("Mouse Initialise Start");
\r
42 Mouse_Send_Command(MOUSECMD_RESET);
\r
43 Emergency_Out("Mouse Send Command");
\r
44 System_GateDescriptor_Set(0x2c, (uint)asm_InterruptHandler2c, 0x02, AR_INTGATE32);
\r
45 IO_Out8(PIC1_IMR, IO_In8(PIC1_IMR) & 0xef);
\r
46 Emergency_Out("Mouse Set INT");
\r
51 void InterruptHandler2c(int *esp)
\r
55 data = IO_In8(KEYB_DATA);
\r
56 IO_Out8(PIC1_OCW2, 0x64);
\r
57 IO_Out8(PIC0_OCW2, 0x62);
\r
58 FIFO32_Put(sendto_m, data + offset_data_m);
\r
62 int Mouse_Decode(uint data)
\r
64 switch (decode_m->phase){
\r
72 Mouse_Send_Command(MOUSECMD_SET_SAMPLE_RATE);
\r
78 Mouse_Send_Command(200);
\r
84 Mouse_Send_Command(MOUSECMD_SET_SAMPLE_RATE);
\r
90 Mouse_Send_Command(100);
\r
96 Mouse_Send_Command(MOUSECMD_SET_SAMPLE_RATE);
\r
102 Mouse_Send_Command(80);
\r
108 Mouse_Send_Command(MOUSECMD_GET_DEVICE_ID);
\r
117 decode_m->type = threebtn;
\r
118 Mouse_Send_Command(MOUSECMD_ENABLE_DATA_REPORTING);
\r
119 decode_m->phase = 10;
\r
120 } else if(data == 0x03){
\r
121 decode_m->type = threebtn_scroll;
\r
122 Mouse_Send_Command(MOUSECMD_ENABLE_DATA_REPORTING);
\r
123 decode_m->phase = 20;
\r
125 Mouse_Send_Command(MOUSECMD_RESET);
\r
126 decode_m->phase = 0;
\r
136 if((data & 0xc8) == 0x08) {
\r
137 decode_m->buf[0] = data;
\r
142 decode_m->buf[1] = data;
\r
146 decode_m->buf[2] = data;
\r
147 decode_m->phase -= 2;
\r
148 decode_m->btn = decode_m->buf[0];
\r
149 decode_m->move.x = decode_m->buf[1];
\r
150 decode_m->move.y = decode_m->buf[2];
\r
151 if(decode_m->buf[0] & 0x10){
\r
152 decode_m->move.x |= 0xffffff00;
\r
154 if(decode_m->buf[0] & 0x20){
\r
155 decode_m->move.y |= 0xffffff00;
\r
157 decode_m->move.y = - decode_m->move.y;
\r
166 if((data & 0xc8) == 0x08) {
\r
167 decode_m->buf[0] = data;
\r
172 decode_m->buf[1] = data;
\r
176 decode_m->buf[2] = data;
\r
177 decode_m->btn = decode_m->buf[0];
\r
178 decode_m->move.x = decode_m->buf[1];
\r
179 decode_m->move.y = decode_m->buf[2];
\r
180 if(decode_m->buf[0] & 0x10){
\r
181 decode_m->move.x |= 0xffffff00;
\r
183 if(decode_m->buf[0] & 0x20){
\r
184 decode_m->move.y |= 0xffffff00;
\r
186 decode_m->move.y = - decode_m->move.y;
\r
190 decode_m->phase -= 3;
\r
191 decode_m->buf[3] = data;
\r
192 decode_m->scroll = decode_m->buf[3] & 0x0f;
\r
193 if(decode_m->scroll & 0x08) {
\r
194 decode_m->scroll |= 0xfffffff0;
\r
201 void Mouse_Send_Command(uint data)
\r
203 Keyboard_Controller_Wait_SendReady();
\r
204 IO_Out8(PORT_KEYCMD, KEYCMD_SENDTO_MOUSE);
\r
205 Keyboard_Controller_Wait_SendReady();
\r
206 IO_Out8(KEYB_DATA, data);
\r
210 void Mouse_Make_MouseCursor(UI_MouseCursor *cursor, int rangex0, int rangey0, int rangex1, int rangey1, uint height)
\r
212 cursor->move_range0.x = rangex0;
\r
213 cursor->move_range0.y = rangey0;
\r
214 cursor->move_range1.x = rangex1;
\r
215 cursor->move_range1.y = rangey1;
\r
216 cursor->position.x = rangex0;
\r
217 cursor->position.y = rangey0;
\r
218 cursor->sheet = System_Sheet_Get(24, 24, 0, 0x000000FF);
\r
219 Mouse_Draw_MouseCursor(cursor, normal);
\r
220 Sheet_Show(cursor->sheet, cursor->position.x, cursor->position.y, height);
\r
224 void Mouse_Draw_MouseCursor(UI_MouseCursor *cursor, mcursor_state state)
\r
229 pattern = &mcursor_pattern0[0][0];
\r
231 if(state == normal){
\r
232 cursor->state = normal;
\r
233 } else if(state == wait){
\r
234 cursor->state = wait;
\r
237 for (y = 0; y < 24; y++) {
\r
238 for (x = 0; x < 24; x++) {
\r
239 if (pattern[y * 24 + x] == '*') {
\r
240 Sheet_Draw_Point(cursor->sheet, 0x000000, x, y);
\r
242 if (pattern[y * 24 + x] == 'O') {
\r
243 Sheet_Draw_Point(cursor->sheet, 0xFFFFFF, x, y);
\r
245 if (pattern[y * 24 + x] == '.') {
\r
246 Sheet_Draw_Point(cursor->sheet, 0x0000FF, x, y);
\r
254 void Mouse_Move_Relative(UI_MouseCursor *cursor, int movex, int movey)
\r
256 cursor->position.x += movex;
\r
257 cursor->position.y += movey;
\r
259 if(cursor->position.x < cursor->move_range0.x){
\r
260 cursor->position.x = cursor->move_range0.x;
\r
261 } else if(cursor->position.x > cursor->move_range1.x){
\r
262 cursor->position.x = cursor->move_range1.x;
\r
264 if(cursor->position.y < cursor->move_range0.y){
\r
265 cursor->position.y = cursor->move_range0.y;
\r
266 } else if(cursor->position.y > cursor->move_range1.y){
\r
267 cursor->position.y = cursor->move_range1.y;
\r
270 Sheet_Slide(cursor->sheet, cursor->position.x, cursor->position.y);
\r
275 void Mouse_Move_Absolute(UI_MouseCursor *cursor, int px, int py)
\r
277 cursor->position.x = px;
\r
278 cursor->position.y = py;
\r
280 if(cursor->position.x < cursor->move_range0.x){
\r
281 cursor->position.x = cursor->move_range0.x;
\r
282 } else if(cursor->position.x > cursor->move_range1.x){
\r
283 cursor->position.x = cursor->move_range1.x;
\r
285 if(cursor->position.y < cursor->move_range0.y){
\r
286 cursor->position.y = cursor->move_range0.y;
\r
287 } else if(cursor->position.y > cursor->move_range1.y){
\r
288 cursor->position.y = cursor->move_range1.y;
\r
291 Sheet_Slide(cursor->sheet, cursor->position.x, cursor->position.y);
\r