Moved WiimoteNew into Dolphin and eliminated the old wiimote plugin. Removed wiimote plugin support. Moved input dialog related InputUICommon stuff into DolphinWX. Removed now unused InputCommon files. UDPWiimote stuff is temporarily disabled until it is reorganized so Core won't depend on wx. Real wiimotes are now initialized on first need(wiimote diag open or game start) and left initialized until Dolphin exit.(maybe this will work better for Linux/OS X) (scons probably needs some fixes)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6270 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak 2010-10-12 19:42:29 +00:00
parent de3ad37299
commit 7e08fc19fc
116 changed files with 661 additions and 14529 deletions

View File

@ -373,8 +373,6 @@ dirs = [
#'Source/Plugins/Plugin_VideoDX9/Src',
'Source/Plugins/Plugin_VideoOGL/Src',
'Source/Plugins/Plugin_VideoSoftware/Src',
'Source/Plugins/Plugin_Wiimote/Src',
'Source/Plugins/Plugin_WiimoteNew/Src',
'Source/UnitTests',
]

View File

@ -480,14 +480,6 @@
RelativePath=".\Src\PluginVideo.h"
>
</File>
<File
RelativePath=".\Src\PluginWiimote.cpp"
>
</File>
<File
RelativePath=".\Src\PluginWiimote.h"
>
</File>
<Filter
Name="Specs"
>
@ -511,10 +503,6 @@
RelativePath="..\..\PluginSpecs\pluginspecs_video.h"
>
</File>
<File
RelativePath="..\..\PluginSpecs\pluginspecs_wiimote.h"
>
</File>
</Filter>
</Filter>
<Filter

View File

@ -1,48 +0,0 @@
// 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 "PluginWiimote.h"
namespace Common {
PluginWiimote::PluginWiimote(const char *_Filename)
: CPlugin(_Filename), validWiimote(false)
{
Wiimote_ControlChannel = reinterpret_cast<TWiimote_ControlChannel>
(LoadSymbol("Wiimote_ControlChannel"));
Wiimote_Input = reinterpret_cast<TWiimote_Input>
(LoadSymbol("Wiimote_Input"));
Wiimote_InterruptChannel = reinterpret_cast<TWiimote_InterruptChannel>
(LoadSymbol("Wiimote_InterruptChannel"));
Wiimote_Update = reinterpret_cast<TWiimote_Update>
(LoadSymbol("Wiimote_Update"));
Wiimote_GetAttachedControllers = reinterpret_cast<TWiimote_GetAttachedControllers>
(LoadSymbol("Wiimote_GetAttachedControllers"));
Wiimote_UnPairWiimotes = reinterpret_cast<TWiimote_UnPairWiimotes>
(LoadSymbol("Wiimote_UnPairWiimotes"));
if ((Wiimote_ControlChannel != 0) &&
(Wiimote_Input != 0) &&
(Wiimote_InterruptChannel != 0) &&
(Wiimote_Update != 0) &&
(Wiimote_GetAttachedControllers != 0))
validWiimote = true;
}
PluginWiimote::~PluginWiimote() { }
} // Namespace

View File

@ -1,53 +0,0 @@
// 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 _PLUGINWIIMOTE_H_
#define _PLUGINWIIMOTE_H_
#include "pluginspecs_wiimote.h"
#include "Plugin.h"
namespace Common {
typedef unsigned int (__cdecl* TPAD_GetAttachedPads)();
typedef void (__cdecl* TWiimote_Update)(int _number);
typedef void (__cdecl* TWiimote_Input)(u16 _Key, u8 _UpDown);
typedef void (__cdecl* TWiimote_ControlChannel)(int _number, u16 _channelID, const void* _pData, u32 _Size);
typedef void (__cdecl* TWiimote_InterruptChannel)(int _number, u16 _channelID, const void* _pData, u32 _Size);
typedef unsigned int (__cdecl* TWiimote_UnPairWiimotes)();
typedef unsigned int (__cdecl* TWiimote_GetAttachedControllers)();
class PluginWiimote : public CPlugin {
public:
PluginWiimote(const char *_Filename);
virtual ~PluginWiimote();
virtual bool IsValid() {return validWiimote;};
TWiimote_ControlChannel Wiimote_ControlChannel;
TWiimote_Input Wiimote_Input;
TWiimote_InterruptChannel Wiimote_InterruptChannel;
TWiimote_Update Wiimote_Update;
TWiimote_UnPairWiimotes Wiimote_UnPairWiimotes;
TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers;
private:
bool validWiimote;
};
} // namespace
#endif // _PLUGINWIIMOTE_H_

View File

@ -45,7 +45,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include;..\..\..\Externals\WiiUse\Src"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -69,8 +69,9 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="wiiuse.lib"
OutputFile="$(OutDir)/Core.lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -115,7 +116,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include;..\..\..\Externals\WiiUse\Src"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -140,7 +141,7 @@
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/Core.lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -189,7 +190,7 @@
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="false"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include;..\..\..\Externals\WiiUse\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
StringPooling="true"
RuntimeLibrary="0"
@ -213,8 +214,9 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="wiiuse.lib"
OutputFile="$(OutDir)/Core.lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -266,7 +268,7 @@
OmitFramePointers="true"
EnableFiberSafeOptimizations="false"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include;..\..\..\Externals\WiiUse\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
StringPooling="true"
RuntimeLibrary="0"
@ -290,8 +292,9 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="wiiuse.lib"
OutputFile="$(OutDir)/Core.lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;;&quot;..\..\..\Externals\Lua\$(OutDir)\Lua.lib&quot;"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;;&quot;..\..\..\Externals\Lua\$(OutDir)\Lua.lib&quot;;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -340,7 +343,7 @@
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="false"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include;..\..\..\Externals\WiiUse\Src"
PreprocessorDefinitions="NDEBUG;_LIB;DEBUGFAST;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
RuntimeLibrary="0"
BufferSecurityCheck="true"
@ -363,8 +366,9 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="wiiuse.lib"
OutputFile="$(OutDir)/Core.lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -414,7 +418,7 @@
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="false"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include"
AdditionalIncludeDirectories=".\Core\Core\Src\Debugger;..\Common\Src;..\DiscIO\Src;..\..\Core\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\LZO;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\zlib;..\..\..\Externals\Lua;..\..\..\Externals\SFML\include;..\..\..\Externals\WiiUse\Src"
PreprocessorDefinitions="NDEBUG;_LIB;DEBUGFAST;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
@ -437,7 +441,7 @@
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/Core.lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\LZO\$(OutDir)\lzo.lib&quot;;&quot;..\..\..\Externals\WiiUse\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -794,6 +798,122 @@
>
</File>
</Filter>
<Filter
Name="Wiimote"
>
<File
RelativePath=".\Src\HW\Wiimote.cpp"
>
</File>
<File
RelativePath=".\Src\HW\Wiimote.h"
>
</File>
<Filter
Name="Emu"
>
<File
RelativePath=".\Src\HW\WiimoteEmu\EmuSubroutines.cpp"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Encryption.cpp"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Encryption.h"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\MatrixMath.h"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Speaker.cpp"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\UDPTLayer.h"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\WiimoteEmu.cpp"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\WiimoteEmu.h"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\WiimoteHid.h"
>
</File>
<Filter
Name="Attachment"
>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Attachment.cpp"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Attachment.h"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Classic.cpp"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Classic.h"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Drums.cpp"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Drums.h"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Guitar.cpp"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Guitar.h"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Nunchuk.cpp"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Nunchuk.h"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Turntable.cpp"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteEmu\Attachment\Turntable.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Real"
>
<File
RelativePath=".\Src\HW\WiimoteReal\WiimoteReal.cpp"
>
</File>
<File
RelativePath=".\Src\HW\WiimoteReal\WiimoteReal.h"
>
</File>
</Filter>
</Filter>
</Filter>
<Filter
Name="PowerPC"

View File

@ -171,7 +171,6 @@ void SConfig::SaveSettings()
// Plugins
ini.Set("Core", "GFXPlugin", m_LocalCoreStartupParameter.m_strVideoPlugin);
ini.Set("Core", "DSPPlugin", m_LocalCoreStartupParameter.m_strDSPPlugin);
ini.Set("Core", "WiiMotePlugin",m_LocalCoreStartupParameter.m_strWiimotePlugin);
ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
m_SYSCONF->Save();
@ -187,7 +186,6 @@ void SConfig::LoadSettings()
// Hard coded defaults
m_DefaultGFXPlugin = DEFAULT_GFX_PLUGIN;
m_DefaultDSPPlugin = DEFAULT_DSP_PLUGIN;
m_DefaultWiiMotePlugin = DEFAULT_WIIMOTE_PLUGIN;
// General
{
@ -302,7 +300,6 @@ void SConfig::LoadSettings()
// Plugins
ini.Get("Core", "GFXPlugin", &m_LocalCoreStartupParameter.m_strVideoPlugin, m_DefaultGFXPlugin.c_str());
ini.Get("Core", "DSPPlugin", &m_LocalCoreStartupParameter.m_strDSPPlugin, m_DefaultDSPPlugin.c_str());
ini.Get("Core", "WiiMotePlugin", &m_LocalCoreStartupParameter.m_strWiimotePlugin, m_DefaultWiiMotePlugin.c_str());
}
m_SYSCONF = new SysConf();

View File

@ -50,7 +50,6 @@ struct SConfig
// hard coded default plugins ...
std::string m_DefaultGFXPlugin;
std::string m_DefaultDSPPlugin;
std::string m_DefaultWiiMotePlugin;
// name of the last used filename
std::string m_LastFilename;

View File

@ -45,6 +45,7 @@
#include "HW/GPFifo.h"
#include "HW/CPU.h"
#include "HW/GCPad.h"
#include "HW/Wiimote.h"
#include "HW/HW.h"
#include "HW/DSP.h"
#include "HW/GPFifo.h"
@ -382,20 +383,11 @@ THREAD_RETURN EmuThread(void *pArg)
Plugins.GetDSP()->Initialize((void *)&dspInit);
GCPad_Init(g_pWindowHandle);
Pad::Initialize(g_pWindowHandle);
// Load and Init WiimotePlugin - only if we are booting in wii mode
// Load and Init Wiimotes - only if we are booting in wii mode
if (_CoreParameter.bWii)
{
SWiimoteInitialize WiimoteInitialize;
WiimoteInitialize.hWnd = g_pWindowHandle;
WiimoteInitialize.ISOId = Ascii2Hex(_CoreParameter.m_strUniqueID);
WiimoteInitialize.pLog = Callback_WiimoteLog;
WiimoteInitialize.pWiimoteInterruptChannel = Callback_WiimoteInterruptChannel;
WiimoteInitialize.pRendererHasFocus = Callback_RendererHasFocus;
// Wait for Wiiuse to find the number of connected Wiimotes
Plugins.GetWiimote()->Initialize((void *)&WiimoteInitialize);
}
Wiimote::Initialize(g_pWindowHandle);
// The hardware is initialized.
g_bHwInit = true;
@ -508,7 +500,8 @@ THREAD_RETURN EmuThread(void *pArg)
if (_CoreParameter.bCPUThread)
Plugins.ShutdownVideoPlugin();
GCPad_Deinit();
Pad::Shutdown();
Wiimote::Shutdown();
Plugins.ShutdownPlugins();
NOTICE_LOG(CONSOLE, "%s", StopMessage(false, "Plugins shutdown").c_str());

View File

@ -126,7 +126,6 @@ struct SCoreStartupParameter
// files
std::string m_strVideoPlugin;
std::string m_strDSPPlugin;
std::string m_strWiimotePlugin;
std::string m_strFilename;
std::string m_strBootROM;

View File

@ -23,47 +23,42 @@
#include "../../InputCommon/Src/InputConfig.h"
static InputPlugin g_plugin("GCPadNew", "Pad", "GCPad");
namespace Pad
{
InputPlugin *PAD_GetPlugin() {
static InputPlugin g_plugin("GCPadNew", "Pad", "GCPad");
InputPlugin *GetPlugin()
{
return &g_plugin;
}
void GCPad_Deinit()
void Shutdown()
{
if ( g_plugin.controller_interface.IsInit() )
{
std::vector<ControllerEmu*>::const_iterator
i = g_plugin.controllers.begin(),
e = g_plugin.controllers.end();
for ( ; i!=e; ++i )
delete *i;
g_plugin.controllers.clear();
std::vector<ControllerEmu*>::const_iterator
i = g_plugin.controllers.begin(),
e = g_plugin.controllers.end();
for ( ; i!=e; ++i )
delete *i;
g_plugin.controllers.clear();
g_plugin.controller_interface.DeInit();
}
g_controller_interface.Shutdown();
}
// if plugin isn't initialized, init and load config
void GCPad_Init( void* const hwnd )
void Initialize(void* const hwnd)
{
// i realize i am checking IsInit() twice, just too lazy to change it
if ( false == g_plugin.controller_interface.IsInit() )
{
// add 4 gcpads
for (unsigned int i=0; i<4; ++i)
g_plugin.controllers.push_back(new GCPad(i));
// needed for Xlib
g_plugin.controller_interface.SetHwnd(hwnd);
g_plugin.controller_interface.Init();
// add 4 gcpads
for (unsigned int i=0; i<4; ++i)
g_plugin.controllers.push_back(new GCPad(i));
// load the saved controller config
g_plugin.LoadConfig();
}
g_controller_interface.SetHwnd(hwnd);
g_controller_interface.Initialize();
// load the saved controller config
g_plugin.LoadConfig();
}
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
{
memset(_pPADStatus, 0, sizeof(*_pPADStatus));
_pPADStatus->err = PAD_ERR_NONE;
@ -84,8 +79,8 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
static int _last_numPAD = 4;
if (_numPAD <= _last_numPAD)
{
g_plugin.controller_interface.UpdateOutput();
g_plugin.controller_interface.UpdateInput();
g_controller_interface.UpdateOutput();
g_controller_interface.UpdateInput();
}
_last_numPAD = _numPAD;
@ -102,7 +97,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
// input: PAD number, Command type (Stop=0, Rumble=1, Stop Hard=2) and strength of Rumble
// output: none
//
void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
{
// enter
if ( g_plugin.controls_crit.TryEnter() )
@ -115,3 +110,5 @@ void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
g_plugin.controls_crit.Leave();
}
}
}

View File

@ -19,10 +19,20 @@
#include "GCPadStatus.h"
#include "../../InputCommon/Src/InputConfig.h"
void GCPad_Init( void* const hwnd );
void GCPad_Deinit();
#ifndef _GCPAD_H_
#define _GCPAD_H_
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus);
void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength);
namespace Pad
{
InputPlugin *PAD_GetPlugin();
void Shutdown();
void Initialize(void* const hwnd);
InputPlugin *GetPlugin();
void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus);
void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength);
}
#endif

View File

@ -148,7 +148,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
DEBUG_LOG(AMBASEBOARDDEBUG, "GC-AM: CMD 10, %02x (READ STATUS&SWITCHES)", ptr(1));
SPADStatus PadStatus;
memset(&PadStatus, 0 ,sizeof(PadStatus));
PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
res[resp++] = 0x10;
res[resp++] = 0x2;
int d10_0 = 0xdf;
@ -313,7 +313,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
for (i=0; i<nr_players; ++i)
{
SPADStatus PadStatus;
PAD_GetStatus(i, &PadStatus);
Pad::GetStatus(i, &PadStatus);
unsigned char player_data[2] = {0,0};
if (PadStatus.button & PAD_BUTTON_START)
player_data[0] |= 0x80;
@ -350,7 +350,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
int slots = *jvs_io++;
msg.addData(1);
SPADStatus PadStatus;
PAD_GetStatus(0, &PadStatus);
Pad::GetStatus(0, &PadStatus);
while (slots--)
{
msg.addData(0);

View File

@ -131,7 +131,7 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low)
SPADStatus PadStatus;
memset(&PadStatus, 0, sizeof(PadStatus));
PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
u32 netValues[2] = {0};
int NetPlay = 2;
@ -281,7 +281,7 @@ void CSIDevice_GCController::SendCommand(u32 _Cmd, u8 _Poll)
#endif
if (numPAD < 4)
PAD_Rumble(numPAD, uType, uStrength);
Pad::Rumble(numPAD, uType, uStrength);
if (!_Poll)
{

View File

@ -0,0 +1,153 @@
#include "Common.h"
#include "Wiimote.h"
#include "WiimoteReal/WiimoteReal.h"
#include "WiimoteEmu/WiimoteEmu.h"
#include "ControllerInterface/ControllerInterface.h"
#include "../../InputCommon/Src/InputConfig.h"
namespace Wiimote
{
static InputPlugin g_plugin(WIIMOTE_INI_NAME, "Wiimote", "Wiimote");
InputPlugin *GetPlugin()
{
return &g_plugin;
}
void Shutdown()
{
std::vector<ControllerEmu*>::const_iterator
i = g_plugin.controllers.begin(),
e = g_plugin.controllers.end();
for ( ; i!=e; ++i )
delete *i;
g_plugin.controllers.clear();
// WiimoteReal is shutdown on app exit
//WiimoteReal::Shutdown();
g_controller_interface.Shutdown();
}
// if plugin isn't initialized, init and load config
void Initialize(void* const hwnd)
{
// add 4 wiimotes
for (unsigned int i = 0; i<4; ++i)
g_plugin.controllers.push_back(new WiimoteEmu::Wiimote(i));
g_controller_interface.SetHwnd(hwnd);
g_controller_interface.Initialize();
g_plugin.LoadConfig();
WiimoteReal::Initialize();
}
// __________________________________________________________________________________________________
// Function: Wiimote_Output
// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
// on the HID CONTROL channel.
// input: Da pakket.
// output: none
//
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
{
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
((WiimoteEmu::Wiimote*)g_plugin.controllers[_number])->ControlChannel(_channelID, _pData, _Size);
if (WIIMOTE_SRC_REAL & g_wiimote_sources[_number])
WiimoteReal::ControlChannel(_number, _channelID, _pData, _Size);
}
// __________________________________________________________________________________________________
// Function: Wiimote_InterruptChannel
// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
// on the HID INTERRUPT channel.
// input: Da pakket.
// output: none
//
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
{
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
((WiimoteEmu::Wiimote*)g_plugin.controllers[_number])->InterruptChannel(_channelID, _pData, _Size);
else
WiimoteReal::InterruptChannel(_number, _channelID, _pData, _Size);
}
// __________________________________________________________________________________________________
// Function: Wiimote_Update
// Purpose: This function is called periodically by the Core.
// input: none
// output: none
//
void Update(int _number)
{
//PanicAlert( "Wiimote_Update" );
// TODO: change this to a TryEnter, and make it give empty input on failure
g_plugin.controls_crit.Enter();
static int _last_number = 4;
if (_number <= _last_number)
{
g_controller_interface.UpdateOutput();
g_controller_interface.UpdateInput();
}
_last_number = _number;
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
((WiimoteEmu::Wiimote*)g_plugin.controllers[_number])->Update();
else
WiimoteReal::Update(_number);
g_plugin.controls_crit.Leave();
}
// __________________________________________________________________________________________________
// Function: PAD_GetAttachedPads
// Purpose: Get mask of attached pads (eg: controller 1 & 4 -> 0x9)
// input: none
// output: number of pads
//
unsigned int GetAttached()
{
unsigned int attached = 0;
for (unsigned int i=0; i<4; ++i)
if (g_wiimote_sources[i])
attached |= (1 << i);
return attached;
}
// ___________________________________________________________________________
// Function: DoState
// Purpose: Saves/load state
// input/output: ptr
// input: mode
//
void DoState(unsigned char **ptr, int mode)
{
// TODO:
//PointerWrap p(ptr, mode);
//for (unsigned int i=0; i<4; ++i)
// ((WiimoteEmu::Wiimote*)g_plugin.controllers[i])->DoState(p);
}
// ___________________________________________________________________________
// Function: EmuStateChange
// Purpose: Notifies the plugin of a change in emulation state
// input: newState
// output: none
//
void EmuStateChange(PLUGIN_EMUSTATE newState)
{
// TODO
WiimoteReal::StateChange(newState);
}
}

View File

@ -0,0 +1,50 @@
#ifndef _WIIMOTE_H_
#define _WIIMOTE_H_
#include "PluginSpecs.h"
#include "../../InputCommon/Src/InputConfig.h"
#define MAX_WIIMOTES 4
#define WIIMOTE_INI_NAME "WiimoteNew"
//extern InputPlugin g_plugin;
extern unsigned int g_wiimote_sources[MAX_WIIMOTES];
//extern SWiimoteInitialize g_WiimoteInitialize;
namespace Wiimote
{
void Shutdown();
void Initialize(void* const hwnd);
unsigned int GetAttached();
void DoState(unsigned char **ptr, int mode);
void EmuStateChange(PLUGIN_EMUSTATE newState);
InputPlugin *GetPlugin();
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
void Update(int _number);
}
namespace WiimoteReal
{
unsigned int Initialize();
void Shutdown();
void Refresh();
void LoadSettings();
#ifdef _WIN32
int PairUp(bool unpair = false);
int UnPair();
#endif
}
#endif

View File

@ -27,7 +27,11 @@ static const u8 nunchuk_button_bitmasks[] =
Nunchuk::BUTTON_Z,
};
#ifdef USE_UDP_WIIMOTE
Nunchuk::Nunchuk(UDPWrapper *wrp) : Attachment("Nunchuk") , m_udpWrap(wrp)
#else
Nunchuk::Nunchuk() : Attachment("Nunchuk")
#endif
{
// buttons
groups.push_back(m_buttons = new Buttons("Buttons"));
@ -85,7 +89,7 @@ void Nunchuk::GetState(u8* const data, const bool focus)
// flip the button bits :/
ncdata->bt ^= 0x03;
//UDPNunchuk stuff
#ifdef USE_UDP_WIIMOTE
if (m_udpWrap->inst)
{
if (m_udpWrap->updNun)
@ -114,7 +118,7 @@ void Nunchuk::GetState(u8* const data, const bool focus)
accel.z=z;
}
}
//End UDPNunchuck
#endif
wm_accel* dt = (wm_accel*)&ncdata->ax;
accel_cal* calib = (accel_cal*)&reg[0x20];

View File

@ -11,7 +11,13 @@ namespace WiimoteEmu
class Nunchuk : public Attachment
{
public:
#ifdef USE_UDP_WIIMOTE
Nunchuk(UDPWrapper * wrp);
#else
Nunchuk();
#endif
virtual void GetState( u8* const data, const bool focus );
enum
@ -31,7 +37,9 @@ private:
unsigned int m_shake_step[3];
#ifdef USE_UDP_WIIMOTE
UDPWrapper* const m_udpWrap;
#endif
};
}

View File

@ -33,9 +33,8 @@
#include <string>
#include <fstream>
#include "Common.h" // Common
#include "Common.h"
#include "FileUtil.h"
#include "pluginspecs_wiimote.h"
#include "WiimoteEmu.h"
#include "WiimoteHid.h"
@ -200,7 +199,7 @@ void Wiimote::SendAck(u8 _reportID)
ack->reportID = _reportID;
ack->errorID = 0;
g_WiimoteInitialize.pWiimoteInterruptChannel( m_index, m_reporting_channel, data, sizeof(data));
Core::Callback_WiimoteInterruptChannel( m_index, m_reporting_channel, data, sizeof(data));
}
void Wiimote::HandleExtensionSwap()
@ -259,7 +258,7 @@ void Wiimote::RequestStatus(const wm_request_status* const rs)
}
// send report
g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_reporting_channel, data, sizeof(data));
Core::Callback_WiimoteInterruptChannel(m_index, m_reporting_channel, data, sizeof(data));
}
/* Write data to Wiimote and Extensions registers. */
@ -526,7 +525,7 @@ void Wiimote::SendReadDataReply(ReadRequest& _request)
}
// Send a piece
g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_reporting_channel, data, sizeof(data));
Core::Callback_WiimoteInterruptChannel(m_index, m_reporting_channel, data, sizeof(data));
}
void Wiimote::DoState(PointerWrap& p)

View File

@ -3,6 +3,10 @@
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
typedef double Matrix[4][4];
typedef struct
{
@ -24,9 +28,10 @@ inline void MatrixFrustum(Matrix &m, double l, double r, double b, double t, dou
m[2][0]=(r+l)/(r-l); m[2][1]=(t+b)/(t-b); m[2][2]=(f+n)/(f-n); m[2][3]=-1;
m[3][0]=0; m[3][1]=0; m[3][2]=2*f*n/(f-n); m[3][3]=0;
}
inline void MatrixPerspective(Matrix & m, double fovy, double aspect, double nplane, double fplane)
{
double xmin,xmax,ymin,ymax;
double xmin, xmax, ymin, ymax;
ymax = nplane * tan(fovy * M_PI / 360.0);
ymin = -ymax;

View File

@ -1,6 +1,6 @@
//UDP Wiimote Translation Layer
#ifndef UDPTLAYER_H
#if (defined(USE_UDP_WIIMOTE) && !defined(UDPTLAYER_H))
#define UDPTLAYER_H
#include "UDPWiimote.h"

View File

@ -12,6 +12,7 @@
#include "Timer.h"
#include "Common.h"
#include "../../Host.h"
#include "UDPTLayer.h"
@ -242,7 +243,7 @@ Wiimote::Wiimote( const unsigned int index )
m_buttons->controls.push_back(new ControlGroup::Input( named_buttons[i]));
// ir
groups.push_back(m_ir = new Cursor("IR", &g_WiimoteInitialize));
groups.push_back(m_ir = new Cursor("IR"));
// swing
groups.push_back(m_swing = new Force("Swing"));
@ -250,8 +251,10 @@ Wiimote::Wiimote( const unsigned int index )
// tilt
groups.push_back(m_tilt = new Tilt("Tilt"));
#ifdef USE_UDP_WIIMOTE
// udp
groups.push_back(m_udp = new UDPWrapper(m_index, "UDP Wiimote"));
#endif
// shake
groups.push_back(m_shake = new Buttons("Shake"));
@ -262,7 +265,11 @@ Wiimote::Wiimote( const unsigned int index )
// extension
groups.push_back(m_extension = new Extension("Extension"));
m_extension->attachments.push_back(new WiimoteEmu::None());
#ifdef USE_UDP_WIIMOTE
m_extension->attachments.push_back(new WiimoteEmu::Nunchuk(m_udp));
#else
m_extension->attachments.push_back(new WiimoteEmu::Nunchuk());
#endif
m_extension->attachments.push_back(new WiimoteEmu::Classic());
m_extension->attachments.push_back(new WiimoteEmu::Guitar());
m_extension->attachments.push_back(new WiimoteEmu::Drums());
@ -319,7 +326,7 @@ std::string Wiimote::GetName() const
}
// if windows is focused or background input is enabled
#define HAS_FOCUS (g_WiimoteInitialize.pRendererHasFocus() || (m_options->settings[0]->value != 0))
#define HAS_FOCUS (Host_RendererHasFocus() || (m_options->settings[0]->value != 0))
bool Wiimote::Step()
{
@ -338,7 +345,9 @@ bool Wiimote::Step()
{
m_buttons->GetState(&m_status.buttons, button_bitmasks);
m_dpad->GetState(&m_status.buttons, is_sideways ? dpad_sideways_bitmasks : dpad_bitmasks);
#ifdef USE_UDP_WIIMOTE
UDPTLayer::GetButtons(m_udp, &m_status.buttons);
#endif
}
// check if there is a read data request
@ -398,8 +407,9 @@ void Wiimote::GetAccelData(u8* const data, u8* const buttons)
{
EmulateSwing(&m_accel, m_swing, is_sideways, is_upright);
EmulateShake(&m_accel, m_shake, m_shake_step);
// UDP Wiimote
#ifdef USE_UDP_WIIMOTE
UDPTLayer::GetAcceleration(m_udp, &m_accel);
#endif
}
wm_accel* dt = (wm_accel*)data;
accel_cal* calib = (accel_cal*)&m_eeprom[0x16];
@ -466,7 +476,9 @@ void Wiimote::GetIRData(u8* const data, bool use_accel)
LowPassFilter(ir_cos,ncos,1.0f/60);
m_ir->GetState(&xx, &yy, &zz, true);
#ifdef USE_UDP_WIIMOTE
UDPTLayer::GetIR(m_udp, &xx, &yy, &zz);
#endif
Vertex v[4];
@ -737,7 +749,7 @@ void Wiimote::Update()
// send data report
if (rptf_size)
g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_reporting_channel, data, rptf_size);
Core::Callback_WiimoteInterruptChannel(m_index, m_reporting_channel, data, rptf_size);
}
void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size)
@ -778,7 +790,7 @@ void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size
HidOutputReport((wm_report*)hidp->data);
u8 handshake = HID_HANDSHAKE_SUCCESS;
g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, _channelID, &handshake, 1);
Core::Callback_WiimoteInterruptChannel(m_index, _channelID, &handshake, 1);
}
break;

View File

@ -8,6 +8,8 @@
// just used to get the OpenAL includes :p
//#include <OpenALStream.h>
#include "../../Core.h"
#include "ControllerEmu.h"
#include "ChunkFile.h"
@ -27,8 +29,6 @@
#define WIIMOTE_REG_EXT_SIZE 0x100
#define WIIMOTE_REG_IR_SIZE 0x34
extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiimoteEmu
{
@ -146,8 +146,9 @@ private:
double ir_sin,ir_cos; //for the low pass filter
//UDPWiimote
#ifdef USE_UDP_WIIMOTE
UDPWrapper* m_udp;
#endif
bool m_rumble_on;
bool m_speaker_mute;

View File

@ -21,7 +21,6 @@
#include "IniFile.h"
#include "StringUtil.h"
#include "Timer.h"
#include "pluginspecs_wiimote.h"
#include "wiiuse.h"
#include "WiimoteReal.h"
@ -30,6 +29,8 @@
// used for pair up
#ifdef _WIN32
#undef NTDDI_VERSION
#define NTDDI_VERSION NTDDI_WINXPSP2
#include <bthdef.h>
#include <BluetoothAPIs.h>
#pragma comment(lib, "Bthprops.lib")
@ -131,7 +132,7 @@ void Wiimote::ControlChannel(const u16 channel, const void* const data, const u3
if (hidp->type == HID_TYPE_SET_REPORT)
{
u8 handshake_ok = HID_HANDSHAKE_SUCCESS;
g_WiimoteInitialize.pWiimoteInterruptChannel(index, channel, &handshake_ok, sizeof(handshake_ok));
Core::Callback_WiimoteInterruptChannel(index, channel, &handshake_ok, sizeof(handshake_ok));
}
}
}
@ -233,7 +234,7 @@ void Wiimote::Update()
// send the report
if (rpt && m_channel)
g_WiimoteInitialize.pWiimoteInterruptChannel(index, m_channel, rpt, MAX_PAYLOAD);
Core::Callback_WiimoteInterruptChannel(index, m_channel, rpt, MAX_PAYLOAD);
// delete the data if it isn't also the last data rpt
if (rpt != m_last_data_report)
@ -250,7 +251,7 @@ void Wiimote::Disconnect()
void LoadSettings()
{
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + g_plugin.ini_name + ".ini" );
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + WIIMOTE_INI_NAME ".ini" );
IniFile inifile;
inifile.Load(ini_filename);
@ -495,6 +496,12 @@ THREAD_RETURN WiimoteThreadFunc(void* arg)
}
#ifdef _WIN32
int UnPair()
{
// TODO:
return 0;
}
// WiiMote Pair-Up, function will return amount of either new paired or unpaired devices
// negative number on failure
int PairUp(bool unpair)

View File

@ -23,16 +23,12 @@
#include "ChunkFile.h"
#include "Thread.h"
#include "FifoQueue.h"
#include "../Wiimote.h"
#include "../WiimoteEmu/WiimoteEmu.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,
@ -84,11 +80,6 @@ private:
extern Common::CriticalSection g_refresh_critsec;
extern Wiimote *g_wiimotes[4];
unsigned int Initialize();
void Shutdown();
void Refresh();
void LoadSettings();
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);
@ -96,10 +87,6 @@ void Update(int _WiimoteNumber);
void DoState(PointerWrap &p);
void StateChange(PLUGIN_EMUSTATE newState);
#ifdef _WIN32
int PairUp(bool unpair = false);
#endif
}; // WiiMoteReal
#endif

View File

@ -18,7 +18,7 @@
#include "../Core.h"
#include "../Debugger/Debugger_SymbolMap.h"
#include "../Host.h"
#include "../PluginManager.h"
#include "../HW/Wiimote.h"
#include "../HW/WII_IPC.h"
#include "WII_IPC_HLE.h"
#include "WII_IPC_HLE_Device_usb.h"
@ -439,7 +439,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
#if defined(HAVE_WX) && HAVE_WX
NetPlay_WiimoteUpdate(i);
#endif
CPluginManager::GetInstance().GetWiimote()->Wiimote_Update(i);
Wiimote::Update(i);
//return true;
}
}

View File

@ -24,6 +24,7 @@
#include "../ConfigManager.h"
#include "../Host.h"
#include "../Core.h"
#include "../HW/Wiimote.h"
#include "l2cap.h" // Local
#include "WiiMote_HID_Attr.h"
@ -183,7 +184,7 @@ void CWII_IPC_HLE_WiiMote::EventDisconnect()
{
// Send disconnect message to plugin
u8 Message = WIIMOTE_DISCONNECT;
CPluginManager::GetInstance().GetWiimote()->Wiimote_ControlChannel(m_ConnectionHandle & 0xFF, 99, &Message, 0);
Wiimote::ControlChannel(m_ConnectionHandle & 0xFF, 99, &Message, 0);
m_ConnectionState = CONN_INACTIVE;
// Clear channel flags
@ -256,7 +257,6 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size)
const int number = 0;
#endif
Common::PluginWiimote* mote = CPluginManager::GetInstance().GetWiimote();
if (itr != m_Channel.end())
{
SChannel& rChannel = itr->second;
@ -268,7 +268,7 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size)
case L2CAP_PSM_HID_CNTL:
if (number < 4)
mote->Wiimote_ControlChannel(number, pHeader->dcid, pData, DataSize);
Wiimote::ControlChannel(number, pHeader->dcid, pData, DataSize);
break;
case L2CAP_PSM_HID_INTR:
@ -280,7 +280,7 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size)
std::string Temp = ArrayToString((const u8*)pData, DataSize);
DEBUG_LOG(WIIMOTE, " Data: %s", Temp.c_str());
mote->Wiimote_InterruptChannel(number, pHeader->dcid, pData, DataSize);
Wiimote::InterruptChannel(number, pHeader->dcid, pData, DataSize);
}
}
break;

View File

@ -71,7 +71,6 @@ CPluginManager::CPluginManager()
// Set initial values to NULL.
m_video = NULL;
m_dsp = NULL;
m_wiimote = NULL;
}
// This will call FreeLibrary() for all plugins
@ -81,14 +80,6 @@ CPluginManager::~CPluginManager()
delete m_PluginGlobals;
delete m_dsp;
if (m_wiimote)
{
m_wiimote->Shutdown();
delete m_wiimote;
m_wiimote = NULL;
}
delete m_video;
}
@ -118,18 +109,6 @@ bool CPluginManager::InitPlugins()
return false;
}
// Init wiimote
if (m_params->bWii)
{
if (!m_params->m_strWiimotePlugin.empty())
GetWiimote();
if (!m_wiimote)
{
PanicAlert("Can't init Wiimote Plugin");
return false;
}
}
return true;
}
@ -138,12 +117,6 @@ bool CPluginManager::InitPlugins()
// for an explanation about the current LoadLibrary() and FreeLibrary() behavior.
void CPluginManager::ShutdownPlugins()
{
if (m_wiimote)
{
m_wiimote->Shutdown();
FreeWiimote();
}
if (m_dsp)
{
m_dsp->Shutdown();
@ -247,10 +220,6 @@ void *CPluginManager::LoadPlugin(const char *_rFilename)
plugin = new Common::PluginDSP(_rFilename);
break;
case PLUGIN_TYPE_WIIMOTE:
plugin = new Common::PluginWiimote(_rFilename);
break;
default:
PanicAlert("Trying to load unsupported type %d", type);
return NULL;
@ -319,27 +288,12 @@ void CPluginManager::ScanForPlugins()
/* Create or return the already created plugin pointers. This will be called
often for Wiimote. And often for the DSP from the DSP files.
often for the DSP from the DSP files.
We don't need to check if [Plugin]->IsValid() here because it will not be set by LoadPlugin()
if it's not valid.
*/
Common::PluginWiimote *CPluginManager::GetWiimote()
{
if (m_wiimote != NULL)
{
if (m_wiimote->GetFilename() == m_params->m_strWiimotePlugin)
return m_wiimote;
else
FreeWiimote();
}
// Else load a new plugin
m_wiimote = (Common::PluginWiimote*)LoadPlugin(m_params->m_strWiimotePlugin.c_str());
return m_wiimote;
}
Common::PluginDSP *CPluginManager::GetDSP()
{
if (m_dsp != NULL)
@ -384,17 +338,10 @@ void CPluginManager::FreeDSP()
m_dsp = NULL;
}
void CPluginManager::FreeWiimote()
{
delete m_wiimote;
m_wiimote = NULL;
}
void CPluginManager::EmuStateChange(PLUGIN_EMUSTATE newState)
{
GetVideo()->EmuStateChange(newState);
GetDSP()->EmuStateChange(newState);
GetWiimote()->EmuStateChange(newState);
}
@ -417,16 +364,15 @@ void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TY
if (GetVideo() != NULL)
GetVideo()->Config(_Parent);
break;
case PLUGIN_TYPE_DSP:
if (GetDSP() != NULL)
GetDSP()->Config(_Parent);
break;
case PLUGIN_TYPE_WIIMOTE:
if (GetWiimote() != NULL)
GetWiimote()->Config(_Parent);
break;
default:
PanicAlert("Type %d config not supported in plugin %s", Type, _rFilename);
break;
}
}
@ -444,11 +390,14 @@ void *CPluginManager::OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TY
case PLUGIN_TYPE_VIDEO:
return GetVideo()->Debug(_Parent, Show);
break;
case PLUGIN_TYPE_DSP:
return GetDSP()->Debug(_Parent, Show);
break;
default:
PanicAlert("Type %d debug not supported in plugin %s", Type, _rFilename);
return NULL;
break;
}
}

View File

@ -21,7 +21,6 @@
#include "Plugin.h"
#include "PluginDSP.h"
#include "PluginVideo.h"
#include "PluginWiimote.h"
#include "CoreParameter.h"
class CPluginInfo
@ -51,11 +50,9 @@ public:
Common::PluginVideo *GetVideo();
Common::PluginDSP *GetDSP();
Common::PluginWiimote *GetWiimote();
void FreeVideo();
void FreeDSP();
void FreeWiimote();
void EmuStateChange(PLUGIN_EMUSTATE newState);
@ -75,7 +72,6 @@ private:
PLUGIN_GLOBALS *m_PluginGlobals;
Common::PluginVideo *m_video;
Common::PluginDSP *m_dsp;
Common::PluginWiimote *m_wiimote;
SCoreStartupParameter * m_params;
CPluginManager();

View File

@ -49,6 +49,17 @@ files = [
"HW/EXI_DeviceEthernet.cpp",
"HW/GPFifo.cpp",
"HW/GCPad.cpp",
"HW/Wiimote.cpp",
"HW/WiimoteEmu/WiimoteEmu.cpp",
"HW/WiimoteEmu/Attachment/Classic.cpp",
"HW/WiimoteEmu/Attachment/Attachment.cpp",
"HW/WiimoteEmu/Attachment/Nunchuk.cpp",
"HW/WiimoteEmu/Attachment/Drums.cpp",
"HW/WiimoteEmu/Attachment/Guitar.cpp",
"HW/WiimoteEmu/Attachment/Turntable.cpp",
"HW/WiimoteEmu/EmuSubroutines.cpp",
"HW/WiimoteEmu/Encryption.cpp",
"HW/WiimoteEmu/Speaker.cpp",
"HW/GCPadEmu.cpp",
"HW/HW.cpp",
"HW/Memmap.cpp",
@ -132,6 +143,10 @@ elif sys.platform == 'darwin':
else:
files += [ "HW/BBA-TAP/TAP_Unix.cpp" ]
if env['HAVE_WIIUSE']:
files += [ 'HW/WiimoteReal/WiimoteReal.cpp' ]
libs += [ 'wiiuse' ]
libs = [
'bdisasm',
'inputcommon',

View File

@ -24,6 +24,7 @@
#include "Thread.h"
#include "CoreTiming.h"
#include "OnFrame.h"
#include "HW/Wiimote.h"
#include "HW/HW.h"
#include "PowerPC/PowerPC.h"
#include "PowerPC/JitCommon/JitBase.h"
@ -90,7 +91,7 @@ void DoState(PointerWrap &p)
pm.GetVideo()->DoState(p.GetPPtr(), p.GetMode());
pm.GetDSP()->DoState(p.GetPPtr(), p.GetMode());
if (Core::g_CoreStartupParameter.bWii)
pm.GetWiimote()->DoState(p.GetPPtr(), p.GetMode());
Wiimote::DoState(p.GetPPtr(), p.GetMode());
PowerPC::DoState(p);
HW::DoState(p);
CoreTiming::DoState(p);

View File

@ -90,11 +90,11 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib xinput.lib Iphlpapi.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib wxmsw28u_adv.lib wxmsw28u_aui.lib"
OutputFile="../../../Binary/Win32/Dolphin.exe"
AdditionalDependencies="Iphlpapi.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib wxmsw28u_adv.lib wxmsw28u_aui.lib"
OutputFile="../../../Binary/$(PlatformName)/Dolphin.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32;../../../Externals/OpenAL/Win32/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;&quot;../../../Externals/OpenAL/$(PlatformName)/&quot;;&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
IgnoreAllDefaultLibraries="false"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
@ -208,11 +208,11 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib xinput.lib Iphlpapi.lib comctl32.lib rpcrt4.lib wxbase28u.lib wxmsw28u_core.lib wxmsw28u_adv.lib wxmsw28u_aui.lib"
OutputFile="../../../Binary/x64/Dolphin.exe"
AdditionalDependencies="Iphlpapi.lib comctl32.lib rpcrt4.lib wxbase28u.lib wxmsw28u_core.lib wxmsw28u_adv.lib wxmsw28u_aui.lib"
OutputFile="../../../Binary/$(PlatformName)/Dolphin.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64;../../../Externals/OpenAL/Win64/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;&quot;../../../Externals/OpenAL/$(PlatformName)/&quot;;&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
IgnoreAllDefaultLibraries="false"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
@ -321,11 +321,11 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/TLBID:1"
AdditionalDependencies="SDL.lib xinput.lib Iphlpapi.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28ud.lib wxmsw28ud_core.lib wxmsw28ud_adv.lib wxmsw28ud_aui.lib"
AdditionalDependencies="Iphlpapi.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28ud.lib wxmsw28ud_core.lib wxmsw28ud_adv.lib wxmsw28ud_aui.lib"
OutputFile="../../../Binary/Win32/DolphinD.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32;../../../Externals/OpenAL/Win32/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;&quot;../../../Externals/OpenAL/$(PlatformName)/&quot;;&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
@ -432,11 +432,11 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/TLBID:1"
AdditionalDependencies="SDL.lib xinput.lib Iphlpapi.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28ud.lib wxmsw28ud_core.lib wxmsw28ud_adv.lib wxmsw28ud_aui.lib"
AdditionalDependencies="Iphlpapi.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28ud.lib wxmsw28ud_core.lib wxmsw28ud_adv.lib wxmsw28ud_aui.lib"
OutputFile="../../../Binary/x64/DolphinD.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64;../../../Externals/OpenAL/Win64/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;&quot;../../../Externals/OpenAL/$(PlatformName)/&quot;;&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
@ -546,11 +546,11 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/NODEFAULTLIB:msvcrt.lib&#x0D;&#x0A;/NODEFAULTLIB:libcmtd.lib"
AdditionalDependencies="SDL.lib xinput.lib Iphlpapi.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib wxmsw28u_adv.lib wxmsw28u_aui.lib"
AdditionalDependencies="Iphlpapi.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib wxmsw28u_adv.lib wxmsw28u_aui.lib"
OutputFile="../../../Binary/Win32/DolphinDF.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32;../../../Externals/OpenAL/Win32/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;&quot;../../../Externals/OpenAL/$(PlatformName)/&quot;;&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
@ -659,11 +659,11 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib xinput.lib Iphlpapi.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib wxmsw28u_adv.lib wxmsw28u_aui.lib"
AdditionalDependencies="Iphlpapi.lib comctl32.lib rpcrt4.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib wxmsw28u_adv.lib wxmsw28u_aui.lib"
OutputFile="../../../Binary/x64/DolphinDF.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64;../../../Externals/OpenAL/Win64/"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)&quot;;&quot;../../../Externals/OpenAL/$(PlatformName)/&quot;;&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
@ -924,6 +924,14 @@
RelativePath=".\Src\PatchAddEdit.h"
>
</File>
<File
RelativePath=".\Src\WiimoteConfigDiag.cpp"
>
</File>
<File
RelativePath=".\Src\WiimoteConfigDiag.h"
>
</File>
<Filter
Name="NetPlay"
>
@ -1054,6 +1062,22 @@
>
</File>
</Filter>
<Filter
Name="InputConfig"
>
<File
RelativePath=".\Src\InputConfigDiag.cpp"
>
</File>
<File
RelativePath=".\Src\InputConfigDiag.h"
>
</File>
<File
RelativePath=".\Src\InputConfigDiagBitmaps.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="Misc"

View File

@ -130,9 +130,6 @@ EVT_BUTTON(ID_GRAPHIC_CONFIG, CConfigMain::OnConfig)
EVT_CHOICE(ID_DSP_CB, CConfigMain::OnSelectionChanged)
EVT_BUTTON(ID_DSP_CONFIG, CConfigMain::OnConfig)
EVT_CHOICE(ID_WIIMOTE_CB, CConfigMain::OnSelectionChanged)
EVT_BUTTON(ID_WIIMOTE_CONFIG, CConfigMain::OnConfig)
END_EVENT_TABLE()
CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
@ -199,7 +196,6 @@ void CConfigMain::UpdateGUI()
// Disable stuff on PluginsPage
GraphicSelection->Disable();
DSPSelection->Disable();
WiimoteSelection->Disable();
}
}
@ -329,7 +325,6 @@ void CConfigMain::InitializeGUIValues()
// Plugins
FillChoiceBox(GraphicSelection, PLUGIN_TYPE_VIDEO, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin);
FillChoiceBox(DSPSelection, PLUGIN_TYPE_DSP, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin);
FillChoiceBox(WiimoteSelection, PLUGIN_TYPE_WIIMOTE, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin);
}
void CConfigMain::InitializeGUITooltips()
@ -743,10 +738,6 @@ void CConfigMain::CreateGUIControls()
DSPSelection = new wxChoice(PluginsPage, ID_DSP_CB, wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator);
DSPConfig = new wxButton(PluginsPage, ID_DSP_CONFIG, wxT("Config..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
sbWiimotePlugin = new wxStaticBoxSizer(wxHORIZONTAL, PluginsPage, wxT("Wiimote"));
WiimoteSelection = new wxChoice(PluginsPage, ID_WIIMOTE_CB, wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator);
WiimoteConfig = new wxButton(PluginsPage, ID_WIIMOTE_CONFIG, wxT("Config..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// Populate the settings
sbGraphicsPlugin->Add(GraphicSelection, 1, wxEXPAND|wxALL, 5);
sbGraphicsPlugin->Add(GraphicConfig, 0, wxALL, 5);
@ -754,14 +745,10 @@ void CConfigMain::CreateGUIControls()
sbDSPPlugin->Add(DSPSelection, 1, wxEXPAND|wxALL, 5);
sbDSPPlugin->Add(DSPConfig, 0, wxALL, 5);
sbWiimotePlugin->Add(WiimoteSelection, 1, wxEXPAND|wxALL, 5);
sbWiimotePlugin->Add(WiimoteConfig, 0, wxALL, 5);
// Populate the Plugins page
sPluginsPage = new wxBoxSizer(wxVERTICAL);
sPluginsPage->Add(sbGraphicsPlugin, 0, wxEXPAND|wxALL, 5);
sPluginsPage->Add(sbDSPPlugin, 0, wxEXPAND|wxALL, 5);
sPluginsPage->Add(sbWiimotePlugin, 0, wxEXPAND|wxALL, 5);
PluginsPage->SetSizer(sPluginsPage);
sPluginsPage->Layout();
@ -1155,8 +1142,6 @@ void CConfigMain::OnSelectionChanged(wxCommandEvent& WXUNUSED (event))
CPluginManager::GetInstance().FreeVideo();
if (GetFilename(DSPSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin))
CPluginManager::GetInstance().FreeDSP();
if (GetFilename(WiimoteSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin))
CPluginManager::GetInstance().FreeWiimote();
}
void CConfigMain::OnConfig(wxCommandEvent& event)
@ -1169,9 +1154,6 @@ void CConfigMain::OnConfig(wxCommandEvent& event)
case ID_DSP_CONFIG:
CallConfig(DSPSelection);
break;
case ID_WIIMOTE_CONFIG:
CallConfig(WiimoteSelection);
break;
}
}

View File

@ -140,7 +140,7 @@ private:
wxBoxSizer* sPluginsPage; // Plugins settings
wxStaticBoxSizer* sbGraphicsPlugin, *sbDSPPlugin, *sbWiimotePlugin; // Graphics, DSP, Wiimote sections
wxStaticBoxSizer* sbGraphicsPlugin, *sbDSPPlugin; // Graphics, DSP sections
// Graphics
wxChoice* GraphicSelection;
@ -150,10 +150,6 @@ private:
wxChoice* DSPSelection;
wxButton* DSPConfig;
// Wiimote
wxChoice* WiimoteSelection;
wxButton* WiimoteConfig;
wxButton* m_Ok;
FILE* pStream;
@ -262,11 +258,6 @@ private:
ID_DSP_CB,
ID_DSP_CONFIG,
ID_DSP_ABOUT,
ID_WIIMOTE_TEXT,
ID_WIIMOTE_CB,
ID_WIIMOTE_CONFIG,
ID_WIIMOTE_ABOUT
};
void InitializeGUILists();

View File

@ -817,9 +817,6 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
&& event.GetModifiers() == wxMOD_SHIFT)
PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode());
#endif
// Send the keyboard status to the Input plugins
CPluginManager::GetInstance().GetWiimote()->Wiimote_Input(event.GetKeyCode(), 1); // 1 = Down
}
else
event.Skip();
@ -828,10 +825,6 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
void CFrame::OnKeyUp(wxKeyEvent& event)
{
event.Skip();
if(Core::GetState() != Core::CORE_UNINITIALIZED) {
CPluginManager::GetInstance().GetWiimote()->Wiimote_Input(event.GetKeyCode(), 0); // 0 = Up
}
}
void CFrame::DoFullscreen(bool bF)

View File

@ -57,12 +57,14 @@ Core::GetWindowHandle().
#include "HW/DVDInterface.h"
#include "HW/ProcessorInterface.h"
#include "HW/GCPad.h"
#include "HW/Wiimote.h"
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
#include "State.h"
#include "VolumeHandler.h"
#include "NANDContentLoader.h"
#include "WXInputBase.h"
#include "../../InputUICommon/Src/ConfigDiag.h"
#include "WiimoteConfigDiag.h"
#include "InputConfigDiag.h"
#include <wx/datetime.h> // wxWidgets
@ -1024,42 +1026,50 @@ void CFrame::OnPluginDSP(wxCommandEvent& WXUNUSED (event))
void CFrame::OnPluginPAD(wxCommandEvent& WXUNUSED (event))
{
InputPlugin *pad_plugin = PAD_GetPlugin();
InputPlugin *const pad_plugin = Pad::GetPlugin();
bool was_init = false;
if ( pad_plugin->controller_interface.IsInit() ) // check if game is running
if (g_controller_interface.IsInit()) // check if game is running
was_init = true;
else
{
#if defined(HAVE_X11) && HAVE_X11
Window win = X11Utils::XWindowFromHandle(GetHandle());
GCPad_Init((void *)win);
Pad::Initialize((void *)win);
#else
GCPad_Init(GetHandle());
Pad::Initialize(GetHandle());
#endif
}
InputConfigDialog* m_ConfigFrame = new InputConfigDialog(this, *pad_plugin, "Dolphin GCPad Configuration");
InputConfigDialog *const m_ConfigFrame = new InputConfigDialog(this, *pad_plugin, "Dolphin GCPad Configuration");
m_ConfigFrame->ShowModal();
m_ConfigFrame->Destroy();
if (!was_init) // if game isn't running
{
GCPad_Deinit();
Pad::Shutdown();
}
}
void CFrame::OnPluginWiimote(wxCommandEvent& WXUNUSED (event))
{
#ifdef _WIN32
Disable(); // Fake a modal dialog
#endif
CPluginManager::GetInstance().OpenConfig(
this,
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin.c_str(),
PLUGIN_TYPE_WIIMOTE
);
#ifdef _WIN32
Enable();
Raise();
#endif
InputPlugin *const wiimote_plugin = Wiimote::GetPlugin();
bool was_init = false;
if (g_controller_interface.IsInit()) // check if game is running
was_init = true;
else
{
#if defined(HAVE_X11) && HAVE_X11
Window win = X11Utils::XWindowFromHandle(GetHandle());
Wiimote::Initialize((void *)win);
#else
Wiimote::Initialize(GetHandle());
#endif
}
WiimoteConfigDiag *const m_ConfigFrame = new WiimoteConfigDiag(this, *wiimote_plugin);
m_ConfigFrame->ShowModal();
m_ConfigFrame->Destroy();
if (!was_init) // if game isn't running
{
Wiimote::Shutdown();
}
}
void CFrame::OnHelp(wxCommandEvent& event)

View File

@ -15,18 +15,20 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "ConfigDiag.h"
#include "InputConfigDiag.h"
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
#define WXSTR_FROM_STR(s) (wxString::From8BitData((s).c_str()))
// ToAscii was causing probs with some extended ascii characters, To8BitData seems to work
#define STR_FROM_WXSTR(w) (std::string((w).To8BitData()))
#ifdef USE_UDP_WIIMOTE
void GamepadPage::ConfigUDPWii(wxCommandEvent &event)
{
UDPWrapper* const wrp = ((UDPConfigButton*)event.GetEventObject())->wrapper;
wrp->Configure(this);
}
#endif
void GamepadPage::ConfigExtension( wxCommandEvent& event )
{
@ -184,10 +186,10 @@ void InputConfigDialog::UpdateControlReferences()
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
e = m_padpages.end();
for ( ; i != e; ++i )
(*i)->controller->UpdateReferences( m_plugin.controller_interface );
(*i)->controller->UpdateReferences(g_controller_interface);
}
void InputConfigDialog::ClickSave( wxCommandEvent& event )
void InputConfigDialog::ClickSave(wxCommandEvent&)
{
m_plugin.SaveConfig();
Close();
@ -197,7 +199,7 @@ void ControlDialog::UpdateListContents()
{
control_lbox->Clear();
ControllerInterface::Device* const dev = m_plugin.controller_interface.FindDevice(m_devq);
ControllerInterface::Device* const dev = g_controller_interface.FindDevice(m_devq);
if (dev)
{
if (control_reference->is_input)
@ -268,7 +270,7 @@ void GamepadPage::UpdateGUI()
}
}
void GamepadPage::ClearAll( wxCommandEvent& event )
void GamepadPage::ClearAll(wxCommandEvent&)
{
// just load an empty ini section to clear everything :P
IniFile::Section section;
@ -284,29 +286,29 @@ void GamepadPage::ClearAll( wxCommandEvent& event )
UpdateGUI();
}
void GamepadPage::LoadDefaults( wxCommandEvent& event )
void GamepadPage::LoadDefaults(wxCommandEvent&)
{
controller->LoadDefaults(m_plugin.controller_interface);
controller->LoadDefaults(g_controller_interface);
m_plugin.controls_crit.Enter(); // enter
controller->UpdateReferences(m_plugin.controller_interface);
controller->UpdateReferences(g_controller_interface);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
void ControlDialog::SetControl( wxCommandEvent& event )
void ControlDialog::SetControl(wxCommandEvent&)
{
control_reference->expression = STR_FROM_WXSTR(textctrl->GetValue());
m_plugin.controls_crit.Enter(); // enter
m_plugin.controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
void GamepadPage::SetDevice( wxCommandEvent& event )
void GamepadPage::SetDevice(wxCommandEvent&)
{
controller->default_device.FromString(STR_FROM_WXSTR(device_cbox->GetValue()));
@ -318,11 +320,11 @@ void GamepadPage::SetDevice( wxCommandEvent& event )
// update references
m_plugin.controls_crit.Enter(); // enter
controller->UpdateReferences( m_plugin.controller_interface );
controller->UpdateReferences( g_controller_interface );
m_plugin.controls_crit.Leave(); // leave
}
void ControlDialog::SetDevice( wxCommandEvent& event )
void ControlDialog::SetDevice(wxCommandEvent&)
{
m_devq.FromString(STR_FROM_WXSTR(device_cbox->GetValue()));
@ -333,18 +335,18 @@ void ControlDialog::SetDevice( wxCommandEvent& event )
UpdateListContents();
}
void ControlDialog::ClearControl(wxCommandEvent& event)
void ControlDialog::ClearControl(wxCommandEvent&)
{
control_reference->expression.clear();
m_plugin.controls_crit.Enter(); // enter
m_plugin.controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
void ControlDialog::SetSelectedControl(wxCommandEvent& event)
void ControlDialog::SetSelectedControl(wxCommandEvent&)
{
const int num = control_lbox->GetSelection();
@ -363,7 +365,7 @@ void ControlDialog::SetSelectedControl(wxCommandEvent& event)
control_reference->expression = STR_FROM_WXSTR(expr);
m_plugin.controls_crit.Enter(); // enter
m_plugin.controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
@ -395,7 +397,7 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
control_reference->expression = STR_FROM_WXSTR(expr);
m_plugin.controls_crit.Enter(); // enter
m_plugin.controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
@ -408,7 +410,7 @@ void GamepadPage::AdjustSetting( wxCommandEvent& event )
m_plugin.controls_crit.Leave(); // leave
}
void GamepadPage::AdjustControlOption( wxCommandEvent& event )
void GamepadPage::AdjustControlOption(wxCommandEvent&)
{
m_plugin.controls_crit.Enter(); // enter / prolly fine not being here
m_control_dialog->control_reference->range = (ControlState)(m_control_dialog->range_slider->GetValue()) / SLIDER_TICK_COUNT;
@ -432,7 +434,7 @@ void GamepadPage::ClearControl( wxCommandEvent& event )
btn->control_reference->range = 1.0f;
m_plugin.controls_crit.Enter(); // enter
controller->UpdateReferences( m_plugin.controller_interface );
controller->UpdateReferences( g_controller_interface );
m_plugin.controls_crit.Leave(); // leave
// update changes
@ -444,7 +446,7 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
wxButton* const btn = (wxButton*)event.GetEventObject();
const wxString lbl = btn->GetLabel();
ControllerInterface::Device* const dev = m_plugin.controller_interface.FindDevice(m_devq);
ControllerInterface::Device* const dev = g_controller_interface.FindDevice(m_devq);
if (dev)
{
btn->SetLabel(wxT("[ waiting ]"));
@ -469,7 +471,7 @@ void GamepadPage::DetectControl( wxCommandEvent& event )
ControlButton* btn = (ControlButton*)event.GetEventObject();
// find device :/
ControllerInterface::Device* const dev = m_plugin.controller_interface.FindDevice(controller->default_device);
ControllerInterface::Device* const dev = g_controller_interface.FindDevice(controller->default_device);
if (dev)
{
btn->SetLabel(wxT("[ waiting ]"));
@ -484,7 +486,7 @@ void GamepadPage::DetectControl( wxCommandEvent& event )
if (ctrl)
{
btn->control_reference->expression = ctrl->GetName();
m_plugin.controller_interface.UpdateReference(btn->control_reference, controller->default_device);
g_controller_interface.UpdateReference(btn->control_reference, controller->default_device);
}
m_plugin.controls_crit.Leave(); // leave
@ -585,7 +587,7 @@ void GamepadPage::GetProfilePath(std::string& path)
}
}
void GamepadPage::LoadProfile(wxCommandEvent& event)
void GamepadPage::LoadProfile(wxCommandEvent&)
{
std::string fname;
GamepadPage::GetProfilePath(fname);
@ -598,13 +600,13 @@ void GamepadPage::LoadProfile(wxCommandEvent& event)
m_plugin.controls_crit.Enter();
controller->LoadConfig(inifile.GetOrCreateSection("Profile"));
controller->UpdateReferences(m_plugin.controller_interface);
controller->UpdateReferences(g_controller_interface);
m_plugin.controls_crit.Leave();
UpdateGUI();
}
void GamepadPage::SaveProfile(wxCommandEvent& event)
void GamepadPage::SaveProfile(wxCommandEvent&)
{
std::string fname;
GamepadPage::GetProfilePath(fname);
@ -622,7 +624,7 @@ void GamepadPage::SaveProfile(wxCommandEvent& event)
PanicAlert("You must enter a valid profile name.");
}
void GamepadPage::DeleteProfile(wxCommandEvent& event)
void GamepadPage::DeleteProfile(wxCommandEvent&)
{
std::string fname;
GamepadPage::GetProfilePath(fname);
@ -647,8 +649,8 @@ void InputConfigDialog::UpdateDeviceComboBox()
{
(*i)->device_cbox->Clear();
std::vector<ControllerInterface::Device*>::const_iterator
di = m_plugin.controller_interface.Devices().begin(),
de = m_plugin.controller_interface.Devices().end();
di = g_controller_interface.Devices().begin(),
de = g_controller_interface.Devices().end();
for ( ; di!=de; ++di )
{
dq.FromDevice( *di );
@ -658,14 +660,13 @@ void InputConfigDialog::UpdateDeviceComboBox()
}
}
void GamepadPage::RefreshDevices( wxCommandEvent& event )
void GamepadPage::RefreshDevices(wxCommandEvent&)
{
m_plugin.controls_crit.Enter(); // enter
// refresh devices
// TODO: remove hackery of not deinting SDL
m_plugin.controller_interface.DeInit(true);
m_plugin.controller_interface.Init();
g_controller_interface.Shutdown();
g_controller_interface.Initialize();
// update all control references
m_config_dialog->UpdateControlReferences();
@ -835,6 +836,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add(configure_btn, 0, wxALL|wxEXPAND, 3 );
}
break;
#ifdef USE_UDP_WIIMOTE
case GROUP_TYPE_UDPWII:
{
wxButton* const btn = new UDPConfigButton( parent, (UDPWrapper*)group );
@ -842,6 +844,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add(btn, 0, wxALL|wxEXPAND, 3);
}
break;
#endif
default:
{
//options

View File

@ -146,6 +146,7 @@ public:
ControllerInterface::ControlReference* const control_reference;
};
#ifdef USE_UDP_WIIMOTE
class UDPConfigButton : public wxButton
{
@ -157,6 +158,8 @@ public:
{}
};
#endif
class ControlGroupBox : public wxStaticBoxSizer
{
public:

View File

@ -15,15 +15,15 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "ConfigDiag.h"
#include "InputConfigDiag.h"
void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
{
wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
m_plugin.controller_interface.UpdateInput();
g_controller_interface.UpdateInput();
// don't want game thread updating input when we are using it here
if (false == m_plugin.controller_interface.update_lock.TryEnter())
if (false == g_controller_interface.update_lock.TryEnter())
return;
GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage(m_pad_notebook->GetSelection());
@ -345,5 +345,5 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
}
}
m_plugin.controller_interface.update_lock.Leave();
g_controller_interface.update_lock.Leave();
}

View File

@ -32,6 +32,7 @@
#include "Host.h" // Core
#include "PluginManager.h"
#include "HW/Wiimote.h"
#include "Globals.h" // Local
#include "Main.h"
@ -336,6 +337,7 @@ bool DolphinApp::OnInit()
LogManager::Init();
SConfig::Init();
CPluginManager::Init();
WiimoteReal::LoadSettings();
if (selectVideoPlugin && videoPluginFilename != wxEmptyString)
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin =
@ -345,10 +347,6 @@ bool DolphinApp::OnInit()
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin =
std::string(audioPluginFilename.mb_str());
if (selectWiimotePlugin && wiimotePluginFilename != wxEmptyString)
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin =
std::string(wiimotePluginFilename.mb_str());
// Enable the PNG image handler for screenshots
wxImage::AddHandler(new wxPNGHandler);
@ -432,12 +430,10 @@ void DolphinApp::OnEndSession()
int DolphinApp::OnExit()
{
WiimoteReal::Shutdown();
#ifdef _WIN32
if (SConfig::GetInstance().m_WiiAutoUnpair)
{
if (CPluginManager::GetInstance().GetWiimote())
CPluginManager::GetInstance().GetWiimote()->Wiimote_UnPairWiimotes();
}
WiimoteReal::UnPair();
#endif
CPluginManager::Shutdown();
SConfig::Shutdown();

View File

@ -392,6 +392,7 @@ int main(int argc, char* argv[])
}
updateMainFrameEvent.Shutdown();
WiimoteReal::Shutdown();
CPluginManager::Shutdown();
SConfig::Shutdown();
LogManager::Shutdown();

View File

@ -33,6 +33,8 @@ if env['HAVE_WX']:
'LogWindow.cpp',
'GameListCtrl.cpp',
'HotkeyDlg.cpp',
'InputConfigDiag.cpp',
'InputConfigDiagBitmaps.cpp',
'ISOFile.cpp',
'ISOProperties.cpp',
'PatchAddEdit.cpp',
@ -43,6 +45,7 @@ if env['HAVE_WX']:
'NetPlayClient.cpp',
'NetPlayServer.cpp',
'NetWindow.cpp',
'WiimoteConfigDiag.cpp',
]
wxlibs = [ 'debwx', 'debugger_ui_util', 'inputuicommon', 'memcard' ]
@ -96,8 +99,6 @@ elif sys.platform == 'darwin' and env['HAVE_WX']:
env.Depends(exeGUIdist, env['plugin_dir'])
env.Fixup(exeGUIdist, exeGUI)
else:
files += [ 'X11Utils.cpp' ]
libs += [ 'SDL' ]
exeGUI = env['binary_dir'] + '/dolphin-emu'
exeNoGUI = env['binary_dir'] + '/dolphin-emu-nogui'
env.InstallAs(env['data_dir'] + '/sys', '#Data/Sys')

View File

@ -1,6 +1,6 @@
#include "WiimoteConfigDiag.h"
#include "WiimoteReal/WiimoteReal.h"
#include "HW/Wiimote.h"
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
@ -87,7 +87,7 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin
Center();
}
void WiimoteConfigDiag::ConfigEmulatedWiimote(wxCommandEvent& event)
void WiimoteConfigDiag::ConfigEmulatedWiimote(wxCommandEvent&)
{
InputConfigDialog* const m_emu_config_diag = new InputConfigDialog(this, m_plugin, "Dolphin Emulated Wiimote Configuration", m_pad_notebook->GetSelection());
m_emu_config_diag->ShowModal();
@ -102,7 +102,7 @@ void WiimoteConfigDiag::UpdateGUI()
}
#ifdef _WIN32
void WiimoteConfigDiag::PairUpRealWiimotes(wxCommandEvent& event)
void WiimoteConfigDiag::PairUpRealWiimotes(wxCommandEvent&)
{
const int paired = WiimoteReal::PairUp();
@ -119,7 +119,7 @@ void WiimoteConfigDiag::PairUpRealWiimotes(wxCommandEvent& event)
}
#endif
void WiimoteConfigDiag::RefreshRealWiimotes(wxCommandEvent& event)
void WiimoteConfigDiag::RefreshRealWiimotes(wxCommandEvent&)
{
WiimoteReal::Refresh();
UpdateGUI();
@ -131,9 +131,9 @@ void WiimoteConfigPage::SelectSource(wxCommandEvent& event)
g_wiimote_sources[m_index] = event.GetInt();
}
void WiimoteConfigDiag::Save(wxCommandEvent& event)
void WiimoteConfigDiag::Save(wxCommandEvent&)
{
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + g_plugin.ini_name + ".ini" );
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + WIIMOTE_INI_NAME ".ini" );
IniFile inifile;
inifile.Load(ini_filename);

View File

@ -13,7 +13,7 @@
#include <wx/panel.h>
#include <wx/spinctrl.h>
#include "ConfigDiag.h"
#include "InputConfigDiag.h"
class WiimoteConfigPage : public wxNotebookPage
{

View File

@ -66,6 +66,8 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="xinput.lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -131,6 +133,8 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="xinput.lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -197,6 +201,8 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="xinput.lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -264,7 +270,9 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="xinput.lib"
OutputFile="$(OutDir)\$(ProjectName).lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -326,6 +334,8 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="xinput.lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -388,6 +398,8 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="xinput.lib"
AdditionalLibraryDirectories="&quot;..\..\..\Externals\SDL\$(PlatformName)&quot;"
/>
<Tool
Name="VCALinkTool"
@ -477,10 +489,6 @@
</File>
</Filter>
</Filter>
<File
RelativePath=".\Src\Configuration.cpp"
>
</File>
<File
RelativePath=".\Src\ControllerEmu.cpp"
>
@ -489,22 +497,10 @@
RelativePath=".\Src\ControllerEmu.h"
>
</File>
<File
RelativePath=".\Src\DirectInputBase.cpp"
>
</File>
<File
RelativePath=".\Src\DirectInputBase.h"
>
</File>
<File
RelativePath=".\Src\GCPadStatus.h"
>
</File>
<File
RelativePath=".\Src\InputCommon.h"
>
</File>
<File
RelativePath=".\Src\InputConfig.cpp"
>
@ -517,14 +513,6 @@
RelativePath=".\Src\SConscript"
>
</File>
<File
RelativePath=".\Src\SDL_Util.cpp"
>
</File>
<File
RelativePath=".\Src\SDL_Util.h"
>
</File>
<File
RelativePath=".\Src\UDPWiimote.cpp"
>
@ -541,14 +529,6 @@
RelativePath=".\Src\UDPWrapper.h"
>
</File>
<File
RelativePath=".\Src\XInput_Util.cpp"
>
</File>
<File
RelativePath=".\Src\XInput_Util.h"
>
</File>
</Files>
<Globals>
</Globals>

View File

@ -1,253 +0,0 @@
// 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 <iostream> // System
#include <vector>
#include <cmath>
#include "Common.h" // Common
#if defined HAVE_WX && HAVE_WX
#include <wx/wx.h>
#endif
#ifdef _WIN32
#define NOMINMAX
#include <Windows.h>
#endif
namespace InputCommon
{
// Degree to radian and back
float Deg2Rad(float Deg)
{
return Deg * (float)M_PI / 180.0f;
}
float Rad2Deg(float Rad)
{
return Rad * 180.0f / (float)M_PI;
}
// Check if the pad is within the dead zone, we assume the range is 0x8000
float CoordinatesToRadius(int x, int y)
{
return sqrt(pow((float)x, 2) + pow((float)y, 2));
}
bool IsDeadZone(float DeadZone, int x, int y)
{
// Get the distance from the center
float Distance = CoordinatesToRadius(x, y) / 32767.0f;
//Console::Print("%f\n", Distance);
// Check if it's within the dead zone
if (Distance <= DeadZone)
return true;
else
return false;
}
// Scale down stick values from 0x8000 to 0x80
/*
The value returned by SDL_JoystickGetAxis is a signed integer s16 (-32768 to
32767). The value used for the gamecube controller is an unsigned char u8 (0
to 255) with neutral at 0x80 (128), so that it's equivalent to a signed -128
to 127. */
//
int Pad_Convert(int _val)
{
/* If the limits on PadState[].axis[] actually is a u16 then we don't need
this but if it's not actually limited to that we need to apply these
limits */
if(_val > 32767) _val = 32767; // upper limit
if(_val < -32768) _val = -32768; // lower limit
// Convert the range (-0x8000 to 0x7fff) to (0 to 0xffff)
_val = 0x8000 +_val;
// Convert the range (0 to 0xffff) to (0 to 0xff)
_val = _val >> 8;
//Console::Print("0x%04x %06i\n\n", _val, _val);
return _val;
}
// Adjust the radius
void RadiusAdjustment(s8 &_x, s8 &_y, int _Radius)
{
// Get the radius setting
float RadiusSetting = (float)_Radius / 100.0f;
float x = (float)_x * RadiusSetting;
float y = (float)_y * RadiusSetting;
// Update values
_x = (s8)x;
_y = (s8)y;
}
/* Convert the stick raidus from a square or rounded box to a circular
radius. I don't know what input values the actual GC controller produce for
the GC, it may be a square, a circle or something in between. But one thing
that is certain is that PC pads differ in their output (as shown in the list
below), so it may be beneficiary to convert whatever radius they produce to
the radius the GC games expect. This is the first implementation of this
that convert a square radius to a circual radius. Use the advanced settings
to enable and calibrate it.
Observed diagonals:
Perfect circle: 71% = sin(45)
Logitech Dual Action: 100%
PS2 Dual Shock 2 (Original) with Super Dual Box Pro: 90%
XBox 360 Wireless: 85%
GameCube Controller (Third Party) with EMS Trio Linker Plus II: 60%
*/
/* Calculate the distance from the outer edges of the box to the outer edges of
the circle inside the box at any angle from 0 to 360. The returned value is
1 + Distance, for example at most sqrt(2) in the corners and at least 1.0 at
the horizontal and vertical angles. */
float Square2CircleDistance(float deg)
{
// See if we have to adjust the angle
deg = fabsf(deg);
if( (deg > 45 && deg < 135) ) deg = deg - 90;
// Calculate distance from center
float val = fabsf(cos(Deg2Rad(deg)));
float Distance = 1 / val;
//m_frame->m_pStatusBar2->SetLabel(wxString::Format("Deg:%f Val:%f Dist:%f", deg, val, dist));
return Distance;
}
// Produce a perfect circle from an original square or rounded box
void Square2Circle(int &_x, int &_y, int _Diagonal, bool Circle2Square)
{
// Do we need to do this check?
if(_x > 32767) _x = 32767; if(_y > 32767) _y = 32767; // upper limit
if(_x < -32768) _x = -32768; if(_y < -32768) _y = -32768; // lower limit
// Convert to circle
// Get the manually configured diagonal distance
float Diagonal = (float)_Diagonal / 100.0f;
// First make a perfect square in case we don't have one already
float OrigDist = sqrt( pow((float)_y, 2) + pow((float)_x, 2) ); // Get current distance
float deg = Rad2Deg(atan2((float)_y, (float)_x)); // Get current angle
/* Calculate the actual distance between the maxium diagonal values, and
the outer edges of the square. A diagonal of 85% means a maximum
distance of 0.85 * sqrt(2) ~1.2 in the diagonals. */
float corner_circle_dist = ( Diagonal / sin(Deg2Rad(45.0f)) );
float SquareDist = Square2CircleDistance(deg);
// The original-to-square distance adjustment
float adj_ratio1;
// The circle-to-square distance adjustment
float adj_ratio2 = SquareDist;
// The resulting distance
float result_dist;
// Calculate the corner-to-square adjustment ratio
if(corner_circle_dist < SquareDist) adj_ratio1 = SquareDist / corner_circle_dist;
else adj_ratio1 = 1;
// Calculate the resulting distance
if(Circle2Square)
result_dist = OrigDist * adj_ratio1;
else
result_dist = OrigDist * adj_ratio1 / adj_ratio2;
// Calculate x and y and return it
float x = result_dist * cos(Deg2Rad(deg));
float y = result_dist * sin(Deg2Rad(deg));
// Update coordinates
_x = (int)floor(x);
_y = (int)floor(y);
// Boundaries
if (_x < -32768) _x = -32768; if (_x > 32767) _x = 32767;
if (_y < -32768) _y = -32768; if (_y > 32767) _y = 32767;
// Debugging
//Console::Print("%f %f %i", corner_circle_dist, Diagonal, Tmp));
}
// Windows Virtual Key Codes Names
#ifdef _WIN32
std::string VKToString(int keycode)
{
// Default value
char KeyStr[64] = {0};
std::string KeyString;
switch(keycode)
{
// Give it some help with a few keys
case VK_END: return "END";
case VK_INSERT: return "INS";
case VK_DELETE: return "DEL";
case VK_HOME: return "HOME";
case VK_PRIOR: return "PGUP";
case VK_NEXT: return "PGDN";
case VK_UP: return "UP";
case VK_DOWN: return "DOWN";
case VK_LEFT: return "LEFT";
case VK_RIGHT: return "RIGHT";
case VK_LSHIFT: return "Left Shift";
case VK_RSHIFT: return "Right Shift";
case VK_LCONTROL: return "Left Ctrl";
case VK_RCONTROL: return "Right Ctrl";
case VK_LMENU: return "Left Alt";
case VK_RMENU: return "Right Alt";
case VK_NUMLOCK: return "Num Lock";
case VK_MULTIPLY: return "Num *";
case VK_ADD: return "Num +";
case VK_SEPARATOR: case 0xC2: return "Num Separator";
case VK_SUBTRACT: return "Num -";
case VK_DECIMAL: return "Num Decimal";
case VK_DIVIDE: return "Num /";
case VK_OEM_PLUS: return "=";
case VK_OEM_MINUS: return "-";
case VK_OEM_COMMA: return ",";
case VK_OEM_PERIOD: return ".";
case VK_BROWSER_BACK: return "Nav Bwd";
case VK_BROWSER_FORWARD: return "Nav Fwd";
//default: return KeyString = KeyStr;
}
// TODO: Switch to unicode GetKeyNameText?
if (keycode < 256) // Keyboard
GetKeyNameTextA(MapVirtualKey(keycode, MAPVK_VK_TO_VSC) << 16, KeyStr, 64);
else // Pad
sprintf(KeyStr, "PAD: %d", keycode - 0x1000);
return KeyString = KeyStr;
}
#endif
}

View File

@ -298,9 +298,8 @@ ControllerEmu::Tilt::Tilt( const char* const _name )
settings.push_back( new Setting("Circle Stick", 0 ) );
}
ControllerEmu::Cursor::Cursor( const char* const _name, const SWiimoteInitialize* const _wiimote_initialize )
: ControlGroup( _name, GROUP_TYPE_CURSOR )
, wiimote_initialize(_wiimote_initialize)
ControllerEmu::Cursor::Cursor(const char* const _name)
: ControlGroup(_name, GROUP_TYPE_CURSOR)
, m_z(0)
{
for ( unsigned int i = 0; i < 4; ++i )

View File

@ -27,7 +27,6 @@
#include <algorithm>
#include "GCPadStatus.h"
#include "pluginspecs_wiimote.h"
#include "ControllerInterface/ControllerInterface.h"
#include "IniFile.h"
@ -374,7 +373,7 @@ public:
class Cursor : public ControlGroup
{
public:
Cursor( const char* const _name, const SWiimoteInitialize* const _wiimote_initialize );
Cursor(const char* const _name);
template <typename C>
void GetState( C* const x, C* const y, C* const z, const bool adjusted = false )
@ -412,9 +411,6 @@ public:
}
}
private:
const SWiimoteInitialize* const wiimote_initialize;
float m_z;
};

View File

@ -20,14 +20,16 @@
#define INPUT_DETECT_THRESHOLD 0.85
ControllerInterface g_controller_interface;
//
// Init
//
// detect devices and inputs outputs / will make refresh function later
//
void ControllerInterface::Init()
void ControllerInterface::Initialize()
{
if ( m_is_init )
if (m_is_init)
return;
#ifdef CIFACE_USE_DINPUT
@ -54,9 +56,9 @@ void ControllerInterface::Init()
//
// remove all devices/ call library cleanup functions
//
void ControllerInterface::DeInit(const bool hacks_no_sdl_quit)
void ControllerInterface::Shutdown()
{
if ( false == m_is_init )
if (false == m_is_init)
return;
std::vector<Device*>::const_iterator
@ -73,12 +75,6 @@ void ControllerInterface::DeInit(const bool hacks_no_sdl_quit)
// update output
(*d)->UpdateOutput();
// TODO: remove this
// major hacks/memleaks to prevent gcpad/wiimote new from crashing eachother
if (hacks_no_sdl_quit)
if ((*d)->GetSource() == "SDL")
continue;
//delete device
delete *d;
}
@ -99,8 +95,7 @@ void ControllerInterface::DeInit(const bool hacks_no_sdl_quit)
#endif
#ifdef CIFACE_USE_SDL
// TODO: there seems to be some sort of memory leak with SDL, quit isn't freeing everything up
if (false == hacks_no_sdl_quit)
SDL_Quit();
SDL_Quit();
#endif
m_is_init = false;

View File

@ -210,9 +210,9 @@ public:
ControllerInterface() : m_is_init(false), m_hwnd(NULL) {}
void SetHwnd(void* const hwnd);
void Init();
void Initialize();
// TODO: remove this hack param
void DeInit(const bool hacks_no_sdl_quit = false);
void Shutdown();
bool IsInit() const { return m_is_init; }
void UpdateReference(ControlReference* control, const DeviceQualifier& default_device) const;
@ -230,4 +230,6 @@ private:
void* m_hwnd;
};
extern ControllerInterface g_controller_interface;
#endif

View File

@ -1,229 +0,0 @@
// 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
// -------------------
#include "DirectInputBase.h"
DInput::DInput()
: g_pDI(NULL),
g_pKeyboard(NULL)
{}
DInput::~DInput()
{
Free();
}
void DInput::DIKToString(unsigned int keycode, char *keyStr)
{
switch(keycode) {
case DIK_RETURN:
sprintf(keyStr, "Enter");
break;
case DIK_LCONTROL:
sprintf(keyStr, "Left Ctrl");
break;
case DIK_RCONTROL:
strcpy(keyStr, "Right Ctrl");
break;
case DIK_LSHIFT:
sprintf(keyStr, "Left Shift");
break;
case DIK_RSHIFT:
sprintf(keyStr, "Right Shift");
break;
case DIK_LMENU:
sprintf(keyStr, "Left Alt");
break;
case DIK_RMENU:
strcpy(keyStr, "Right Alt");
break;
case DIK_UP:
sprintf(keyStr, "Up");
break;
case DIK_DOWN:
sprintf(keyStr, "Down");
break;
case DIK_LEFT:
sprintf(keyStr, "Left");
break;
case DIK_RIGHT:
sprintf(keyStr, "Right");
break;
case DIK_HOME:
strcpy(keyStr, "Home");
break;
case DIK_END:
strcpy(keyStr, "End");
break;
case DIK_INSERT:
strcpy(keyStr, "Ins");
break;
case DIK_DELETE:
strcpy(keyStr, "Del");
break;
case DIK_PGUP:
strcpy(keyStr, "PgUp");
break;
case DIK_PGDN:
strcpy(keyStr, "PgDn");
break;
case DIK_NUMLOCK:
strcpy(keyStr, "Num Lock");
break;
case DIK_NUMPAD0:
strcpy(keyStr, "Num 0");
break;
case DIK_NUMPAD1:
strcpy(keyStr, "Num 1");
break;
case DIK_NUMPAD2:
strcpy(keyStr, "Num 2");
break;
case DIK_NUMPAD3:
strcpy(keyStr, "Num 3");
break;
case DIK_NUMPAD4:
strcpy(keyStr, "Num 4");
break;
case DIK_NUMPAD5:
strcpy(keyStr, "Num 5");
break;
case DIK_NUMPAD6:
strcpy(keyStr, "Num 6");
break;
case DIK_NUMPAD7:
strcpy(keyStr, "Num 7");
break;
case DIK_NUMPAD8:
strcpy(keyStr, "Num 8");
break;
case DIK_NUMPAD9:
strcpy(keyStr, "Num 9");
break;
case DIK_DIVIDE:
strcpy(keyStr, "Num /");
break;
case DIK_NUMPADENTER:
strcpy(keyStr, "Num Enter");
break;
case DIK_DECIMAL:
strcpy(keyStr, "Num Decimal");
break;
case DIK_NUMPADCOMMA:
case DIK_ABNT_C2:
strcpy(keyStr, "Num Separator");
break;
case DIK_NUMPADEQUALS:
strcpy(keyStr, "Num =");
break;
default:
// TODO: Switch to unicode GetKeyNameText?
GetKeyNameTextA(keycode << 16, keyStr, 64);
break;
}
}
HRESULT DInput::Init(HWND hWnd)
{
HRESULT hr;
DWORD dwCoopFlags;
dwCoopFlags = DISCL_FOREGROUND | DISCL_NOWINKEY;
// Create a DInput object
if (FAILED(hr = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION,
IID_IDirectInput8, (VOID* *)&g_pDI, NULL)))
{
MessageBox(0, L"Direct Input Create Failed", 0, MB_ICONERROR);
return(hr);
}
if (FAILED(hr = g_pDI->CreateDevice(GUID_SysKeyboard, &g_pKeyboard, NULL)))
{
MessageBox(0, L"Couldn't access keyboard", 0, MB_ICONERROR);
Free();
return(hr);
}
g_pKeyboard->SetDataFormat(&c_dfDIKeyboard);
g_pKeyboard->SetCooperativeLevel(hWnd, dwCoopFlags);
g_pKeyboard->Acquire();
return(S_OK);
}
void DInput::Free()
{
if (g_pKeyboard)
{
g_pKeyboard->Unacquire();
g_pKeyboard->Release();
g_pKeyboard = 0;
}
if (g_pDI)
{
g_pDI->Release();
g_pDI = 0;
}
}
// Desc: Read the input device's state when in immediate mode and display it.
HRESULT DInput::Read()
{
HRESULT hr;
if (NULL == g_pKeyboard)
{
return(S_OK);
}
// Get the input's device state, and put the state in dims
ZeroMemory(diks, sizeof(diks));
hr = g_pKeyboard->GetDeviceState(sizeof(diks), diks);
//for (int i=0; i<256; i++)
// if (diks[i]) MessageBox(0,"DSFJDKSF|",0,0);
if (FAILED(hr))
{
// DirectInput may be telling us that the input stream has been
// interrupted. We aren't tracking any state between polls, so
// we don't have any special reset that needs to be done.
// We just re-acquire and try again.
// If input is lost then acquire and keep trying
hr = g_pKeyboard->Acquire();
while (hr == DIERR_INPUTLOST)
{
hr = g_pKeyboard->Acquire();
}
// hr may be DIERR_OTHERAPPHASPRIO or other errors. This
// may occur when the app is minimized or in the process of
// switching, so just try again later
return(S_OK);
}
return(S_OK);
}

View File

@ -1,53 +0,0 @@
// 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 _DIRECTINPUTBASE_H
#define _DIRECTINPUTBASE_H
#include <windows.h> // System
#include <stdio.h>
#define DIRECTINPUT_VERSION 0x0800 // DirectInput
#include <dinput.h>
class DInput
{
public:
DInput();
~DInput();
static void DInput::DIKToString(unsigned int keycode, char *keyStr);
HRESULT Init(HWND hWnd);
void Free();
HRESULT Read();
BYTE diks[256]; // DirectInput keyboard state buffer
private:
LPDIRECTINPUT8 g_pDI; // The DirectInput object
LPDIRECTINPUTDEVICE8 g_pKeyboard; // The keyboard device
};
#endif

View File

@ -1,23 +0,0 @@
namespace InputCommon
{
enum EButtonType
{
CTL_AXIS = 0,
CTL_HAT,
CTL_BUTTON,
CTL_KEY,
};
enum ETriggerType
{
CTL_TRIGGER_SDL = 0,
CTL_TRIGGER_XINPUT,
};
enum EXInputTrigger
{
XI_TRIGGER_L = 0,
XI_TRIGGER_R,
};
}

View File

@ -17,19 +17,6 @@
#include "InputConfig.h"
InputPlugin::InputPlugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name )
: ini_name(_ini_name)
, gui_name(_gui_name)
, profile_name(_profile_name)
{
// GCPads
//for ( unsigned int i = 0; i<4; ++i )
//controllers.push_back( new GCPad( i ) );
// Wiimotes / disabled, cause it only the GUI half is done
//for ( unsigned int i = 0; i<4; ++i )
// controllers.push_back( new Wiimote( i ) );
};
InputPlugin::~InputPlugin()
{
// delete pads
@ -52,14 +39,14 @@ bool InputPlugin::LoadConfig()
// load settings from ini
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
// update refs
(*i)->UpdateReferences(controller_interface);
(*i)->UpdateReferences(g_controller_interface);
}
return true;
}
else
{
controllers[0]->LoadDefaults(controller_interface);
controllers[0]->UpdateReferences(controller_interface);
controllers[0]->LoadDefaults(g_controller_interface);
controllers[0]->UpdateReferences(g_controller_interface);
return false;
}
}

View File

@ -30,13 +30,16 @@
#include <map>
#include <sstream>
// InputPlugin isn't a very good name anymore since it's also used for GCPad which
// will soon not even be a plugin anymore.
// InputPlugin isn't a very good name anymore since it's used by GCPad/Wiimote
// which are not even plugins anymore.
class InputPlugin
{
public:
InputPlugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name );
InputPlugin(const char* const _ini_name, const char* const _gui_name,
const char* const _profile_name)
: ini_name(_ini_name), gui_name(_gui_name), profile_name(_profile_name) {}
~InputPlugin();
bool LoadConfig();
@ -44,8 +47,7 @@ public:
std::vector< ControllerEmu* > controllers;
Common::CriticalSection controls_crit; // critical section for changing any control references
ControllerInterface controller_interface;
Common::CriticalSection controls_crit; // critical section for changing any control references
const char * const ini_name;
const char * const gui_name;

View File

@ -3,13 +3,11 @@ import sys
Import('env')
files = [
'Configuration.cpp',
'ControllerEmu.cpp',
'InputConfig.cpp',
'ControllerInterface/ControllerInterface.cpp',
'UDPWiimote.cpp',
'UDPWrapper.cpp',
'SDL_Util.cpp', # XXX needed by old Wiimote plugin
]
if sys.platform == 'win32':
@ -30,7 +28,6 @@ elif env['HAVE_X11']:
files += [
'ControllerInterface/SDL/SDL.cpp',
'ControllerInterface/Xlib/Xlib.cpp',
'X11InputBase.cpp'
]
env.StaticLibrary(env['local_libs'] + "inputcommon", files)

View File

@ -1,222 +0,0 @@
// Project description
// -------------------
// Name: SDL Input
// Description: Common SDL Input Functions
//
// Author: Falcon4ever (nJoy@falcon4ever.com, www.multigesture.net), JPeterson etc
// Copyright (C) 2003 Dolphin Project.
//
//
// Licensetype: GNU General Public License (GPL)
//
// 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/
//
#define _SDL_MAIN_ // Avoid certain declarations in SDL.h
#include "InputCommon.h"
#include "SDL_Util.h" // Local
#ifdef _WIN32
#include "XInput_Util.h"
#endif
namespace InputCommon
{
// Search attached devices. Populate joyinfo for all attached physical devices.
// -----------------------
bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
{
if (!SDL_WasInit(0))
#if SDL_VERSION_ATLEAST(1, 3, 0)
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC) < 0)
#else
if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
#endif
{
PanicAlert("Could not initialize SDL: %s", SDL_GetError());
return false;
}
// Get device status
int numjoy = SDL_NumJoysticks();
for (int i = 0; i < numjoy; i++)
{
CONTROLLER_INFO Tmp;
Tmp.joy = SDL_JoystickOpen(i);
Tmp.ID = i;
Tmp.NumAxes = SDL_JoystickNumAxes(Tmp.joy);
Tmp.NumButtons = SDL_JoystickNumButtons(Tmp.joy);
Tmp.NumBalls = SDL_JoystickNumBalls(Tmp.joy);
Tmp.NumHats = SDL_JoystickNumHats(Tmp.joy);
Tmp.Name = SDL_JoystickName(i);
// Check if the device is okay
if ( Tmp.NumAxes == 0
&& Tmp.NumBalls == 0
&& Tmp.NumButtons == 0
&& Tmp.NumHats == 0
)
{
Tmp.Good = false;
}
else
{
_NumGoodPads++;
Tmp.Good = true;
}
_joyinfo.push_back(Tmp);
// We have now read the values we need so we close the device
// if (SDL_JoystickOpened(i)) SDL_JoystickClose(_joyinfo[i].joy);
}
_NumPads = (int)_joyinfo.size();
return true;
}
// Avoid extreme axis values
// ---------------------
/* Function: We have to avoid very big values because some triggers are -0x8000 in the
unpressed state (and then go from -0x8000 to 0x8000 as they are fully pressed) */
bool AvoidValues(int value, bool NoTriggerFilter)
{
// Avoid detecting very small or very big (for triggers) values
if((value > -0x1000 && value < 0x1000) // Small values
|| ((value < -0x7000 || value > 0x7000) && !NoTriggerFilter)) // Big values
return true; // Avoid
else
return false; // Keep
}
// Detect a pressed button
// ---------------------
void GetButton(SDL_Joystick *joy, int ControllerID, int buttons, int axes, int hats,
int &KeyboardKey, int &value, int &type, int &pressed, bool &Succeed, bool &Stop,
bool LeftRight, bool Axis, bool XInput, bool Button, bool Hat, bool NoTriggerFilter)
{
// It needs the wxWidgets excape keycode
static const int WXK_ESCAPE = 27;
// Update the internal status
SDL_JoystickUpdate();
// For the triggers we accept both a digital or an analog button
if(Axis)
{
for(int i = 0; i < axes; i++)
{
value = SDL_JoystickGetAxis(joy, i);
if(AvoidValues(value, NoTriggerFilter)) continue; // Avoid values
pressed = i + (LeftRight ? 1000 : 0); // Identify the analog triggers
type = InputCommon::CTL_AXIS;
Succeed = true;
}
}
// Check for a hat
if(Hat)
{
for(int i = 0; i < hats; i++)
{
value = SDL_JoystickGetHat(joy, i);
if(value)
{
pressed = i;
type = InputCommon::CTL_HAT;
Succeed = true;
}
}
}
// Check for a button
if(Button)
{
for(int i = 0; i < buttons; i++)
{
// Some kind of bug in SDL 1.3 would give button 9 and 10 (nonexistent) the value 48 on the 360 pad
if (SDL_JoystickGetButton(joy, i) > 1) continue;
if(SDL_JoystickGetButton(joy, i))
{
pressed = i;
type = InputCommon::CTL_BUTTON;
Succeed = true;
}
}
}
// Check for a XInput trigger
#ifdef _WIN32
if(XInput && LeftRight)
{
for(int i = 0; i <= InputCommon::XI_TRIGGER_R; i++)
{
if(XInput::GetXI(ControllerID, i))
{
pressed = i + 1000;
type = InputCommon::CTL_AXIS;
Succeed = true;
}
}
}
#endif
// Check for keyboard action
if (KeyboardKey)
{
if(Button)
{
// Todo: Add a separate keyboard vector to remove this restriction
if(KeyboardKey >= buttons)
{
pressed = KeyboardKey;
type = InputCommon::CTL_BUTTON;
Succeed = true;
KeyboardKey = 0;
if(pressed == WXK_ESCAPE) pressed = -1; // Check for the escape key
}
// Else show the error message
else
{
pressed = KeyboardKey;
KeyboardKey = -1;
Stop = true;
}
}
// Only accept the escape key
else if (KeyboardKey == WXK_ESCAPE)
{
Succeed = true;
KeyboardKey = 0;
pressed = -1;
}
}
}
} // InputCommon

View File

@ -1,76 +0,0 @@
// 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 _SDL_h
#define _SDL_h
#include <iostream> // System
#include <vector>
#include <cmath>
#ifdef _WIN32
#include <SDL.h> // Externals
#if SDL_VERSION_ATLEAST(1, 3, 0)
#include <SDL_haptic.h>
#endif
#else
#include <SDL/SDL.h>
#if SDL_VERSION_ATLEAST(1, 3, 0)
#include <SDL/SDL_haptic.h>
#endif
#endif
#include "Common.h" // Common
namespace InputCommon
{
struct CONTROLLER_INFO // CONNECTED WINDOWS DEVICES INFO
{
int NumAxes; // Amount of Axes
int NumButtons; // Amount of Buttons
int NumBalls; // Amount of Balls
int NumHats; // Amount of Hats (POV)
std::string Name; // Joypad/stickname
int ID; // SDL joystick device ID
bool Good; // Pad is good (it has at least one button or axis)
SDL_Joystick *joy; // SDL joystick device
};
// General functions
bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &NumPads, int &NumGoodPads);
void GetButton(SDL_Joystick*, int,int,int,int, int&,int&,int&,int&,bool&,bool&, bool,bool,bool,bool,bool,bool);
// Value conversion
float Deg2Rad(float Deg);
float Rad2Deg(float Rad);
int Pad_Convert(int _val);
float SquareDistance(float deg);
bool IsDeadZone(float DeadZone, int x, int y);
void Square2Circle(int &_x, int &_y, int _Diagonal, bool Circle2Square = false);
void RadiusAdjustment(s8 &_x, s8 &_y, int _Radius);
// Input configuration
std::string VKToString(int keycode);
} // InputCommon
#endif // _SDL_h

View File

@ -1,5 +1,8 @@
#include "UDPWiimote.h"
#ifdef USE_UDP_WIIMOTE
#ifdef _WIN32
#include <winsock2.h>
@ -418,3 +421,5 @@ void UDPWiimote::changeName(const char * name)
displayName=name;
d->nameMutex.Leave();
}
#endif

View File

@ -1,4 +1,7 @@
#ifndef UDPWIIMOTE_H
//#define USE_UDP_WIIMOTE
#if (!defined(UDPWIIMOTE_H) && defined(USE_UDP_WIIMOTE))
#define UDPWIIMOTE_H
#include "Common.h"

View File

@ -1,4 +1,8 @@
#include "UDPWrapper.h"
#ifdef USE_UDP_WIIMOTE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -197,3 +201,5 @@ void UDPWrapper::Configure(wxWindow * parent)
diag->Destroy();
}
#endif
#endif

View File

@ -1,4 +1,7 @@
#ifndef UDPWRAPPER_H
#include "UDPWiimote.h"
#if (defined(USE_UDP_WIIMOTE) && !defined(UDPWRAPPER_H))
#define UDPWRAPPER_H
#include "Common.h"
@ -19,8 +22,6 @@
#include <wx/spinctrl.h>
#endif
#include "UDPWiimote.h"
class UDPWrapper : public ControllerEmu::ControlGroup
{
public:

View File

@ -1,123 +0,0 @@
//
// Licensetype: GNU General Public License (GPL)
//
// 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/
//
// File description
/* -------------------
Function: This file will get the status of the analog triggers of any connected XInput device.
This code was made with the help of SimpleController.cpp in the June 2008 Microsoft DirectX SDK
Samples.
///////////////////////////////////////////////////// */
#ifdef _WIN32
// Includes
// -------------------
#include <windows.h>
#include <XInput.h> // XInput API
#include "InputCommon.h"
namespace XInput
{
// Declarations
// -------------------
#define MAX_CONTROLLERS 4 // XInput handles up to 4 controllers
struct CONTROLER_STATE
{
XINPUT_STATE state;
bool bConnected;
};
CONTROLER_STATE g_Controllers[MAX_CONTROLLERS];
// Init
// -------------------
/* Function: Calculate the number of connected XInput devices
Todo: Implement this to figure out if there are multiple XInput controllers connected,
we currently only try to connect to XInput device 0 */
void Init()
{
// Init state
//ZeroMemory( g_Controllers, sizeof( CONTROLER_STATE ) * MAX_CONTROLLERS );
// Declaration
DWORD dwResult;
// Calculate the number of connected XInput devices
for( DWORD i = 0; i < MAX_CONTROLLERS; i++ )
{
// Simply get the state of the controller from XInput.
dwResult = XInputGetState( i, &g_Controllers[i].state );
if( dwResult == ERROR_SUCCESS )
g_Controllers[i].bConnected = true;
else
g_Controllers[i].bConnected = false;
}
}
// Get the trigger status
// -------------------
int GetXI(int Controller, int Button)
{
// Update the internal status
DWORD dwResult;
dwResult = XInputGetState(Controller, &g_Controllers[Controller].state);
if (dwResult != ERROR_SUCCESS) return -1;
switch (Button)
{
case InputCommon::XI_TRIGGER_L:
return g_Controllers[Controller].state.Gamepad.bLeftTrigger;
case InputCommon::XI_TRIGGER_R:
return g_Controllers[Controller].state.Gamepad.bRightTrigger;
default:
return 0;
}
}
// Check if a certain controller is connected
// -------------------
bool IsConnected(int Controller)
{
DWORD dwResult = XInputGetState( Controller, &g_Controllers[Controller].state );
// Update the connected status
if( dwResult == ERROR_SUCCESS )
return true;
else
return false;
}
} // XInput
#endif

View File

@ -1,42 +0,0 @@
//
// Licensetype: GNU General Public License (GPL)
//
// 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/
//
#ifdef _WIN32
// Includes
// ----------
#include <iostream>
namespace XInput
{
// Declarations
// ----------
void Init();
int GetXI(int Controller, int Button);
bool IsConnected(int Controller);
} // XInput
#endif

View File

@ -404,18 +404,6 @@
<References>
</References>
<Files>
<File
RelativePath=".\Src\ConfigDiag.cpp"
>
</File>
<File
RelativePath=".\Src\ConfigDiag.h"
>
</File>
<File
RelativePath=".\Src\ConfigDiagBitmaps.cpp"
>
</File>
<File
RelativePath=".\Src\SConscript"
>

View File

@ -6,8 +6,6 @@ if not env['HAVE_WX']:
Return()
files = [
'ConfigDiag.cpp',
'ConfigDiagBitmaps.cpp',
'WXInputBase.cpp',
]

View File

@ -65,7 +65,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dolphin", "Core\DolphinWX\D
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160} = {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}
{D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8} = {D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8}
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1} = {D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}
{8D612734-FAA5-4B8A-804F-4DEA2367D495} = {8D612734-FAA5-4B8A-804F-4DEA2367D495}
{05C75041-D67D-4903-A362-8395A7B35C75} = {05C75041-D67D-4903-A362-8395A7B35C75}
{636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18} = {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}
{33546D62-7F34-4EA6-A88E-D538B36E16BF} = {33546D62-7F34-4EA6-A88E-D538B36E16BF}
@ -117,17 +116,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LZO", "..\Externals\LZO\LZO
{B807E8DB-4241-4754-BC2A-2F435BCA881A} = {B807E8DB-4241-4754-BC2A-2F435BCA881A}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_Wiimote", "Plugins\Plugin_Wiimote\Plugin_Wiimote.vcproj", "{8D612734-FAA5-4B8A-804F-4DEA2367D495}"
ProjectSection(ProjectDependencies) = postProject
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}
{11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED}
{0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} = {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E}
{374E2DB7-42DF-4E59-8474-62B6687F4978} = {374E2DB7-42DF-4E59-8474-62B6687F4978}
{1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} = {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE}
{B807E8DB-4241-4754-BC2A-2F435BCA881A} = {B807E8DB-4241-4754-BC2A-2F435BCA881A}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InputCommon", "Core\InputCommon\InputCommon.vcproj", "{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}"
ProjectSection(ProjectDependencies) = postProject
{B807E8DB-4241-4754-BC2A-2F435BCA881A} = {B807E8DB-4241-4754-BC2A-2F435BCA881A}
@ -236,22 +224,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoSoftware", "Plu
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_WiimoteNew", "Plugins\Plugin_WiimoteNew\Plugin_WiimoteNew.vcproj", "{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InputUICommon", "Core\InputUICommon\InputUICommon.vcproj", "{374E2DB7-42DF-4E59-8474-62B6687F4978}"
ProjectSection(ProjectDependencies) = postProject
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}
{05C75041-D67D-4903-A362-8395A7B35C75} = {05C75041-D67D-4903-A362-8395A7B35C75}
{11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED}
{0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} = {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E}
{374E2DB7-42DF-4E59-8474-62B6687F4978} = {374E2DB7-42DF-4E59-8474-62B6687F4978}
{1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} = {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE}
{B807E8DB-4241-4754-BC2A-2F435BCA881A} = {B807E8DB-4241-4754-BC2A-2F435BCA881A}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InputUICommon", "Core\InputUICommon\InputUICommon.vcproj", "{374E2DB7-42DF-4E59-8474-62B6687F4978}"
ProjectSection(ProjectDependencies) = postProject
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}
{B807E8DB-4241-4754-BC2A-2F435BCA881A} = {B807E8DB-4241-4754-BC2A-2F435BCA881A}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoDX11", "Plugins\Plugin_VideoDX11\Plugin_VideoDX11.vcproj", "{21DBE606-2958-43AC-A14E-B6B798D56554}"
@ -433,18 +413,6 @@ Global
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.Release|Win32.Build.0 = Release|Win32
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.Release|x64.ActiveCfg = Release|x64
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.Release|x64.Build.0 = Release|x64
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|Win32.ActiveCfg = Debug|Win32
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|Win32.Build.0 = Debug|Win32
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|x64.ActiveCfg = Debug|x64
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|x64.Build.0 = Debug|x64
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|Win32.Build.0 = DebugFast|Win32
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|x64.ActiveCfg = DebugFast|x64
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|x64.Build.0 = DebugFast|x64
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.ActiveCfg = Release|Win32
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.Build.0 = Release|Win32
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|x64.ActiveCfg = Release|x64
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|x64.Build.0 = Release|x64
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Debug|Win32.ActiveCfg = Debug|Win32
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Debug|Win32.Build.0 = Debug|Win32
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Debug|x64.ActiveCfg = Debug|x64
@ -625,18 +593,6 @@ Global
{66A4E7BD-E2E8-4373-9B75-8750EB5AE683}.Release|Win32.Build.0 = Release|Win32
{66A4E7BD-E2E8-4373-9B75-8750EB5AE683}.Release|x64.ActiveCfg = Release|x64
{66A4E7BD-E2E8-4373-9B75-8750EB5AE683}.Release|x64.Build.0 = Release|x64
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.Debug|Win32.ActiveCfg = Debug|Win32
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.Debug|Win32.Build.0 = Debug|Win32
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.Debug|x64.ActiveCfg = Debug|x64
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.Debug|x64.Build.0 = Debug|x64
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.DebugFast|Win32.Build.0 = DebugFast|Win32
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.DebugFast|x64.ActiveCfg = DebugFast|x64
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.DebugFast|x64.Build.0 = DebugFast|x64
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.Release|Win32.ActiveCfg = Release|Win32
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.Release|Win32.Build.0 = Release|Win32
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.Release|x64.ActiveCfg = Release|x64
{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.Release|x64.Build.0 = Release|x64
{374E2DB7-42DF-4E59-8474-62B6687F4978}.Debug|Win32.ActiveCfg = Debug|Win32
{374E2DB7-42DF-4E59-8474-62B6687F4978}.Debug|Win32.Build.0 = Debug|Win32
{374E2DB7-42DF-4E59-8474-62B6687F4978}.Debug|x64.ActiveCfg = Debug|x64

View File

@ -61,7 +61,7 @@ enum PLUGIN_TYPE {
PLUGIN_TYPE_AUDIO,
PLUGIN_TYPE_COMPILER,
PLUGIN_TYPE_DSP,
PLUGIN_TYPE_WIIMOTE,
PLUGIN_TYPE_WIIMOTE_REMOVED,
};
#define STATE_MODE_READ 1

View File

@ -1,84 +0,0 @@
//__________________________________________________________________________________________________
// Common wiimote plugin spec, unversioned
//
#ifndef _WIIMOTE_H_INCLUDED__
#define _WIIMOTE_H_INCLUDED__
#include "PluginSpecs.h"
#include "ExportProlog.h"
typedef void (*TLogv)(const char* _pMessage, int _v);
// This is called when the Wiimote sends input reports to the Core.
// Payload: an L2CAP packet.
typedef void (*TWiimoteInterruptChannel)(int _number, u16 _channelID, const void* _pData, u32 _Size);
typedef bool (*TRendererHasFocus)(void);
// This data is passed from the core on initialization.
typedef struct
{
void *hWnd;
u32 ISOId;
TLogv pLog;
TWiimoteInterruptChannel pWiimoteInterruptChannel;
TRendererHasFocus pRendererHasFocus;
} SWiimoteInitialize;
// I N T E R F A C E
// __________________________________________________________________________________________________
// Function: Wiimote_Output
// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
// on the HID CONTROL channel.
// input: Da pakket.
// output: none
//
EXPORT void CALL Wiimote_ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
// __________________________________________________________________________________________________
// Function: Send keyboard input to the plugin
// Purpose:
// input: The key and if it's pressed or released
// output: None
//
EXPORT void CALL Wiimote_Input(u16 _Key, u8 _UpDown);
// __________________________________________________________________________________________________
// Function: Wiimote_InterruptChannel
// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
// on the HID INTERRUPT channel.
// input: Da pakket.
// output: none
//
EXPORT void CALL Wiimote_InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
// __________________________________________________________________________________________________
// Function: Wiimote_Update
// Purpose: This function is called periodically by the Core.
// input: none
// output: none
//
EXPORT void CALL Wiimote_Update(int _number);
// __________________________________________________________________________________________________
// Function: Wiimote_UnPairWiimotes
// Purpose: Unpair real wiimotes to safe battery
// input: none
// output: number of unpaired wiimotes
//
EXPORT unsigned int CALL Wiimote_UnPairWiimotes();
// __________________________________________________________________________________________________
// Function: PAD_GetAttachedPads
// Purpose: Get mask of attached pads (eg: controller 1 & 4 -> 0x9)
// input: none
// output: number of pads
//
EXPORT unsigned int CALL Wiimote_GetAttachedControllers();
#include "ExportEpilog.h"
#endif //_WIIMOTE_H_INCLUDED__

View File

@ -1,672 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="Plugin_Wiimote"
ProjectGUID="{8D612734-FAA5-4B8A-804F-4DEA2367D495}"
RootNamespace="Plugin_Wiimote"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_WIIMOTE_TEST_EXPORTS;_SECURE_SCL=0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
AssemblerListingLocation="$(IntDir)\"
ProgramDataBaseFileName="$(IntDir)\"
WarningLevel="3"
WarnAsError="false"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
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"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
SubSystem="0"
OptimizeReferences="0"
EnableCOMDATFolding="0"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_WIIMOTE_TEST_EXPORTS;_SECURE_SCL=0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
AssemblerListingLocation="$(IntDir)\"
ProgramDataBaseFileName="$(IntDir)\"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib rpcrt4.lib wxbase28ud.lib wxmsw28ud_core.lib"
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_WiimoteD.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\WiiUse\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
SubSystem="0"
OptimizeReferences="0"
EnableCOMDATFolding="0"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_WIIMOTE_TEST_EXPORTS;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
AssemblerListingLocation="$(IntDir)\"
ProgramDataBaseFileName="$(IntDir)\"
WarningLevel="3"
WarnAsError="false"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/NODEFAULTLIB:msvcrt.lib"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib"
OutputFile="..\..\..\Binary\Win32\Plugins\Plugin_Wiimote.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\WiiUse\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
SubSystem="0"
OptimizeReferences="0"
EnableCOMDATFolding="0"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_WIIMOTE_TEST_EXPORTS;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
AssemblerListingLocation="$(IntDir)\"
ProgramDataBaseFileName="$(IntDir)\"
WarningLevel="3"
WarnAsError="false"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib"
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_Wiimote.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\WiiUse\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
SubSystem="0"
OptimizeReferences="0"
EnableCOMDATFolding="0"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="DebugFast|Win32"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="DEBUGFAST;WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_WIIMOTE_TEST_EXPORTS;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
WarningLevel="3"
WarnAsError="false"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/NODEFAULTLIB:msvcrt.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"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="DebugFast|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\Include_1.3;..\..\..\Externals\WiiUse\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Common\Src;..\..\Core\InputCommon\Src;..\..\Core\InputUICommon\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_WIIMOTE_TEST_EXPORTS;DEBUGFAST;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
WarningLevel="3"
WarnAsError="false"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
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"
GenerateManifest="false"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Emulated Wiimote"
>
<File
RelativePath=".\Src\DataReports.cpp"
>
</File>
<File
RelativePath=".\Src\EmuDefinitions.cpp"
>
</File>
<File
RelativePath=".\Src\EmuDefinitions.h"
>
</File>
<File
RelativePath=".\Src\EmuDynamics.cpp"
>
</File>
<File
RelativePath=".\Src\EmuMain.cpp"
>
</File>
<File
RelativePath=".\Src\EmuMain.h"
>
</File>
<File
RelativePath=".\Src\EmuPad.cpp"
>
</File>
<File
RelativePath=".\Src\EmuSubroutines.cpp"
>
</File>
<File
RelativePath=".\Src\EmuSubroutines.h"
>
</File>
<File
RelativePath=".\Src\Encryption.cpp"
>
</File>
<File
RelativePath=".\Src\Encryption.h"
>
</File>
<File
RelativePath=".\Src\FillReport.cpp"
>
</File>
<File
RelativePath=".\Src\Rumble.cpp"
>
</File>
<File
RelativePath=".\Src\UDPWiimote.cpp"
>
</File>
<File
RelativePath=".\Src\UDPWiimote.h"
>
</File>
<File
RelativePath=".\Src\wiimote_hid.h"
>
</File>
</Filter>
<Filter
Name="Real Wiimote"
>
<File
RelativePath=".\Src\wiimote_real.cpp"
>
</File>
<File
RelativePath=".\Src\wiimote_real.h"
>
</File>
</Filter>
<Filter
Name="Config"
>
<File
RelativePath=".\Src\Config.cpp"
>
</File>
<File
RelativePath=".\Src\Config.h"
>
</File>
<File
RelativePath=".\Src\ConfigBasicDlg.cpp"
>
</File>
<File
RelativePath=".\Src\ConfigBasicDlg.h"
>
</File>
<File
RelativePath=".\Src\ConfigGamepad.cpp"
>
</File>
<File
RelativePath=".\Src\ConfigPadDlg.cpp"
>
</File>
<File
RelativePath=".\Src\ConfigPadDlg.h"
>
</File>
</Filter>
<Filter
Name="UDP Wiimote"
>
<File
RelativePath=".\Src\UDPWiimote.cpp"
>
</File>
<File
RelativePath=".\Src\UDPWiimote.h"
>
</File>
</Filter>
<File
RelativePath=".\Src\main.cpp"
>
</File>
<File
RelativePath=".\Src\main.h"
>
</File>
<File
RelativePath="..\..\PluginSpecs\pluginspecs_wiimote.h"
>
</File>
<File
RelativePath=".\Src\SConscript"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,530 +0,0 @@
// 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 <iostream>
#include "Common.h"
#include "IniFile.h"
#include "StringUtil.h"
#include "wiimote_hid.h"
#include "Config.h"
#include "EmuDefinitions.h" // for PadMapping
#include "main.h"
#include "FileUtil.h"
#include "WXInputBase.h"
// Configuration file control names
// Do not change the order unless you change the related arrays
// Directionals are ordered as L, R, U, D
static const char* wmControlNames[] =
{
"WmA",
"WmB",
"Wm1",
"Wm2",
"WmP",
"WmM",
"WmH",
"WmL",
"WmR",
"WmU",
"WmD",
"WmRollL",
"WmRollR",
"WmPitchU",
"WmPitchD",
"WmShake",
"NcZ",
"NcC",
"NcL",
"NcR",
"NcU",
"NcD",
"NcRollL",
"NcRollR",
"NcPitchU",
"NcPitchD",
"NcShake",
"CcA",
"CcB",
"CcX",
"CcY",
"CcP",
"CcM",
"CcH",
"CcTl",
"CcTr",
"CcZl",
"CcZr",
"CcDl",
"CcDr",
"CcDu",
"CcDd",
"CcLl",
"CcLr",
"CcLu",
"CcLd",
"CcRl",
"CcRr",
"CcRu",
"CcRd",
"GH3Green",
"GH3Red",
"GH3Yellow",
"GH3Blue",
"GH3Orange",
"GH3Plus",
"GH3Minus",
"GH3Whammy",
"GH3Al",
"GH3Ar",
"GH3Au",
"GH3Ad",
"GH3StrumUp",
"GH3StrumDown",
};
static int wmDefaultControls[] =
{
// Wiimote
#ifdef _WIN32
'Z',
'X',
'C',
'V',
VK_OEM_PLUS,
VK_OEM_MINUS,
VK_BACK,
VK_LEFT,
VK_RIGHT,
VK_UP,
VK_DOWN,
'N',
'M',
VK_OEM_COMMA,
VK_OEM_PERIOD,
VK_OEM_2, // /
#elif defined(HAVE_X11) && HAVE_X11
XK_z,
XK_x,
XK_c,
XK_v,
XK_equal,
XK_minus,
XK_BackSpace,
XK_Left,
XK_Right,
XK_Up,
XK_Down,
XK_n,
XK_m,
XK_comma,
XK_period,
XK_slash,
#elif defined(USE_WX) && USE_WX
'Z',
'X',
'C',
'V',
'P',
'O',
WXK_BACK,
WXK_LEFT,
WXK_RIGHT,
WXK_UP,
WXK_DOWN,
'N',
'M',
WXK_SEPARATOR,
WXK_DECIMAL,
WXK_DIVIDE,
#else
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
#endif
// Nunchuck
#ifdef _WIN32
VK_NUMPAD0,
VK_DECIMAL,
VK_NUMPAD4,
VK_NUMPAD6,
VK_NUMPAD8,
VK_NUMPAD5,
VK_NUMPAD7,
VK_NUMPAD9,
VK_NUMPAD1,
VK_NUMPAD3,
VK_NUMPAD2,
#elif defined(HAVE_X11) && HAVE_X11
XK_KP_0,
XK_KP_Decimal,
XK_KP_4,
XK_KP_6,
XK_KP_8,
XK_KP_5,
XK_KP_7,
XK_KP_9,
XK_KP_1,
XK_KP_3,
XK_KP_2,
#elif defined(USE_WX) && USE_WX
WXK_NUMPAD0,
WXK_NUMPAD_DECIMAL,
WXK_NUMPAD4,
WXK_NUMPAD6,
WXK_NUMPAD8,
WXK_NUMPAD5,
WXK_NUMPAD7,
WXK_NUMPAD9,
WXK_NUMPAD1,
WXK_NUMPAD3,
WXK_NUMPAD2,
#else
0,0,0,0,0,0,0,0,0,0,0,
#endif
// Classic Controller
// A, B, X, Y
#ifdef _WIN32
VK_OEM_4, // [
VK_OEM_6, // ]
VK_OEM_1, // ;
VK_OEM_7, // '
#elif defined(HAVE_X11) && HAVE_X11
XK_bracketleft,
XK_bracketright,
XK_semicolon,
XK_quoteright,
#elif defined(USE_WX) && USE_WX
'O',
'P',
'K',
'L',
#else
0,0,0,0,
#endif
// +, -, Home
'H',
'F',
'G',
// Triggers, Zs
'E',
'Y',
'R',
'T',
// Digital pad
#ifdef _WIN32
VK_NUMPAD4,
VK_NUMPAD6,
VK_NUMPAD8,
VK_NUMPAD5,
#elif defined(HAVE_X11) && HAVE_X11
XK_KP_4,
XK_KP_6,
XK_KP_8,
XK_KP_5,
#elif defined(HAVE_X11) && HAVE_X11
WXK_NUMPAD4,
WXK_NUMPAD6,
WXK_NUMPAD8,
WXK_NUMPAD5,
#else
0,0,0,0,
#endif
// Left analog
'A',
'D',
'W',
'S',
// Right analog
'J',
'L',
'I',
'K',
// Guttar Hero
'A',
'S',
'D',
'F',
'G',
'L',
'J',
'H',
#ifdef _WIN32
VK_NUMPAD4,
VK_NUMPAD6,
VK_NUMPAD8,
VK_NUMPAD5,
#elif defined(HAVE_X11) && HAVE_X11
XK_KP_4,
XK_KP_6,
XK_KP_8,
XK_KP_5,
#elif defined(HAVE_X11) && HAVE_X11
WXK_NUMPAD4,
WXK_NUMPAD6,
WXK_NUMPAD8,
WXK_NUMPAD5,
#else
0,0,0,0,
#endif
'I',
'K',
};
Config g_Config;
Config::Config()
{
// Set all default values to zero
memset(this, 0, sizeof(Config));
}
void Config::Load()
{
std::string temp;
IniFile iniFile;
iniFile.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "Wiimote.ini").c_str());
// Real Wiimote
iniFile.Get("Real", "UpdateStatus", &bUpdateRealWiimote, true);
iniFile.Get("Real", "Unpair", &bUnpairRealWiimote, false);
iniFile.Get("Real", "Autopair", &bPairRealWiimote, false);
iniFile.Get("Real", "Timeout", &bWiiReadTimeout, 30);
iniFile.Get("Real", "AccNeutralX", &iAccNeutralX, 0);
iniFile.Get("Real", "AccNeutralY", &iAccNeutralY, 0);
iniFile.Get("Real", "AccNeutralZ", &iAccNeutralZ, 0);
iniFile.Get("Real", "AccNunNeutralX", &iAccNunNeutralX, 0);
iniFile.Get("Real", "AccNunNeutralY", &iAccNunNeutralY, 0);
iniFile.Get("Real", "AccNunNeutralZ", &iAccNunNeutralZ, 0);
for (int i = 0; i < MAX_WIIMOTES; i++)
{
// Slot specific settings
char SectionName[32];
sprintf(SectionName, "Wiimote%i", i + 1);
// General
iniFile.Get(SectionName, "Source", &WiiMoteEmu::WiiMapping[i].Source, (i == 0) ? 1 : 0);
iniFile.Get(SectionName, "Sideways", &WiiMoteEmu::WiiMapping[i].bSideways, false);
iniFile.Get(SectionName, "Upright", &WiiMoteEmu::WiiMapping[i].bUpright, false);
iniFile.Get(SectionName, "ExtensionConnected", &WiiMoteEmu::WiiMapping[i].iExtensionConnected, WiiMoteEmu::EXT_NONE);
iniFile.Get(SectionName, "MotionPlusConnected", &WiiMoteEmu::WiiMapping[i].bMotionPlusConnected, false);
iniFile.Get(SectionName, "TiltInputWM", &WiiMoteEmu::WiiMapping[i].Tilt.InputWM, WiiMoteEmu::FROM_KEYBOARD);
iniFile.Get(SectionName, "TiltInputNC", &WiiMoteEmu::WiiMapping[i].Tilt.InputNC, WiiMoteEmu::FROM_KEYBOARD);
iniFile.Get(SectionName, "TiltRollDegree", &WiiMoteEmu::WiiMapping[i].Tilt.RollDegree, 60);
iniFile.Get(SectionName, "TiltRollSwing", &WiiMoteEmu::WiiMapping[i].Tilt.RollSwing, false);
iniFile.Get(SectionName, "TiltRollInvert", &WiiMoteEmu::WiiMapping[i].Tilt.RollInvert, false);
WiiMoteEmu::WiiMapping[i].Tilt.RollRange = (WiiMoteEmu::WiiMapping[i].Tilt.RollSwing) ? 0 : WiiMoteEmu::WiiMapping[i].Tilt.RollDegree;
iniFile.Get(SectionName, "TiltPitchDegree", &WiiMoteEmu::WiiMapping[i].Tilt.PitchDegree, 60);
iniFile.Get(SectionName, "TiltPitchSwing", &WiiMoteEmu::WiiMapping[i].Tilt.PitchSwing, false);
iniFile.Get(SectionName, "TiltPitchInvert", &WiiMoteEmu::WiiMapping[i].Tilt.PitchInvert, false);
WiiMoteEmu::WiiMapping[i].Tilt.PitchRange = (WiiMoteEmu::WiiMapping[i].Tilt.PitchSwing) ? 0 : WiiMoteEmu::WiiMapping[i].Tilt.PitchDegree;
// StickMapping
iniFile.Get(SectionName, "NCStick", &WiiMoteEmu::WiiMapping[i].Stick.NC, WiiMoteEmu::FROM_KEYBOARD);
iniFile.Get(SectionName, "CCStickLeft", &WiiMoteEmu::WiiMapping[i].Stick.CCL, WiiMoteEmu::FROM_KEYBOARD);
iniFile.Get(SectionName, "CCStickRight", &WiiMoteEmu::WiiMapping[i].Stick.CCR, WiiMoteEmu::FROM_KEYBOARD);
iniFile.Get(SectionName, "CCTriggers", &WiiMoteEmu::WiiMapping[i].Stick.CCT, WiiMoteEmu::FROM_KEYBOARD);
iniFile.Get(SectionName, "GHStick", &WiiMoteEmu::WiiMapping[i].Stick.GH, WiiMoteEmu::FROM_KEYBOARD);
// ButtonMapping
for (int x = 0; x < WiiMoteEmu::LAST_CONSTANT; x++)
iniFile.Get(SectionName, wmControlNames[x], &WiiMoteEmu::WiiMapping[i].Button[x], wmDefaultControls[x]);
// This pad Id could possibly be higher than the number of pads that are connected,
// but we check later, when needed, that that is not the case
iniFile.Get(SectionName, "DeviceID", &WiiMoteEmu::WiiMapping[i].ID, 0);
iniFile.Get(SectionName, "Axis_Lx", &WiiMoteEmu::WiiMapping[i].AxisMapping.Lx, 0);
iniFile.Get(SectionName, "Axis_Ly", &WiiMoteEmu::WiiMapping[i].AxisMapping.Ly, 1);
iniFile.Get(SectionName, "Axis_Rx", &WiiMoteEmu::WiiMapping[i].AxisMapping.Rx, 2);
iniFile.Get(SectionName, "Axis_Ry", &WiiMoteEmu::WiiMapping[i].AxisMapping.Ry, 3);
iniFile.Get(SectionName, "Trigger_L", &WiiMoteEmu::WiiMapping[i].AxisMapping.Tl, 1004);
iniFile.Get(SectionName, "Trigger_R", &WiiMoteEmu::WiiMapping[i].AxisMapping.Tr, 1005);
iniFile.Get(SectionName, "DeadZoneL", &WiiMoteEmu::WiiMapping[i].DeadZoneL, 0);
iniFile.Get(SectionName, "DeadZoneR", &WiiMoteEmu::WiiMapping[i].DeadZoneR, 0);
iniFile.Get(SectionName, "Diagonal", &WiiMoteEmu::WiiMapping[i].Diagonal, 100);
iniFile.Get(SectionName, "Circle2Square", &WiiMoteEmu::WiiMapping[i].bCircle2Square, false);
iniFile.Get(SectionName, "Rumble", &WiiMoteEmu::WiiMapping[i].Rumble, false);
iniFile.Get(SectionName, "RumbleStrength", &WiiMoteEmu::WiiMapping[i].RumbleStrength, 80);
iniFile.Get(SectionName, "TriggerType", &WiiMoteEmu::WiiMapping[i].TriggerType, 0);
//UDPWii
iniFile.Get(SectionName, "UDPWii_Enable", &WiiMoteEmu::WiiMapping[i].UDPWM.enable, false);
std::string port;
char default_port[15];
sprintf(default_port,"%d",4432+i);
iniFile.Get(SectionName, "UDPWii_Port", &port, default_port);
strncpy(WiiMoteEmu::WiiMapping[i].UDPWM.port,port.c_str(),10);
iniFile.Get(SectionName, "UDPWii_EnableAccel", &WiiMoteEmu::WiiMapping[i].UDPWM.enableAccel, true);
iniFile.Get(SectionName, "UDPWii_EnableButtons", &WiiMoteEmu::WiiMapping[i].UDPWM.enableButtons, true);
iniFile.Get(SectionName, "UDPWii_EnableIR", &WiiMoteEmu::WiiMapping[i].UDPWM.enableIR, true);
iniFile.Get(SectionName, "UDPWii_EnableNunchuck", &WiiMoteEmu::WiiMapping[i].UDPWM.enableNunchuck, true);
}
iniFile.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "Dolphin.ini").c_str());
for (int i = 0; i < MAX_WIIMOTES; i++)
{
char SectionName[32];
sprintf(SectionName, "Wiimote%i", i + 1);
iniFile.Get(SectionName, "AutoReconnectRealWiimote", &WiiMoteEmu::WiiMapping[i].bWiiAutoReconnect, false);
}
Config::LoadIR();
// Load a few screen settings to. If these are added to the DirectX plugin it's probably
// better to place them in the main Dolphin.ini file
iniFile.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_opengl.ini").c_str());
iniFile.Get("Settings", "KeepAR_4_3", &bKeepAR43, false);
iniFile.Get("Settings", "KeepAR_16_9", &bKeepAR169, false);
iniFile.Get("Settings", "Crop", &bCrop, false);
//DEBUG_LOG(WIIMOTE, "Load()");
}
void Config::LoadIR()
{
// Load the IR cursor settings if it's avaliable for the GameId, if not load the default settings
IniFile iniFile;
char TmpSection[32];
int defaultLeft, defaultTop, defaultWidth, defaultHeight;
sprintf(TmpSection, "%s", g_ISOId ? Hex2Ascii(g_ISOId).c_str() : "Default");
iniFile.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "IrPointer.ini").c_str());
//Load defaults first...
iniFile.Get("Default", "IRLeft", &defaultLeft, LEFT);
iniFile.Get("Default", "IRTop", &defaultTop, TOP);
iniFile.Get("Default", "IRWidth", &defaultWidth, RIGHT - LEFT);
iniFile.Get("Default", "IRHeight", &defaultHeight, BOTTOM - TOP);
iniFile.Get("Default", "IRLevel", &iIRLevel, 3);
//...and fall back to them if the GameId is not found.
//It shouldn't matter if we read Default twice, its in memory anyways.
iniFile.Get(TmpSection, "IRLeft", &iIRLeft, defaultLeft);
iniFile.Get(TmpSection, "IRTop", &iIRTop, defaultTop);
iniFile.Get(TmpSection, "IRWidth", &iIRWidth, defaultWidth);
iniFile.Get(TmpSection, "IRHeight", &iIRHeight, defaultHeight);
}
void Config::Save()
{
IniFile iniFile;
iniFile.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "Wiimote.ini").c_str());
iniFile.Set("Real", "UpdateStatus", bUpdateRealWiimote);
iniFile.Set("Real", "Unpair", bUnpairRealWiimote);
iniFile.Set("Real", "Autopair", bPairRealWiimote);
iniFile.Set("Real", "Timeout", bWiiReadTimeout);
iniFile.Set("Real", "AccNeutralX", iAccNeutralX);
iniFile.Set("Real", "AccNeutralY", iAccNeutralY);
iniFile.Set("Real", "AccNeutralZ", iAccNeutralZ);
iniFile.Set("Real", "AccNunNeutralX", iAccNunNeutralX);
iniFile.Set("Real", "AccNunNeutralY", iAccNunNeutralY);
iniFile.Set("Real", "AccNunNeutralZ", iAccNunNeutralZ);
for (int i = 0; i < MAX_WIIMOTES; i++)
{
// Slot specific settings
char SectionName[32];
sprintf(SectionName, "Wiimote%i", i + 1);
iniFile.Set(SectionName, "Source", WiiMoteEmu::WiiMapping[i].Source);
iniFile.Set(SectionName, "Sideways", WiiMoteEmu::WiiMapping[i].bSideways);
iniFile.Set(SectionName, "Upright", WiiMoteEmu::WiiMapping[i].bUpright);
iniFile.Set(SectionName, "ExtensionConnected", WiiMoteEmu::WiiMapping[i].iExtensionConnected);
iniFile.Set(SectionName, "MotionPlusConnected", WiiMoteEmu::WiiMapping[i].bMotionPlusConnected);
iniFile.Set(SectionName, "TiltInputWM", WiiMoteEmu::WiiMapping[i].Tilt.InputWM);
iniFile.Set(SectionName, "TiltInputNC", WiiMoteEmu::WiiMapping[i].Tilt.InputNC);
iniFile.Set(SectionName, "TiltRollDegree", WiiMoteEmu::WiiMapping[i].Tilt.RollDegree);
iniFile.Set(SectionName, "TiltRollSwing", WiiMoteEmu::WiiMapping[i].Tilt.RollSwing);
iniFile.Set(SectionName, "TiltRollInvert", WiiMoteEmu::WiiMapping[i].Tilt.RollInvert);
iniFile.Set(SectionName, "TiltPitchDegree", WiiMoteEmu::WiiMapping[i].Tilt.PitchDegree);
iniFile.Set(SectionName, "TiltPitchSwing", WiiMoteEmu::WiiMapping[i].Tilt.PitchSwing);
iniFile.Set(SectionName, "TiltPitchInvert", WiiMoteEmu::WiiMapping[i].Tilt.PitchInvert);
// StickMapping
iniFile.Set(SectionName, "NCStick", WiiMoteEmu::WiiMapping[i].Stick.NC);
iniFile.Set(SectionName, "CCStickLeft", WiiMoteEmu::WiiMapping[i].Stick.CCL);
iniFile.Set(SectionName, "CCStickRight", WiiMoteEmu::WiiMapping[i].Stick.CCR);
iniFile.Set(SectionName, "CCTriggers", WiiMoteEmu::WiiMapping[i].Stick.CCT);
iniFile.Set(SectionName, "GHStick", WiiMoteEmu::WiiMapping[i].Stick.GH);
// ButtonMapping
for (int x = 0; x < WiiMoteEmu::LAST_CONSTANT; x++)
iniFile.Set(SectionName, wmControlNames[x], WiiMoteEmu::WiiMapping[i].Button[x]);
// Save the physical device ID number
iniFile.Set(SectionName, "DeviceID", WiiMoteEmu::WiiMapping[i].ID);
iniFile.Set(SectionName, "Axis_Lx", WiiMoteEmu::WiiMapping[i].AxisMapping.Lx);
iniFile.Set(SectionName, "Axis_Ly", WiiMoteEmu::WiiMapping[i].AxisMapping.Ly);
iniFile.Set(SectionName, "Axis_Rx", WiiMoteEmu::WiiMapping[i].AxisMapping.Rx);
iniFile.Set(SectionName, "Axis_Ry", WiiMoteEmu::WiiMapping[i].AxisMapping.Ry);
iniFile.Set(SectionName, "Trigger_L", WiiMoteEmu::WiiMapping[i].AxisMapping.Tl);
iniFile.Set(SectionName, "Trigger_R", WiiMoteEmu::WiiMapping[i].AxisMapping.Tr);
iniFile.Set(SectionName, "DeadZoneL", WiiMoteEmu::WiiMapping[i].DeadZoneL);
iniFile.Set(SectionName, "DeadZoneR", WiiMoteEmu::WiiMapping[i].DeadZoneR);
iniFile.Set(SectionName, "Diagonal", WiiMoteEmu::WiiMapping[i].Diagonal);
iniFile.Set(SectionName, "Circle2Square", WiiMoteEmu::WiiMapping[i].bCircle2Square);
iniFile.Set(SectionName, "Rumble", WiiMoteEmu::WiiMapping[i].Rumble);
iniFile.Set(SectionName, "RumbleStrength", WiiMoteEmu::WiiMapping[i].RumbleStrength);
iniFile.Set(SectionName, "TriggerType", WiiMoteEmu::WiiMapping[i].TriggerType);
// UDPWii
iniFile.Set(SectionName, "UDPWii_Enable", WiiMoteEmu::WiiMapping[i].UDPWM.enable);
iniFile.Set(SectionName, "UDPWii_Port", WiiMoteEmu::WiiMapping[i].UDPWM.port);
iniFile.Set(SectionName, "UDPWii_EnableAccel", WiiMoteEmu::WiiMapping[i].UDPWM.enableAccel);
iniFile.Set(SectionName, "UDPWii_EnableButtons", WiiMoteEmu::WiiMapping[i].UDPWM.enableButtons);
iniFile.Set(SectionName, "UDPWii_EnableIR", WiiMoteEmu::WiiMapping[i].UDPWM.enableIR);
iniFile.Set(SectionName, "UDPWii_EnableNunchuck", WiiMoteEmu::WiiMapping[i].UDPWM.enableNunchuck);
}
iniFile.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "Wiimote.ini").c_str());
// Save the IR cursor settings if it's avaliable for the GameId, if not save the default settings
iniFile.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "IrPointer.ini").c_str());
char TmpSection[32];
sprintf(TmpSection, "%s", g_ISOId ? Hex2Ascii(g_ISOId).c_str() : "Default");
iniFile.Set(TmpSection, "IRLeft", iIRLeft);
iniFile.Set(TmpSection, "IRTop", iIRTop);
iniFile.Set(TmpSection, "IRWidth", iIRWidth);
iniFile.Set(TmpSection, "IRHeight", iIRHeight);
iniFile.Set(TmpSection, "IRLevel", iIRLevel);
iniFile.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "IrPointer.ini").c_str());
//Save any options that need to be accessed in Dolphin
iniFile.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "Dolphin.ini").c_str());
for (int i = 0; i < MAX_WIIMOTES; i++)
{
char SectionName[32];
sprintf(SectionName, "Wiimote%i", i + 1);
iniFile.Set(SectionName, "AutoReconnectRealWiimote", WiiMoteEmu::WiiMapping[i].bWiiAutoReconnect);
}
iniFile.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "Dolphin.ini").c_str());
//DEBUG_LOG(WIIMOTE, "Save()");
}

View File

@ -1,48 +0,0 @@
// 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 _PLUGIN_WIIMOTE_CONFIG_H
#define _PLUGIN_WIIMOTE_CONFIG_H
#if defined(HAVE_X11) && HAVE_X11
#include <X11/keysym.h>
#endif
struct Config
{
Config();
void Load();
void LoadIR();
void Save();
// For dialog sync
int CurrentPage;
// Real Wiimote
bool bUpdateRealWiimote, bUnpairRealWiimote, bPairRealWiimote;
volatile int bNumberRealWiimotes;
int bNumberEmuWiimotes, bWiiReadTimeout;
int iIRLeft, iIRTop, iIRWidth, iIRHeight, iIRLevel;
int iAccNeutralX, iAccNeutralY, iAccNeutralZ;
int iAccNunNeutralX, iAccNunNeutralY, iAccNunNeutralZ;
// Screen size settings
bool bKeepAR43, bKeepAR169, bCrop;
};
extern Config g_Config;
#endif // _PLUGIN_WIIMOTE_CONFIG_H

View File

@ -1,659 +0,0 @@
// 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 "wiimote_real.h" // Local
#include "wiimote_hid.h"
#include "main.h"
#include "ConfigBasicDlg.h"
#include "ConfigPadDlg.h"
#include "Config.h"
#include "EmuMain.h" // for SetDefaultExtensionRegistry
#include "EmuSubroutines.h" // for WmRequestStatus
BEGIN_EVENT_TABLE(WiimoteBasicConfigDialog,wxDialog)
EVT_CLOSE(WiimoteBasicConfigDialog::OnClose)
EVT_BUTTON(wxID_OK, WiimoteBasicConfigDialog::ButtonClick)
EVT_BUTTON(wxID_CANCEL, WiimoteBasicConfigDialog::ButtonClick)
EVT_BUTTON(ID_BUTTONMAPPING, WiimoteBasicConfigDialog::ButtonClick)
EVT_BUTTON(ID_BUTTONRECORDING, WiimoteBasicConfigDialog::ButtonClick)
EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, WiimoteBasicConfigDialog::NotebookPageChanged)
EVT_BUTTON(IDB_PAIRUP_REAL, WiimoteBasicConfigDialog::ButtonClick)
EVT_BUTTON(IDB_REFRESH_REAL, WiimoteBasicConfigDialog::ButtonClick)
EVT_CHOICE(IDC_INPUT_SOURCE, WiimoteBasicConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_SIDEWAYSWIIMOTE, WiimoteBasicConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_UPRIGHTWIIMOTE, WiimoteBasicConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_MOTIONPLUSCONNECTED, WiimoteBasicConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_WIIAUTORECONNECT, WiimoteBasicConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_WIIAUTOUNPAIR, WiimoteBasicConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_WIIAUTOPAIR, WiimoteBasicConfigDialog::GeneralSettingsChanged)
EVT_CHOICE(IDC_EXTCONNECTED, WiimoteBasicConfigDialog::GeneralSettingsChanged)
//UDPWii
EVT_CHECKBOX(IDC_UDPWIIENABLE, WiimoteBasicConfigDialog::UDPWiiSettingsChanged)
EVT_CHECKBOX(IDC_UDPWIIACCEL, WiimoteBasicConfigDialog::UDPWiiSettingsChanged)
EVT_CHECKBOX(IDC_UDPWIIBUTT, WiimoteBasicConfigDialog::UDPWiiSettingsChanged)
EVT_CHECKBOX(IDC_UDPWIIIR, WiimoteBasicConfigDialog::UDPWiiSettingsChanged)
EVT_CHECKBOX(IDC_UDPWIINUN, WiimoteBasicConfigDialog::UDPWiiSettingsChanged)
EVT_TEXT(IDT_UDPWIIPORT, WiimoteBasicConfigDialog::UDPWiiSettingsChanged)
// IR cursor
EVT_COMMAND_SCROLL(IDS_WIDTH, WiimoteBasicConfigDialog::IRCursorChanged)
EVT_COMMAND_SCROLL(IDS_HEIGHT, WiimoteBasicConfigDialog::IRCursorChanged)
EVT_COMMAND_SCROLL(IDS_LEFT, WiimoteBasicConfigDialog::IRCursorChanged)
EVT_COMMAND_SCROLL(IDS_TOP, WiimoteBasicConfigDialog::IRCursorChanged)
EVT_COMMAND_SCROLL(IDS_LEVEL, WiimoteBasicConfigDialog::IRCursorChanged)
EVT_COMMAND_SCROLL(IDS_TIMEOUT, WiimoteBasicConfigDialog::IRCursorChanged)//scrollevent
EVT_TIMER(IDTM_UPDATE_ONCE, WiimoteBasicConfigDialog::UpdateOnce)
END_EVENT_TABLE()
WiimoteBasicConfigDialog::WiimoteBasicConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
#if wxUSE_TIMER
m_TimeoutOnce = new wxTimer(this, IDTM_UPDATE_ONCE);
m_ShutDownTimer = new wxTimer(this, IDTM_SHUTDOWN);
#endif
ControlsCreated = false;
m_Page = 0;
#if defined HAVE_WIIUSE && HAVE_WIIUSE
// Initialize the Real WiiMotes here, so we get a count of how many were found and set everything properly
WiiMoteReal::Initialize();
#endif
CreateGUIControls();
UpdateGUI();
}
void WiimoteBasicConfigDialog::OnClose(wxCloseEvent& event)
{
EndModal(wxID_CLOSE);
}
void WiimoteBasicConfigDialog::ButtonClick(wxCommandEvent& event)
{
switch(event.GetId())
{
case wxID_OK:
#if defined HAVE_WIIUSE && HAVE_WIIUSE
WiiMoteReal::Allocate();
#endif
g_Config.Save();
Close();
break;
case wxID_CANCEL:
g_Config.Load();
Close();
break;
case ID_BUTTONMAPPING:
g_Config.CurrentPage = m_Page;
m_PadConfigFrame = new WiimotePadConfigDialog(this);
m_PadConfigFrame->ShowModal();
m_PadConfigFrame->Destroy();
m_PadConfigFrame = NULL;
m_Page = g_Config.CurrentPage;
m_Notebook->ChangeSelection(g_Config.CurrentPage);
UpdateGUI();
break;
#ifdef _WIN32
case IDB_PAIRUP_REAL:
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY)
{
WiiMoteReal::g_StartAutopairThread.Set();
}
break;
#endif
case IDB_REFRESH_REAL:
// If the config dialog was open when the user click on Play/Pause, the GUI was not updated, so this could crash everything!
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY)
{
DoRefreshReal();
}
UpdateGUI();
break;
}
}
void WiimoteBasicConfigDialog::CreateGUIControls()
{
wxArrayString arrayStringFor_source;
arrayStringFor_source.Add(wxT("Inactive"));
arrayStringFor_source.Add(wxT("Emulated Wiimote"));
arrayStringFor_source.Add(wxT("Real Wiimote"));
wxArrayString arrayStringFor_extension;
arrayStringFor_extension.Add(wxT("None"));
arrayStringFor_extension.Add(wxT("Nunchuck"));
arrayStringFor_extension.Add(wxT("Classic Controller"));
arrayStringFor_extension.Add(wxT("Guitar Hero 3 Guitar"));
m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize);
for (int i = 0; i < MAX_WIIMOTES; i++)
{
m_Controller[i] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE1 + i, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Controller[i], wxString::Format(wxT("Wiimote %d"), i+1));
// Basic Settings
m_InputSource[i] = new wxChoice(m_Controller[i], IDC_INPUT_SOURCE, wxDefaultPosition, wxDefaultSize, arrayStringFor_source, 0, wxDefaultValidator);
m_InputSource[i]->SetToolTip(wxT("This can only be changed when the emulator is paused or stopped."));
// Emulated Wiimote
m_SidewaysWiimote[i] = new wxCheckBox(m_Controller[i], IDC_SIDEWAYSWIIMOTE, wxT("Sideways Wiimote"));
m_SidewaysWiimote[i]->SetToolTip(wxT("Treat the sideways position as neutral"));
m_UprightWiimote[i] = new wxCheckBox(m_Controller[i], IDC_UPRIGHTWIIMOTE, wxT("Upright Wiimote"));
m_UprightWiimote[i]->SetToolTip(wxT("Treat the upright position as neutral"));
m_WiiMotionPlusConnected[i] = new wxCheckBox(m_Controller[i], IDC_MOTIONPLUSCONNECTED, wxT("Wii Motion Plus Connected"));
m_Extension[i] = new wxChoice(m_Controller[i], IDC_EXTCONNECTED, wxDefaultPosition, wxDefaultSize, arrayStringFor_extension, 0, wxDefaultValidator);
// UDPWii
m_UDPWiiEnable[i] = new wxCheckBox(m_Controller[i], IDC_UDPWIIENABLE, wxT("Enable UDPWii"));
m_UDPWiiEnable[i]->SetToolTip(wxT("Enable listening for wiimote data on the network. Requires emulation restart"));
m_UDPWiiAccel[i] = new wxCheckBox(m_Controller[i], IDC_UDPWIIACCEL, wxT("Update acceleration from UDPWii"));
m_UDPWiiAccel[i]->SetToolTip(wxT("Retrieve acceleration data from a device on the network"));
m_UDPWiiButt[i] = new wxCheckBox(m_Controller[i], IDC_UDPWIIBUTT, wxT("Update buttons from UDPWii"));
m_UDPWiiButt[i]->SetToolTip(wxT("Retrieve button data from a device on the network. This doesn't affect keyboard mappings"));
m_UDPWiiIR[i] = new wxCheckBox(m_Controller[i], IDC_UDPWIIIR, wxT("Update IR pointer from UDPWii"));
m_UDPWiiIR[i]->SetToolTip(wxT("Retrieve IR pointer from a device on the network. Disables using mouse as pointer"));
m_UDPWiiNun[i] = new wxCheckBox(m_Controller[i], IDC_UDPWIINUN, wxT("Update nunchuck from UDPWii"));
m_UDPWiiNun[i]->SetToolTip(wxT("Retrieve nunchuck data from a device on the network."));
m_UDPWiiPort[i] = new wxTextCtrl(m_Controller[i], IDT_UDPWIIPORT);
m_UDPWiiPort[i]->SetMaxLength(9);
m_TextUDPWiiPort[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("UDP Port:"));
m_TextUDPWiiPort[i]->SetToolTip(wxT("The UDP port on witch UDPWii listens for this remote."));
#ifdef _WIN32
m_PairUpRealWiimote[i] = new wxButton(m_Controller[i], IDB_PAIRUP_REAL, wxT("Pair Up"));
m_PairUpRealWiimote[i]->SetToolTip(wxT("Press the Buttons 1 and 2 on your Wiimote.\nThis might take a few seconds.\nIt only works if you are using Microsoft Bluetooth stack.")); // Only working with MS BT Stack.
#endif
m_TextFoundRealWiimote[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Connected to 0 Real Wiimotes"));
m_ConnectRealWiimote[i] = new wxButton(m_Controller[i], IDB_REFRESH_REAL, wxT("Refresh"));
m_ConnectRealWiimote[i]->SetToolTip(wxT("This can only be done when the emulator is paused or stopped."));
m_TextWiimoteTimeout[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Timeout: 000 ms"));
m_WiimoteTimeout[i] = new wxSlider(m_Controller[i], IDS_TIMEOUT, 0, 10, 200, wxDefaultPosition, wxSize(75, -1));
m_WiimoteTimeout[i]->SetToolTip(wxT("General Real Wiimote Read Timeout, Default: 30 (ms). Higher values eliminate frequent disconnects and packet loss."));
#ifdef _WIN32
//Real Wiimote / automatic settings
m_WiiAutoReconnect[i] = new wxCheckBox(m_Controller[i], IDC_WIIAUTORECONNECT, wxT("Reconnect Wiimote on disconnect"));
m_WiiAutoReconnect[i]->SetToolTip(wxT("This makes dolphin automatically reconnect a wiimote when it has being disconnected.\nThis will cause problems when 2 controllers are connected for a 1 player game."));
m_WiiAutoUnpair[i] = new wxCheckBox(m_Controller[i], IDC_WIIAUTOUNPAIR, wxT("Unpair Wiimote on close"));
m_WiiAutoUnpair[i]->SetToolTip(wxT("This makes dolphin automatically unpair a wiimote when dolphin is about to be closed."));
m_WiiExtendedPairUp[i] = new wxCheckBox(m_Controller[i], IDC_WIIAUTOPAIR, wxT("Extended PairUp/Connect"));
m_WiiExtendedPairUp[i]->SetToolTip(wxT("This makes dolphin automatically pair up and connect Wiimotes on pressing 1+2 on your Wiimote."));
#endif
//IR Pointer
m_TextScreenWidth[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Width: 000"));
m_TextScreenHeight[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Height: 000"));
m_TextScreenLeft[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Left: 000"));
m_TextScreenTop[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Top: 000"));
m_TextScreenIrLevel[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Sensivity: 000"));
m_SliderWidth[i] = new wxSlider(m_Controller[i], IDS_WIDTH, 0, 100, 923, wxDefaultPosition, wxSize(75, -1));
m_SliderHeight[i] = new wxSlider(m_Controller[i], IDS_HEIGHT, 0, 0, 727, wxDefaultPosition, wxSize(75, -1));
m_SliderLeft[i] = new wxSlider(m_Controller[i], IDS_LEFT, 0, 100, 500, wxDefaultPosition, wxSize(75, -1));
m_SliderTop[i] = new wxSlider(m_Controller[i], IDS_TOP, 0, 0, 500, wxDefaultPosition, wxSize(75, -1));
m_SliderIrLevel[i] = new wxSlider(m_Controller[i], IDS_LEVEL, 0, 1, 5, wxDefaultPosition, wxSize(75, -1));
// These are changed from the graphics plugin settings, so they are just here to show the loaded status
m_TextAR[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Aspect Ratio"));
m_CheckAR43[i] = new wxCheckBox(m_Controller[i], wxID_ANY, wxT("4:3"), wxDefaultPosition, wxSize(-1, -1), 0, wxDefaultValidator);
m_CheckAR43[i]->Enable(false);
m_CheckAR169[i] = new wxCheckBox(m_Controller[i], wxID_ANY, wxT("16:9"), wxDefaultPosition, wxSize(-1, -1), 0, wxDefaultValidator);
m_CheckAR169[i]->Enable(false);
m_Crop[i] = new wxCheckBox(m_Controller[i], wxID_ANY, wxT("Crop"), wxDefaultPosition, wxSize(-1, -1), 0, wxDefaultValidator);
m_Crop[i]->Enable(false);
// Sizers
m_SizeBasic[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Input Source"));
m_SizeBasic[i]->Add(m_InputSource[i], 0, wxEXPAND | wxALL, 5);
m_SizeEmu[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Emulated Position"));
m_SizeEmu[i]->Add(m_SidewaysWiimote[i], 0, wxEXPAND | wxALL, 5);
m_SizeEmu[i]->Add(m_UprightWiimote[i], 0, wxEXPAND | (wxLEFT | wxDOWN | wxRIGHT), 5);
m_SizeExtensions[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Emulated Extension"));
m_SizeExtensions[i]->Add(m_WiiMotionPlusConnected[i], 0, wxEXPAND | wxALL, 5);
m_SizeExtensions[i]->Add(m_Extension[i], 0, wxEXPAND | wxALL, 5);
m_SizeUDPWii[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Emulated UDPWii"));
m_SizeUDPWii[i]->Add(m_UDPWiiEnable[i], 0, wxEXPAND | wxALL,1);
m_SizeUDPWiiPort[i]= new wxBoxSizer(wxHORIZONTAL);
m_SizeUDPWiiPort[i]->Add(m_TextUDPWiiPort[i], 0, wxEXPAND | wxALL,1);
m_SizeUDPWiiPort[i]->Add(m_UDPWiiPort[i], 0, wxEXPAND | wxALL,1);
m_SizeUDPWii[i]->Add(m_SizeUDPWiiPort[i], 0, wxEXPAND | wxALL,1);
m_SizeUDPWii[i]->Add(m_UDPWiiAccel[i], 0, wxEXPAND | wxALL,1);
m_SizeUDPWii[i]->Add(m_UDPWiiButt[i], 0, wxEXPAND | wxALL,1);
m_SizeUDPWii[i]->Add(m_UDPWiiIR[i], 0, wxEXPAND | wxALL,1);
m_SizeUDPWii[i]->Add(m_UDPWiiNun[i], 0, wxEXPAND | wxALL,1);
#ifdef _WIN32
m_SizeRealAuto[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Automatic"));
m_SizeRealAuto[i]->Add(m_WiiAutoReconnect[i], 0, wxEXPAND | (wxDOWN | wxTOP), 5);
m_SizeRealAuto[i]->Add(m_WiiAutoUnpair[i], 0, wxEXPAND | (wxDOWN | wxTOP), 5);
m_SizeRealAuto[i]->Add(m_WiiExtendedPairUp[i], 0, wxEXPAND | (wxDOWN | wxTOP), 5);
#endif
m_SizeRealTimeout[i] = new wxBoxSizer(wxHORIZONTAL);
m_SizeRealTimeout[i]->Add(m_TextWiimoteTimeout[i], 0, wxEXPAND | (wxTOP), 3);
m_SizeRealTimeout[i]->Add(m_WiimoteTimeout[i], 0, wxEXPAND | (wxRIGHT), 0);
m_SizeRealRefreshPair[i] = new wxBoxSizer(wxHORIZONTAL);
#ifdef _WIN32
m_SizeRealRefreshPair[i]->Add(m_PairUpRealWiimote[i], 0, wxEXPAND | wxALL, 5);
#endif
m_SizeRealRefreshPair[i]->Add(m_ConnectRealWiimote[i], 0, wxEXPAND | wxALL, 5);
m_SizeReal[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Real Wiimote"));
m_SizeReal[i]->Add(m_TextFoundRealWiimote[i], 0, wxALIGN_CENTER | wxALL, 5);
m_SizeReal[i]->Add(m_SizeRealRefreshPair[i], 0, wxALIGN_CENTER | (wxLEFT | wxDOWN | wxRIGHT), 5);
#ifdef _WIN32
m_SizeReal[i]->Add(m_SizeRealAuto[i], 0, wxEXPAND | wxALL, 5);
#endif
m_SizeReal[i]->Add(m_SizeRealTimeout[i], 0, wxEXPAND | (wxLEFT | wxDOWN | wxRIGHT), 5);
m_SizerIRPointerWidth[i] = new wxBoxSizer(wxHORIZONTAL);
m_SizerIRPointerWidth[i]->Add(m_TextScreenLeft[i], 0, wxEXPAND | (wxTOP), 3);
m_SizerIRPointerWidth[i]->Add(m_SliderLeft[i], 0, wxEXPAND | (wxRIGHT), 0);
m_SizerIRPointerWidth[i]->Add(m_TextScreenWidth[i], 0, wxEXPAND | (wxTOP), 3);
m_SizerIRPointerWidth[i]->Add(m_SliderWidth[i], 0, wxEXPAND | (wxLEFT), 0);
m_SizerIRPointerHeight[i] = new wxBoxSizer(wxHORIZONTAL);
m_SizerIRPointerHeight[i]->Add(m_TextScreenTop[i], 0, wxEXPAND | (wxTOP), 3);
m_SizerIRPointerHeight[i]->Add(m_SliderTop[i], 0, wxEXPAND | (wxRIGHT), 0);
m_SizerIRPointerHeight[i]->Add(m_TextScreenHeight[i], 0, wxEXPAND | (wxTOP), 3);
m_SizerIRPointerHeight[i]->Add(m_SliderHeight[i], 0, wxEXPAND | (wxLEFT), 0);
m_SizerIRPointerScreen[i] = new wxBoxSizer(wxHORIZONTAL);
m_SizerIRPointerScreen[i]->Add(m_TextAR[i], 0, wxEXPAND | (wxTOP), 0);
m_SizerIRPointerScreen[i]->Add(m_CheckAR43[i], 0, wxEXPAND | (wxLEFT), 5);
m_SizerIRPointerScreen[i]->Add(m_CheckAR169[i], 0, wxEXPAND | (wxLEFT), 5);
m_SizerIRPointerScreen[i]->Add(m_Crop[i], 0, wxEXPAND | (wxLEFT), 5);
m_SizerIRPointerSensitivity[i] = new wxBoxSizer(wxHORIZONTAL);
m_SizerIRPointerSensitivity[i]->Add(m_TextScreenIrLevel[i], 0, wxEXPAND | (wxTOP), 3);
m_SizerIRPointerSensitivity[i]->Add(m_SliderIrLevel[i], 0, wxEXPAND | (wxRIGHT), 0);
m_SizerIRPointer[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("IR Pointer"));
m_SizerIRPointer[i]->Add(m_SizerIRPointerWidth[i], 0, wxEXPAND | (wxLEFT | wxDOWN | wxRIGHT), 5);
m_SizerIRPointer[i]->Add(m_SizerIRPointerHeight[i], 0, wxEXPAND | (wxLEFT | wxDOWN | wxRIGHT), 5);
m_SizerIRPointer[i]->Add(m_SizerIRPointerSensitivity[i], 0, wxEXPAND | (wxLEFT | wxDOWN | wxRIGHT), 5);
m_SizerIRPointer[i]->Add(m_SizerIRPointerScreen[i], 0, wxALIGN_CENTER | (wxUP | wxDOWN), 10);
m_SizeBasicGeneralLeft[i] = new wxBoxSizer(wxVERTICAL);
m_SizeBasicGeneralLeft[i]->Add(m_SizeBasic[i], 0, wxEXPAND | (wxUP), 5);
m_SizeBasicGeneralLeft[i]->Add(m_SizeEmu[i], 0, wxEXPAND | (wxUP), 5);
m_SizeBasicGeneralLeft[i]->Add(m_SizeExtensions[i], 0, wxEXPAND | (wxUP), 5);
m_SizeBasicGeneralLeft[i]->Add(m_SizeUDPWii[i], 0, wxEXPAND | (wxUP), 5);
m_SizeBasicGeneralRight[i] = new wxBoxSizer(wxVERTICAL);
m_SizeBasicGeneralRight[i]->Add(m_SizeReal[i], 0, wxEXPAND | (wxUP), 5);
m_SizeBasicGeneralRight[i]->Add(m_SizerIRPointer[i], 0, wxEXPAND | (wxUP), 5);
m_SizeBasicGeneral[i] = new wxBoxSizer(wxHORIZONTAL);
m_SizeBasicGeneral[i]->Add(m_SizeBasicGeneralLeft[i], 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5);
m_SizeBasicGeneral[i]->Add(m_SizeBasicGeneralRight[i], 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5);
// Set the main sizer
m_Controller[i]->SetSizer(m_SizeBasicGeneral[i]);
}
m_ButtonMapping = new wxButton(this, ID_BUTTONMAPPING, wxT("Button Mapping"));
m_OK = new wxButton(this, wxID_OK, wxT("OK"));
m_OK->SetToolTip(wxT("Save changes and close"));
m_Cancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"));
m_Cancel->SetToolTip(wxT("Discard changes and close"));
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
sButtons->Add(m_ButtonMapping, 0, (wxALL), 0);
sButtons->AddStretchSpacer();
sButtons->Add(m_OK, 0, (wxALL), 0);
sButtons->Add(m_Cancel, 0, (wxLEFT), 5);
m_MainSizer = new wxBoxSizer(wxVERTICAL);
m_MainSizer->Add(m_Notebook, 1, wxEXPAND | wxALL, 5);
m_MainSizer->Add(sButtons, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5);
SetSizer(m_MainSizer);
Layout();
Fit();
// Center the window if there is room for it
#ifdef _WIN32
if (GetSystemMetrics(SM_CYFULLSCREEN) > 600)
Center();
#endif
ControlsCreated = true;
}
// Execute a delayed function
void WiimoteBasicConfigDialog::UpdateOnce(wxTimerEvent& event)
{
switch(event.GetId())
{
case IDTM_UPDATE_ONCE:
// Reenable the checkbox
SetCursor(wxCursor(wxCURSOR_ARROW));
UpdateGUI();
break;
}
}
#if HAVE_WIIUSE
void WiimoteBasicConfigDialog::DoRefreshReal()
{
WiiMoteReal::Shutdown();
WiiMoteReal::Initialize();
}
void WiimoteBasicConfigDialog::UpdateBasicConfigDialog(bool state) {
#ifdef _WIN32
if (m_BasicConfigFrame != NULL) {
if (state) {
m_PairUpRealWiimote[m_Page]->Enable(true);
m_BasicConfigFrame->UpdateGUI();
}
else
m_PairUpRealWiimote[m_Page]->Enable(false);
}
#endif
}
void WiimoteBasicConfigDialog::DoUseReal()
{
if (!g_RealWiiMotePresent)
return;
// Clear any eventual events in the Wiimote queue
WiiMoteReal::ClearEvents();
// Are we using an extension now? The report that it's removed, then reconnected.
bool UsingExtension = false;
if ((WiiMoteEmu::WiiMapping[m_Page].iExtensionConnected != WiiMoteEmu::EXT_NONE) || ( WiiMoteEmu::WiiMapping[m_Page].bMotionPlusConnected))
UsingExtension = true;
DEBUG_LOG(WIIMOTE, "DoUseReal() Connect extension: %i", !UsingExtension);
DoExtensionConnectedDisconnected(UsingExtension ? 0 : 1);
UsingExtension = !UsingExtension;
DEBUG_LOG(WIIMOTE, "DoUseReal() Connect extension: %i", !UsingExtension);
DoExtensionConnectedDisconnected(UsingExtension ? 1 : 0);
if (g_EmulatorState == PLUGIN_EMUSTATE_PLAY)
{
// Disable the checkbox for a moment
SetCursor(wxCursor(wxCURSOR_WAIT));
// We may not need this if there is already a message queue that allows the nessesary timeout
//sleep(100);
/* Start the timer to allow the approximate time it takes for the Wiimote to come online
it would simpler to use sleep(1000) but that doesn't work because we need the functions in main.cpp
to work */
m_TimeoutOnce->Start(1000, true);
}
}
#endif
// Generate connect/disconnect status event
void WiimoteBasicConfigDialog::DoExtensionConnectedDisconnected(int Extension)
{
// There is no need for this if no game is running
if (!g_EmulatorRunning || WiiMoteEmu::WiiMapping[m_Page].Source != 1)
return;
u8 DataFrame[8] = {0}; // make a blank report for it
wm_request_status *rs = (wm_request_status*)DataFrame;
// Check if a game is running, in that case change the status
if (WiiMoteEmu::g_ReportingChannel[m_Page] > 0)
{
WiiMoteEmu::g_ID = m_Page;
WiiMoteEmu::WmRequestStatus(WiiMoteEmu::g_ReportingChannel[m_Page], rs, Extension);
}
}
// Notebook page changed
void WiimoteBasicConfigDialog::NotebookPageChanged(wxNotebookEvent& event)
{
// Update the global variable
m_Page = event.GetSelection();
// Update GUI
if (ControlsCreated)
UpdateGUI();
}
void WiimoteBasicConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
{
switch (event.GetId())
{
case IDC_INPUT_SOURCE:
// If the config dialog was open when the user click on Play/Pause, the GUI was not updated, so this could crash everything!
if (g_EmulatorState == PLUGIN_EMUSTATE_PLAY)
{
PanicAlert("This can only be changed when the emulator is paused or stopped!");
WiiMoteEmu::WiiMapping[m_Page].Source = 0;
}
else
{
if (m_InputSource[m_Page]->GetSelection() == 2)
{
WiiMoteEmu::WiiMapping[m_Page].Source = 2;
DoUseReal();
}
else
WiiMoteEmu::WiiMapping[m_Page].Source = m_InputSource[m_Page]->GetSelection();
}
break;
case IDC_SIDEWAYSWIIMOTE:
WiiMoteEmu::WiiMapping[m_Page].bSideways = m_SidewaysWiimote[m_Page]->IsChecked();
break;
case IDC_UPRIGHTWIIMOTE:
WiiMoteEmu::WiiMapping[m_Page].bUpright = m_UprightWiimote[m_Page]->IsChecked();
break;
case IDC_MOTIONPLUSCONNECTED:
WiiMoteEmu::WiiMapping[m_Page].bMotionPlusConnected = m_WiiMotionPlusConnected[m_Page]->IsChecked();
DoExtensionConnectedDisconnected(WiiMoteEmu::EXT_NONE);
if (g_EmulatorRunning)
SLEEP(25);
WiiMoteEmu::UpdateExtRegisterBlocks(m_Page);
DoExtensionConnectedDisconnected();
break;
case IDC_WIIAUTORECONNECT:
WiiMoteEmu::WiiMapping[m_Page].bWiiAutoReconnect = m_WiiAutoReconnect[m_Page]->IsChecked();
break;
case IDC_WIIAUTOUNPAIR:
g_Config.bUnpairRealWiimote = m_WiiAutoUnpair[m_Page]->IsChecked();
break;
#ifdef _WIN32
case IDC_WIIAUTOPAIR:
if (m_WiiExtendedPairUp[m_Page]->IsChecked())
WiiMoteReal::g_StartAutopairThread.Set();
g_Config.bPairRealWiimote = m_WiiExtendedPairUp[m_Page]->IsChecked();
break;
#endif
case IDC_EXTCONNECTED:
// Disconnect the extension so that the game recognize the change
DoExtensionConnectedDisconnected(WiiMoteEmu::EXT_NONE);
// It doesn't seem to be needed but shouldn't it at least take 25 ms to
// reconnect an extension after we disconnected another?
if (g_EmulatorRunning)
SLEEP(25);
// Update status
WiiMoteEmu::WiiMapping[m_Page].iExtensionConnected = m_Extension[m_Page]->GetSelection();
// Copy the calibration data
WiiMoteEmu::UpdateExtRegisterBlocks(m_Page);
// Generate connect/disconnect status event
DoExtensionConnectedDisconnected();
break;
}
UpdateGUI();
}
void WiimoteBasicConfigDialog::IRCursorChanged(wxScrollEvent& event)
{
switch (event.GetId())
{
case IDS_WIDTH:
g_Config.iIRWidth = m_SliderWidth[m_Page]->GetValue();
break;
case IDS_HEIGHT:
g_Config.iIRHeight = m_SliderHeight[m_Page]->GetValue();
break;
case IDS_LEFT:
g_Config.iIRLeft = m_SliderLeft[m_Page]->GetValue();
break;
case IDS_TOP:
g_Config.iIRTop = m_SliderTop[m_Page]->GetValue();
break;
case IDS_LEVEL:
g_Config.iIRLevel = m_SliderIrLevel[m_Page]->GetValue();
if (g_RealWiiMotePresent) {
for (int i = 0; i < WiiMoteReal::g_NumberOfWiiMotes; i++)
wiiuse_set_ir_sensitivity(WiiMoteReal::g_WiiMotesFromWiiUse[i], g_Config.iIRLevel);
}
break;
case IDS_TIMEOUT:
g_Config.bWiiReadTimeout = m_WiimoteTimeout[m_Page]->GetValue();
if (g_RealWiiMotePresent) {
wiiuse_set_timeout(WiiMoteReal::g_WiiMotesFromWiiUse, WiiMoteReal::g_NumberOfWiiMotes, g_Config.bWiiReadTimeout);
}
break;
}
UpdateGUI();
}
void WiimoteBasicConfigDialog::UDPWiiSettingsChanged(wxCommandEvent &event)
{
switch(event.GetId())
{
case IDC_UDPWIIENABLE:
WiiMoteEmu::WiiMapping[m_Page].UDPWM.enable=m_UDPWiiEnable[m_Page]->GetValue();
break;
case IDC_UDPWIIACCEL:
WiiMoteEmu::WiiMapping[m_Page].UDPWM.enableAccel=m_UDPWiiAccel[m_Page]->GetValue();
break;
case IDC_UDPWIIIR:
WiiMoteEmu::WiiMapping[m_Page].UDPWM.enableIR=m_UDPWiiIR[m_Page]->GetValue();
break;
case IDC_UDPWIIBUTT:
WiiMoteEmu::WiiMapping[m_Page].UDPWM.enableButtons=m_UDPWiiButt[m_Page]->GetValue();
break;
case IDC_UDPWIINUN:
WiiMoteEmu::WiiMapping[m_Page].UDPWM.enableNunchuck=m_UDPWiiNun[m_Page]->GetValue();
break;
case IDT_UDPWIIPORT:
strncpy(WiiMoteEmu::WiiMapping[m_Page].UDPWM.port,(const char*)(m_UDPWiiPort[m_Page]->GetValue().mb_str(wxConvUTF8)),10);
break;
}
UpdateGUI();
}
void WiimoteBasicConfigDialog::UpdateGUI()
{
/* I have disabled this option during a running game because it's enough to be able to switch
between using and not using then. To also use the connect option during a running game would
mean that the wiimote must be sent the current reporting mode and the channel ID after it
has been initialized. Functions for that are basically already in place so these two options
could possibly be simplified to one option. */
#ifdef _WIN32
m_PairUpRealWiimote[m_Page]->Enable(g_EmulatorState != PLUGIN_EMUSTATE_PLAY);
#endif
m_TextFoundRealWiimote[m_Page]->SetLabel(wxString::Format(wxT("Connected to %i Real Wiimotes"), WiiMoteReal::g_NumberOfWiiMotes));
m_ConnectRealWiimote[m_Page]->Enable(g_EmulatorState != PLUGIN_EMUSTATE_PLAY);
m_InputSource[m_Page]->SetSelection(WiiMoteEmu::WiiMapping[m_Page].Source);
m_InputSource[m_Page]->Enable(g_EmulatorState != PLUGIN_EMUSTATE_PLAY);
if (WiiMoteEmu::WiiMapping[m_Page].Source == 2)
{
m_Extension[m_Page]->Enable(false);
m_WiiMotionPlusConnected[m_Page]->Enable(false);
m_SidewaysWiimote[m_Page]->Enable(false);
m_UprightWiimote[m_Page]->Enable(false);
m_WiimoteTimeout[m_Page]->Enable(true);
m_SliderIrLevel[m_Page]->Enable(true);
}
else
{
m_Extension[m_Page]->Enable(true);
m_WiiMotionPlusConnected[m_Page]->Enable(true);
m_SidewaysWiimote[m_Page]->Enable(true);
m_UprightWiimote[m_Page]->Enable(true);
m_WiimoteTimeout[m_Page]->Enable(false);
m_SliderIrLevel[m_Page]->Enable(false);
}
//General settings
m_Extension[m_Page]->SetSelection(WiiMoteEmu::WiiMapping[m_Page].iExtensionConnected);
m_SidewaysWiimote[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].bSideways);
m_UprightWiimote[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].bUpright);
m_WiiMotionPlusConnected[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].bMotionPlusConnected);
//Real Wiimote related settings
#ifdef _WIN32
//Automatic settings
m_WiiAutoReconnect[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].bWiiAutoReconnect);
m_WiiAutoUnpair[m_Page]->SetValue(g_Config.bUnpairRealWiimote);
m_WiiExtendedPairUp[m_Page]->SetValue(g_Config.bPairRealWiimote);
#endif
m_TextWiimoteTimeout[m_Page]->SetLabel(wxString::Format(wxT("Timeout: %i ms"), g_Config.bWiiReadTimeout));
m_WiimoteTimeout[m_Page]->SetValue(g_Config.bWiiReadTimeout);
// Update the Wiimote IR pointer calibration
m_TextScreenWidth[m_Page]->SetLabel(wxString::Format(wxT("Width: %i"), g_Config.iIRWidth));
m_TextScreenHeight[m_Page]->SetLabel(wxString::Format(wxT("Height: %i"), g_Config.iIRHeight));
m_TextScreenLeft[m_Page]->SetLabel(wxString::Format(wxT("Left: %i"), g_Config.iIRLeft));
m_TextScreenTop[m_Page]->SetLabel(wxString::Format(wxT("Top: %i"), g_Config.iIRTop));
m_TextScreenIrLevel[m_Page]->SetLabel(wxString::Format(wxT("Sensitivity: %i"), g_Config.iIRLevel));
// Update the slider position if a configuration has been loaded
m_SliderWidth[m_Page]->SetValue(g_Config.iIRWidth);
m_SliderHeight[m_Page]->SetValue(g_Config.iIRHeight);
m_SliderLeft[m_Page]->SetValue(g_Config.iIRLeft);
m_SliderTop[m_Page]->SetValue(g_Config.iIRTop);
m_SliderIrLevel[m_Page]->SetValue(g_Config.iIRLevel);
m_CheckAR43[m_Page]->SetValue(g_Config.bKeepAR43);
m_CheckAR169[m_Page]->SetValue(g_Config.bKeepAR169);
m_Crop[m_Page]->SetValue(g_Config.bCrop);
//Update UDPWii
m_UDPWiiEnable[m_Page]->Enable(g_EmulatorState != PLUGIN_EMUSTATE_PLAY);
m_UDPWiiPort[m_Page]->Enable(g_EmulatorState != PLUGIN_EMUSTATE_PLAY);
m_UDPWiiEnable[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].UDPWM.enable);
m_UDPWiiAccel[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].UDPWM.enableAccel);
m_UDPWiiButt[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].UDPWM.enableButtons);
m_UDPWiiIR[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].UDPWM.enableIR);
m_UDPWiiNun[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].UDPWM.enableNunchuck);
m_UDPWiiPort[m_Page]->ChangeValue(wxString::FromAscii(WiiMoteEmu::WiiMapping[m_Page].UDPWM.port));
}

View File

@ -1,188 +0,0 @@
// 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 __BASICCONFIGDIALOG_h__
#define __BASICCONFIGDIALOG_h__
#include <iostream>
#include <vector>
#include <wx/wx.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/gbsizer.h>
#include "wiimote_hid.h"
class WiimoteBasicConfigDialog : public wxDialog
{
public:
WiimoteBasicConfigDialog(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString &title = wxT("Wii Remote Plugin Configuration"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS);
virtual ~WiimoteBasicConfigDialog(){;}
// General open, close and event functions
void UpdateGUI();
void UpdateBasicConfigDialog(bool state);
void ButtonClick(wxCommandEvent& event);
void ShutDown(wxTimerEvent& WXUNUSED(event));
void UpdateOnce(wxTimerEvent& event);
// Timers
wxTimer *m_TimeoutOnce,
*m_ShutDownTimer;
private:
DECLARE_EVENT_TABLE();
bool ControlsCreated;
int m_Page;
wxNotebook *m_Notebook;
wxPanel *m_Controller[MAX_WIIMOTES];
wxButton *m_OK,
*m_Cancel,
*m_ButtonMapping,
*m_Recording,
*m_PairUpRealWiimote[MAX_WIIMOTES],
*m_ConnectRealWiimote[MAX_WIIMOTES];
wxChoice *m_InputSource[MAX_WIIMOTES],
*m_Extension[MAX_WIIMOTES];
wxSlider *m_SliderWidth[MAX_WIIMOTES],
*m_SliderHeight[MAX_WIIMOTES],
*m_SliderLeft[MAX_WIIMOTES],
*m_SliderTop[MAX_WIIMOTES],
*m_WiimoteTimeout[MAX_WIIMOTES],
*m_SliderIrLevel[MAX_WIIMOTES];
wxCheckBox *m_SidewaysWiimote[MAX_WIIMOTES],
*m_UprightWiimote[MAX_WIIMOTES],
*m_WiiMotionPlusConnected[MAX_WIIMOTES],
*m_CheckAR43[MAX_WIIMOTES],
*m_CheckAR169[MAX_WIIMOTES],
*m_Crop[MAX_WIIMOTES],
*m_WiiAutoReconnect[MAX_WIIMOTES],
*m_WiiAutoUnpair[MAX_WIIMOTES],
*m_WiiExtendedPairUp[MAX_WIIMOTES],
*m_UDPWiiEnable[MAX_WIIMOTES],
*m_UDPWiiAccel[MAX_WIIMOTES],
*m_UDPWiiButt[MAX_WIIMOTES],
*m_UDPWiiIR[MAX_WIIMOTES],
*m_UDPWiiNun[MAX_WIIMOTES];
wxStaticText *m_TextWiimoteTimeout[MAX_WIIMOTES],
*m_TextScreenWidth[MAX_WIIMOTES],
*m_TextScreenHeight[MAX_WIIMOTES],
*m_TextScreenLeft[MAX_WIIMOTES],
*m_TextScreenTop[MAX_WIIMOTES],
*m_TextScreenIrLevel[MAX_WIIMOTES],
*m_TextAR[MAX_WIIMOTES],
*m_TextFoundRealWiimote[MAX_WIIMOTES],
*m_TextUDPWiiPort[MAX_WIIMOTES];
wxBoxSizer *m_MainSizer,
*m_SizeBasicGeneral[MAX_WIIMOTES],
*m_SizeBasicGeneralLeft[MAX_WIIMOTES],
*m_SizeBasicGeneralRight[MAX_WIIMOTES],
*m_SizeRealTimeout[MAX_WIIMOTES],
*m_SizeRealRefreshPair[MAX_WIIMOTES],
*m_SizerIRPointerWidth[MAX_WIIMOTES],
*m_SizerIRPointerHeight[MAX_WIIMOTES],
*m_SizerIRPointerScreen[MAX_WIIMOTES],
*m_SizerIRPointerSensitivity[MAX_WIIMOTES],
*m_SizeUDPWiiPort[MAX_WIIMOTES];
wxStaticBoxSizer *m_SizeBasic[MAX_WIIMOTES],
*m_SizeEmu[MAX_WIIMOTES],
*m_SizeReal[MAX_WIIMOTES],
*m_SizeRealAuto[MAX_WIIMOTES],
*m_SizeExtensions[MAX_WIIMOTES],
*m_SizerIRPointer[MAX_WIIMOTES],
*m_SizeUDPWii[MAX_WIIMOTES];
wxTextCtrl *m_UDPWiiPort[MAX_WIIMOTES];
enum
{
ID_BUTTONMAPPING,
ID_BUTTONRECORDING,
IDTM_SHUTDOWN,
IDTM_UPDATE,
IDTM_UPDATE_ONCE,
ID_NOTEBOOK,
ID_CONTROLLERPAGE1,
ID_CONTROLLERPAGE2,
ID_CONTROLLERPAGE3,
ID_CONTROLLERPAGE4,
// Emulated/Real Wiimote
IDC_INPUT_SOURCE,
IDC_SIDEWAYSWIIMOTE,
IDC_UPRIGHTWIIMOTE,
IDC_MOTIONPLUSCONNECTED,
IDC_WIIAUTORECONNECT,
IDC_WIIAUTOUNPAIR,
IDC_WIIAUTOPAIR,
IDC_EXTCONNECTED,
//UDPWii
IDC_UDPWIIENABLE,
IDC_UDPWIIACCEL,
IDC_UDPWIIBUTT,
IDC_UDPWIIIR,
IDC_UDPWIINUN,
IDT_UDPWIIPORT,
// Real
IDB_PAIRUP_REAL,
IDB_REFRESH_REAL,
IDS_WIDTH,
IDS_HEIGHT,
IDS_LEFT,
IDS_TOP,
IDS_LEVEL,
IDS_TIMEOUT,
};
void CreateGUIControls();
void OnClose(wxCloseEvent& event);
void NotebookPageChanged(wxNotebookEvent& event);
void GeneralSettingsChanged(wxCommandEvent& event);
void IRCursorChanged(wxScrollEvent& event);
void UDPWiiSettingsChanged(wxCommandEvent& event);
void DoRefreshReal(); // Real
void DoUseReal();
void DoExtensionConnectedDisconnected(int Extension = -1); // Emulated
};
extern WiimoteBasicConfigDialog *m_BasicConfigFrame;
#endif

View File

@ -1,347 +0,0 @@
// 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 "wiimote_hid.h"
#include "main.h"
#include "ConfigPadDlg.h"
#include "Config.h"
#include "EmuMain.h" // for WiiMoteEmu class
#include "EmuDefinitions.h"
#if defined(HAVE_X11) && HAVE_X11
#include "X11InputBase.h"
#endif
// Replace the harder to understand -1 with "" for the sake of user friendliness
void WiimotePadConfigDialog::ToBlank(bool toBlank, int Id)
{
if (!m_ControlsCreated)
return;
if(toBlank)
{
if (GetButtonText(Id) == wxString(wxT("-1")))
SetButtonText(Id, wxString());
}
else
{
if (GetButtonText(Id).IsEmpty())
SetButtonText(Id, wxString(wxT("-1")));
}
}
void WiimotePadConfigDialog::DoChangeDeadZone()
{
float Rad;
Rad = (float)WiiMoteEmu::WiiMapping[m_Page].DeadZoneL * ((float)BoxW / 100.0) * 0.5;
m_bmpDeadZoneLeftIn[m_Page]->SetBitmap(CreateBitmapClear());
m_bmpDeadZoneLeftIn[m_Page]->SetSize(0, 0);
m_bmpDeadZoneLeftIn[m_Page]->SetBitmap(CreateBitmapDeadZone((int)Rad));
m_bmpDeadZoneLeftIn[m_Page]->SetPosition(wxPoint(BoxW / 2 - (int)Rad, BoxH / 2 - (int)Rad));
m_bmpDeadZoneLeftIn[m_Page]->Refresh();
Rad = (float)WiiMoteEmu::WiiMapping[m_Page].DeadZoneR * ((float)BoxW / 100.0) * 0.5;
m_bmpDeadZoneRightIn[m_Page]->SetBitmap(CreateBitmapClear());
m_bmpDeadZoneRightIn[m_Page]->SetSize(0, 0);
m_bmpDeadZoneRightIn[m_Page]->SetBitmap(CreateBitmapDeadZone((int)Rad));
m_bmpDeadZoneRightIn[m_Page]->SetPosition(wxPoint(BoxW / 2 - (int)Rad, BoxH / 2 - (int)Rad));
m_bmpDeadZoneRightIn[m_Page]->Refresh();
}
// Set dialog items from saved values
// Update the textbox for the buttons
void WiimotePadConfigDialog::SetButtonText(int id, const wxString &str)
{
if (IDB_ANALOG_LEFT_X <= id && id <= IDB_TRIGGER_R)
m_Button_Analog[id - IDB_ANALOG_LEFT_X][m_Page]->SetLabel(str);
else if (IDB_WM_A <= id && id <= IDB_WM_SHAKE)
m_Button_Wiimote[id - IDB_WM_A][m_Page]->SetLabel(str);
else if (IDB_NC_Z <= id && id <= IDB_NC_SHAKE)
m_Button_NunChuck[id - IDB_NC_Z][m_Page]->SetLabel(str);
else if (IDB_CC_A <= id && id <= IDB_CC_RD)
m_Button_Classic[id - IDB_CC_A][m_Page]->SetLabel(str);
else if (IDB_GH3_GREEN <= id && id <= IDB_GH3_STRUM_DOWN)
m_Button_GH3[id - IDB_GH3_GREEN][m_Page]->SetLabel(str);
}
// Get the text in the textbox for the buttons
wxString WiimotePadConfigDialog::GetButtonText(int id)
{
if (IDB_ANALOG_LEFT_X <= id && id <= IDB_TRIGGER_R)
return m_Button_Analog[id - IDB_ANALOG_LEFT_X][m_Page]->GetLabel();
else if (IDB_WM_A <= id && id <= IDB_WM_SHAKE)
return m_Button_Wiimote[id - IDB_WM_A][m_Page]->GetLabel();
else if (IDB_NC_Z <= id && id <= IDB_NC_SHAKE)
return m_Button_NunChuck[id - IDB_NC_Z][m_Page]->GetLabel();
else if (IDB_CC_A <= id && id <= IDB_CC_RD)
return m_Button_Classic[id - IDB_CC_A][m_Page]->GetLabel();
else if (IDB_GH3_GREEN <= id && id <= IDB_GH3_STRUM_DOWN)
return m_Button_GH3[id - IDB_GH3_GREEN][m_Page]->GetLabel();
return wxString();
}
void WiimotePadConfigDialog::DoGetButtons(int _GetId)
{
// Collect the starting values
// Get the current controller
int PadID = WiiMoteEmu::WiiMapping[m_Page].ID;
// Get the controller and trigger type
int TriggerType = WiiMoteEmu::WiiMapping[m_Page].TriggerType;
// Collect the accepted buttons for this slot
bool LeftRight = (_GetId == IDB_TRIGGER_L || _GetId == IDB_TRIGGER_R);
bool Axis = (_GetId >= IDB_ANALOG_LEFT_X && _GetId <= IDB_TRIGGER_R)
// Don't allow SDL axis input for the shoulder buttons if XInput is selected
&& !(TriggerType == InputCommon::CTL_TRIGGER_XINPUT && (_GetId == IDB_TRIGGER_L || _GetId == IDB_TRIGGER_R) );
bool XInput = (TriggerType == InputCommon::CTL_TRIGGER_XINPUT);
bool Button = (_GetId >= IDB_WM_A && _GetId <= IDB_GH3_STRUM_DOWN);
bool Hat = (_GetId >= IDB_WM_A && _GetId <= IDB_GH3_STRUM_DOWN);
bool NoTriggerFilter = false;
// Values used in this function
int Seconds = 4; // Seconds to wait for
int TimesPerSecond = 40; // How often to run the check
// Values returned from InputCommon::GetButton()
int value; // Axis value or Hat value
int type; // Button type
int KeyPressed = 0;
int pressed = 0;
bool Succeed = false;
bool Stop = false; // Stop the timer
//DEBUG_LOG(WIIMOTE, "Before (%i) Id:%i %i IsRunning:%i",
// GetButtonWaitingTimer, GetButtonWaitingID, _GetId, m_ButtonMappingTimer->IsRunning());
// If the Id has changed or the timer is not running we should start one
if( GetButtonWaitingID != _GetId || !m_ButtonMappingTimer->IsRunning() )
{
if(m_ButtonMappingTimer->IsRunning())
m_ButtonMappingTimer->Stop();
// Save the button Id
GetButtonWaitingID = _GetId;
GetButtonWaitingTimer = 0;
// Start the timer
#if wxUSE_TIMER
m_ButtonMappingTimer->Start(1000 / TimesPerSecond);
#endif
DEBUG_LOG(WIIMOTE, "Timer Started: Pad:%i _GetId:%i "
"Allowed input is Axis:%i LeftRight:%i XInput:%i Button:%i Hat:%i",
WiiMoteEmu::WiiMapping[m_Page].ID, _GetId,
Axis, LeftRight, XInput, Button, Hat);
}
// Check for buttons
// If there is a timer we should not create a new one
else if (WiiMoteEmu::NumGoodPads > 0)
{
InputCommon::GetButton(
WiiMoteEmu::WiiMapping[m_Page].joy, PadID, WiiMoteEmu::joyinfo[PadID].NumButtons, WiiMoteEmu::joyinfo[PadID].NumAxes, WiiMoteEmu::joyinfo[PadID].NumHats,
KeyPressed, value, type, pressed, Succeed, Stop,
LeftRight, Axis, XInput, Button, Hat, NoTriggerFilter);
}
// Process results
// Count each time
GetButtonWaitingTimer++;
// This is run every second
if (GetButtonWaitingTimer % TimesPerSecond == 0)
{
// Current time
int TmpTime = Seconds - (GetButtonWaitingTimer / TimesPerSecond);
// Update text
SetButtonText(_GetId, wxString::Format(wxT("[ %d ]"), TmpTime));
}
// Time's up
if (GetButtonWaitingTimer / TimesPerSecond >= Seconds)
{
Stop = true;
// Revert back to old label
SetButtonText(_GetId, OldLabel);
}
// If we got a button
if(Succeed)
{
Stop = true;
// We need to assign hat special code
if (type == InputCommon::CTL_HAT)
{
// Index of pressed starts from 0
if (value & SDL_HAT_UP) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_UP;
else if (value & SDL_HAT_DOWN) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_DOWN;
else if (value & SDL_HAT_LEFT) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_LEFT;
else if (value & SDL_HAT_RIGHT) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_RIGHT;
else pressed = -1;
}
if (IDB_WM_A <= _GetId && _GetId <= IDB_GH3_STRUM_DOWN)
{
// Better make the pad button code far from virtual key code
SaveButtonMapping(_GetId, 0x1000 + pressed);
SetButtonText(_GetId, wxString::Format(wxT("PAD: %d"), pressed));
}
else if (IDB_ANALOG_LEFT_X <= _GetId && _GetId <= IDB_TRIGGER_R)
{
SaveButtonMapping(_GetId, pressed);
SetButtonText(_GetId, wxString::Format(wxT("%d"), pressed));
}
}
// Stop the timer
if(Stop)
{
DEBUG_LOG(WIIMOTE, "Timer Stopped for Pad:%i _GetId:%i",
WiiMoteEmu::WiiMapping[m_Page].ID, _GetId);
EndGetButtons();
}
// If we got a bad button
if(KeyPressed == -1)
{
// Update text
SetButtonText(_GetId, wxString(wxT("PAD: -1")));
// Notify the user
wxMessageBox(wxString::Format(
wxT("You selected a key with a to low key code (%i), please")
wxT(" select another key with a higher key code."), pressed)
, wxT("Notice"), wxICON_INFORMATION);
}
}
void WiimotePadConfigDialog::EndGetButtons(void)
{
wxTheApp->Disconnect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(WiimotePadConfigDialog::OnKeyDown),
(wxObject*)0, this);
m_ButtonMappingTimer->Stop();
GetButtonWaitingTimer = 0;
GetButtonWaitingID = 0;
ClickedButton = NULL;
}
// Convert the 0x8000 range values to BoxW and BoxH for the plot
void WiimotePadConfigDialog::Convert2Box(int &x)
{
// Border adjustment
int BoxW_ = BoxW - 2;
// Convert values
x = (BoxW_ / 2) + (x * BoxW_ / (32767 * 2));
}
// Update the input status boxes
void WiimotePadConfigDialog::UpdatePadInfo(wxTimerEvent& WXUNUSED(event))
{
//DEBUG_LOG(WIIMOTE, "SDL_WasInit: %i", SDL_WasInit(0));
/* Return if it's not enabled or not detected. The ID should never be less than zero here,
it can only be that because of a manual ini file change, but we make that check anway. */
if (WiiMoteEmu::WiiMapping[m_Page].ID < 0 || WiiMoteEmu::WiiMapping[m_Page].ID >= WiiMoteEmu::NumGoodPads)
{
m_tStatusLeftIn[m_Page]->SetLabel(wxT("Not connected"));
m_tStatusLeftOut[m_Page]->SetLabel(wxT("Not connected"));
m_tStatusRightIn[m_Page]->SetLabel(wxT("Not connected"));
m_tStatusRightOut[m_Page]->SetLabel(wxT("Not connected"));
m_TriggerStatusL[m_Page]->SetLabel(wxT("000"));
m_TriggerStatusR[m_Page]->SetLabel(wxT("000"));
return;
}
// Check that Dolphin is in focus, otherwise don't update the pad status
//if (IsFocus())
WiiMoteEmu::GetAxisState(WiiMoteEmu::WiiMapping[m_Page]);
// Analog stick
// Get original values
int main_x = WiiMoteEmu::WiiMapping[m_Page].AxisState.Lx;
int main_y = WiiMoteEmu::WiiMapping[m_Page].AxisState.Ly;
int right_x = WiiMoteEmu::WiiMapping[m_Page].AxisState.Rx;
int right_y = WiiMoteEmu::WiiMapping[m_Page].AxisState.Ry;
// Get adjusted values
int main_x_after = main_x, main_y_after = main_y;
int right_x_after = right_x, right_y_after = right_y;
// Produce square
if(WiiMoteEmu::WiiMapping[m_Page].bCircle2Square)
InputCommon::Square2Circle(main_x_after, main_y_after, WiiMoteEmu::WiiMapping[m_Page].Diagonal, true);
// Check dead zone
float DeadZoneLeft = (float)WiiMoteEmu::WiiMapping[m_Page].DeadZoneL / 100.0;
float DeadZoneRight = (float)WiiMoteEmu::WiiMapping[m_Page].DeadZoneR / 100.0;
if (InputCommon::IsDeadZone(DeadZoneLeft, main_x_after, main_y_after))
{
main_x_after = 0;
main_y_after = 0;
}
if (InputCommon::IsDeadZone(DeadZoneRight, right_x_after, right_y_after))
{
right_x_after = 0;
right_y_after = 0;
}
int Lx = InputCommon::Pad_Convert(main_x); int Ly = InputCommon::Pad_Convert(main_y);
int Rx = InputCommon::Pad_Convert(right_x); int Ry = InputCommon::Pad_Convert(right_y);
int Lx_after = InputCommon::Pad_Convert(main_x_after); int Ly_after = InputCommon::Pad_Convert(main_y_after);
int Rx_after = InputCommon::Pad_Convert(right_x_after); int Ry_after = InputCommon::Pad_Convert(right_y_after);
m_tStatusLeftIn[m_Page]->SetLabel(wxString::Format(wxT("X:%03i Y:%03i"), Lx, Ly));
m_tStatusLeftOut[m_Page]->SetLabel(wxString::Format(wxT("X:%03i Y:%03i"), Lx_after, Ly_after));
m_tStatusRightIn[m_Page]->SetLabel(wxString::Format(wxT("X:%03i Y:%03i"), Rx, Ry));
m_tStatusRightOut[m_Page]->SetLabel(wxString::Format(wxT("X:%03i Y:%03i"), Rx_after, Ry_after));
// Adjust the values for the plot
Convert2Box(main_x); Convert2Box(main_y);
Convert2Box(right_x); Convert2Box(right_y);
Convert2Box(main_x_after); Convert2Box(main_y_after);
Convert2Box(right_x_after); Convert2Box(right_y_after);
// Adjust the dot
m_bmpDotLeftIn[m_Page]->SetPosition(wxPoint(main_x, main_y));
m_bmpDotLeftOut[m_Page]->SetPosition(wxPoint(main_x_after, main_y_after));
m_bmpDotRightIn[m_Page]->SetPosition(wxPoint(right_x, right_y));
m_bmpDotRightOut[m_Page]->SetPosition(wxPoint(right_x_after, right_y_after));
// Get the trigger values
int TriggerLeft = WiiMoteEmu::WiiMapping[m_Page].AxisState.Tl;
int TriggerRight = WiiMoteEmu::WiiMapping[m_Page].AxisState.Tr;
// Convert the triggers values
if (WiiMoteEmu::WiiMapping[m_Page].TriggerType == InputCommon::CTL_TRIGGER_SDL)
{
TriggerLeft = InputCommon::Pad_Convert(TriggerLeft);
TriggerRight = InputCommon::Pad_Convert(TriggerRight);
}
m_TriggerStatusL[m_Page]->SetLabel(wxString::Format(wxT("%03i"), TriggerLeft));
m_TriggerStatusR[m_Page]->SetLabel(wxString::Format(wxT("%03i"), TriggerRight));
}

File diff suppressed because it is too large Load Diff

View File

@ -1,227 +0,0 @@
// 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 __PADCONFIGDIALOG_h__
#define __PADCONFIGDIALOG_h__
#include <iostream>
#include <vector>
#include <wx/wx.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/gbsizer.h>
#include "Config.h"
#include "wiimote_hid.h"
#if defined(HAVE_X11) && HAVE_X11
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h>
#include "X11InputBase.h"
#endif
class WiimotePadConfigDialog : public wxDialog
{
public:
WiimotePadConfigDialog(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString &title = wxT("Wii Remote Plugin Configuration"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS);
virtual ~WiimotePadConfigDialog();
void Convert2Box(int &x);
wxTimer *m_UpdatePadTimer,
*m_ButtonMappingTimer;
wxStaticBitmap *m_bmpDotLeftIn[MAX_WIIMOTES],
*m_bmpDotLeftOut[MAX_WIIMOTES],
*m_bmpDotRightIn[MAX_WIIMOTES],
*m_bmpDotRightOut[MAX_WIIMOTES],
*m_bmpDeadZoneLeftIn[MAX_WIIMOTES],
*m_bmpDeadZoneRightIn[MAX_WIIMOTES];
private:
DECLARE_EVENT_TABLE();
enum
{
// <It's important that the internal ordering of these are unchanged>
// Wiimote
IDB_WM_A, IDB_WM_B,
IDB_WM_1, IDB_WM_2,
IDB_WM_P, IDB_WM_M, IDB_WM_H,
IDB_WM_L, IDB_WM_R, IDB_WM_U, IDB_WM_D,
IDB_WM_ROLL_L, IDB_WM_ROLL_R,
IDB_WM_PITCH_U, IDB_WM_PITCH_D,
IDB_WM_SHAKE,
// Nunchuck
IDB_NC_Z,
IDB_NC_C,
IDB_NC_L,
IDB_NC_R,
IDB_NC_U,
IDB_NC_D,
IDB_NC_ROLL_L, IDB_NC_ROLL_R,
IDB_NC_PITCH_U, IDB_NC_PITCH_D,
IDB_NC_SHAKE,
// Classic Controller
IDB_CC_A, IDB_CC_B,
IDB_CC_X, IDB_CC_Y,
IDB_CC_P, IDB_CC_M, IDB_CC_H,
IDB_CC_TL, IDB_CC_TR, IDB_CC_ZL, IDB_CC_ZR, // Shoulder triggers and Zs
IDB_CC_DL, IDB_CC_DR, IDB_CC_DU, IDB_CC_DD, // Digital pad
IDB_CC_LL, IDB_CC_LR, IDB_CC_LU, IDB_CC_LD, // Left analog stick
IDB_CC_RL, IDB_CC_RR, IDB_CC_RU, IDB_CC_RD, // Right analog stick
// Guitar Hero 3 Controller
IDB_GH3_GREEN,
IDB_GH3_RED,
IDB_GH3_YELLOW,
IDB_GH3_BLUE,
IDB_GH3_ORANGE,
IDB_GH3_PLUS,
IDB_GH3_MINUS,
IDB_GH3_WHAMMY,
IDB_GH3_ANALOG_LEFT,
IDB_GH3_ANALOG_RIGHT,
IDB_GH3_ANALOG_UP,
IDB_GH3_ANALOG_DOWN,
IDB_GH3_STRUM_UP,
IDB_GH3_STRUM_DOWN,
// Gamepad
IDB_ANALOG_LEFT_X, IDB_ANALOG_LEFT_Y,
IDB_ANALOG_RIGHT_X, IDB_ANALOG_RIGHT_Y,
IDB_TRIGGER_L, IDB_TRIGGER_R,
IDTM_BUTTON = 1000, // Timer
IDTM_UPDATE_PAD, // Timer
ID_NOTEBOOK,
ID_CONTROLLERPAGE1,
ID_CONTROLLERPAGE2,
ID_CONTROLLERPAGE3,
ID_CONTROLLERPAGE4,
// Gamepad settings
IDC_JOYNAME,
IDC_RUMBLE, IDC_RUMBLE_STRENGTH,
IDC_DEAD_ZONE_LEFT, IDC_DEAD_ZONE_RIGHT,
IDC_STICK_DIAGONAL, IDC_STICK_C2S,
IDC_TILT_TYPE_WM, IDC_TILT_TYPE_NC,
IDC_TILT_ROLL, IDC_TILT_ROLL_SWING,
IDC_TILT_PITCH, IDC_TILT_PITCH_SWING,
IDC_TILT_ROLL_INVERT, IDC_TILT_PITCH_INVERT,
IDC_TRIGGER_TYPE,
IDC_NUNCHUCK_STICK,
IDC_CC_LEFT_STICK, IDC_CC_RIGHT_STICK, IDC_CC_TRIGGERS,
IDC_GH3_ANALOG,
};
bool m_ControlsCreated;
int m_Page, BoxW, BoxH;
wxString OldLabel;
wxNotebook *m_Notebook;
wxStaticBitmap *m_bmpSquareLeftIn[MAX_WIIMOTES],
*m_bmpSquareLeftOut[MAX_WIIMOTES],
*m_bmpSquareRightIn[MAX_WIIMOTES],
*m_bmpSquareRightOut[MAX_WIIMOTES];
wxCheckBox *m_CheckC2S[MAX_WIIMOTES],
*m_CheckRumble[MAX_WIIMOTES],
*m_TiltRollSwing[MAX_WIIMOTES],
*m_TiltPitchSwing[MAX_WIIMOTES],
*m_TiltRollInvert[MAX_WIIMOTES],
*m_TiltPitchInvert[MAX_WIIMOTES];
wxButton *ClickedButton,
*m_Button_Analog[IDB_TRIGGER_R - IDB_ANALOG_LEFT_X + 1][MAX_WIIMOTES],
*m_Button_Wiimote[IDB_WM_SHAKE - IDB_WM_A + 1][MAX_WIIMOTES],
*m_Button_NunChuck[IDB_NC_SHAKE - IDB_NC_Z + 1][MAX_WIIMOTES],
*m_Button_Classic[IDB_CC_RD - IDB_CC_A + 1][MAX_WIIMOTES],
*m_Button_GH3[IDB_GH3_STRUM_DOWN - IDB_GH3_GREEN + 1][MAX_WIIMOTES];
wxChoice *m_Joyname[MAX_WIIMOTES],
*m_ComboDeadZoneLeft[MAX_WIIMOTES],
*m_ComboDeadZoneRight[MAX_WIIMOTES],
*m_ComboDiagonal[MAX_WIIMOTES],
*m_RumbleStrength[MAX_WIIMOTES],
*m_TiltTypeWM[MAX_WIIMOTES],
*m_TiltTypeNC[MAX_WIIMOTES],
*m_TiltComboRangeRoll[MAX_WIIMOTES],
*m_TiltComboRangePitch[MAX_WIIMOTES],
*m_TriggerType[MAX_WIIMOTES],
*m_NunchuckComboStick[MAX_WIIMOTES],
*m_CcComboLeftStick[MAX_WIIMOTES],
*m_CcComboRightStick[MAX_WIIMOTES],
*m_CcComboTriggers[MAX_WIIMOTES],
*m_GH3ComboAnalog[MAX_WIIMOTES];
wxBoxSizer *m_Sizer_Classic[IDB_CC_RD - IDB_CC_A + 1][MAX_WIIMOTES];
wxStaticText
*m_tStatusLeftIn[MAX_WIIMOTES], *m_tStatusLeftOut[MAX_WIIMOTES],
*m_tStatusRightIn[MAX_WIIMOTES], *m_tStatusRightOut[MAX_WIIMOTES],
*m_TriggerStatusL[MAX_WIIMOTES], *m_TriggerStatusR[MAX_WIIMOTES];
wxBitmap CreateBitmap();
wxBitmap CreateBitmapDot();
wxBitmap CreateBitmapDeadZone(int Radius);
wxBitmap CreateBitmapClear();
void OnClose(wxCloseEvent& event);
void CloseClick(wxCommandEvent& event);
void CreatePadGUIControls();
void UpdateGUI();
void NotebookPageChanged(wxNotebookEvent& event);
void OnButtonTimer(wxTimerEvent& WXUNUSED(event)) { DoGetButtons(GetButtonWaitingID); }
void OnKeyDown(wxKeyEvent& event);
void OnButtonClick(wxCommandEvent& event);
void OnAxisClick(wxCommandEvent& event);
void GeneralSettingsChanged(wxCommandEvent& event);
void SaveButtonMapping(int Id, int Key);
// Gamepad configuration
void SetButtonText(int id,const wxString &str);
wxString GetButtonText(int id);
void DoGetButtons(int id);
void EndGetButtons();
void UpdatePadInfo(wxTimerEvent& WXUNUSED(event));
void ToBlank(bool ToBlank, int Id);
void DoChangeDeadZone();
// Configure buttons
int GetButtonWaitingID, GetButtonWaitingTimer, g_Pressed;
};
extern WiimotePadConfigDialog *m_PadConfigFrame;
#endif

View File

@ -1,286 +0,0 @@
// 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/
/* Data reports guide. The different structures location in the Input
reports. The ? in the IR coordinates is the High coordinates that are four
in one byte.
0x37: For the data reportingmode 0x37 there are five unused IR bytes in the
end (represented) by "..." below, it seems like they can be set to either
0xff or 0x00 without affecting the IR emulation. */
/* 0x33 [c.left etc] [c.a etc] acc.x y z ir0.x y ? ir1.x y ? ir2.x y ? ir3.x y
?
0x37 [c.left etc] [c.a etc] acc.x y z ir0.x1 y1 ? x2 y2 ir1.x1 y1 ? x2 y2
... ext.jx jy ax ay az bt
The Data Report's path from here is
WII_IPC_HLE_WiiMote.cpp:
Callback_WiimoteInterruptChannel()
CWII_IPC_HLE_WiiMote::SendL2capData()
WII_IPC_HLE_Device_usb.cpp:
CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLPacket()
at that point the message is queued and will be sent by the next
CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
*/
#include <vector>
#include <string>
#include "Common.h" // Common
#include "pluginspecs_wiimote.h"
#include "StringUtil.h" // for ArrayToString
#include "wiimote_hid.h" // Local
#include "main.h"
#include "EmuMain.h"
#include "EmuSubroutines.h"
#include "EmuDefinitions.h"
#include "Encryption.h" // for extension encryption
#include "Config.h" // for g_Config
extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteEmu
{
// Subroutines
// Update the data reporting mode
void WmReportMode(u16 _channelID, wm_report_mode* dr)
{
INFO_LOG(WIIMOTE, "Set data report mode");
DEBUG_LOG(WIIMOTE, " Rumble: %x", dr->rumble);
DEBUG_LOG(WIIMOTE, " Continuous: %x", dr->continuous);
DEBUG_LOG(WIIMOTE, " All The Time: %x", dr->all_the_time);
DEBUG_LOG(WIIMOTE, " Mode: 0x%02x", dr->mode);
g_ReportingAuto[g_ID] = dr->all_the_time;
g_ReportingMode[g_ID] = dr->mode;
g_ReportingChannel[g_ID] = _channelID;
if (dr->all_the_time == 0)
{
PanicAlert("Wiimote: Reporting Always is set to OFF!");
}
// Validation check
switch(dr->mode)
{
case WM_REPORT_CORE:
case WM_REPORT_CORE_ACCEL:
case WM_REPORT_CORE_ACCEL_IR12:
case WM_REPORT_CORE_ACCEL_EXT16:
case WM_REPORT_CORE_ACCEL_IR10_EXT6:
break;
default:
PanicAlert("Wiimote: Unsupported reporting mode 0x%x", dr->mode);
}
}
/* Case 0x30: Core Buttons */
void SendReportCore(u16 _channelID)
{
u8 DataFrame[1024];
u32 Offset = WriteWmReportHdr(DataFrame, WM_REPORT_CORE);
wm_report_core* pReport = (wm_report_core*)(DataFrame + Offset);
Offset += sizeof(wm_report_core);
memset(pReport, 0, sizeof(wm_report_core));
#if defined(HAVE_WX) && HAVE_WX
FillReportInfo(pReport->c);
#endif
INFO_LOG(WIIMOTE, " SendReportCore(0x30)");
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
}
/* 0x31: Core Buttons and Accelerometer */
void SendReportCoreAccel(u16 _channelID)
{
u8 DataFrame[1024];
u32 Offset = WriteWmReportHdr(DataFrame, WM_REPORT_CORE_ACCEL);
wm_report_core_accel* pReport = (wm_report_core_accel*)(DataFrame + Offset);
Offset += sizeof(wm_report_core_accel);
memset(pReport, 0, sizeof(wm_report_core_accel));
#if defined(HAVE_WX) && HAVE_WX
FillReportInfo(pReport->c);
FillReportAcc(pReport->a);
#endif
INFO_LOG(WIIMOTE, " SendReportCoreAccel (0x31)");
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
}
/* Case 0x33: Core Buttons and Accelerometer with 12 IR bytes */
void SendReportCoreAccelIr12(u16 _channelID) {
u8 DataFrame[1024];
u32 Offset = WriteWmReportHdr(DataFrame, WM_REPORT_CORE_ACCEL_IR12);
wm_report_core_accel_ir12* pReport = (wm_report_core_accel_ir12*)(DataFrame + Offset);
Offset += sizeof(wm_report_core_accel_ir12);
memset(pReport, 0, sizeof(wm_report_core_accel_ir12));
#if defined(HAVE_WX) && HAVE_WX
FillReportInfo(pReport->c);
FillReportAcc(pReport->a);
// We settle with emulating two objects, not all four. We leave object 2 and 3 with 0xff.
FillReportIR(pReport->ir[0], pReport->ir[1]);
#endif
memset(&pReport->ir[2], 0xff, sizeof(wm_ir_extended));
memset(&pReport->ir[3], 0xff, sizeof(wm_ir_extended));
INFO_LOG(WIIMOTE, " SendReportCoreAccelIr12(0x33)");
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
}
/* Case 0x35: Core Buttons and Accelerometer with 16 Extension Bytes */
void SendReportCoreAccelExt16(u16 _channelID)
{
u8 DataFrame[1024];
u32 Offset = WriteWmReportHdr(DataFrame, WM_REPORT_CORE_ACCEL_EXT16);
wm_report_core_accel_ext16* pReport = (wm_report_core_accel_ext16*)(DataFrame + Offset);
Offset += sizeof(wm_report_core_accel_ext16);
memset(pReport, 0, sizeof(wm_report_core_accel_ext16));
// Make a classic extension struct
wm_classic_extension _ext;
memset(&_ext, 0, sizeof(wm_classic_extension));
#if defined(HAVE_WX) && HAVE_WX
FillReportInfo(pReport->c);
FillReportAcc(pReport->a);
#endif
if(WiiMapping[g_ID].iExtensionConnected == EXT_NUNCHUK)
{
#if defined(HAVE_WX) && HAVE_WX
FillReportExtension(pReport->ext);
#endif
}
else if(WiiMapping[g_ID].iExtensionConnected == EXT_CLASSIC_CONTROLLER)
{
#if defined(HAVE_WX) && HAVE_WX
FillReportClassicExtension(_ext);
#endif
// Copy _ext to pReport->ext
memcpy(&pReport->ext, &_ext, sizeof(_ext));
}
INFO_LOG(WIIMOTE, " SendReportCoreAccelExt16 (0x35)");
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
}
/* Case 0x37: Core Buttons and Accelerometer with 10 IR bytes and 6 Extension Bytes */
void SendReportCoreAccelIr10Ext(u16 _channelID)
{
u8 DataFrame[1024];
u32 Offset = WriteWmReportHdr(DataFrame, WM_REPORT_CORE_ACCEL_IR10_EXT6);
wm_report_core_accel_ir10_ext6* pReport = (wm_report_core_accel_ir10_ext6*)(DataFrame + Offset);
Offset += sizeof(wm_report_core_accel_ir10_ext6);
memset(pReport, 0, sizeof(wm_report_core_accel_ir10_ext6));
// Make a classic extension struct
#if defined(HAVE_WX) && HAVE_WX
FillReportInfo(pReport->c);
FillReportAcc(pReport->a);
FillReportIRBasic(pReport->ir[0], pReport->ir[1]);
if ((WiiMapping[g_ID].bMotionPlusConnected) )
{
if(WiiMapping[g_ID].iExtensionConnected == EXT_NUNCHUK)
{
if (g_RegExt[g_ID][0xFF] == 0x05) {
FillReportMotionPlus(pReport->ext, true);
}
else {
FillReportExtension(pReport->ext);
}
DEBUG_LOG(WIIMOTE, "Motionplus:Nunchuk data -> ext:%01x mp:%01x [ff:0x%02x]", (pReport->ext.az &0x01), (pReport->ext.bt &0x02),g_RegExt[g_ID][0xFF]);
}
else if (WiiMapping[g_ID].iExtensionConnected == EXT_NONE)
{
FillReportMotionPlus(pReport->ext, false);
}
}
else {
if(WiiMapping[g_ID].iExtensionConnected == EXT_NUNCHUK)
{
FillReportExtension(pReport->ext);
}
else if(WiiMapping[g_ID].iExtensionConnected == EXT_CLASSIC_CONTROLLER)
{
wm_classic_extension _ext;
memset(&_ext, 0, sizeof(wm_classic_extension));
FillReportClassicExtension(_ext);
// Copy _ext to pReport->ext
memcpy(&pReport->ext, &_ext, sizeof(_ext));
}
else if(WiiMapping[g_ID].iExtensionConnected == EXT_GUITARHERO)
{
wm_GH3_extension _GH3_ext;
memset(&_GH3_ext, 0, sizeof(wm_GH3_extension));
FillReportGuitarHero3Extension(_GH3_ext);
memcpy(&pReport->ext, &_GH3_ext, sizeof(_GH3_ext));
}
}
#endif
INFO_LOG(WIIMOTE, " SendReportCoreAccelIr10Ext(0x37)");
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
}
} // end of namespace

View File

@ -1,70 +0,0 @@
// 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 _EMU_DEFINITIONS_
#define _EMU_DEFINITIONS_
#include <vector>
#include <string>
#include "Common.h"
#include "pluginspecs_wiimote.h"
#include "wiimote_hid.h"
#include "EmuDefinitions.h"
#include "Encryption.h"
extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteEmu
{
//******************************************************************************
// Definitions and variable declarations
//******************************************************************************
u8 g_Eeprom[MAX_WIIMOTES][WIIMOTE_EEPROM_SIZE];
u8 g_RegExt[MAX_WIIMOTES][WIIMOTE_REG_EXT_SIZE];
u8 g_RegMotionPlus[MAX_WIIMOTES][WIIMOTE_REG_EXT_SIZE];
u8 g_RegSpeaker[MAX_WIIMOTES][WIIMOTE_REG_SPEAKER_SIZE];
u8 g_RegIr[MAX_WIIMOTES][WIIMOTE_REG_IR_SIZE];
u8 g_IRClock[MAX_WIIMOTES];
u8 g_IR[MAX_WIIMOTES];
u8 g_Leds[MAX_WIIMOTES];
u8 g_Speaker[MAX_WIIMOTES];
u8 g_MotionPlus[MAX_WIIMOTES];
u8 g_SpeakerMute[MAX_WIIMOTES];
u8 g_MotionPlusLastWriteReg[MAX_WIIMOTES];
u8 g_RegExtTmp[WIIMOTE_REG_EXT_SIZE];
int g_ID; // Current refreshing Wiimote
bool g_ReportingAuto[MAX_WIIMOTES]; // Auto report or passive report
bool g_InterleavedData[MAX_WIIMOTES]; //sending alternated data packets from the nunchuk/motionplus
u8 g_ReportingMode[MAX_WIIMOTES]; // The reporting mode and channel id
u16 g_ReportingChannel[MAX_WIIMOTES];
wiimote_key g_ExtKey[MAX_WIIMOTES]; // The extension encryption key
bool g_Encryption; // Encryption on or off
// Gamepad input
int NumPads = 0, NumGoodPads = 0; // Number of goods pads
std::vector<InputCommon::CONTROLLER_INFO> joyinfo;
CONTROLLER_MAPPING_WII WiiMapping[MAX_WIIMOTES];
} // namespace
#endif //_EMU_DECLARATIONS_

View File

@ -1,363 +0,0 @@
// 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 _EMU_DECLARATIONS_
#define _EMU_DECLARATIONS_
#include <vector>
#include <string>
#include "../../../Core/InputCommon/Src/InputCommon.h" // Core
#include "../../../Core/InputCommon/Src/SDL_Util.h"
#ifdef _WIN32
#include "../../../Core/InputCommon/Src/XInput_Util.h"
#endif
#include "Common.h"
#include "pluginspecs_wiimote.h"
#include "wiimote_hid.h" // Local
#include "Encryption.h"
#include "UDPWiimote.h"
#if defined(HAVE_X11) && HAVE_X11
#include <X11/X.h>
#endif
extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteEmu
{
//******************************************************************************
// Definitions and variable declarations
//******************************************************************************
/* The Libogc bounding box in smoothed IR coordinates is 232,284 792,704. However, there is no
universal standard that works with all games. They all use their own calibration. Also,
there is no widescreen mode for the calibration, at least not in the games I tried, the
game decides for example that a horizontal value of 500 is 50% from the left of the screen,
and then that's the same regardless if we use the widescreen mode or not.*/
#define LEFT 266
#define TOP 215
#define RIGHT 752
#define BOTTOM 705
/* Since the width of the entire virtual screen is 1024 a reasonable sensor bar width is perhaps 200,
given how small most sensor bars are compared to the total TV width. When I tried the distance with
my Wiimote from around three meters distance from the sensor bar (that has around 15 cm beteen the
IR lights) I got a dot distance of around 110 (and a dot size of between 1 and 2). */
#define SENSOR_BAR_WIDTH 200
// Movement recording
extern int g_RecordingPlaying[3];
extern int g_RecordingCounter[3];
extern int g_RecordingPoint[3];
extern double g_RecordingStart[3];
extern double g_RecordingCurrentTime[3];
// Registry sizes
#define WIIMOTE_EEPROM_SIZE (16*1024)
#define WIIMOTE_EEPROM_FREE_SIZE 0x16ff
#define WIIMOTE_REG_SPEAKER_SIZE 10
#define WIIMOTE_REG_EXT_SIZE 0x100
#define WIIMOTE_REG_IR_SIZE 0x34
extern u8 g_Eeprom[MAX_WIIMOTES][WIIMOTE_EEPROM_SIZE];
extern u8 g_RegExt[MAX_WIIMOTES][WIIMOTE_REG_EXT_SIZE];
extern u8 g_RegMotionPlus[MAX_WIIMOTES][WIIMOTE_REG_EXT_SIZE];
extern u8 g_RegSpeaker[MAX_WIIMOTES][WIIMOTE_REG_SPEAKER_SIZE];
extern u8 g_RegIr[MAX_WIIMOTES][WIIMOTE_REG_IR_SIZE];
extern u8 g_IRClock[MAX_WIIMOTES];
extern u8 g_IR[MAX_WIIMOTES];
extern u8 g_Leds[MAX_WIIMOTES];
extern u8 g_Speaker[MAX_WIIMOTES];
extern u8 g_MotionPlus[MAX_WIIMOTES];
extern u8 g_MotionPlusLastWriteReg[MAX_WIIMOTES];
extern u8 g_SpeakerMute[MAX_WIIMOTES];
extern u8 g_RegExtTmp[WIIMOTE_REG_EXT_SIZE];
extern int g_ID;
extern bool g_ReportingAuto[MAX_WIIMOTES];
extern u8 g_ReportingMode[MAX_WIIMOTES];
extern u16 g_ReportingChannel[MAX_WIIMOTES];
extern bool g_InterleavedData[MAX_WIIMOTES];
extern wiimote_key g_ExtKey[MAX_WIIMOTES]; // extension encryption key
extern bool g_Encryption;
/* An example of a factory default first bytes of the Eeprom memory. There are differences between
different Wiimotes, my Wiimote had different neutral values for the accelerometer. */
static const u8 EepromData_0[] = {
0xA1, 0xAA, 0x8B, 0x99, 0xAE, 0x9E, 0x78, 0x30, 0xA7, 0x74, 0xD3,
0xA1, 0xAA, 0x8B, 0x99, 0xAE, 0x9E, 0x78, 0x30, 0xA7, 0x74, 0xD3,
// Accelerometer neutral values
0x82, 0x82, 0x82, 0x15, 0x9C, 0x9C, 0x9E, 0x38, 0x40, 0x3E,
0x82, 0x82, 0x82, 0x15, 0x9C, 0x9C, 0x9E, 0x38, 0x40, 0x3E
};
static const u8 EepromData_16D0[] = {
0x00, 0x00, 0x00, 0xFF, 0x11, 0xEE, 0x00, 0x00,
0x33, 0xCC, 0x44, 0xBB, 0x00, 0x00, 0x66, 0x99,
0x77, 0x88, 0x00, 0x00, 0x2B, 0x01, 0xE8, 0x13
};
/* Default calibration for the nunchuck. It should be written to 0x20 - 0x3f of the
extension register. 0x80 is the neutral x and y accelerators and 0xb3 is the
neutral z accelerometer that is adjusted for gravity. */
static const u8 nunchuck_calibration[] =
{
0x80,0x80,0x80,0x00, // accelerometer x, y, z neutral
0xb3,0xb3,0xb3,0x00, // x, y, z g-force values
0xff, 0x00, 0x80, 0xff, // 0xff max, 0x00 min, 0x80 = analog stick x and y axis center
0x00, 0x80, 0xec, 0x41 // checksum on the last two bytes
};
static const u8 wireless_nunchuck_calibration[] =
{
128, 128, 128, 0x00,
181, 181, 181, 0x00,
255, 0, 125, 255,
0, 126, 0xed, 0x43
};
/* Classic Controller calibration */
static const u8 classic_calibration[] =
{
0xff,0x00,0x80, 0xff,0x00,0x80, 0xff,0x00,0x80, 0xff,0x00,0x80,
0x00,0x00, 0x51,0xa6
};
/* Default calibration for the motion plus, 0xA60020 */
static const u8 motion_plus_calibration[] =
{
0x79, 0xbe, 0x77, 0x5a, 0x77, 0x38, // gyroscope neutral values (each 14 bit, last 2bits unknown) fast motion
0x2f, 0x90, 0xcd, 0x3b, // "" min/max
0x2f, 0xfd, 0xc8, 0x29, // "" min/max
0x9c, 0x75,
0x7d, 0xd4, 0x78, 0xef, 0x78, 0x8a, // gyroscope neutral values (each 14 bit, last 2bits unknown) slow motion
0x35, 0xa6, 0xc9, 0x9b, // "" min/max
0x33, 0x50, // "" min
0x2d, 0x00, 0xbd, 0x23
}; // TODO: figure out remaining parts;
static const u8 motionplus_accel_gyro_syncing[] = { //resulting calibration data at 0xA60050 by syncing accels and gyros
0x1e, 0x54, 0x74, 0xa2, 0x96, 0xec, 0x2b, 0xd6, 0xe1, 0xef, 0xc3, 0xf7, 0x84, 0x9e, 0x06, 0xbb,
0x39, 0x33, 0x3d, 0x20, 0x97, 0xed, 0x75, 0x52, 0xfd, 0x98, 0xaf, 0xd8, 0xc9, 0x5a, 0x17, 0x23,
0x74, 0x3a, 0x49, 0xd3, 0xb9, 0xf6, 0xff, 0x4f, 0x34, 0xa8, 0x6d, 0xc4, 0x96, 0x5c, 0xcd, 0xb2,
0x33, 0x78, 0x98, 0xe9, 0xa9, 0x7f, 0xf7, 0x5e, 0x07, 0x87, 0xbb, 0x29, 0x01, 0x2b, 0x70, 0x3f
};
static const u8 motionplus_activeflags[] = { //0xA600F0
0x55, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0xff, 0xff, //Different flags, e.g. activation, calibration, initiaton, extensionstate.
0x00, 0x00, 0xa6, 0x20, 0x00, 0x05 //Extension ID
};
// Extension device IDs to be written to the last bytes of the extension reg
static const u8 nunchuck_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x00, 0x00 };
static const u8 classic_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x01 };
static const u8 gh3glp_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x03 };
static const u8 ghwtdrums_id[] = { 0x01, 0x00, 0xa4, 0x20, 0x01, 0x03 };
static const u8 wbb_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x4, 0x02 };
static const u8 motionplus_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x04, 0x05 };
static const u8 motionplusnunchuk_id[] = { 0x00, 0x00, 0xa6, 0x20, 0x05, 0x05 };
// The id for nothing inserted
static const u8 nothing_id[] = { 0x00, 0x00, 0x00, 0x00, 0x2e, 0x2e };
// The id for a partially inserted extension
static const u8 partially_id[] = { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff };
enum EExtensionType
{
EXT_NONE = 0,
EXT_NUNCHUK,
EXT_CLASSIC_CONTROLLER,
EXT_GUITARHERO,
EXT_WBB,
};
enum EInputType
{
FROM_KEYBOARD,
FROM_ANALOG1,
FROM_ANALOG2,
FROM_TRIGGER,
};
enum EButtonCode
{
EWM_A = 0, // Keyboard A and Mouse A
EWM_B,
EWM_ONE, EWM_TWO,
EWM_P, EWM_M, EWM_H,
EWM_L, EWM_R, EWM_U, EWM_D,
EWM_ROLL_L, EWM_ROLL_R,
EWM_PITCH_U, EWM_PITCH_D,
EWM_SHAKE,
ENC_Z, ENC_C,
ENC_L, ENC_R, ENC_U, ENC_D,
ENC_ROLL_L, ENC_ROLL_R,
ENC_PITCH_U, ENC_PITCH_D,
ENC_SHAKE,
ECC_A, ECC_B, ECC_X, ECC_Y,
ECC_P, ECC_M, ECC_H,
ECC_Tl, ECC_Tr, ECC_Zl, ECC_Zr,
ECC_Dl, ECC_Dr, ECC_Du, ECC_Dd,
ECC_Ll, ECC_Lr, ECC_Lu, ECC_Ld,
ECC_Rl, ECC_Rr, ECC_Ru, ECC_Rd,
EGH_Green, EGH_Red, EGH_Yellow, EGH_Blue, EGH_Orange,
EGH_Plus, EGH_Minus, EGH_Whammy,
EGH_Al, EGH_Ar, EGH_Au, EGH_Ad,
EGH_StrumUp, EGH_StrumDown,
LAST_CONSTANT,
};
union UAxis
{
int Code[6];
struct
{
int Lx;
int Ly;
int Rx;
int Ry;
int Tl; // Trigger
int Tr; // Trigger
};
};
struct SStickMapping
{
int NC;
int CCL;
int CCR;
int CCT; //Trigger
int GH; // Analog Stick
int GHB; // Whammy bar
};
struct STiltMapping
{
int InputWM;
int InputNC;
bool RollInvert;
bool PitchInvert;
int RollDegree;
bool RollSwing;
int RollRange;
int PitchDegree;
bool PitchSwing;
int PitchRange;
};
struct SDot
{
int Rx, Ry, X, Y;
bool Visible;
int Size; // Size of the IR dot (0-15)
int Order; // Increasing order from low to higher x-axis values
};
struct SIR
{
SDot Dot[4];
int Distance;
};
struct STiltData
{
// FakeNoise is used to prevent disconnection
// when there is no input for a long time
int FakeNoise;
int Shake;
int Roll, Pitch;
STiltData()
{
FakeNoise = 1;
Shake = 0;
Roll = 0;
Pitch = 0;
}
};
struct SMotion
{
// Raw X and Y coordinate and processed X and Y coordinates
SIR IR;
STiltData TiltWM;
STiltData TiltNC;
};
struct UDPWiiSettings
{
bool enable;
bool enableAccel;
bool enableButtons;
bool enableIR;
bool enableNunchuck;
char port[10];
UDPWiimote *instance;
};
struct CONTROLLER_MAPPING_WII // WII PAD MAPPING
{
SDL_Joystick *joy; // SDL joystick device
UAxis AxisState;
UAxis AxisMapping; // 6 Axes (Main, Sub, Triggers)
int TriggerType; // SDL or XInput trigger
int ID; // SDL joystick device ID
bool Rumble;
int RumbleStrength;
int DeadZoneL; // Analog 1 Deadzone
int DeadZoneR; // Analog 2 Deadzone
bool bCircle2Square;
int Diagonal;
int Source; // 0: inactive, 1: emu, 2: real
bool bSideways;
bool bUpright;
bool bMotionPlusConnected;
bool bWiiAutoReconnect;
int iExtensionConnected;
STiltMapping Tilt;
SStickMapping Stick;
int Button[LAST_CONSTANT];
SMotion Motion;
UDPWiiSettings UDPWM;
};
// Gamepad input
extern int NumPads, NumGoodPads; // Number of goods pads
extern std::vector<InputCommon::CONTROLLER_INFO> joyinfo;
extern CONTROLLER_MAPPING_WII WiiMapping[4];
} // namespace
#endif //_EMU_DEFINITIONS_

View File

@ -1,433 +0,0 @@
// 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 <vector>
#include <string>
#include "Common.h" // Common
#include "MathUtil.h"
#include "StringUtil.h" // for ArrayToString()
#include "IniFile.h"
#include "pluginspecs_wiimote.h"
#include "EmuDefinitions.h" // Local
#include "main.h"
#include "wiimote_hid.h"
#include "EmuSubroutines.h"
#include "EmuMain.h"
#include "Encryption.h" // for extension encryption
#include "Config.h" // for g_Config
namespace WiiMoteEmu
{
//******************************************************************************
// Accelerometer functions
//******************************************************************************
// Wiimote accelerometer
/* The accelerometer x, y and z values range from 0x00 to 0xff with the default
netural values being [y = 0x84, x = 0x84, z = 0x9f] according to a
source. The extremes are 0x00 for (-) and 0xff for (+). It's important that
all values are not 0x80, the mouse pointer can disappear from the screen
permanently then, until z is adjusted back. This is because the game detects
a steep pitch of the Wiimote then.
Wiimote Accelerometer Axes
+ (- -- X -- +)
| ___
| | |\ -
| | + || \
| . || \
Y |. .|| Z
| . || \
| | . || \
| |___|| +
- ---
*/
// Single shake step of all three directions
void ShakeToAccelerometer(int &_x, int &_y, int &_z, STiltData &_TiltData)
{
switch(_TiltData.Shake)
{
case 0:
_TiltData.Shake = -1;
break;
case 1:
case 3:
_x = g_wm.cal_zero.x / 2;
_y = g_wm.cal_zero.y / 2;
_z = g_wm.cal_zero.z / 2;
break;
case 5:
case 7:
_x = (0xFF - g_wm.cal_zero.x ) / 2;
_y = (0xFF - g_wm.cal_zero.y ) / 2;
_z = (0xFF - g_wm.cal_zero.z ) / 2;
break;
case 2:
_x = 0x00;
_y = 0x00;
_z = 0x00;
break;
case 6:
_x = 0xFF;
_y = 0xFF;
_z = 0xFF;
break;
case 4:
_x = 0x80;
_y = 0x80;
_z = 0x80;
break;
default:
_TiltData.Shake = -1;
break;
}
_TiltData.Shake++;
if (_TiltData.Shake != 0)
{
DEBUG_LOG(WIIMOTE, "Shake: %i - 0x%02x, 0x%02x, 0x%02x", _TiltData.Shake, _x, _y, _z);
}
}
/* Tilting by gamepad. We can guess that the game will calculate
roll and pitch and use them as measures of the tilting. We are
interested in this tilting range 90 to -90*/
void TiltByGamepad(STiltData &_TiltData, int Type)
{
// Return if we have no pads
if (NumGoodPads == 0) return;
/* Adjust the pad state values, including a downscaling from the original
0x8000 size values to 0x80. The only reason we do this is that the code
below crrently assume that the range is 0 to 255 for all axes. If we
lose any precision by doing this we could consider not doing this
adjustment. And instead for example upsize the XInput trigger from 0x80
to 0x8000. */
int Lx = WiiMapping[g_ID].AxisState.Lx;
int Ly = WiiMapping[g_ID].AxisState.Ly;
int Rx = WiiMapping[g_ID].AxisState.Rx;
int Ry = WiiMapping[g_ID].AxisState.Ry;
int Tl = WiiMapping[g_ID].AxisState.Tl;
int Tr = WiiMapping[g_ID].AxisState.Tr;
// Save the Range in degrees, 45 and 90 are good values in some games
int RollRange = WiiMapping[g_ID].Tilt.RollRange;
int PitchRange = WiiMapping[g_ID].Tilt.PitchRange;
// The trigger currently only controls pitch, no roll, no free swing
if (Type == FROM_TRIGGER)
{
// Make the range the same dimension as the analog stick
Tl = Tl / 2;
Tr = Tr / 2;
// Invert
if (WiiMapping[g_ID].Tilt.PitchInvert) { Tl = -Tl; Tr = -Tr; }
// The final value
_TiltData.Pitch = (int)((float)PitchRange * ((float)(Tl - Tr) / 128.0f));
}
/* For the analog stick roll is by default set to the X-axis, pitch is by
default set to the Y-axis. By changing the axis mapping and the invert
options this can be altered in any way */
else if (Type == FROM_ANALOG1)
{
// Adjust the trigger to go between negative and positive values
Lx = Lx - 0x80;
Ly = Ly - 0x80;
// Invert
if (WiiMapping[g_ID].Tilt.RollInvert) Lx = -Lx; // else Tr = -Tr;
if (WiiMapping[g_ID].Tilt.PitchInvert) Ly = -Ly; // else Tr = -Tr;
// Produce the final value
_TiltData.Roll = (int)((RollRange) ? (float)RollRange * ((float)Lx / 128.0f) : Lx);
_TiltData.Pitch = (int)((PitchRange) ? (float)PitchRange * ((float)Ly / 128.0f) : Ly);
}
// Otherwise we are using ANALOG2
else
{
// Adjust the trigger to go between negative and positive values
Rx = Rx - 0x80;
Ry = Ry - 0x80;
// Invert
if (WiiMapping[g_ID].Tilt.RollInvert) Rx = -Rx; // else Tr = -Tr;
if (WiiMapping[g_ID].Tilt.PitchInvert) Ry = -Ry; // else Tr = -Tr;
// Produce the final value
_TiltData.Roll = (int)((RollRange) ? (float)RollRange * ((float)Rx / 128.0f) : Rx);
_TiltData.Pitch = (int)((PitchRange) ? (float)PitchRange * ((float)Ry / 128.0f) : Ry);
}
}
// Tilting by keyboard
void TiltByKeyboard(STiltData &_TiltData, int Type)
{
#if defined(HAVE_WX) && HAVE_WX
int _ROLL_LEFT_ = (Type) ? ENC_ROLL_L : EWM_ROLL_L;
int _ROLL_RIGHT_ = (Type) ? ENC_ROLL_R : EWM_ROLL_R;
int _PITCH_UP_ = (Type) ? ENC_PITCH_U : EWM_PITCH_U;
int _PITCH_DOWN_ = (Type) ? ENC_PITCH_D : EWM_PITCH_D;
// Do roll/pitch or free swing
if (IsKey(_ROLL_LEFT_))
{
if (WiiMapping[g_ID].Tilt.RollRange)
{
// Stop at the lower end of the range
if (_TiltData.Roll > -WiiMapping[g_ID].Tilt.RollRange)
_TiltData.Roll -= 3; // aim left
}
else // Free swing
{
_TiltData.Roll = -0x80 / 2;
}
}
else if (IsKey(_ROLL_RIGHT_))
{
if (WiiMapping[g_ID].Tilt.RollRange)
{
// Stop at the upper end of the range
if (_TiltData.Roll < WiiMapping[g_ID].Tilt.RollRange)
_TiltData.Roll += 3; // aim right
}
else // Free swing
{
_TiltData.Roll = 0x80 / 2;
}
}
else
{
_TiltData.Roll = 0;
}
if (IsKey(_PITCH_UP_))
{
if (WiiMapping[g_ID].Tilt.PitchRange)
{
// Stop at the lower end of the range
if (_TiltData.Pitch > -WiiMapping[g_ID].Tilt.PitchRange)
_TiltData.Pitch -= 3; // aim down
}
else // Free swing
{
_TiltData.Pitch = -0x80 / 2;
}
}
else if (IsKey(_PITCH_DOWN_))
{
if (WiiMapping[g_ID].Tilt.PitchRange)
{
// Stop at the upper end of the range
if (_TiltData.Pitch < WiiMapping[g_ID].Tilt.PitchRange)
_TiltData.Pitch += 3; // aim up
}
else // Free swing
{
_TiltData.Pitch = 0x80 / 2;
}
}
else
{
_TiltData.Pitch = 0;
}
#endif
}
// Tilting Wiimote (Wario Land aiming, Mario Kart steering and other things)
void TiltWiimote(int &_x, int &_y, int &_z)
{
// Select input method and return the x, y, x values
if ((WiiMapping[g_ID].UDPWM.instance)&&(WiiMapping[g_ID].UDPWM.enableAccel))
{
float x,y,z;
WiiMapping[g_ID].UDPWM.instance->getAccel(x,y,z);
float xg = WiiMoteEmu::g_wm.cal_g.x;
float yg = WiiMoteEmu::g_wm.cal_g.y;
float zg = WiiMoteEmu::g_wm.cal_g.z;
_x = WiiMoteEmu::g_wm.cal_zero.x + (int)(xg * x);
_y = WiiMoteEmu::g_wm.cal_zero.y + (int)(yg * y);
_z = WiiMoteEmu::g_wm.cal_zero.z + (int)(zg * z);
}
else
{
if (WiiMapping[g_ID].Tilt.InputWM == FROM_KEYBOARD)
TiltByKeyboard(WiiMapping[g_ID].Motion.TiltWM, 0);
else
TiltByGamepad(WiiMapping[g_ID].Motion.TiltWM, WiiMapping[g_ID].Tilt.InputWM);
// Adjust angles, it's only needed if both roll and pitch is used together
if (WiiMapping[g_ID].Tilt.RollRange && WiiMapping[g_ID].Tilt.PitchRange)
AdjustAngles(WiiMapping[g_ID].Motion.TiltWM.Roll, WiiMapping[g_ID].Motion.TiltWM.Pitch);
// Calculate the accelerometer value from this tilt angle
TiltToAccelerometer(_x, _y, _z,WiiMapping[g_ID].Motion.TiltWM);
}
//DEBUG_LOG(WIIMOTE, "Roll:%i, Pitch:%i, _x:%u, _y:%u, _z:%u", g_Wiimote_kbd.TiltData.Roll, g_Wiimote_kbd.TiltData.Pitch, _x, _y, _z);
}
// Tilting Nunchuck (Mad World, Dead Space and other things)
void TiltNunchuck(int &_x, int &_y, int &_z)
{
// Select input method and return the x, y, x values
if (WiiMapping[g_ID].Tilt.InputNC == FROM_KEYBOARD)
TiltByKeyboard(WiiMapping[g_ID].Motion.TiltNC, 1);
else
TiltByGamepad(WiiMapping[g_ID].Motion.TiltNC, WiiMapping[g_ID].Tilt.InputNC);
// Adjust angles, it's only needed if both roll and pitch is used together
if (WiiMapping[g_ID].Tilt.RollRange && WiiMapping[g_ID].Tilt.PitchRange)
AdjustAngles(WiiMapping[g_ID].Motion.TiltNC.Roll, WiiMapping[g_ID].Motion.TiltNC.Pitch);
// Calculate the accelerometer value from this tilt angle
TiltToAccelerometer(_x, _y, _z, WiiMapping[g_ID].Motion.TiltNC);
//DEBUG_LOG(WIIMOTE, "Roll:%i, Pitch:%i, _x:%u, _y:%u, _z:%u", g_NunchuckExt.TiltData.Roll, g_NunchuckExt.TiltData.Pitch, _x, _y, _z);
}
/* Angles adjustment for the upside down state when both roll and pitch is
used. When the absolute values of the angles go over 90 the Wiimote is
upside down and these adjustments are needed. */
void AdjustAngles(int &Roll, int &Pitch)
{
int OldPitch = Pitch;
if (abs(Roll) > 90)
{
if (Pitch >= 0)
Pitch = 180 - Pitch; // 15 to 165
else
Pitch = -180 - Pitch; // -15 to -165
}
if (abs(OldPitch) > 90)
{
if (Roll >= 0)
Roll = 180 - Roll; // 15 to 165
else
Roll = -180 - Roll; // -15 to -165
}
}
// Angles to accelerometer values
void TiltToAccelerometer(int &_x, int &_y, int &_z, STiltData &_TiltData)
{
if (_TiltData.Roll == 0 && _TiltData.Pitch == 0)
return;
// We need radiands for the math functions
float Roll = InputCommon::Deg2Rad((float)_TiltData.Roll);
float Pitch = InputCommon::Deg2Rad((float)_TiltData.Pitch);
// We need float values
float x = 0.0f, y = 0.0f, z = 1.0f; // Gravity
// In these cases we can use the simple and accurate formula
if(WiiMapping[g_ID].Tilt.RollRange && !WiiMapping[g_ID].Tilt.PitchRange)
{
x = sin(Roll);
z = cos(Roll);
}
else if (WiiMapping[g_ID].Tilt.PitchRange && !WiiMapping[g_ID].Tilt.RollRange)
{
y = sin(Pitch);
z = cos(Pitch);
}
else if(WiiMapping[g_ID].Tilt.RollRange && WiiMapping[g_ID].Tilt.PitchRange)
{
// ====================================================
/* This seems to always produce the exact same combination of x, y, z
and Roll and Pitch that the real Wiimote produce. There is an
unlimited amount of x, y, z combinations for any combination of Roll
and Pitch. But if we select a Z from the smallest of the absolute
value of cos(Roll) and cos (Pitch) we get the right values. */
// ---------
if (fabsf(cos(Roll)) < fabsf(cos(Pitch)))
z = cos(Roll);
else
z = cos(Pitch);
/* I got these from reversing the calculation in
PitchAccelerometerToDegree() in a math program. */
float x_num = 2 * tanf(0.5f * Roll) * z;
float x_den = pow2f(tanf(0.5f * Roll)) - 1;
x = - (x_num / x_den);
float y_num = 2 * tanf(0.5f * Pitch) * z;
float y_den = pow2f(tanf(0.5f * Pitch)) - 1;
y = - (y_num / y_den);
}
// Multiply with neutral value and its g
float xg = g_wm.cal_g.x;
float yg = g_wm.cal_g.y;
float zg = g_wm.cal_g.z;
int ix = g_wm.cal_zero.x + (int)(xg * x);
int iy = g_wm.cal_zero.y + (int)(yg * y);
int iz = g_wm.cal_zero.z + (int)(zg * z);
if (!WiiMapping[g_ID].bUpright)
{
if(WiiMapping[g_ID].Tilt.RollRange) _x = ix;
if(WiiMapping[g_ID].Tilt.PitchRange) _y = iy;
_z = iz;
}
else // Upright wiimote
{
if(WiiMapping[g_ID].Tilt.RollRange) _x = ix;
if(WiiMapping[g_ID].Tilt.PitchRange) _z = iy;
_y = 0xFF - iz;
}
// Direct mapping for swing, from analog stick to accelerometer
if (!WiiMapping[g_ID].Tilt.RollRange)
{
_x -= _TiltData.Roll;
}
if (!WiiMapping[g_ID].Tilt.PitchRange)
{
if (!WiiMapping[g_ID].bUpright)
_z -= _TiltData.Pitch;
else // Upright wiimote
_y += _TiltData.Pitch;
}
}
// Rotate IR dot when rolling Wiimote
void RotateIRDot(int &_x, int &_y, STiltData &_TiltData)
{
if (!WiiMapping[g_ID].Tilt.RollRange || !_TiltData.Roll)
return;
// The IR camera resolution is 1023x767
float dot_x = _x - 1023.0f / 2;
float dot_y = _y - 767.0f / 2;
float radius = sqrt(pow(dot_x, 2) + pow(dot_y, 2));
float radian = atan2(dot_y, dot_x);
_x = (int)(radius * cos(radian + InputCommon::Deg2Rad((float)_TiltData.Roll)) + 1023.0f / 2);
_y = (int)(radius * sin(radian + InputCommon::Deg2Rad((float)_TiltData.Roll)) + 767.0f / 2);
// Out of sight check
if (_x < 0 || _x > 1023) _x = 0xFFFF;
if (_y < 0 || _y > 767) _y = 0xFFFF;
}
} // WiiMoteEmu

View File

@ -1,731 +0,0 @@
// 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 <vector>
#include <string>
#include "Common.h" // Common
#include "StringUtil.h" // for ArrayToString()
#include "IniFile.h"
#include "pluginspecs_wiimote.h"
#include "EmuDefinitions.h" // Local
#include "main.h"
#include "wiimote_hid.h"
#include "EmuSubroutines.h"
#include "EmuMain.h"
#include "Encryption.h" // for extension encryption
#include "Config.h" // for g_Config
extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteEmu
{
// Settings
accel_cal g_wm;
nu_cal g_nu;
mp_cal g_mp[2]; //fast[0] and slow[01]-motion
cc_cal g_ClassicContCalibration;
gh3_cal g_GH3Calibration;
bool g_EmulatedWiiMoteInitialized = false;
/* Homebrew encryption for 16 byte zero keys. */
void CryptBuffer(u8* _buffer, u8 _size)
{
for (int i=0; i<_size; i++)
{
_buffer[i] = ((_buffer[i] - 0x17) ^ 0x17) & 0xFF;
}
}
void WriteCrypted16(u8* _baseBlock, u16 _address, u16 _value)
{
u16 cryptedValue = _value;
CryptBuffer((u8*)&cryptedValue, sizeof(u16));
*(u16*)(_baseBlock + _address) = cryptedValue;
}
/* Calculate Extenstion Regisister Calibration Checksum */
// This function is not currently used, it's just here to show how the values
// in EmuDefinitions.h are calculated.
void GetCalibrationChecksum()
{
u8 sum = 0;
for (u32 i = 0; i < sizeof(nunchuck_calibration) - 2; i++)
sum += nunchuck_calibration[i];
INFO_LOG(WIIMOTE, "0x%02x 0x%02x", (sum + 0x55), (sum + 0xaa));
}
// Calculate checksum for the nunchuck calibration. The last two bytes.
void ExtensionChecksum(u8 * Calibration)
{
u8 sum = 0; //u8 Byte15, Byte16;
for (u32 i = 0; i < sizeof(Calibration) - 2; i++)
{
sum += Calibration[i];
//INFO_LOG(WIIMOTE, "Plus 0x%02x", Calibration[i]);
}
// Byte15 = sum + 0x55; // Byte 15
// Byte16 = sum + 0xaa; // Byte 16
}
/* Bit shift conversions */
u32 convert24bit(const u8* src) {
return (src[0] << 16) | (src[1] << 8) | src[2];
}
u16 convert16bit(const u8* src) {
return (src[0] << 8) | src[1];
}
/* Load pre-recorded movements */
void LoadRecordedMovements()
{
INFO_LOG(WIIMOTE, "LoadRecordedMovements()");
IniFile file;
file.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "WiimoteMovement.ini").c_str());
for(int i = 0; i < RECORDING_ROWS; i++)
{
//INFO_LOG(WIIMOTE, "Recording%i ", i + 1);
// Temporary storage
int iTmp;
std::string STmp;
// First clear the list
VRecording.at(i).Recording.clear();
// Get row name
std::string SaveName = StringFromFormat("Recording%i", i + 1);
// Get movement
std::string TmpMovement; file.Get(SaveName.c_str(), "Movement", &TmpMovement, "");
// Get IR
std::string TmpIR; file.Get(SaveName.c_str(), "IR", &TmpIR, "");
// Get time
std::string TmpTime; file.Get(SaveName.c_str(), "Time", &TmpTime, "");
// Get IR bytes
int TmpIRBytes; file.Get(SaveName.c_str(), "IRBytes", &TmpIRBytes, 0);
VRecording.at(i).IRBytes = TmpIRBytes;
SRecording Tmp;
for (int j = 0, k = 0, l = 0; (u32)j < TmpMovement.length(); j+=13)
{
// Skip blank savings
if (TmpMovement.length() < 3) continue;
// Avoid going to far, this can only happen with modified ini files, but we check for it anyway
if (TmpMovement.length() < (u32)j + 12) continue;
// Skip old style recordings
if (TmpMovement.substr(j, 1) != "-" && TmpMovement.substr(j, 1) != "+") continue;
std::string StrX = TmpMovement.substr(j, 4);
std::string StrY = TmpMovement.substr(j + 4, 4);
std::string StrZ = TmpMovement.substr(j + 8, 4);
Tmp.x = atoi(StrX.c_str());
Tmp.y = atoi(StrY.c_str());
Tmp.z = atoi(StrZ.c_str());
// Go to next set of IR values
// If there is no IR data saving we fill the array with
// zeroes. This should only be able to occur from manual ini
// editing but we check for it anyway
for(int ii = 0; ii < TmpIRBytes; ii++)
{
if(TmpIR.length() < (u32)(k + i + TmpIRBytes)) continue; // Safety check
std::string TmpStr = TmpIR.substr(k + ii*2, 2);
u32 TmpU32;
AsciiToHex(TmpStr.c_str(), TmpU32);
Tmp.IR[ii] = (u8)TmpU32;
}
if (TmpIRBytes == 10) k += (10*2 + 1); else k += (12*2 + 1);
// Go to next set of time values
double Time = (double)atoi(TmpTime.substr(l, 5).c_str());
Tmp.Time = (double)(Time/1000);
l += 6;
// Save the values
VRecording.at(i).Recording.push_back(Tmp);
// Log results
/*INFO_LOG(WIIMOTE, "Time:%f", Tmp.Time);
std::string TmpIRLog = ArrayToString(Tmp.IR, TmpIRBytes, 0, 30);
INFO_LOG(WIIMOTE, "IR: %s", TmpIRLog.c_str());
INFO_LOG(WIIMOTE, "");*/
}
// Get HotKey
file.Get(SaveName.c_str(), "HotKeySwitch", &iTmp, 3); VRecording.at(i).HotKeySwitch = iTmp;
file.Get(SaveName.c_str(), "HotKeyWiimote", &iTmp, 10); VRecording.at(i).HotKeyWiimote = iTmp;
file.Get(SaveName.c_str(), "HotKeyNunchuck", &iTmp, 10); VRecording.at(i).HotKeyNunchuck = iTmp;
file.Get(SaveName.c_str(), "HotKeyIR", &iTmp, 10); VRecording.at(i).HotKeyIR = iTmp;
// Get Recording speed
int TmpPlaybackSpeed; file.Get(SaveName.c_str(), "PlaybackSpeed", &TmpPlaybackSpeed, -1);
VRecording.at(i).PlaybackSpeed = TmpPlaybackSpeed;
// Logging
/*std::string TmpIRLog;
if(TmpIRBytes > 0 && VRecording.size() > i)
TmpIRLog = ArrayToString(VRecording.at(i).Recording.at(0).IR, TmpIRBytes, 0, 30);
else
TmpIRLog = "";
INFO_LOG(WIIMOTE, "Size:%i HotKey:%i PlSpeed:%i IR:%s X:%i Y:%i Z:%i",
VRecording.at(i).Recording.size(), VRecording.at(i).HotKeyWiimote, VRecording.at(i).PlaybackSpeed,
TmpIRLog.c_str(),
VRecording.at(i).Recording.at(0).x, VRecording.at(i).Recording.at(0).y, VRecording.at(i).Recording.at(0).z
);*/
}
}
/* Calibrate the mouse position to the emulation window. g_WiimoteInitialize.hWnd is the rendering window handle. */
void GetMousePos(float& x, float& y)
{
#ifdef _WIN32
POINT point;
// Get the cursor position for the entire screen
GetCursorPos(&point);
// Get the cursor position relative to the upper left corner of the rendering window
ScreenToClient((HWND)g_WiimoteInitialize.hWnd, &point);
// Get the size of the rendering window. (In my case Rect.top and Rect.left was zero.)
RECT Rect;
GetClientRect((HWND)g_WiimoteInitialize.hWnd, &Rect);
// Width and height is the size of the rendering window
float WinWidth = (float)(Rect.right - Rect.left);
float WinHeight = (float)(Rect.bottom - Rect.top);
float XOffset = 0, YOffset = 0;
float PictureWidth = WinWidth, PictureHeight = WinHeight;
#else
#if defined(HAVE_X11) && HAVE_X11
float WinWidth = 0, WinHeight = 0;
float XOffset = 0, YOffset = 0;
int root_x, root_y, win_x, win_y;
if (IsFocus())
{
Window GLWin = (Window)g_WiimoteInitialize.hWnd;
XWindowAttributes WinAttribs;
XGetWindowAttributes (WMdisplay, GLWin, &WinAttribs);
WinWidth = (float)WinAttribs.width;
WinHeight = (float)WinAttribs.height;
Window rootDummy, childWin;
unsigned int mask;
XQueryPointer(WMdisplay, GLWin, &rootDummy, &childWin, &root_x, &root_y, &win_x, &win_y, &mask);
}
float PictureWidth = WinWidth, PictureHeight = WinHeight;
#endif
#endif
#if defined(_WIN32) || (defined(HAVE_X11) && HAVE_X11)
/* Calculate the actual picture size and location */
// Output: PictureWidth, PictureHeight, XOffset, YOffset
if (g_Config.bKeepAR43 || g_Config.bKeepAR169)
{
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
float Ratio = WinWidth / WinHeight / (g_Config.bKeepAR43 ? (4.0f / 3.0f) : (16.0f / 9.0f));
// Check if height or width is the limiting factor. If ratio > 1 the picture is to wide and have to limit the width.
if (Ratio > 1)
{
// Calculate the new width and height for glViewport, this is not the actual size of either the picture or the screen
PictureWidth = WinWidth / Ratio;
// Calculate the new X offset
// Move the left of the picture to the middle of the screen
XOffset = XOffset + WinWidth / 2.0f;
// Then remove half the picture height to move it to the horizontal center
XOffset = XOffset - PictureWidth / 2.0f;
}
// The window is to high, we have to limit the height
else
{
// Calculate the new width and height for glViewport, this is not the actual size of either the picture or the screen
// Invert the ratio to make it > 1
Ratio = 1.0f / Ratio;
PictureHeight = WinHeight / Ratio;
// Calculate the new Y offset
// Move the top of the picture to the middle of the screen
YOffset = YOffset + WinHeight / 2.0f;
// Then remove half the picture height to move it to the vertical center
YOffset = YOffset - PictureHeight / 2.0f;
}
/*
INFO_LOG(WIIMOTE, "Screen Width:%4.0f Height:%4.0f Ratio:%1.2f", WinWidth, WinHeight, Ratio);
INFO_LOG(WIIMOTE, "Picture Width:%4.1f Height:%4.1f YOffset:%4.0f XOffset:%4.0f", PictureWidth, PictureHeight, YOffset, XOffset);
*/
}
// Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.
// Output: PictureWidth, PictureHeight, XOffset, YOffset
if ((g_Config.bKeepAR43 || g_Config.bKeepAR169) && g_Config.bCrop)
{
float Ratio = g_Config.bKeepAR43 ? ((4.0f / 3.0f) / (5.0f / 4.0f)) : (((16.0f / 9.0f) / (16.0f / 10.0f)));
// The width and height we will add (calculate this before PictureWidth and PictureHeight is adjusted)
float IncreasedWidth = (Ratio - 1.0f) * PictureWidth;
float IncreasedHeight = (Ratio - 1.0f) * PictureHeight;
// The new width and height
PictureWidth = PictureWidth * Ratio;
PictureHeight = PictureHeight * Ratio;
// Adjust the X and Y offset
XOffset = float(XOffset - (IncreasedWidth / 2.0));
YOffset = float(YOffset - (IncreasedHeight / 2.0));
/*
INFO_LOG(WIIMOTE, "Crop Ratio:%1.2f IncrWidth:%3.0f IncrHeight:%3.0f", Ratio, IncreasedWidth, IncreasedHeight);
INFO_LOG(WIIMOTE, "Picture Width:%4.1f Height:%4.1f YOffset:%4.0f XOffset:%4.0f", PictureWidth, PictureHeight, YOffset, XOffset);
*/
}
#endif
// Return the mouse position as a fraction of one, inside the picture, with (0.0, 0.0) being the upper left corner of the picture
#ifdef _WIN32
x = ((float)point.x - XOffset) / PictureWidth;
y = ((float)point.y - YOffset) / PictureHeight;
/*
INFO_LOG(WIIMOTE, "GetCursorPos: %i %i", point.x, point.y);
INFO_LOG(WIIMOTE, "GetClientRect: %i %i %i %i", Rect.left, Rect.right, Rect.top, Rect.bottom);
INFO_LOG(WIIMOTE, "Position X:%1.2f Y:%1.2f", x, y);
*/
#else
#if defined(HAVE_X11) && HAVE_X11
x = ((float)win_x - XOffset) / PictureWidth;
y = ((float)win_y - YOffset) / PictureHeight;
#endif
#endif
}
/* This is not needed if we call FreeLibrary() when we stop a game, but if it's
not called we need to reset these variables. */
void Shutdown()
{
INFO_LOG(WIIMOTE, "ShutDown");
ResetVariables();
// We can't close it here or it might crash
// because the joystick could have been closed already in GCPad
// But there is no easy way to know the situation of another DLL
// So we just skip the close procedure here
/*
// Close joypads
Close_Devices();
// Finally close SDL
if (SDL_WasInit(0))
SDL_Quit();
*/
for (int i=0; i<MAX_WIIMOTES; i++)
{
if (WiiMapping[i].UDPWM.instance)
delete WiiMapping[i].UDPWM.instance;
}
g_SearchDeviceDone = false;
}
// Start emulation
void Initialize()
{
INFO_LOG(WIIMOTE, "Initialize");
// Reset variables
ResetVariables();
/* Populate joyinfo for all attached devices and do g_Config.Load() if the
configuration window is not already open, if it's already open we
continue with the settings we have */
if(!g_SearchDeviceDone)
{
g_Config.Load();
Search_Devices(joyinfo, NumPads, NumGoodPads);
g_SearchDeviceDone = true;
}
InitCalibration();
for (int i = 0; i < MAX_WIIMOTES; i++)
{
// Write default Eeprom data to g_Eeprom[], this may be overwritten by
// WiiMoteReal::Initialize() after this function.
memset(g_Eeprom[i], 0, WIIMOTE_EEPROM_SIZE);
memcpy(g_Eeprom[i], EepromData_0, sizeof(EepromData_0));
memcpy(g_Eeprom[i] + 0x16D0, EepromData_16D0, sizeof(EepromData_16D0));
// Copy extension id and calibration to its register, g_Config.Load() is needed before this
UpdateExtRegisterBlocks(i);
if (WiiMapping[i].UDPWM.enable)
WiiMapping[i].UDPWM.instance=new UDPWiimote(WiiMapping[i].UDPWM.port);
else
WiiMapping[i].UDPWM.instance=NULL;
}
// The emulated Wiimote is initialized
g_EmulatedWiiMoteInitialized = true;
// Load pre-recorded movements
LoadRecordedMovements();
/* The Nuncheck extension ID for homebrew applications that use the zero
key. This writes 0x0000 in encrypted form (0xfefe) to 0xfe in the
extension register. */
//WriteCrypted16(g_RegExt, 0xfe, 0x0000); // Fully inserted Nunchuk
// I forgot what these were for? Is this the zero key encrypted 0xa420?
// g_RegExt[0xfd] = 0x1e;
// g_RegExt[0xfc] = 0x9a;
}
// Set initial valuesm this done both in Init and Shutdown
void ResetVariables()
{
g_EmulatedWiiMoteInitialized = false;
g_ID = 0;
g_Encryption = false;
for (int i = 0; i < MAX_WIIMOTES; i++)
{
g_ReportingAuto[i] = false;
g_MotionPlusLastWriteReg[i] = 0;
g_InterleavedData[i] = false;
g_ReportingMode[i] = 0;
g_ReportingChannel[i] = 0;
WiiMapping[i].Motion.TiltWM.Shake = 0;
WiiMapping[i].Motion.TiltWM.Roll = 0;
WiiMapping[i].Motion.TiltWM.Pitch = 0;
WiiMapping[i].Motion.TiltNC.Shake = 0;
WiiMapping[i].Motion.TiltNC.Roll = 0;
WiiMapping[i].Motion.TiltNC.Pitch = 0;
}
// Set default recording values
#if defined(HAVE_WX) && HAVE_WX
for (int i = 0; i < 3; i++)
{
g_RecordingPlaying[i] = -1;
g_RecordingCounter[i] = 0;
g_RecordingPoint[i] = 0;
g_RecordingStart[i] = 0;
g_RecordingCurrentTime[i] = 0;
}
#endif
}
// Initiate the accelerometer neutral values
void InitCalibration()
{
g_wm.cal_zero.x = EepromData_0[22];
g_wm.cal_zero.y = EepromData_0[23];
g_wm.cal_zero.z = EepromData_0[24];
g_wm.cal_g.x = EepromData_0[26] - EepromData_0[22];
g_wm.cal_g.y = EepromData_0[27] - EepromData_0[23];
g_wm.cal_g.z = EepromData_0[28] - EepromData_0[24];
g_nu.cal_zero.x = nunchuck_calibration[0x00];
g_nu.cal_zero.y = nunchuck_calibration[0x01];
g_nu.cal_zero.z = nunchuck_calibration[0x02];
g_nu.cal_g.x = nunchuck_calibration[0x04] - nunchuck_calibration[0x00];
g_nu.cal_g.y = nunchuck_calibration[0x05] - nunchuck_calibration[0x01];
g_nu.cal_g.z = nunchuck_calibration[0x06] - nunchuck_calibration[0x02];
g_mp[0].cal_zero.x = ((motion_plus_calibration[0x00]<<6) + (motion_plus_calibration[0x01]>>2));
g_mp[0].cal_zero.y = ((motion_plus_calibration[0x02]<<6) + (motion_plus_calibration[0x03]>>2));
g_mp[0].cal_zero.z = ((motion_plus_calibration[0x04]<<6) + (motion_plus_calibration[0x05]>>2));
g_mp[1].cal_zero.x = ((motion_plus_calibration[0x10]<<6) + (motion_plus_calibration[0x11]>>2));
g_mp[1].cal_zero.y = ((motion_plus_calibration[0x12]<<6) + (motion_plus_calibration[0x13]>>2));
g_mp[1].cal_zero.z = ((motion_plus_calibration[0x14]<<6) + (motion_plus_calibration[0x15]>>2));
g_nu.jx.max = nunchuck_calibration[0x08];
g_nu.jx.min = nunchuck_calibration[0x09];
g_nu.jx.center = nunchuck_calibration[0x0a];
g_nu.jy.max = nunchuck_calibration[0x0b];
g_nu.jy.min = nunchuck_calibration[0x0c];
g_nu.jy.center = nunchuck_calibration[0x0d];
g_ClassicContCalibration.Lx.max = classic_calibration[0x00];
g_ClassicContCalibration.Lx.min = classic_calibration[0x01];
g_ClassicContCalibration.Lx.center = classic_calibration[0x02];
g_ClassicContCalibration.Ly.max = classic_calibration[0x03];
g_ClassicContCalibration.Ly.min = classic_calibration[0x04];
g_ClassicContCalibration.Ly.center = classic_calibration[0x05];
g_ClassicContCalibration.Rx.max = classic_calibration[0x06];
g_ClassicContCalibration.Rx.min = classic_calibration[0x07];
g_ClassicContCalibration.Rx.center = classic_calibration[0x08];
g_ClassicContCalibration.Ry.max = classic_calibration[0x09];
g_ClassicContCalibration.Ry.min = classic_calibration[0x0a];
g_ClassicContCalibration.Ry.center = classic_calibration[0x0b];
g_ClassicContCalibration.Tl.neutral = classic_calibration[0x0c];
g_ClassicContCalibration.Tr.neutral = classic_calibration[0x0d];
// TODO get the correct values here
g_GH3Calibration.Lx.max = classic_calibration[0x00];
g_GH3Calibration.Lx.min = classic_calibration[0x01];
g_GH3Calibration.Lx.center = classic_calibration[0x02];
g_GH3Calibration.Ly.max = classic_calibration[0x03];
g_GH3Calibration.Ly.min = classic_calibration[0x04];
g_GH3Calibration.Ly.center = classic_calibration[0x05];
}
// Update the extension calibration values with our default values
void UpdateExtRegisterBlocks(int Slot)
{
if (WiiMapping[Slot].bMotionPlusConnected)
{
// Copy extension id and calibration to its register
if (WiiMapping[Slot].iExtensionConnected == EXT_NONE)
{
memset(g_RegExt[Slot],0,sizeof(g_RegExt[0]));
memcpy(g_RegExt[Slot] + 0x20, motion_plus_calibration, sizeof(motion_plus_calibration));
memset(g_RegExt[Slot] + 0x40, 0xFF, sizeof(nunchuck_calibration));
memcpy(g_RegExt[Slot] + 0x50, motionplus_accel_gyro_syncing, sizeof(motionplus_accel_gyro_syncing));
memcpy(g_RegExt[Slot] + 0xf0, motionplus_activeflags, sizeof(motionplus_activeflags));
memcpy(g_RegExt[Slot] + 0xfa, motionplus_id, sizeof(motionplus_id));
}
else if(WiiMapping[Slot].iExtensionConnected == EXT_NUNCHUK)
{
memset(g_RegExt[Slot],0,sizeof(g_RegExt[0]));
memset(g_RegMotionPlus[Slot],0,sizeof(g_RegMotionPlus[0]));
memcpy(g_RegExt[Slot] + 0x20, nunchuck_calibration, sizeof(nunchuck_calibration));
memcpy(g_RegExt[Slot] + 0x30, nunchuck_calibration, sizeof(nunchuck_calibration));
memcpy(g_RegExt[Slot] + 0xfa, nunchuck_id, sizeof(nunchuck_id));
memcpy(g_RegMotionPlus[Slot] + 0x20, motion_plus_calibration, sizeof(motion_plus_calibration));
memcpy(g_RegMotionPlus[Slot] + 0x40, nunchuck_calibration, sizeof(nunchuck_calibration));
memcpy(g_RegMotionPlus[Slot] + 0x50, motionplus_accel_gyro_syncing, sizeof(motionplus_accel_gyro_syncing));
memcpy(g_RegMotionPlus[Slot] + 0xf0, motionplus_activeflags, sizeof(motionplus_activeflags));
memcpy(g_RegMotionPlus[Slot] + 0xfa, motionplusnunchuk_id, sizeof(motionplusnunchuk_id));
}
g_MotionPlus[Slot] = (WiiMapping[Slot].iExtensionConnected) ? 0 : 1;
} else
{
// Copy extension id and calibration to its register
if(WiiMapping[Slot].iExtensionConnected == EXT_NUNCHUK)
{
memcpy(g_RegExt[Slot] + 0x20, nunchuck_calibration, sizeof(nunchuck_calibration));
memcpy(g_RegExt[Slot] + 0x30, nunchuck_calibration, sizeof(nunchuck_calibration));
memcpy(g_RegExt[Slot] + 0xfa, nunchuck_id, sizeof(nunchuck_id));
}
else if(WiiMapping[Slot].iExtensionConnected == EXT_CLASSIC_CONTROLLER)
{
memcpy(g_RegExt[Slot] + 0x20, classic_calibration, sizeof(classic_calibration));
memcpy(g_RegExt[Slot] + 0x30, classic_calibration, sizeof(classic_calibration));
memcpy(g_RegExt[Slot] + 0xfa, classic_id, sizeof(classic_id));
}
else if(WiiMapping[Slot].iExtensionConnected == EXT_GUITARHERO)
{
// TODO get the correct values here
memcpy(g_RegExt[Slot] + 0x20, classic_calibration, sizeof(classic_calibration));
memcpy(g_RegExt[Slot] + 0x30, classic_calibration, sizeof(classic_calibration));
memcpy(g_RegExt[Slot] + 0xfa, gh3glp_id, sizeof(gh3glp_id));
}
else if(WiiMapping[Slot].iExtensionConnected == EXT_WBB)
{
// TODO
}
}
INFO_LOG(WIIMOTE, "UpdateExtRegisterBlocks()");
}
void DoState(PointerWrap &p)
{
// TODO: Shorten the list
p.DoArray(&g_Eeprom[0][0], WIIMOTE_EEPROM_SIZE * MAX_WIIMOTES);
p.DoArray(&g_RegExt[0][0], WIIMOTE_REG_EXT_SIZE * MAX_WIIMOTES);
p.DoArray(&g_RegMotionPlus[0][0], WIIMOTE_REG_EXT_SIZE * MAX_WIIMOTES);
p.DoArray(&g_RegSpeaker[0][0], WIIMOTE_REG_SPEAKER_SIZE * MAX_WIIMOTES);
p.DoArray(&g_RegIr[0][0], WIIMOTE_REG_IR_SIZE * MAX_WIIMOTES);
//p.DoArray(g_RegExtTmp, WIIMOTE_REG_EXT_SIZE);
p.Do(g_Encryption);
//p.Do(NumPads);
//p.Do(NumGoodPads);
//p.Do(joyinfo);
//p.DoArray(PadState, 4);
//p.DoArray(PadMapping, 4);
//p.Do(g_Wiimote_kbd);
//p.Do(g_NunchuckExt);
//p.Do(g_ClassicContExt);
for (int i = 0; i < MAX_WIIMOTES; i++)
{
p.Do(g_ReportingAuto[i]);
p.Do(g_ReportingMode[i]);
p.Do(g_ReportingChannel[i]);
//p.Do(g_IRClock[i]);
p.Do(g_IR[i]);
p.Do(g_Leds[i]);
p.Do(g_Speaker[i]);
//p.Do(g_MotionPlus[i]);
//p.Do(g_SpeakerMute[i]);
p.Do(g_ExtKey[i]);
}
return;
}
/* This function produce Wiimote Input, i.e. reports from the Wiimote in
response to Output from the Wii. */
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
{
g_ID = _number;
hid_packet* hidp = (hid_packet*)_pData;
INFO_LOG(WIIMOTE, "Emu InterruptChannel (page: %i, type: 0x%02x, param: 0x%02x)", _number, hidp->type, hidp->param);
switch(hidp->type)
{
case HID_TYPE_DATA:
{
switch(hidp->param)
{
case HID_PARAM_OUTPUT:
{
wm_report* sr = (wm_report*)hidp->data;
HidOutputReport(_channelID, sr);
/* This is the 0x22 answer to all Inputs.*/
// There are no 0x22 replys to these report from the real
// wiimote from what I could see Report 0x10 that seems to
// be only used for rumble, and we don't need to answer
// that
// The rumble report still needs more investigation
}
break;
default:
PanicAlert("HidInput: HID_TYPE_DATA - param 0x%02x", hidp->type, hidp->param);
break;
}
}
break;
default:
PanicAlert("HidInput: Unknown type 0x%02x and param 0x%02x", hidp->type, hidp->param);
break;
}
}
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
{
g_ID = _number;
hid_packet* hidp = (hid_packet*)_pData;
INFO_LOG(WIIMOTE, "Emu ControlChannel (page: %i, type: 0x%02x, param: 0x%02x)", _number, hidp->type, hidp->param);
switch(hidp->type)
{
case HID_TYPE_HANDSHAKE:
PanicAlert("HID_TYPE_HANDSHAKE - %s", (hidp->param == HID_PARAM_INPUT) ? "INPUT" : "OUPUT");
break;
case HID_TYPE_SET_REPORT:
if (hidp->param == HID_PARAM_INPUT)
{
PanicAlert("HID_TYPE_SET_REPORT - INPUT");
}
else
{
// AyuanX: My experiment shows Control Channel is never used
// shuffle2: but lwbt uses this, so we'll do what we must :)
HidOutputReport(_channelID, (wm_report*)hidp->data);
u8 handshake = HID_HANDSHAKE_SUCCESS;
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, &handshake, 1);
}
break;
case HID_TYPE_DATA:
PanicAlert("HID_TYPE_DATA - %s", (hidp->param == HID_PARAM_INPUT) ? "INPUT" : "OUTPUT");
break;
default:
PanicAlert("HidControlChannel: Unknown type %x and param %x", hidp->type, hidp->param);
break;
}
}
/* This is called from Wiimote_Update(). See SystemTimers.cpp for a
documentation. I'm not sure exactly how often this function is called but I
think it's tied to the frame rate of the game rather than a certain amount
of times per second. */
void Update(int _number)
{
if (g_ReportingAuto[_number] == false)
return;
g_ID = _number;
// Read input or not
if (WiiMapping[g_ID].Source == 1)
{
// Check if the pad state should be updated
if (NumGoodPads > 0 && joyinfo.size() > (u32)WiiMapping[g_ID].ID)
UpdatePadState(WiiMapping[g_ID]);
}
switch(g_ReportingMode[g_ID])
{
case 0:
break;
case WM_REPORT_CORE:
SendReportCore(g_ReportingChannel[g_ID]);
break;
case WM_REPORT_CORE_ACCEL:
SendReportCoreAccel(g_ReportingChannel[g_ID]);
break;
case WM_REPORT_CORE_ACCEL_IR12:
SendReportCoreAccelIr12(g_ReportingChannel[g_ID]);
break;
case WM_REPORT_CORE_ACCEL_EXT16:
SendReportCoreAccelExt16(g_ReportingChannel[g_ID]);
break;
case WM_REPORT_CORE_ACCEL_IR10_EXT6:
SendReportCoreAccelIr10Ext(g_ReportingChannel[g_ID]);
break;
}
}
} // end of namespace

View File

@ -1,89 +0,0 @@
// 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_EMU_H
#define WIIMOTE_EMU_H
#include <string>
#include "wiimote_hid.h"
#include "EmuDefinitions.h"
#include "ChunkFile.h"
namespace WiiMoteEmu
{
// TODO: those are only used with Emulated wiimote.
// if it were a class, we didn't need the extern here.
// Settings
extern accel_cal g_wm;
extern nu_cal g_nu;
extern mp_cal g_mp[2];
extern cc_cal g_ClassicContCalibration;
extern gh3_cal g_GH3Calibration;
u32 convert24bit(const u8* src);
u16 convert16bit(const u8* src);
// General functions
void ResetVariables();
void Initialize();
void Shutdown();
void InitCalibration();
void UpdateExtRegisterBlocks(int Slot);
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size) ;
void Update(int _number);
void DoState(PointerWrap &p);
bool IsKey(int Key);
// Recordings
void LoadRecordedMovements();
void GetMousePos(float& x, float& y);
// Gamepad
void Close_Devices();
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads);
void GetAxisState(CONTROLLER_MAPPING_WII &_WiiMapping);
void UpdatePadState(CONTROLLER_MAPPING_WII &_WiiMapping);
void TiltWiimote(int &_x, int &_y, int &_z);
void TiltNunchuck(int &_x, int &_y, int &_z);
void ShakeToAccelerometer(int &_x, int &_y, int &_z, STiltData &_TiltData);
void TiltToAccelerometer(int &_x, int &_y, int &_z, STiltData &_TiltData);
void AdjustAngles(int &Roll, int &Pitch);
void RotateIRDot(int &_x, int &_y, STiltData &_TiltData);
// Accelerometer
//void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, int&, int&);
//float AccelerometerToG(float Current, float Neutral, float G);
// IR data
//void IRData2Dots(u8 *Data);
//void IRData2DotsBasic(u8 *Data);
//void ReorderIRDots();
//void IRData2Distance();
// Classic Controller data
//std::string CCData2Values(u8 *Data);
}; // WiiMoteEmu
#endif

View File

@ -1,209 +0,0 @@
// 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 <vector>
#include <string>
#include "Common.h" // Common
#include "StringUtil.h" // for ArrayToString()
#include "IniFile.h"
#include "pluginspecs_wiimote.h"
#include "EmuDefinitions.h" // Local
#include "main.h"
#include "wiimote_hid.h"
#include "EmuSubroutines.h"
#include "EmuMain.h"
#include "Encryption.h" // for extension encryption
#include "Config.h" // for g_Config
#ifdef _WIN32
#include "XInput.h"
#endif
extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteEmu
{
extern void PAD_RumbleClose();
// Close joypads
void Close_Devices()
{
PAD_RumbleClose();
// Close all devices carefully. We must check that we are not accessing any
// undefined vector elements or any bad devices
if (SDL_WasInit(0))
{
for (int i = 0; i < NumPads; i++)
{
if (joyinfo.at(i).joy)
{
if(SDL_JoystickOpened(i))
{
INFO_LOG(WIIMOTE, "Shut down Joypad: %i", i);
SDL_JoystickClose(joyinfo.at(i).joy);
}
}
}
}
for (int i = 0; i < MAX_WIIMOTES; i++)
WiiMapping[i].joy = NULL;
// Clear the physical device info
joyinfo.clear();
NumPads = 0;
NumGoodPads = 0;
}
// Fill joyinfo with the current connected devices
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
{
// Close opened pad first
Close_Devices();
bool WasGotten = InputCommon::SearchDevices(_joyinfo, _NumPads, _NumGoodPads);
if (_NumGoodPads == 0)
return false;
for (int i = 0; i < MAX_WIIMOTES; i++)
{
if (_NumPads > WiiMapping[i].ID)
if(_joyinfo.at(WiiMapping[i].ID).Good)
{
WiiMapping[i].joy = _joyinfo.at(WiiMapping[i].ID).joy;
#ifdef _WIN32
XINPUT_STATE xstate;
DWORD xresult = XInputGetState(WiiMapping[i].ID, &xstate);
if (xresult == ERROR_SUCCESS)
WiiMapping[i].TriggerType = InputCommon::CTL_TRIGGER_XINPUT;
#endif
}
}
return WasGotten;
}
// Request joystick state
/* Called from: PAD_GetStatus() Input: The virtual device 0, 1, 2 or 3
Function: Updates the PadState struct with the current pad status. The input
value "controller" is for a virtual controller 0 to 3. */
void GetAxisState(CONTROLLER_MAPPING_WII &_WiiMapping)
{
// Update the gamepad status
SDL_JoystickUpdate();
// Update axis states. It doesn't hurt much if we happen to ask for nonexisting axises here.
_WiiMapping.AxisState.Lx = SDL_JoystickGetAxis(_WiiMapping.joy, _WiiMapping.AxisMapping.Lx);
_WiiMapping.AxisState.Ly = SDL_JoystickGetAxis(_WiiMapping.joy, _WiiMapping.AxisMapping.Ly);
_WiiMapping.AxisState.Rx = SDL_JoystickGetAxis(_WiiMapping.joy, _WiiMapping.AxisMapping.Rx);
_WiiMapping.AxisState.Ry = SDL_JoystickGetAxis(_WiiMapping.joy, _WiiMapping.AxisMapping.Ry);
// Update the analog trigger axis values
#ifdef _WIN32
if (_WiiMapping.TriggerType == InputCommon::CTL_TRIGGER_SDL)
{
#endif
// If we are using SDL analog triggers the buttons have to be mapped as 1000 or up, otherwise they are not used
// We must also check that we are not asking for a negative axis number because SDL_JoystickGetAxis() has
// no good way of handling that
if ((_WiiMapping.AxisMapping.Tl - 1000) >= 0)
_WiiMapping.AxisState.Tl = SDL_JoystickGetAxis(_WiiMapping.joy, _WiiMapping.AxisMapping.Tl - 1000);
if ((_WiiMapping.AxisMapping.Tr - 1000) >= 0)
_WiiMapping.AxisState.Tr = SDL_JoystickGetAxis(_WiiMapping.joy, _WiiMapping.AxisMapping.Tr - 1000);
#ifdef _WIN32
}
else
{
_WiiMapping.AxisState.Tl = XInput::GetXI(_WiiMapping.ID, _WiiMapping.AxisMapping.Tl - 1000);
_WiiMapping.AxisState.Tr = XInput::GetXI(_WiiMapping.ID, _WiiMapping.AxisMapping.Tr - 1000);
}
#endif
/* Debugging
// Console::ClearScreen();
DEBUG_LOG(CONSOLE,
"Controller and handle: %i %i\n"
"Triggers:%i %i %i %i %i\n"
"Analog:%06i %06i \n",
controller, (int)_PadState.joy,
_PadMapping.triggertype,
_PadMapping.Axis.Tl, _PadMapping.Axis.Tr,
_PadState.Axis.Tl, _PadState.Axis.Tr,
_PadState.Axis.Lx, _PadState.Axis.Ly
);*/
}
void UpdatePadState(CONTROLLER_MAPPING_WII &_WiiMapping)
{
// Return if we have no pads
if (NumGoodPads == 0) return;
GetAxisState(_WiiMapping);
int &Lx = _WiiMapping.AxisState.Lx;
int &Ly = _WiiMapping.AxisState.Ly;
int &Rx = _WiiMapping.AxisState.Rx;
int &Ry = _WiiMapping.AxisState.Ry;
int &Tl = _WiiMapping.AxisState.Tl;
int &Tr = _WiiMapping.AxisState.Tr;
// Check the circle to square option
if(_WiiMapping.bCircle2Square)
{
InputCommon::Square2Circle(Lx, Ly, _WiiMapping.Diagonal, true);
InputCommon::Square2Circle(Rx, Ry, _WiiMapping.Diagonal, true);
}
// Dead zone adjustment
float DeadZoneLeft = (float)_WiiMapping.DeadZoneL / 100.0f;
float DeadZoneRight = (float)_WiiMapping.DeadZoneR / 100.0f;
if (InputCommon::IsDeadZone(DeadZoneLeft, Lx, Ly))
{
Lx = 0;
Ly = 0;
}
if (InputCommon::IsDeadZone(DeadZoneRight, Rx, Ry))
{
Rx = 0;
Ry = 0;
}
// Downsize the values from 0x8000 to 0x80
Lx = InputCommon::Pad_Convert(Lx);
Ly = InputCommon::Pad_Convert(Ly);
Rx = InputCommon::Pad_Convert(Rx);
Ry = InputCommon::Pad_Convert(Ry);
// The XInput range is already 0 to 0x80
if (_WiiMapping.TriggerType == InputCommon::CTL_TRIGGER_SDL)
{
Tl = InputCommon::Pad_Convert(Tl);
Tr = InputCommon::Pad_Convert(Tr);
}
}
} // end of namespace WiiMoteEmu

View File

@ -1,717 +0,0 @@
// 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/
/* HID reports access guide. */
/* 0x10 - 0x1a Output EmuMain.cpp: HidOutputReport()
0x10 - 0x14: General
0x15: Status report request from the Wii
0x16 and 0x17: Write and read memory or registers
0x19 and 0x1a: General
0x20 - 0x22 Input EmuMain.cpp: HidOutputReport() to the destination
0x15 leads to a 0x20 Input report
0x17 leads to a 0x21 Input report
0x10 - 0x1a leads to a 0x22 Input report
0x30 - 0x3f Input This file: Update() */
#include <vector>
#include <string>
#include "Common.h" // Common
#include "StringUtil.h"
#include "pluginspecs_wiimote.h"
#include "EmuMain.h" // Local
#include "EmuSubroutines.h"
#include "Config.h" // for g_Config
extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteEmu
{
extern void PAD_Rumble(u8 _numPAD, unsigned int _uType);
/* Here we process the Output Reports that the Wii sends. Our response will be
an Input Report back to the Wii. Input and Output is from the Wii's
perspective, Output means data to the Wiimote (from the Wii), Input means
data from the Wiimote.
The call browser:
1. Wiimote_InterruptChannel > InterruptChannel > HidOutputReport
2. Wiimote_ControlChannel > ControlChannel > HidOutputReport
The IR enable/disable and speaker enable/disable and mute/unmute values are
bit2: 0 = Disable (0x02), 1 = Enable (0x06)
*/
void HidOutputReport(u16 _channelID, wm_report* sr)
{
INFO_LOG(WIIMOTE, "HidOutputReport (page: %i, cid: 0x%02x, wm: 0x%02x)", g_ID, _channelID, sr->wm);
switch(sr->wm)
{
case WM_RUMBLE: // 0x10
PAD_Rumble(g_ID, sr->data[0]);
break;
case WM_LEDS: // 0x11
INFO_LOG(WIIMOTE, "Set LEDs: 0x%02x", sr->data[0]);
g_Leds[g_ID] = sr->data[0] >> 4;
break;
case WM_REPORT_MODE: // 0x12
WmReportMode(_channelID, (wm_report_mode*)sr->data);
break;
case WM_IR_PIXEL_CLOCK: // 0x13
INFO_LOG(WIIMOTE, "WM IR Clock: 0x%02x", sr->data[0]);
//g_IRClock[g_ID] = (sr->data[0] & 0x04) ? 1 : 0;
break;
case WM_SPEAKER_ENABLE: // 0x14
INFO_LOG(WIIMOTE, "WM Speaker Enable: 0x%02x", sr->data[0]);
g_Speaker[g_ID] = (sr->data[0] & 0x04) ? 1 : 0;
break;
case WM_REQUEST_STATUS: // 0x15
WmRequestStatus(_channelID, (wm_request_status*)sr->data);
break;
case WM_WRITE_DATA: // 0x16
WmWriteData(_channelID, (wm_write_data*)sr->data);
break;
case WM_READ_DATA: // 0x17
WmReadData(_channelID, (wm_read_data*)sr->data);
break;
case WM_WRITE_SPEAKER_DATA: // 0x18
// TODO: Does this need an ack?
break;
case WM_SPEAKER_MUTE: // 0x19
INFO_LOG(WIIMOTE, "WM Speaker Mute: 0x%02x", sr->data[0]);
//g_SpeakerMute[g_ID] = (sr->data[0] & 0x04) ? 1 : 0;
break;
case WM_IR_LOGIC: // 0x1a
// This enables or disables the IR lights, we update the global variable g_IR
// so that WmRequestStatus() knows about it
INFO_LOG(WIIMOTE, "WM IR Enable: 0x%02x", sr->data[0]);
g_IR[g_ID] = (sr->data[0] & 0x04) ? 1 : 0;
break;
default:
PanicAlert("HidOutputReport: Unknown channel 0x%02x", sr->wm);
return;
}
// Send general feedback except the following types
// as these ones generate their own feedbacks
// or don't send feedbacks
if ((sr->wm != WM_RUMBLE)
&& (sr->wm != WM_READ_DATA)
&& (sr->wm != WM_REQUEST_STATUS)
&& (sr->wm != WM_WRITE_SPEAKER_DATA)
)
{
WmSendAck(_channelID, sr->wm);
}
}
/* Generate the right header for wm reports. The returned values is the length
of the header before the data begins. It's always two for all reports 0x20 -
0x22, 0x30 - 0x37 */
int WriteWmReportHdr(u8* dst, u8 wm)
{
// Update the first byte to 0xa1
u32 Offset = 0;
hid_packet* pHidHeader = (hid_packet*)dst;
Offset += sizeof(hid_packet);
pHidHeader->type = HID_TYPE_DATA;
pHidHeader->param = HID_PARAM_INPUT;
// Update the second byte to the current report type 0x20 - 0x22, 0x30 - 0x37
wm_report* pReport = (wm_report*)(dst + Offset);
Offset += sizeof(wm_report);
pReport->wm = wm;
return Offset;
}
/* This will generate the 0x22 acknowledgement for most Input reports.
It has the form of "a1 22 00 00 _reportID 00".
The first two bytes are the core buttons data,
00 00 means nothing is pressed.
The last byte is the success code 00. */
void WmSendAck(u16 _channelID, u8 _reportID)
{
u8 DataFrame[1024];
// Write DataFrame header
u32 Offset = WriteWmReportHdr(DataFrame, WM_ACK_DATA);
wm_acknowledge* pData = (wm_acknowledge*)(DataFrame + Offset);
memset(pData, 0, sizeof(wm_acknowledge));
#if defined(HAVE_WX) && HAVE_WX
FillReportInfo(pData->buttons);
#endif
pData->reportID = _reportID;
pData->errorID = 0;
Offset += sizeof(wm_acknowledge);
DEBUG_LOG(WIIMOTE, "WMSendAck");
DEBUG_LOG(WIIMOTE, " Report ID: %02x", _reportID);
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
}
/* Read data from Wiimote and Extensions registers. */
void WmReadData(u16 _channelID, wm_read_data* rd)
{
u32 address = convert24bit(rd->address);
u16 size = convert16bit(rd->size);
u8 addressHI = (address >> 16) & 0xFE;
INFO_LOG(WIIMOTE, "Read data");
DEBUG_LOG(WIIMOTE, " Read data Space: %x", rd->space);
DEBUG_LOG(WIIMOTE, " Read data Address: 0x%06x", address);
DEBUG_LOG(WIIMOTE, " Read data Size: 0x%04x", size);
/* Now we determine what address space we are reading from. Space 0 is
Eeprom and space 1 and 2 are the registers. */
if(rd->space == WM_SPACE_EEPROM)
{
if (address + size > WIIMOTE_EEPROM_SIZE)
{
PanicAlert("WmReadData: address + size out of bounds");
return;
}
SendReadDataReply(_channelID, g_Eeprom[g_ID] + address, address, addressHI, (int)size);
/*DEBUG_LOG(WIIMOTE, "Read RegEeprom: Size: %i, Address: %08x, Offset: %08x",
size, address, (address & 0xffff));*/
}
else if(rd->space == WM_SPACE_REGS1 || rd->space == WM_SPACE_REGS2)
{
u8* block;
u32 blockSize;
switch(addressHI)
{
case 0xA2:
block = g_RegSpeaker[g_ID];
blockSize = WIIMOTE_REG_SPEAKER_SIZE;
DEBUG_LOG(WIIMOTE, " Case 0xa2: g_RegSpeaker");
break;
case 0xA4:
block = g_RegExt[g_ID];
blockSize = WIIMOTE_REG_EXT_SIZE;
DEBUG_LOG(WIIMOTE, " Case 0xa4: ExtReg");
break;
case 0xA6:
block = g_RegMotionPlus[g_ID];
blockSize = WIIMOTE_REG_EXT_SIZE;
DEBUG_LOG(WIIMOTE, " Case 0xa6: MotionPlusReg [%x]", address);
break;
case 0xB0:
block = g_RegIr[g_ID];
blockSize = WIIMOTE_REG_IR_SIZE;
DEBUG_LOG(WIIMOTE, " Case 0xb0: g_RegIr");
break;
default:
ERROR_LOG(WIIMOTE, "WmReadData: bad register block!");
PanicAlert("WmReadData: bad register block!");
return;
}
// Encrypt data that is read from the Wiimote Extension Register
if(addressHI == 0xa4)
{
// Check if encrypted reads is on
if(g_RegExt[g_ID][0xf0] == 0xaa)
{
/* Copy the registry to a temporary space. We don't want to change the unencrypted
data in the registry */
memcpy(g_RegExtTmp, g_RegExt[g_ID], sizeof(g_RegExt[0]));
// Encrypt g_RegExtTmp at that location
wiimote_encrypt(&g_ExtKey[g_ID], &g_RegExtTmp[address & 0xffff], (address & 0xffff), (u8)size);
// Update the block that SendReadDataReply will eventually send to the Wii
block = g_RegExtTmp;
}
}
address &= 0xFFFF;
if(address + size > blockSize)
{
PanicAlert("WmReadData: address + size out of bounds! [%d %d %d]", address, size, blockSize);
return;
}
// Let this function process the message and send it to the Wii
SendReadDataReply(_channelID, block + address, address, addressHI, (u8)size);
}
else
{
PanicAlert("WmReadData: unimplemented parameters (size: %i, addr: 0x%x)!", size, rd->space);
}
}
/* Here we produce the actual 0x21 Input report that we send to the Wii. The
message is divided into 16 bytes pieces and sent piece by piece. There will
be five formatting bytes at the begging of all reports. A common format is
00 00 f0 00 20, the 00 00 means that no buttons are pressed, the f means 16
bytes in the message, the 0 means no error, the 00 20 means that the message
is at the 00 20 offest in the registry that was read.
_Base: The data beginning at _Base[0]
_Address: The starting address inside the registry, this is used to check for out of bounds reading
_Size: The total size to send
*/
void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _AddressHI, int _Size)
{
int dataOffset = 0;
const u8* data = (const u8*)_Base;
while (_Size > 0)
{
u8 DataFrame[1024];
// Write the first two bytes to DataFrame
u32 Offset = WriteWmReportHdr(DataFrame, WM_READ_DATA_REPLY);
// Limit the size to 16 bytes
int copySize = (_Size > 16) ? 16 : _Size;
// AyuanX: the MTU is 640B though... what a waste!
wm_read_data_reply* pReply = (wm_read_data_reply*)(DataFrame + Offset);
memset(pReply,0,sizeof(wm_read_data_reply));
Offset += sizeof(wm_read_data_reply);
#if defined(HAVE_WX) && HAVE_WX
FillReportInfo(pReply->buttons);
#endif
pReply->error = 0;
// 0x1 means two bytes, 0xf means 16 bytes
pReply->size = copySize - 1;
pReply->address = Common::swap16(_Address + dataOffset);
// Clear the mem first
memset(pReply->data, 0, 16);
// Write a pice of _Base to DataFrame
memcpy(pReply->data, data + dataOffset, copySize);
// Update DataOffset for the next loop
dataOffset += copySize;
/* Out of bounds. The real Wiimote generate an error for the first
request to 0x1770 if we dont't replicate that the game will never
read the capibration data at the beginning of Eeprom. I think this
error is supposed to occur when we try to read above the freely
usable space that ends at 0x16ff. */
if (Common::swap16(pReply->address + pReply->size) > WIIMOTE_EEPROM_FREE_SIZE)
{
pReply->size = 0x0f;
pReply->error = 0x08;
}
if (WiiMapping[g_ID].bMotionPlusConnected)
{
//MP+ will try to read from this Registeraddress, expecting an error if a previous WM+ activation has been succesful
//It will also return an error if there was no WM+ present at all
if (((_Address == 0x00FE ) || (_Address == 0x00FF )) && (_AddressHI == 0xA6) && (g_RegExt[g_ID][0xFF] == 0x05))
{
pReply->size = 0x0f;
pReply->error = 0x07; //error: write-only area when activated/or not present
}
}
// Logging
DEBUG_LOG(WIIMOTE, "SendReadDataReply");
DEBUG_LOG(WIIMOTE, " Buttons: 0x%04x", pReply->buttons);
DEBUG_LOG(WIIMOTE, " Error: 0x%x", pReply->error);
DEBUG_LOG(WIIMOTE, " Size: 0x%x", pReply->size);
DEBUG_LOG(WIIMOTE, " Address: 0x%04x", pReply->address);
#if defined(_DEBUG) || defined(DEBUGFAST)
std::string Temp = ArrayToString(DataFrame, Offset);
DEBUG_LOG(WIIMOTE, "Data: %s", Temp.c_str());
#endif
// Send a piece
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
// Update the size that is left
_Size -= copySize;
}
}
/* Write data to Wiimote and Extensions registers. */
void WmWriteData(u16 _channelID, wm_write_data* wd)
{
u32 address = convert24bit(wd->address);
u8 addressHI = (address >> 16) & 0xFE;
INFO_LOG(WIIMOTE, "Write data");
DEBUG_LOG(WIIMOTE, " Space: %x", wd->space);
DEBUG_LOG(WIIMOTE, " Address: 0x%06x", address);
DEBUG_LOG(WIIMOTE, " Size: 0x%02x", wd->size);
// Write to EEPROM
if(wd->size <= 16 && wd->space == WM_SPACE_EEPROM)
{
if(address + wd->size > WIIMOTE_EEPROM_SIZE) {
ERROR_LOG(WIIMOTE, "WmWriteData: address + size out of bounds!");
PanicAlert("WmWriteData: address + size out of bounds!");
return;
}
memcpy(g_Eeprom[g_ID] + address, wd->data, wd->size);
}
// Write to registers
else if(wd->size <= 16 && (wd->space == WM_SPACE_REGS1 || wd->space == WM_SPACE_REGS2))
{
u8* block;
u32 blockSize;
switch(addressHI)
{
case 0xA2:
block = g_RegSpeaker[g_ID];
blockSize = WIIMOTE_REG_SPEAKER_SIZE;
DEBUG_LOG(WIIMOTE, " Case 0xa2: RegSpeaker");
break;
case 0xA4:
block = g_RegExt[g_ID]; // Extension Controller register
blockSize = WIIMOTE_REG_EXT_SIZE;
DEBUG_LOG(WIIMOTE, " Case 0xa4: ExtReg");
break;
case 0xA6:
block = g_RegMotionPlus[g_ID];
blockSize = WIIMOTE_REG_EXT_SIZE;
DEBUG_LOG(WIIMOTE, " Case 0xa6: MotionPlusReg [%x]", address);
break;
case 0xB0:
block = g_RegIr[g_ID];
blockSize = WIIMOTE_REG_IR_SIZE;
INFO_LOG(WIIMOTE, " Case 0xb0: RegIr");
break;
default:
ERROR_LOG(WIIMOTE, "WmWriteData: bad register block!");
PanicAlert("WmWriteData: bad register block!");
return;
}
address &= 0xFFFF;
// Check if the address is within bounds
if(address + wd->size > blockSize) {
PanicAlert("WmWriteData: address + size out of bounds!");
return;
}
// Finally write the registers to the right structure
memcpy(block + address, wd->data, wd->size);
// Generate key for the Wiimote Extension
if(blockSize == WIIMOTE_REG_EXT_SIZE)
{
// Run the key generation on all writes in the key area, it doesn't matter
// that we send it parts of a key, only the last full key will have an effect
if(address >= 0x40 && address <= 0x4c)
wiimote_gen_key(&g_ExtKey[g_ID], &g_RegExt[g_ID][0x40]);
}
if (WiiMapping[g_ID].bMotionPlusConnected) {
//If the MP+ gets activated, it's important to send one or two status reports depending on the presence of a pass-through extension
int sendreport = HandlingMotionPlusWrites(wd->data, addressHI, address);
g_MotionPlusLastWriteReg[g_ID] = address;
switch (sendreport)
{
//pass-through extension disconnected and wm+ connected
case 1:
WmRequestStatus(_channelID, (wm_request_status*) wd, 0);
WmRequestStatus(_channelID, (wm_request_status*) wd, 1);
break;
//wm+ unplugged(on deactivation)
case 2:
WmRequestStatus(_channelID, (wm_request_status*) wd, 0);
break;
//wm+ plugged in(on activation)
case 3:
WmRequestStatus(_channelID, (wm_request_status*) wd, 1);
break;
default:
break;
}
}
}
else
{
PanicAlert("WmWriteData: unimplemented parameters!");
}
/* Just added for home brew... Isn't it enough that we call this from
InterruptChannel()? Or is there a separate route here that don't pass
though InterruptChannel()? */
}
/* Here we produce a 0x20 status report to send to the Wii. We currently ignore
the status request rs and all its eventual instructions it may include (for
example turn off rumble or something else) and just send the status
report. */
void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension)
{
u8 DataFrame[1024];
u32 Offset = WriteWmReportHdr(DataFrame, WM_STATUS_REPORT);
wm_status_report* pStatus = (wm_status_report*)(DataFrame + Offset);
Offset += sizeof(wm_status_report);
memset(pStatus, 0, sizeof(wm_status_report)); // fill the status report with zeros
// Status values
#if defined(HAVE_WX) && HAVE_WX
FillReportInfo(pStatus->buttons);
#endif
pStatus->leds = g_Leds[g_ID]; // leds are 4 bit
pStatus->ir = g_IR[g_ID]; // 1 bit
pStatus->speaker = g_Speaker[g_ID]; // 1 bit
pStatus->battery_low = 0; // battery is okay
pStatus->battery = 0x5f; // fully charged
/* Battery levels in voltage
0x00 - 0x32: level 1
0x33 - 0x43: level 2
0x33 - 0x54: level 3
0x55 - 0xff: level 4 */
// Check if we have a specific order about the extension status
if (Extension == -1)
{
if (WiiMapping[g_ID].bMotionPlusConnected)
pStatus->extension = ((g_MotionPlus[g_ID]) || (WiiMapping[g_ID].iExtensionConnected != EXT_NONE)) ? 1 : 0;
else
pStatus->extension = (WiiMapping[g_ID].iExtensionConnected == EXT_NONE) ? 0 : 1;
// Read config value for the first time
}
else
{
pStatus->extension = (Extension) ? 1 : 0;
}
INFO_LOG(WIIMOTE, "Request Status");
DEBUG_LOG(WIIMOTE, " Buttons: 0x%04x", pStatus->buttons);
DEBUG_LOG(WIIMOTE, " Extension: %x", pStatus->extension);
DEBUG_LOG(WIIMOTE, " Speaker: %x", pStatus->speaker);
DEBUG_LOG(WIIMOTE, " IR: %x", pStatus->ir);
DEBUG_LOG(WIIMOTE, " LEDs: %x", pStatus->leds);
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
}
//http://snzgoo.blogspot.com for more details on what this is doing
int HandlingMotionPlusWrites(u8* data, u8 addressHI, u32 address)
{
bool MPlusActiveExt = (g_RegExt[g_ID][0xFF] == 0x05) ? 1 : 0;
switch (addressHI)
{
case 0xA4:
switch (address)
{
case 0x00FE:
if (data[0] == 0x00)
{
if (MPlusActiveExt)
{
if (WiiMapping[g_ID].iExtensionConnected)
{
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: Disabling WM+ and swapping registers back", data[0], addressHI, address);
g_RegExt[g_ID][0xFE] = 0x00;
SwapExtRegisters();
return 1; // we need to issue a 0x20 report, if there's an extension connected to the MP+!
}
}
else
{
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: WM+ already inactive", data[0], addressHI, address);
}
g_MotionPlus[g_ID] = 1;
}
break;
//1. Disables an active wiimote; 0x20 report sent when iExtensionConnected != NONE : ext disconnect.
//2. Initializing the pass-through extension: writing 0x55 ->0xA400F0 and then 0x00 to 0xA400FB.
//3. Single write 0x00 to 0x00FB when MP got activated, part of the MP activation.
case 0x00FB:
if ((data[0] == 0x00) && (g_MotionPlusLastWriteReg[g_ID] == 0xF0))
{
switch (g_MotionPlusLastWriteReg[g_ID])
{
case 0xF0:
//1. disabling wiimote,
if (MPlusActiveExt) //mp already deactivated, no register swap needed
{
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: Disabling WM+ and swapping registers back", data[0], addressHI, address)
g_MotionPlus[g_ID] = WiiMapping[g_ID].iExtensionConnected ? 1 : 0;
g_RegExt[g_ID][0xFE] = 0x05;
SwapExtRegisters();
if (!WiiMapping[g_ID].iExtensionConnected)
return 2;
} //2. Default extension init, disable mp if actitaved, else do nothing
else
{
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: WM+ already disabled [ext:%i] - no swapping", data[0], addressHI, address, WiiMapping[g_ID].iExtensionConnected);
g_RegMotionPlus[g_ID][0xFE] = 0x05;
g_RegMotionPlus[g_ID][0xF7] = 0x08;
}
break;
//3. part of wm activation.
default:
if (MPlusActiveExt)
{
g_RegExt[g_ID][0xF1] = 0x01;
g_RegExt[g_ID][0xF7] = 0x08; //init/calibration state flag
if (WiiMapping[g_ID].iExtensionConnected)
{
//I don't know what these are for: F6h,F8h, F9h. They seem necessary to be set to 0x00 instead of 0xFF(default),
//when there's an extension connected to the MP
g_RegExt[g_ID][0xF6] = 0x00;
g_RegExt[g_ID][0xF8] = 0x00;
g_RegExt[g_ID][0xF9] = 0x00;
}
}
break;
}
}
break;
//switch for invalid/valid data calibration (0x00/0x01)
case 0x00F1:
if (MPlusActiveExt)
{
g_RegExt[g_ID][0xF7] = 0x1A; //syncing finished
}
break;
//switch for triggering the calibration/syncing between wiimote and MP (corresponding data will be at 50h)
case 0x00F2:
if(MPlusActiveExt && (g_RegExt[g_ID][0xF7] < 0x0E))
{
g_RegExt[g_ID][0xF7] = 0x0E;
}
break;
}
break;
//MotionPlus Register
case 0xA6:
switch (address)
{
//Enabling WM+: swapping extension registers
case 0x00FE:
if ((data[0] == 0x04) || (data[0] == 0x05))
{
if (!MPlusActiveExt)
{
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: Enabling WM+ and swapping registers", data[0], addressHI, address);
//The WII will try to read from the A6 WM+ register directly after activation,
//and we need to reply with an error each time as long the mp is still activate.
//In addition, we need to sent 1-2 0x20 statusreports depending on if theres an extension connected to the MP or not.
g_MotionPlus[g_ID] = 1;
SwapExtRegisters();
g_RegExt[g_ID][0xF7] = 0x08; //Reset flag
g_RegExt[g_ID][0xFE] = data[0];
if (WiiMapping[g_ID].iExtensionConnected != EXT_NONE)
{
g_RegExt[g_ID][0xF1] = 0x01;
g_RegExt[g_ID][0xF6] = 0x00;
g_RegExt[g_ID][0xF8] = 0x00;
g_RegExt[g_ID][0xF9] = 0x00;
return 1; // we need to issue 2 0x20 reports, if there's an extension connected to the MP
}
return 3; // we need to issue 1 0x20 report, if there's no extension connected to the MP
}
else
{
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: WM already enabled no register swapping", data[0], addressHI, address);
}
}
break;
//Part of the WM+ init()
case 0x00F0:
if (data[0] == 0x55) {
//If the wiimote is already active, we will init() the WM+ directly in the ExtReg, shouldn't happen usually
if (MPlusActiveExt)
{
g_RegExt[g_ID][0xFE] = 0x05;
g_RegExt[g_ID][0xF7] = 0x08;
}
if (WiiMapping[g_ID].iExtensionConnected == EXT_NONE)
g_MotionPlus[g_ID] = 0;
}
break;
default:
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: unknown reason", data[0], addressHI, address);
break;
}
break;
}
return false;
}
//Swapping Ext/WM+-registers
void SwapExtRegisters()
{
memset(g_RegExtTmp, 0, sizeof(g_RegExtTmp));
memcpy(g_RegExtTmp, g_RegExt[g_ID], sizeof(g_RegExt[0]));
memset(g_RegExt[0], 0, sizeof(g_RegExt[0]));
memcpy(g_RegExt[g_ID], g_RegMotionPlus[g_ID], sizeof(g_RegMotionPlus[0]));
memset(g_RegMotionPlus[0], 0, sizeof(g_RegMotionPlus[0]));
memcpy(g_RegMotionPlus[g_ID], g_RegExtTmp, sizeof(g_RegExtTmp));
if (g_RegMotionPlus[g_ID][0xFC]) {
g_RegMotionPlus[g_ID][0xFC] = 0xa6;
}
if (g_RegExt[g_ID][0xFC]) {
g_RegExt[g_ID][0xFC] = 0xa4;
}
}
} // WiiMoteEmu

View File

@ -1,70 +0,0 @@
// 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 _EMU_SUBFUNCTIONS_
#define _EMU_SUBFUNCTIONS_
#include "pluginspecs_wiimote.h"
#include <vector>
#include <string>
#include "Common.h" // Common
#include "main.h"
#include "wiimote_hid.h" // Local
#include "EmuDefinitions.h"
#include "Encryption.h"
extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteEmu
{
void HidOutputReport(u16 _channelID, wm_report* sr);
void WmReadData(u16 _channelID, wm_read_data* rd);
void WmWriteData(u16 _channelID, wm_write_data* wd);
void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension = -1);
void WmRequestStatus_(u16 _channelID, int a);
void WmReportMode(u16 _channelID, wm_report_mode* dr);
void SendReportCoreAccel(u16 _channelID);
void SendReportCoreAccelIr12(u16 _channelID);
void SendReportCore(u16 _channelID);
void SendReportCoreAccelExt16(u16 _channelID);
void SendReportCoreAccelIr10Ext(u16 _channelID);
int WriteWmReportHdr(u8* dst, u8 wm);
void WmSendAck(u16 _channelID, u8 _reportID);
void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _AddressHI, int _Size);
void SwapExtRegisters();
int HandlingMotionPlusWrites(u8* data, u8 addressHI, u32 address);
void FillReportAcc(wm_accel& _acc);
void FillReportInfo(wm_core& _core);
void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1);
void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1);
void FillReportExtension(wm_extension& _ext);
void FillReportClassicExtension(wm_classic_extension& _ext);
void FillReportGuitarHero3Extension(wm_GH3_extension& _ext);
void FillReportMotionPlusNunchukExtension(wm_extension& _ext);
void FillReportMotionPlusNoExtension(wm_extension& _ext);
void FillReportMotionPlus(wm_extension& ext, bool extension);
} // namespace
#endif //_EMU_DECLARATIONS_

View File

@ -1,296 +0,0 @@
// Copyright (C) 2003 Dolphin Project.
// Copyright (C) Hector Martin "marcan" (hector@marcansoft.com)
// 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 "Common.h"
#include "pluginspecs_wiimote.h"
#include "Encryption.h"
u8 ans_tbl[7][6] = {
{0xA8,0x77,0xA6,0xE0,0xF7,0x43},
{0x5A,0x35,0x85,0xE2,0x72,0x97},
{0x8F,0xB7,0x1A,0x62,0x87,0x38},
{ 0xD,0x67,0xC7,0xBE,0x4F,0x3E},
{0x20,0x76,0x37,0x8F,0x68,0xB7},
{0xA9,0x26,0x3F,0x2B,0x10,0xE3},
{0x30,0x7E,0x90, 0xE,0x85, 0xA},
};
u8 tsbox[256] = {
0x70,0x51, 3,0x86,0x40, 0xD,0x4F,0xEB,0x3E,0xCC,0xD1,0x87,0x35,0xBD,0xF5, 0xB,
0x5E,0xD0,0xF8,0xF2,0xD5,0xE2,0x6C,0x31, 0xC,0xAD,0xFC,0x21,0xC3,0x78,0xC1, 6,
0xC2,0x4C,0x55,0xE6,0x4A,0x34,0x48,0x11,0x1E,0xDA,0xE7,0x1A,0x84,0xA0,0x96,0xA7,
0xE3,0x7F,0xAF,0x63,0x9C,0xFA,0x23,0x5B,0x79,0xC8,0x9E,0xBA,0xB2,0xC9,0x22,0x12,
0x4B,0xB3,0xA1,0xB6,0x32,0x49,0xA2,0xE1,0x89,0x39,0x10,0x66,0xC5, 7,0x8F,0x54,
0xEA,0x91,0xCA,0x3F,0xF9,0x19,0xF0,0xD7,0x46,0xBC,0x28,0x1B,0x61,0xE8,0x2F,0x6A,
0xAE,0x9D,0xF6,0x4E, 9,0x14,0x77,0x4D,0xDB,0x1F,0x2E,0x7B,0x7C,0xF1,0x43,0xA3,
0,0xB8,0x13,0x8C,0x85,0xB9,0x29,0x75,0x88,0xFD,0xD2,0x56,0x1C,0x50,0x97,0x41,
0xE5,0x3B,0x60,0xB5,0xC0,0x64,0xEE,0x98,0xD6,0x2D,0x25,0xA4,0xAA,0xCD,0x7D,0xA8,
0x83,0xC6,0xAB,0xBE,0x44,0x99,0x26,0x3C,0xCE,0x9F,0xBF,0xD3,0xCB,0x76,0x7A,0x7E,
0x82, 1,0x8A,0x9A,0x80,0x1D, 0xE,0xB0,0x5C,0xD4,0x38,0x62,0xF4,0x30,0xE0,0x8E,
0x53,0xB7, 2,0x57,0xAC,0xA6,0x52, 0xA,0x6D,0x92,0x65,0x17,0x24,0x33,0x45,0x72,
0x74,0xB1,0xB4,0xF7,0x5D,0xED,0x2C,0xFF,0x47,0x37,0x5A,0x90,0xBB,0xDF,0x2A,0x16,
0x59,0x95,0xD9,0xC4,0x27,0x67,0x73,0xC7,0x68,0xFE,0xA5,0xDD,0x6B,0x5F,0x93,0xD8,
0xEC, 5,0x3A,0x8D,0x6E,0xFB,0x3D,0xA9,0x69,0x36,0xF3,0x94,0xDE,0xEF,0x15,0x6F,
0x8B,0x9B, 8, 0xF,0xDC,0x81,0x18,0x20, 4,0xE4,0x71,0xCF,0xE9,0x2B,0x42,0x58,
};
u8 sboxes[8][256] = {
{
1,0xA0,0xA9,0x62,0xD6,0x3F,0x85,0xA7,0xB6,0xD4,0xFA,0x15,0x66,0x17, 9,0xBD,
0x5D,0x14,0x34,0x26,0x59,0x72,0x91,0x54, 6,0x4F,0xF8,0xB0,0x5B,0x74,0x93,0x99,
0x8C,0xF2,0x45,0xCD,0xEA,0x4E,0xAD,0x10,0x4A,0xE5,0xCA,0xEE,0xDF,0xC6,0x6F,0x9F,
0x88,0x8E, 2,0xCC, 8,0xA8,0x77,0x94,0x6D,0x21,0xB1,0x28,0xE4,0x39,0x79,0x96,
0x60,0x71,0x81,0x16,0x2E,0xE6,0x78,0xB9,0xC4,0x46,0x9A,0x42,0xAE,0xB7,0x7C,0x43,
0xB3,0x22,0x1A,0x86,0xC2,0x32,0x3D,0x2D,0x9C,0xD2,0x29,0xE9,0x63,0x9B,0xD1,0x31,
0x38,0x5E,0x1E,0x36,0x41,0xBB, 3,0x18,0x2B,0x3E,0xBF,0x68,0x61,0xFC,0x52,0xC0,
0xDE,0xE0, 0xA,0x58,0x13,0x5A, 0,0xBE,0x1C,0x90, 0xE,0x53,0x12,0xFD,0xE2,0x6E,
0xBA,0xCE,0x24,0x27,0x44,0x7F,0x87,0xA3,0xA1,0xD5,0x50,0x40,0xE3,0xF9,0x83,0xF7,
0xC7,0xA2,0x35,0xC8,0xDB,0x19,0xAB,0x2F,0x11,0x25,0xED,0x33,0x9E,0x55,0xE1,0x48,
0xAF,0x73,0x84,0xDA,0x2A,0xAA,0x51,0xEB,0x9D,0x95,0xB2,0xCB,0xE7,0x70,0x80,0xFE,
0x4C,0x65, 4,0xEF,0xC5,0xF1,0xC3,0x3A,0xB4,0xF5,0x5F,0x23,0x89,0xDD,0x30,0xA5,
0x8B,0xD3,0xF6,0xDC,0x4D,0x64,0xD7,0xF0,0x8F,0xEC,0x56,0x37,0x5C,0xA4, 0xD, 7,
0x76,0x8A,0x2C, 0xB,0xB5,0xD8,0xC1,0x1F,0xE8,0x3B,0xF4,0x4B,0x1B,0x47,0x6C,0x49,
0x67,0x7B,0x92,0xCF,0x75,0x7E,0x20,0xD9,0x7D,0x3C,0x97,0x7A,0xD0, 5,0x6B, 0xF,
0x1D,0xFB,0x82,0x98,0x57,0x8D,0xF3,0x6A,0xBC,0xAC,0xC9,0xA6,0xFF,0xB8,0x69, 0xC,
},
{
0x4C,0x4D,0x72, 7,0x5A,0x49,0x33,0x8D,0xA2,0xAB,0x46,0x3D,0x63, 0xD,0xA0,0x97,
0xFF,0xF0,0xF5,0xFA,0xC0,0xE9,0xDB,0x62,0xE4,0xE1,0x74,0x43,0xDC,0x86,0x18,0x29,
0x37,0xF4, 6,0xE2,0xED,0x6F,0x90,0x48,0x1E,0x2D,0x1D,0xEA,0x73,0x94,0x54,0xDF,
0x25,0xF6,0x47,0x27,0xD9,0x11,0x77,0xC9,0x84,0x1C,0x5B,0x5C,0x51,0x81,0xA6,0x22,
0x3E,0x24,0x96,0xC8,0x8A,0xEC,0x82,0x7C, 9,0xB8,0x45,0x4A,0x57,0xBB,0x2F,0x50,
0x75,0x8E,0x61,0x70,0x8C,0x6C,0xAF,0xD0,0xFD,0xB4,0x1B,0xAE,0xDE,0xFE,0x3B,0xB5,
0x36,0xBD,0x55, 1, 0xE,0x9C,0x41,0x56,0x5F,0xB3,0x26, 3,0x83,0xBA,0x13,0x4B,
0xCA,0xC5, 0xA,0xF8,0x60,0xA5,0xB9,0xC7,0xC3,0x98,0x32,0xFB,0x12,0xF9,0xA7,0x92,
0xAA,0x68,0xF3,0x78,0x7E, 5,0x20,0x21, 2,0xE8,0xBF,0xF2,0xB0,0x59,0x8F,0xD2,
0xCB,0x87,0x65,0x15,0xF1,0x1A,0xB2,0x30,0xAD,0xEE,0x58,0xA3,0x8B,0x66,0x1F,0x2C,
0xD7,0x5D,0x19,0x85,0xA8,0xE6,0xD3,0x6B,0xA1, 0xC,0x91,0x93,0x6A,0x5E, 0xB,0x79,
0xE3,0xDD, 0,0x4F,0x3C,0x89,0x6E,0x71,0x69,0xA9,0xAC,0x40,0xE5,0x99,0x28,0xC6,
0x31,0x4E,0x7A,0xCD, 8,0x9E,0x7D,0xEF,0x17,0xFC,0x88,0xD8,0xA4,0x6D,0x44,0x95,
0xD1,0xB7,0xD4,0x9B,0xBE,0x2A,0x34,0x64,0x2B,0xCF,0x2E,0xEB,0x38,0xCE,0x23,0xE0,
0x3A,0x3F,0xF7,0x7B,0x9F,0x10,0x53,0xBC,0x52,0x67,0x16,0xE7,0x80,0x76, 4,0xC4,
0xB6,0xC1,0xC2,0x7F,0x9A,0xDA,0xD5,0x39,0x42,0x14,0x9D,0xB1, 0xF,0x35,0xD6,0xCC,
},
{
0xB9,0xDA,0x38, 0xC,0xA2,0x9C, 9,0x1F, 6,0xB1,0xB6,0xFD,0x1A,0x69,0x23,0x30,
0xC4,0xDE, 1,0xD1,0xF4,0x58,0x29,0x37,0x1C,0x7D,0xD5,0xBF,0xFF,0xBD,0xC8,0xC9,
0xCF,0x65,0xBE,0x7B,0x78,0x97,0x98,0x67, 8,0xB3,0x26,0x57,0xF7,0xFA,0x40,0xAD,
0x8E,0x75,0xA6,0x7C,0xDB,0x91,0x8B,0x51,0x99,0xD4,0x17,0x7A,0x90,0x8D,0xCE,0x63,
0xCB,0x4E,0xA0,0xAB,0x18,0x3A,0x5B,0x50,0x7F,0x21,0x74,0xC1,0xBB,0xB8,0xB7,0xBA,
0xB,0x35,0x95,0x31,0x59,0x9A,0x4D, 4, 7,0x1E,0x5A,0x76,0x13,0xF3,0x71,0x83,
0xD0,0x86, 3,0xA8,0x39,0x42,0xAA,0x28,0xE6,0xE4,0xD8,0x5D,0xD3,0xD0,0x6E,0x6F,
0x96,0xFB,0x5E,0xBC,0x56,0xC2,0x5F,0x85,0x9B,0xE7,0xAF,0xD2,0x3B,0x84,0x6A,0xA7,
0x53,0xC5,0x44,0x49,0xA5,0xF9,0x36,0x72,0x3D,0x2C,0xD9,0x1B,0xA1,0xF5,0x4F,0x93,
0x9D,0x68,0x47,0x41,0x16,0xCA,0x2A,0x4C,0xA3,0x87,0xD6,0xE5,0x19,0x2E,0x77,0x15,
0x6D,0x70,0xC0,0xDF,0xB2, 0,0x46,0xED,0xC6,0x6C,0x43,0x60,0x92,0x2D,0xA9,0x22,
0x45,0x8F,0x34,0x55,0xAE,0xA4, 0xA,0x66,0x32,0xE0,0xDC, 2,0xAC,0xE8,0x20,0x8C,
0x89,0x62,0x4A,0xFE,0xEE,0xC3,0xE3,0x3C,0xF1,0x79, 5,0xE9,0xF6,0x27,0x33,0xCC,
0xF2,0x9E,0x11,0x81,0x7E,0x80,0x10,0x8A,0x82,0x9F,0x48, 0xD,0xD7,0xB4,0xFC,0x2F,
0xB5,0xC7,0xDD,0x88,0x14,0x6B,0x2B,0x54,0xEA,0x1D,0x94,0x5C,0xB0,0xEF,0x12,0x24,
0xCD,0xEB,0xE1,0xE2,0x64,0x73,0x3F, 0xE,0x52,0x61,0x25,0x3E,0xF8, 0xF,0x4B,0xEC,
},
{
0xC0, 0,0x30,0xF6, 2,0x49,0x3D,0x10,0x6E,0x20,0xC9,0xA6,0x2F,0xFE,0x2C,0x2B,
0x75,0x2E,0x45,0x26,0xAB,0x48,0xA9,0x80,0xFC, 4,0xCC,0xD3,0xB5,0xBA,0xA3,0x38,
0x31,0x7D, 1,0xD9,0xA7,0x7B,0x96,0xB6,0x63,0x69,0x4E,0xF7,0xDE,0xE0,0x78,0xCA,
0x50,0xAA,0x41,0x91,0x65,0x88,0xE4,0x21,0x85,0xDA,0x3A,0x27,0xBE,0x1C,0x3E,0x42,
0x5E,0x17,0x52,0x7F,0x1F,0x89,0x24,0x6F,0x8F,0x5C,0x67,0x74, 0xE,0x12,0x87,0x8D,
0xE9,0x34,0xED,0x73,0xC4,0xF8,0x61,0x5B, 5,0xDF,0x59,0x4C,0x97,0x79,0x83,0x18,
0xA4,0x55,0x95,0xEB,0xBD,0x53,0xF5,0xF1,0x57,0x66,0x46,0x9F,0xB2,0x81, 9,0x51,
0x86,0x22,0x16,0xDD,0x23,0x93,0x76,0x29,0xC2,0xD7,0x1D,0xD4,0xBF,0x36,0x3F,0xEA,
0x4B,0x11,0x32,0xB9,0x62,0x54,0x60,0xD6,0x6D,0x43,0x9A, 0xD,0x92,0x9C,0xB0,0xEF,
0x58,0x6C,0x9D,0x77,0x2D,0x70,0xFA,0xF3,0xB3, 0xB,0xE2,0x40,0x7E,0xF4,0x8A,0xE5,
0x8C,0x3C,0x56,0x71,0xD1,0x64,0xE1,0x82, 0xA,0xCB,0x13,0x15,0x90,0xEC, 3,0x99,
0xAF,0x14,0x5D, 0xF,0x33,0x4A,0x94,0xA5,0xA8,0x35,0x1B,0xE3,0x6A,0xC6,0x28,0xFF,
0x4D,0xE7,0x25,0x84,0xAC, 8,0xAE,0xC5,0xA2,0x2A,0xB8,0x37, 0xC,0x7A,0xA0,0xC3,
0xCE,0xAD, 6,0x1A,0x9E,0x8B,0xFB,0xD5,0xD0,0xC1,0x1E,0xD0,0xB4,0x9B,0xB1,0x44,
0xF2,0x47,0xC7,0x68,0xCF,0x72,0xBB,0x4F,0x5A,0xF9,0xDC,0x6B,0xDB,0xD2,0xE8,0x7C,
0xC8,0xEE,0x98,0xA1,0xE6,0xD8,0x39, 7,0x5F,0xFD,0x8E,0x19,0xB7,0x3B,0xBC,0xCD,
},
{
0x7C,0xE3,0x81,0x73,0xB2,0x11,0xBF,0x6F,0x20,0x98,0xFE,0x75,0x96,0xEF,0x6C,0xDA,
0x50,0xE1, 9,0x72,0x54,0x45,0xBA,0x34,0x80,0x5B,0xED,0x3E,0x53,0x2C,0x87,0xA4,
0x57,0xF3,0x33,0x3F,0x3C,0xB7,0x67,0xB4,0xA3,0x25,0x60,0x4F, 7,0x6B,0x1B,0x47,
0x15, 0xF,0xE4, 0xA,0xEA,0xD1,0x32,0x78,0x36,0x49,0x8D,0x4B,0xD2,0xBC,0xA5,0xDC,
0x1D, 0xD,0x4D,0xCD,0x9A,0x82,0x5F,0xFC,0x94,0x65,0xBE,0xE2,0xF4,0xC9,0x1E,0x44,
0xCB,0x9E, 0xC,0x64,0x71,0x26,0x63,0xB3,0x14,0xE8,0x40,0x70,0x8A, 0xE,0x19,0x42,
0x6D,0xAC,0x88,0x10,0x5C,0xDF,0x41,0xA9,0xAD,0xE5,0xFB,0x74,0xCC,0xD5, 6,0x8E,
0x59,0x86,0xCE,0x1F,0x3D,0x76,0xE0,0x8F,0xB9,0x77,0x27,0x7B,0xA6,0xD8,0x29,0xD3,
0xEC,0xB8,0x13,0xF7,0xFA,0xC3,0x51,0x6A,0xDE,0x4A,0x5A,0xEB,0xC2,0x8B,0x23,0x48,
0x92,0xCF,0x62,0xA8,0x99,0xF8,0xD0,0x2E,0x85,0x61,0x43,0xC8,0xBD,0xF0, 5,0x93,
0xCA,0x4E,0xF1,0x7D,0x30,0xFD,0xC4,0x69,0x66,0x2F, 8,0xB1,0x52,0xF9,0x21,0xE6,
0x7A,0x2B,0xDD,0x39,0x84,0xFF,0xC0,0x91,0xD6,0x37,0xD4,0x7F,0x2D,0x9B,0x5D,0xA1,
0x3B,0x6E,0xB5,0xC5,0x46, 4,0xF5,0x90,0xEE,0x7E,0x83,0x1C, 3,0x56,0xB6,0xAA,
0,0x17, 1,0x35,0x55,0x79, 0xB,0x12,0xBB,0x1A,0x31,0xE7, 2,0x28,0x16,0xC1,
0xF6,0xA2,0xDB,0x18,0x9C,0x89,0x68,0x38,0x97,0xAB,0xC7,0x2A,0xD7,0x3A,0xF2,0xC6,
0x24,0x4C,0xB0,0x58,0xA0,0x22,0x5E,0x9D,0xD9,0xA7,0xE9,0xAE,0xAF,0x8C,0x95,0x9F,
},
{
0x28,0xB7,0x20,0xD7,0xB0,0x30,0xC3, 9,0x19,0xC0,0x67,0xD6, 0,0x3C,0x7E,0xE7,
0xE9,0xF4, 8,0x5A,0xF8,0xB8,0x2E, 5,0xA6,0x25,0x9E,0x5C,0xD8,0x15, 0xD,0xE1,
0xF6,0x11,0x54,0x6B,0xCD,0x21,0x46,0x66,0x5E,0x84,0xAD, 6,0x38,0x29,0x44,0xC5,
0xA2,0xCE,0xF1,0xAA,0xC1,0x40,0x71,0x86,0xB5,0xEF,0xFC,0x36,0xA8,0xCB, 0xA,0x48,
0x27,0x45,0x64,0xA3,0xAF,0x8C,0xB2,0xC6,0x9F, 7,0x89,0xDC,0x17,0xD3,0x49,0x79,
0xFB,0xFE,0x1D,0xD0,0xB9,0x88,0x43,0x52,0xBC, 1,0x78,0x2B,0x7D,0x94,0xC7, 0xE,
0xDE,0xA5,0xD5,0x9B,0xCC,0xF7,0x61,0x7A,0xC2,0x74,0x81,0x39, 3,0xAB,0x96,0xA0,
0x37,0xBD,0x2D,0x72,0x75,0x3F,0xC9,0xD4,0x8E,0x6F,0xF9,0x8D,0xED,0x62,0xDB,0x1C,
0xDF, 4,0xAC,0x1B,0x6C,0x14,0x4B,0x63,0xD0,0xBF,0xB4,0x82,0xEC,0x7B,0x1A,0x59,
0x92,0xD2,0x10,0x60,0xB6,0x3D,0x5F,0xE6,0x80,0x6E,0x70,0xC4,0xF2,0x35,0xD9,0x7C,
0xEE,0xE5,0x41,0xA4,0x5B,0x50,0xDD,0xBB,0x4C,0xF3,0x1F,0x9D,0x5D,0x57,0x55,0x51,
0x97,0xE3,0x58,0x42,0x4D,0x9C,0x73,0xBA,0xC8,0x77,0x31,0x69,0x26,0xAE,0xEA,0x8A,
0xDA,0x22,0xB3,0x87,0x56,0xFA,0x93, 0xB,0x34,0x16,0x33,0xE8,0xE4,0x53,0xBE,0xA9,
0xB1,0x3A,0x3E,0xF5,0x90,0x6A,0xCF,0x3B,0x12,0xFD,0x8F,0x9A,0xA7,0x47,0x91,0x99,
0xEB, 0xF,0x24,0xFF,0x23,0x18,0x85,0x4E,0x7F, 0xC,0xE0,0xA1,0xD2,0xD1,0x2C,0x2A,
0x4A, 2,0x4F,0x1E,0x95,0x68,0x8B,0x98,0x83,0x6D,0x76,0xCA,0x65,0x32,0x13,0x2F,
},
{
0xC3,0x82,0x9A,0xA4,0xBA,0x81,0x60,0x37,0x34,0x35,0xFC,0x80,0xA8,0x51,0x65,0x67,
0xED,0x30,0x5F,0x10,0xD3,0x4A,0x27,0x2F,0x13,0xB9,0x2A,0xD2,0xCC,0xE1,0xEF,0xAE,
0xEB,0xBE,0xF4,0xBD,0xCF,0x43,0xB3,0xC5,0x88,0x84,0xB7,0xDD,0x39,0x40,0xCE,0x48,
0x6D,0x9B,0x72,0x61,0x7E,0xE7,0xA1,0x4E,0x53,0x2E,0x77,0x3B,0xE2,0xC9,0x36,0x22,
0x1B,0x6E,0x73,0xB1, 3,0xB2,0x4C,0x87,0xA9,0xD4,0x4D, 0xF,0xD8,0x15,0x6C,0xAA,
0x18,0xF6,0x49,0x57,0x5D,0xFB,0x7A,0x14,0x94,0x63,0xA0,0x11,0xB0,0x9E,0xDE, 5,
0x46,0xC8,0xEE,0x47,0xDB,0xDC,0x24,0x89,0x9C,0x91,0x97,0x29,0xE9,0x7B,0xC1, 7,
0x1E,0xB8,0xFD,0xFE,0xAC,0xC6,0x62,0x98,0x4F,0xF1,0x79,0xE0,0xE8,0x6B,0x78,0x56,
0xB6,0x8D, 4,0x50,0x86,0xCA,0x6F,0x20,0xE6,0xEA,0xE5,0x76,0x17,0x1C,0x74,0x7F,
0xBC, 0xD,0x2C,0x85,0xF7,0x66,0x96,0xE4,0x8B,0x75,0x3F,0x4B,0xD9,0x38,0xAF,0x7C,
0xDA, 0xB,0x83,0x2D,0x31,0x32,0xA2,0xF5,0x1D,0x59,0x41,0x45,0xBF,0x3C,0x1F,0xF8,
0xF9,0x8A,0xD0,0x16,0x25,0x69,0x12,0x99,0x9D,0x21,0x95,0xAB, 1,0xA6,0xD7,0xB5,
0xC0,0x7D,0xFF,0x58, 0xE,0x3A,0x92,0xD1,0x55,0xE3, 8,0x9F,0xD6,0x3E,0x52,0x8E,
0xFA,0xA3,0xC7, 2,0xCD,0xDF,0x8F,0x64,0x19,0x8C,0xF3,0xA7, 0xC,0x5E, 0xA,0x6A,
9,0xF0,0x93,0x5B,0x42,0xC2, 6,0x23,0xEC,0x71,0xAD,0xB4,0xCB,0xBB,0x70,0x28,
0xD5,0x1A,0x5C,0x33,0x68,0x5A, 0,0x44,0x90,0xA5,0xC4,0x26,0x3D,0x2B,0xF2,0x54,
},
{
0x96,0xAD,0xDA,0x1F,0xED,0x33,0xE1,0x81,0x69, 8, 0xD, 0xA,0xDB,0x35,0x77,0x9A,
0x64,0xD1,0xFC,0x78,0xAA,0x1B,0xD0,0x67,0xA0,0xDD,0xFA,0x6C,0x63,0x71, 5,0x84,
0x17,0x6A,0x89,0x4F,0x66,0x7F,0xC6,0x50,0x55,0x92,0x6F,0xBD,0xE7,0xD2,0x40,0x72,
0x8D,0xBB,0xEC, 6,0x42,0x8A,0xE4,0x88,0x9D,0x7E,0x7A,0x82,0x27,0x13,0x41,0x1A,
0xAF,0xC8,0xA4,0x76,0xB4,0xC2,0xFE,0x6D,0x1C,0xD9,0x61,0x30,0xB3,0x7C,0xEA,0xF7,
0x29, 0xF,0xF2,0x3B,0x51,0xC1,0xDE,0x5F,0xE5,0x2A,0x2F,0x99, 0xB,0x5D,0xA3,0x2B,
0x4A,0xAB,0x95,0xA5,0xD3,0x58,0x56,0xEE,0x28,0x31, 0,0xCC,0x15,0x46,0xCA,0xE6,
0x86,0x38,0x3C,0x65,0xF5,0xE3,0x9F,0xD6,0x5B, 9,0x49,0x83,0x70,0x2D,0x53,0xA9,
0x7D,0xE2,0xC4,0xAC,0x8E,0x5E,0xB8,0x25,0xF4,0xB9,0x57,0xF3,0xF1,0x68,0x47,0xB2,
0xA2,0x59,0x20,0xCE,0x34,0x79,0x5C,0x90, 0xE,0x1E,0xBE,0xD5,0x22,0x23,0xB1,0xC9,
0x18,0x62,0x16,0x2E,0x91,0x3E, 7,0x8F,0xD8,0x3F,0x93,0x3D,0xD4,0x9B,0xDF,0x85,
0x21,0xFB,0x11,0x74,0x97,0xC7,0xD7,0xDC,0x4C,0x19,0x45,0x98,0xE9,0x43, 2,0x4B,
0xBC,0xC3, 4,0x9C,0x6B,0xF0,0x75,0x52,0xA7,0x26,0xF6,0xC5,0xBA,0xCF,0xB0,0xB7,
0xAE,0x5A,0xA1,0xBF, 3,0x8B,0x80,0x12,0x6E, 0xC,0xEB,0xF9,0xC0,0x44,0x24,0xEF,
0x10,0xF8,0xA8,0x8C,0xE8,0x7B,0xFF,0x9E,0x2C,0xCD,0x60,0x36,0x87,0xB5,0x94,0xA6,
0x54,0x73,0x3A,0x14,0x4E, 1,0x1D,0xB6,0xFD,0x37,0x48,0x4D,0x39,0xCB,0xE0,0x32,
}
};
static inline u8 ror8(u8 a, u8 b) {
return (a>>b) | ((a<<(8-b))&0xff);
}
void genkey(u8 *rand, u8 idx, u8 *key)
{
u8 *ans = ans_tbl[idx];
u8 t0[10];
int i;
for(i=0;i<10;i++)
t0[i] = tsbox[rand[i]];
key[0] = ((ror8((ans[0]^t0[5]),(t0[2]%8)) - t0[9]) ^ t0[4]);
key[1] = ((ror8((ans[1]^t0[1]),(t0[0]%8)) - t0[5]) ^ t0[7]);
key[2] = ((ror8((ans[2]^t0[6]),(t0[8]%8)) - t0[2]) ^ t0[0]);
key[3] = ((ror8((ans[3]^t0[4]),(t0[7]%8)) - t0[3]) ^ t0[2]);
key[4] = ((ror8((ans[4]^t0[1]),(t0[6]%8)) - t0[3]) ^ t0[4]);
key[5] = ((ror8((ans[5]^t0[7]),(t0[8]%8)) - t0[5]) ^ t0[9]);
}
void gentabs(u8 *rand, u8 *key, u8 idx, u8 *ft, u8 *sb)
{
ft[0] = sboxes[idx][key[4]] ^ sboxes[(idx+1)%8][rand[3]];
ft[1] = sboxes[idx][key[2]] ^ sboxes[(idx+1)%8][rand[5]];
ft[2] = sboxes[idx][key[5]] ^ sboxes[(idx+1)%8][rand[7]];
ft[3] = sboxes[idx][key[0]] ^ sboxes[(idx+1)%8][rand[2]];
ft[4] = sboxes[idx][key[1]] ^ sboxes[(idx+1)%8][rand[4]];
ft[5] = sboxes[idx][key[3]] ^ sboxes[(idx+1)%8][rand[9]];
ft[6] = sboxes[idx][rand[0]] ^ sboxes[(idx+1)%8][rand[6]];
ft[7] = sboxes[idx][rand[1]] ^ sboxes[(idx+1)%8][rand[8]];
sb[0] = sboxes[idx][key[0]] ^ sboxes[(idx+1)%8][rand[1]];
sb[1] = sboxes[idx][key[5]] ^ sboxes[(idx+1)%8][rand[4]];
sb[2] = sboxes[idx][key[3]] ^ sboxes[(idx+1)%8][rand[0]];
sb[3] = sboxes[idx][key[2]] ^ sboxes[(idx+1)%8][rand[9]];
sb[4] = sboxes[idx][key[4]] ^ sboxes[(idx+1)%8][rand[7]];
sb[5] = sboxes[idx][key[1]] ^ sboxes[(idx+1)%8][rand[8]];
sb[6] = sboxes[idx][rand[3]] ^ sboxes[(idx+1)%8][rand[5]];
sb[7] = sboxes[idx][rand[2]] ^ sboxes[(idx+1)%8][rand[6]];
}
/* Generate key from the 0x40-0x4c data in g_RegExt */
void wiimote_gen_key(wiimote_key *key, u8 *keydata)
{
u8 rand[10];
u8 skey[6];
u8 testkey[6];
int idx;
for(int i=0;i<10;i++)
rand[9-i] = keydata[i];
for(int i=0;i<6;i++)
skey[5-i] = keydata[i+10];
DEBUG_LOG(WIIMOTE, "rand: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", rand[0], rand[1], rand[2], rand[3], rand[4], rand[5], rand[6], rand[7], rand[8], rand[9]);
DEBUG_LOG(WIIMOTE, "key: %02x %02x %02x %02x %02x %02x", skey[0], skey[1], skey[2], skey[3], skey[4], skey[5]);
for(idx = 0; idx < 7; idx++)
{
genkey(rand, idx, testkey);
if(!memcmp(testkey, skey, 6))
break;
}
// default case is idx = 7 which is valid (homebrew uses it for the 0x17 case)
DEBUG_LOG(WIIMOTE, "idx: %d", idx);
gentabs(rand, skey, idx, key->ft, key->sb);
DEBUG_LOG(WIIMOTE, "ft: %02x %02x %02x %02x %02x %02x %02x %02x", key->ft[0], key->ft[1], key->ft[2], key->ft[3], key->ft[4], key->ft[5], key->ft[6], key->ft[7]);
DEBUG_LOG(WIIMOTE, "sb: %02x %02x %02x %02x %02x %02x %02x %02x", key->sb[0], key->sb[1], key->sb[2], key->sb[3], key->sb[4], key->sb[5], key->sb[6], key->sb[7]);
// for homebrew, ft and sb are all 0x97 which is equivalent to 0x17
}
/* Encrypt data */
void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len)
{
for(int i = 0; i < len; i++, addr++)
data[i] = (data[i] - key->ft[addr%8]) ^ key->sb[addr%8];
}
/* Decrypt data */
void wiimote_decrypt(wiimote_key *key, u8 *data, int addr, u8 len)
{
for(int i = 0; i < len; i++, addr++)
data[i] = (data[i] ^ key->sb[addr%8]) + key->ft[addr%8];
}

Some files were not shown because too many files have changed in this diff Show More