Skip to content

Commit

Permalink
Added mouse capture toggle choice "ctrl+alt+g" (currently used by Qemu).
Browse files Browse the repository at this point in the history
  • Loading branch information
vruppert committed Dec 29, 2024
1 parent b8fc94c commit 7af21c2
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 14 deletions.
4 changes: 2 additions & 2 deletions bochs/.bochsrc
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest.bin
# 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), 'ctrl+alt' (like QEMU)
# or 'f12'.
# to change the method to 'ctrl+f10' (like DOSBox), 'ctrl+alt' (legacy QEMU),
# 'ctrl+alt+g' (QEMU current) or 'f12'.
#
# Examples:
# mouse: enabled=1
Expand Down
3 changes: 2 additions & 1 deletion bochs/CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ Detailed change log :
- Debugger gui now updates the memory dump window if necessary
- Added bitmap change support for the wxWidgets toolbar / Improved wxWidgets
toolbar functionality
- Fullscreen mode fixes for the win32 gui
- Fullscreen mode fixes for the legacy SDL and win32 gui
- Fixed SDL2 fullscreen toggle
- SDL/SDL2: Added support for keypad enter key in gui console mode
- Fixed legacy SDL key handling issues
- Scroll lock release now works again (Formerly used as fullscreen toggle)
- Fix Pause / Ctrl+Break key handling (possibly SDL issue)
- Fixed enter key in gui console mode on Android
- Keymap: Added support for using language specifier instead of file name
- Added mouse capture toggle choice "ctrl+alt+g" (currently used by Qemu)

- I/O Devices
- VGA / Bochs VBE support
Expand Down
3 changes: 2 additions & 1 deletion bochs/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1139,12 +1139,13 @@ void bx_init_options()
"ctrl+mbutton",
"ctrl+f10",
"ctrl+alt",
"ctrl+alt+g",
"f12",
NULL
};
toggle = new bx_param_enum_c(mouse,
"toggle", "Mouse toggle method",
"The mouse toggle method can be one of these: 'ctrl+mbutton', 'ctrl+f10', 'ctrl+alt'",
"The mouse toggle method can be one of these: 'ctrl+mbutton', 'ctrl+f10', 'ctrl+alt', 'ctrl+alt+g'",
mouse_toggle_list,
BX_MOUSE_TOGGLE_CTRL_MB,
BX_MOUSE_TOGGLE_CTRL_MB);
Expand Down
4 changes: 2 additions & 2 deletions bochs/doc/docbook/user/user.dbk
Original file line number Diff line number Diff line change
Expand Up @@ -3815,8 +3815,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)
or 'f12'.
to change the method to 'ctrl+f10' (like DOSBox), 'ctrl+alt' (legacy QEMU),
'ctrl+alt+g' (QEMU current) or 'f12'.
</para>
</section>

Expand Down
6 changes: 3 additions & 3 deletions bochs/doc/man/bochsrc.5
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.\"Document Author: Timothy R. Butler - [email protected]"
.TH bochsrc 5 "27 Dec 2024" "bochsrc" "The Bochs Project"
.TH bochsrc 5 "29 Dec 2024" "bochsrc" "The Bochs Project"
.\"SKIP_SECTION"
.SH NAME
bochsrc \- Configuration file for Bochs.
Expand Down Expand Up @@ -464,8 +464,8 @@ 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), 'ctrl+alt' (like QEMU)
or 'f12'.
to change the method to 'ctrl+f10' (like DOSBox), 'ctrl+alt' (legacy QEMU),
'ctrl+alt+g' (QEMU current) or 'f12'.

