mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-03 01:53:24 +08:00
鼠标解读(1)
This commit is contained in:
@@ -11,6 +11,7 @@ void HariMain(void)
|
||||
{
|
||||
struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
|
||||
char s[40], mcursor[256], keybuf[32], mousebuf[128];
|
||||
unsigned char mouse_dbuf[3], mouse_phase;
|
||||
int mx, my, i;
|
||||
|
||||
init_gdtidt();
|
||||
@@ -34,6 +35,7 @@ void HariMain(void)
|
||||
putfonts8_asc(binfo->vram, binfo->scrnx, 0, 0, COL8_FFFFFF, s);
|
||||
|
||||
enable_mouse();
|
||||
mouse_phase = 0; /* 进入到等待鼠标的0xfa的状态 */
|
||||
|
||||
for (;;) {
|
||||
io_cli();
|
||||
@@ -49,10 +51,29 @@ void HariMain(void)
|
||||
} else if (fifo8_status(&mousefifo) != 0) {
|
||||
i = fifo8_get(&mousefifo);
|
||||
io_sti();
|
||||
sprintf(s, "%02X", i);
|
||||
boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 32, 16, 47, 31);
|
||||
putfonts8_asc(binfo->vram, binfo->scrnx, 32, 16, COL8_FFFFFF, s);
|
||||
}
|
||||
if (mouse_phase == 0) {
|
||||
/* 等待鼠标的0xfa的状态 */
|
||||
if (i == 0xfa) {
|
||||
mouse_phase = 1;
|
||||
}
|
||||
} else if (mouse_phase == 1) {
|
||||
/* 等待鼠标的第一字节 */
|
||||
mouse_dbuf[0] = i;
|
||||
mouse_phase = 2;
|
||||
} else if (mouse_phase == 2) {
|
||||
/* 等待鼠标的第二字节 */
|
||||
mouse_dbuf[1] = i;
|
||||
mouse_phase = 3;
|
||||
} else if (mouse_phase == 3) {
|
||||
/* 等待鼠标的第三字节 */
|
||||
mouse_dbuf[2] = i;
|
||||
mouse_phase = 1;
|
||||
/* 鼠标的3个字节都齐了,显示出来 */
|
||||
sprintf(s, "%02X %02X %02X", mouse_dbuf[0], mouse_dbuf[1], mouse_dbuf[2]);
|
||||
boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 32, 16, 32 + 8 * 8 - 1, 31);
|
||||
putfonts8_asc(binfo->vram, binfo->scrnx, 32, 16, COL8_FFFFFF, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user