void init_mouse() { unsigned char _status; //unsigned char //Enable the auxiliary mouse device mouse_wait(1); outb(0x64, 0xA8); //Enable the interrupts mouse_wait(1); outb(0x64, 0x20); mouse_wait(0); _status=(inb(0x60) | 2); mouse_wait(1); outb(0x64, 0x60); mouse_wait(1); outb(0x60, _status); //Tell the mouse to use default settings mouse_write(0xF6); mouse_read(); //Acknowledge //Enable the mouse mouse_write(0xF4); mouse_read(); //Acknowledge //Setup the mouse handler //irq_install_handler(12, mouse_handler); // Firstly, register our keyboard callback. register_interrupt_handler(IRQ12, &mouse_callback); }
void mouseinit(void) { uchar statustemp; mouse_wait(1); outb(0x64, 0xa8); //激活鼠标接口 mouse_wait(1); //激活中断 outb(0x64, 0x20); mouse_wait(0); statustemp = (inb(0x60) | 2); mouse_wait(0); outb(0x64, 0x60); mouse_wait(1); outb(0x60, statustemp); mouse_write(0xf6); //设置鼠标为默认设置 mouse_read(); mouse_write(0xf3); //设置鼠标采样率 mouse_read(); mouse_write(10); mouse_read(); mouse_write(0xf4); mouse_read(); initlock(&mouselock, "mouse"); picenable(IRQ_MOUSE); ioapicenable(IRQ_MOUSE, 0); count = 0; lastclicktick = lastdowntick = -1000; }
void installmouse() { unsigned char _status; //unsigned char //Enable the auxiliary mouse device mouse_wait(1); outportb(0x64, 0xA8); //Enable the interrupts mouse_wait(1); outportb(0x64, 0x20); mouse_wait(0); _status=(inportb(0x60) | 2); mouse_wait(1); outportb(0x64, 0x60); mouse_wait(1); outportb(0x60, _status); //Tell the mouse to use default settings mouse_write(0xF6); mouse_read(); //Acknowledge //Enable the mouse mouse_write(0xF4); mouse_read(); //Acknowledge //set the handler,mousewrapper (in irqwrap.asm), IRQ12 setinterruptvector(0x2C,dex_idtbase,0x8E,mousewrapper,SYS_CODE_SEL); printf("MOUSE successfully installed!!!"); }
void mouse_install(){ unsigned char status; mouse_wait(1); outb(0xa8,0x64);//enable device mouse_wait(1); outb(0x20,0x64); mouse_wait(0); status=(inb(0x60)|2);//enable interrupt mouse_wait(1); outb(0x60,0x64); mouse_wait(1); outb(status,0x60); mouse_write(0xF6); mouse_read(); mouse_write(0xF4); mouse_read(); //vesa_draw_string(0,100,"mouse_install"); /*outb(0xa8,0x64); outb(0xd4,0x64); outb(0xf4,0x60); outb(0x60,0x64); outb(0x47,0x60);*/ outb(inb(0x21)&0xfb, 0x21); outb(inb(0xa1)&0xef, 0xa1); }
int mouse_handler() { int i; unsigned long data = 0; if (interrupts == 0) { for (i = 0; i < KBC_IO_MAX_TRIES; i++) { mouse_read(&data); if (data & BIT(3)) { p[0] = data; break; } } counter++; interrupts = 1; } else { mouse_read(&data); if (counter == 0 && data & BIT(3) == 0) { interrupts = 0; return 0; } p[counter++] = data; if (counter == 3) { interrupts = 0; print(p); } } return 0; }
void init() { printf("moused: init\n"); uint8 _status; //unsigned char //Enable the auxiliary mouse device mouse_wait(1); outb(0x64, 0xA8); //Enable the interrupts mouse_wait(1); outb(0x64, 0x20); mouse_wait(0); _status=(inb(0x60) | 2); mouse_wait(1); outb(0x64, 0x60); mouse_wait(1); outb(0x60, _status); //Tell the mouse to use default settings mouse_write(0xF6); mouse_read(); //Acknowledge //Enable the mouse mouse_write(0xF4); mouse_read(); //Acknowledge }
int test_config(void) { printf("\n\tTouch in the mouse\n\n"); unsigned long data, res; unsigned char a[3]; mouse_subscribe(); mouse_write(MOUSE_STATUS); mouse_read(&data); while (1) { mouse_read(&data); if ((BIT(7) & data) && (BIT(3) & res)) break; } a[0] = data; while (1) { mouse_read(&data); if (data <= 3) break; } a[1] = data; tickdelay(micros_to_ticks(DELAY_US)); if (mouse_read(&data) != 0) return -1; a[2] = data; printf("\n\tCONFIGURATION\n"); printf( "\tMode: %s\n\tEnable: %d\n\tScaling: %s\n\tLB: %d\n\tMB: %d\n\tRB: %d\n\tResolution: %d count/mm\n\tSample Rate: %d\n", MODE(a[0]) ? "Remote" : "Stream", ENABLE(a[0]), SCALING(a[0]) ? "1:1" : "2:1", LEFT(a[0]), MIDDLE(a[0]), RIGHT(a[0]), RESOLUTION(a[1]), RATE(a[2])); mouse_unsubscribe(); printf("\n\tpress ANY KEY to continue\n"); mouse_read(&res); /* clear out buffer */ }
int gesture_handler(){ unsigned long byte; if(counter == 0){ byte = mouse_read(); if(byte & BIT(3)){ packet[0] = byte; counter++; } return 0; } else{ byte = mouse_read(); packet[counter] = byte; counter++; if(counter == 3){ counter = 0; packet_sum(); if(LENGTH >0){ if(X > LENGTH){ return 1; } } else{ if(X< LENGTH){ return 1; } } } return 0; } return 1; }
void mouse_install() { byte _status; //unsigned char //Enable the auxiliary mouse device mouse_wait(1); outportb(0x64, 0xA8); //Enable the interrupts mouse_wait(1); outportb(0x64, 0x20); mouse_wait(0); _status=(inportb(0x60) | 2); mouse_wait(1); outportb(0x64, 0x60); mouse_wait(1); outportb(0x60, _status); //Tell the mouse to use default settings mouse_write(0xF6); mouse_read(); //Acknowledge //Enable the mouse mouse_write(0xF4); mouse_read(); //Acknowledge //Setup the mouse handler irq_install_handler(12, mouse_handler); }
int test_gesture(short length, unsigned short tolerance) { int ipc_status; message msg; int receive; int validation = 1; sumOfX = 0; int irq_set = mouse_subscribe(); unsigned long clean; counter = 0; interrupts = 0; while (validation) { receive = driver_receive(ANY, &msg, &ipc_status); if (receive != 0) { printf("driver_receive failed with: %d", receive); continue; } if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: if (msg.NOTIFY_ARG & irq_set) { validation = gesture_handler(length, tolerance); } break; default: break; } } else { } } mouse_unsubscribe(); printf("\n\tpress ANY KEY to continue\n"); mouse_read(&clean); //Clean the buffer return 0; }
int test_packet(unsigned short cnt) { int i = 0; int ipc_status; message msg; int receive; int irq_set = mouse_subscribe(); unsigned long clean; counter = 0; interrupts = 0; while (i < cnt * 3) { receive = driver_receive(ANY, &msg, &ipc_status); if (receive != 0) { printf("driver_receive failed with: %d", receive); continue; } if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: if (msg.NOTIFY_ARG & irq_set) { mouse_handler(); i++; } break; default: break; } } else { } } mouse_unsubscribe(); printf("\n\tpress ANY KEY to continue\n"); mouse_read(&clean); //Clean the buffer return 0; }
int test_config(void) { unsigned long byte; subscribe_mouse(); mouse_write_byte(DISABLE_DATA_PACKETS); mouse_write_byte(STATUS_REQUEST); byte = mouse_read(); if(byte == -1) return 1; printf("byte 1: 0x%X\n", byte); printf("Scaling: "); if(!SCALING(byte)) printf("1:1 "); else printf("2:1 "); printf("Data Reporting: "); if(!DATA_REPORTING(byte)) printf("disable "); else printf("enable "); printf("Mode: "); if(!MODE(byte)) printf("remote mode\n\n"); else printf("stream mode\n\n"); if(LB(byte)) printf("LB: pressed "); else printf("LB: not pressed "); if(RB(byte)) printf("RB: pressed "); else printf("RB: not pressed "); if(MB(byte)) printf("MB: pressed "); else printf("MB: not pressed "); byte = mouse_read(); if(byte == -1) return 1; printf("\n byte 2: 0x%X\n", byte); printf("Resolution: %d\n\n", byte); byte = mouse_read(); if(byte == -1) return 1; printf("byte 3: 0x%X\n", byte); printf("Sample Rate: %d\n\n", byte); }
void mouse_init() { mouse_wait(1); outb(MOUSE_CMD, ENABLE_AUX_PS2); mouse_wait(1); outb(MOUSE_CMD, GET_COMPAQ_STATUS); uint8_t status = mouse_read() | 2; // Enable IRQ12 mouse_wait(1); outb(MOUSE_CMD, SET_COMPAQ_STATUS); mouse_wait(0); outb(MOUSE_DATA, status); mouse_write(USE_DEFAULTS); mouse_read(); // Waits for ACK mouse_write(ENABLE_MOUSE); mouse_read(); }
void handlerMouse() { unsigned long data; mouse_read(&data); mouse->packet[mouse->counter] = data; if (mouse->counter == 0 && !(BIT(3) & mouse->packet[0])) return; mouse->counter = (mouse->counter + 1) % 3; mouse->interrupts++; if (mouse->counter != 0) return; updateMouse(); }
void mouse_init() { printf(LNG_MOUSE_SETUP); mouse_waitcmd(1); outportb(0x64,0xA8); mouse_waitcmd(1); outportb(0x64,0x20); unsigned char status_byte; mouse_waitcmd(0); status_byte = (inportb(0x60) | 2); mouse_waitcmd(1); outportb(0x64, 0x60); mouse_waitcmd(1); outportb(0x60, status_byte); mouse_write (0xF6); mouse_read(); mouse_write (0xF4); mouse_read(); add_IRQ_handler(12, mouse_IRQhandler); enable_IRQ(12); _kprintOK(); }
void mouse_install() { debug_print(NOTICE, "Initializing PS/2 mouse interface"); uint8_t status; IRQ_OFF; mouse_pipe = make_pipe(sizeof(mouse_device_packet_t) * PACKETS_IN_PIPE); mouse_wait(1); outportb(MOUSE_STATUS, 0xA8); mouse_wait(1); outportb(MOUSE_STATUS, 0x20); mouse_wait(0); status = inportb(0x60) | 2; mouse_wait(1); outportb(MOUSE_STATUS, 0x60); mouse_wait(1); outportb(MOUSE_PORT, status); mouse_write(0xF6); mouse_read(); mouse_write(0xF4); mouse_read(); IRQ_RES; irq_install_handler(MOUSE_IRQ, mouse_handler); }
static bool cm_check( MOUSESTAT *status, MOUSEORD *row, MOUSEORD *col, MOUSETIME *time ) /**************************************************************************************/ { struct mouse_event event; struct itimerspec timer; if( MouseInstalled ) { if( mouse_read( MouseCtrl, &event, 1, UIRemProxy, 0 ) > 0 ) { ScaledRow -= event.dy; if( ScaledRow < 0 ) ScaledRow = 0; if( ScaledRow > ( UIData->height - 1 ) * MOUSE_SCALE ) { ScaledRow = ( UIData->height - 1 ) * MOUSE_SCALE; } ScaledCol += event.dx; if( ScaledCol < 0 ) ScaledCol = 0; if( ScaledCol > ( UIData->width - 1 ) * MOUSE_SCALE ) { ScaledCol = ( UIData->width - 1 ) * MOUSE_SCALE; } MyStatus = 0; if( event.buttons & _MOUSE_LEFT ) MyStatus |= UI_MOUSE_PRESS; if( event.buttons & _MOUSE_MIDDLE ) MyStatus |= UI_MOUSE_PRESS_MIDDLE; if( event.buttons & _MOUSE_RIGHT ) MyStatus |= UI_MOUSE_PRESS_RIGHT; timer.it_value.tv_sec = 0; timer.it_value.tv_nsec = 0; } else if( (MyStatus & UI_MOUSE_PRESS_ANY) == 0 ) { timer.it_value.tv_sec = 0; timer.it_value.tv_nsec = 0; } else { timer.it_value.tv_sec = 0; timer.it_value.tv_nsec = UIData->mouse_rpt_delay * 1000000UL; if( timer.it_value.tv_nsec == 0 ) { timer.it_value.tv_nsec = 1; } } timer.it_interval.tv_sec = 0; timer.it_interval.tv_nsec = 0; reltimer( MouseTimer, &timer, NULL ); *status = MyStatus; *time = uiclock(); *row = ScaledRow / MOUSE_SCALE; *col = ScaledCol / MOUSE_SCALE; } uisetmouse( *row, *col ); return( false ); }
int mouse_handler() { unsigned long byte; if(counter == 0){ byte = mouse_read(); if(byte & BIT(3)){ packet[0] = byte; counter++; } return 0; } else{ byte = mouse_read(); packet[counter] = byte; counter++; if(counter == 3){ counter = 0; time = 0; packet_print(); } return 0; } return 1; }
static int cm_stop( void ) /************************/ { struct itimerspec timer; if( MouseInstalled ) { timer.it_value.tv_sec = 0; timer.it_value.tv_nsec = 0; reltimer( MouseTimer, &timer, NULL ); mouse_read( MouseCtrl, NULL, 0, -1, 0 ); while( Creceive( UILocalProxy, 0, 0 ) > 0 ) {} } return( 0 ); }
static int mouse_cmd(int fd, unsigned char cmd) { int ret; DEBUG("mouse_cmd: %02x\n",cmd); ret = write(fd, &cmd, 1); if (ret != 1) { return -1; } ret = mouse_read(fd); if (ret == MOUSE_RESP_ACK) return 0; else return -1; }
void IOOUTCALL sio_o(UINT port, REG8 value) { switch(port) { case 0x1f90: /* CH-A データ */ if (sio.ch[SIOCH_A].wr[3] & 0x08) { fifo_w(&sio.ch[SIOCH_A].TxD, value, 0); } break; case 0x1f91: /* CH-A コントロール */ sio.ch[SIOCH_A].wr[sio.ch[SIOCH_A].num] = value; if (sio.ch[SIOCH_A].num) { sio.ch[SIOCH_A].num = 0; } else if (value & 0xf1) { sio.ch[SIOCH_A].num = (value & 7); } break; #if 0 case 0x1f92: /* CH-B データ (Mouse) */ if (CH_B.wr[3] & 0x08) { fifo_w(&CH_B.T_D, value, 0); } break; #endif case 0x1f93: /* CH-B コントロール (Mouse) */ if (sio.ch[SIOCH_B].num == 5) { /* RTS(WR5:BIT1)を0から1へ変化させると */ /* マウスから3バイトのデータが送られてくる */ if (!(sio.ch[SIOCH_B].wr[5] & 2) && (value & 2)) { mouse_read(sio.ch + SIOCH_B); } } sio.ch[SIOCH_B].wr[sio.ch[SIOCH_B].num] = value; if (sio.ch[SIOCH_B].num) { sio.ch[SIOCH_B].num = 0; } else { sio.ch[SIOCH_B].num = value & 7; } break; } }
int test_async(unsigned short idle_time) { int ipc_status; message msg; int time = 0; int receive; unsigned long clean; int irq_set_mouse = mouse_subscribe(); int irq_set_timer = timer_subscribe_int(); counter = 0; interrupts = 0; while (time < idle_time * 60) { receive = driver_receive(ANY, &msg, &ipc_status); if (receive != 0) { printf("driver_receive failed with: %d", receive); continue; } if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: if (msg.NOTIFY_ARG & irq_set_mouse) { mouse_handler(); time = 0; } if (msg.NOTIFY_ARG & irq_set_timer) { time++; } break; default: break; } } else { } } mouse_unsubscribe(); timer_unsubscribe_int(); printf("\n\tpress ANY KEY to continue\n"); mouse_read(&clean); return 0; }
static void test_keyboard() { s32 k_x = 60, k_y = 80; while (TRUE) { if (get_tick_count() % 10) io_halt(); mouse_read(); u32 key = 0; keyboard_read(&key); if (key == 0 || KEY_TYPE(key) != KT_ASCII) continue; draw_asc16((char)key, k_x, k_y, color); k_x += 8; if (k_x + 100 > 1000) { k_x = 60; k_y += 20; } } }
int mouse_get_status(unsigned num_tries, mouse_status_packet_t *mouse_status_packet) { if (mouse_write(num_tries, MOUSE_STATUS_REQUEST)) { return 1; } size_t i; for (i = 0; i < MOUSE_STATUS_SIZE; ++i) { if (mouse_read(num_tries, &mouse_status_packet->bytes[i])) { return 1; } } mouse_status_packet->remote_mode = mouse_status_packet->bytes[0] & BIT(MOUSE_STATUS_REMOTE_MODE_BIT); mouse_status_packet->enabled = mouse_status_packet->bytes[0] & BIT(MOUSE_STATUS_ENABLED_BIT); mouse_status_packet->scaling_2_1 = mouse_status_packet->bytes[0] & BIT(MOUSE_STATUS_SCALING_2_1_BIT); mouse_status_packet->left_button = mouse_status_packet->bytes[0] & BIT(MOUSE_STATUS_LEFT_BTN_BIT); mouse_status_packet->middle_button = mouse_status_packet->bytes[0] & BIT(MOUSE_STATUS_MIDDLE_BTN_BIT); mouse_status_packet->right_button = mouse_status_packet->bytes[0] & BIT(MOUSE_STATUS_RIGHT_BTN_BIT); mouse_status_packet->resolution = mouse_status_packet->bytes[1]; mouse_status_packet->sample_rate = mouse_status_packet->bytes[2]; return 0; }
int psauxProbe(char* devclass, char *driver, char *desc) { /* #ifdef TESTING_MOUSE int d = 0; d = probe_qp(); printf("%d\n",d); return 0; #endif */ int portfd, ret; for (ret=0; ret < sizeof(mouse_devices)/sizeof(mouse_devices[0]); ret++) { strcpy(devclass, mouse_devices[ret]); if ((portfd=open(devclass, O_RDWR | O_NONBLOCK)) > 0) { ret = 0; break; } } if (ret) { DEBUG("error opening mouse port.\n"); return 0; } mouse_cmd(portfd, MOUSE_CMD_RESET); if ((ret = mouse_read(portfd)) != MOUSE_RESP_TESTOK) DEBUG("Mouse self-test failed.\n"); if ((ret = mouse_read(portfd)) != 0x00) DEBUG("Mouse did not finish reset response.\n"); mouse_cmd(portfd, MOUSE_CMD_ENABLE); if (mouse_cmd(portfd, MOUSE_CMD_GET_DEVICE_ID)) { DEBUG("mouse device id command failed: no mouse\n"); ret = 0; goto out; } ret = mouse_read(portfd); DEBUG("got mouse type %02x\n",ret); if (-1 == ret) { DEBUG("Failed to read initial mouse type\n"); ret = 0; goto out; } /* attempt to enable IntelliMouse 3-button mode */ DEBUG("Attempting to enable IntelliMouse 3-button mode\n"); mouse_cmd(portfd, MOUSE_CMD_SET_SAMPLE_RATE); mouse_cmd(portfd, 0xc8); mouse_cmd(portfd, MOUSE_CMD_SET_SAMPLE_RATE); mouse_cmd(portfd, 0x64); mouse_cmd(portfd, MOUSE_CMD_SET_SAMPLE_RATE); mouse_cmd(portfd, 0x50); /* now issue get device id command */ mouse_cmd(portfd, MOUSE_CMD_GET_DEVICE_ID); ret = mouse_read(portfd); DEBUG("Device ID after IntelliMouse initialization: %02x\n", ret); if (0x03 == ret) { /* attempt to enable IntelliMouse 5-button mode */ DEBUG("Attempting to enable IntelliMouse 5-button mode\n"); mouse_cmd(portfd, MOUSE_CMD_SET_SAMPLE_RATE); mouse_cmd(portfd, 0xc8); mouse_cmd(portfd, MOUSE_CMD_SET_SAMPLE_RATE); mouse_cmd(portfd, 0xc8); mouse_cmd(portfd, MOUSE_CMD_SET_SAMPLE_RATE); mouse_cmd(portfd, 0x50); /* now issue get device id command */ mouse_cmd(portfd, MOUSE_CMD_GET_DEVICE_ID); ret = mouse_read(portfd); DEBUG("Device ID after IntelliMouse 5 button initialization: %02x\n", ret); } //ps2dev->device=strdup("psaux"); //ps2dev->type=CLASS_MOUSE; /* ### generic - 2-button serial ### genericps/2 - 2-button ps/2 ### msintellips/2 - MS Intellimouse ### generic3ps/2 - 3 button ps/2 */ switch (ret) { case 0x03: case 0x04: case 0x05: strcpy(driver,"msintellips/2"); strcpy(desc,"Generic PS/2 Wheel Mouse"); break; case 0x02: /* a ballpoint something or other */ case 0x06: /* A4 Tech 4D Mouse ? */ case 0x08: /* A4 Tech 4D+ Mouse ? */ case 0x00: default: DEBUG("mouse type: %x\n",ret); strcpy(driver,"genericps/2"); strcpy(desc,"Generic Mouse (PS/2)"); break; } ret = 1; out: DEBUG("resetting mouse\n"); mouse_cmd(portfd, MOUSE_CMD_RESET); if (mouse_read(portfd) != MOUSE_RESP_TESTOK) DEBUG("Mouse self-test failed.\n"); if (mouse_read(portfd) != 0x00) DEBUG("Mouse did not finish reset response.\n"); if (mouse_cmd(portfd, MOUSE_CMD_ENABLE)) { DEBUG("mouse enable failed: no mouse?\n"); } if (mouse_cmd(portfd, MOUSE_CMD_GET_DEVICE_ID)) { DEBUG("mouse type command failed: no mouse\n"); } if (0x00 != mouse_read(portfd)) { DEBUG("initial mouse type check strange: no mouse\n"); } close(portfd); return ret; }
int gesture_handler(short length, unsigned short tolerance) { unsigned long data = 0; short auxX, auxY; if (interrupts == 0) { while (1) { mouse_read(&data); if (data & BIT(3)) { p[0] = data; break; } } counter++; interrupts = 1; } else { mouse_read(&data); if (counter == 0 && data & BIT(3) == 0) { interrupts = 0; return -1; } p[counter++] = data; if (counter == 3) { interrupts = 0; counter = 0; //prints printf("sumX: %d left: %d ", sumOfX, LEFT_B(p[0])); if (Y_NEGATIVE(p[2])) { auxY = p[2] | 0xFF00; } else { auxY = p[2]; } printf("Y=%d ", auxY); if (X_NEGATIVE(p[1])) { auxX = p[1] | 0xFF00; } else { auxX = p[1]; } printf("X=%d \n \n", auxX); // Y += abs(auxY); if (Y < tolerance && LEFT_B(p[0])) { sumOfX += auxX; if (length > 0){ if (auxX < 0) sumOfX = 0; if (sumOfX >= length) return 0; } else { if (auxX > 0) sumOfX = 0; if (sumOfX < length) return 0; } } if (Y > tolerance || !LEFT_B(p[0])) { sumOfX = 0; Y = 0; return -1; } } return -1; } }
int test_async(unsigned short idle_time) { int conta = 0, ind = 0, r, ipc_status, conta_timer = 0, fim = 0; unsigned long irq_set_mouse, irq_set_timer; char cmd, packet[3]; int tmp = 60 * idle_time; message msg; if ((irq_set_timer = timer_subscribe_int()) == -1) { printf("Unable to subscribe timer!\n"); return 1; } if ((irq_set_mouse = mouse_subscribe()) == -1) { printf("Unable to subscribe mouse!\n"); return 1; } if (sys_outb(STAT_REG, 0xA8) != OK) //rato enable printf("Error\n"); if (sys_outb(STAT_REG, W_TO_MOUSE) != OK) printf("Error-MC\n"); if (sys_outb(OUT_BUF, ENABLE_SEND) != OK) printf("Error-SEND\n"); // Enable Sending Data Packets while (fim == 0) { if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) { printf("driver_receive failed with: %d", r); continue; } if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: if (msg.NOTIFY_ARG & irq_set_mouse) { conta_timer = 0; cmd = mouse_read(); switch (ind) { case 0: if (cmd & BIT(3)) packet[0] = cmd; ind++; break; case 1: packet[1] = cmd; ind++; break; case 2: packet[2] = cmd; conta++; ind = 0; mouse_print(packet); break; } } if (msg.NOTIFY_ARG & irq_set_timer) { conta_timer++; if (conta_timer >= tmp) { fim = 1; } } break; default: break; } } else { } } printf("Acabou o tempo de espera!\n"); if (sys_outb(STAT_REG, W_TO_MOUSE) != OK) printf("ERROR-MC"); if (sys_outb(OUT_BUF, DISABLE_STREAM) != OK) printf("ERROR-DISABLE_STREAM"); if (mouse_unsubscribe() == -1) printf("falhou unsubscribe mouse!\n"); if (timer_unsubscribe_int() == -1) printf("Falhou unsubscribe timer!\n"); return 0; }