From 8feabb00d6e5db792f9ae5ac469f16baf815ef88 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 12 Apr 2014 21:31:59 -0400 Subject: [PATCH] Correct event handlers to trigger in all instnces Some events don't propagate correctly to the right sub-window and some things like the pad handler don't even necessarily have windows. So, just register some events with the top-level app. Also add a virtual destructor to the PadHandlerBase to be able to deal with multiple inheritance in the derived classes. --- rpcs3/CMakeLists.txt | 1 - rpcs3/Emu/Io/Windows/WindowsKeyboardHandler.h | 4 +- rpcs3/Emu/Io/Windows/WindowsMouseHandler.h | 16 +-- rpcs3/Emu/Io/Windows/WindowsPadHandler.h | 4 +- rpcs3/Gui/Debugger.cpp | 2 +- rpcs3/Gui/InterpreterDisAsm.cpp | 2 +- rpcs3/Gui/MainFrame.cpp | 136 +++++++++--------- rpcs3/Gui/PADManager.cpp | 4 +- rpcs3/rpcs3.cpp | 2 +- rpcs3/rpcs3.h | 2 +- 10 files changed, 86 insertions(+), 87 deletions(-) diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 9db0112871..68ef012f69 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -70,7 +70,6 @@ endforeach() file( GLOB_RECURSE RPCS3_SRC -<<<<<<< HEAD "${RPCS3_SRC_DIR}/rpcs3.cpp" "${RPCS3_SRC_DIR}/Ini.cpp" "${RPCS3_SRC_DIR}/Emu/*" diff --git a/rpcs3/Emu/Io/Windows/WindowsKeyboardHandler.h b/rpcs3/Emu/Io/Windows/WindowsKeyboardHandler.h index e614b5682d..3ecb827d4b 100644 --- a/rpcs3/Emu/Io/Windows/WindowsKeyboardHandler.h +++ b/rpcs3/Emu/Io/Windows/WindowsKeyboardHandler.h @@ -11,8 +11,8 @@ class WindowsKeyboardHandler final public: WindowsKeyboardHandler() : wxWindow() { - Bind(wxEVT_KEY_DOWN, &WindowsKeyboardHandler::KeyDown, this); - Bind(wxEVT_KEY_UP, &WindowsKeyboardHandler::KeyUp, this); + wxGetApp().Bind(wxEVT_KEY_DOWN, &WindowsKeyboardHandler::KeyDown, this); + wxGetApp().Bind(wxEVT_KEY_UP, &WindowsKeyboardHandler::KeyUp, this); } virtual void KeyDown(wxKeyEvent& event) { Key(event.GetKeyCode(), 1); event.Skip(); } diff --git a/rpcs3/Emu/Io/Windows/WindowsMouseHandler.h b/rpcs3/Emu/Io/Windows/WindowsMouseHandler.h index 54f6a16560..06f095e9b4 100644 --- a/rpcs3/Emu/Io/Windows/WindowsMouseHandler.h +++ b/rpcs3/Emu/Io/Windows/WindowsMouseHandler.h @@ -10,14 +10,14 @@ class WindowsMouseHandler final public: WindowsMouseHandler() : wxWindow() { - Bind(wxEVT_LEFT_DOWN, &WindowsMouseHandler::MouseButtonDown, this); - Bind(wxEVT_RIGHT_DOWN, &WindowsMouseHandler::MouseButtonDown, this); - Bind(wxEVT_MIDDLE_DOWN, &WindowsMouseHandler::MouseButtonDown, this); - Bind(wxEVT_LEFT_UP, &WindowsMouseHandler::MouseButtonUp, this); - Bind(wxEVT_RIGHT_UP, &WindowsMouseHandler::MouseButtonUp, this); - Bind(wxEVT_MIDDLE_UP, &WindowsMouseHandler::MouseButtonUp, this); - Bind(wxEVT_MOUSEWHEEL, &WindowsMouseHandler::MouseScroll, this); - Bind(wxEVT_MOTION, &WindowsMouseHandler::MouseMove, this); + wxGetApp().Bind(wxEVT_LEFT_DOWN, &WindowsMouseHandler::MouseButtonDown, this); + wxGetApp().Bind(wxEVT_RIGHT_DOWN, &WindowsMouseHandler::MouseButtonDown, this); + wxGetApp().Bind(wxEVT_MIDDLE_DOWN, &WindowsMouseHandler::MouseButtonDown, this); + wxGetApp().Bind(wxEVT_LEFT_UP, &WindowsMouseHandler::MouseButtonUp, this); + wxGetApp().Bind(wxEVT_RIGHT_UP, &WindowsMouseHandler::MouseButtonUp, this); + wxGetApp().Bind(wxEVT_MIDDLE_UP, &WindowsMouseHandler::MouseButtonUp, this); + wxGetApp().Bind(wxEVT_MOUSEWHEEL, &WindowsMouseHandler::MouseScroll, this); + wxGetApp().Bind(wxEVT_MOTION, &WindowsMouseHandler::MouseMove, this); } virtual void MouseButtonDown(wxMouseEvent& event) diff --git a/rpcs3/Emu/Io/Windows/WindowsPadHandler.h b/rpcs3/Emu/Io/Windows/WindowsPadHandler.h index 93311b6d5e..74f8e2ee4f 100644 --- a/rpcs3/Emu/Io/Windows/WindowsPadHandler.h +++ b/rpcs3/Emu/Io/Windows/WindowsPadHandler.h @@ -10,8 +10,8 @@ class WindowsPadHandler final public: WindowsPadHandler() : wxWindow() { - Bind(wxEVT_KEY_DOWN, &WindowsPadHandler::KeyDown, this); - Bind(wxEVT_KEY_UP, &WindowsPadHandler::KeyUp, this); + wxGetApp().Bind(wxEVT_KEY_DOWN, &WindowsPadHandler::KeyDown, this); + wxGetApp().Bind(wxEVT_KEY_UP, &WindowsPadHandler::KeyUp, this); } virtual void KeyDown(wxKeyEvent& event) { Key(event.GetKeyCode(), 1); event.Skip(); } diff --git a/rpcs3/Gui/Debugger.cpp b/rpcs3/Gui/Debugger.cpp index f3e5741688..2e80468ecc 100644 --- a/rpcs3/Gui/Debugger.cpp +++ b/rpcs3/Gui/Debugger.cpp @@ -33,7 +33,7 @@ public: Layout(); UpdateUI(); - Bind(wxEVT_DBG_COMMAND, &DbgEmuPanel::HandleCommand, this); + wxGetApp().Bind(wxEVT_DBG_COMMAND, &DbgEmuPanel::HandleCommand, this); } void UpdateUI() diff --git a/rpcs3/Gui/InterpreterDisAsm.cpp b/rpcs3/Gui/InterpreterDisAsm.cpp index 85f0f46c8b..81687fd519 100644 --- a/rpcs3/Gui/InterpreterDisAsm.cpp +++ b/rpcs3/Gui/InterpreterDisAsm.cpp @@ -89,7 +89,7 @@ InterpreterDisAsmFrame::InterpreterDisAsmFrame(wxWindow* parent) Bind(wxEVT_SIZE, &InterpreterDisAsmFrame::OnResize, this); Bind(wxEVT_KEY_DOWN, &InterpreterDisAsmFrame::OnKeyDown, this); - Bind(wxEVT_DBG_COMMAND, &InterpreterDisAsmFrame::HandleCommand, this); + wxGetApp().Bind(wxEVT_DBG_COMMAND, &InterpreterDisAsmFrame::HandleCommand, this); ShowAddr(CentrePc(PC)); UpdateUnitList(); diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 93fc4a6453..ab5ce3c3e6 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -60,43 +60,43 @@ MainFrame::MainFrame() SetLabel(wxString::Format(_PRGNAME_ " " _PRGVER_)); #endif - wxMenuBar& menubar(*new wxMenuBar()); + wxMenuBar* menubar = new wxMenuBar(); - wxMenu& menu_boot(*new wxMenu()); - menubar.Append(&menu_boot, "Boot"); - menu_boot.Append(id_boot_game, "Boot game"); - menu_boot.Append(id_install_pkg, "Install PKG"); - menu_boot.AppendSeparator(); - menu_boot.Append(id_boot_elf, "Boot (S)ELF"); + wxMenu* menu_boot = new wxMenu(); + menubar->Append(menu_boot, "Boot"); + menu_boot->Append(id_boot_game, "Boot game"); + menu_boot->Append(id_install_pkg, "Install PKG"); + menu_boot->AppendSeparator(); + menu_boot->Append(id_boot_elf, "Boot (S)ELF"); - wxMenu& menu_sys(*new wxMenu()); - menubar.Append(&menu_sys, "System"); - menu_sys.Append(id_sys_pause, "Pause")->Enable(false); - menu_sys.Append(id_sys_stop, "Stop\tCtrl + S")->Enable(false); - menu_sys.AppendSeparator(); - menu_sys.Append(id_sys_send_open_menu, "Send open system menu cmd")->Enable(false); - menu_sys.Append(id_sys_send_exit, "Send exit cmd")->Enable(false); + wxMenu* menu_sys = new wxMenu(); + menubar->Append(menu_sys, "System"); + menu_sys->Append(id_sys_pause, "Pause")->Enable(false); + menu_sys->Append(id_sys_stop, "Stop\tCtrl + S")->Enable(false); + menu_sys->AppendSeparator(); + menu_sys->Append(id_sys_send_open_menu, "Send open system menu cmd")->Enable(false); + menu_sys->Append(id_sys_send_exit, "Send exit cmd")->Enable(false); - wxMenu& menu_conf(*new wxMenu()); - menubar.Append(&menu_conf, "Config"); - menu_conf.Append(id_config_emu, "Settings"); - menu_conf.Append(id_config_pad, "PAD Settings"); - menu_conf.AppendSeparator(); - menu_conf.Append(id_config_vfs_manager, "Virtual File System Manager"); - menu_conf.Append(id_config_vhdd_manager, "Virtual HDD Manager"); + wxMenu* menu_conf = new wxMenu(); + menubar->Append(menu_conf, "Config"); + menu_conf->Append(id_config_emu, "Settings"); + menu_conf->Append(id_config_pad, "PAD Settings"); + menu_conf->AppendSeparator(); + menu_conf->Append(id_config_vfs_manager, "Virtual File System Manager"); + menu_conf->Append(id_config_vhdd_manager, "Virtual HDD Manager"); - wxMenu& menu_tools(*new wxMenu()); - menubar.Append(&menu_tools, "Tools"); - menu_tools.Append(id_tools_compiler, "ELF Compiler"); - menu_tools.Append(id_tools_memory_viewer, "Memory Viewer"); - menu_tools.Append(id_tools_rsx_debugger, "RSX Debugger"); - menu_tools.Append(id_tools_fnid_generator, "FunctionID Generator"); + wxMenu* menu_tools = new wxMenu(); + menubar->Append(menu_tools, "Tools"); + menu_tools->Append(id_tools_compiler, "ELF Compiler"); + menu_tools->Append(id_tools_memory_viewer, "Memory Viewer"); + menu_tools->Append(id_tools_rsx_debugger, "RSX Debugger"); + menu_tools->Append(id_tools_fnid_generator, "FunctionID Generator"); - wxMenu& menu_help(*new wxMenu()); - menubar.Append(&menu_help, "Help"); - menu_help.Append(id_help_about, "About..."); + wxMenu* menu_help = new wxMenu(); + menubar->Append(menu_help, "Help"); + menu_help->Append(id_help_about, "About..."); - SetMenuBar(&menubar); + SetMenuBar(menubar); // Panels m_game_viewer = new GameViewer(this); @@ -108,31 +108,31 @@ MainFrame::MainFrame() AddPane(m_debugger_frame, "Debugger", wxAUI_DOCK_RIGHT); // Events - Connect( id_boot_game, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootGame) ); - Connect( id_install_pkg, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::InstallPkg) ); - Connect( id_boot_elf, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootElf) ); + Bind(wxEVT_MENU, &MainFrame::BootGame, this, id_boot_game); + Bind(wxEVT_MENU, &MainFrame::InstallPkg, this, id_install_pkg); + Bind(wxEVT_MENU, &MainFrame::BootElf, this, id_boot_elf); - Connect( id_sys_pause, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Pause) ); - Connect( id_sys_stop, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Stop) ); - Connect( id_sys_send_open_menu, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::SendOpenCloseSysMenu) ); - Connect( id_sys_send_exit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::SendExit) ); + Bind(wxEVT_MENU, &MainFrame::Pause, this, id_sys_pause); + Bind(wxEVT_MENU, &MainFrame::Stop, this, id_sys_stop); + Bind(wxEVT_MENU, &MainFrame::SendOpenCloseSysMenu, this, id_sys_send_open_menu); + Bind(wxEVT_MENU, &MainFrame::SendExit, this, id_sys_send_exit); - Connect( id_config_emu, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Config) ); - Connect( id_config_pad, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::ConfigPad) ); - Connect( id_config_vfs_manager, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::ConfigVFS) ); - Connect( id_config_vhdd_manager, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::ConfigVHDD) ); + Bind(wxEVT_MENU, &MainFrame::Config, this, id_config_emu); + Bind(wxEVT_MENU, &MainFrame::ConfigPad, this, id_config_pad); + Bind(wxEVT_MENU, &MainFrame::ConfigVFS, this, id_config_vfs_manager); + Bind(wxEVT_MENU, &MainFrame::ConfigVHDD, this, id_config_vhdd_manager); - Connect( id_tools_compiler, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenELFCompiler)); - Connect( id_tools_memory_viewer, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenMemoryViewer)); - Connect( id_tools_rsx_debugger, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenRSXDebugger)); - Connect(id_tools_fnid_generator, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenFnIdGenerator)); + Bind(wxEVT_MENU, &MainFrame::OpenELFCompiler, this, id_tools_compiler); + Bind(wxEVT_MENU, &MainFrame::OpenMemoryViewer, this, id_tools_memory_viewer); + Bind(wxEVT_MENU, &MainFrame::OpenRSXDebugger, this, id_tools_rsx_debugger); + Bind(wxEVT_MENU, &MainFrame::OpenFnIdGenerator, this, id_tools_fnid_generator); - Connect( id_help_about, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::AboutDialogHandler) ); + Bind(wxEVT_MENU, &MainFrame::AboutDialogHandler, this, id_help_about); - Connect( id_update_dbg, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::UpdateUI) ); + Bind(wxEVT_MENU, &MainFrame::UpdateUI, this, id_update_dbg); - m_app_connector.Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(MainFrame::OnKeyDown), (wxObject*)0, this); - m_app_connector.Connect(wxEVT_DBG_COMMAND, wxCommandEventHandler(MainFrame::UpdateUI), (wxObject*)0, this); + Bind(wxEVT_KEY_DOWN, &MainFrame::OnKeyDown, this); + wxGetApp().Bind(wxEVT_DBG_COMMAND, &MainFrame::UpdateUI, this); } MainFrame::~MainFrame() @@ -187,7 +187,7 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event)) } else { - ConLog.Error("Ps3 executable not found in selected folder (%s)", ctrl.GetPath().wx_str()); + ConLog.Error("PS3 executable not found in selected folder (%s)", ctrl.GetPath().wx_str()); } } @@ -326,35 +326,35 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) nb_config->AddPage(p_hle, wxT("HLE / Misc.")); nb_config->AddPage(p_system, wxT("System")); - wxBoxSizer* s_subpanel_system(new wxBoxSizer(wxVERTICAL)); - wxBoxSizer* s_subpanel_cpu(new wxBoxSizer(wxVERTICAL)); - wxBoxSizer* s_subpanel_graphics(new wxBoxSizer(wxVERTICAL)); - wxBoxSizer* s_subpanel_audio(new wxBoxSizer(wxVERTICAL)); - wxBoxSizer* s_subpanel_io(new wxBoxSizer(wxVERTICAL)); - wxBoxSizer* s_subpanel_hle(new wxBoxSizer(wxVERTICAL)); + wxBoxSizer* s_subpanel_system = new wxBoxSizer(wxVERTICAL); + wxBoxSizer* s_subpanel_cpu = new wxBoxSizer(wxVERTICAL); + wxBoxSizer* s_subpanel_graphics = new wxBoxSizer(wxVERTICAL); + wxBoxSizer* s_subpanel_audio = new wxBoxSizer(wxVERTICAL); + wxBoxSizer* s_subpanel_io = new wxBoxSizer(wxVERTICAL); + wxBoxSizer* s_subpanel_hle = new wxBoxSizer(wxVERTICAL); // CPU/SPU settings - wxStaticBoxSizer* s_round_cpu_decoder( new wxStaticBoxSizer( wxVERTICAL, p_cpu, _("CPU") ) ); - wxStaticBoxSizer* s_round_spu_decoder( new wxStaticBoxSizer( wxVERTICAL, p_cpu, _("SPU") ) ); + wxStaticBoxSizer* s_round_cpu_decoder = new wxStaticBoxSizer(wxVERTICAL, p_cpu, _("CPU")); + wxStaticBoxSizer* s_round_spu_decoder = new wxStaticBoxSizer(wxVERTICAL, p_cpu, _("SPU")); // Graphics - wxStaticBoxSizer* s_round_gs_render( new wxStaticBoxSizer( wxVERTICAL, p_graphics, _("Render") ) ); - wxStaticBoxSizer* s_round_gs_res( new wxStaticBoxSizer( wxVERTICAL, p_graphics, _("Default resolution") ) ); - wxStaticBoxSizer* s_round_gs_aspect( new wxStaticBoxSizer( wxVERTICAL, p_graphics, _("Default aspect ratio") ) ); + wxStaticBoxSizer* s_round_gs_render = new wxStaticBoxSizer(wxVERTICAL, p_graphics, _("Render")); + wxStaticBoxSizer* s_round_gs_res = new wxStaticBoxSizer(wxVERTICAL, p_graphics, _("Default resolution")); + wxStaticBoxSizer* s_round_gs_aspect = new wxStaticBoxSizer(wxVERTICAL, p_graphics, _("Default aspect ratio")); // Input / Output - wxStaticBoxSizer* s_round_io_pad_handler( new wxStaticBoxSizer( wxVERTICAL, p_io, _("Pad Handler") ) ); - wxStaticBoxSizer* s_round_io_keyboard_handler( new wxStaticBoxSizer( wxVERTICAL, p_io, _("Keyboard Handler") ) ); - wxStaticBoxSizer* s_round_io_mouse_handler( new wxStaticBoxSizer( wxVERTICAL, p_io, _("Mouse Handler") ) ); + wxStaticBoxSizer* s_round_io_pad_handler = new wxStaticBoxSizer(wxVERTICAL, p_io, _("Pad Handler")); + wxStaticBoxSizer* s_round_io_keyboard_handler = new wxStaticBoxSizer(wxVERTICAL, p_io, _("Keyboard Handler")); + wxStaticBoxSizer* s_round_io_mouse_handler = new wxStaticBoxSizer(wxVERTICAL, p_io, _("Mouse Handler")); // Audio - wxStaticBoxSizer* s_round_audio_out( new wxStaticBoxSizer( wxVERTICAL, p_audio, _("Audio Out") ) ); + wxStaticBoxSizer* s_round_audio_out = new wxStaticBoxSizer(wxVERTICAL, p_audio, _("Audio Out")); // HLE / Misc. - wxStaticBoxSizer* s_round_hle_log_lvl( new wxStaticBoxSizer( wxVERTICAL, p_hle, _("Log lvl") ) ); + wxStaticBoxSizer* s_round_hle_log_lvl = new wxStaticBoxSizer(wxVERTICAL, p_hle, _("Log lvl")); // System - wxStaticBoxSizer* s_round_sys_lang( new wxStaticBoxSizer( wxVERTICAL, p_system, _("Language") ) ); + wxStaticBoxSizer* s_round_sys_lang = new wxStaticBoxSizer(wxVERTICAL, p_system, _("Language")); wxComboBox* cbox_cpu_decoder = new wxComboBox(p_cpu, wxID_ANY); wxComboBox* cbox_spu_decoder = new wxComboBox(p_cpu, wxID_ANY); diff --git a/rpcs3/Gui/PADManager.cpp b/rpcs3/Gui/PADManager.cpp index ae03550f9e..58accb4581 100644 --- a/rpcs3/Gui/PADManager.cpp +++ b/rpcs3/Gui/PADManager.cpp @@ -209,8 +209,8 @@ PADManager::PADManager(wxWindow* parent) SetSizerAndFit(s_panel); // Bind buttons - Bind(wxEVT_KEY_UP, &PADManager::OnKeyUp, this); - Bind(wxEVT_KEY_DOWN, &PADManager::OnKeyDown, this); + wxGetApp().Bind(wxEVT_KEY_UP, &PADManager::OnKeyUp, this); + wxGetApp().Bind(wxEVT_KEY_DOWN, &PADManager::OnKeyDown, this); b_up_lstick ->Bind(wxEVT_BUTTON, &PADManager::OnButtonClicked, this); b_down_lstick ->Bind(wxEVT_BUTTON, &PADManager::OnButtonClicked, this); b_left_lstick ->Bind(wxEVT_BUTTON, &PADManager::OnButtonClicked, this); diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index a1f0ee9812..3bf28ccc5e 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -82,4 +82,4 @@ CPUThread& GetCPU(const u8 core) return Emu.GetCPU().Get(core); }*/ -GameInfo CurGameInfo; \ No newline at end of file +GameInfo CurGameInfo; diff --git a/rpcs3/rpcs3.h b/rpcs3/rpcs3.h index f2f5e96b26..5727484759 100644 --- a/rpcs3/rpcs3.h +++ b/rpcs3/rpcs3.h @@ -12,7 +12,7 @@ template T max(const T a, const T b) { return a > b ? a : b; } template T re(const T val) { T res; se_t::func(res, val); return res; } template void re(T1& dst, const T2 val) { se_t::func(dst, val); } -extern const wxEventTypeTag wxEVT_DBG_COMMAND; +wxDECLARE_EVENT(wxEVT_DBG_COMMAND, wxCommandEvent); enum DbgCommand {