Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- mouse capture toggle option choice 'f12' replaces win32 'legacyF12'…
… option

- implemented mouse capture toggle method option in RFB
- user documentation updates (mouse, usb)
  • Loading branch information
vruppert committed May 18, 2010
1 parent ff39681 commit 791ebff
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 84 deletions.
6 changes: 3 additions & 3 deletions .bochsrc
Expand Up @@ -61,7 +61,6 @@
#display_library: rfb, options="timeout=60" # time to wait for client
#display_library: sdl, options="fullscreen" # startup in fullscreen mode
#display_library: term
#display_library: win32, options="legacyF12" # use F12 to toggle mouse
#display_library: win32, options="gui_debug" # use Win32 debugger gui
#display_library: wx
#display_library: x, options="hideIPS" # disable IPS output in status bar
Expand Down Expand Up @@ -656,12 +655,13 @@ keyboard_paste_delay: 100000
# set to 0. The hardware emulation itself is not disabled by this.
# 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 (X11, SDL, wxWidgets and Win32 - see below).
# usage at runtime (RFB, SDL, Win32, wxWidgets and X11 - see below).
#
# TOGGLE:
# The default method to toggle the mouse capture at runtime is to press the
# CTRL key and the middle mouse button ('ctrl+mbutton'). This option allows
# to change the method to 'ctrl+f10' (like DOSBox) or 'ctrl+alt' (like QEMU).
# to change the method to 'ctrl+f10' (like DOSBox), 'ctrl+alt' (like QEMU)
# or 'f12' (replaces win32 'legacyF12' option).
#
# Examples:
# mouse: enabled=1
Expand Down
3 changes: 2 additions & 1 deletion config.cc
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: config.cc,v 1.204 2010/05/16 09:01:36 vruppert Exp $
// $Id: config.cc,v 1.205 2010/05/18 15:33:41 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2009 The Bochs Project
Expand Down Expand Up @@ -858,6 +858,7 @@ void bx_init_options()
"ctrl+mbutton",
"ctrl+f10",
"ctrl+alt",
"f12",
NULL
};
toggle = new bx_param_enum_c(mouse,
Expand Down
44 changes: 24 additions & 20 deletions doc/docbook/user/user.dbk
@@ -1,7 +1,7 @@
<!--
================================================================
doc/docbook/user/user.dbk
$Id: user.dbk,v 1.278 2010/05/16 20:44:08 vruppert Exp $
$Id: user.dbk,v 1.279 2010/05/18 15:33:41 vruppert Exp $

This is the top level file for the Bochs Users Manual.
================================================================
Expand Down Expand Up @@ -519,9 +519,9 @@ currently work with.
<entry>USB</entry>
<entry>incomplete</entry>
<entry>Two types of host controllers (UHCI and OHCI) and the devices 'mouse',
'tablet', 'keypad', 'disk', 'cdrom' and 'hub' are available. Plugging in and
removing devices at runtime is possible. Access to real hardware is not
implemented yet.
'tablet', 'keypad', 'disk', 'cdrom', 'hub' and 'printer'. are available.
Plugging in and removing devices at runtime is possible. Access to real
hardware is not implemented yet.
</entry>
</row>
<row>
Expand Down Expand Up @@ -3500,7 +3500,6 @@ behaviour. See the examples below for currently supported options.
<screen>
display_library: rfb, options="timeout=60" # time to wait for client
display_library: sdl, options="fullscreen" # startup in fullscreen mode
display_library: win32, options="legacyF12" # use F12 to toggle mouse
display_library: win32, options="gui_debug" # use win32 debugger gui frontend
display_library: x, options="hideIPS" # disable IPS output in status bar
display_library: x, options="gui_debug" # use GTK debugger gui frontend
Expand Down Expand Up @@ -3935,7 +3934,8 @@ and the 'toggle' option below).
<para>
The default method to toggle the mouse capture at runtime is to press the
CTRL key and the middle mouse button ('ctrl+mbutton'). This option allows
to change the method to 'ctrl+f10' (like DOSBox) or 'ctrl+alt' (like QEMU).
to change the method to 'ctrl+f10' (like DOSBox) or 'ctrl+alt' (like QEMU)
or 'f12' (replaces win32 'legacyF12' option).
</para>
</section>

