Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- implemented mouse capture toggle method option in win32.cc
- updated mouse option description and added cpuid options section in the user docs
  • Loading branch information
vruppert committed May 16, 2010
1 parent b1e4b73 commit e92ce51
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 60 deletions.
1 change: 0 additions & 1 deletion .bochsrc
Expand Up @@ -662,7 +662,6 @@ keyboard_paste_delay: 100000
# 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).
# NOTE: currently implemented in the X11, SDL and wxWidgets guis only!
#
# Examples:
# mouse: enabled=1
Expand Down
137 changes: 106 additions & 31 deletions doc/docbook/user/user.dbk
@@ -1,7 +1,7 @@
<!--
================================================================
doc/docbook/user/user.dbk
$Id: user.dbk,v 1.277 2010/04/24 09:36:04 sshwarts Exp $
$Id: user.dbk,v 1.278 2010/05/16 20:44:08 vruppert Exp $

This is the top level file for the Bochs Users Manual.
================================================================
Expand Down Expand Up @@ -2998,11 +2998,6 @@ Reset the CPU when triple fault occur (highly recommended) rather than PANIC.
Remember that if you are trying to continue after triple fault the simulation
will be completely bogus !
</para>
<para><command>cpuid_limit_winnt</command></para>
<para>
Determine whether to limit maximum CPUID function to 3. This mode is required
to workaround WinNT installation and boot issues.
</para>
<para><command>msrs</command></para>
<para>
Define path to user CPU Model Specific Registers (MSRs) specification.
Expand All @@ -3014,16 +3009,6 @@ Ignore MSR references that Bochs does not understand; print a warning message
instead of generating #GP exception. This option is enabled by default but
will not be avaiable if configurable MSRs are enabled.
</para>
<para><command>vendor_string</command></para>
<para>
Set the CPUID vendor string returned by CPUID(0x0). This should be a
twelve-character ASCII string.
</para>
<para><command>brand_string</command></para>
<para>
Set the CPUID brand string returned by CPUID(0x80000002 .. 0x80000004]). This should be
at most a forty-eight-character ASCII string.
</para>
<para><command>ips</command></para>
<para>
Emulated Instructions Per Second. This is the number of IPS that Bochs is
Expand Down Expand Up @@ -3064,6 +3049,82 @@ speed.</para></footnote>.
</table>
</section>

<section><title>cpuid</title>
<para>
Example:
<screen>
cpuid: mmx=1, sep=1, sse=sse4_2, xapic=1, aes=1, movbe=1, xsave=1, cpuid_limit_winnt=0
</screen>
This defines features and functionality supported by Bochs emulated CPU:
</para>
<para><command>mmx</command></para>
<para>
Select MMX instruction set support.
This option exists only if Bochs compiled with BX_CPU_LEVEL >= 5.
</para>
<para><command>sep</command></para>
<para>
Select SYSENTER/SYSEXIT instruction set support.
This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
</para>
<para><command>sse</command></para>
<para>
Select SSE instruction set support.
Any of NONE/SSE/SSE2/SSE3/SSSE3/SSE4_1/SSE4_2 could be selected.
This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
</para>
<para><command>xapic</command></para>
<para>
Select XAPIC extensions support.
This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
</para>
<para><command>aes</command></para>
<para>
Select AES instruction set support.
This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
</para>
<para><command>movbe</command></para>
<para>
Select MOVBE Intel(R) Atom instruction support.
This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
</para>
<para><command>xsave</command></para>
<para>
Select XSAVE extensions support.
This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
</para>
<para><command>1g_pages</command></para>
<para>
Enable 1G page size support in long mode.
This option exists only if Bochs compiled with x86-64 support.
</para>
<para><command>pcid</command></para>
<para>
Enable Process-Context Identifiers (PCID) support in long mode.
This option exists only if Bochs compiled with x86-64 support.
</para>
<para><command>mwait_is_nop</command></para>
<para>
When this option is enabled MWAIT will not put the CPU into a sleep state.
This option exists only if Bochs compiled with --enable-monitor-mwait.
</para>
<para><command>vendor_string</command></para>
<para>
Set the CPUID vendor string returned by CPUID(0x0). This should be a
twelve-character ASCII string.
</para>
<para><command>brand_string</command></para>
<para>
Set the CPUID brand string returned by CPUID(0x80000002 .. 0x80000004]). This should be
at most a forty-eight-character ASCII string.
</para>
<para><command>cpuid_limit_winnt</command></para>
<para>
Determine whether to limit maximum CPUID function to 3. This mode is required
to workaround WinNT installation and boot issues.
</para>
</section>

