From 531c75c002a61c67f2da9c0e24db33d25345edc3 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Fri, 2 Dec 2005 17:27:19 +0000 Subject: [PATCH] - keyboard/mouse runtime parameter handlers moved into the device code - minor code cleanups --- bochs/config.cc | 18 +---------------- bochs/iodev/iodev.h | 8 +------- bochs/iodev/keyboard.cc | 45 ++++++++++++++++++++++++++++++++--------- bochs/iodev/keyboard.h | 11 +++++----- bochs/plugin.h | 6 +----- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/bochs/config.cc b/bochs/config.cc index 547fc16ef..91dcaf3fc 100755 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: config.cc,v 1.64 2005-11-29 20:46:17 vruppert Exp $ +// $Id: config.cc,v 1.65 2005-12-02 17:27:18 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -59,13 +59,6 @@ bx_param_handler (bx_param_c *param, int set, Bit64s val) { bx_id id = param->get_id (); switch (id) { - case BXP_MOUSE_ENABLED: - // if after init, notify the GUI - if (set && SIM->get_init_done ()) { - bx_gui->mouse_enabled_changed (val!=0); - DEV_mouse_enabled_changed (val!=0); - } - break; case BXP_LOAD32BITOS_WHICH: if (set) { int enable = (val != Load32bitOSNone); @@ -121,11 +114,6 @@ bx_param_handler (bx_param_c *param, int set, Bit64s val) bx_gui->update_drive_status_buttons (); } break; - case BXP_KBD_PASTE_DELAY: - if ((set) && (SIM->get_init_done ())) { - DEV_kbd_paste_delay_changed (); - } - break; case BXP_ATA0_MASTER_MODE: case BXP_ATA0_SLAVE_MODE: @@ -1162,8 +1150,6 @@ void bx_init_options () "Enable the mouse", "Controls whether the mouse sends events to the guest. The hardware emulation is always enabled.", 0); - bx_options.Omouse_enabled->set_handler (bx_param_handler); - bx_options.Omouse_enabled->set_runtime_param (1); static char *mouse_type_list[] = { "none", @@ -1627,8 +1613,6 @@ void bx_init_options () "Approximate time in microseconds between attemps to paste characters to the keyboard controller.", 1000, BX_MAX_BIT32U, 100000); - bx_options.Okeyboard_paste_delay->set_handler (bx_param_handler); - bx_options.Okeyboard_paste_delay->set_runtime_param (1); bx_options.cmosimage.Oenabled = new bx_param_bool_c (BXP_CMOSIMAGE_ENABLED, "Use a CMOS image", "Controls the usage of a CMOS image", diff --git a/bochs/iodev/iodev.h b/bochs/iodev/iodev.h index 5a40fdb62..b6c4a0a02 100644 --- a/bochs/iodev/iodev.h +++ b/bochs/iodev/iodev.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: iodev.h,v 1.65 2005-11-27 17:49:58 vruppert Exp $ +// $Id: iodev.h,v 1.66 2005-12-02 17:27:19 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -109,12 +109,6 @@ class BOCHSAPI bx_keyb_stub_c : public bx_devmodel_c { virtual void paste_bytes(Bit8u *data, Bit32s length) { STUBFUNC(keyboard, paste_bytes); } - virtual void paste_delay_changed () { - STUBFUNC(keyboard, paste_delay_changed); - } - virtual void mouse_enabled_changed(bool enabled) { - STUBFUNC(keyboard, mouse_enabled_changed); - } }; class BOCHSAPI bx_hard_drive_stub_c : public bx_devmodel_c { diff --git a/bochs/iodev/keyboard.cc b/bochs/iodev/keyboard.cc index 9493b1daf..a87bace76 100644 --- a/bochs/iodev/keyboard.cc +++ b/bochs/iodev/keyboard.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: keyboard.cc,v 1.105 2005-10-31 15:32:18 vruppert Exp $ +// $Id: keyboard.cc,v 1.106 2005-12-02 17:27:19 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.105 2005-10-31 15:32:18 vruppert Exp $")); + BX_DEBUG(("Init $Id: keyboard.cc,v 1.106 2005-12-02 17:27:19 vruppert Exp $")); Bit32u i; DEV_register_irq(1, "8042 Keyboard controller"); @@ -199,7 +199,7 @@ bx_keyb_c::init(void) BX_KEY_THIS pastebuf = NULL; BX_KEY_THIS pastebuf_len = 0; BX_KEY_THIS pastebuf_ptr = 0; - BX_KEY_THIS paste_delay_changed (); + BX_KEY_THIS paste_delay_changed(bx_options.Okeyboard_paste_delay->get()); BX_KEY_THIS stop_paste = 0; // mouse port installed on system board @@ -251,6 +251,12 @@ bx_keyb_c::init(void) &BX_KEY_THIS s.kbd_controller.outb)); } #endif + + // init runtime parameters + bx_options.Omouse_enabled->set_handler(kbd_param_handler); + bx_options.Omouse_enabled->set_runtime_param(1); + bx_options.Okeyboard_paste_delay->set_handler(kbd_param_handler); + bx_options.Okeyboard_paste_delay->set_runtime_param(1); } void @@ -261,10 +267,29 @@ bx_keyb_c::reset(unsigned type) } } - void -bx_keyb_c::paste_delay_changed() +Bit64s bx_keyb_c::kbd_param_handler(bx_param_c *param, int set, Bit64s val) { - BX_KEY_THIS pastedelay = bx_options.Okeyboard_paste_delay->get()/BX_IODEV_HANDLER_PERIOD; + if (set) { + bx_id id = param->get_id (); + switch (id) { + case BXP_MOUSE_ENABLED: + bx_gui->mouse_enabled_changed(val!=0); + BX_KEY_THIS mouse_enabled_changed(val!=0); + break; + case BXP_KBD_PASTE_DELAY: + BX_KEY_THIS paste_delay_changed(val); + break; + default: + BX_PANIC(("kbd_param_handler called with unexpected parameter %d", id)); + } + } + return val; +} + + void +bx_keyb_c::paste_delay_changed(Bit32u value) +{ + BX_KEY_THIS pastedelay = value / BX_IODEV_HANDLER_PERIOD; BX_INFO(("will paste characters every %d keyboard ticks",BX_KEY_THIS pastedelay)); } @@ -1512,7 +1537,7 @@ bx_keyb_c::create_mouse_packet(bool force_enq) { void -bx_keyb_c::mouse_enabled_changed(bool enabled) +bx_keyb_c::mouse_enabled_changed(bx_bool enabled) { #if BX_SUPPORT_PCIUSB // if type == usb, connect or disconnect the USB mouse @@ -1526,9 +1551,9 @@ bx_keyb_c::mouse_enabled_changed(bool enabled) BX_KEY_THIS s.mouse.delayed_dz) { create_mouse_packet(1); } - s.mouse.delayed_dx=0; - s.mouse.delayed_dy=0; - s.mouse.delayed_dz=0; + BX_KEY_THIS s.mouse.delayed_dx=0; + BX_KEY_THIS s.mouse.delayed_dy=0; + BX_KEY_THIS s.mouse.delayed_dz=0; BX_DEBUG(("PS/2 mouse %s", enabled?"enabled":"disabled")); } diff --git a/bochs/iodev/keyboard.h b/bochs/iodev/keyboard.h index 9eb73346c..5e4b73afd 100644 --- a/bochs/iodev/keyboard.h +++ b/bochs/iodev/keyboard.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: keyboard.h,v 1.30 2005-09-13 19:35:01 vruppert Exp $ +// $Id: keyboard.h,v 1.31 2005-12-02 17:27:19 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -38,7 +38,7 @@ # define BX_KEY_THIS theKeyboard-> #else # define BX_KEY_SMF -# define BX_KEY_THIS +# define BX_KEY_THIS this-> #endif #define MOUSE_MODE_RESET 10 @@ -58,9 +58,10 @@ public: virtual void paste_bytes(Bit8u *data, Bit32s length); virtual void mouse_motion(int delta_x, int delta_y, int delta_z, unsigned button_state); - // update the paste delay based on bx_options.Okeyboard_paste_delay - virtual void paste_delay_changed (); - virtual void mouse_enabled_changed(bool enabled); + // runtime options + static Bit64s kbd_param_handler(bx_param_c *param, int set, Bit64s val); + BX_KEY_SMF void paste_delay_changed(Bit32u value); + BX_KEY_SMF void mouse_enabled_changed(bx_bool enabled); private: BX_KEY_SMF Bit8u get_kbd_enable(void); diff --git a/bochs/plugin.h b/bochs/plugin.h index 320dd5e14..a21d4dc2c 100644 --- a/bochs/plugin.h +++ b/bochs/plugin.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: plugin.h,v 1.43 2005-11-27 17:49:58 vruppert Exp $ +// $Id: plugin.h,v 1.44 2005-12-02 17:27:18 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // This file provides macros and types needed for plugins. It is based on @@ -111,10 +111,6 @@ extern "C" { (bx_devices.pluginKeyboard->gen_scancode(key)) #define DEV_kbd_paste_bytes(bytes, count) \ (bx_devices.pluginKeyboard->paste_bytes(bytes,count)) -#define DEV_kbd_paste_delay_changed() \ - (bx_devices.pluginKeyboard->paste_delay_changed()) -#define DEV_mouse_enabled_changed(val) \ - (bx_devices.pluginKeyboard->mouse_enabled_changed(val)) ///////// hard drive macros #define DEV_hd_read_handler(a, b, c) \