- the USB mouse connection status no longer depends on the mouse capture status.

The connection status is now only controlled by the USB port options (TODO:
  device change support at runtime)
- a connected USB mouse now has the priority when sending mouse data from the
  gui to the emulated mouse device.
This commit is contained in:
Volker Ruppert 2006-09-23 12:59:57 +00:00
parent 48ed7e1ba6
commit 93534890b0
5 changed files with 28 additions and 36 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: iodev.h,v 1.81 2006-09-20 18:24:17 vruppert Exp $
// $Id: iodev.h,v 1.82 2006-09-23 12:59:56 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -346,8 +346,8 @@ public:
virtual void usb_mouse_enq(int delta_x, int delta_y, int delta_z, unsigned button_state) {
STUBFUNC(pciusb, usb_mouse_enq);
}
virtual void usb_mouse_enable(bx_bool enable) {
STUBFUNC(pciusb, usb_mouse_enable);
virtual void usb_mouse_enabled_changed(bx_bool enable) {
STUBFUNC(pciusb, usb_mouse_enabled_changed);
}
virtual bx_bool usb_key_enq(Bit8u *scan_code) {
STUBFUNC(pciusb, usb_key_enq);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: keyboard.cc,v 1.125 2006-09-16 14:47:40 vruppert Exp $
// $Id: keyboard.cc,v 1.126 2006-09-23 12:59:56 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -126,7 +126,7 @@ void bx_keyb_c::resetinternals(bx_bool powerup)
void bx_keyb_c::init(void)
{
BX_DEBUG(("Init $Id: keyboard.cc,v 1.125 2006-09-16 14:47:40 vruppert Exp $"));
BX_DEBUG(("Init $Id: keyboard.cc,v 1.126 2006-09-23 12:59:56 vruppert Exp $"));
Bit32u i;
DEV_register_irq(1, "8042 Keyboard controller");
@ -1604,9 +1604,9 @@ void bx_keyb_c::create_mouse_packet(bool force_enq)
void bx_keyb_c::mouse_enabled_changed(bx_bool enabled)
{
#if BX_SUPPORT_PCIUSB
// if type == usb, connect or disconnect the USB mouse
if (BX_KEY_THIS s.mouse.type == BX_MOUSE_TYPE_USB) {
DEV_usb_mouse_enable(enabled);
// if an usb mouse is connected, notify the device about the status change
if (DEV_usb_mouse_connected()) {
DEV_usb_mouse_enabled_changed(enabled);
return;
}
#endif
@ -1631,6 +1631,14 @@ void bx_keyb_c::mouse_motion(int delta_x, int delta_y, int delta_z, unsigned but
if (!BX_KEY_THIS s.mouse.captured)
return;
#if BX_SUPPORT_PCIUSB
// 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;
}
#endif
// if type == serial, redirect mouse data to the serial device
if ((BX_KEY_THIS s.mouse.type == BX_MOUSE_TYPE_SERIAL) ||
(BX_KEY_THIS s.mouse.type == BX_MOUSE_TYPE_SERIAL_WHEEL)) {
@ -1646,14 +1654,6 @@ void bx_keyb_c::mouse_motion(int delta_x, int delta_y, int delta_z, unsigned but
}
#endif
#if BX_SUPPORT_PCIUSB
// 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;
}
#endif
// don't generate interrupts if we are in remote mode.
if ( BX_KEY_THIS s.mouse.mode == MOUSE_MODE_REMOTE)
// is there any point in doing any work if we don't act on the result

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pciusb.cc,v 1.42 2006-09-17 20:39:36 vruppert Exp $
// $Id: pciusb.cc,v 1.43 2006-09-23 12:59:57 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2004 MandrakeSoft S.A.
@ -352,13 +352,8 @@ void bx_pciusb_c::init_device(Bit8u port, char *devname)
if (!strcmp(devname, "mouse")) {
type = USB_DEV_TYPE_MOUSE;
connected = SIM->get_param_bool(BXPN_MOUSE_ENABLED)->get();
if (SIM->get_param_enum(BXPN_MOUSE_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;
}
connected = 1;
BX_USB_THIS mouse_connected = 1;
} else if (!strcmp(devname, "keypad")) {
type = USB_DEV_TYPE_KEYPAD;
connected = 1;
@ -1644,14 +1639,11 @@ void bx_pciusb_c::pci_write_handler(Bit8u address, Bit32u value, unsigned io_len
BX_DEBUG(("USB PCI write register 0x%02x value 0x%s", address, szTmp));
}
void bx_pciusb_c::usb_mouse_enable(bx_bool enable)
void bx_pciusb_c::usb_mouse_enabled_changed(bx_bool enable)
{
BX_USB_THIS mouse_connected = enable;
if (BX_USB_THIS last_connect != enable) {
for (int i=0; i<USB_NUM_PORTS; i++)
usb_set_connect_status(i, USB_DEV_TYPE_MOUSE, enable);
BX_USB_THIS last_connect = enable;
}
BX_USB_THIS mouse_delayed_dx=0;
BX_USB_THIS mouse_delayed_dy=0;
BX_USB_THIS mouse_delayed_dz=0;
}
void bx_pciusb_c::usb_set_connect_status(Bit8u port, int type, bx_bool connected)

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pciusb.h,v 1.18 2006-05-27 15:54:48 sshwarts Exp $
// $Id: pciusb.h,v 1.19 2006-09-23 12:59:57 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2004 MandrakeSoft S.A.
@ -342,7 +342,7 @@ public:
virtual void init(void);
virtual void reset(unsigned);
virtual void usb_mouse_enq(int delta_x, int delta_y, int delta_z, unsigned button_state);
virtual void usb_mouse_enable(bx_bool enable);
virtual void usb_mouse_enabled_changed(bx_bool enable);
virtual bx_bool usb_key_enq(Bit8u *scan_code);
virtual bx_bool usb_keyboard_connected();
virtual bx_bool usb_mouse_connected();

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: plugin.h,v 1.54 2006-09-16 14:47:40 vruppert Exp $
// $Id: plugin.h,v 1.55 2006-09-23 12:59:56 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// This file provides macros and types needed for plugins. It is based on
@ -214,8 +214,8 @@ extern "C" {
#if BX_SUPPORT_PCIUSB
#define DEV_usb_mouse_enq(dx, dy, dz, state) \
(bx_devices.pluginPciUSBAdapter->usb_mouse_enq(dx, dy, dz, state))
#define DEV_usb_mouse_enable(enable) \
(bx_devices.pluginPciUSBAdapter->usb_mouse_enable(enable))
#define DEV_usb_mouse_enabled_changed(enable) \
(bx_devices.pluginPciUSBAdapter->usb_mouse_enabled_changed(enable))
#define DEV_usb_key_enq(scan_code) \
(bx_devices.pluginPciUSBAdapter->usb_key_enq(scan_code))
#define DEV_usb_keyboard_connected() \