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.
This commit is contained in:
Lioncash 2014-04-12 21:31:59 -04:00
parent b877879db6
commit 8feabb00d6
10 changed files with 86 additions and 87 deletions

View File

@ -70,7 +70,6 @@ endforeach()
file( file(
GLOB_RECURSE GLOB_RECURSE
RPCS3_SRC RPCS3_SRC
<<<<<<< HEAD
"${RPCS3_SRC_DIR}/rpcs3.cpp" "${RPCS3_SRC_DIR}/rpcs3.cpp"
"${RPCS3_SRC_DIR}/Ini.cpp" "${RPCS3_SRC_DIR}/Ini.cpp"
"${RPCS3_SRC_DIR}/Emu/*" "${RPCS3_SRC_DIR}/Emu/*"

View File

@ -11,8 +11,8 @@ class WindowsKeyboardHandler final
public: public:
WindowsKeyboardHandler() : wxWindow() WindowsKeyboardHandler() : wxWindow()
{ {
Bind(wxEVT_KEY_DOWN, &WindowsKeyboardHandler::KeyDown, this); wxGetApp().Bind(wxEVT_KEY_DOWN, &WindowsKeyboardHandler::KeyDown, this);
Bind(wxEVT_KEY_UP, &WindowsKeyboardHandler::KeyUp, this); wxGetApp().Bind(wxEVT_KEY_UP, &WindowsKeyboardHandler::KeyUp, this);
} }
virtual void KeyDown(wxKeyEvent& event) { Key(event.GetKeyCode(), 1); event.Skip(); } virtual void KeyDown(wxKeyEvent& event) { Key(event.GetKeyCode(), 1); event.Skip(); }

View File

@ -10,14 +10,14 @@ class WindowsMouseHandler final
public: public:
WindowsMouseHandler() : wxWindow() WindowsMouseHandler() : wxWindow()
{ {
Bind(wxEVT_LEFT_DOWN, &WindowsMouseHandler::MouseButtonDown, this); wxGetApp().Bind(wxEVT_LEFT_DOWN, &WindowsMouseHandler::MouseButtonDown, this);
Bind(wxEVT_RIGHT_DOWN, &WindowsMouseHandler::MouseButtonDown, this); wxGetApp().Bind(wxEVT_RIGHT_DOWN, &WindowsMouseHandler::MouseButtonDown, this);
Bind(wxEVT_MIDDLE_DOWN, &WindowsMouseHandler::MouseButtonDown, this); wxGetApp().Bind(wxEVT_MIDDLE_DOWN, &WindowsMouseHandler::MouseButtonDown, this);
Bind(wxEVT_LEFT_UP, &WindowsMouseHandler::MouseButtonUp, this); wxGetApp().Bind(wxEVT_LEFT_UP, &WindowsMouseHandler::MouseButtonUp, this);
Bind(wxEVT_RIGHT_UP, &WindowsMouseHandler::MouseButtonUp, this); wxGetApp().Bind(wxEVT_RIGHT_UP, &WindowsMouseHandler::MouseButtonUp, this);
Bind(wxEVT_MIDDLE_UP, &WindowsMouseHandler::MouseButtonUp, this); wxGetApp().Bind(wxEVT_MIDDLE_UP, &WindowsMouseHandler::MouseButtonUp, this);
Bind(wxEVT_MOUSEWHEEL, &WindowsMouseHandler::MouseScroll, this); wxGetApp().Bind(wxEVT_MOUSEWHEEL, &WindowsMouseHandler::MouseScroll, this);
Bind(wxEVT_MOTION, &WindowsMouseHandler::MouseMove, this); wxGetApp().Bind(wxEVT_MOTION, &WindowsMouseHandler::MouseMove, this);
} }
virtual void MouseButtonDown(wxMouseEvent& event) virtual void MouseButtonDown(wxMouseEvent& event)

View File

@ -10,8 +10,8 @@ class WindowsPadHandler final
public: public:
WindowsPadHandler() : wxWindow() WindowsPadHandler() : wxWindow()
{ {
Bind(wxEVT_KEY_DOWN, &WindowsPadHandler::KeyDown, this); wxGetApp().Bind(wxEVT_KEY_DOWN, &WindowsPadHandler::KeyDown, this);
Bind(wxEVT_KEY_UP, &WindowsPadHandler::KeyUp, this); wxGetApp().Bind(wxEVT_KEY_UP, &WindowsPadHandler::KeyUp, this);
} }
virtual void KeyDown(wxKeyEvent& event) { Key(event.GetKeyCode(), 1); event.Skip(); } virtual void KeyDown(wxKeyEvent& event) { Key(event.GetKeyCode(), 1); event.Skip(); }

View File

@ -33,7 +33,7 @@ public:
Layout(); Layout();
UpdateUI(); UpdateUI();
Bind(wxEVT_DBG_COMMAND, &DbgEmuPanel::HandleCommand, this); wxGetApp().Bind(wxEVT_DBG_COMMAND, &DbgEmuPanel::HandleCommand, this);
} }
void UpdateUI() void UpdateUI()

