Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- implemented mouse capture toggle method option in wxWidgets
  • Loading branch information
vruppert committed May 16, 2010
1 parent a6fdad4 commit c02426a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .bochsrc
Expand Up @@ -662,7 +662,7 @@ 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 and SDL guis only!
# NOTE: currently implemented in the X11, SDL and wxWidgets guis only!
#
# Examples:
# mouse: enabled=1
Expand Down
41 changes: 28 additions & 13 deletions gui/wx.cc
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wx.cc,v 1.103 2010/02/26 14:18:18 sshwarts Exp $
// $Id: wx.cc,v 1.104 2010/05/16 14:40:53 vruppert Exp $
/////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
Expand Down Expand Up @@ -246,9 +246,13 @@ void MyPanel::OnMouse(wxMouseEvent& event)
}
)

if (event.MiddleDown() && event.ControlDown()) {
ToggleMouse (false);
return;
if (event.MiddleDown()) {
if (bx_gui->mouse_toggle_check(BX_MT_MBUTTON, 1)) {
ToggleMouse(false);
return;
}
} else if (event.MiddleUp()) {
bx_gui->mouse_toggle_check(BX_MT_MBUTTON, 0);
}

if (!mouse_captured)
Expand Down Expand Up @@ -750,26 +754,37 @@ bx_bool MyPanel::fillBxKeyEvent_GTK (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool
#endif
}

bx_bool MyPanel::fillBxKeyEvent (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release)
bx_bool MyPanel::fillBxKeyEvent(wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release)
{
// Use raw codes if they are available. Raw codes are a nonstandard addition
// to the wxWidgets library. At present, the only way to use the "RAW_CODES"
// mode is to apply Bryce's "patch.wx-raw-keycodes" patch to the wxWidgets
// sources and recompile. This patch, or something like it, should appear in
// future wxWidgets versions.
Bit32u key = wxev.m_keyCode;
bx_bool mouse_toggle = 0;

if (key == WXK_CONTROL) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_CTRL, !release);
} else if (key == WXK_ALT) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_ALT, !release);
} else if (key == WXK_F10) {
mouse_toggle = bx_gui->mouse_toggle_check(BX_MT_KEY_F10, !release);
}
if (mouse_toggle) {
ToggleMouse(false);
return false;
}

// Use raw codes if they are available. Raw codes are an addition to the
// wxWidgets library introduced in version 2.3.3.

#if defined (wxHAS_RAW_KEY_CODES) && defined(__WXMSW__)
return fillBxKeyEvent_MSW (wxev, bxev, release);
return fillBxKeyEvent_MSW(wxev, bxev, release);
#endif

#if defined (wxHAS_RAW_KEY_CODES) && defined(__WXGTK__)
return fillBxKeyEvent_GTK (wxev, bxev, release);
return fillBxKeyEvent_GTK(wxev, bxev, release);
#endif

// otherwise fall back to using portable WXK_* keycodes. Not all keys
// can be mapped correctly using WXK_* codes but it should be usable.
IFDBG_KEY (wxLogDebug (wxT ("fillBxKeyEvent. key code %ld", wxev.m_keyCode)));
Bit32u key = wxev.m_keyCode;
Bit32u bx_key;

if(key >= WXK_SPACE && key < WXK_DELETE) {
Expand Down

0 comments on commit c02426a

Please sign in to comment.