+++ /dev/null
-\r
-#include "core.h"\r
-\r
-uint offset_data_m;\r
-DATA_FIFO *sendto_m;\r
-UI_MouseInfo *decode_m;\r
-\r
-uchar mcursor_pattern0[24][24] = {\r
- ".**.....................",\r
- "*O**....................",\r
- "*OO**...................",\r
- "*OOO**..................",\r
- "*OOOO**.................",\r
- "*OOOOO**................",\r
- "*OOOOOO**...............",\r
- "*OOOOOOO**..............",\r
- "*OOOOOOOO**.............",\r
- "*OOOOOOOOO**............",\r
- "*OOOOOOOOOO**...........",\r
- "*OOOOOOOOOOO**..........",\r
- "*OOOOOOOOOOOO**.........",\r
- "*OOOOOOOOOOOOO**........",\r
- "*OOOOOOOOOOOOOO**.......",\r
- "*OOOOOOOOOOOOOOO**......",\r
- "*OOOOOOOOOOOOOOOO**.....",\r
- "*OOOOOO*************....",\r
- "*OOOOO**................",\r
- "*OOOO**.................",\r
- "*OOO**..................",\r
- "*OO**...................",\r
- "*O**....................",\r
- "***.....................",\r
-};\r
-\r
-void Initialise_Mouse(DATA_FIFO *sendto, uint offset, UI_MouseInfo *decode)\r
-{\r
- sendto_m = sendto;\r
- offset_data_m = offset;\r
- decode_m = decode;\r
-Emergency_Out("Mouse Initialise Start");\r
- decode->phase = 0;\r
- Mouse_Send_Command(MOUSECMD_RESET);\r
-Emergency_Out("Mouse Send Command");\r
- System_GateDescriptor_Set(0x2c, (uint)asm_InterruptHandler2c, 0x02, AR_INTGATE32);\r
- IO_Out8(PIC1_IMR, IO_In8(PIC1_IMR) & 0xef);\r
-Emergency_Out("Mouse Set INT");\r
-\r
- return;\r
-}\r
-\r
-void InterruptHandler2c(int *esp)\r
-{\r
- int data;\r
-\r
- data = IO_In8(KEYB_DATA);\r
- IO_Out8(PIC1_OCW2, 0x64);\r
- IO_Out8(PIC0_OCW2, 0x62);\r
- FIFO32_Put(sendto_m, data + offset_data_m);\r
- return;\r
-}\r
-\r
-int Mouse_Decode(uint data)\r
-{\r
- switch (decode_m->phase){\r
- case 0:\r
- if(data == 0xfa){\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 1:\r
- if(data == 0xaa){\r
- Mouse_Send_Command(MOUSECMD_SET_SAMPLE_RATE);\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 2:\r
- if(data == 0xfa){\r
- Mouse_Send_Command(200);\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 3:\r
- if(data == 0xfa){\r
- Mouse_Send_Command(MOUSECMD_SET_SAMPLE_RATE);\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 4:\r
- if(data == 0xfa){\r
- Mouse_Send_Command(100);\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 5:\r
- if(data == 0xfa){\r
- Mouse_Send_Command(MOUSECMD_SET_SAMPLE_RATE);\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 6:\r
- if(data == 0xfa){\r
- Mouse_Send_Command(80);\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 7:\r
- if(data == 0xfa){\r
- Mouse_Send_Command(MOUSECMD_GET_DEVICE_ID);\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 8:\r
- if(data == 0xfa){\r
- break;\r
- }\r
- if(data == 0x00){\r
- decode_m->type = threebtn;\r
- Mouse_Send_Command(MOUSECMD_ENABLE_DATA_REPORTING);\r
- decode_m->phase = 10;\r
- } else if(data == 0x03){\r
- decode_m->type = threebtn_scroll;\r
- Mouse_Send_Command(MOUSECMD_ENABLE_DATA_REPORTING);\r
- decode_m->phase = 20;\r
- } else{\r
- Mouse_Send_Command(MOUSECMD_RESET);\r
- decode_m->phase = 0;\r
- }\r
- break;\r
-\r
- case 10:\r
- if(data == 0xfa){\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 11:\r
- if((data & 0xc8) == 0x08) {\r
- decode_m->buf[0] = data;\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 12:\r
- decode_m->buf[1] = data;\r
- decode_m->phase++;\r
- break;\r
- case 13:\r
- decode_m->buf[2] = data;\r
- decode_m->phase -= 2;\r
- decode_m->btn = decode_m->buf[0];\r
- decode_m->move.x = decode_m->buf[1];\r
- decode_m->move.y = decode_m->buf[2];\r
- if(decode_m->buf[0] & 0x10){\r
- decode_m->move.x |= 0xffffff00;\r
- }\r
- if(decode_m->buf[0] & 0x20){\r
- decode_m->move.y |= 0xffffff00;\r
- }\r
- decode_m->move.y = - decode_m->move.y;\r
- return 1;\r
-\r
- case 20:\r
- if(data == 0xfa){\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 21:\r
- if((data & 0xc8) == 0x08) {\r
- decode_m->buf[0] = data;\r
- decode_m->phase++;\r
- }\r
- break;\r
- case 22:\r
- decode_m->buf[1] = data;\r
- decode_m->phase++;\r
- break;\r
- case 23:\r
- decode_m->buf[2] = data;\r
- decode_m->btn = decode_m->buf[0];\r
- decode_m->move.x = decode_m->buf[1];\r
- decode_m->move.y = decode_m->buf[2];\r
- if(decode_m->buf[0] & 0x10){\r
- decode_m->move.x |= 0xffffff00;\r
- }\r
- if(decode_m->buf[0] & 0x20){\r
- decode_m->move.y |= 0xffffff00;\r
- }\r
- decode_m->move.y = - decode_m->move.y;\r
- decode_m->phase++;\r
- break;\r
- case 24:\r
- decode_m->phase -= 3;\r
- decode_m->buf[3] = data;\r
- decode_m->scroll = decode_m->buf[3] & 0x0f;\r
- if(decode_m->scroll & 0x08) {\r
- decode_m->scroll |= 0xfffffff0;\r
- }\r
- return 1;\r
- }\r
- return 0;\r
-}\r
-\r
-void Mouse_Send_Command(uint data)\r
-{\r
- Keyboard_Controller_Wait_SendReady();\r
- IO_Out8(PORT_KEYCMD, KEYCMD_SENDTO_MOUSE);\r
- Keyboard_Controller_Wait_SendReady();\r
- IO_Out8(KEYB_DATA, data);\r
- return;\r
-}\r
-\r
-void Mouse_Make_MouseCursor(UI_MouseCursor *cursor, int rangex0, int rangey0, int rangex1, int rangey1, uint height)\r
-{\r
- cursor->move_range0.x = rangex0;\r
- cursor->move_range0.y = rangey0;\r
- cursor->move_range1.x = rangex1;\r
- cursor->move_range1.y = rangey1;\r
- cursor->position.x = rangex0;\r
- cursor->position.y = rangey0;\r
- cursor->sheet = System_Sheet_Get(24, 24, 0, 0x000000FF);\r
- Mouse_Draw_MouseCursor(cursor, normal);\r
- Sheet_Show(cursor->sheet, cursor->position.x, cursor->position.y, height);\r
- return;\r
-}\r
-\r
-void Mouse_Draw_MouseCursor(UI_MouseCursor *cursor, mcursor_state state)\r
-{\r
- uint x, y;\r
- uchar *pattern;\r
-\r
- pattern = &mcursor_pattern0[0][0];\r
-\r
- if(state == normal){\r
- cursor->state = normal;\r
- } else if(state == wait){\r
- cursor->state = wait;\r
- }\r
-\r
- for (y = 0; y < 24; y++) {\r
- for (x = 0; x < 24; x++) {\r
- if (pattern[y * 24 + x] == '*') {\r
- Sheet_Draw_Point(cursor->sheet, 0x000000, x, y);\r
- }\r
- if (pattern[y * 24 + x] == 'O') {\r
- Sheet_Draw_Point(cursor->sheet, 0xFFFFFF, x, y);\r
- }\r
- if (pattern[y * 24 + x] == '.') {\r
- Sheet_Draw_Point(cursor->sheet, 0x0000FF, x, y);\r
- }\r
- }\r
- }\r
-\r
- return;\r
-}\r
-\r
-void Mouse_Move_Relative(UI_MouseCursor *cursor, int movex, int movey)\r
-{\r
- cursor->position.x += movex;\r
- cursor->position.y += movey;\r
-\r
- if(cursor->position.x < cursor->move_range0.x){\r
- cursor->position.x = cursor->move_range0.x;\r
- } else if(cursor->position.x > cursor->move_range1.x){\r
- cursor->position.x = cursor->move_range1.x;\r
- }\r
- if(cursor->position.y < cursor->move_range0.y){\r
- cursor->position.y = cursor->move_range0.y;\r
- } else if(cursor->position.y > cursor->move_range1.y){\r
- cursor->position.y = cursor->move_range1.y;\r
- }\r
-\r
- Sheet_Slide(cursor->sheet, cursor->position.x, cursor->position.y);\r
-\r
- return;\r
-}\r
-\r
-void Mouse_Move_Absolute(UI_MouseCursor *cursor, int px, int py)\r
-{\r
- cursor->position.x = px;\r
- cursor->position.y = py;\r
-\r
- if(cursor->position.x < cursor->move_range0.x){\r
- cursor->position.x = cursor->move_range0.x;\r
- } else if(cursor->position.x > cursor->move_range1.x){\r
- cursor->position.x = cursor->move_range1.x;\r
- }\r
- if(cursor->position.y < cursor->move_range0.y){\r
- cursor->position.y = cursor->move_range0.y;\r
- } else if(cursor->position.y > cursor->move_range1.y){\r
- cursor->position.y = cursor->move_range1.y;\r
- }\r
-\r
- Sheet_Slide(cursor->sheet, cursor->position.x, cursor->position.y);\r
-\r
- return;\r
-}\r