New Wiimote Plugin: Added real wiimote support.(only tested on Windows, still a few probs: after refresh alt+F{5..8} x2 is needed) New Wiimote/GCPad: Re-merged Keyboard+Mouse for easier kb+mouse configuration, like before.(DirectInput doesn't support individual kb/mice anymore like I thought it did) Fixed some bugs and maybe leaks in GUI.(got rid of evil dynamic_cast) Renamed stuff from DirectInput to DInput, cause it's shorter and rhymes with XInput, I guess. (I remembered eol-style native, shuffle lost his job :P)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5822 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak
2010-07-03 08:04:10 +00:00
parent 0dc8833396
commit 0bf3dfda03
25 changed files with 1276 additions and 736 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Version="9.00"
Name="Plugin_Wiimote"
ProjectGUID="{8D612734-FAA5-4B8A-804F-4DEA2367D495}"
RootNamespace="Plugin_Wiimote"
@ -67,7 +67,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib rpcrt4.lib wxbase28ud.lib wxmsw28ud_core.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib rpcrt4.lib wxbase28ud.lib wxmsw28ud_core.lib"
OutputFile="..\..\..\Binary\Win32/Plugins\Plugin_WiimoteD.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\WiiUse\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32"
@ -402,7 +402,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/NODEFAULTLIB:msvcrt.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib wiiuse.lib"
OutputFile="..\..\..\Binary\Win32\Plugins\Plugin_WiimoteDF.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\WiiUse\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32"
@ -484,7 +484,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib wiiuse.lib"
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_WiimoteDF.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\WiiUse\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64"

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Version="9.00"
Name="Plugin_WiimoteNew"
ProjectGUID="{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}"
RootNamespace="Plugin_WiimoteNew"
@ -44,7 +44,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\Core\Common\Src;..\InputPluginCommon\Src;..\..\Core\InputCommon\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\inc;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;Plugin_WiimoteNew_TEST_EXPORTS;_SECURE_SCL=0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -67,10 +67,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28ud.lib wxmsw28ud_core.lib openal32.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28ud.lib wxmsw28ud_core.lib openal32.lib wiiuse.lib"
OutputFile="..\..\..\Binary\Win32/Plugins\Plugin_WiimoteNewD.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32;../../../Externals/OpenAL/Win32/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;;&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;../../../Externals/OpenAL/Win32/;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
@ -130,7 +130,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\Core\Common\Src;..\InputPluginCommon\Src;..\..\Core\InputCommon\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\inc;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;Plugin_WiimoteNew_TEST_EXPORTS;_SECURE_SCL=0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -151,10 +151,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28ud.lib wxmsw28ud_core.lib openal32.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28ud.lib wxmsw28ud_core.lib openal32.lib wiiuse.lib"
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_WiimoteNewD.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64;../../../Externals/OpenAL/Win64/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;;&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;../../../Externals/OpenAL/Win64/;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
@ -213,7 +213,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\Core\Common\Src;..\InputPluginCommon\Src;..\..\Core\InputCommon\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\inc;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;Plugin_WiimoteNew_TEST_EXPORTS;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
AssemblerListingLocation="$(IntDir)\"
@ -235,10 +235,10 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/NODEFAULTLIB:msvcrt.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib wiiuse.lib"
OutputFile="..\..\..\Binary\Win32\Plugins\Plugin_WiimoteNew.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32;../../../Externals/OpenAL/Win32/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;;&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;../../../Externals/OpenAL/Win32/;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
@ -299,7 +299,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\Core\Common\Src;..\InputPluginCommon\Src;..\..\Core\InputCommon\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\inc;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;Plugin_WiimoteNew_TEST_EXPORTS;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
AssemblerListingLocation="$(IntDir)\"
@ -320,10 +320,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib wiiuse.lib"
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_WiimoteNew.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64;../../../Externals/OpenAL/Win64/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;;&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;../../../Externals/OpenAL/Win64/;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
@ -382,7 +382,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\Core\Common\Src;..\InputPluginCommon\Src;..\..\Core\InputCommon\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\inc;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="DEBUGFAST;WIN32;NDEBUG;_WINDOWS;_USRDLL;Plugin_WiimoteNew_TEST_EXPORTS;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
WarningLevel="3"
@ -402,10 +402,10 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/NODEFAULTLIB:msvcrt.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib wiiuse.lib"
OutputFile="..\..\..\Binary\Win32\Plugins\Plugin_WiimoteNewDF.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32;../../../Externals/OpenAL/Win32/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;;&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;../../../Externals/OpenAL/Win32/;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
@ -465,7 +465,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\Core\Common\Src;..\InputPluginCommon\Src;..\..\Core\InputCommon\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\inc;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;Plugin_WiimoteNew_TEST_EXPORTS;DEBUGFAST;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
WarningLevel="3"
@ -484,10 +484,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib wiiuse.lib"
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_WiimoteNewDF.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64;../../../Externals/OpenAL/Win64/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;;&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;../../../Externals/OpenAL/Win64/;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
@ -601,6 +601,26 @@
</File>
</Filter>
</Filter>
<Filter
Name="WiimoteReal"
>
<File
RelativePath=".\Src\WiimoteReal\WiimoteReal.cpp"
>
</File>
<File
RelativePath=".\Src\WiimoteReal\WiimoteReal.h"
>
</File>
</Filter>
<File
RelativePath=".\Src\WiimoteConfigDiag.cpp"
>
</File>
<File
RelativePath=".\Src\WiimoteConfigDiag.h"
>
</File>
<File
RelativePath=".\Src\WiimoteNew.cpp"
>

View File

@ -16,7 +16,9 @@ files = [
'WiimoteEmu/EmuSubroutines.cpp',
'WiimoteEmu/Encryption.cpp',
'WiimoteEmu/Speaker.cpp',
'WiimoteReal/WiimoteReal.cpp',
'WiimoteNew.cpp',
'WiimoteConfigDiag.cpp',
]
wiinewenv.Append(

View File

@ -0,0 +1,114 @@
#include "WiimoteConfigDiag.h"
#include "WiimoteReal/WiimoteReal.h"
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
WiimoteConfigPage::WiimoteConfigPage(wxWindow* const parent, const int index)
: wxNotebookPage(parent, -1, wxDefaultPosition, wxDefaultSize)
, m_index(index)
{
// input source
m_input_src_choice = new wxChoice(this, -1, wxDefaultPosition);
m_input_src_choice->Append(wxT("None"));
m_input_src_choice->Append(wxT("Emulated Wiimote"));
m_input_src_choice->Append(wxT("Real Wiimote"));
m_input_src_choice->Select(g_wiimote_sources[m_index]);
_connect_macro_(m_input_src_choice, WiimoteConfigPage::SelectSource, wxEVT_COMMAND_CHOICE_SELECTED, this);
wxStaticBoxSizer* const input_src_sizer = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("Input Source"));
input_src_sizer->Add(m_input_src_choice, 1, wxEXPAND | wxALL, 5);
// emulated wiimote
wxButton* const configure_wiimote_emu_btn = new wxButton(this, -1, wxT("Configure"));
wxStaticBoxSizer* const wiimote_emu_sizer = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("Emulated Wiimote"));
wiimote_emu_sizer->Add(configure_wiimote_emu_btn, 1, wxEXPAND | wxALL, 5);
_connect_macro_(configure_wiimote_emu_btn, WiimoteConfigDiag::ConfigEmulatedWiimote, wxEVT_COMMAND_BUTTON_CLICKED, parent->GetParent());
// real wiimote
m_connected_wiimotes_txt = new wxStaticText(this, -1, wxEmptyString);
wxStaticBoxSizer* const wiimote_real_sizer = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Real Wiimote"));
wxButton* const refresh_btn = new wxButton(this, -1, wxT("Refresh"), wxDefaultPosition);
_connect_macro_(refresh_btn, WiimoteConfigPage::RefreshRealWiimotes, wxEVT_COMMAND_BUTTON_CLICKED, this);
wiimote_real_sizer->Add(m_connected_wiimotes_txt, 1, wxALIGN_CENTER | wxALL, 5);
wiimote_real_sizer->Add(refresh_btn, 1, wxALIGN_CENTER | wxALL, 5);
m_connected_wiimotes_txt->SetLabel(wxString(wxT("Connected to ")) + wxChar(wxT('0') + WiimoteReal::Initialize()) + wxT(" Real Wiimotes"));
// sizers
wxBoxSizer* const left_sizer = new wxBoxSizer(wxVERTICAL);
left_sizer->Add(input_src_sizer, 1, wxEXPAND | wxBOTTOM, 5);
left_sizer->Add(wiimote_emu_sizer, 1, wxEXPAND, 0);
wxBoxSizer* const main_sizer = new wxBoxSizer(wxHORIZONTAL);
main_sizer->Add(left_sizer, 1, wxLEFT | wxTOP | wxBOTTOM | wxEXPAND, 5);
main_sizer->Add(wiimote_real_sizer, 1, wxALL | wxEXPAND, 5);
SetSizerAndFit(main_sizer);
Layout();
}
WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin)
: wxDialog(parent, -1, wxT("Dolphin Wiimote Configuration"), wxDefaultPosition, wxDefaultSize)
, m_plugin(plugin)
{
m_pad_notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT);
for (unsigned int i = 0; i < 4; ++i)
{
WiimoteConfigPage* const wpage = new WiimoteConfigPage(m_pad_notebook, i);
//m_padpages.push_back(wpage);
m_pad_notebook->AddPage(wpage, wxString(wxT("Wiimote ")) + wxChar('1'+i));
}
wxButton* const ok_button = new wxButton(this, -1, wxT("OK"), wxDefaultPosition);
_connect_macro_(ok_button, WiimoteConfigDiag::Save, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(m_pad_notebook, 1, wxEXPAND | wxALL, 5);
main_sizer->Add(ok_button, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5);
SetSizerAndFit(main_sizer);
Center();
}
void WiimoteConfigDiag::ConfigEmulatedWiimote(wxCommandEvent& event)
{
InputConfigDialog* const m_emu_config_diag = new InputConfigDialog(this, m_plugin, "Dolphin Emulated Wiimote Configuration", m_pad_notebook->GetSelection());
m_emu_config_diag->ShowModal();
m_emu_config_diag->Destroy();
}
void WiimoteConfigPage::RefreshRealWiimotes(wxCommandEvent& event)
{
WiimoteReal::Refresh();
m_connected_wiimotes_txt->SetLabel(wxString(wxT("Connected to ")) + wxChar(wxT('0') + WiimoteReal::Initialize()) + wxT(" Real Wiimotes"));
}
void WiimoteConfigPage::SelectSource(wxCommandEvent& event)
{
// should be kinda fine, maybe should just set when user clicks OK, w/e change it later
g_wiimote_sources[m_index] = m_input_src_choice->GetSelection();
}
void WiimoteConfigDiag::Save(wxCommandEvent& event)
{
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + g_plugin.ini_name + ".ini" );
IniFile inifile;
inifile.Load(ini_filename);
for (unsigned int i=0; i<MAX_WIIMOTES; ++i)
{
std::string secname("Wiimote");
secname += (char)('1' + i);
IniFile::Section& sec = *inifile.GetOrCreateSection(secname.c_str());
sec.Set("Source", (int)g_wiimote_sources[i]);
}
inifile.Save(ini_filename);
Close();
}

