- redirect mouse data to USB only when an USB mouse is connected

- connect USB mouse only when the mouse type is set to 'usb'
This commit is contained in:
Volker Ruppert 2005-01-21 16:07:38 +00:00
parent 57fcc89274
commit 8d2d2bd83b
5 changed files with 27 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: iodev.h,v 1.58 2005-01-14 18:28:46 vruppert Exp $
// $Id: iodev.h,v 1.59 2005-01-21 16:07:19 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -330,6 +330,9 @@ class BOCHSAPI bx_usb_stub_c : public bx_devmodel_c {
virtual bx_bool usb_keyboard_connected() {
return 0;
}
virtual bx_bool usb_mouse_connected() {
return 0;
}
};
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: keyboard.cc,v 1.100 2005-01-14 18:28:46 vruppert Exp $
// $Id: keyboard.cc,v 1.101 2005-01-21 16:07:36 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.100 2005-01-14 18:28:46 vruppert Exp $"));
BX_DEBUG(("Init $Id: keyboard.cc,v 1.101 2005-01-21 16:07:36 vruppert Exp $"));
Bit32u i;
DEV_register_irq(1, "8042 Keyboard controller");
@ -1570,8 +1570,8 @@ bx_keyb_c::mouse_motion(int delta_x, int delta_y, int delta_z, unsigned button_s
#endif
#if BX_SUPPORT_PCIUSB
// if type == usb, redirect mouse data to the usb device
if (BX_KEY_THIS s.mouse.type == BX_MOUSE_TYPE_USB) {
// if an usb mouse is connected redirect mouse data to the usb device
if (DEV_usb_mouse_connected()) {
DEV_usb_mouse_enq(delta_x, delta_y, delta_z, button_state);
return;
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pciusb.cc,v 1.19 2005-01-14 18:28:47 vruppert Exp $
// $Id: pciusb.cc,v 1.20 2005-01-21 16:07:37 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2004 MandrakeSoft S.A.
@ -224,6 +224,7 @@ bx_pciusb_c::reset(unsigned type)
memset(&BX_USB_THIS hub[i].device[j], 0, sizeof(USB_DEVICE));
BX_USB_THIS keyboard_connected = 0;
BX_USB_THIS mouse_connected = 0;
// include the device(s) initialize code
#include "pciusb_devs.h"
@ -244,8 +245,11 @@ bx_pciusb_c::init_device(Bit8u port, char *devname)
if (!strcmp(devname, "mouse")) {
type = USB_DEV_TYPE_MOUSE;
connected = bx_options.Omouse_enabled->get();
if (bx_options.Omouse_type->get() != BX_MOUSE_TYPE_USB) {
BX_ERROR(("USB mouse present, but other mouse type configured"));
if (bx_options.Omouse_type->get() == BX_MOUSE_TYPE_USB) {
BX_USB_THIS mouse_connected = connected;
} else if (connected) {
BX_ERROR(("USB mouse connect ignored, since other mouse type is configured"));
connected = 0;
}
} else if (!strcmp(devname, "keypad")) {
type = USB_DEV_TYPE_KEYPAD;
@ -1620,4 +1624,10 @@ bx_pciusb_c::usb_keyboard_connected()
return BX_USB_THIS keyboard_connected;
}
bx_bool
bx_pciusb_c::usb_mouse_connected()
{
return BX_USB_THIS mouse_connected;
}
#endif // BX_SUPPORT_PCI && BX_SUPPORT_PCIUSB

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pciusb.h,v 1.8 2005-01-14 18:28:47 vruppert Exp $
// $Id: pciusb.h,v 1.9 2005-01-21 16:07:38 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2004 MandrakeSoft S.A.
@ -357,6 +357,7 @@ public:
virtual void usb_mouse_enable(bx_bool enable);
virtual bx_bool usb_key_enq(Bit8u *scan_code);
virtual bx_bool usb_keyboard_connected();
virtual bx_bool usb_mouse_connected();
private:
@ -385,6 +386,7 @@ private:
bx_bool last_connect;
bx_bool keyboard_connected;
bx_bool mouse_connected;
static void init_device(Bit8u port, char *devname);
static void usb_set_connect_status(int type, bx_bool connected);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: plugin.h,v 1.38 2005-01-14 18:28:45 vruppert Exp $
// $Id: plugin.h,v 1.39 2005-01-21 16:07:18 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// This file provides macros and types needed for plugins. It is based on
@ -215,6 +215,8 @@ extern "C" {
(bx_devices.pluginPciUSBAdapter->usb_key_enq(scan_code))
#define DEV_usb_keyboard_connected() \
(bx_devices.pluginPciUSBAdapter->usb_keyboard_connected())
#define DEV_usb_mouse_connected() \
(bx_devices.pluginPciUSBAdapter->usb_mouse_connected())
#endif
//////// Memory macros