void _ps2_mouse_isr( int vec, int code ){ static int byte_c = 0; static char mouse_p = '+'; static char m_bytes[3]; // temp vars char button_change = 0; if(_init) m_bytes[byte_c++] = __inb(PS2_PORT); // Only dump information once we have everything the mouse sent if(byte_c == 3){ if( (m_bytes[0] & 0x80) || (m_bytes[0] & 0x40) ){ // overflow! throw away packet c_puts( "Mouse overflow!\n" ); } else{ // Check left-button status if( m_bytes[0] & 0x1 ){ if( _left_button != 1) //c_puts( "Left Button Pressed!\n" ); _left_button = 1; button_change = 1; } else if( _left_button ){ //c_puts( "Left Button Released!\n" ); _left_button = 0; button_change = 1; } // check right-button status if( m_bytes[0] & 0x2 ){ if(_right_button != 1) //c_puts( "Right Button Pressed!\n" ); _right_button = 1; button_change = 1; } else if( _right_button ){ //c_puts( "Right Button Released!\n" ); _right_button = 0; button_change = 1; } // check middle-button status if( m_bytes[0] & 0x4 ){ if(_middle_button != 1) //c_puts( "Middle Button Pressed!\n" ); _middle_button = 1; button_change = 1; } else if( _middle_button ){ //c_puts( "Middle Button Released!\n" ); _middle_button = 0; button_change = 1; } _x_move = m_bytes[1]; if( (m_bytes[0] & 0x8) == 0 ){ _x_move *= -1; } if( (m_bytes[0] & 0x20) != 0 ){ _y_move *= -1; } _y_move = m_bytes[2]; //c_printf( "X: %dmm\n", _x_move ); //c_printf( "Y: %dmm\n", _y_move ); } byte_c = 0; } // remove the mouse cursor at the previous location c_putchar_at(_x_pos, _y_pos, ' '); // limit total possible movement _x_move = _x_move > 80 ? 80 : _x_move; _x_move = _x_move < -80 ? -80 : _x_move; _y_move = _y_move > 64 ? 64 : _y_move; _y_move = _y_move < -64 ? -64 : _y_move; // move mouse cursor _x_t_move += ( _x_move / 2 ); _y_t_move += ( _y_move / 6 ); /* // apply a minimum bound of movement if( _x_move < 0 && _x_move > -16 ) _x_t_move -= 1; else if( _x_move > 0 && _x_move < 16 ) _x_t_move += 1; if( _y_move < 0 && _y_move > -16 ) _y_t_move += 1; else if( _y_move > 0 && _y_move < 16 ) _y_t_move -= 1; */ if(_x_t_move > 6){ _x_pos++; _x_t_move = 0; } else if(_x_t_move < -6){ _x_pos--; _x_t_move = 0; } if(_y_t_move > 8){ _y_pos--; _y_t_move = 0; } else if(_y_t_move < -8){ _y_pos++; _y_t_move = 0; } // enforce boundaries if( _x_pos > 79 ) _x_pos = 79; if( _x_pos < 0 ) _x_pos = 0; if( _y_pos > 24) _y_pos = 24; if( _y_pos < 0) _y_pos = 0; if(_left_button) mouse_p = 'x'; else if(_right_button) mouse_p = '#'; else if(_middle_button) mouse_p = '|'; else mouse_p = '+'; c_putchar_at( _x_pos, _y_pos, mouse_p ); update_cursor_pos( _x_pos, _y_pos ); if( button_change == 1 ) update_mouse_button( _left_button, _right_button, _middle_button ); // indicate that we have read the interrupt __outb( 0x20, 0x20 ); __outb( 0xA0, 0x20 ); }
static void text_prepare_status_real(int printalways, int clearbar, int level, const char *msg) { int y, i; if (msg) strncpy(lastheader, msg, 512); if (console_loglevel >= SUSPEND_ERROR) { if (!(suspend_action & (1 << SUSPEND_LOGALL)) || level == SUSPEND_UI_MSG) printf("\n** %s\n", lastheader); return; } /* Remember where the cursor was */ if (cur_x != -1) update_cursor_pos(); /* Print version */ move_cursor_to(0, video_num_lines); printf("%s", software_suspend_version); /* Update help text */ update_help(0); /* Print header */ move_cursor_to((video_num_columns - 19) / 2, (video_num_lines / 3) - 3); printf("T U X O N I C E"); /* Print action */ y = video_num_lines / 3; move_cursor_to(0, y); /* Clear old message */ for (i = 0; i < video_num_columns; i++) printf(" "); move_cursor_to((video_num_columns - strlen(lastheader)) / 2, y); printf("%s", lastheader); if (draw_progress_bar) { /* Draw left bracket of progress bar. */ y++; move_cursor_to(video_num_columns / 4, y); printf("["); /* Draw right bracket of progress bar. */ move_cursor_to(video_num_columns - (video_num_columns / 4) - 1, y); printf("]"); if (clearbar) { /* Position at start of progress */ move_cursor_to(video_num_columns / 4 + 1, y); /* Clear bar */ for (i = 0; i < barwidth; i++) printf(" "); move_cursor_to(video_num_columns / 4 + 1, y); barposn = 0; } } if (cur_x == -1) { cur_x = 1; cur_y = y+2; } move_cursor_to(cur_x, cur_y); hide_cursor(); }