- standard 2-button serial mouse implemented (with mouse option 'type=serial'
and one com port needs setting 'mode=mouse')
This commit is contained in:
parent
6cc4cd8c4b
commit
301ffc2a7f
@ -384,11 +384,13 @@ debugger_log: -
|
||||
# messing with things, and run bochs in the other window. Serial I/O to
|
||||
# com1 (port 0x3f8) will all go to the other window.
|
||||
# Other serial modes are 'null' (no input/output), 'file' (output to a file
|
||||
# specified as the 'dev' parameter) and 'raw' (use the real serial port - under
|
||||
# construction for win32).
|
||||
# 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')
|
||||
#
|
||||
# Examples:
|
||||
# com1: enabled=1, mode=null
|
||||
# com1: enabled=1, mode=mouse
|
||||
# com2: enabled=1, mode=file, dev=serial.out
|
||||
# com3: enabled=1, mode=raw, dev=com1
|
||||
#=======================================================================
|
||||
@ -507,11 +509,16 @@ floppy_command_delay: 500
|
||||
# You can turn the mouse on by setting enabled to 1, or turn it off by
|
||||
# setting enabled to 0. Unless you have a particular reason for enabling
|
||||
# the mouse by default, it is recommended that you leave it off.
|
||||
# You can also toggle the mouse usage at runtime (middle mouse button on
|
||||
# X11 and SDL, F12 on Win32).
|
||||
# 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').
|
||||
#
|
||||
# Examples:
|
||||
# mouse: enabled=1
|
||||
# mouse: enabled=1, type=imps2
|
||||
# mouse: enabled=1, type=serial
|
||||
# mouse: enabled=0
|
||||
#=======================================================================
|
||||
mouse: enabled=0
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: config.cc,v 1.19 2004-11-30 21:02:56 vruppert Exp $
|
||||
// $Id: config.cc,v 1.20 2004-12-02 21:34:25 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -1146,7 +1146,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'",
|
||||
"The mouse type can be one of these: 'ps2', 'imps2', 'serial'",
|
||||
mouse_type_list,
|
||||
0,
|
||||
0);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: devices.cc,v 1.76 2004-10-03 20:02:09 vruppert Exp $
|
||||
// $Id: devices.cc,v 1.77 2004-12-02 21:34:25 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -75,7 +75,7 @@ bx_devices_c::bx_devices_c(void)
|
||||
pluginFloppyDevice = &stubFloppy;
|
||||
pluginBiosDevice = NULL;
|
||||
pluginCmosDevice = &stubCmos;
|
||||
pluginSerialDevice = NULL;
|
||||
pluginSerialDevice = &stubSerial;
|
||||
pluginParallelDevice = NULL;
|
||||
pluginUnmapped = NULL;
|
||||
pluginVgaDevice = &stubVga;
|
||||
@ -106,7 +106,7 @@ bx_devices_c::init(BX_MEM_C *newmem)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
BX_DEBUG(("Init $Id: devices.cc,v 1.76 2004-10-03 20:02:09 vruppert Exp $"));
|
||||
BX_DEBUG(("Init $Id: devices.cc,v 1.77 2004-12-02 21:34:25 vruppert Exp $"));
|
||||
mem = newmem;
|
||||
|
||||
/* set no-default handlers, will be overwritten by the real default handler */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: iodev.h,v 1.52 2004-09-25 22:15:02 vruppert Exp $
|
||||
// $Id: iodev.h,v 1.53 2004-12-02 21:34:25 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -304,6 +304,13 @@ class BOCHSAPI bx_speaker_stub_c : public bx_devmodel_c {
|
||||
virtual void beep_off() {}
|
||||
};
|
||||
|
||||
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) {
|
||||
STUBFUNC(serial, serial_mouse_enq);
|
||||
}
|
||||
};
|
||||
|
||||
class BOCHSAPI bx_devices_c : public logfunctions {
|
||||
public:
|
||||
bx_devices_c(void);
|
||||
@ -359,7 +366,7 @@ public:
|
||||
bx_dma_stub_c *pluginDmaDevice;
|
||||
bx_floppy_stub_c *pluginFloppyDevice;
|
||||
bx_cmos_stub_c *pluginCmosDevice;
|
||||
bx_devmodel_c *pluginSerialDevice;
|
||||
bx_serial_stub_c *pluginSerialDevice;
|
||||
bx_devmodel_c *pluginParallelDevice;
|
||||
bx_devmodel_c *pluginUnmapped;
|
||||
bx_vga_stub_c *pluginVgaDevice;
|
||||
@ -385,9 +392,10 @@ public:
|
||||
bx_floppy_stub_c stubFloppy;
|
||||
bx_vga_stub_c stubVga;
|
||||
bx_pci_stub_c stubPci;
|
||||
bx_pci2isa_stub_c stubPci2Isa;
|
||||
bx_ne2k_stub_c stubNE2k;
|
||||
bx_pci2isa_stub_c stubPci2Isa;
|
||||
bx_ne2k_stub_c stubNE2k;
|
||||
bx_speaker_stub_c stubSpeaker;
|
||||
bx_serial_stub_c stubSerial;
|
||||
|
||||
// Some info to pass to devices which can handled bulk IO. This allows
|
||||
// the interface to remain the same for IO devices which can't handle
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: keyboard.cc,v 1.91 2004-11-30 21:02:56 vruppert Exp $
|
||||
// $Id: keyboard.cc,v 1.92 2004-12-02 21:34:25 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.91 2004-11-30 21:02:56 vruppert Exp $"));
|
||||
BX_DEBUG(("Init $Id: keyboard.cc,v 1.92 2004-12-02 21:34:25 vruppert Exp $"));
|
||||
Bit32u i;
|
||||
|
||||
DEV_register_irq(1, "8042 Keyboard controller");
|
||||
@ -1500,9 +1500,9 @@ bx_keyb_c::mouse_motion(int delta_x, int delta_y, unsigned button_state)
|
||||
if (bx_options.Omouse_enabled->get () == 0)
|
||||
return;
|
||||
|
||||
|
||||
// redirect mouse data to the serial device
|
||||
if (BX_KEY_THIS s.mouse.type == MOUSE_TYPE_SERIAL) {
|
||||
// TODO: forward mouse motion to the serial device
|
||||
DEV_serial_mouse_enq(delta_x, delta_y, button_state);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1512,7 +1512,6 @@ bx_keyb_c::mouse_motion(int delta_x, int delta_y, unsigned button_state)
|
||||
// so go home.
|
||||
return;
|
||||
|
||||
|
||||
// Note: enable only applies in STREAM MODE.
|
||||
if ( BX_KEY_THIS s.mouse.enable==0 )
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: serial.cc,v 1.58 2004-11-27 10:09:27 vruppert Exp $
|
||||
// $Id: serial.cc,v 1.59 2004-12-02 21:34:26 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2004 MandrakeSoft S.A.
|
||||
@ -106,6 +106,13 @@ bx_serial_c::init(void)
|
||||
Bit16u ports[BX_SERIAL_MAXDEV] = {0x03f8, 0x02f8, 0x03e8, 0x02e8};
|
||||
char name[16];
|
||||
|
||||
BX_SER_THIS mouse_port = -1;
|
||||
BX_SER_THIS mouse_internal_buffer.num_elements = 0;
|
||||
for (int i=0; i<BX_MOUSE_BUFF_SIZE; i++)
|
||||
BX_SER_THIS mouse_internal_buffer.buffer[i] = 0;
|
||||
BX_SER_THIS mouse_internal_buffer.head = 0;
|
||||
BX_SER_THIS mouse_delayed_dx = 0;
|
||||
BX_SER_THIS mouse_delayed_dy = 0;
|
||||
/*
|
||||
* Put the UART registers into their RESET state
|
||||
*/
|
||||
@ -263,6 +270,7 @@ bx_serial_c::init(void)
|
||||
#endif
|
||||
} else if (!strcmp(mode, "mouse")) {
|
||||
BX_SER_THIS s[i].io_mode = BX_SER_MODE_MOUSE;
|
||||
BX_SER_THIS mouse_port = i;
|
||||
} else if (strcmp(mode, "null")) {
|
||||
BX_PANIC(("unknown serial i/o mode"));
|
||||
}
|
||||
@ -804,7 +812,8 @@ bx_serial_c::write(Bit32u address, Bit32u value, unsigned io_len)
|
||||
break;
|
||||
|
||||
case BX_SER_MCR: /* MODEM control register */
|
||||
if (BX_SER_THIS s[port].io_mode == BX_SER_MODE_MOUSE) {
|
||||
if ((BX_SER_THIS s[port].io_mode == BX_SER_MODE_MOUSE) &&
|
||||
(BX_SER_THIS s[port].line_cntl.wordlen_sel == 2)) {
|
||||
detect_mouse = (new_b0 & new_b1);
|
||||
}
|
||||
if (BX_SER_THIS s[port].io_mode == BX_SER_MODE_RAW) {
|
||||
@ -1149,7 +1158,13 @@ bx_serial_c::rx_timer(void)
|
||||
#endif
|
||||
break;
|
||||
case BX_SER_MODE_MOUSE:
|
||||
// TODO: get data from mouse queue
|
||||
if (BX_SER_THIS mouse_internal_buffer.num_elements > 0) {
|
||||
chbuf = BX_SER_THIS mouse_internal_buffer.buffer[BX_SER_THIS mouse_internal_buffer.head];
|
||||
BX_SER_THIS mouse_internal_buffer.head = (BX_SER_THIS mouse_internal_buffer.head + 1) %
|
||||
BX_MOUSE_BUFF_SIZE;
|
||||
BX_SER_THIS mouse_internal_buffer.num_elements--;
|
||||
data_ready = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (data_ready) {
|
||||
@ -1201,3 +1216,70 @@ bx_serial_c::fifo_timer(void)
|
||||
BX_SER_THIS s[port].line_status.rxdata_ready = 1;
|
||||
raise_interrupt(port, BX_SER_INT_FIFO);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bx_serial_c::serial_mouse_enq(int delta_x, int delta_y, unsigned button_state)
|
||||
{
|
||||
Bit8u b1, b2, mouse_data[3];
|
||||
int tail;
|
||||
|
||||
if (BX_SER_THIS mouse_port == -1) {
|
||||
BX_ERROR(("mouse not connected to a serial port"));
|
||||
return;
|
||||
}
|
||||
|
||||
// scale down the motion
|
||||
if ( (delta_x < -1) || (delta_x > 1) )
|
||||
delta_x /= 2;
|
||||
if ( (delta_y < -1) || (delta_y > 1) )
|
||||
delta_y /= 2;
|
||||
|
||||
if(delta_x>127) delta_x=127;
|
||||
if(delta_y>127) delta_y=127;
|
||||
if(delta_x<-128) delta_x=-128;
|
||||
if(delta_y<-128) delta_y=-128;
|
||||
|
||||
BX_SER_THIS mouse_delayed_dx+=delta_x;
|
||||
BX_SER_THIS mouse_delayed_dy-=delta_y;
|
||||
|
||||
if ((BX_SER_THIS mouse_internal_buffer.num_elements + 3) >= BX_MOUSE_BUFF_SIZE) {
|
||||
return; /* buffer doesn't have the space */
|
||||
}
|
||||
|
||||
if (BX_SER_THIS mouse_delayed_dx > 127) {
|
||||
delta_x = 127;
|
||||
BX_SER_THIS mouse_delayed_dx -= 127;
|
||||
} else if (BX_SER_THIS mouse_delayed_dx < -128) {
|
||||
delta_x = -128;
|
||||
BX_SER_THIS mouse_delayed_dx += 128;
|
||||
} else {
|
||||
delta_x = BX_SER_THIS mouse_delayed_dx;
|
||||
BX_SER_THIS mouse_delayed_dx = 0;
|
||||
}
|
||||
if (BX_SER_THIS mouse_delayed_dy > 127) {
|
||||
delta_y = 127;
|
||||
BX_SER_THIS mouse_delayed_dy -= 127;
|
||||
} else if (BX_SER_THIS mouse_delayed_dy < -128) {
|
||||
delta_y = -128;
|
||||
BX_SER_THIS mouse_delayed_dy += 128;
|
||||
} else {
|
||||
delta_y = BX_SER_THIS mouse_delayed_dy;
|
||||
BX_SER_THIS mouse_delayed_dy = 0;
|
||||
}
|
||||
|
||||
b1 = (Bit8u)delta_x;
|
||||
b2 = (Bit8u)delta_y;
|
||||
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;
|
||||
|
||||
/* enqueue mouse data in multibyte internal mouse buffer */
|
||||
for (int i = 0; i < 3; 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];
|
||||
BX_SER_THIS mouse_internal_buffer.num_elements++;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: serial.h,v 1.23 2004-11-27 10:09:41 vruppert Exp $
|
||||
// $Id: serial.h,v 1.24 2004-12-02 21:34:26 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2004 MandrakeSoft S.A.
|
||||
@ -191,16 +191,26 @@ typedef struct {
|
||||
|
||||
|
||||
|
||||
class bx_serial_c : public bx_devmodel_c {
|
||||
class bx_serial_c : public bx_serial_stub_c {
|
||||
public:
|
||||
bx_serial_c(void);
|
||||
~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);
|
||||
|
||||
private:
|
||||
bx_serial_t s[BX_SERIAL_MAXDEV];
|
||||
|
||||
int mouse_port;
|
||||
int mouse_delayed_dx;
|
||||
int mouse_delayed_dy;
|
||||
struct {
|
||||
int num_elements;
|
||||
Bit8u buffer[BX_MOUSE_BUFF_SIZE];
|
||||
int head;
|
||||
} mouse_internal_buffer;
|
||||
|
||||
static void lower_interrupt(Bit8u port);
|
||||
static void raise_interrupt(Bit8u port, int type);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: plugin.h,v 1.32 2004-09-25 22:15:01 vruppert Exp $
|
||||
// $Id: plugin.h,v 1.33 2004-12-02 21:34:25 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This file provides macros and types needed for plugins. It is based on
|
||||
@ -190,10 +190,14 @@ extern "C" {
|
||||
#define DEV_ne2k_print_info(file,page,reg,brief) \
|
||||
bx_devices.pluginNE2kDevice->print_info(file,page,reg,brief)
|
||||
|
||||
///////// Speaker macro
|
||||
///////// Speaker macros
|
||||
#define DEV_speaker_beep_on(frequency) bx_devices.pluginSpeaker->beep_on(frequency)
|
||||
#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))
|
||||
|
||||
//////// Memory macros
|
||||
#define DEV_register_memory_handlers(rh,rp,wh,wp,b,e) \
|
||||
bx_devices.mem->registerMemoryHandlers(rh,rp,wh,wp,b,e)
|
||||
|
Loading…
Reference in New Issue
Block a user