View File

@ -89,7 +89,7 @@ InterpreterDisAsmFrame::InterpreterDisAsmFrame(wxWindow* parent)
Bind(wxEVT_SIZE, &InterpreterDisAsmFrame::OnResize, this); Bind(wxEVT_SIZE, &InterpreterDisAsmFrame::OnResize, this);
Bind(wxEVT_KEY_DOWN, &InterpreterDisAsmFrame::OnKeyDown, 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)); ShowAddr(CentrePc(PC));
UpdateUnitList(); UpdateUnitList();

View File

@ -60,43 +60,43 @@ MainFrame::MainFrame()
SetLabel(wxString::Format(_PRGNAME_ " " _PRGVER_)); SetLabel(wxString::Format(_PRGNAME_ " " _PRGVER_));
#endif #endif
wxMenuBar& menubar(*new wxMenuBar()); wxMenuBar* menubar = new wxMenuBar();
wxMenu& menu_boot(*new wxMenu()); wxMenu* menu_boot = new wxMenu();
menubar.Append(&menu_boot, "Boot"); menubar->Append(menu_boot, "Boot");
menu_boot.Append(id_boot_game, "Boot game"); menu_boot->Append(id_boot_game, "Boot game");
menu_boot.Append(id_install_pkg, "Install PKG"); menu_boot->Append(id_install_pkg, "Install PKG");
menu_boot.AppendSeparator(); menu_boot->AppendSeparator();
menu_boot.Append(id_boot_elf, "Boot (S)ELF"); menu_boot->Append(id_boot_elf, "Boot (S)ELF");
wxMenu& menu_sys(*new wxMenu()); wxMenu* menu_sys = new wxMenu();
menubar.Append(&menu_sys, "System"); menubar->Append(menu_sys, "System");
menu_sys.Append(id_sys_pause, "Pause")->Enable(false); menu_sys->Append(id_sys_pause, "Pause")->Enable(false);
menu_sys.Append(id_sys_stop, "Stop\tCtrl + S")->Enable(false); menu_sys->Append(id_sys_stop, "Stop\tCtrl + S")->Enable(false);
menu_sys.AppendSeparator(); menu_sys->AppendSeparator();
menu_sys.Append(id_sys_send_open_menu, "Send open system menu cmd")->Enable(false); 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); menu_sys->Append(id_sys_send_exit, "Send exit cmd")->Enable(false);
wxMenu& menu_conf(*new wxMenu()); wxMenu* menu_conf = new wxMenu();
menubar.Append(&menu_conf, "Config"); menubar->Append(menu_conf, "Config");
menu_conf.Append(id_config_emu, "Settings"); menu_conf->Append(id_config_emu, "Settings");
menu_conf.Append(id_config_pad, "PAD Settings"); menu_conf->Append(id_config_pad, "PAD Settings");
menu_conf.AppendSeparator(); menu_conf->AppendSeparator();
menu_conf.Append(id_config_vfs_manager, "Virtual File System Manager"); menu_conf->Append(id_config_vfs_manager, "Virtual File System Manager");
menu_conf.Append(id_config_vhdd_manager, "Virtual HDD Manager"); menu_conf->Append(id_config_vhdd_manager, "Virtual HDD Manager");
wxMenu& menu_tools(*new wxMenu()); wxMenu* menu_tools = new wxMenu();
menubar.Append(&menu_tools, "Tools"); menubar->Append(menu_tools, "Tools");
menu_tools.Append(id_tools_compiler, "ELF Compiler"); menu_tools->Append(id_tools_compiler, "ELF Compiler");
menu_tools.Append(id_tools_memory_viewer, "Memory Viewer"); menu_tools->Append(id_tools_memory_viewer, "Memory Viewer");
menu_tools.Append(id_tools_rsx_debugger, "RSX Debugger"); menu_tools->Append(id_tools_rsx_debugger, "RSX Debugger");
menu_tools.Append(id_tools_fnid_generator, "FunctionID Generator"); menu_tools->Append(id_tools_fnid_generator, "FunctionID Generator");
wxMenu& menu_help(*new wxMenu()); wxMenu* menu_help = new wxMenu();
menubar.Append(&menu_help, "Help"); menubar->Append(menu_help, "Help");
menu_help.Append(id_help_about, "About..."); menu_help->Append(id_help_about, "About...");
SetMenuBar(&menubar); SetMenuBar(menubar);
// Panels // Panels
m_game_viewer = new GameViewer(this); m_game_viewer = new GameViewer(this);
@ -108,31 +108,31 @@ MainFrame::MainFrame()
AddPane(m_debugger_frame, "Debugger", wxAUI_DOCK_RIGHT); AddPane(m_debugger_frame, "Debugger", wxAUI_DOCK_RIGHT);
// Events // Events
Connect( id_boot_game, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootGame) ); Bind(wxEVT_MENU, &MainFrame::BootGame, this, id_boot_game);
Connect( id_install_pkg, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::InstallPkg) ); Bind(wxEVT_MENU, &MainFrame::InstallPkg, this, id_install_pkg);
Connect( id_boot_elf, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootElf) ); Bind(wxEVT_MENU, &MainFrame::BootElf, this, id_boot_elf);
Connect( id_sys_pause, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Pause) ); Bind(wxEVT_MENU, &MainFrame::Pause, this, id_sys_pause);
Connect( id_sys_stop, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Stop) ); Bind(wxEVT_MENU, &MainFrame::Stop, this, id_sys_stop);
Connect( id_sys_send_open_menu, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::SendOpenCloseSysMenu) ); Bind(wxEVT_MENU, &MainFrame::SendOpenCloseSysMenu, this, id_sys_send_open_menu);
Connect( id_sys_send_exit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::SendExit) ); Bind(wxEVT_MENU, &MainFrame::SendExit, this, id_sys_send_exit);
Connect( id_config_emu, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Config) ); Bind(wxEVT_MENU, &MainFrame::Config, this, id_config_emu);
Connect( id_config_pad, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::ConfigPad) ); Bind(wxEVT_MENU, &MainFrame::ConfigPad, this, id_config_pad);
Connect( id_config_vfs_manager, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::ConfigVFS) ); Bind(wxEVT_MENU, &MainFrame::ConfigVFS, this, id_config_vfs_manager);
Connect( id_config_vhdd_manager, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::ConfigVHDD) ); Bind(wxEVT_MENU, &MainFrame::ConfigVHDD, this, id_config_vhdd_manager);
Connect( id_tools_compiler, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenELFCompiler)); Bind(wxEVT_MENU, &MainFrame::OpenELFCompiler, this, id_tools_compiler);
Connect( id_tools_memory_viewer, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenMemoryViewer)); Bind(wxEVT_MENU, &MainFrame::OpenMemoryViewer, this, id_tools_memory_viewer);
Connect( id_tools_rsx_debugger, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenRSXDebugger)); Bind(wxEVT_MENU, &MainFrame::OpenRSXDebugger, this, id_tools_rsx_debugger);
Connect(id_tools_fnid_generator, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenFnIdGenerator)); 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); Bind(wxEVT_KEY_DOWN, &MainFrame::OnKeyDown, this);
m_app_connector.Connect(wxEVT_DBG_COMMAND, wxCommandEventHandler(MainFrame::UpdateUI), (wxObject*)0, this); wxGetApp().Bind(wxEVT_DBG_COMMAND, &MainFrame::UpdateUI, this);
} }
MainFrame::~MainFrame() MainFrame::~MainFrame()
@ -187,7 +187,7 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event))
} }
else 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_hle, wxT("HLE / Misc."));
nb_config->AddPage(p_system, wxT("System")); nb_config->AddPage(p_system, wxT("System"));
wxBoxSizer* s_subpanel_system(new wxBoxSizer(wxVERTICAL)); wxBoxSizer* s_subpanel_system = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_cpu(new wxBoxSizer(wxVERTICAL)); wxBoxSizer* s_subpanel_cpu = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_graphics(new wxBoxSizer(wxVERTICAL)); wxBoxSizer* s_subpanel_graphics = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_audio(new wxBoxSizer(wxVERTICAL)); wxBoxSizer* s_subpanel_audio = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_io(new wxBoxSizer(wxVERTICAL)); wxBoxSizer* s_subpanel_io = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_hle(new wxBoxSizer(wxVERTICAL)); wxBoxSizer* s_subpanel_hle = new wxBoxSizer(wxVERTICAL);
// CPU/SPU settings // CPU/SPU settings
wxStaticBoxSizer* s_round_cpu_decoder( new wxStaticBoxSizer( wxVERTICAL, p_cpu, _("CPU") ) ); 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_spu_decoder = new wxStaticBoxSizer(wxVERTICAL, p_cpu, _("SPU"));
// Graphics // Graphics
wxStaticBoxSizer* s_round_gs_render( new wxStaticBoxSizer( wxVERTICAL, p_graphics, _("Render") ) ); 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_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_aspect = new wxStaticBoxSizer(wxVERTICAL, p_graphics, _("Default aspect ratio"));
// Input / Output // Input / Output
wxStaticBoxSizer* s_round_io_pad_handler( new wxStaticBoxSizer( wxVERTICAL, p_io, _("Pad 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_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_mouse_handler = new wxStaticBoxSizer(wxVERTICAL, p_io, _("Mouse Handler"));
// Audio // 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. // 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 // 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_cpu_decoder = new wxComboBox(p_cpu, wxID_ANY);
wxComboBox* cbox_spu_decoder = new wxComboBox(p_cpu, wxID_ANY); wxComboBox* cbox_spu_decoder = new wxComboBox(p_cpu, wxID_ANY);

View File

@ -209,8 +209,8 @@ PADManager::PADManager(wxWindow* parent)
SetSizerAndFit(s_panel); SetSizerAndFit(s_panel);
// Bind buttons // Bind buttons
Bind(wxEVT_KEY_UP, &PADManager::OnKeyUp, this); wxGetApp().Bind(wxEVT_KEY_UP, &PADManager::OnKeyUp, this);
Bind(wxEVT_KEY_DOWN, &PADManager::OnKeyDown, this); wxGetApp().Bind(wxEVT_KEY_DOWN, &PADManager::OnKeyDown, this);
b_up_lstick ->Bind(wxEVT_BUTTON, &PADManager::OnButtonClicked, this); b_up_lstick ->Bind(wxEVT_BUTTON, &PADManager::OnButtonClicked, this);
b_down_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); b_left_lstick ->Bind(wxEVT_BUTTON, &PADManager::OnButtonClicked, this);

View File

@ -82,4 +82,4 @@ CPUThread& GetCPU(const u8 core)
return Emu.GetCPU().Get(core); return Emu.GetCPU().Get(core);
}*/ }*/
GameInfo CurGameInfo; GameInfo CurGameInfo;

View File

@ -12,7 +12,7 @@ template<typename T> T max(const T a, const T b) { return a > b ? a : b; }
template<typename T> T re(const T val) { T res; se_t<T>::func(res, val); return res; } template<typename T> T re(const T val) { T res; se_t<T>::func(res, val); return res; }
template<typename T1, typename T2> void re(T1& dst, const T2 val) { se_t<T1>::func(dst, val); } template<typename T1, typename T2> void re(T1& dst, const T2 val) { se_t<T1>::func(dst, val); }
extern const wxEventTypeTag<wxCommandEvent> wxEVT_DBG_COMMAND; wxDECLARE_EVENT(wxEVT_DBG_COMMAND, wxCommandEvent);
enum DbgCommand enum DbgCommand
{ {