int test_config(void) { unsigned long status; mouse_subscribe_int(); while (mouse_send_command(MOUSE_STATUS) != 0) { }; if (sys_inb(OUT_BUF, &status) == OK) { if (status & BIT(3) & BIT(0)) { printf("1:1 - Linear mode\n"); } else { printf("2:1 - Acceleration mode\n"); } if (status & BIT(5)) { printf("Info Report: ON\n "); } else { printf("Info Report: OFF\n "); } if (status & BIT(6)) { printf("remote: ON\n"); } else { printf("remote: OFF\n"); } sys_inb(OUT_BUF, &status); printf("X Delta: 0x%x\n", status); if (sys_inb(OUT_BUF, &status) == OK) { printf("Y Delta: 0x%x\n", status); } } mouse_unsubscribe_int(); return 0; }
int mouse_int_handler(unsigned long cmd){ int cmd_receive = 0; int cmd_receive2 = 0; int nr_tentativas = 0; while(1) { while(nr_tentativas < 5) { mouse_send_first_command(); /*cmd_receive = mouse_cmd_receive(); printf("done\n"); if(MOUSE_DATA == (MOUSE_DATA & cmd_receive)) { if (NACK == cmd_receive || ERROR == cmd_receive) { printf("cmd1\n"); nr_tentativas++; continue; } } else continue; */ break; } nr_tentativas = 0; while (nr_tentativas < 5) { mouse_send_command(cmd); cmd_receive2 = mouse_cmd_receive(); if(MOUSE_DATA == (MOUSE_DATA & cmd_receive2)) //verificar se o que estou a ler é do mouse { if (cmd_receive2 == NACK) // se e NACK, então repete só o cmd enviado, não necessita de enviar 0xD4 { nr_tentativas++; continue; } else break; } else continue; } if (cmd_receive2 == ERROR) //erro, volta a repetir todo o processo { continue; } break; } return 0; }