diff --git a/bochs/.bochsrc b/bochs/.bochsrc index 0373436d9..50c06ead9 100644 --- a/bochs/.bochsrc +++ b/bochs/.bochsrc @@ -386,7 +386,7 @@ debugger_log: - # Other serial modes are 'null' (no input/output), 'file' (output to a file # specified as the 'dev' parameter), 'raw' (use the real serial port - under # construction for win32) and 'mouse' (standard serial mouse - requires -# mouse option setting 'type=serial') +# mouse option setting 'type=serial' or 'type=serial_wheel') # # Examples: # com1: enabled=1, mode=null @@ -512,8 +512,9 @@ floppy_command_delay: 500 # You can also toggle the mouse usage at runtime (control key + middle # mouse button on X11, SDL, wxWidgets and Win32). # With the new mouse type option you can select the type of mouse to emulate. -# The default value is 'ps2'. The other choices are 'imps2' (under -# construction) and 'serial' (one com port requires setting 'mode=mouse'). +# The default value is 'ps2'. The other choices are 'imps2' (wheel mouse +# on PS/2), 'serial' and 'serial_wheel' (one com port requires setting +# 'mode=mouse'). # # Examples: # mouse: enabled=1 diff --git a/bochs/config.cc b/bochs/config.cc index 4df1bc0de..16ac11223 100755 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: config.cc,v 1.20 2004-12-02 21:34:25 vruppert Exp $ +// $Id: config.cc,v 1.21 2004-12-05 20:23:38 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -1142,11 +1142,12 @@ void bx_init_options () "ps2", "imps2", "serial", + "serial_wheel", NULL }; 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'", + "The mouse type can be one of these: 'ps2', 'imps2', 'serial', 'serial_wheel'", mouse_type_list, 0, 0); diff --git a/bochs/gui/win32.cc b/bochs/gui/win32.cc index 1c5d712b4..ff67e3ffd 100644 --- a/bochs/gui/win32.cc +++ b/bochs/gui/win32.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: win32.cc,v 1.86 2004-08-22 16:22:09 vruppert Exp $ +// $Id: win32.cc,v 1.87 2004-12-05 20:23:38 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -34,9 +34,10 @@ #define BX_PLUGGABLE #include "bochs.h" -#include "iodev.h" +#include "iodev/iodev.h" #if BX_WITH_WIN32 +#include "zmouse.h" #include "win32res.h" #include "font/vga.bitmap.h" // windows.h is included by bochs.h @@ -78,6 +79,7 @@ struct QueueEvent { Bit32u key_event; int mouse_x; int mouse_y; + int mouse_z; int mouse_button_state; }; QueueEvent* deq_key_event(void); @@ -85,9 +87,9 @@ QueueEvent* deq_key_event(void); static QueueEvent keyevents[SCANCODE_BUFSIZE]; static unsigned head=0, tail=0; static int mouse_button_state = 0; -static int ms_xdelta=0, ms_ydelta=0; -static int ms_lastx=0, ms_lasty=0; -static int ms_savedx=0, ms_savedy=0; +static int ms_xdelta=0, ms_ydelta=0, ms_zdelta=0; +static int ms_lastx=0, ms_lasty=0, ms_lastz=0; +static int ms_savedx=0, ms_savedy=0, ms_savedz=0; static BOOL mouseCaptureMode, mouseCaptureNew, mouseToggleReq; static unsigned long workerThread = 0; static DWORD workerThreadID = 0; @@ -457,7 +459,7 @@ Bit32u win32_to_bx_key[2][0x100] = void bx_signal_handler(int); #endif -static void processMouseXY( int x, int y, int windows_state, int implied_state_change) +static void processMouseXY( int x, int y, int z, int windows_state, int implied_state_change) { int bx_state; int old_bx_state; @@ -477,8 +479,10 @@ static void processMouseXY( int x, int y, int windows_state, int implied_state_c } ms_ydelta=ms_savedy-y; ms_xdelta=x-ms_savedx; + ms_zdelta=z-ms_savedz; ms_lastx=x; ms_lasty=y; + ms_lastz=z; if ( bx_state!=mouse_button_state) { EnterCriticalSection( &stInfo.keyCS); @@ -495,7 +499,8 @@ static void resetDelta() EnterCriticalSection( &stInfo.mouseCS); ms_savedx=ms_lastx; ms_savedy=ms_lasty; - ms_ydelta=ms_xdelta=0; + ms_savedz=ms_lastz; + ms_ydelta=ms_xdelta=ms_zdelta=0; LeaveCriticalSection( &stInfo.mouseCS); } @@ -509,6 +514,7 @@ static void cursorWarped() ms_lasty=stretched_y/2; ms_savedx=ms_lastx; ms_savedy=ms_lasty; + ms_savedz=ms_lastz; LeaveCriticalSection( &stInfo.mouseCS); } @@ -983,7 +989,13 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) case WM_MOUSEMOVE: if (!mouseModeChange) { - processMouseXY( LOWORD(lParam), HIWORD(lParam), wParam, 0); + processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 0); + } + return 0; + + case WM_MOUSEWHEEL: + if (!mouseModeChange) { + processMouseXY( 0, 0, HIWORD(wParam), 0, 0); } return 0; @@ -998,11 +1010,11 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) } else if (mouseModeChange && (iMsg == WM_LBUTTONUP)) { mouseModeChange = FALSE; } else { - processMouseXY( LOWORD(lParam), HIWORD(lParam), wParam, 1); + processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 1); } return 0; } - processMouseXY( LOWORD(lParam), HIWORD(lParam), wParam, 1); + processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 1); return 0; case WM_MBUTTONDOWN: @@ -1015,7 +1027,7 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) } else if (mouseModeChange && (iMsg == WM_MBUTTONUP)) { mouseModeChange = FALSE; } else { - processMouseXY( LOWORD(lParam), HIWORD(lParam), wParam, 4); + processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 4); } return 0; @@ -1030,11 +1042,11 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) } else if (mouseModeChange && (iMsg == WM_RBUTTONUP)) { mouseModeChange = FALSE; } else { - processMouseXY( LOWORD(lParam), HIWORD(lParam), wParam, 2); + processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 2); } return 0; } - processMouseXY( LOWORD(lParam), HIWORD(lParam), wParam, 2); + processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 2); return 0; case WM_CLOSE: @@ -1130,7 +1142,7 @@ void enq_key_event(Bit32u key, Bit32u press_release) void enq_mouse_event(void) { EnterCriticalSection( &stInfo.mouseCS); - if ( ms_xdelta || ms_ydelta) + if ( ms_xdelta || ms_ydelta || ms_zdelta) { if (((tail+1) % SCANCODE_BUFSIZE) == head) { BX_ERROR(( "enq_scancode: buffer full" )); @@ -1140,6 +1152,7 @@ void enq_mouse_event(void) current.key_event=MOUSE_MOTION; current.mouse_x=ms_xdelta; current.mouse_y=ms_ydelta; + current.mouse_z=ms_zdelta; current.mouse_button_state=mouse_button_state; resetDelta(); tail = (tail + 1) % SCANCODE_BUFSIZE; @@ -1185,12 +1198,12 @@ void bx_win32_gui_c::handle_events(void) { key = queue_event->key_event; if ( key==MOUSE_MOTION) { - DEV_mouse_motion( queue_event->mouse_x, - queue_event->mouse_y, queue_event->mouse_button_state); + DEV_mouse_motion_ext( queue_event->mouse_x, + queue_event->mouse_y, queue_event->mouse_z, queue_event->mouse_button_state); } // Check for mouse buttons first else if ( key & MOUSE_PRESSED) { - DEV_mouse_motion( 0, 0, LOWORD(key)); + DEV_mouse_motion_ext( 0, 0, 0, LOWORD(key)); } else if (key & HEADERBAR_CLICKED) { headerbar_click(LOWORD(key)); diff --git a/bochs/iodev/iodev.h b/bochs/iodev/iodev.h index 82e8ec0fc..dcfd4e43e 100644 --- a/bochs/iodev/iodev.h +++ b/bochs/iodev/iodev.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: iodev.h,v 1.53 2004-12-02 21:34:25 vruppert Exp $ +// $Id: iodev.h,v 1.54 2004-12-05 20:23:38 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -97,7 +97,7 @@ class BOCHSAPI bx_keyb_stub_c : public bx_devmodel_c { public: virtual ~bx_keyb_stub_c () {} // stubs for bx_keyb_c methods - virtual void mouse_motion(int delta_x, int delta_y, unsigned button_state) { + virtual void mouse_motion(int delta_x, int delta_y, int delta_z, unsigned button_state) { STUBFUNC(keyboard, mouse_motion); } virtual void gen_scancode(Bit32u key) { @@ -306,7 +306,7 @@ class BOCHSAPI bx_speaker_stub_c : public bx_devmodel_c { class BOCHSAPI bx_serial_stub_c : public bx_devmodel_c { public: - virtual void serial_mouse_enq(int delta_x, int delta_y, unsigned button_state) { + virtual void serial_mouse_enq(int delta_x, int delta_y, int delta_z, unsigned button_state) { STUBFUNC(serial, serial_mouse_enq); } }; diff --git a/bochs/iodev/keyboard.cc b/bochs/iodev/keyboard.cc index 795877136..3a363cf5e 100644 --- a/bochs/iodev/keyboard.cc +++ b/bochs/iodev/keyboard.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: keyboard.cc,v 1.92 2004-12-02 21:34:25 vruppert Exp $ +// $Id: keyboard.cc,v 1.93 2004-12-05 20:23:38 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.92 2004-12-02 21:34:25 vruppert Exp $")); + BX_DEBUG(("Init $Id: keyboard.cc,v 1.93 2004-12-05 20:23:38 vruppert Exp $")); Bit32u i; DEV_register_irq(1, "8042 Keyboard controller"); @@ -185,7 +185,9 @@ bx_keyb_c::init(void) BX_KEY_THIS s.mouse.enable = 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_KEY_THIS s.mouse.im_request = 0; // wheel mouse mode request + BX_KEY_THIS s.mouse.im_mode = 0; // wheel mouse mode for (i=0; i= BX_MOUSE_BUFF_SIZE) { + int bytes = 3; + if (BX_KEY_THIS s.mouse.im_mode) bytes = 4; + + if ((BX_KEY_THIS s.mouse_internal_buffer.num_elements + bytes) >= BX_MOUSE_BUFF_SIZE) { return(0); /* buffer doesn't have the space */ } mouse_enQ(b1); mouse_enQ(b2); mouse_enQ(b3); + if (BX_KEY_THIS s.mouse.im_mode) mouse_enQ(b4); + return(1); } @@ -1238,7 +1242,8 @@ bx_keyb_c::kbd_ctrl_to_mouse(Bit8u value) BX_KEY_THIS s.mouse.im_request = 2; } else if ((value == 80) && (BX_KEY_THIS s.mouse.im_request == 2)) { if (BX_KEY_THIS s.mouse.type == MOUSE_TYPE_IMPS2) { - BX_INFO(("wheel mouse mode request (not implemented)")); + BX_INFO(("wheel mouse mode enabled")); + BX_KEY_THIS s.mouse.im_mode = 1; } else { BX_INFO(("wheel mouse mode request rejected")); } @@ -1348,7 +1353,10 @@ bx_keyb_c::kbd_ctrl_to_mouse(Bit8u value) case 0xf2: // Read Device Type controller_enQ(0xFA, 1); // ACK - controller_enQ(0x00, 1); // Device ID (standard) + if (BX_KEY_THIS s.mouse.im_mode) + controller_enQ(0x03, 1); // Device ID (wheel z-mouse) + else + controller_enQ(0x00, 1); // Device ID (standard) BX_DEBUG(("[mouse] Read mouse ID")); break; @@ -1385,10 +1393,13 @@ bx_keyb_c::kbd_ctrl_to_mouse(Bit8u value) 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 (normal mouse, wheelmouse has id 0x3) + controller_enQ(0x00, 1); // ID code (standard after reset) BX_DEBUG(("[mouse] Mouse reset")); break; @@ -1405,7 +1416,7 @@ bx_keyb_c::kbd_ctrl_to_mouse(Bit8u value) controller_enQ(0xFA, 1); // ACK // perhaps we should be adding some movement here. mouse_enQ_packet( ((BX_KEY_THIS s.mouse.button_status & 0x0f) | 0x08), - 0x00, 0x00 ); // bit3 of first byte always set + 0x00, 0x00, 0x00); // bit3 of first byte always set //assumed we really aren't in polling mode, a rather odd assumption. BX_ERROR(("[mouse] Warning: Read Data command partially supported.")); break; @@ -1419,7 +1430,7 @@ bx_keyb_c::kbd_ctrl_to_mouse(Bit8u value) void bx_keyb_c::create_mouse_packet(bool force_enq) { - Bit8u b1, b2, b3; + Bit8u b1, b2, b3, b4; if(BX_KEY_THIS s.mouse_internal_buffer.num_elements && !force_enq) return; @@ -1476,22 +1487,29 @@ bx_keyb_c::create_mouse_packet(bool force_enq) { b1 |= 0x20; BX_KEY_THIS s.mouse.delayed_dy+=256; } - mouse_enQ_packet(b1, b2, b3); + + b4 = (Bit8u) BX_KEY_THIS s.mouse.delayed_dz & 0x07; + if (BX_KEY_THIS s.mouse.delayed_dz < 0) + b4 |= 0xF8; + + mouse_enQ_packet(b1, b2, b3, b4); } void bx_keyb_c::mouse_enabled_changed(bool enabled) { - if (s.mouse.delayed_dx || BX_KEY_THIS s.mouse.delayed_dy) { + if (BX_KEY_THIS s.mouse.delayed_dx || BX_KEY_THIS s.mouse.delayed_dy || + 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_DEBUG(("Keyboard mouse disable called.")); } void -bx_keyb_c::mouse_motion(int delta_x, int delta_y, unsigned button_state) +bx_keyb_c::mouse_motion(int delta_x, int delta_y, int delta_z, unsigned button_state) { bool force_enq=0; @@ -1501,8 +1519,9 @@ bx_keyb_c::mouse_motion(int delta_x, int delta_y, unsigned button_state) return; // redirect mouse data to the serial device - if (BX_KEY_THIS s.mouse.type == MOUSE_TYPE_SERIAL) { - DEV_serial_mouse_enq(delta_x, delta_y, button_state); + if ((BX_KEY_THIS s.mouse.type == MOUSE_TYPE_SERIAL) || + (BX_KEY_THIS s.mouse.type == MOUSE_TYPE_SERIAL_WHEEL)) { + DEV_serial_mouse_enq(delta_x, delta_y, delta_z, button_state); return; } @@ -1522,12 +1541,15 @@ bx_keyb_c::mouse_motion(int delta_x, int delta_y, unsigned button_state) if ( (delta_y < -1) || (delta_y > 1) ) delta_y /= 2; + if (!BX_KEY_THIS s.mouse.im_mode) + delta_z = 0; + #ifdef VERBOSE_KBD_DEBUG - if (delta_x != 0 || delta_y != 0) - BX_DEBUG(("[mouse] Dx=%d Dy=%d", delta_x, delta_y)); + if (delta_x != 0 || delta_y != 0 || delta_z != 0) + BX_DEBUG(("[mouse] Dx=%d Dy=%d Dz=%d", delta_x, delta_y, delta_z)); #endif /* ifdef VERBOSE_KBD_DEBUG */ - if( (delta_x==0) && (delta_y==0) && (BX_KEY_THIS s.mouse.button_status == (button_state & 0x7) ) ) { + if( (delta_x==0) && (delta_y==0) && (delta_z==0) && (BX_KEY_THIS s.mouse.button_status == (button_state & 0x7) ) ) { BX_DEBUG(("Ignoring useless mouse_motion call:\n")); BX_DEBUG(("This should be fixed in the gui code.\n")); return; @@ -1543,9 +1565,12 @@ bx_keyb_c::mouse_motion(int delta_x, int delta_y, unsigned button_state) if(delta_y>255) delta_y=255; if(delta_x<-256) delta_x=-256; if(delta_y<-256) delta_y=-256; + if(delta_z == 120) delta_z = 1; + if(delta_z == 65416) delta_z = -1; BX_KEY_THIS s.mouse.delayed_dx+=delta_x; BX_KEY_THIS s.mouse.delayed_dy+=delta_y; + BX_KEY_THIS s.mouse.delayed_dz+=delta_z; if((BX_KEY_THIS s.mouse.delayed_dx>255)|| (BX_KEY_THIS s.mouse.delayed_dx<-256)|| diff --git a/bochs/iodev/keyboard.h b/bochs/iodev/keyboard.h index 01e493d76..43fa7f4e3 100644 --- a/bochs/iodev/keyboard.h +++ b/bochs/iodev/keyboard.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: keyboard.h,v 1.25 2004-11-30 21:03:16 vruppert Exp $ +// $Id: keyboard.h,v 1.26 2004-12-05 20:23:38 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -46,9 +46,10 @@ #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_PS2 0 +#define MOUSE_TYPE_IMPS2 1 +#define MOUSE_TYPE_SERIAL 2 +#define MOUSE_TYPE_SERIAL_WHEEL 3 class bx_keyb_c : public bx_keyb_stub_c { public: @@ -60,7 +61,7 @@ public: // override stubs from bx_keyb_stub_c virtual void gen_scancode(Bit32u key); virtual void paste_bytes(Bit8u *data, Bit32s length); - virtual void mouse_motion(int delta_x, int delta_y, unsigned button_state); + 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 (); @@ -166,7 +167,9 @@ private: Bit8u button_status; Bit16s delayed_dx; Bit16s delayed_dy; + Bit16s delayed_dz; Bit8u im_request; + bx_bool im_mode; } mouse; struct { @@ -228,7 +231,7 @@ private: BX_KEY_SMF void kbd_enQ_imm(Bit8u val); BX_KEY_SMF void activate_timer(void); BX_KEY_SMF void controller_enQ(Bit8u data, unsigned source); - BX_KEY_SMF bx_bool mouse_enQ_packet(Bit8u b1, Bit8u b2, Bit8u b3) BX_CPP_AttrRegparmN(3); + BX_KEY_SMF bx_bool mouse_enQ_packet(Bit8u b1, Bit8u b2, Bit8u b3, Bit8u b4); BX_KEY_SMF void mouse_enQ(Bit8u mouse_data); static void timer_handler(void *); diff --git a/bochs/iodev/serial.cc b/bochs/iodev/serial.cc index 492fea671..92f529b87 100644 --- a/bochs/iodev/serial.cc +++ b/bochs/iodev/serial.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: serial.cc,v 1.59 2004-12-02 21:34:26 vruppert Exp $ +// $Id: serial.cc,v 1.60 2004-12-05 20:23:39 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2004 MandrakeSoft S.A. @@ -106,6 +106,7 @@ bx_serial_c::init(void) Bit16u ports[BX_SERIAL_MAXDEV] = {0x03f8, 0x02f8, 0x03e8, 0x02e8}; char name[16]; + BX_SER_THIS detect_mouse = 0; BX_SER_THIS mouse_port = -1; BX_SER_THIS mouse_internal_buffer.num_elements = 0; for (int i=0; iget() == MOUSE_TYPE_SERIAL) { + 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.num_elements = 6; + BX_SER_THIS mouse_internal_buffer.buffer[0] = 'M'; + BX_SER_THIS mouse_internal_buffer.buffer[1] = 'Z'; + BX_SER_THIS mouse_internal_buffer.buffer[2] = '@'; + BX_SER_THIS mouse_internal_buffer.buffer[3] = '\0'; + BX_SER_THIS mouse_internal_buffer.buffer[4] = '\0'; + BX_SER_THIS mouse_internal_buffer.buffer[5] = '\0'; + } + BX_SER_THIS detect_mouse = 0; + } } + if (BX_SER_THIS s[port].io_mode == BX_SER_MODE_RAW) { #if USE_RAW_SERIAL if (mcr_changed) { @@ -1003,6 +1020,7 @@ bx_serial_c::tx_timer(void) } else if (timer_id == BX_SER_THIS s[3].tx_timer_index) { port = 3; } + if (BX_SER_THIS s[port].modem_cntl.local_loopback) { rx_fifo_enq(port, BX_SER_THIS s[port].tsrbuffer); } else { @@ -1086,6 +1104,7 @@ bx_serial_c::rx_timer(void) } else if (timer_id == BX_SER_THIS s[3].rx_timer_index) { port = 3; } + int bdrate = BX_SER_THIS s[port].baudrate / (BX_SER_THIS s[port].line_cntl.wordlen_sel + 5); unsigned char chbuf = 0; @@ -1219,9 +1238,9 @@ bx_serial_c::fifo_timer(void) void -bx_serial_c::serial_mouse_enq(int delta_x, int delta_y, unsigned button_state) +bx_serial_c::serial_mouse_enq(int delta_x, int delta_y, int delta_z, unsigned button_state) { - Bit8u b1, b2, mouse_data[3]; + Bit8u b1, b2, b3, mouse_data[4]; int tail; if (BX_SER_THIS mouse_port == -1) { @@ -1242,6 +1261,7 @@ bx_serial_c::serial_mouse_enq(int delta_x, int delta_y, unsigned button_state) BX_SER_THIS mouse_delayed_dx+=delta_x; BX_SER_THIS mouse_delayed_dy-=delta_y; + BX_SER_THIS mouse_delayed_dz+=delta_z; if ((BX_SER_THIS mouse_internal_buffer.num_elements + 3) >= BX_MOUSE_BUFF_SIZE) { return; /* buffer doesn't have the space */ @@ -1267,16 +1287,31 @@ bx_serial_c::serial_mouse_enq(int delta_x, int delta_y, unsigned button_state) 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; 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; mouse_data[2] = b2 & 0x3f; + mouse_data[3] = b3 & 0x0f; + mouse_data[3] |= ((button_state & 0x04) << 2); /* enqueue mouse data in multibyte internal mouse buffer */ - for (int i = 0; i < 3; i++) { + int bytes = 3; + if (bx_options.Omouse_type->get() == MOUSE_TYPE_SERIAL_WHEEL) bytes = 4; + for (int i = 0; i < bytes; i++) { tail = (BX_SER_THIS mouse_internal_buffer.head + BX_SER_THIS mouse_internal_buffer.num_elements) % BX_MOUSE_BUFF_SIZE; BX_SER_THIS mouse_internal_buffer.buffer[tail] = mouse_data[i]; diff --git a/bochs/iodev/serial.h b/bochs/iodev/serial.h index 02015eda3..f01bf48b5 100644 --- a/bochs/iodev/serial.h +++ b/bochs/iodev/serial.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: serial.h,v 1.24 2004-12-02 21:34:26 vruppert Exp $ +// $Id: serial.h,v 1.25 2004-12-05 20:23:39 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2004 MandrakeSoft S.A. @@ -197,14 +197,16 @@ public: ~bx_serial_c(void); virtual void init(void); virtual void reset(unsigned type); - virtual void serial_mouse_enq(int delta_x, int delta_y, unsigned button_state); + virtual void serial_mouse_enq(int delta_x, int delta_y, int delta_z, unsigned button_state); private: bx_serial_t s[BX_SERIAL_MAXDEV]; + int detect_mouse; int mouse_port; int mouse_delayed_dx; int mouse_delayed_dy; + int mouse_delayed_dz; struct { int num_elements; Bit8u buffer[BX_MOUSE_BUFF_SIZE]; diff --git a/bochs/plugin.h b/bochs/plugin.h index 2286719a6..f0eb862c6 100644 --- a/bochs/plugin.h +++ b/bochs/plugin.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: plugin.h,v 1.33 2004-12-02 21:34:25 vruppert Exp $ +// $Id: plugin.h,v 1.34 2004-12-05 20:23:38 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // This file provides macros and types needed for plugins. It is based on @@ -103,7 +103,9 @@ extern "C" { ///////// keyboard macros #define DEV_mouse_motion(dx, dy, state) \ - (bx_devices.pluginKeyboard->mouse_motion(dx, dy, state)) + (bx_devices.pluginKeyboard->mouse_motion(dx, dy, 0, state)) +#define DEV_mouse_motion_ext(dx, dy, dz, state) \ + (bx_devices.pluginKeyboard->mouse_motion(dx, dy, dz, state)) #define DEV_kbd_gen_scancode(key) \ (bx_devices.pluginKeyboard->gen_scancode(key)) #define DEV_kbd_paste_bytes(bytes, count) \ @@ -195,8 +197,8 @@ extern "C" { #define DEV_speaker_beep_off() bx_devices.pluginSpeaker->beep_off() ///////// Serial macro -#define DEV_serial_mouse_enq(dx, dy, state) \ - (bx_devices.pluginSerialDevice->serial_mouse_enq(dx, dy, state)) +#define DEV_serial_mouse_enq(dx, dy, dz, state) \ + (bx_devices.pluginSerialDevice->serial_mouse_enq(dx, dy, dz, state)) //////// Memory macros #define DEV_register_memory_handlers(rh,rp,wh,wp,b,e) \