Improved USB debugger toolbar handling.

- Added method set_usbdbg_bitmap() to get rid of the public members hack.
- Init toolbar with USB debugger disabled bitmap and switch to active when
  setting up the USB debug type.
- Internally changed bitmap names.
- TODO: add similar functionality for the wx version.
This commit is contained in:
Volker Ruppert 2024-06-28 14:11:15 +02:00
parent 3b826875f6
commit c0706da40c
7 changed files with 24 additions and 27 deletions

View File

@ -5,7 +5,7 @@
#define BX_USB_BMAP_X 32
#define BX_USB_BMAP_Y 32
static const unsigned char bx_usb_bmap[(BX_USB_BMAP_X * BX_USB_BMAP_Y)/8] = {
static const unsigned char bx_usbdbg_bmap[(BX_USB_BMAP_X * BX_USB_BMAP_Y)/8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x03,
0xE0, 0xFF, 0xFF, 0x07, 0xF0, 0x01, 0x80, 0x0F, 0xF0, 0x00, 0x00, 0x0F,
0xF0, 0x01, 0x80, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F,
@ -19,7 +19,7 @@ static const unsigned char bx_usb_bmap[(BX_USB_BMAP_X * BX_USB_BMAP_Y)/8] = {
0xC0, 0xFF, 0xFF, 0x03, 0x80, 0xFF, 0xFF, 0x01
};
static const unsigned char bx_usb_eject_bmap[(BX_USB_BMAP_X * BX_USB_BMAP_Y)/8] = {
static const unsigned char bx_usbdbg_dis_bmap[(BX_USB_BMAP_X * BX_USB_BMAP_Y)/8] = {
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x40, 0xC4, 0xFF, 0xFF, 0x23,
0xE8, 0xFF, 0xFF, 0x17, 0xE0, 0x01, 0x80, 0x07, 0xD0, 0x00, 0x00, 0x0B,
0xB0, 0x01, 0x80, 0x0D, 0x70, 0xFF, 0xFF, 0x0E, 0xF0, 0xFE, 0x7F, 0x0F,
@ -33,7 +33,7 @@ static const unsigned char bx_usb_eject_bmap[(BX_USB_BMAP_X * BX_USB_BMAP_Y)/8]
0xC2, 0xFF, 0xFF, 0x43, 0x80, 0xFF, 0xFF, 0x01
};
static const unsigned char bx_usb_trigger_bmap[(BX_USB_BMAP_X * BX_USB_BMAP_Y)/8] = {
static const unsigned char bx_usbdbg_trigger_bmap[(BX_USB_BMAP_X * BX_USB_BMAP_Y)/8] = {
0x08, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x40, 0xC2, 0xFF, 0xFF, 0x23,
0xE4, 0xFF, 0xFF, 0x47, 0xF8, 0x01, 0x80, 0x8F, 0xF4, 0x00, 0x00, 0x4F,
0xF2, 0x01, 0x80, 0x2F, 0xF4, 0xFF, 0xFF, 0x4F, 0xF8, 0xFF, 0xFF, 0x8F,

View File

@ -1,5 +1,5 @@
/* XPM */
static const char *usb_xpm[] = {
static const char *usbdbg_xpm[] = {
/* width height num_colors chars_per_pixel */
" 32 32 2 1",
/* colors */

View File

@ -237,11 +237,11 @@ void bx_gui_c::init(int argc, char **argv, unsigned max_xres, unsigned max_yres,
BX_SAVE_RESTORE_BMAP_X, BX_SAVE_RESTORE_BMAP_Y);
#if BX_USE_WIN32USBDEBUG
BX_GUI_THIS usb_bmap_id = create_bitmap(bx_usb_bmap,
BX_GUI_THIS usbdbg_bmap_id = create_bitmap(bx_usbdbg_bmap,
BX_USB_BMAP_X, BX_USB_BMAP_Y);
BX_GUI_THIS usb_eject_bmap_id = create_bitmap(bx_usb_eject_bmap,
BX_GUI_THIS usbdbg_dis_bmap_id = create_bitmap(bx_usbdbg_dis_bmap,
BX_USB_BMAP_X, BX_USB_BMAP_Y);
BX_GUI_THIS usb_trigger_bmap_id = create_bitmap(bx_usb_trigger_bmap,
BX_GUI_THIS usbdbg_trigger_bmap_id = create_bitmap(bx_usbdbg_trigger_bmap,
BX_USB_BMAP_X, BX_USB_BMAP_Y);
#endif
@ -276,19 +276,9 @@ void bx_gui_c::init(int argc, char **argv, unsigned max_xres, unsigned max_yres,
#if BX_USE_WIN32USBDEBUG
// USB button
if (BX_GUI_THIS dialog_caps & BX_GUI_DLG_USB) {
if ((SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get() > 0) && (
SIM->get_param_bool(BXPN_UHCI_ENABLED)->get() ||
SIM->get_param_bool(BXPN_OHCI_ENABLED)->get() ||
SIM->get_param_bool(BXPN_EHCI_ENABLED)->get() ||
SIM->get_param_bool(BXPN_XHCI_ENABLED)->get())) {
BX_GUI_THIS usb_hbar_id = headerbar_bitmap(BX_GUI_THIS usb_bmap_id,
BX_GRAVITY_LEFT, usb_handler);
BX_GUI_THIS set_tooltip(BX_GUI_THIS usb_hbar_id, "Trigger the USB Debugger");
} else {
BX_GUI_THIS usb_hbar_id = headerbar_bitmap(BX_GUI_THIS usb_eject_bmap_id,
BX_GRAVITY_LEFT, usb_handler);
BX_GUI_THIS set_tooltip(BX_GUI_THIS usb_hbar_id, "USB support not enabled");
}
BX_GUI_THIS usbdbg_hbar_id = headerbar_bitmap(BX_GUI_THIS usbdbg_dis_bmap_id,
BX_GRAVITY_LEFT, usb_handler);
BX_GUI_THIS set_tooltip(BX_GUI_THIS usbdbg_hbar_id, "USB debugger support not enabled");
}
#endif
@ -724,6 +714,12 @@ void bx_gui_c::usb_handler(void)
SIM->usb_debug_interface(USB_DEBUG_FRAME, 0, 0);
}
}
void bx_gui_c::set_usbdbg_bitmap(bool trigger)
{
set_tooltip(BX_GUI_THIS usbdbg_hbar_id, "Trigger the USB debugger");
replace_bitmap(usbdbg_hbar_id, trigger ? usbdbg_trigger_bmap_id : usbdbg_bmap_id);
}
#endif
void bx_gui_c::toggle_mouse_enable(void)

View File

@ -245,6 +245,9 @@ public:
void set_fullscreen_mode(bool active) {fullscreen_mode = active;}
// marklog handler without button, called in gui command mode
static void marklog_handler(void);
#if BX_USE_WIN32USBDEBUG
void set_usbdbg_bitmap(bool trigger);
#endif
protected:
// And these are defined and used privately in gui.cc
@ -296,10 +299,7 @@ protected:
unsigned user_bmap_id, user_hbar_id;
unsigned save_restore_bmap_id, save_restore_hbar_id;
#if BX_USE_WIN32USBDEBUG
// TODO: this is a lousy hack. we need to keep these protected....
public:
unsigned usb_bmap_id, usb_eject_bmap_id, usb_trigger_bmap_id, usb_hbar_id;
protected:
unsigned usbdbg_bmap_id, usbdbg_dis_bmap_id, usbdbg_trigger_bmap_id, usbdbg_hbar_id;
#endif
// the "classic" Bochs headerbar
unsigned bx_headerbar_entries;

View File

@ -954,6 +954,7 @@ void bx_real_sim_c::register_usb_debug_type(int type)
BX_PANIC(("USB debugger does not yet support type %d", type));
} else {
usb_debug_type = type;
bx_gui->set_usbdbg_bitmap(0);
}
}
}

View File

@ -75,9 +75,9 @@ int win32_usb_interface(int type, int wParam, int lParam)
// if "start_frame" is 2, the HC triggered the debug
if (SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->get() == BX_USB_DEBUG_SOF_SET) {
SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->set(BX_USB_DEBUG_SOF_TRIGGER);
bx_gui->replace_bitmap(bx_gui->usb_hbar_id, bx_gui->usb_trigger_bmap_id);
bx_gui->set_usbdbg_bitmap(1);
} else {
bx_gui->replace_bitmap(bx_gui->usb_hbar_id, bx_gui->usb_bmap_id);
bx_gui->set_usbdbg_bitmap(0);
if (win32_usb_start(GetForegroundWindow(), type, wParam, lParam) < 0) {
bx_user_quit = 1;
#if !BX_DEBUGGER

View File

@ -450,7 +450,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
BX_ADD_TOOL(ID_Edit_Cdrom1, cdrom1_eject_xpm, wxT("Change first CDROM media"));
BX_ADD_TOOL(ID_Toolbar_Mouse_en, mouse_dis_xpm, wxT("Enable mouse capture"));
#if BX_USE_WIN32USBDEBUG
BX_ADD_TOOL(ID_Toolbar_USB_Debug, usb_xpm, wxT("Trigger the USB Debugger"));
BX_ADD_TOOL(ID_Toolbar_USB_Debug, usbdbg_xpm, wxT("Trigger the USB Debugger"));
#endif
bxToolBar->AddSeparator();
BX_ADD_TOOL(ID_Toolbar_User, userbutton_xpm, wxT("Send keyboard shortcut"));