Expand Down Expand Up @@ -4005,8 +4005,8 @@ i440FX PCI chipset.
</para>
<para>
With the port<replaceable>X</replaceable> option you can connect devices
to the hub (currently supported: 'mouse', 'tablet', 'keypad', 'disk', 'cdrom'
and 'hub').
to the hub (currently supported: 'mouse', 'tablet', 'keypad', 'disk', 'cdrom',
'hub' and 'printer').
</para>
<para>
If you connect the mouse or tablet to one of the ports, Bochs forwards the
Expand All @@ -4026,6 +4026,12 @@ to the root hub. To specify the number of ports you have to add the value
separated with a colon. Connecting devices to the external hub ports is only
available in the runtime configuration.
</para>
<para>
The device 'printer' emulates the HP Deskjet 920C printer. The PCL data is
sent to a file specified in bochsrc.txt. The current code appends the PCL
code to the file if the file already existed. It would probably be nice to
overwrite the file instead, asking user first.
</para>
<note><para>
PCI support must be enabled.
</para></note>
Expand Down Expand Up @@ -4941,8 +4947,9 @@ You can also start bochs with the -q option to skip these menus.
2. Read options from...
3. Edit options
4. Save options to...
5. Begin simulation
6. Quit now
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now

Please choose one: [5]
</screen>
Expand Down Expand Up @@ -4987,12 +4994,11 @@ behavoiur of Bochs at runtime if you click on one of these buttons:
events are captured, you cannot reach the button anymore, in order to disable
capturing again. By default you can enable and disable the mouse capture pressing
the CTRL key and the third (middle) mouse button. See the <link linkend="bochsopt-mouse">mouse option</link>
parameter 'toggle' for other methods to toggle the mouse capture. The win32 display
library can be configured to use the legacy F12 key instead.
parameter 'toggle' for other methods to toggle the mouse capture.
</para>
<para>&FIXME; Support for 2 button mouse to toggle the capture mode not yet complete.
Some display libraries still don't support changing the mouse capture at runtime,
but it is already supported on X11, SDL, wxWidgets and Win32.</para>
but it is already supported on RFB, SDL, Win32, wxWidgets and X11.</para>
</listitem>
<listitem>
<para>user button</para>
Expand Down Expand Up @@ -5061,13 +5067,11 @@ Bochs Runtime Options
7. (not implemented)
8. Log options for all devices
9. Log options for individual devices
10. VGA Update Interval: 100000
11. Mouse: disabled
12. Keyboard paste delay: 100000
13. Userbutton shortcut: ctrlaltdel
14. Instruction tracing: off (doesn't exist yet)
15. Continue simulation
16. Quit now
10. Instruction tracing: off (doesn't exist yet)
11. USB runtime options
12. Misc runtime options
13. Continue simulation
14. Quit now

Please choose one: [15]
</screen>
Expand Down
7 changes: 4 additions & 3 deletions doc/man/bochsrc.5
@@ -1,5 +1,5 @@
.\"Document Author: Timothy R. Butler - tbutler@uninetsolutions.com"
.TH bochsrc 5 "16 May 2010" "bochsrc" "The Bochs Project"
.TH bochsrc 5 "18 May 2010" "bochsrc" "The Bochs Project"
.\"SKIP_SECTION"
.SH NAME
bochsrc \- Configuration file for Bochs.
Expand Down Expand Up @@ -740,13 +740,14 @@ The Bochs gui creates mouse "events" unless the 'enabled' option is
set to 0. The hardware emulation itself is not disabled by this.
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 (X11, SDL, wxWidgets and Win32 - see below).
usage at runtime (RFB, SDL, Win32, wxWidgets and X11 - see below).

toggle

The default method to toggle the mouse capture at runtime is to press the
CTRL key and the middle mouse button ('ctrl+mbutton'). This option allows
to change the method to 'ctrl+f10' (like DOSBox) or 'ctrl+alt' (like QEMU).
to change the method to 'ctrl+f10' (like DOSBox), 'ctrl+alt' (like QEMU)
or 'f12' (replaces win32 'legacyF12' option).

Examples:
mouse: enabled=1
Expand Down
10 changes: 9 additions & 1 deletion gui/gui.cc
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.115 2010/05/16 09:01:36 vruppert Exp $
// $Id: gui.cc,v 1.116 2010/05/18 15:33:41 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2009 The Bochs Project
Expand Down Expand Up @@ -128,6 +128,8 @@ void bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheig
break;
case BX_MOUSE_TOGGLE_CTRL_ALT:
strcpy(mouse_toggle_text, "CTRL + ALT");
case BX_MOUSE_TOGGLE_F12:
strcpy(mouse_toggle_text, "F12");
break;
}

Expand Down Expand Up @@ -538,13 +540,19 @@ bx_bool bx_gui_c::mouse_toggle_check(Bit32u key, bx_bool pressed)
switch (toggle_method) {
case BX_MOUSE_TOGGLE_CTRL_MB:
toggle = (newstate & BX_GUI_MT_CTRL_MB) == BX_GUI_MT_CTRL_MB;
if (!toggle) {
toggle = (newstate & BX_GUI_MT_CTRL_LRB) == BX_GUI_MT_CTRL_LRB;
}
break;
case BX_MOUSE_TOGGLE_CTRL_F10:
toggle = (newstate & BX_GUI_MT_CTRL_F10) == BX_GUI_MT_CTRL_F10;
break;
case BX_MOUSE_TOGGLE_CTRL_ALT:
toggle = (newstate & BX_GUI_MT_CTRL_ALT) == BX_GUI_MT_CTRL_ALT;
break;
case BX_MOUSE_TOGGLE_F12:
toggle = (newstate == BX_GUI_MT_F12);
break;
}
toggle_keystate = newstate;
} else {
Expand Down
13 changes: 10 additions & 3 deletions gui/gui.h
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.h,v 1.63 2010/05/16 09:01:36 vruppert Exp $
// $Id: gui.h,v 1.64 2010/05/18 15:33:41 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2009 The Bochs Project
Expand Down Expand Up @@ -28,17 +28,24 @@
#define BX_GUI_DLG_SAVE_RESTORE 0x20
#define BX_GUI_DLG_ALL 0x3F

// text mode blink feature
#define BX_TEXT_BLINK_MODE 0x01
#define BX_TEXT_BLINK_TOGGLE 0x02
#define BX_TEXT_BLINK_STATE 0x04

// mouse capture toggle feature
#define BX_MT_KEY_CTRL 0x01
#define BX_MT_KEY_ALT 0x02
#define BX_MT_KEY_F10 0x04
#define BX_MT_MBUTTON 0x08
#define BX_MT_KEY_F12 0x08
#define BX_MT_MBUTTON 0x10
#define BX_MT_LBUTTON 0x20
#define BX_MT_RBUTTON 0x40

#define BX_GUI_MT_CTRL_MB 0x09
#define BX_GUI_MT_CTRL_MB 0x11
#define BX_GUI_MT_CTRL_LRB 0x61
#define BX_GUI_MT_CTRL_F10 0x05
#define BX_GUI_MT_F12 0x08
#define BX_GUI_MT_CTRL_ALT 0x03

typedef struct {
Expand Down
56 changes: 38 additions & 18 deletions gui/rfb.cc
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: rfb.cc,v 1.67 2010/02/26 14:18:18 sshwarts Exp $
// $Id: rfb.cc,v 1.68 2010/05/18 15:33:41 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2000 Psyon.Org!
Expand Down Expand Up @@ -439,6 +439,7 @@ void HandleRfbClient(SOCKET sClient)
U32 auth;
rfbClientInitMessage cim;
rfbServerInitMessage sim;
bx_bool mouse_toggle = 0;

client_connected = true;
setsockopt(sClient, IPPROTO_TCP, TCP_NODELAY, (const char *)&one, sizeof(one));
Expand Down Expand Up @@ -610,30 +611,49 @@ void HandleRfbClient(SOCKET sClient)
ReadExact(sClient, (char *)&ke, sizeof(rfbKeyEventMessage));
ke.key = ntohl(ke.key);
while(bKeyboardInUse);
bKeyboardInUse = true;
if (rfbKeyboardEvents >= MAX_KEY_EVENTS) break;
rfbKeyboardEvent[rfbKeyboardEvents].type = KEYBOARD;
rfbKeyboardEvent[rfbKeyboardEvents].key = ke.key;
rfbKeyboardEvent[rfbKeyboardEvents].down = ke.downFlag;
rfbKeyboardEvents++;
bKeyboardInUse = false;

if ((ke.key == XK_Control_L) || (ke.key == XK_Control_R)) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_CTRL, ke.downFlag);
} else if (ke.key == XK_Alt_L) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_ALT, ke.downFlag);
} else if (ke.key == XK_F10) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_F10, ke.downFlag);
} else if (ke.key == XK_F12) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_F12, ke.downFlag);
}
if (mouse_toggle) {
bx_gui->toggle_mouse_enable();
} else {
bKeyboardInUse = true;
if (rfbKeyboardEvents >= MAX_KEY_EVENTS) break;
rfbKeyboardEvent[rfbKeyboardEvents].type = KEYBOARD;
rfbKeyboardEvent[rfbKeyboardEvents].key = ke.key;
rfbKeyboardEvent[rfbKeyboardEvents].down = ke.downFlag;
rfbKeyboardEvents++;
bKeyboardInUse = false;
}
break;
}
case rfbPointerEvent:
{
rfbPointerEventMessage pe;
ReadExact(sClient, (char *)&pe, sizeof(rfbPointerEventMessage));
while(bKeyboardInUse);
bKeyboardInUse = true;
if (rfbKeyboardEvents >= MAX_KEY_EVENTS) break;
rfbKeyboardEvent[rfbKeyboardEvents].type = MOUSE;
rfbKeyboardEvent[rfbKeyboardEvents].x = ntohs(pe.xPosition);
rfbKeyboardEvent[rfbKeyboardEvents].y = ntohs(pe.yPosition);
rfbKeyboardEvent[rfbKeyboardEvents].down = (pe.buttonMask & 0x01) |
((pe.buttonMask>>1) & 0x02) |
((pe.buttonMask<<1) & 0x04);
rfbKeyboardEvents++;
bKeyboardInUse = false;

if (bx_gui->mouse_toggle_check(BX_MT_MBUTTON, (pe.buttonMask & 0x02) > 0)) {
bx_gui->toggle_mouse_enable();
} else {
bKeyboardInUse = true;
if (rfbKeyboardEvents >= MAX_KEY_EVENTS) break;
rfbKeyboardEvent[rfbKeyboardEvents].type = MOUSE;
rfbKeyboardEvent[rfbKeyboardEvents].x = ntohs(pe.xPosition);
rfbKeyboardEvent[rfbKeyboardEvents].y = ntohs(pe.yPosition);
rfbKeyboardEvent[rfbKeyboardEvents].down = (pe.buttonMask & 0x01) |
((pe.buttonMask>>1) & 0x02) |
((pe.buttonMask<<1) & 0x04);
rfbKeyboardEvents++;
bKeyboardInUse = false;
}
break;
}
case rfbClientCutText:
Expand Down
6 changes: 5 additions & 1 deletion gui/sdl.cc
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: sdl.cc,v 1.90 2010/05/16 09:01:36 vruppert Exp $
// $Id: sdl.cc,v 1.91 2010/05/18 15:33:41 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2009 The Bochs Project
Expand Down Expand Up @@ -1070,6 +1070,8 @@ void bx_sdl_gui_c::handle_events(void)
mouse_toggle = mouse_toggle_check(BX_MT_KEY_ALT, 1);
} else if (sdl_event.key.keysym.sym == SDLK_F10) {
mouse_toggle = mouse_toggle_check(BX_MT_KEY_F10, 1);
} else if (sdl_event.key.keysym.sym == SDLK_F12) {
mouse_toggle = mouse_toggle_check(BX_MT_KEY_F12, 1);
}
if (mouse_toggle) {
toggle_mouse_enable();
Expand Down Expand Up @@ -1122,6 +1124,8 @@ void bx_sdl_gui_c::handle_events(void)
mouse_toggle_check(BX_MT_KEY_ALT, 0);
} else if (sdl_event.key.keysym.sym == SDLK_F10) {
mouse_toggle_check(BX_MT_KEY_F10, 0);
} else if (sdl_event.key.keysym.sym == SDLK_F12) {
mouse_toggle_check(BX_MT_KEY_F12, 0);
}

// filter out release of Windows/Fullscreen toggle and unsupported keys
Expand Down
5 changes: 3 additions & 2 deletions gui/siminterface.h
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.252 2010/05/16 09:01:36 vruppert Exp $
// $Id: siminterface.h,v 1.253 2010/05/18 15:33:41 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
Expand Down Expand Up @@ -907,7 +907,8 @@ enum {
enum {
BX_MOUSE_TOGGLE_CTRL_MB,
BX_MOUSE_TOGGLE_CTRL_F10,
BX_MOUSE_TOGGLE_CTRL_ALT
BX_MOUSE_TOGGLE_CTRL_ALT,
BX_MOUSE_TOGGLE_F12
};

#define BX_FDD_NONE 0 // floppy not present
Expand Down

0 comments on commit 791ebff

Please sign in to comment.