<section><title>romimage</title>
<para>
Examples:
Expand Down Expand Up @@ -3845,23 +3906,36 @@ Default value are sync=none, time0=local
Examples:
<screen>
mouse: enabled=1
mouse: enabled=1, type=imps2
mouse: enabled=1, type=serial
mouse: enabled=0
mouse: type=imps2, enabled=1
mouse: type=serial, enabled=1
mouse: enabled=0, toggle=ctrl+f10
</screen>
This defines parameters for the emulated mouse type, the initial status
of the mouse capture and the runtime method to toggle it.
</para>
<para><command>type</command></para>
<para>
With the mouse type option you can select the type of mouse to emulate.
The default value is 'ps2'. The other choices are 'imps2' (wheel mouse
on PS/2), 'serial', 'serial_wheel' and 'serial_msys' (one com port requires
setting 'mode=mouse', see <link linkend="bochsopt-com">com option</link>).
To connect a mouse to an USB port, see the <link linkend="bochsopt-usb_uhci">usb_uhci</link>
or 'usb_ohci' option (requires PCI and USB support).
</para>
<para><command>enabled</command></para>
<para>
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 (see <link linkend="headerbar">headerbar</link>).
mouse usage at runtime (see <link linkend="headerbar">headerbar</link>
and the 'toggle' option below).
</para>
<para><command>toggle</command></para>
<para>
With the mouse type option you can select the type of mouse to emulate.
The default value is 'ps2'. The other choices are 'imps2' (wheel mouse
on PS/2), 'serial', 'serial_wheel' and 'serial_msys' (one com port requires
setting 'mode=mouse', see <link linkend="bochsopt-com">com option</link>).
To connect a mouse to an USB port, see the <link linkend="bochsopt-usb_uhci">usb_uhci option</link>
(requires PCI and USB support).
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).
</para>
</section>

Expand Down Expand Up @@ -4911,13 +4985,14 @@ behavoiur of Bochs at runtime if you click on one of these buttons:
<para>
Here you can enable the creation of mouse events by the host. Once mouse
events are captured, you cannot reach the button anymore, in order to disable
capturing again. In this case, use "Ctrl+3rd mouse button" to disable it.
On Win32 Bochs can be configured to use the legacy F12 button to toggle the
mouse capture.
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.
</para>
<para>&FIXME; Support for 2 button mouse to toggle the capture mode not yet complete.
Some display libraries still don't support the new feature, but
it is already supported on X11, SDL, wxWidgets and Win32.</para>
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>
</listitem>
<listitem>
<para>user button</para>
Expand Down
89 changes: 61 additions & 28 deletions gui/win32.cc
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32.cc,v 1.137 2010/02/26 14:18:18 sshwarts Exp $
// $Id: win32.cc,v 1.138 2010/05/16 20:44:08 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2009 The Bochs Project
Expand Down Expand Up @@ -179,9 +179,9 @@ static BOOL gui_debug = FALSE;
static HWND hotKeyReceiver = NULL;
static HWND saveParent = NULL;

static const char *szMouseEnable = "CTRL + 3rd button enables mouse ";
static const char *szMouseDisable = "CTRL + 3rd button disables mouse";
static const char *szMouseTooltip = "Enable mouse capture\nUse CTRL + 3rd button to release";
static char szMouseEnable[40];
static char szMouseDisable[40];
static char szMouseTooltip[64];

