- mouse type 'none' added (no mouse connected)

- added emulation of the PS/2 mouse port without a mouse connected (some OS's
  still detect a mouse)
- fixes for the mouse type 'serial_wheel' (the wheel still doesn't work in Win98)
This commit is contained in:
Volker Ruppert 2004-12-07 21:06:35 +00:00
parent 1d5eb60ec8
commit faafc6a93a
5 changed files with 72 additions and 47 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: rombios.c,v 1.122 2004-12-05 16:38:31 vruppert Exp $
// $Id: rombios.c,v 1.123 2004-12-07 21:06:32 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -912,10 +912,10 @@ Bit16u cdrom_boot();
#endif // BX_ELTORITO_BOOT
static char bios_cvs_version_string[] = "$Revision: 1.122 $";
static char bios_date_string[] = "$Date: 2004-12-05 16:38:31 $";
static char bios_cvs_version_string[] = "$Revision: 1.123 $";
static char bios_date_string[] = "$Date: 2004-12-07 21:06:32 $";
static char CVSID[] = "$Id: rombios.c,v 1.122 2004-12-05 16:38:31 vruppert Exp $";
static char CVSID[] = "$Id: rombios.c,v 1.123 2004-12-07 21:06:32 vruppert Exp $";
/* Offset to skip the CVS $Id: prefix */
#define bios_version_string (CVSID + 4)
@ -3696,6 +3696,11 @@ BX_DEBUG_INT15("case 1 or 5:\n");
ret = send_to_mouse_ctrl(0xFF); // reset mouse command
if (ret == 0) {
ret = get_mouse_data(&mouse_data3);
// if no mouse attached, it will return RESEND
if (mouse_data3 == 0xfe) {
SET_CF();
return;
}
if (mouse_data3 != 0xfa)
BX_PANIC("Mouse reset returned %02x (should be ack)\n", (unsigned)mouse_data3);
if ( ret == 0 ) {

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: config.cc,v 1.21 2004-12-05 20:23:38 vruppert Exp $
// $Id: config.cc,v 1.22 2004-12-07 21:06:25 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -1139,6 +1139,7 @@ void bx_init_options ()
bx_options.Omouse_enabled->set_runtime_param (1);
static char *mouse_type_list[] = {
"none",
"ps2",
"imps2",
"serial",
@ -1147,7 +1148,7 @@ void bx_init_options ()
};
bx_options.Omouse_type = new bx_param_enum_c (BXP_MOUSE_TYPE,
"Mouse type",
"The mouse type can be one of these: 'ps2', 'imps2', 'serial', 'serial_wheel'",
"The mouse type can be one of these: 'none', 'ps2', 'imps2', 'serial', 'serial_wheel'",
mouse_type_list,
0,
0);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: keyboard.cc,v 1.94 2004-12-06 21:12:11 vruppert Exp $
// $Id: keyboard.cc,v 1.95 2004-12-07 21:06:34 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -125,7 +125,7 @@ bx_keyb_c::resetinternals(bx_bool powerup)
void
bx_keyb_c::init(void)
{
BX_DEBUG(("Init $Id: keyboard.cc,v 1.94 2004-12-06 21:12:11 vruppert Exp $"));
BX_DEBUG(("Init $Id: keyboard.cc,v 1.95 2004-12-07 21:06:34 vruppert Exp $"));
Bit32u i;
DEV_register_irq(1, "8042 Keyboard controller");
@ -293,9 +293,9 @@ bx_keyb_c::read(Bit32u address, unsigned io_len)
#else
UNUSED(this_ptr);
#endif // !BX_USE_KEY_SMF
Bit8u val;
if (address == 0x60) { /* output buffer */
Bit8u val;
if (BX_KEY_THIS s.kbd_controller.auxb) { /* mouse byte available */
val = BX_KEY_THIS s.kbd_controller.aux_output_buffer;
BX_KEY_THIS s.kbd_controller.aux_output_buffer = 0;
@ -360,7 +360,7 @@ bx_keyb_c::read(Bit32u address, unsigned io_len)
#if BX_CPU_LEVEL >= 2
else if (address == 0x64) { /* status register */
return (BX_KEY_THIS s.kbd_controller.pare << 7) |
val = (BX_KEY_THIS s.kbd_controller.pare << 7) |
(BX_KEY_THIS s.kbd_controller.tim << 6) |
(BX_KEY_THIS s.kbd_controller.auxb << 5) |
(BX_KEY_THIS s.kbd_controller.keyl << 4) |
@ -368,6 +368,8 @@ bx_keyb_c::read(Bit32u address, unsigned io_len)
(BX_KEY_THIS s.kbd_controller.sysf << 2) |
(BX_KEY_THIS s.kbd_controller.inpb << 1) |
BX_KEY_THIS s.kbd_controller.outb;
BX_KEY_THIS s.kbd_controller.tim = 0;
return val;
}
#else /* BX_CPU_LEVEL > 0 */
@ -1220,6 +1222,11 @@ bx_keyb_c::activate_timer(void)
void
bx_keyb_c::kbd_ctrl_to_mouse(Bit8u value)
{
// if we are not using a ps2 mouse, some of the following commands need to return different values
bx_bool is_ps2 = 0;
if ((bx_options.Omouse_type->get() == MOUSE_TYPE_PS2) ||
(bx_options.Omouse_type->get() == MOUSE_TYPE_IMPS2)) is_ps2 = 1;
BX_DEBUG(("MOUSE: kbd_ctrl_to_mouse(%02xh)", (unsigned) value));
BX_DEBUG((" enable = %u", (unsigned) BX_KEY_THIS s.mouse.enable));
BX_DEBUG((" allow_irq12 = %u",
@ -1366,9 +1373,16 @@ bx_keyb_c::kbd_ctrl_to_mouse(Bit8u value)
break;
case 0xf4: // Enable (in stream mode)
BX_KEY_THIS s.mouse.enable = 1;
controller_enQ(0xFA, 1); // ACK
BX_DEBUG(("[mouse] Mouse enabled (stream mode)"));
// is a mouse present?
if (is_ps2) {
BX_KEY_THIS s.mouse.enable = 1;
controller_enQ(0xFA, 1); // ACK
BX_DEBUG(("[mouse] Mouse enabled (stream mode)"));
} else {
// a mouse isn't present. We need to return a 0xFE (resend) instead of a 0xFA (ACK)
controller_enQ(0xFE, 1); // RESEND
BX_KEY_THIS s.kbd_controller.tim = 1;
}
break;
case 0xf5: // Disable (in stream mode)
@ -1388,19 +1402,26 @@ bx_keyb_c::kbd_ctrl_to_mouse(Bit8u value)
break;
case 0xff: // Reset
BX_KEY_THIS s.mouse.sample_rate = 100; /* reports per second (default) */
BX_KEY_THIS s.mouse.resolution_cpmm = 4; /* 4 counts per millimeter (default) */
BX_KEY_THIS s.mouse.scaling = 1; /* 1:1 (default) */
BX_KEY_THIS s.mouse.mode = MOUSE_MODE_RESET;
BX_KEY_THIS s.mouse.enable = 0;
if (BX_KEY_THIS s.mouse.im_mode)
BX_INFO(("wheel mouse mode disabled"));
BX_KEY_THIS s.mouse.im_mode = 0;
/* (mch) NT expects an ack here */
controller_enQ(0xFA, 1); // ACK
controller_enQ(0xAA, 1); // completion code
controller_enQ(0x00, 1); // ID code (standard after reset)
BX_DEBUG(("[mouse] Mouse reset"));
// is a mouse present?
if (is_ps2) {
BX_KEY_THIS s.mouse.sample_rate = 100; /* reports per second (default) */
BX_KEY_THIS s.mouse.resolution_cpmm = 4; /* 4 counts per millimeter (default) */
BX_KEY_THIS s.mouse.scaling = 1; /* 1:1 (default) */
BX_KEY_THIS s.mouse.mode = MOUSE_MODE_RESET;
BX_KEY_THIS s.mouse.enable = 0;
if (BX_KEY_THIS s.mouse.im_mode)
BX_INFO(("wheel mouse mode disabled"));
BX_KEY_THIS s.mouse.im_mode = 0;
/* (mch) NT expects an ack here */
controller_enQ(0xFA, 1); // ACK
controller_enQ(0xAA, 1); // completion code
controller_enQ(0x00, 1); // ID code (standard after reset)
BX_DEBUG(("[mouse] Mouse reset"));
} else {
// a mouse isn't present. We need to return a 0xFE (resend) instead of a 0xFA (ACK)
controller_enQ(0xFE, 1); // RESEND
BX_KEY_THIS s.kbd_controller.tim = 1;
}
break;
case 0xe9: // Get mouse information

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: keyboard.h,v 1.26 2004-12-05 20:23:38 vruppert Exp $
// $Id: keyboard.h,v 1.27 2004-12-07 21:06:35 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -46,10 +46,11 @@
#define MOUSE_MODE_REMOTE 12
#define MOUSE_MODE_WRAP 13
#define MOUSE_TYPE_PS2 0
#define MOUSE_TYPE_IMPS2 1
#define MOUSE_TYPE_SERIAL 2
#define MOUSE_TYPE_SERIAL_WHEEL 3
#define MOUSE_TYPE_NONE 0
#define MOUSE_TYPE_PS2 1
#define MOUSE_TYPE_IMPS2 2
#define MOUSE_TYPE_SERIAL 3
#define MOUSE_TYPE_SERIAL_WHEEL 4
class bx_keyb_c : public bx_keyb_stub_c {
public:

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: serial.cc,v 1.60 2004-12-05 20:23:39 vruppert Exp $
// $Id: serial.cc,v 1.61 2004-12-07 21:06:35 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2004 MandrakeSoft S.A.
@ -893,10 +893,12 @@ bx_serial_c::write(Bit32u address, Bit32u value, unsigned io_len)
if (BX_SER_THIS s[port].io_mode == BX_SER_MODE_MOUSE) {
if (BX_SER_THIS detect_mouse == 2) {
if (bx_options.Omouse_type->get() == MOUSE_TYPE_SERIAL) {
BX_SER_THIS mouse_internal_buffer.head = 0;
BX_SER_THIS mouse_internal_buffer.num_elements = 1;
BX_SER_THIS mouse_internal_buffer.buffer[0] = 'M';
}
if (bx_options.Omouse_type->get() == MOUSE_TYPE_SERIAL_WHEEL) {
BX_SER_THIS mouse_internal_buffer.head = 0;
BX_SER_THIS mouse_internal_buffer.num_elements = 6;
BX_SER_THIS mouse_internal_buffer.buffer[0] = 'M';
BX_SER_THIS mouse_internal_buffer.buffer[1] = 'Z';
@ -1248,6 +1250,10 @@ bx_serial_c::serial_mouse_enq(int delta_x, int delta_y, int delta_z, unsigned bu
return;
}
// if the DTR and RTS lines aren't up, the mouse doesn't have any power to send packets.
if (!BX_SER_THIS s[BX_SER_THIS mouse_port].modem_cntl.dtr || !BX_SER_THIS s[BX_SER_THIS mouse_port].modem_cntl.rts)
return;
// scale down the motion
if ( (delta_x < -1) || (delta_x > 1) )
delta_x /= 2;
@ -1261,9 +1267,9 @@ bx_serial_c::serial_mouse_enq(int delta_x, int delta_y, int delta_z, unsigned bu
BX_SER_THIS mouse_delayed_dx+=delta_x;
BX_SER_THIS mouse_delayed_dy-=delta_y;
BX_SER_THIS mouse_delayed_dz+=delta_z;
BX_SER_THIS mouse_delayed_dz =delta_z;
if ((BX_SER_THIS mouse_internal_buffer.num_elements + 3) >= BX_MOUSE_BUFF_SIZE) {
if ((BX_SER_THIS mouse_internal_buffer.num_elements + 4) >= BX_MOUSE_BUFF_SIZE) {
return; /* buffer doesn't have the space */
}
@ -1287,20 +1293,11 @@ bx_serial_c::serial_mouse_enq(int delta_x, int delta_y, int delta_z, unsigned bu
delta_y = BX_SER_THIS mouse_delayed_dy;
BX_SER_THIS mouse_delayed_dy = 0;
}
if (BX_SER_THIS mouse_delayed_dz == 120) {
delta_z = 1;
BX_SER_THIS mouse_delayed_dz += 1;
} else if (BX_SER_THIS mouse_delayed_dz == 65416) { // -120
delta_z = -1;
BX_SER_THIS mouse_delayed_dz -= 1;
} else {
delta_z = BX_SER_THIS mouse_delayed_dz;
BX_SER_THIS mouse_delayed_dz = 0;
}
b1 = (Bit8u)delta_x;
b2 = (Bit8u)delta_y;
b3 = (Bit8u)delta_z;
b1 = (Bit8u) delta_x;
b2 = (Bit8u) delta_y;
b3 = (Bit8u) -((Bit8s) delta_z);
mouse_data[0] = 0x40 | ((b1 & 0xc0) >> 6) | ((b2 & 0xc0) >> 4);
mouse_data[0] |= ((button_state & 0x01) << 5) | ((button_state & 0x02) << 3);
mouse_data[1] = b1 & 0x3f;