View File

@ -0,0 +1,49 @@
#ifndef WIIMOTE_CONFIG_DIAG_H
#define WIIMOTE_CONFIG_DIAG_H
#include <wx/wx.h>
#include <wx/listbox.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/stattext.h>
#include <wx/combobox.h>
#include <wx/checkbox.h>
#include <wx/notebook.h>
#include <wx/panel.h>
#include <wx/spinctrl.h>
#include "ConfigDiag.h"
class WiimoteConfigPage : public wxNotebookPage
{
public:
WiimoteConfigPage(wxWindow* const parent, const int index);
void RefreshRealWiimotes(wxCommandEvent& event);
void SelectSource(wxCommandEvent& event);
private:
const int m_index;
wxStaticText* m_connected_wiimotes_txt;
wxChoice* m_input_src_choice;
};
class WiimoteConfigDiag : public wxDialog
{
public:
WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin);
void ConfigEmulatedWiimote(wxCommandEvent& event);
void Save(wxCommandEvent& event);
private:
InputPlugin& m_plugin;
wxNotebook* m_pad_notebook;
};
#endif

View File

@ -2,6 +2,9 @@
#include "Common.h"
#include "pluginspecs_wiimote.h"
#include "WiimoteConfigDiag.h"
#include "WiimoteReal/WiimoteReal.h"
#include "ControllerInterface/ControllerInterface.h"
#include "WiimoteEmu/WiimoteEmu.h"
@ -32,7 +35,7 @@
#endif
// plugin globals
static InputPlugin g_plugin( "WiimoteNew", "Wiimote", "Wiimote" );
InputPlugin g_plugin( "WiimoteNew", "Wiimote", "Wiimote" );
SWiimoteInitialize g_WiimoteInitialize;
#ifdef _WIN32
@ -90,7 +93,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
void DeInitPlugin()
{
if ( g_plugin.controller_interface.IsInit() )
if (g_plugin.controller_interface.IsInit())
{
std::vector<ControllerEmu*>::const_iterator
i = g_plugin.controllers.begin(),
@ -102,13 +105,16 @@ void DeInitPlugin()
// true parameter to make SDL not quit in the wiimote plugin,
// the old wiimote plugin uses this hack as well, to prevent crash on stop
g_plugin.controller_interface.DeInit(true);
// real wiimotes
WiimoteReal::Shutdown();
}
}
// if plugin isn't initialized, init and load config
void InitPlugin( void* const hwnd )
{
if ( false == g_plugin.controller_interface.IsInit() )
if (false == g_plugin.controller_interface.IsInit())
{
// add 4 wiimotes
for ( unsigned int i = 0; i<4; ++i )
@ -118,15 +124,18 @@ void InitPlugin( void* const hwnd )
g_plugin.LoadConfig();
// needed for Xlib and exclusive dinput
g_plugin.controller_interface.SetHwnd( hwnd );
g_plugin.controller_interface.SetHwnd(hwnd);
g_plugin.controller_interface.Init();
// update control refs
std::vector<ControllerEmu*>::const_iterator i = g_plugin.controllers.begin(),
std::vector<ControllerEmu*>::const_iterator
i = g_plugin.controllers.begin(),
e = g_plugin.controllers.end();
for ( ; i!=e; ++i )
(*i)->UpdateReferences( g_plugin.controller_interface );
// real wiimotes
WiimoteReal::Initialize();
}
}
@ -141,8 +150,15 @@ void InitPlugin( void* const hwnd )
//
void Wiimote_ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
{
//PanicAlert( "Wiimote_ControlChannel" );
((WiimoteEmu::Wiimote*)g_plugin.controllers[ _number ])->ControlChannel( _channelID, _pData, _Size );
switch (g_wiimote_sources[_number])
{
case WIIMOTE_SRC_REAL :
WiimoteReal::ControlChannel(_number, _channelID, _pData, _Size);
break;
case WIIMOTE_SRC_EMU :
((WiimoteEmu::Wiimote*)g_plugin.controllers[ _number ])->ControlChannel( _channelID, _pData, _Size );
break;
}
}
// __________________________________________________________________________________________________
@ -176,8 +192,15 @@ unsigned int Wiimote_UnPairWiimotes(void)
//
void Wiimote_InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
{
//PanicAlert( "Wiimote_InterruptChannel" );
((WiimoteEmu::Wiimote*)g_plugin.controllers[ _number ])->InterruptChannel( _channelID, _pData, _Size );
switch (g_wiimote_sources[_number])
{
case WIIMOTE_SRC_REAL :
WiimoteReal::InterruptChannel(_number, _channelID, _pData, _Size);
break;
case WIIMOTE_SRC_EMU :
((WiimoteEmu::Wiimote*)g_plugin.controllers[ _number ])->InterruptChannel( _channelID, _pData, _Size );
break;
}
}
// __________________________________________________________________________________________________
@ -202,7 +225,15 @@ void Wiimote_Update(int _number)
}
_last_number = _number;
((WiimoteEmu::Wiimote*)g_plugin.controllers[ _number ])->Update();
switch (g_wiimote_sources[_number])
{
case WIIMOTE_SRC_REAL :
WiimoteReal::Update(_number);
break;
case WIIMOTE_SRC_EMU :
((WiimoteEmu::Wiimote*)g_plugin.controllers[ _number ])->Update();
break;
}
g_plugin.controls_crit.Leave();
}
@ -250,11 +281,9 @@ void GetDllInfo(PLUGIN_INFO* _pPluginInfo)
void DllConfig(HWND _hParent)
{
#if defined(HAVE_WX) && HAVE_WX
bool was_init = false;
const bool was_init = g_plugin.controller_interface.IsInit();
if ( g_plugin.controller_interface.IsInit() ) // hack for showing dialog when game isnt running
was_init = true;
else
if (false == was_init)
{
#if defined(HAVE_X11) && HAVE_X11
Window win = GDK_WINDOW_XID(GTK_WIDGET(_hParent)->window);
@ -266,9 +295,9 @@ void DllConfig(HWND _hParent)
#endif
}
// copied from GCPad
wxWindow *frame = GetParentedWxWindow(_hParent);
InputConfigDialog* m_ConfigFrame = new InputConfigDialog(frame, g_plugin, PLUGIN_FULL_NAME);
WiimoteConfigDiag* const m_ConfigFrame = new WiimoteConfigDiag(frame, g_plugin);
//InputConfigDialog* const m_ConfigFrame = new InputConfigDialog(frame, g_plugin, PLUGIN_FULL_NAME);
#ifdef _WIN32
frame->Disable();
@ -279,17 +308,16 @@ void DllConfig(HWND _hParent)
#endif
#ifdef _WIN32
wxMilliSleep( 50 ); // hooray for hacks
wxMilliSleep(50); // hooray for hacks
frame->SetFocus();
frame->SetHWND(NULL);
#endif
m_ConfigFrame->Destroy();
m_ConfigFrame = NULL;
frame->Destroy();
// /
if ( false == was_init )
if (false == was_init)
DeInitPlugin();
#endif
}
@ -350,9 +378,11 @@ void Shutdown(void)
//
void DoState(unsigned char **ptr, int mode)
{
PointerWrap p(ptr, mode);
for (unsigned int i=0; i<4; ++i)
((WiimoteEmu::Wiimote*)g_plugin.controllers[i])->DoState(p);
// TODO: this
//PointerWrap p(ptr, mode);
//for (unsigned int i=0; i<4; ++i)
// ((WiimoteEmu::Wiimote*)g_plugin.controllers[i])->DoState(p);
}
// ___________________________________________________________________________
@ -364,4 +394,5 @@ void DoState(unsigned char **ptr, int mode)
void EmuStateChange(PLUGIN_EMUSTATE newState)
{
// maybe use this later
WiimoteReal::StateChange(newState);
}

