Skip to content

Commit

Permalink
Started preparing USB debugger support for wxWidgets (Windows port).
Browse files Browse the repository at this point in the history
Toolbar button for USB debugger is now available in wxWidgets, but currently
causes a panic. Moving USB debugger related code from gui.cc and win32config.cc
to siminterface.cc is required to support it in wx.
  • Loading branch information
vruppert committed Jun 16, 2024
1 parent 533e2f7 commit 7abf471
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bochs/gui/siminterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ bx_real_sim_c::bx_real_sim_c()
bxevent_callback_data = NULL;
ci_callback = NULL;
ci_callback_data = NULL;
#if BX_USE_WIN32USBDEBUG
usbi_callback = NULL;
#endif
is_sim_thread_func = NULL;
bx_debug_gui = 0;
bx_log_viewer = 0;
Expand Down
3 changes: 2 additions & 1 deletion bochs/gui/siminterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ typedef enum {
BX_TOOLBAR_SNAPSHOT,
BX_TOOLBAR_CONFIG,
BX_TOOLBAR_MOUSE_EN,
BX_TOOLBAR_USER
BX_TOOLBAR_USER,
BX_TOOLBAR_USB_DEBUG
} bx_toolbar_buttons;

// normally all action choices are available for all event types. The exclude
Expand Down
6 changes: 5 additions & 1 deletion bochs/gui/wx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ void bx_wx_gui_c::specific_init(int argc, char **argv, unsigned headerbar_y)

new_gfx_api = 1;
new_text_api = 1;
dialog_caps = BX_GUI_DLG_USER | BX_GUI_DLG_SNAPSHOT | BX_GUI_DLG_SAVE_RESTORE;
dialog_caps = BX_GUI_DLG_USER | BX_GUI_DLG_SNAPSHOT | BX_GUI_DLG_SAVE_RESTORE | BX_GUI_DLG_USB;
}

void bx_wx_gui_c::handle_events(void)
Expand All @@ -1084,6 +1084,7 @@ void bx_wx_gui_c::handle_events(void)
case BX_TOOLBAR_PASTE: paste_handler(); break;
case BX_TOOLBAR_SNAPSHOT: tb_button = 3; break;
case BX_TOOLBAR_USER: tb_button = 4; break;
case BX_TOOLBAR_USB_DEBUG: tb_button = 5; break;
default:
wxLogDebug (wxT ("unknown toolbar id %d"), event_queue[i].u.toolbar.button);
}
Expand Down Expand Up @@ -1193,6 +1194,9 @@ void bx_wx_gui_c::handle_events(void)
} else if (tb_button == 4) {
// userbutton_handler() also calls a dialog.
userbutton_handler();
} else if (tb_button == 5) {
// usb_handler() also calls a dialog.
usb_handler();
}
}

Expand Down
13 changes: 13 additions & 0 deletions bochs/gui/wxmain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
//#include "bitmaps/configbutton.xpm"
#include "bitmaps/userbutton.xpm"
#include "bitmaps/saverestore.xpm"
#if BX_USE_WIN32USBDEBUG
#include "bitmaps/usb.xpm"
#endif
#ifdef __WXGTK__
#include "icon_bochs.xpm"
#endif
Expand Down Expand Up @@ -344,6 +347,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_TOOL(ID_Toolbar_Snapshot, MyFrame::OnToolbarClick)
EVT_TOOL(ID_Toolbar_Mouse_en, MyFrame::OnToolbarClick)
EVT_TOOL(ID_Toolbar_User, MyFrame::OnToolbarClick)
#if BX_USE_WIN32USBDEBUG
EVT_TOOL(ID_Toolbar_USB_Debug, MyFrame::OnToolbarClick)
#endif
END_EVENT_TABLE()


Expand Down Expand Up @@ -447,6 +453,9 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
BX_ADD_TOOL(ID_Toolbar_Snapshot, snapshot_xpm, wxT("Save screen snapshot"));
BX_ADD_TOOL(ID_Toolbar_Mouse_en, mouse_xpm, wxT("Enable mouse capture\nThere is also a shortcut for this: a CTRL key + the middle mouse button."));
BX_ADD_TOOL(ID_Toolbar_User, userbutton_xpm, wxT("Keyboard shortcut"));
#if BX_USE_WIN32USBDEBUG
BX_ADD_TOOL(ID_Toolbar_USB_Debug, usb_xpm, wxT("USB Debugger"));
#endif

bxToolBar->Realize();
UpdateToolBar(false);
Expand Down Expand Up @@ -862,6 +871,9 @@ void MyFrame::UpdateToolBar(bool simPresent)
} else {
bxToolBar->SetToolShortHelp(ID_Toolbar_SaveRestore, wxT("Restore simulation state"));
}
#if BX_USE_WIN32USBDEBUG
bxToolBar->EnableTool(ID_Toolbar_USB_Debug, simPresent);
#endif
}

void MyFrame::OnStartSim(wxCommandEvent& event)
Expand Down Expand Up @@ -1271,6 +1283,7 @@ void MyFrame::OnToolbarClick(wxCommandEvent& event)
case ID_Toolbar_Snapshot: which = BX_TOOLBAR_SNAPSHOT; break;
case ID_Toolbar_Mouse_en: panel->ToggleMouse(true); break;
case ID_Toolbar_User: which = BX_TOOLBAR_USER; break;
case ID_Toolbar_USB_Debug: which = BX_TOOLBAR_USB_DEBUG; break;
default:
wxLogError(wxT("unknown toolbar id %d"), id);
}
Expand Down
1 change: 1 addition & 0 deletions bochs/gui/wxmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ enum
ID_Toolbar_Mouse_en,
ID_Toolbar_User,
ID_Toolbar_SaveRestore,
ID_Toolbar_USB_Debug,
// dialog box: LogMsgAskDialog
ID_Continue,
ID_Die,
Expand Down

0 comments on commit 7abf471

Please sign in to comment.