Examples:
mouse: enabled=1
Expand Down
8 changes: 7 additions & 1 deletion bochs/gui/gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ void bx_gui_c::init(int argc, char **argv, unsigned max_xres, unsigned max_yres,
case BX_MOUSE_TOGGLE_CTRL_ALT:
strcpy(mouse_toggle_text, "CTRL + ALT");
break;
case BX_MOUSE_TOGGLE_CTRL_ALT_G:
strcpy(mouse_toggle_text, "CTRL + ALT + G");
break;
case BX_MOUSE_TOGGLE_F12:
strcpy(mouse_toggle_text, "F12");
break;
Expand Down Expand Up @@ -755,7 +758,10 @@ bool bx_gui_c::mouse_toggle_check(Bit32u key, bool pressed)
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;
toggle = (newstate & BX_GUI_MT_CTRL_ALT_G) == BX_GUI_MT_CTRL_ALT;
break;
case BX_MOUSE_TOGGLE_CTRL_ALT_G:
toggle = (newstate & BX_GUI_MT_CTRL_ALT_G) == BX_GUI_MT_CTRL_ALT_G;
break;
case BX_MOUSE_TOGGLE_F12:
toggle = (newstate == BX_GUI_MT_F12);
Expand Down
8 changes: 5 additions & 3 deletions bochs/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@
#define BX_MT_KEY_ALT 0x02
#define BX_MT_KEY_F10 0x04
#define BX_MT_KEY_F12 0x08
#define BX_MT_MBUTTON 0x10
#define BX_MT_LBUTTON 0x20
#define BX_MT_RBUTTON 0x40
#define BX_MT_KEY_G 0x10
#define BX_MT_MBUTTON 0x20
#define BX_MT_LBUTTON 0x40
#define BX_MT_RBUTTON 0x80

#define BX_GUI_MT_CTRL_MB (BX_MT_KEY_CTRL | BX_MT_MBUTTON)
#define BX_GUI_MT_CTRL_LRB (BX_MT_KEY_CTRL | BX_MT_LBUTTON | BX_MT_RBUTTON)
#define BX_GUI_MT_CTRL_F10 (BX_MT_KEY_CTRL | BX_MT_KEY_F10)
#define BX_GUI_MT_F12 (BX_MT_KEY_F12)
#define BX_GUI_MT_CTRL_ALT (BX_MT_KEY_CTRL | BX_MT_KEY_ALT)
#define BX_GUI_MT_CTRL_ALT_G (BX_MT_KEY_CTRL | BX_MT_KEY_ALT | BX_MT_KEY_G)

// display library option flags
#define BX_GUI_OPT_HIDE_IPS 0x01
Expand Down
4 changes: 3 additions & 1 deletion bochs/gui/rfb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Donald Becker
// http://www.psyon.org
//
// Copyright (C) 2001-2023 The Bochs Project
// Copyright (C) 2001-2024 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -1404,6 +1404,8 @@ void HandleRfbClient(SOCKET sClient)
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);
} else if (ke.key == XK_g) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_G, ke.downFlag);
}
if (mouse_toggle) {
bx_gui->toggle_mouse_enable();
Expand Down
4 changes: 4 additions & 0 deletions bochs/gui/sdl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ void bx_sdl_gui_c::handle_events(void)
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);
} else if (sdl_event.key.keysym.sym == SDLK_g) {
mouse_toggle = mouse_toggle_check(BX_MT_KEY_G, 1);
}
if (mouse_toggle) {
toggle_mouse_enable();
Expand Down Expand Up @@ -914,6 +916,8 @@ void bx_sdl_gui_c::handle_events(void)
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);
} else if (sdl_event.key.keysym.sym == SDLK_g) {
mouse_toggle_check(BX_MT_KEY_G, 0);
}

// filter out release of unsupported keys
Expand Down
4 changes: 4 additions & 0 deletions bochs/gui/sdl2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,8 @@ void bx_sdl2_gui_c::handle_events(void)
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);
} else if (sdl_event.key.keysym.sym == SDLK_g) {
mouse_toggle = mouse_toggle_check(BX_MT_KEY_G, 1);
}
if (mouse_toggle) {
toggle_mouse_enable();
Expand Down Expand Up @@ -890,6 +892,8 @@ void bx_sdl2_gui_c::handle_events(void)
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);
} else if (sdl_event.key.keysym.sym == SDLK_g) {
mouse_toggle_check(BX_MT_KEY_G, 0);
}

// filter out release of Windows/Fullscreen toggle
Expand Down
1 change: 1 addition & 0 deletions bochs/gui/siminterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ enum {
BX_MOUSE_TOGGLE_CTRL_MB,
BX_MOUSE_TOGGLE_CTRL_F10,
BX_MOUSE_TOGGLE_CTRL_ALT,
BX_MOUSE_TOGGLE_CTRL_ALT_G,
BX_MOUSE_TOGGLE_F12
};

Expand Down
2 changes: 2 additions & 0 deletions bochs/gui/vncsrv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,8 @@ void dokey(rfbBool down, rfbKeySym key, rfbClientPtr cl)
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_F10, down);
} else if (key == XK_F12) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_F12, down);
} else if (key == XK_g) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_G, down);
}
if (mouse_toggle) {
bx_gui->toggle_mouse_enable();
Expand Down
4 changes: 4 additions & 0 deletions bochs/gui/win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,8 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_F10, 1);
} else if (wParam == VK_F12) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_F12, 1);
} else if (wParam == 'G') {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_G, 1);
}
if (mouse_toggle) {
mouseCaptureMode = !mouseCaptureMode;
Expand Down Expand Up @@ -1488,6 +1490,8 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
bx_gui->mouse_toggle_check(BX_MT_KEY_F10, 0);
} else if (wParam == VK_F12) {
bx_gui->mouse_toggle_check(BX_MT_KEY_F12, 0);
} else if (wParam == 'G') {
bx_gui->mouse_toggle_check(BX_MT_KEY_G, 0);
}
EnterCriticalSection(&stInfo.keyCS);
enq_key_event(HIWORD (lParam) & 0x01FF, BX_KEY_RELEASED);
Expand Down
2 changes: 2 additions & 0 deletions bochs/gui/wx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,8 @@ bool MyPanel::fillBxKeyEvent(wxKeyEvent& wxev, BxKeyEvent& bxev, bool release)
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_F10, !release);
} else if (key == WXK_F12) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_F12, !release);
} else if (key == 'g') {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_G, !release);
}
if (mouse_toggle) {
ToggleMouse(false);
Expand Down
2 changes: 2 additions & 0 deletions bochs/gui/x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,8 @@ void bx_x_gui_c::xkeypress(KeySym keysym, int press_release)
mouse_toggle = mouse_toggle_check(BX_MT_KEY_F10, !press_release);
} else if (keysym == XK_F12) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_F12, !press_release);
} else if (keysym == XK_g) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_G, !press_release);
}
if (mouse_toggle) {
toggle_mouse_enable();
Expand Down

0 comments on commit 7af21c2

Please sign in to comment.