static const char szAppName[] = "Bochs for Windows";
static const char szWindowName[] = "Bochs for Windows - Display";
Expand Down Expand Up @@ -637,14 +637,6 @@ void bx_win32_gui_c::specific_init(int argc, char **argv, unsigned
mouseCaptureNew = FALSE;
mouseToggleReq = FALSE;

mouse_buttons = GetSystemMetrics(SM_CMOUSEBUTTONS);
BX_INFO(("Number of Mouse Buttons = %d", mouse_buttons));
if (mouse_buttons == 2) {
szMouseEnable = "CTRL + Lbutton + Rbutton enables mouse ";
szMouseDisable = "CTRL + Lbutton + Rbutton disables mouse";
szMouseTooltip = "Enable mouse capture\nUse CTRL + Lbutton + Rbutton to release";
}

// parse win32 specific options
if (argc > 1) {
for (i = 1; i < argc; i++) {
Expand All @@ -667,9 +659,22 @@ void bx_win32_gui_c::specific_init(int argc, char **argv, unsigned
}

if (legacyF12) {
szMouseEnable = "Press F12 to enable mouse ";
szMouseDisable = "Press F12 to disable mouse";
szMouseTooltip = "Enable mouse capture\nUse F12 to release";
lstrcpy(szMouseEnable, "Press F12 to enable mouse");
lstrcpy(szMouseDisable, "Press F12 to disable mouse");
lstrcpy(szMouseTooltip, "Enable mouse capture\nUse F12 to release");
} else {
mouse_buttons = GetSystemMetrics(SM_CMOUSEBUTTONS);
BX_INFO(("Number of Mouse Buttons = %d", mouse_buttons));
if ((SIM->get_param_enum(BXPN_MOUSE_TOGGLE)->get() == BX_MOUSE_TOGGLE_CTRL_MB) &&
(mouse_buttons == 2)) {
lstrcpy(szMouseEnable, "CTRL + Lbutton + Rbutton enables mouse ");
lstrcpy(szMouseDisable, "CTRL + Lbutton + Rbutton disables mouse");
lstrcpy(szMouseTooltip, "Enable mouse capture\nUse CTRL + Lbutton + Rbutton to release");
} else {
wsprintf(szMouseEnable, "%s enables mouse ", get_toggle_info());
wsprintf(szMouseDisable, "%s disables mouse", get_toggle_info());
wsprintf(szMouseTooltip, "Enable mouse capture\nUse %s to release", get_toggle_info());
}
}

stInfo.hInstance = GetModuleHandle(NULL);
Expand Down Expand Up @@ -1094,6 +1099,7 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
HDC hdc, hdcMem;
PAINTSTRUCT ps;
POINT pt;
bx_bool mouse_toggle = 0;
static BOOL mouseModeChange = FALSE;

switch (iMsg) {
Expand Down Expand Up @@ -1170,11 +1176,14 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
case WM_LBUTTONDBLCLK:
case WM_LBUTTONUP:
if (mouse_buttons == 2) {
if (wParam == (MK_CONTROL | MK_LBUTTON | MK_RBUTTON)) {
mouseCaptureMode = !mouseCaptureMode;
SetMouseCapture();
mouseModeChange = TRUE;
if ((wParam & (MK_LBUTTON | MK_RBUTTON)) == (MK_LBUTTON | MK_RBUTTON)) {
if (bx_gui->mouse_toggle_check(BX_MT_MBUTTON, 1)) {
mouseCaptureMode = !mouseCaptureMode;
SetMouseCapture();
mouseModeChange = TRUE;
}
} else if (mouseModeChange && (iMsg == WM_LBUTTONUP)) {
bx_gui->mouse_toggle_check(BX_MT_MBUTTON, 0);
mouseModeChange = FALSE;
} else {
processMouseXY(LOWORD(lParam), HIWORD(lParam), 0, wParam, 1);
Expand All @@ -1187,11 +1196,14 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
case WM_MBUTTONUP:
if (wParam == (MK_CONTROL | MK_MBUTTON)) {
mouseCaptureMode = !mouseCaptureMode;
SetMouseCapture();
mouseModeChange = TRUE;
if ((wParam & MK_MBUTTON) == MK_MBUTTON) {
if (bx_gui->mouse_toggle_check(BX_MT_MBUTTON, 1)) {
mouseCaptureMode = !mouseCaptureMode;
SetMouseCapture();
mouseModeChange = TRUE;
}
} else if (mouseModeChange && (iMsg == WM_MBUTTONUP)) {
bx_gui->mouse_toggle_check(BX_MT_MBUTTON, 0);
mouseModeChange = FALSE;
} else {
processMouseXY(LOWORD(lParam), HIWORD(lParam), 0, wParam, 4);
Expand All @@ -1202,11 +1214,14 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
case WM_RBUTTONDBLCLK:
case WM_RBUTTONUP:
if (mouse_buttons == 2) {
if (wParam == (MK_CONTROL | MK_LBUTTON | MK_RBUTTON)) {
mouseCaptureMode = !mouseCaptureMode;
SetMouseCapture();
mouseModeChange = TRUE;
if ((wParam & (MK_LBUTTON | MK_RBUTTON)) == (MK_LBUTTON | MK_RBUTTON)) {
if (bx_gui->mouse_toggle_check(BX_MT_MBUTTON, 1)) {
mouseCaptureMode = !mouseCaptureMode;
SetMouseCapture();
mouseModeChange = TRUE;
}
} else if (mouseModeChange && (iMsg == WM_RBUTTONUP)) {
bx_gui->mouse_toggle_check(BX_MT_MBUTTON, 0);
mouseModeChange = FALSE;
} else {
processMouseXY(LOWORD(lParam), HIWORD(lParam), 0, wParam, 2);
Expand All @@ -1229,7 +1244,18 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)

case WM_KEYDOWN:
case WM_SYSKEYDOWN:
if (legacyF12 && (wParam == VK_F12)) {
if (legacyF12) {
if (wParam == VK_F12) {
mouse_toggle = 1;
}
} else if (wParam == VK_CONTROL) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_CTRL, 1);
} else if (wParam == VK_MENU) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_ALT, 1);
} else if (wParam == VK_F10) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_F10, 1);
}
if (mouse_toggle) {
mouseCaptureMode = !mouseCaptureMode;
SetMouseCapture();
return 0;
Expand All @@ -1255,6 +1281,13 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
0, 0, current_bpp);
}
} else {
if (wParam == VK_CONTROL) {
bx_gui->mouse_toggle_check(BX_MT_KEY_CTRL, 0);
} else if (wParam == VK_MENU) {
bx_gui->mouse_toggle_check(BX_MT_KEY_ALT, 0);
} else if (wParam == VK_F10) {
bx_gui->mouse_toggle_check(BX_MT_KEY_F10, 0);
}
EnterCriticalSection(&stInfo.keyCS);
enq_key_event(HIWORD (lParam) & 0x01FF, BX_KEY_RELEASED);
LeaveCriticalSection(&stInfo.keyCS);
Expand Down

0 comments on commit e92ce51

Please sign in to comment.