From f0596fee55656e45c33eb30d2ffaed65cd413efb Mon Sep 17 00:00:00 2001 From: John Peterson Date: Sat, 22 Nov 2008 16:46:12 +0000 Subject: [PATCH] Added Copy EFB hotkey to OpenGL plugin (to be able to easily switch back and forth during emulation). Added Unlimited JIT cache option to debugger. It may fix the Zelda TP crashes. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1243 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/CoreParameter.h | 6 +- .../Core/Core/Src/PowerPC/Jit64/JitCache.cpp | 18 +- .../Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp | 18 +- Source/Core/DebuggerWX/Src/CodeWindow.cpp | 97 +-- Source/Core/DebuggerWX/Src/CodeWindow.h | 23 +- Source/Core/DolphinWX/Src/Frame.cpp | 7 + .../Plugins/Plugin_DSP_HLE/Src/ConfigDlg.cpp | 18 + .../Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp | 1 - .../Src/UCodes/UCode_AX_Voice.h | 8 +- .../Plugin_PadSimple/Src/GUI/ConfigDlg.cpp | 662 +++++++++--------- .../Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp | 2 +- Source/Plugins/Plugin_VideoOGL/Src/Config.cpp | 2 + Source/Plugins/Plugin_VideoOGL/Src/Config.h | 2 +- .../Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp | 24 +- .../Plugin_VideoOGL/Src/GUI/ConfigDlg.h | 4 +- .../Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp | 11 +- 16 files changed, 492 insertions(+), 411 deletions(-) diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index e631a20b9a..39a651f078 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -37,14 +37,16 @@ struct SCoreStartupParameter // flags bool bEnableDebugging; bool bUseJIT; - bool bJITOff; - bool bJITLoadStoreOff; + + bool bJITUnlimitedCache, bJITOff; // JIT + bool bJITLoadStoreOff, bJITLoadStorelXzOff, bJITLoadStorelwzOff, bJITLoadStorelbzxOff; bool bJITLoadStoreFloatingOff; bool bJITLoadStorePairedOff; bool bJITFloatingPointOff; bool bJITIntegerOff; bool bJITPairedOff; bool bJITSystemRegistersOff; + bool bUseDualCore; bool bSkipIdle; bool bNTSC; diff --git a/Source/Core/Core/Src/PowerPC/Jit64/JitCache.cpp b/Source/Core/Core/Src/PowerPC/Jit64/JitCache.cpp index b4f5f88a9e..4217f9b6c4 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/JitCache.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/JitCache.cpp @@ -50,11 +50,13 @@ namespace Jit64 enum { - CODE_SIZE = 1024*1024*8, + //CODE_SIZE = 1024*1024*8, GEN_SIZE = 4096, TRAMPOLINE_SIZE = 1024*1024, - MAX_NUM_BLOCKS = 65536, + //MAX_NUM_BLOCKS = 65536, }; + int CODE_SIZE = 1024*1024*8; // nonconstant to be able to have an option for it + int MAX_NUM_BLOCKS = 65536; static u8 **blockCodePointers; // cut these in half and force below 2GB? @@ -75,6 +77,12 @@ namespace Jit64 void InitCache() { + if(Core::g_CoreStartupParameter.bJITUnlimitedCache) + { + CODE_SIZE *= 8; + MAX_NUM_BLOCKS *= 8; + } + codeCache = (u8*)AllocateExecutableMemory(CODE_SIZE); genFunctions = (u8*)AllocateExecutableMemory(GEN_SIZE); trampolineCache = (u8*)AllocateExecutableMemory(TRAMPOLINE_SIZE); @@ -103,6 +111,8 @@ namespace Jit64 numBlocks = 0; } + /* This clears the JIT cache. It's called from JitCache.cpp when the JIT cache + is full and when saving and loading states */ void ClearCache() { Core::DisplayMessage("Cleared code cache.", 3000); @@ -165,6 +175,10 @@ namespace Jit64 if (GetCodePtr() >= codeCache + CODE_SIZE - 0x10000 || numBlocks >= MAX_NUM_BLOCKS - 1) { LOG(DYNA_REC, "JIT cache full - clearing.") + if(Core::g_CoreStartupParameter.bJITUnlimitedCache) + { + PanicAlert("What? JIT cache still full - clearing."); + } ClearCache(); } diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp index 9213059a70..773e185e13 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp @@ -55,7 +55,8 @@ namespace Jit64 void lbzx(UGeckoInstruction inst) { #ifdef JIT_OFF_OPTIONS - if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) + if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff + || Core::g_CoreStartupParameter.bJITLoadStorelbzxOff) {Default(inst); return;} // turn off from debugger #endif INSTRUCTION_START; @@ -80,11 +81,12 @@ namespace Jit64 void lXz(UGeckoInstruction inst) { #ifdef JIT_OFF_OPTIONS - if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) + if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff + || Core::g_CoreStartupParameter.bJITLoadStorelXzOff) {Default(inst); return;} // turn off from debugger #endif INSTRUCTION_START; - + int d = inst.RD; int a = inst.RA; @@ -125,10 +127,16 @@ namespace Jit64 int accessSize; switch (inst.OPCD) { - case 32: accessSize = 32; break; //lwz + case 32: + accessSize = 32; + if(Core::g_CoreStartupParameter.bJITLoadStorelwzOff) {Default(inst); return;} + break; //lwz case 40: accessSize = 16; break; //lhz case 34: accessSize = 8; break; //lbz - default: _assert_msg_(DYNA_REC, 0, "lXz: invalid access size"); return; + default: + //_assert_msg_(DYNA_REC, 0, "lXz: invalid access size"); + PanicAlert("lXz: invalid access size"); + return; } //Still here? Do regular path. diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.cpp b/Source/Core/DebuggerWX/Src/CodeWindow.cpp index 4c0a65f6c0..4a66620ef0 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindow.cpp @@ -92,14 +92,18 @@ BEGIN_EVENT_TABLE(CCodeWindow, wxFrame) EVT_MENU(IDM_VIDEOWINDOW, CCodeWindow::OnToggleVideoWindow) EVT_MENU(IDM_INTERPRETER, CCodeWindow::OnInterpreter) // CPU Mode + EVT_MENU(IDM_JITUNLIMITED, CCodeWindow::OnJITOff) EVT_MENU(IDM_JITOFF, CCodeWindow::OnJITOff) - EVT_MENU(IDM_JITLSOFF, CCodeWindow::OnJITLSOff) - EVT_MENU(IDM_JITLSFOFF, CCodeWindow::OnJITLSFOff) - EVT_MENU(IDM_JITLSPOFF, CCodeWindow::OnJITLSPOff) - EVT_MENU(IDM_JITFPOFF, CCodeWindow::OnJITFPOff) - EVT_MENU(IDM_JITIOFF, CCodeWindow::OnJITIOff) - EVT_MENU(IDM_JITPOFF, CCodeWindow::OnJITPOff) - EVT_MENU(IDM_JITSROFF, CCodeWindow::OnJITSROff) + EVT_MENU(IDM_JITLSOFF, CCodeWindow::OnJITOff) + EVT_MENU(IDM_JITLSLXZOFF, CCodeWindow::OnJITOff) + EVT_MENU(IDM_JITLSLWZOFF, CCodeWindow::OnJITOff) + EVT_MENU(IDM_JITLSLBZXOFF, CCodeWindow::OnJITOff) + EVT_MENU(IDM_JITLSFOFF, CCodeWindow::OnJITOff) + EVT_MENU(IDM_JITLSPOFF, CCodeWindow::OnJITOff) + EVT_MENU(IDM_JITFPOFF, CCodeWindow::OnJITOff) + EVT_MENU(IDM_JITIOFF, CCodeWindow::OnJITOff) + EVT_MENU(IDM_JITPOFF, CCodeWindow::OnJITOff) + EVT_MENU(IDM_JITSROFF, CCodeWindow::OnJITOff) EVT_MENU(IDM_CLEARSYMBOLS, CCodeWindow::OnSymbolsMenu) EVT_MENU(IDM_LOADMAPFILE, CCodeWindow::OnSymbolsMenu) @@ -335,29 +339,19 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam pCoreMenu->AppendSeparator(); #ifdef JIT_OFF_OPTIONS + jitunlimited = pCoreMenu->Append(IDM_JITUNLIMITED, _T("&Unlimited JIT Cache"), wxEmptyString, wxITEM_CHECK); + pCoreMenu->AppendSeparator(); jitoff = pCoreMenu->Append(IDM_JITOFF, _T("&JIT off (JIT core)"), wxEmptyString, wxITEM_CHECK); - jitoff->Check(_LocalCoreStartupParameter.bJITOff); - jitlsoff = pCoreMenu->Append(IDM_JITLSOFF, _T("&JIT LoadStore off"), wxEmptyString, wxITEM_CHECK); - jitlsoff->Check(_LocalCoreStartupParameter.bJITLoadStoreOff); - + jitlslbzxoff = pCoreMenu->Append(IDM_JITLSLBZXOFF, _T(" &JIT LoadStore lbzx off"), wxEmptyString, wxITEM_CHECK); + jitlslxzoff = pCoreMenu->Append(IDM_JITLSLXZOFF, _T(" &JIT LoadStore lXz off"), wxEmptyString, wxITEM_CHECK); + jitlslwzoff = pCoreMenu->Append(IDM_JITLSLWZOFF, _T(" &JIT LoadStore lwz off"), wxEmptyString, wxITEM_CHECK); jitlspoff = pCoreMenu->Append(IDM_JITLSFOFF, _T("&JIT LoadStore Floating off"), wxEmptyString, wxITEM_CHECK); - jitlspoff->Check(_LocalCoreStartupParameter.bJITLoadStoreFloatingOff); - jitlsfoff = pCoreMenu->Append(IDM_JITLSPOFF, _T("&JIT LoadStore Paired off"), wxEmptyString, wxITEM_CHECK); - jitlsfoff->Check(_LocalCoreStartupParameter.bJITLoadStorePairedOff); - jitfpoff = pCoreMenu->Append(IDM_JITFPOFF, _T("&JIT FloatingPoint off"), wxEmptyString, wxITEM_CHECK); - jitfpoff->Check(_LocalCoreStartupParameter.bJITFloatingPointOff); - jitioff = pCoreMenu->Append(IDM_JITIOFF, _T("&JIT Integer off"), wxEmptyString, wxITEM_CHECK); - jitioff->Check(_LocalCoreStartupParameter.bJITIntegerOff); - jitpoff = pCoreMenu->Append(IDM_JITPOFF, _T("&JIT Paired off"), wxEmptyString, wxITEM_CHECK); - jitpoff->Check(_LocalCoreStartupParameter.bJITPairedOff); - jitsroff = pCoreMenu->Append(IDM_JITSROFF, _T("&JIT SystemRegisters off"), wxEmptyString, wxITEM_CHECK); - jitsroff->Check(_LocalCoreStartupParameter.bJITSystemRegistersOff); #endif // wxMenuItem* dualcore = pDebugMenu->Append(IDM_DUALCORE, _T("&DualCore"), wxEmptyString, wxITEM_CHECK); @@ -459,43 +453,58 @@ void CCodeWindow::OnInterpreter(wxCommandEvent& event) wxMessageBox(_T("Please pause the emulator before changing mode.")); } } -void CCodeWindow::DoJITOff(wxCommandEvent& event, wxMenuItem* a, bool& b) + + +void CCodeWindow::OnJITOff(wxCommandEvent& event) { if (Core::GetState() == Core::CORE_UNINITIALIZED) { // we disallow changing the status here because it will be reset to the defult when BootCore() // creates the SCoreStartupParameter as a game is loaded - a->Check(!a->IsChecked()); + GetMenuBar()->Check(event.GetId(),!event.IsChecked()); wxMessageBox(_T("Please start a game before changing mode.")); } else { if (Core::GetState() != Core::CORE_RUN) { - b = !b; + switch (event.GetId()) + { + case IDM_JITUNLIMITED: + Core::g_CoreStartupParameter.bJITUnlimitedCache = event.IsChecked(); + Jit64::ClearCache(); // allow InitCache() even after the game has started + Jit64::InitCache(); + GetMenuBar()->Enable(event.GetId(),!event.IsChecked()); + break; + case IDM_JITOFF: + Core::g_CoreStartupParameter.bJITOff = event.IsChecked(); break; + case IDM_JITLSOFF: + Core::g_CoreStartupParameter.bJITLoadStoreOff = event.IsChecked(); break; + case IDM_JITLSLXZOFF: + Core::g_CoreStartupParameter.bJITLoadStorelXzOff = event.IsChecked(); break; + case IDM_JITLSLWZOFF: + Core::g_CoreStartupParameter.bJITLoadStorelwzOff = event.IsChecked(); break; + case IDM_JITLSLBZXOFF: + Core::g_CoreStartupParameter.bJITLoadStorelbzxOff = event.IsChecked(); break; + case IDM_JITLSFOFF: + Core::g_CoreStartupParameter.bJITLoadStoreFloatingOff = event.IsChecked(); break; + case IDM_JITLSPOFF: + Core::g_CoreStartupParameter.bJITLoadStorePairedOff = event.IsChecked(); break; + case IDM_JITFPOFF: + Core::g_CoreStartupParameter.bJITFloatingPointOff = event.IsChecked(); break; + case IDM_JITIOFF: + Core::g_CoreStartupParameter.bJITIntegerOff = event.IsChecked(); break; + case IDM_JITPOFF: + Core::g_CoreStartupParameter.bJITPairedOff = event.IsChecked(); break; + case IDM_JITSROFF: + Core::g_CoreStartupParameter.bJITSystemRegistersOff = event.IsChecked(); break; + } Jit64::ClearCache(); } else { //event.Skip(); // this doesn't work - a->Check(!a->IsChecked()); + GetMenuBar()->Check(event.GetId(),!event.IsChecked()); wxMessageBox(_T("Please pause the emulator before changing mode.")); } } } - -void CCodeWindow::OnJITOff(wxCommandEvent& event) {DoJITOff(event, jitoff, - Core::g_CoreStartupParameter.bJITOff);} -void CCodeWindow::OnJITLSOff(wxCommandEvent& event) {DoJITOff(event, jitlsoff, - Core::g_CoreStartupParameter.bJITLoadStoreOff);} -void CCodeWindow::OnJITLSFOff(wxCommandEvent& event) {DoJITOff(event, jitlsoff, - Core::g_CoreStartupParameter.bJITLoadStoreFloatingOff);} -void CCodeWindow::OnJITLSPOff(wxCommandEvent& event) {DoJITOff(event, jitlsoff, - Core::g_CoreStartupParameter.bJITLoadStorePairedOff);} -void CCodeWindow::OnJITFPOff(wxCommandEvent& event) {DoJITOff(event, jitfpoff, - Core::g_CoreStartupParameter.bJITFloatingPointOff);} -void CCodeWindow::OnJITIOff(wxCommandEvent& event) {DoJITOff(event, jitioff, - Core::g_CoreStartupParameter.bJITIntegerOff);} -void CCodeWindow::OnJITPOff(wxCommandEvent& event) {DoJITOff(event, jitpoff, - Core::g_CoreStartupParameter.bJITPairedOff);} -void CCodeWindow::OnJITSROff(wxCommandEvent& event) {DoJITOff(event, jitsroff, - Core::g_CoreStartupParameter.bJITSystemRegistersOff);} // ============== @@ -970,7 +979,7 @@ void CCodeWindow::OnToggleVideoWindow(wxCommandEvent& event) { bool show = GetMenuBar()->IsChecked(event.GetId()); //GetMenuBar()->Check(event.GetId(), false); // Turn off - + IniFile ini; ini.Load(DEBUGGER_CONFIG_FILE); ini.Set("ShowOnStart", "VideoWindow", show); diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.h b/Source/Core/DebuggerWX/Src/CodeWindow.h index 138ffef4c7..9fba9144a8 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.h +++ b/Source/Core/DebuggerWX/Src/CodeWindow.h @@ -79,14 +79,15 @@ class CCodeWindow IDM_CALLSLIST, IDM_SYMBOLLIST, IDM_INTERPRETER, - IDM_JITOFF, // jit - IDM_JITLSOFF, - IDM_JITLSPOFF, - IDM_JITLSFOFF, + + IDM_JITUNLIMITED, IDM_JITOFF, // jit + IDM_JITLSOFF, IDM_JITLSLXZOFF, IDM_JITLSLWZOFF, IDM_JITLSLBZXOFF, + IDM_JITLSPOFF, IDM_JITLSFOFF, IDM_JITIOFF, IDM_JITFPOFF, IDM_JITPOFF, IDM_JITSROFF, + IDM_DUALCORE, IDM_LOGWINDOW, IDM_REGISTERWINDOW, @@ -129,8 +130,8 @@ class CCodeWindow CMemoryWindow* m_MemoryWindow; CJitWindow* m_JitWindow; - wxMenuItem* jitoff; - wxMenuItem* jitlsoff; + wxMenuItem* jitunlimited, *jitoff; + wxMenuItem* jitlsoff, *jitlslxzoff, *jitlslwzoff, *jitlslbzxoff; wxMenuItem* jitlspoff; wxMenuItem* jitlsfoff; wxMenuItem* jitfpoff; @@ -175,15 +176,7 @@ class CCodeWindow void OnProfilerMenu(wxCommandEvent& event); void OnInterpreter(wxCommandEvent& event); // cpu mode menu - void OnJITOff(wxCommandEvent& event); - void OnJITLSOff(wxCommandEvent& event); - void OnJITLSPOff(wxCommandEvent& event); - void OnJITLSFOff(wxCommandEvent& event); - void OnJITFPOff(wxCommandEvent& event); - void OnJITIOff(wxCommandEvent& event); - void OnJITPOff(wxCommandEvent& event); - void OnJITSROff(wxCommandEvent& event); - void DoJITOff(wxCommandEvent& event, wxMenuItem* a, bool& b); + void OnJITOff(wxCommandEvent& event); void CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter); diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 678f94d0e2..f36064d5b7 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -613,12 +613,19 @@ void CFrame::OnToggleStatusbar(wxCommandEvent& event) void CFrame::OnKeyDown(wxKeyEvent& event) { + // Toggle fullscreen from Alt + Enter or Esc if (((event.GetKeyCode() == WXK_RETURN) && (event.GetModifiers() == wxMOD_ALT)) || (event.GetKeyCode() == WXK_ESCAPE)) { ShowFullScreen(!IsFullScreen()); UpdateGUI(); } +#ifdef _WIN32 + else if(event.GetKeyCode() == 'E') // Send this to the video plugin WndProc + { + PostMessage((HWND)Core::GetWindowHandle(), WM_KEYDOWN, event.GetKeyCode(), 0); + } +#endif else { event.Skip(); diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/ConfigDlg.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/ConfigDlg.cpp index 4158c4093e..b57e989c9d 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/ConfigDlg.cpp @@ -50,6 +50,24 @@ CConfigDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BO m_comboSampleRate.AddString("48000"); m_comboSampleRate.SetCurSel(g_Config.m_SampleRate == 44100 ? 0 : 1); + // Add tooltips + CToolTipCtrl ToolTips; + ToolTips.Create(m_hWnd); + ToolTips.Activate(true); + ToolTips.SetMaxTipWidth(200); // limit the width + ToolTips.SetDelayTime(TTDT_AUTOPOP, 20 * 1000); // give us time to read it + CToolInfo tiHLE(TTF_SUBCLASS, m_buttonEnableHLEAudio, 0, NULL, + "This is the most common sound type"); + CToolInfo tiDTK(TTF_SUBCLASS, m_buttonEnableDTKMusic, 0, NULL, + "This is sometimes used to play music tracks from the disc"); + CToolInfo tiOther(TTF_SUBCLASS, m_buttonEnableThrottle, 0, NULL, + "This is sometimes used together with pre-rendered movies. Disabling this" + " also disables the speed throttle that is causes. Meaning that" + " there will be no upper limit on your FPS."); + ToolTips.AddTool(tiHLE); + ToolTips.AddTool(tiDTK); + ToolTips.AddTool(tiOther); + return(TRUE); } diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp index d91d74b1ba..4f15257ab0 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp @@ -109,7 +109,6 @@ void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate) { Sleep(0); } } else { - wprintf("Tab"); return; } #else diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h index 7c85c50a6d..385bd7f762 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h @@ -111,7 +111,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, ratioFactor = 32000.0f / 44100.0f; #endif - if(!Wii) DoVoiceHacks(pb); + DoVoiceHacks(pb, Wii); // ============= if (pb.running) @@ -148,7 +148,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, //if (pb.src_type == 2 && (pb.src.ratio_hi == 0 && pb.src.ratio_lo == 0)) if (pb.running && (pb.src.ratio_hi == 0 && pb.src.ratio_lo == 0)) { - pb.src.ratio_hi = 1; + //pb.src.ratio_hi = 1; } // ============= @@ -299,7 +299,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, // Voice hacks // -------------- template -inline void DoVoiceHacks(ParamBlockType &pb) +inline void DoVoiceHacks(ParamBlockType &pb, bool Wii) { // get necessary values const u32 sampleEnd = (pb.audio_addr.end_addr_hi << 16) | pb.audio_addr.end_addr_lo; @@ -317,6 +317,7 @@ inline void DoVoiceHacks(ParamBlockType &pb) if ( (sampleEnd > (0x017fffff * 2) || loopPos > (0x017fffff * 2)) // ARAM bounds in nibbles && gSSBMremedy1 + && !Wii ) { pb.running = 0; @@ -356,6 +357,7 @@ inline void DoVoiceHacks(ParamBlockType &pb) && pb.mixer_control == 0 // only use this in SSBM && gSSBMremedy2 // let us turn this fix on and off + && !Wii ) { // reset the detection values diff --git a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp index 00fe94042c..28901395f5 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp @@ -1,332 +1,332 @@ -// Copyright (C) 2003-2008 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - - -#include "ConfigDlg.h" -#include "../PadSimple.h" - -#ifdef _WIN32 -#include "XInput.h" -#include "../DirectInputBase.h" - -DInput m_dinput; -#endif - -BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) - EVT_CLOSE(ConfigDialog::OnClose) - EVT_BUTTON(ID_CLOSE,ConfigDialog::OnCloseClick) - EVT_BUTTON(ID_PAD_ABOUT,ConfigDialog::DllAbout) - EVT_CHECKBOX(ID_ATTACHED,ConfigDialog::ControllerSettingsChanged) - EVT_CHECKBOX(ID_X360PAD,ConfigDialog::ControllerSettingsChanged) - EVT_CHOICE(ID_X360PAD_CHOICE,ConfigDialog::ControllerSettingsChanged) - EVT_CHECKBOX(ID_RUMBLE,ConfigDialog::ControllerSettingsChanged) - EVT_CHECKBOX(ID_DISABLE,ConfigDialog::ControllerSettingsChanged) - EVT_BUTTON(CTL_A,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_B,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_X,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_Y,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_Z,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_START,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_L,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_R,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_MAINUP,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_MAINDOWN,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_MAINLEFT,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_MAINRIGHT,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_SUBUP,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_SUBDOWN,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_SUBLEFT,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_SUBRIGHT,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_DPADUP,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_DPADDOWN,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_DPADLEFT,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_DPADRIGHT,ConfigDialog::OnButtonClick) - EVT_BUTTON(CTL_HALFPRESS,ConfigDialog::OnButtonClick) -END_EVENT_TABLE() - -ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style) -: wxDialog(parent, id, title, position, size, style) -{ -#ifdef _WIN32 - m_dinput.Init((HWND)parent); -#endif - clickedButton = NULL; - CreateGUIControls(); - Fit(); -} - -ConfigDialog::~ConfigDialog() -{ -} - -inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer, - const char *name, int ctl, int controller) -{ - wxBoxSizer *hButton = new wxBoxSizer(wxHORIZONTAL); - char keyStr[10] = {0}; - - hButton->Add(new wxStaticText(pan, 0, wxString::FromAscii(name), - wxDefaultPosition, wxDefaultSize), 0, - wxALIGN_CENTER_VERTICAL|wxALL); -#ifdef _WIN32 - DInput::DIKToString(pad[controller].keyForControl[ctl], keyStr); -#else - XKeyToString(pad[controller].keyForControl[ctl], keyStr); -#endif - - *button = new wxButton(pan, ctl, wxString::FromAscii(keyStr), - wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS); - - hButton->Add(*button, 0, wxALIGN_RIGHT|wxALL); - - sizer->Add(hButton, 0, wxALIGN_RIGHT|wxALL); -} - -void ConfigDialog::CreateGUIControls() -{ - // Notebook - m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize); - - // Controller pages - m_Controller[0] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE1, wxDefaultPosition, wxDefaultSize); - m_Notebook->AddPage(m_Controller[0], wxT("Controller 1")); - m_Controller[1] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE2, wxDefaultPosition, wxDefaultSize); - m_Notebook->AddPage(m_Controller[1], wxT("Controller 2")); - m_Controller[2] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE3, wxDefaultPosition, wxDefaultSize); - m_Notebook->AddPage(m_Controller[2], wxT("Controller 3")); - m_Controller[3] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE4, wxDefaultPosition, wxDefaultSize); - m_Notebook->AddPage(m_Controller[3], wxT("Controller 4")); - - // Standard buttons - m_Close = new wxButton(this, ID_CLOSE, wxT("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - m_About = new wxButton(this, ID_PAD_ABOUT, wxT("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - - // Put notebook and standard buttons in sizers - wxBoxSizer* sSButtons; - sSButtons = new wxBoxSizer(wxHORIZONTAL); - sSButtons->Add(m_About,0,wxALL, 5); - sSButtons->Add(0, 0, 1, wxEXPAND, 5); - sSButtons->Add(m_Close, 0, wxALL, 5); - - wxBoxSizer* sMain; - sMain = new wxBoxSizer(wxVERTICAL); - sMain->Add(m_Notebook, 1, wxEXPAND|wxALL, 5); - sMain->Add(sSButtons, 0, wxEXPAND, 5); - - this->SetSizer(sMain); - this->Layout(); - -#ifdef _WIN32 - // Add connected XPads - for (int x = 0; x < 4; x++) - { - XINPUT_STATE xstate; - DWORD xresult = XInputGetState(x, &xstate); - - if (xresult == ERROR_SUCCESS) - { - arrayStringFor_X360Pad.Add(wxString::Format("%i", x+1)); - } - } -#endif - - for(int i = 0; i < 4; i++) - { - sbDevice[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Controller Settings")); - sDevice[i] = new wxBoxSizer(wxHORIZONTAL); - m_Attached[i] = new wxCheckBox(m_Controller[i], ID_ATTACHED, wxT("Controller attached"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); -#ifdef _WIN32 - m_X360Pad[i] = new wxCheckBox(m_Controller[i], ID_X360PAD, wxT("Enable X360Pad"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - m_X360PadC[i] = new wxChoice(m_Controller[i], ID_X360PAD_CHOICE, wxDefaultPosition, wxDefaultSize, arrayStringFor_X360Pad, 0, wxDefaultValidator); - m_Rumble[i] = new wxCheckBox(m_Controller[i], ID_RUMBLE, wxT("Enable rumble"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); -#endif - m_Disable[i] = new wxCheckBox(m_Controller[i], ID_DISABLE, wxT("Disable when Dolphin is not in focus"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - m_Attached[i]->SetValue(pad[i].bAttached); -#ifdef _WIN32 - if (arrayStringFor_X360Pad.IsEmpty()) - { - m_X360Pad[i]->SetLabel(wxT("Enable X360Pad - No pad connected")); - m_X360Pad[i]->SetValue(false); - m_X360Pad[i]->Enable(false); - pad[i].bEnableXPad = false; - m_X360PadC[i]->Hide(); - m_Rumble[i]->Hide(); - } - else - { - m_X360Pad[i]->SetValue(pad[i].bEnableXPad); - m_X360PadC[i]->SetSelection(pad[i].XPadPlayer); - m_X360PadC[i]->Enable(m_X360Pad[i]->IsChecked()); - m_Rumble[i]->SetValue(pad[i].bRumble); - m_Rumble[i]->Enable(m_X360Pad[i]->IsChecked()); - } -#endif - m_Disable[i]->SetValue(pad[i].bDisable); - - sDevice[i]->Add(m_Attached[i], 0, wxEXPAND|wxALL, 1); - sDevice[i]->AddStretchSpacer(); -#ifdef _WIN32 - sDevice[i]->Add(m_X360Pad[i], 0, wxEXPAND|wxALL, 1); - sDevice[i]->Add(m_X360PadC[i], 0, wxEXPAND|wxALL, 1); - sDevice[i]->Add(m_Rumble[i], 0, wxEXPAND|wxALL, 1); - sDevice[i]->AddStretchSpacer(); -#endif - sDevice[i]->Add(m_Disable[i], 0, wxEXPAND|wxALL, 1); - sbDevice[i]->Add(sDevice[i], 0, wxEXPAND|wxALL, 1); - - sButtons[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Buttons")); - - AddControl(m_Controller[i], &(m_ButtonA[i]), sButtons[i], "A: ", CTL_A, i); - AddControl(m_Controller[i], &(m_ButtonB[i]), sButtons[i], "B: ", CTL_B, i); - AddControl(m_Controller[i], &(m_ButtonX[i]), sButtons[i], "X: ", CTL_X, i); - AddControl(m_Controller[i], &(m_ButtonY[i]), sButtons[i], "Y: ", CTL_Y, i); - AddControl(m_Controller[i], &(m_ButtonZ[i]), sButtons[i], "Z: ", CTL_Z, i); - AddControl(m_Controller[i], &(m_ButtonStart[i]), sButtons[i], "Start: ", CTL_START, i); - - sTriggers[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Triggers")); - - AddControl(m_Controller[i], &(m_ButtonL[i]), sTriggers[i], " L: ", CTL_L, i); - AddControl(m_Controller[i], &(m_ButtonR[i]), sTriggers[i], " R: ", CTL_R, i); - - sModifiers[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Modifiers")); - - AddControl(m_Controller[i], &(m_HalfPress[i]), sModifiers[i], "1/2 Press: ", CTL_HALFPRESS, i); - - sStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Main Stick")); - - AddControl(m_Controller[i], &(m_StickUp[i]), sStick[i], "Up: ", CTL_MAINUP, i); - AddControl(m_Controller[i], &(m_StickDown[i]), sStick[i], "Down: ", CTL_MAINDOWN, i); - AddControl(m_Controller[i], &(m_StickLeft[i]), sStick[i], "Left: ", CTL_MAINLEFT, i); - AddControl(m_Controller[i], &(m_StickRight[i]), sStick[i], "Right: ", CTL_MAINRIGHT, i); - - sDPad[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("D-Pad")); - - AddControl(m_Controller[i], &(m_DPadUp[i]), sDPad[i], "Up: ", CTL_DPADUP, i); - AddControl(m_Controller[i], &(m_DPadDown[i]), sDPad[i], "Down: ", CTL_DPADDOWN, i); - AddControl(m_Controller[i], &(m_DPadLeft[i]), sDPad[i], "Left: ", CTL_DPADLEFT, i); - AddControl(m_Controller[i], &(m_DPadRight[i]), sDPad[i], "Right: ", CTL_DPADRIGHT, i); - - sCStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("C-Stick")); - - AddControl(m_Controller[i], &(m_CStickUp[i]), sCStick[i], "Up: ", CTL_SUBUP, i); - AddControl(m_Controller[i], &(m_CStickDown[i]), sCStick[i], "Down: ", CTL_SUBDOWN, i); - AddControl(m_Controller[i], &(m_CStickLeft[i]), sCStick[i], "Left: ", CTL_SUBLEFT, i); - AddControl(m_Controller[i], &(m_CStickRight[i]), sCStick[i], "Right: ", CTL_SUBRIGHT, i); - - sPage[i] = new wxGridBagSizer(0, 0); - sPage[i]->SetFlexibleDirection(wxBOTH); - sPage[i]->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); - sPage[i]->Add(sbDevice[i], wxGBPosition(0, 0), wxGBSpan(1, 5), wxEXPAND|wxALL, 1); - sPage[i]->Add(sButtons[i], wxGBPosition(1, 0), wxGBSpan(2, 1), wxALL, 1); - sPage[i]->Add(sTriggers[i], wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 1); - sPage[i]->Add(sModifiers[i], wxGBPosition(2, 1), wxGBSpan(1, 1), wxALL, 1); - sPage[i]->Add(sStick[i], wxGBPosition(1, 2), wxGBSpan(2, 1), wxALL, 1); - sPage[i]->Add(sDPad[i], wxGBPosition(1, 3), wxGBSpan(2, 1), wxALL, 1); - sPage[i]->Add(sCStick[i], wxGBPosition(1, 4), wxGBSpan(2, 1), wxALL, 1); - m_Controller[i]->SetSizer(sPage[i]); - sPage[i]->Layout(); - } -} - -void ConfigDialog::OnClose(wxCloseEvent& event) -{ -#ifdef _WIN32 - m_dinput.Free(); -#endif - EndModal(0); -} - -void ConfigDialog::OnKeyDown(wxKeyEvent& event) -{ - if(clickedButton != NULL) - { - int page = m_Notebook->GetSelection(); - -#ifdef _WIN32 - m_dinput.Read(); - for(int i = 0; i < 255; i++) - { - if(m_dinput.diks[i]) - { - char keyStr[10] = {0}; - pad[page].keyForControl[clickedButton->GetId()] = i; - DInput::DIKToString(i, keyStr); - clickedButton->SetLabel(wxString::FromAscii(keyStr)); - break; - } - } -#else - pad[page].keyForControl[clickedButton->GetId()] = wxCharCodeWXToX(event.GetKeyCode()); - clickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode())); -#endif - clickedButton->Disconnect(); - } - - clickedButton = NULL; - event.Skip(); -} - -void ConfigDialog::OnCloseClick(wxCommandEvent& event) -{ - Close(); -} - -void ConfigDialog::ControllerSettingsChanged(wxCommandEvent& event) -{ - int page = m_Notebook->GetSelection(); - - switch (event.GetId()) - { - case ID_ATTACHED: - pad[page].bAttached = m_Attached[page]->GetValue(); - break; - case ID_X360PAD: - pad[page].bEnableXPad = event.IsChecked(); - m_Rumble[page]->Enable(event.IsChecked()); - m_X360PadC[page]->Enable(event.IsChecked()); - break; - case ID_X360PAD_CHOICE: - pad[page].XPadPlayer = event.GetSelection(); - break; - case ID_RUMBLE: - pad[page].bRumble = m_Rumble[page]->GetValue(); - break; - case ID_DISABLE: - pad[page].bDisable = m_Disable[page]->GetValue(); - break; - } -} - -void ConfigDialog::OnButtonClick(wxCommandEvent& event) -{ - if(clickedButton) - { - clickedButton->SetLabel(oldLabel); - } - clickedButton = (wxButton *)event.GetEventObject(); - oldLabel = clickedButton->GetLabel(); - clickedButton->SetLabel(_("Press Key")); - - clickedButton->Connect(wxID_ANY, wxEVT_KEY_DOWN, - wxKeyEventHandler(ConfigDialog::OnKeyDown), - (wxObject*)NULL, this); -} -void ConfigDialog::DllAbout(wxCommandEvent& event) -{ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + + +#include "ConfigDlg.h" +#include "../PadSimple.h" + +#ifdef _WIN32 +#include "XInput.h" +#include "../DirectInputBase.h" + +DInput m_dinput; +#endif + +BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) + EVT_CLOSE(ConfigDialog::OnClose) + EVT_BUTTON(ID_CLOSE,ConfigDialog::OnCloseClick) + EVT_BUTTON(ID_PAD_ABOUT,ConfigDialog::DllAbout) + EVT_CHECKBOX(ID_ATTACHED,ConfigDialog::ControllerSettingsChanged) + EVT_CHECKBOX(ID_X360PAD,ConfigDialog::ControllerSettingsChanged) + EVT_CHOICE(ID_X360PAD_CHOICE,ConfigDialog::ControllerSettingsChanged) + EVT_CHECKBOX(ID_RUMBLE,ConfigDialog::ControllerSettingsChanged) + EVT_CHECKBOX(ID_DISABLE,ConfigDialog::ControllerSettingsChanged) + EVT_BUTTON(CTL_A,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_B,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_X,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_Y,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_Z,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_START,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_L,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_R,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_MAINUP,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_MAINDOWN,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_MAINLEFT,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_MAINRIGHT,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_SUBUP,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_SUBDOWN,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_SUBLEFT,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_SUBRIGHT,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_DPADUP,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_DPADDOWN,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_DPADLEFT,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_DPADRIGHT,ConfigDialog::OnButtonClick) + EVT_BUTTON(CTL_HALFPRESS,ConfigDialog::OnButtonClick) +END_EVENT_TABLE() + +ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style) +: wxDialog(parent, id, title, position, size, style) +{ +#ifdef _WIN32 + m_dinput.Init((HWND)parent); +#endif + clickedButton = NULL; + CreateGUIControls(); + Fit(); +} + +ConfigDialog::~ConfigDialog() +{ +} + +inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer, + const char *name, int ctl, int controller) +{ + wxBoxSizer *hButton = new wxBoxSizer(wxHORIZONTAL); + char keyStr[10] = {0}; + + hButton->Add(new wxStaticText(pan, 0, wxString::FromAscii(name), + wxDefaultPosition, wxDefaultSize), 0, + wxALIGN_CENTER_VERTICAL|wxALL); +#ifdef _WIN32 + DInput::DIKToString(pad[controller].keyForControl[ctl], keyStr); +#else + XKeyToString(pad[controller].keyForControl[ctl], keyStr); +#endif + + *button = new wxButton(pan, ctl, wxString::FromAscii(keyStr), + wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS); + + hButton->Add(*button, 0, wxALIGN_RIGHT|wxALL); + + sizer->Add(hButton, 0, wxALIGN_RIGHT|wxALL); +} + +void ConfigDialog::CreateGUIControls() +{ + // Notebook + m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize); + + // Controller pages + m_Controller[0] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE1, wxDefaultPosition, wxDefaultSize); + m_Notebook->AddPage(m_Controller[0], wxT("Controller 1")); + m_Controller[1] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE2, wxDefaultPosition, wxDefaultSize); + m_Notebook->AddPage(m_Controller[1], wxT("Controller 2")); + m_Controller[2] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE3, wxDefaultPosition, wxDefaultSize); + m_Notebook->AddPage(m_Controller[2], wxT("Controller 3")); + m_Controller[3] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE4, wxDefaultPosition, wxDefaultSize); + m_Notebook->AddPage(m_Controller[3], wxT("Controller 4")); + + // Standard buttons + m_Close = new wxButton(this, ID_CLOSE, wxT("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_About = new wxButton(this, ID_PAD_ABOUT, wxT("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + + // Put notebook and standard buttons in sizers + wxBoxSizer* sSButtons; + sSButtons = new wxBoxSizer(wxHORIZONTAL); + sSButtons->Add(m_About,0,wxALL, 5); + sSButtons->Add(0, 0, 1, wxEXPAND, 5); + sSButtons->Add(m_Close, 0, wxALL, 5); + + wxBoxSizer* sMain; + sMain = new wxBoxSizer(wxVERTICAL); + sMain->Add(m_Notebook, 1, wxEXPAND|wxALL, 5); + sMain->Add(sSButtons, 0, wxEXPAND, 5); + + this->SetSizer(sMain); + this->Layout(); + +#ifdef _WIN32 + // Add connected XPads + for (int x = 0; x < 4; x++) + { + XINPUT_STATE xstate; + DWORD xresult = XInputGetState(x, &xstate); + + if (xresult == ERROR_SUCCESS) + { + arrayStringFor_X360Pad.Add(wxString::Format("%i", x+1)); + } + } +#endif + + for(int i = 0; i < 4; i++) + { + sbDevice[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Controller Settings")); + sDevice[i] = new wxBoxSizer(wxHORIZONTAL); + m_Attached[i] = new wxCheckBox(m_Controller[i], ID_ATTACHED, wxT("Controller attached"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); +#ifdef _WIN32 + m_X360Pad[i] = new wxCheckBox(m_Controller[i], ID_X360PAD, wxT("Enable X360Pad"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_X360PadC[i] = new wxChoice(m_Controller[i], ID_X360PAD_CHOICE, wxDefaultPosition, wxDefaultSize, arrayStringFor_X360Pad, 0, wxDefaultValidator); + m_Rumble[i] = new wxCheckBox(m_Controller[i], ID_RUMBLE, wxT("Enable rumble"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); +#endif + m_Disable[i] = new wxCheckBox(m_Controller[i], ID_DISABLE, wxT("Disable when Dolphin is not in focus"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_Attached[i]->SetValue(pad[i].bAttached); +#ifdef _WIN32 + if (arrayStringFor_X360Pad.IsEmpty()) + { + m_X360Pad[i]->SetLabel(wxT("Enable X360Pad - No pad connected")); + m_X360Pad[i]->SetValue(false); + m_X360Pad[i]->Enable(false); + pad[i].bEnableXPad = false; + m_X360PadC[i]->Hide(); + m_Rumble[i]->Hide(); + } + else + { + m_X360Pad[i]->SetValue(pad[i].bEnableXPad); + m_X360PadC[i]->SetSelection(pad[i].XPadPlayer); + m_X360PadC[i]->Enable(m_X360Pad[i]->IsChecked()); + m_Rumble[i]->SetValue(pad[i].bRumble); + m_Rumble[i]->Enable(m_X360Pad[i]->IsChecked()); + } +#endif + m_Disable[i]->SetValue(pad[i].bDisable); + + sDevice[i]->Add(m_Attached[i], 0, wxEXPAND|wxALL, 1); + sDevice[i]->AddStretchSpacer(); +#ifdef _WIN32 + sDevice[i]->Add(m_X360Pad[i], 0, wxEXPAND|wxALL, 1); + sDevice[i]->Add(m_X360PadC[i], 0, wxEXPAND|wxALL, 1); + sDevice[i]->Add(m_Rumble[i], 0, wxEXPAND|wxALL, 1); + sDevice[i]->AddStretchSpacer(); +#endif + sDevice[i]->Add(m_Disable[i], 0, wxEXPAND|wxALL, 1); + sbDevice[i]->Add(sDevice[i], 0, wxEXPAND|wxALL, 1); + + sButtons[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Buttons")); + + AddControl(m_Controller[i], &(m_ButtonA[i]), sButtons[i], "A: ", CTL_A, i); + AddControl(m_Controller[i], &(m_ButtonB[i]), sButtons[i], "B: ", CTL_B, i); + AddControl(m_Controller[i], &(m_ButtonX[i]), sButtons[i], "X: ", CTL_X, i); + AddControl(m_Controller[i], &(m_ButtonY[i]), sButtons[i], "Y: ", CTL_Y, i); + AddControl(m_Controller[i], &(m_ButtonZ[i]), sButtons[i], "Z: ", CTL_Z, i); + AddControl(m_Controller[i], &(m_ButtonStart[i]), sButtons[i], "Start: ", CTL_START, i); + + sTriggers[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Triggers")); + + AddControl(m_Controller[i], &(m_ButtonL[i]), sTriggers[i], " L: ", CTL_L, i); + AddControl(m_Controller[i], &(m_ButtonR[i]), sTriggers[i], " R: ", CTL_R, i); + + sModifiers[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Modifiers")); + + AddControl(m_Controller[i], &(m_HalfPress[i]), sModifiers[i], "1/2 Press: ", CTL_HALFPRESS, i); + + sStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Main Stick")); + + AddControl(m_Controller[i], &(m_StickUp[i]), sStick[i], "Up: ", CTL_MAINUP, i); + AddControl(m_Controller[i], &(m_StickDown[i]), sStick[i], "Down: ", CTL_MAINDOWN, i); + AddControl(m_Controller[i], &(m_StickLeft[i]), sStick[i], "Left: ", CTL_MAINLEFT, i); + AddControl(m_Controller[i], &(m_StickRight[i]), sStick[i], "Right: ", CTL_MAINRIGHT, i); + + sDPad[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("D-Pad")); + + AddControl(m_Controller[i], &(m_DPadUp[i]), sDPad[i], "Up: ", CTL_DPADUP, i); + AddControl(m_Controller[i], &(m_DPadDown[i]), sDPad[i], "Down: ", CTL_DPADDOWN, i); + AddControl(m_Controller[i], &(m_DPadLeft[i]), sDPad[i], "Left: ", CTL_DPADLEFT, i); + AddControl(m_Controller[i], &(m_DPadRight[i]), sDPad[i], "Right: ", CTL_DPADRIGHT, i); + + sCStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("C-Stick")); + + AddControl(m_Controller[i], &(m_CStickUp[i]), sCStick[i], "Up: ", CTL_SUBUP, i); + AddControl(m_Controller[i], &(m_CStickDown[i]), sCStick[i], "Down: ", CTL_SUBDOWN, i); + AddControl(m_Controller[i], &(m_CStickLeft[i]), sCStick[i], "Left: ", CTL_SUBLEFT, i); + AddControl(m_Controller[i], &(m_CStickRight[i]), sCStick[i], "Right: ", CTL_SUBRIGHT, i); + + sPage[i] = new wxGridBagSizer(0, 0); + sPage[i]->SetFlexibleDirection(wxBOTH); + sPage[i]->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); + sPage[i]->Add(sbDevice[i], wxGBPosition(0, 0), wxGBSpan(1, 5), wxEXPAND|wxALL, 1); + sPage[i]->Add(sButtons[i], wxGBPosition(1, 0), wxGBSpan(2, 1), wxALL, 1); + sPage[i]->Add(sTriggers[i], wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 1); + sPage[i]->Add(sModifiers[i], wxGBPosition(2, 1), wxGBSpan(1, 1), wxALL, 1); + sPage[i]->Add(sStick[i], wxGBPosition(1, 2), wxGBSpan(2, 1), wxALL, 1); + sPage[i]->Add(sDPad[i], wxGBPosition(1, 3), wxGBSpan(2, 1), wxALL, 1); + sPage[i]->Add(sCStick[i], wxGBPosition(1, 4), wxGBSpan(2, 1), wxALL, 1); + m_Controller[i]->SetSizer(sPage[i]); + sPage[i]->Layout(); + } +} + +void ConfigDialog::OnClose(wxCloseEvent& event) +{ +#ifdef _WIN32 + m_dinput.Free(); +#endif + EndModal(0); +} + +void ConfigDialog::OnKeyDown(wxKeyEvent& event) +{ + if(clickedButton != NULL) + { + int page = m_Notebook->GetSelection(); + +#ifdef _WIN32 + m_dinput.Read(); + for(int i = 0; i < 255; i++) + { + if(m_dinput.diks[i]) + { + char keyStr[10] = {0}; + pad[page].keyForControl[clickedButton->GetId()] = i; + DInput::DIKToString(i, keyStr); + clickedButton->SetLabel(wxString::FromAscii(keyStr)); + break; + } + } +#else + pad[page].keyForControl[clickedButton->GetId()] = wxCharCodeWXToX(event.GetKeyCode()); + clickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode())); +#endif + clickedButton->Disconnect(); + } + + clickedButton = NULL; + event.Skip(); +} + +void ConfigDialog::OnCloseClick(wxCommandEvent& event) +{ + Close(); +} + +void ConfigDialog::ControllerSettingsChanged(wxCommandEvent& event) +{ + int page = m_Notebook->GetSelection(); + + switch (event.GetId()) + { + case ID_ATTACHED: + pad[page].bAttached = m_Attached[page]->GetValue(); + break; + case ID_X360PAD: + pad[page].bEnableXPad = event.IsChecked(); + m_Rumble[page]->Enable(event.IsChecked()); + m_X360PadC[page]->Enable(event.IsChecked()); + break; + case ID_X360PAD_CHOICE: + pad[page].XPadPlayer = event.GetSelection(); + break; + case ID_RUMBLE: + pad[page].bRumble = m_Rumble[page]->GetValue(); + break; + case ID_DISABLE: + pad[page].bDisable = m_Disable[page]->GetValue(); + break; + } +} + +void ConfigDialog::OnButtonClick(wxCommandEvent& event) +{ + if(clickedButton) + { + clickedButton->SetLabel(oldLabel); + } + clickedButton = (wxButton *)event.GetEventObject(); + oldLabel = clickedButton->GetLabel(); + clickedButton->SetLabel(_("Press Key")); + + clickedButton->Connect(wxID_ANY, wxEVT_KEY_DOWN, + wxKeyEventHandler(ConfigDialog::OnKeyDown), + (wxObject*)NULL, this); +} +void ConfigDialog::DllAbout(wxCommandEvent& event) +{ wxString message; #ifdef _WIN32 message = _("A simple keyboard and XInput plugin for dolphin."); @@ -335,5 +335,5 @@ void ConfigDialog::DllAbout(wxCommandEvent& event) #endif wxMessageBox(_T("Dolphin PadSimple Plugin\nBy ector and F|RES\n\n" + message), - _T("Dolphin PadSimple"), wxOK, this); -} + _T("Dolphin PadSimple"), wxOK, this); +} diff --git a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp index 49cfc08df1..1a718740b6 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp @@ -170,4 +170,4 @@ namespace EmuWindow rc.bottom = rc.top + h; ::MoveWindow(m_hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); } -} \ No newline at end of file +} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp index 251bb6a7ce..6e4ea5c6c7 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp @@ -78,6 +78,7 @@ void Config::Load() iniFile.Get("Hacks", "EFBToTextureDisable", &bEBFToTextureDisable, 0); + iniFile.Get("Hacks", "EBFToTextureDisableHotKey", &bEBFToTextureDisableHotKey, 0); iniFile.Get("Hacks", "ProjectionHax1", &bProjectionHax1, 0); iniFile.Get("Hacks", "ProjectionHax2", &bProjectionHax2, 0); } @@ -112,6 +113,7 @@ void Config::Save() iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso); iniFile.Set("Hacks", "EFBToTextureDisable", bEBFToTextureDisable); + iniFile.Set("Hacks", "EBFToTextureDisableHotKey", &bEBFToTextureDisableHotKey); iniFile.Set("Hacks", "ProjectionHax1", bProjectionHax1); iniFile.Set("Hacks", "ProjectionHax2", bProjectionHax2); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.h b/Source/Plugins/Plugin_VideoOGL/Src/Config.h index 5642467f7e..4fc640d681 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.h @@ -62,7 +62,7 @@ struct Config bool bDumpTextures; // Hacks - bool bEBFToTextureDisable; + bool bEBFToTextureDisable; bool bEBFToTextureDisableHotKey; bool bProjectionHax1; bool bProjectionHax2; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp index b7fdb2fe9f..d2886fd5cf 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp @@ -97,7 +97,12 @@ void ConfigDialog::CreateGUIControls() m_Fullscreen->SetValue(g_Config.bFullscreen); m_RenderToMainWindow = new wxCheckBox(m_PageGeneral, ID_RENDERTOMAINWINDOW, wxT("Render to main window"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_RenderToMainWindow->SetValue(g_Config.renderToMainframe); - m_StretchToFit = new wxCheckBox(m_PageGeneral, ID_STRETCHTOFIT, wxT("Stretch to fit (instead of changing res.)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_StretchToFit = new wxCheckBox(m_PageGeneral, ID_STRETCHTOFIT, wxT("Stretch to fit"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_StretchToFit->SetToolTip + ("This will use the game's native resolution and stretch it to fill the" + "\nwindow instead of changing the internal display resolution. It" + "\nmay result in a slightly blurrier image, but it may also give a higher" + "\nFPS if you have a slow graphics card."); m_StretchToFit->SetValue(g_Config.bStretchToFit); m_KeepAR = new wxCheckBox(m_PageGeneral, ID_KEEPAR, wxT("Keep 4:3 aspect ratio"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_KeepAR->SetValue(g_Config.bKeepAR); @@ -188,11 +193,20 @@ void ConfigDialog::CreateGUIControls() // Hacks sbHacks = new wxStaticBoxSizer(wxVERTICAL, m_PageAdvanced, wxT("Hacks")); - m_EFBToTextureDisable = new wxCheckBox(m_PageAdvanced, ID_EFBTOTEXTUREDISABLE, wxT("Disable copy EFB to texture"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_EFBToTextureDisable = new wxCheckBox(m_PageAdvanced, + ID_EFBTOTEXTUREDISABLE, wxT("Disable copy EFB to texture"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_EFBToTextureDisable->SetToolTip("Do not copy the Embedded Framebuffer (EFB)" + " to the\nTexture. This may result in a speed increase."); m_EFBToTextureDisable->Enable(true); m_EFBToTextureDisable->SetValue(g_Config.bEBFToTextureDisable); + m_EFBToTextureDisableHotKey = new wxCheckBox(m_PageAdvanced, + ID_EFBTOTEXTUREDISABLEHOTKEY, wxT("with hotkey E"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_EFBToTextureDisableHotKey->SetToolTip("Use the E key to turn this option on and off"); + m_EFBToTextureDisableHotKey->SetValue(g_Config.bEBFToTextureDisableHotKey); m_ProjectionHax1 = new wxCheckBox(m_PageAdvanced, ID_PROJECTIONHACK1, wxT("Projection before R945"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_ProjectionHax1->SetToolTip("This may reveal otherwise invisible graphics" + " in\ngames like Mario Galaxy or Ikaruga."); m_ProjectionHax1->Enable(true); m_ProjectionHax1->SetValue(g_Config.bProjectionHax1); @@ -226,6 +240,7 @@ void ConfigDialog::CreateGUIControls() sHacks = new wxGridBagSizer(0, 0); sHacks->Add(m_EFBToTextureDisable, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5); + sHacks->Add(m_EFBToTextureDisableHotKey, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALL, 5); sHacks->Add(m_ProjectionHax1, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 5); sHacks->Add(m_ProjectionHax2, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL, 5); sbHacks->Add(sHacks); @@ -288,7 +303,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) case ID_STRETCHTOFIT: g_Config.bStretchToFit = m_StretchToFit->IsChecked(); break; - case ID_KEEPAR: + case ID_KEEPAR: g_Config.bKeepAR = m_KeepAR->IsChecked(); break; case ID_HIDECURSOR: @@ -355,6 +370,9 @@ void ConfigDialog::AdvancedSettingsChanged(wxCommandEvent& event) case ID_EFBTOTEXTUREDISABLE: g_Config.bEBFToTextureDisable = m_EFBToTextureDisable->IsChecked(); break; + case ID_EFBTOTEXTUREDISABLEHOTKEY: + g_Config.bEBFToTextureDisableHotKey = m_EFBToTextureDisableHotKey->IsChecked(); + break; case ID_PROJECTIONHACK1: g_Config.bProjectionHax1 = m_ProjectionHax1->IsChecked(); break; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h index 71d7c70a15..ee343e23a6 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h @@ -93,7 +93,7 @@ class ConfigDialog : public wxDialog wxCheckBox *m_DisableTexturing; wxCheckBox *m_DumpTextures; wxDirPickerCtrl *m_TexturePath; - wxCheckBox *m_EFBToTextureDisable; + wxCheckBox *m_EFBToTextureDisable, *m_EFBToTextureDisableHotKey; wxCheckBox *m_ProjectionHax1; wxCheckBox *m_ProjectionHax2; @@ -135,7 +135,7 @@ class ConfigDialog : public wxDialog ID_DUMPTEXTURES, ID_TEXTUREPATH, - ID_EFBTOTEXTUREDISABLE, + ID_EFBTOTEXTUREDISABLE, ID_EFBTOTEXTUREDISABLEHOTKEY, ID_PROJECTIONHACK1, ID_PROJECTIONHACK2 }; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp index 62c402f1b3..b656d5a3f4 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp @@ -29,8 +29,9 @@ #include "main.h" #include "Win32.h" +#include "Render.h" // for AddMessage -#include "IniFile.h" // we need this for the debugger to work +#include "StringUtil.h" // for StringFromFormat void OpenConsole(); void CloseConsole(); @@ -136,6 +137,14 @@ namespace EmuWindow case MY_KEYS: hypotheticalScene->sendMessage(KEYDOWN...); */ + case 'E': // EFB hotkey + if(g_Config.bEBFToTextureDisableHotKey) + { + g_Config.bEBFToTextureDisable = !g_Config.bEBFToTextureDisable; + Renderer::AddMessage(StringFromFormat("Copy EFB was turned %s", + g_Config.bEBFToTextureDisable ? "off" : "on").c_str(), 5000); + } + break; } g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0); break;