apply the new wxw method to dsp hle, wiimote, and padsimple.

wiimote config now loads way faster :)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3649 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman
2009-07-02 19:00:27 +00:00
parent 12efada734
commit 99a33ccba9
24 changed files with 618 additions and 689 deletions

View File

@ -26,48 +26,48 @@
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)
BEGIN_EVENT_TABLE(PADConfigDialogSimple,wxDialog)
EVT_CLOSE(PADConfigDialogSimple::OnClose)
EVT_BUTTON(ID_CLOSE,PADConfigDialogSimple::OnCloseClick)
EVT_BUTTON(ID_PAD_ABOUT,PADConfigDialogSimple::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_CHECKBOX(ID_ATTACHED,PADConfigDialogSimple::ControllerSettingsChanged)
EVT_CHECKBOX(ID_X360PAD,PADConfigDialogSimple::ControllerSettingsChanged)
EVT_CHOICE(ID_X360PAD_CHOICE,PADConfigDialogSimple::ControllerSettingsChanged)
EVT_CHECKBOX(ID_RUMBLE,PADConfigDialogSimple::ControllerSettingsChanged)
EVT_CHECKBOX(ID_DISABLE,PADConfigDialogSimple::ControllerSettingsChanged)
// Input recording
#ifdef RERECORDING
EVT_CHECKBOX(ID_RECORDING,ConfigDialog::ControllerSettingsChanged)
EVT_CHECKBOX(ID_PLAYBACK,ConfigDialog::ControllerSettingsChanged)
EVT_BUTTON(ID_SAVE_RECORDING,ConfigDialog::ControllerSettingsChanged)
EVT_CHECKBOX(ID_RECORDING,PADConfigDialogSimple::ControllerSettingsChanged)
EVT_CHECKBOX(ID_PLAYBACK,PADConfigDialogSimple::ControllerSettingsChanged)
EVT_BUTTON(ID_SAVE_RECORDING,PADConfigDialogSimple::ControllerSettingsChanged)
#endif
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)
EVT_BUTTON(CTL_A,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_B,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_X,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_Y,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_Z,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_START,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_L,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_R,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAINUP,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAINDOWN,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAINLEFT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAINRIGHT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_SUBUP,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_SUBDOWN,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_SUBLEFT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_SUBRIGHT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADUP,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADDOWN,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADLEFT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADRIGHT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_HALFPRESS,PADConfigDialogSimple::OnButtonClick)
END_EVENT_TABLE()
ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
PADConfigDialogSimple::PADConfigDialogSimple(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
#ifdef _WIN32
@ -79,11 +79,11 @@ ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &titl
// Connect keydown to the window
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN,
wxKeyEventHandler(ConfigDialog::OnKeyDown),
wxKeyEventHandler(PADConfigDialogSimple::OnKeyDown),
(wxObject*)NULL, this);
}
ConfigDialog::~ConfigDialog()
PADConfigDialogSimple::~PADConfigDialogSimple()
{
}
@ -118,7 +118,7 @@ inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer,
////////////////////////////////////
void ConfigDialog::CreateGUIControls()
void PADConfigDialogSimple::CreateGUIControls()
{
// Notebook
m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize);
@ -324,7 +324,7 @@ void ConfigDialog::CreateGUIControls()
}
}
void ConfigDialog::OnClose(wxCloseEvent& event)
void PADConfigDialogSimple::OnClose(wxCloseEvent& event)
{
#ifdef _WIN32
m_dinput.Free();
@ -332,7 +332,7 @@ void ConfigDialog::OnClose(wxCloseEvent& event)
EndModal(0);
}
void ConfigDialog::OnKeyDown(wxKeyEvent& event)
void PADConfigDialogSimple::OnKeyDown(wxKeyEvent& event)
{
char keyStr[10] = {0};
if(ClickedButton != NULL)
@ -368,7 +368,7 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event)
}
// We have clicked a button
void ConfigDialog::OnButtonClick(wxCommandEvent& event)
void PADConfigDialogSimple::OnButtonClick(wxCommandEvent& event)
{
// Check if the Space key was set, to solve the problem that the Space key calls this function
#ifdef _WIN32
@ -386,12 +386,12 @@ void ConfigDialog::OnButtonClick(wxCommandEvent& event)
ClickedButton->SetWindowStyle(wxWANTS_CHARS);
}
void ConfigDialog::OnCloseClick(wxCommandEvent& event)
void PADConfigDialogSimple::OnCloseClick(wxCommandEvent& event)
{
Close();
}
void ConfigDialog::ControllerSettingsChanged(wxCommandEvent& event)
void PADConfigDialogSimple::ControllerSettingsChanged(wxCommandEvent& event)
{
int page = m_Notebook->GetSelection();
@ -438,7 +438,7 @@ void ConfigDialog::ControllerSettingsChanged(wxCommandEvent& event)
}
}
void ConfigDialog::DllAbout(wxCommandEvent& event)
void PADConfigDialogSimple::DllAbout(wxCommandEvent& event)
{
wxString message;
#ifdef _WIN32

View File

@ -33,15 +33,15 @@
#include "../XInputBase.h"
#endif
class ConfigDialog : public wxDialog
class PADConfigDialogSimple : public wxDialog
{
public:
ConfigDialog(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("Pad Configuration"),
PADConfigDialogSimple(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("Pad Configuration"),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE);
virtual ~ConfigDialog();
virtual ~PADConfigDialogSimple();
private:
DECLARE_EVENT_TABLE();

View File

@ -16,9 +16,8 @@
// http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Include
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#include <stdio.h>
#include <math.h>
@ -32,6 +31,7 @@
#if defined(HAVE_WX) && HAVE_WX
#include "GUI/ConfigDlg.h"
PADConfigDialogSimple* m_ConfigFrame = NULL;
#endif
#ifdef _WIN32
@ -55,23 +55,81 @@
#include <Cocoa/Cocoa.h>
bool KeyStatus[NUMCONTROLS];
#endif
////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Declarations
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SPads pad[4];
HINSTANCE g_hInstance;
SPADInitialize g_PADInitialize;
////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Standard crap to make wxWidgets happy
#ifdef _WIN32
HINSTANCE g_hInstance;
#if defined(HAVE_WX) && HAVE_WX
class wxDLLApp : public wxApp
{
bool OnInit()
{
return true;
}
};
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
#endif
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
DWORD dwReason, // reason called
LPVOID lpvReserved) // reserved
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{
#if defined(HAVE_WX) && HAVE_WX
wxSetInstance((HINSTANCE)hinstDLL);
int argc = 0;
char **argv = NULL;
wxEntryStart(argc, argv);
if (!wxTheApp || !wxTheApp->CallOnInit())
return FALSE;
#endif
}
break;
case DLL_PROCESS_DETACH:
#if defined(HAVE_WX) && HAVE_WX
wxEntryCleanup();
#endif
break;
default:
break;
}
g_hInstance = hinstDLL;
return TRUE;
}
#endif
#if defined(HAVE_WX) && HAVE_WX
wxWindow* GetParentedWxWindow(HWND Parent)
{
#ifdef _WIN32
wxSetInstance((HINSTANCE)g_hInstance);
#endif
wxWindow *win = new wxWindow();
#ifdef _WIN32
win->SetHWND((WXHWND)Parent);
win->AdoptAttributesFromHWND();
#endif
return win;
}
#endif
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Input Recording
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Enable these to record or play back
//#define RECORD_REPLAY
@ -83,7 +141,6 @@ PLUGIN_GLOBALS* globals = NULL;
SPADStatus recordBuffer[RECORD_SIZE];
int count = 0;
bool g_EmulatorRunning = false;
////////////////////////////////
//******************************************************************************
// Supporting functions
@ -169,57 +226,11 @@ bool IsFocus()
#endif
}
#ifdef _WIN32
class wxDLLApp : public wxApp
{
bool OnInit()
{
return true;
}
};
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
DWORD dwReason, // reason called
LPVOID lpvReserved) // reserved
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{ //use wxInitialize() if you don't want GUI instead of the following 12 lines
wxSetInstance((HINSTANCE)hinstDLL);
int argc = 0;
char **argv = NULL;
wxEntryStart(argc, argv);
if ( !wxTheApp || !wxTheApp->CallOnInit() )
return FALSE;
}
break;
case DLL_PROCESS_DETACH:
wxEntryCleanup(); //use wxUninitialize() if you don't want GUI
break;
default:
break;
}
g_hInstance = hinstDLL;
return(TRUE);
}
#endif
const float kDeadZone = 0.1f;
// Implement circular deadzone
const float kDeadZone = 0.1f;
void ScaleStickValues(unsigned char* outx,
unsigned char* outy,
short inx, short iny)
unsigned char* outy,
short inx, short iny)
{
float x = ((float)inx + 0.5f) / 32767.5f;
float y = ((float)iny + 0.5f) / 32767.5f;
@ -616,21 +627,19 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals)
void DllConfig(HWND _hParent)
{
//Console::Open(70, 5000);
// Load configuration
LoadConfig();
// Show wxDialog
#ifdef _WIN32
wxWindow win;
win.SetHWND(_hParent);
ConfigDialog frame(&win);
frame.ShowModal();
win.SetHWND(0);
#elif defined(HAVE_WX) && HAVE_WX
ConfigDialog frame(NULL);
frame.ShowModal();
#if defined(HAVE_WX) && HAVE_WX
if (!m_ConfigFrame)
m_ConfigFrame = new PADConfigDialogSimple(GetParentedWxWindow(_hParent));
// Only allow one open at a time
if (!m_ConfigFrame->IsShown())
m_ConfigFrame->ShowModal();
else
m_ConfigFrame->Hide();
#endif
// Save configuration
@ -641,18 +650,13 @@ void DllDebugger(HWND _hParent, bool Show) {}
void Initialize(void *init)
{
//Console::Open(70, 5000);
// We are now running a game
g_EmulatorRunning = true;
// Load configuration
LoadConfig();
// -------------------------------------------
// Rerecording
// ----------------------
#ifdef RERECORDING
#ifdef RERECORDING
/* Check if we are starting the pad to record the input, and an old file exists. In that case ask
if we really want to start the recording and eventually overwrite the file */
if (pad[0].bRecording && File::Exists("pad-record.bin"))
@ -670,8 +674,7 @@ void Initialize(void *init)
// Load recorded input if we are to play it back, otherwise begin with a blank recording
if (pad[0].bPlayback) LoadRecord();
#endif
// ----------------------
#endif
g_PADInitialize = *(SPADInitialize*)init;
@ -706,18 +709,13 @@ void DoState(unsigned char **ptr, int mode)
void Shutdown()
{
//Console::Print("ShutDown()\n");
// -------------------------------------------
// Save the recording and reset the counter
// ----------------------
#ifdef RERECORDING
#ifdef RERECORDING
// Save recording
if (pad[0].bRecording) SaveRecord();
// Reset the counter
count = 0;
#endif
// ----------------------
#endif
// We have stopped the game
g_EmulatorRunning = false;
@ -737,7 +735,6 @@ void Shutdown()
// Set buttons status from wxWidgets in the main application
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void PAD_Input(u16 _Key, u8 _UpDown) {}
@ -746,17 +743,14 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
// Check if all is okay
if (_pPADStatus == NULL) return;
// -------------------------------------------
// Play back input instead of accepting any user input
// ----------------------
#ifdef RERECORDING
#ifdef RERECORDING
if (pad[0].bPlayback)
{
*_pPADStatus = PlayRecord();
return;
}
#endif
// ----------------------
#endif
const int base = 0x80;
// Clear pad
@ -788,14 +782,10 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
cocoa_Read(_numPAD, _pPADStatus);
#endif
// -------------------------------------------
// Rerecording
// ----------------------
#ifdef RERECORDING
#ifdef RERECORDING
// Record input
if (pad[0].bRecording) RecordInput(*_pPADStatus);
#endif
// ----------------------
#endif
}
@ -950,7 +940,6 @@ void LoadConfig()
file.Get(SectionName, "RumbleStrength", &pad[i].RumbleStrength, 8000);
file.Get(SectionName, "XPad#", &pad[i].XPadPlayer);
// Recording
#ifdef RERECORDING
file.Get(SectionName, "Recording", &pad[0].bRecording, false);
file.Get(SectionName, "Playback", &pad[0].bPlayback, false);
@ -986,12 +975,12 @@ void SaveConfig()
file.Set(SectionName, "Rumble", pad[i].bRumble);
file.Set(SectionName, "RumbleStrength", pad[i].RumbleStrength);
file.Set(SectionName, "XPad#", pad[i].XPadPlayer);
// Recording
#ifdef RERECORDING
file.Set(SectionName, "Recording", pad[0].bRecording);
file.Set(SectionName, "Playback", pad[0].bPlayback);
#endif
for (int x = 0; x < NUMCONTROLS; x++)
{
file.Set(SectionName, controlNames[x], pad[i].keyForControl[x]);
@ -999,5 +988,3 @@ void SaveConfig()
}
file.Save(FULL_CONFIG_DIR "pad.ini");
}