View File

@ -0,0 +1,392 @@
// Copyright (C) 2003 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 <queue>
#include "Common.h"
#include "IniFile.h"
#include "Thread.h"
#include "StringUtil.h"
#include "Timer.h"
#include "pluginspecs_wiimote.h"
#include "wiiuse.h"
#include "WiimoteReal.h"
#include "../WiimoteEmu/WiimoteHid.h"
unsigned int g_wiimote_sources[MAX_WIIMOTES];
namespace WiimoteReal
{
bool g_real_wiimotes_initialized = false;
wiimote_t** g_wiimotes_from_wiiuse = NULL;
unsigned int g_wiimotes_found = 0;
volatile bool g_run_wiimote_thread = false;
Common::Thread *g_wiimote_thread = NULL;
Common::CriticalSection g_wiimote_critsec;
THREAD_RETURN WiimoteThreadFunc(void* arg);
// silly, copying data n stuff, o well, don't use this too often
void SendPacket(wiimote_t* const wm, const u8 rpt_id, const void* const data, const unsigned int size)
{
u8* const rpt = new u8[size + 2];
rpt[0] = 0xA1;
rpt[1] = rpt_id;
memcpy(rpt + 2, data, size);
wiiuse_io_write(wm, (byte*)rpt, size + 2);
delete[] rpt;
}
class Wiimote
{
public:
Wiimote(wiimote_t* const wm, const unsigned int index);
~Wiimote();
void ControlChannel(const u16 channel, const void* const data, const u32 size);
void InterruptChannel(const u16 channel, const void* const data, const u32 size);
void Update();
void Read();
void Disconnect();
private:
void ClearReports();
wiimote_t* const m_wiimote;
const unsigned int m_index;
u16 m_channel;
u8 m_last_data_report[MAX_PAYLOAD];
bool m_last_data_report_valid;
std::queue<u8*> m_reports;
};
Wiimote::Wiimote(wiimote_t* const wm, const unsigned int index)
: m_wiimote(wm)
, m_index(index)
, m_channel(0)
, m_last_data_report_valid(false)
{
{
// disable reporting
wm_report_mode rpt = wm_report_mode();
rpt.mode = WM_REPORT_CORE;
SendPacket(m_wiimote, WM_REPORT_MODE, &rpt, sizeof(rpt));
}
// clear all msgs, silly maybe
while (wiiuse_io_read(m_wiimote));
{
// request status, will be sent to game on start
wm_request_status rpt = wm_request_status();
SendPacket(m_wiimote, WM_REQUEST_STATUS, &rpt, sizeof(rpt));
}
//{
// LEDs test
//wm_leds rpt = wm_leds();
//rpt.leds = 1 << i;
//SendPacket(g_wiimotes_from_wiiuse[i], WM_LEDS, &rpt, sizeof(rpt));
//}
// set LEDs
wiiuse_set_leds(m_wiimote, WIIMOTE_LED_1 << m_index);
}
Wiimote::~Wiimote()
{
ClearReports();
// send disconnect message to wii, maybe, i hope, naw shit messes up on emu-stop
//if (g_WiimoteInitialize.pWiimoteInterruptChannel)
//{
// //u8* const rpt = new u8[2];
// //rpt[0] = 0XA1; rpt[1] = 0x15;
// //m_reports.push(rpt);
// //Update();
// const u8 rpt[] = { 0xA1, 0x15 };
// g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_channel, rpt, sizeof(rpt));
//}
}
void Wiimote::ClearReports()
{
while (m_reports.size())
{
delete[] m_reports.front();
m_reports.pop();
}
}
void Wiimote::ControlChannel(const u16 channel, const void* const data, const u32 size)
{
// Check for custom communication
if (99 == channel)
Disconnect();
else
InterruptChannel(channel, data, size);
}
void Wiimote::InterruptChannel(const u16 channel, const void* const data, const u32 size)
{
m_channel = channel;
wiiuse_io_write(m_wiimote, (byte*)data, size);
}
void Wiimote::Read()
{
if (wiiuse_io_read(m_wiimote))
{
// a data report, save it
if (m_wiimote->event_buf[1] >= 0x30)
{
memcpy(m_last_data_report, m_wiimote->event_buf, MAX_PAYLOAD - 1);
m_last_data_report_valid = true;
}
else
{
// some other report, add it to queue
u8* const rpt = new u8[MAX_PAYLOAD - 1];
memcpy(rpt, m_wiimote->event_buf, MAX_PAYLOAD - 1);
m_reports.push(rpt);
}
}
}
void Wiimote::Update()
{
// do we have some queued reports
if (m_reports.size())
{
u8* const rpt = m_reports.front();
m_reports.pop();
g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_channel, rpt, MAX_PAYLOAD - 1);
delete[] rpt;
}
else if (m_last_data_report_valid)
{
// otherwise send the last data report, if there is one
g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_channel, m_last_data_report, MAX_PAYLOAD - 1);
}
}
void Wiimote::Disconnect()
{
{
// disable reporting
wm_report_mode rpt = wm_report_mode();
rpt.mode = WM_REPORT_CORE;
SendPacket(m_wiimote, WM_REPORT_MODE, &rpt, sizeof(rpt));
}
// clear queue
m_last_data_report_valid = false;
ClearReports();
// clear out wiiuse queue, or maybe not, silly? idk
while (wiiuse_io_read(m_wiimote));
}
Wiimote* g_wiimotes[4];
unsigned int Initialize()
{
// return if already initialized
if (g_real_wiimotes_initialized)
return g_wiimotes_found;
// load realwiimote settings from inifile
{
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + g_plugin.ini_name + ".ini" );
IniFile inifile;
inifile.Load(ini_filename);
for (unsigned int i=0; i<MAX_WIIMOTES; ++i)
{
std::string secname("Wiimote");
secname += (char)('1' + i);
IniFile::Section& sec = *inifile.GetOrCreateSection(secname.c_str());
sec.Get("Source", &g_wiimote_sources[i], WIIMOTE_SRC_EMU);
}
}
// end load settings
memset(g_wiimotes, 0, sizeof(g_wiimotes));
// only call wiiuse_find with the number of slots configured for real wiimotes
unsigned int wanted_wiimotes = 0;
for (unsigned int i = 0; i < MAX_WIIMOTES; ++i)
if (WIIMOTE_SRC_REAL == g_wiimote_sources[i])
++wanted_wiimotes;
// don't bother initializing wiiuse if we don't want any real wiimotes
if (0 == wanted_wiimotes)
{
g_wiimotes_found = 0;
return 0;
}
// initialized
g_real_wiimotes_initialized = true;
// Call Wiiuse.dll
g_wiimotes_from_wiiuse = wiiuse_init(MAX_WIIMOTES);
g_wiimotes_found = wiiuse_find(g_wiimotes_from_wiiuse, wanted_wiimotes, 5);
DEBUG_LOG(WIIMOTE, "Found %i Real Wiimotes, %i wanted", g_wiimotes_found, wanted_wiimotes);
g_wiimote_critsec.Enter(); // enter
// create real wiimote class instances, assign wiimotes
unsigned int index = 0;
for (unsigned int i = 0; i < g_wiimotes_found; ++i)
{
if (WIIMOTE_SRC_REAL != g_wiimote_sources[i])
continue;
// create/assign wiimote
g_wiimotes[i] = new Wiimote(g_wiimotes_from_wiiuse[index++], i);
}
g_wiimote_critsec.Leave(); // leave
// start wiimote thread
g_run_wiimote_thread = true;
g_wiimote_thread = new Common::Thread(WiimoteThreadFunc, 0);
return g_wiimotes_found;
}
void Shutdown(void)
{
if (false == g_real_wiimotes_initialized)
return;
// Uninitialized
g_real_wiimotes_initialized = false;
// stop wiimote thread
if (g_wiimote_thread)
{
g_run_wiimote_thread = false;
g_wiimote_thread->WaitForDeath();
delete g_wiimote_thread;
g_wiimote_thread = NULL;
}
g_wiimote_critsec.Enter(); // enter
// delete wiimotes
for (unsigned int i=0; i<MAX_WIIMOTES; ++i)
if (g_wiimotes[i])
{
delete g_wiimotes[i];
g_wiimotes[i] = NULL;
}
g_wiimote_critsec.Leave(); // leave
// set all LEDs on, idk
//for (unsigned int i=0; i<g_wiimotes_found; ++i)
//{
// wiiuse_set_leds(g_wiimotes_from_wiiuse[i], 0xF0);
//}
// Clean up wiiuse
wiiuse_cleanup(g_wiimotes_from_wiiuse, MAX_WIIMOTES);
}
void Refresh()
{
// should be fine i think
Shutdown();
Initialize();
}
void InterruptChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size)
{
g_wiimote_critsec.Enter(); // enter
if (g_wiimotes[_WiimoteNumber])
g_wiimotes[_WiimoteNumber]->InterruptChannel(_channelID, _pData, _Size);
g_wiimote_critsec.Leave(); // leave
}
void ControlChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size)
{
g_wiimote_critsec.Enter(); // enter
if (g_wiimotes[_WiimoteNumber])
g_wiimotes[_WiimoteNumber]->ControlChannel(_channelID, _pData, _Size);
g_wiimote_critsec.Leave(); // leave
}
// Read the Wiimote once
void Update(int _WiimoteNumber)
{
g_wiimote_critsec.Enter(); // enter
if (g_wiimotes[_WiimoteNumber])
g_wiimotes[_WiimoteNumber]->Update();
g_wiimote_critsec.Leave(); // leave
}
void StateChange(PLUGIN_EMUSTATE newState)
{
g_wiimote_critsec.Enter(); // enter
// TODO: disable/enable auto reporting, maybe
g_wiimote_critsec.Leave(); // leave
}
THREAD_RETURN WiimoteThreadFunc(void* arg)
{
while (g_run_wiimote_thread)
{
g_wiimote_critsec.Enter(); // enter
for (unsigned int i=0; i<MAX_WIIMOTES; ++i)
if (g_wiimotes[i])
g_wiimotes[i]->Read();
g_wiimote_critsec.Leave(); // leave
// hmmm, i get occasional lockups without this :/
Common::SleepCurrentThread(1);
}
return 0;
}
}; // end of namespace

View File

@ -0,0 +1,56 @@
// Copyright (C) 2003 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/
#ifndef WIIMOTE_REAL_H
#define WIIMOTE_REAL_H
#include "wiiuse.h"
#include "ChunkFile.h"
#include "../../InputCommon/Src/InputConfig.h"
#define MAX_WIIMOTES 4
extern unsigned int g_wiimote_sources[MAX_WIIMOTES];
extern InputPlugin g_plugin;
extern SWiimoteInitialize g_WiimoteInitialize;
enum
{
WIIMOTE_SRC_NONE = 0,
WIIMOTE_SRC_EMU,
WIIMOTE_SRC_REAL,
};
namespace WiimoteReal
{
unsigned int Initialize();
void Shutdown();
void Refresh();
void InterruptChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size);
void ControlChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size);
void Update(int _WiimoteNumber);
void DoState(PointerWrap &p);
void StateChange(PLUGIN_EMUSTATE newState);
}; // WiiMoteReal
#endif