mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
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:
@ -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=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib""
|
||||
AdditionalLibraryDirectories=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib";"..\..\..\Externals\WiiUse\$(PlatformName)""
|
||||
/>
|
||||
<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=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib""
|
||||
AdditionalLibraryDirectories=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib";"..\..\..\Externals\WiiUse\$(PlatformName)""
|
||||
/>
|
||||
<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=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib""
|
||||
AdditionalLibraryDirectories=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib";"..\..\..\Externals\WiiUse\$(PlatformName)""
|
||||
/>
|
||||
<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=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib";"..\..\..\Externals\Lua\$(OutDir)\Lua.lib""
|
||||
AdditionalLibraryDirectories=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib";"..\..\..\Externals\Lua\$(OutDir)\Lua.lib";"..\..\..\Externals\WiiUse\$(PlatformName)""
|
||||
/>
|
||||
<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=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib""
|
||||
AdditionalLibraryDirectories=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib";"..\..\..\Externals\WiiUse\$(PlatformName)""
|
||||
/>
|
||||
<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=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib""
|
||||
AdditionalLibraryDirectories=""..\..\..\Externals\LZO\$(OutDir)\lzo.lib";"..\..\..\Externals\WiiUse\$(PlatformName)""
|
||||
/>
|
||||
<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"
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
153
Source/Core/Core/Src/HW/Wiimote.cpp
Normal file
153
Source/Core/Core/Src/HW/Wiimote.cpp
Normal 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);
|
||||
}
|
||||
|
||||
}
|
50
Source/Core/Core/Src/HW/Wiimote.h
Normal file
50
Source/Core/Core/Src/HW/Wiimote.h
Normal 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
|
34
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Attachment.cpp
Normal file
34
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Attachment.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
#include "Attachment.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
// Extension device IDs to be written to the last bytes of the extension reg
|
||||
// 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 };
|
||||
|
||||
Attachment::Attachment( const char* const _name ) : name( _name )
|
||||
{
|
||||
reg.resize( WIIMOTE_REG_EXT_SIZE, 0);
|
||||
}
|
||||
|
||||
None::None() : Attachment( "None" )
|
||||
{
|
||||
// set up register
|
||||
memcpy( ®[0xfa], nothing_id, sizeof(nothing_id) );
|
||||
}
|
||||
|
||||
std::string Attachment::GetName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ControllerEmu::Extension::GetState( u8* const data, const bool focus )
|
||||
{
|
||||
((WiimoteEmu::Attachment*)attachments[ active_extension ])->GetState( data, focus );
|
||||
}
|
30
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Attachment.h
Normal file
30
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Attachment.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef _ATTACHMENT_EMU_H_
|
||||
#define _ATTACHMENT_EMU_H_
|
||||
|
||||
#include "ControllerEmu.h"
|
||||
#include "../WiimoteEmu.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
class Attachment : public ControllerEmu
|
||||
{
|
||||
public:
|
||||
Attachment( const char* const _name );
|
||||
|
||||
virtual void GetState( u8* const data, const bool focus = true ) {}
|
||||
std::string GetName() const;
|
||||
|
||||
const char* const name;
|
||||
std::vector<u8> reg;
|
||||
};
|
||||
|
||||
class None : public Attachment
|
||||
{
|
||||
public:
|
||||
None();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
130
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Classic.cpp
Normal file
130
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Classic.cpp
Normal file
@ -0,0 +1,130 @@
|
||||
#include "Classic.h"
|
||||
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
static const u8 classic_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x01 };
|
||||
/* Classic Controller calibration */
|
||||
static const u8 classic_calibration[] =
|
||||
{
|
||||
0xff, 0x00, 0x80, 0xff, 0x00, 0x80,
|
||||
0xff, 0x00, 0x80, 0xff, 0x00, 0x80,
|
||||
0x00, 0x00, 0x51, 0xa6
|
||||
};
|
||||
|
||||
static const u16 classic_button_bitmasks[] =
|
||||
{
|
||||
Classic::BUTTON_A,
|
||||
Classic::BUTTON_B,
|
||||
Classic::BUTTON_X,
|
||||
Classic::BUTTON_Y,
|
||||
|
||||
Classic::BUTTON_ZL,
|
||||
Classic::BUTTON_ZR,
|
||||
|
||||
Classic::BUTTON_MINUS,
|
||||
Classic::BUTTON_PLUS,
|
||||
|
||||
Classic::BUTTON_HOME,
|
||||
};
|
||||
|
||||
static const char* const classic_button_names[] =
|
||||
{
|
||||
"A","B","X","Y","ZL","ZR","-","+","Home",
|
||||
};
|
||||
|
||||
static const u16 classic_trigger_bitmasks[] =
|
||||
{
|
||||
Classic::TRIGGER_L, Classic::TRIGGER_R,
|
||||
};
|
||||
|
||||
static const char* const classic_trigger_names[] =
|
||||
{
|
||||
"L", "R", "L-Analog", "R-Analog"
|
||||
};
|
||||
|
||||
static const u16 classic_dpad_bitmasks[] =
|
||||
{
|
||||
Classic::PAD_UP, Classic::PAD_DOWN, Classic::PAD_LEFT, Classic::PAD_RIGHT
|
||||
};
|
||||
|
||||
Classic::Classic() : Attachment( "Classic" )
|
||||
{
|
||||
// buttons
|
||||
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
|
||||
for ( unsigned int i = 0; i < sizeof(classic_button_names)/sizeof(*classic_button_names); ++i )
|
||||
m_buttons->controls.push_back( new ControlGroup::Input( classic_button_names[i] ) );
|
||||
|
||||
// sticks
|
||||
groups.push_back( m_left_stick = new AnalogStick( "Left Stick" ) );
|
||||
groups.push_back( m_right_stick = new AnalogStick( "Right Stick" ) );
|
||||
|
||||
// triggers
|
||||
groups.push_back( m_triggers = new MixedTriggers( "Triggers" ) );
|
||||
for ( unsigned int i=0; i < sizeof(classic_trigger_names)/sizeof(*classic_trigger_names); ++i )
|
||||
m_triggers->controls.push_back( new ControlGroup::Input( classic_trigger_names[i] ) );
|
||||
|
||||
// dpad
|
||||
groups.push_back( m_dpad = new Buttons( "D-Pad" ) );
|
||||
for ( unsigned int i=0; i < 4; ++i )
|
||||
m_dpad->controls.push_back( new ControlGroup::Input( named_directions[i] ) );
|
||||
|
||||
// set up register
|
||||
// calibration
|
||||
memcpy( ®[0x20], classic_calibration, sizeof(classic_calibration) );
|
||||
// id
|
||||
memcpy( ®[0xfa], classic_id, sizeof(classic_id) );
|
||||
}
|
||||
|
||||
void Classic::GetState( u8* const data, const bool focus )
|
||||
{
|
||||
wm_classic_extension* const ccdata = (wm_classic_extension*)data;
|
||||
ccdata->bt = 0;
|
||||
|
||||
// not using calibration data, o well
|
||||
|
||||
// left stick
|
||||
{
|
||||
u8 x, y;
|
||||
m_left_stick->GetState( &x, &y, 0x20, focus ? 0x1F /*0x15*/ : 0 );
|
||||
|
||||
ccdata->lx = x;
|
||||
ccdata->ly = y;
|
||||
}
|
||||
|
||||
// right stick
|
||||
{
|
||||
u8 x, y;
|
||||
m_right_stick->GetState( &x, &y, 0x10, focus ? 0x0F /*0x0C*/ : 0 );
|
||||
|
||||
ccdata->rx1 = x;
|
||||
ccdata->rx2 = x >> 1;
|
||||
ccdata->rx3 = x >> 3;
|
||||
ccdata->ry = y;
|
||||
}
|
||||
|
||||
//triggers
|
||||
{
|
||||
u8 trigs[2];
|
||||
m_triggers->GetState( &ccdata->bt, classic_trigger_bitmasks, trigs, focus ? 0x1F : 0 );
|
||||
|
||||
ccdata->lt1 = trigs[0];
|
||||
ccdata->lt2 = trigs[0] >> 3;
|
||||
ccdata->rt = trigs[1];
|
||||
}
|
||||
|
||||
if (focus)
|
||||
{
|
||||
// buttons
|
||||
m_buttons->GetState( &ccdata->bt, classic_button_bitmasks );
|
||||
// dpad
|
||||
m_dpad->GetState( &ccdata->bt, classic_dpad_bitmasks );
|
||||
}
|
||||
|
||||
// flip button bits
|
||||
ccdata->bt ^= 0xFFFF;
|
||||
}
|
||||
|
||||
|
||||
}
|
41
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Classic.h
Normal file
41
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Classic.h
Normal file
@ -0,0 +1,41 @@
|
||||
#include "Attachment.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
class Classic : public Attachment
|
||||
{
|
||||
public:
|
||||
Classic();
|
||||
void GetState( u8* const data, const bool focus );
|
||||
|
||||
enum
|
||||
{
|
||||
PAD_RIGHT = 0x80,
|
||||
PAD_DOWN = 0x40,
|
||||
TRIGGER_L = 0x20,
|
||||
BUTTON_MINUS = 0x10,
|
||||
BUTTON_HOME = 0x08,
|
||||
BUTTON_PLUS = 0x04,
|
||||
TRIGGER_R = 0x02,
|
||||
NOTHING = 0x01,
|
||||
BUTTON_ZL = 0x8000,
|
||||
BUTTON_B = 0x4000,
|
||||
BUTTON_Y = 0x2000,
|
||||
BUTTON_A = 0x1000,
|
||||
BUTTON_X = 0x0800,
|
||||
BUTTON_ZR = 0x0400,
|
||||
PAD_LEFT = 0x0200,
|
||||
PAD_UP = 0x0100,
|
||||
};
|
||||
|
||||
private:
|
||||
Buttons* m_buttons;
|
||||
MixedTriggers* m_triggers;
|
||||
Buttons* m_dpad;
|
||||
AnalogStick* m_left_stick;
|
||||
AnalogStick* m_right_stick;
|
||||
};
|
||||
|
||||
|
||||
}
|
82
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Drums.cpp
Normal file
82
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Drums.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
#include "Drums.h"
|
||||
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
static const u8 drums_id[] = { 0x01, 0x00, 0xa4, 0x20, 0x01, 0x03 };
|
||||
|
||||
static const u16 drum_pad_bitmasks[] =
|
||||
{
|
||||
Drums::PAD_RED,
|
||||
Drums::PAD_YELLOW,
|
||||
Drums::PAD_BLUE,
|
||||
Drums::PAD_GREEN,
|
||||
Drums::PAD_ORANGE,
|
||||
Drums::PAD_BASS,
|
||||
};
|
||||
|
||||
static const char* const drum_pad_names[] =
|
||||
{
|
||||
"Red","Yellow","Blue","Green","Orange","Bass"
|
||||
};
|
||||
|
||||
static const u16 drum_button_bitmasks[] =
|
||||
{
|
||||
Drums::BUTTON_MINUS,
|
||||
Drums::BUTTON_PLUS,
|
||||
};
|
||||
|
||||
Drums::Drums() : Attachment( "Drums" )
|
||||
{
|
||||
// pads
|
||||
groups.push_back( m_pads = new Buttons( "Pads" ) );
|
||||
for ( unsigned int i = 0; i < sizeof(drum_pad_names)/sizeof(*drum_pad_names); ++i )
|
||||
m_pads->controls.push_back( new ControlGroup::Input( drum_pad_names[i] ) );
|
||||
|
||||
// stick
|
||||
groups.push_back( m_stick = new AnalogStick( "Stick" ) );
|
||||
|
||||
// buttons
|
||||
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("-") );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("+") );
|
||||
|
||||
// set up register
|
||||
// id
|
||||
memcpy( ®[0xfa], drums_id, sizeof(drums_id) );
|
||||
}
|
||||
|
||||
void Drums::GetState(u8* const data, const bool focus)
|
||||
{
|
||||
wm_drums_extension* const ddata = (wm_drums_extension*)data;
|
||||
ddata->bt = 0;
|
||||
|
||||
// calibration data not figured out yet?
|
||||
|
||||
// stick
|
||||
{
|
||||
u8 x, y;
|
||||
m_stick->GetState( &x, &y, 0x20, focus ? 0x1F /*0x15*/ : 0 );
|
||||
|
||||
ddata->sx = x;
|
||||
ddata->sy = y;
|
||||
}
|
||||
|
||||
// TODO: softness maybe
|
||||
data[2] = 0xFF;
|
||||
data[3] = 0xFF;
|
||||
|
||||
if (focus)
|
||||
{
|
||||
// buttons
|
||||
m_buttons->GetState( &ddata->bt, drum_button_bitmasks );
|
||||
// pads
|
||||
m_pads->GetState( &ddata->bt, drum_pad_bitmasks );
|
||||
}
|
||||
|
||||
// flip button bits
|
||||
ddata->bt ^= 0xFFFF;
|
||||
}
|
||||
|
||||
}
|
32
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Drums.h
Normal file
32
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Drums.h
Normal file
@ -0,0 +1,32 @@
|
||||
#include "Attachment.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
class Drums : public Attachment
|
||||
{
|
||||
public:
|
||||
Drums();
|
||||
void GetState( u8* const data, const bool focus );
|
||||
|
||||
enum
|
||||
{
|
||||
BUTTON_PLUS = 0x04,
|
||||
BUTTON_MINUS = 0x10,
|
||||
|
||||
PAD_BASS = 0x0400,
|
||||
PAD_BLUE = 0x0800,
|
||||
PAD_GREEN = 0x1000,
|
||||
PAD_YELLOW = 0x2000,
|
||||
PAD_RED = 0x4000,
|
||||
PAD_ORANGE = 0x8000,
|
||||
};
|
||||
|
||||
private:
|
||||
Buttons* m_buttons;
|
||||
Buttons* m_pads;
|
||||
AnalogStick* m_stick;
|
||||
};
|
||||
|
||||
|
||||
}
|
102
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Guitar.cpp
Normal file
102
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Guitar.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
#include "Guitar.h"
|
||||
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
static const u8 guitar_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x03 };
|
||||
|
||||
static const u16 guitar_fret_bitmasks[] =
|
||||
{
|
||||
Guitar::FRET_GREEN,
|
||||
Guitar::FRET_RED,
|
||||
Guitar::FRET_YELLOW,
|
||||
Guitar::FRET_BLUE,
|
||||
Guitar::FRET_ORANGE,
|
||||
};
|
||||
|
||||
static const char* const guitar_fret_names[] =
|
||||
{
|
||||
"Green","Red","Yellow","Blue","Orange",
|
||||
};
|
||||
|
||||
static const u16 guitar_button_bitmasks[] =
|
||||
{
|
||||
Guitar::BUTTON_MINUS,
|
||||
Guitar::BUTTON_PLUS,
|
||||
};
|
||||
|
||||
static const u16 guitar_strum_bitmasks[] =
|
||||
{
|
||||
Guitar::BAR_UP,
|
||||
Guitar::BAR_DOWN,
|
||||
};
|
||||
|
||||
Guitar::Guitar() : Attachment( "Guitar" )
|
||||
{
|
||||
// frets
|
||||
groups.push_back( m_frets = new Buttons( "Frets" ) );
|
||||
for ( unsigned int i = 0; i < sizeof(guitar_fret_names)/sizeof(*guitar_fret_names); ++i )
|
||||
m_frets->controls.push_back( new ControlGroup::Input( guitar_fret_names[i] ) );
|
||||
|
||||
// strum
|
||||
groups.push_back( m_strum = new Buttons( "Strum" ) );
|
||||
m_strum->controls.push_back( new ControlGroup::Input("Up") );
|
||||
m_strum->controls.push_back( new ControlGroup::Input("Down") );
|
||||
|
||||
// buttons
|
||||
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("-") );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("+") );
|
||||
|
||||
// stick
|
||||
groups.push_back( m_stick = new AnalogStick( "Stick" ) );
|
||||
|
||||
// whammy
|
||||
groups.push_back( m_whammy = new Triggers( "Whammy" ) );
|
||||
m_whammy->controls.push_back( new ControlGroup::Input("Bar") );
|
||||
|
||||
// set up register
|
||||
// id
|
||||
memcpy( ®[0xfa], guitar_id, sizeof(guitar_id) );
|
||||
}
|
||||
|
||||
void Guitar::GetState(u8* const data, const bool focus)
|
||||
{
|
||||
wm_guitar_extension* const gdata = (wm_guitar_extension*)data;
|
||||
gdata->bt = 0;
|
||||
|
||||
// calibration data not figured out yet?
|
||||
|
||||
// stick
|
||||
{
|
||||
u8 x, y;
|
||||
m_stick->GetState( &x, &y, 0x20, focus ? 0x1F /*0x15*/ : 0 );
|
||||
|
||||
gdata->sx = x;
|
||||
gdata->sy = y;
|
||||
}
|
||||
|
||||
// TODO: touch bar, probably not
|
||||
gdata->tb = 0x0F; // not touched
|
||||
|
||||
// whammy bar
|
||||
u8 whammy;
|
||||
m_whammy->GetState( &whammy, 0x1F );
|
||||
gdata->whammy = whammy;
|
||||
|
||||
if (focus)
|
||||
{
|
||||
// buttons
|
||||
m_buttons->GetState( &gdata->bt, guitar_button_bitmasks );
|
||||
// frets
|
||||
m_frets->GetState( &gdata->bt, guitar_fret_bitmasks );
|
||||
// strum
|
||||
m_strum->GetState( &gdata->bt, guitar_strum_bitmasks );
|
||||
}
|
||||
|
||||
// flip button bits
|
||||
gdata->bt ^= 0xFFFF;
|
||||
}
|
||||
|
||||
}
|
35
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Guitar.h
Normal file
35
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Guitar.h
Normal file
@ -0,0 +1,35 @@
|
||||
#include "Attachment.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
class Guitar : public Attachment
|
||||
{
|
||||
public:
|
||||
Guitar();
|
||||
void GetState( u8* const data, const bool focus );
|
||||
|
||||
enum
|
||||
{
|
||||
BUTTON_PLUS = 0x04,
|
||||
BUTTON_MINUS = 0x10,
|
||||
BAR_DOWN = 0x40,
|
||||
|
||||
BAR_UP = 0x0100,
|
||||
FRET_YELLOW = 0x0800,
|
||||
FRET_GREEN = 0x1000,
|
||||
FRET_BLUE = 0x2000,
|
||||
FRET_RED = 0x4000,
|
||||
FRET_ORANGE = 0x8000,
|
||||
};
|
||||
|
||||
private:
|
||||
Buttons* m_buttons;
|
||||
Buttons* m_frets;
|
||||
Buttons* m_strum;
|
||||
Triggers* m_whammy;
|
||||
AnalogStick* m_stick;
|
||||
};
|
||||
|
||||
|
||||
}
|
131
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.cpp
Normal file
131
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.cpp
Normal file
@ -0,0 +1,131 @@
|
||||
#include "Nunchuk.h"
|
||||
|
||||
#include "UDPWrapper.h"
|
||||
#include "UDPWiimote.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
static const u8 nunchuck_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x00, 0x00 };
|
||||
/* 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
|
||||
|
||||
// 0x80 = analog stick x and y axis center
|
||||
0xff, 0x00, 0x80,
|
||||
0xff, 0x00, 0x80,
|
||||
0xec, 0x41 // checksum on the last two bytes
|
||||
};
|
||||
|
||||
static const u8 nunchuk_button_bitmasks[] =
|
||||
{
|
||||
Nunchuk::BUTTON_C,
|
||||
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"));
|
||||
m_buttons->controls.push_back(new ControlGroup::Input("C"));
|
||||
m_buttons->controls.push_back(new ControlGroup::Input("Z"));
|
||||
|
||||
// stick
|
||||
groups.push_back(m_stick = new AnalogStick("Stick"));
|
||||
|
||||
// swing
|
||||
groups.push_back(m_swing = new Force("Swing"));
|
||||
|
||||
// tilt
|
||||
groups.push_back(m_tilt = new Tilt("Tilt"));
|
||||
|
||||
// shake
|
||||
groups.push_back(m_shake = new Buttons("Shake"));
|
||||
m_shake->controls.push_back(new ControlGroup::Input("X"));
|
||||
m_shake->controls.push_back(new ControlGroup::Input("Y"));
|
||||
m_shake->controls.push_back(new ControlGroup::Input("Z"));
|
||||
|
||||
// set up register
|
||||
// calibration
|
||||
memcpy(®[0x20], nunchuck_calibration, sizeof(nunchuck_calibration));
|
||||
// id
|
||||
memcpy(®[0xfa], nunchuck_id, sizeof(nunchuck_id));
|
||||
|
||||
// this should get set to 0 on disconnect, but it isn't, o well
|
||||
memset(m_shake_step, 0, sizeof(m_shake_step));
|
||||
}
|
||||
|
||||
void Nunchuk::GetState(u8* const data, const bool focus)
|
||||
{
|
||||
wm_extension* const ncdata = (wm_extension*)data;
|
||||
ncdata->bt = 0;
|
||||
|
||||
// stick / not using calibration data for stick, o well
|
||||
m_stick->GetState(&ncdata->jx, &ncdata->jy, 0x80, focus ? 127 : 0);
|
||||
|
||||
AccelData accel;
|
||||
|
||||
// tilt
|
||||
EmulateTilt(&accel, m_tilt, focus);
|
||||
|
||||
if (focus)
|
||||
{
|
||||
// swing
|
||||
EmulateSwing(&accel, m_swing);
|
||||
// shake
|
||||
EmulateShake(&accel, m_shake, m_shake_step);
|
||||
// buttons
|
||||
m_buttons->GetState(&ncdata->bt, nunchuk_button_bitmasks);
|
||||
}
|
||||
|
||||
// flip the button bits :/
|
||||
ncdata->bt ^= 0x03;
|
||||
|
||||
#ifdef USE_UDP_WIIMOTE
|
||||
if (m_udpWrap->inst)
|
||||
{
|
||||
if (m_udpWrap->updNun)
|
||||
{
|
||||
u8 mask;
|
||||
float x, y;
|
||||
m_udpWrap->inst->getNunchuck(x, y, mask);
|
||||
// buttons
|
||||
if (mask & UDPWM_NC)
|
||||
ncdata->bt &= ~WiimoteEmu::Nunchuk::BUTTON_C;
|
||||
if (mask & UDPWM_NZ)
|
||||
ncdata->bt &= ~WiimoteEmu::Nunchuk::BUTTON_Z;
|
||||
// stick
|
||||
if (ncdata->jx == 0x80 && ncdata->jy == 0x80)
|
||||
{
|
||||
ncdata->jx = u8(0x80 + x*127);
|
||||
ncdata->jy = u8(0x80 + y*127);
|
||||
}
|
||||
}
|
||||
if (m_udpWrap->updNunAccel)
|
||||
{
|
||||
float x,y,z;
|
||||
m_udpWrap->inst->getNunchuckAccel(x,y,z);
|
||||
accel.x=x;
|
||||
accel.y=y;
|
||||
accel.z=z;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
wm_accel* dt = (wm_accel*)&ncdata->ax;
|
||||
accel_cal* calib = (accel_cal*)®[0x20];
|
||||
dt->x=u8(trim(accel.x*(calib->one_g.x-calib->zero_g.x)+calib->zero_g.x));
|
||||
dt->y=u8(trim(accel.y*(calib->one_g.y-calib->zero_g.y)+calib->zero_g.y));
|
||||
dt->z=u8(trim(accel.z*(calib->one_g.z-calib->zero_g.z)+calib->zero_g.z));
|
||||
}
|
||||
|
||||
|
||||
}
|
47
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.h
Normal file
47
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef NUNCHUCK_H
|
||||
#define NUNCHUCK_H
|
||||
|
||||
#include "Attachment.h"
|
||||
|
||||
class UDPWrapper;
|
||||
|
||||
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
|
||||
{
|
||||
BUTTON_C = 0x02,
|
||||
BUTTON_Z = 0x01,
|
||||
};
|
||||
|
||||
private:
|
||||
Tilt* m_tilt;
|
||||
Force* m_swing;
|
||||
|
||||
Buttons* m_shake;
|
||||
|
||||
Buttons* m_buttons;
|
||||
AnalogStick* m_stick;
|
||||
|
||||
unsigned int m_shake_step[3];
|
||||
|
||||
#ifdef USE_UDP_WIIMOTE
|
||||
UDPWrapper* const m_udpWrap;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
121
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Turntable.cpp
Normal file
121
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Turntable.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
#include "Turntable.h"
|
||||
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
static const u8 turntable_id[] = {0x03, 0x00, 0xa4, 0x20, 0x01, 0x03};
|
||||
|
||||
static const u16 turntable_button_bitmasks[] =
|
||||
{
|
||||
Turntable::BUTTON_L_GREEN,
|
||||
Turntable::BUTTON_L_RED,
|
||||
Turntable::BUTTON_L_BLUE,
|
||||
Turntable::BUTTON_R_GREEN,
|
||||
Turntable::BUTTON_R_RED,
|
||||
Turntable::BUTTON_R_BLUE,
|
||||
Turntable::BUTTON_MINUS,
|
||||
Turntable::BUTTON_PLUS,
|
||||
Turntable::BUTTON_EUPHORIA,
|
||||
};
|
||||
|
||||
static const char* const turntable_button_names[] =
|
||||
{
|
||||
"Green Left", "Red Left", "Blue Left",
|
||||
"Green Right", "Red Right", "Blue Right",
|
||||
"-", "+", "Euphoria",
|
||||
};
|
||||
|
||||
Turntable::Turntable() : Attachment("Turntable")
|
||||
{
|
||||
// buttons
|
||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
||||
for (unsigned int i = 0; i < sizeof(turntable_button_names)/sizeof(*turntable_button_names); ++i)
|
||||
m_buttons->controls.push_back(new ControlGroup::Input( turntable_button_names[i]));
|
||||
|
||||
// turntables
|
||||
groups.push_back(m_left_table = new Slider("Table Left"));
|
||||
groups.push_back(m_right_table = new Slider("Table Right"));
|
||||
|
||||
// stick
|
||||
groups.push_back(m_stick = new AnalogStick("Stick"));
|
||||
|
||||
// effect dial
|
||||
groups.push_back(m_effect_dial = new Triggers("Effect"));
|
||||
m_effect_dial->controls.push_back(new ControlGroup::Input("Dial"));
|
||||
|
||||
// crossfade
|
||||
groups.push_back(m_crossfade = new Slider("Crossfade"));
|
||||
|
||||
// set up register
|
||||
// id
|
||||
memcpy(®[0xfa], turntable_id, sizeof(turntable_id));
|
||||
}
|
||||
|
||||
void Turntable::GetState(u8* const data, const bool focus)
|
||||
{
|
||||
wm_turntable_extension* const ttdata = (wm_turntable_extension*)data;
|
||||
ttdata->bt = 0;
|
||||
|
||||
// stick
|
||||
{
|
||||
u8 x, y;
|
||||
m_stick->GetState(&x, &y, 0x20, focus ? 0x1F /*0x15*/ : 0);
|
||||
|
||||
ttdata->sx = x;
|
||||
ttdata->sy = y;
|
||||
}
|
||||
|
||||
// left table
|
||||
{
|
||||
s8 tt = 0;
|
||||
m_left_table->GetState(&tt, focus ? 0x1F : 0);
|
||||
|
||||
ttdata->ltable1 = tt;
|
||||
ttdata->ltable2 = tt << 5;
|
||||
}
|
||||
|
||||
// right table
|
||||
{
|
||||
s8 tt = 0;
|
||||
m_right_table->GetState(&tt, focus ? 0x1F : 0);
|
||||
|
||||
ttdata->rtable1 = tt;
|
||||
ttdata->rtable2 = tt << 1;
|
||||
ttdata->rtable3 = tt << 3;
|
||||
ttdata->rtable4 = tt << 5;
|
||||
}
|
||||
|
||||
// effect dial
|
||||
{
|
||||
u8 dial = 0;
|
||||
m_effect_dial->GetState(&dial, focus ? 0xF : 0);
|
||||
|
||||
ttdata->dial1 = dial;
|
||||
ttdata->dial2 = dial << 3;
|
||||
}
|
||||
|
||||
// crossfade slider
|
||||
{
|
||||
u8 cfs = 0;
|
||||
m_crossfade->GetState(&cfs, 8, 7);
|
||||
|
||||
ttdata->slider = cfs;
|
||||
}
|
||||
|
||||
if (focus)
|
||||
{
|
||||
// buttons
|
||||
m_buttons->GetState(&ttdata->bt, turntable_button_bitmasks);
|
||||
}
|
||||
|
||||
// flip button bits :/
|
||||
ttdata->bt ^= (
|
||||
BUTTON_L_GREEN | BUTTON_L_RED | BUTTON_L_BLUE |
|
||||
BUTTON_R_GREEN | BUTTON_R_RED | BUTTON_R_BLUE |
|
||||
BUTTON_MINUS | BUTTON_PLUS | BUTTON_EUPHORIA
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
37
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Turntable.h
Normal file
37
Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Turntable.h
Normal file
@ -0,0 +1,37 @@
|
||||
#include "Attachment.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
class Turntable : public Attachment
|
||||
{
|
||||
public:
|
||||
Turntable();
|
||||
void GetState(u8* const data, const bool focus);
|
||||
|
||||
enum
|
||||
{
|
||||
BUTTON_EUPHORIA = 0x1000,
|
||||
|
||||
BUTTON_L_GREEN = 0x0800,
|
||||
BUTTON_L_RED = 0x20,
|
||||
BUTTON_L_BLUE = 0x8000,
|
||||
|
||||
BUTTON_R_GREEN = 0x2000,
|
||||
BUTTON_R_RED = 0x02,
|
||||
BUTTON_R_BLUE = 0x0400,
|
||||
|
||||
BUTTON_MINUS = 0x10,
|
||||
BUTTON_PLUS = 0x04,
|
||||
};
|
||||
|
||||
private:
|
||||
Buttons* m_buttons;
|
||||
MixedTriggers* m_triggers;
|
||||
AnalogStick* m_stick;
|
||||
Triggers *m_effect_dial;
|
||||
Slider *m_left_table, *m_right_table, *m_crossfade;
|
||||
};
|
||||
|
||||
|
||||
}
|
542
Source/Core/Core/Src/HW/WiimoteEmu/EmuSubroutines.cpp
Normal file
542
Source/Core/Core/Src/HW/WiimoteEmu/EmuSubroutines.cpp
Normal file
@ -0,0 +1,542 @@
|
||||
// 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 <fstream>
|
||||
|
||||
#include "Common.h"
|
||||
#include "FileUtil.h"
|
||||
|
||||
#include "WiimoteEmu.h"
|
||||
#include "WiimoteHid.h"
|
||||
#include "../WiimoteReal/WiimoteReal.h"
|
||||
|
||||
#include "Attachment/Attachment.h"
|
||||
|
||||
/* Bit shift conversions */
|
||||
u32 swap24(const u8* src)
|
||||
{
|
||||
return (src[0] << 16) | (src[1] << 8) | src[2];
|
||||
}
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
void Wiimote::ReportMode(const wm_report_mode* const 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);
|
||||
|
||||
//m_reporting_auto = dr->all_the_time;
|
||||
m_reporting_auto = dr->continuous; // this right?
|
||||
m_reporting_mode = dr->mode;
|
||||
//m_reporting_channel = _channelID; // this is set in every Interrupt/Control Channel now
|
||||
|
||||
// reset IR camera
|
||||
//memset(m_reg_ir, 0, sizeof(*m_reg_ir)); //ugly hack
|
||||
|
||||
if (dr->mode > 0x37)
|
||||
PanicAlert("Wiimote: Unsupported Reporting mode.");
|
||||
else if (dr->mode < WM_REPORT_CORE)
|
||||
PanicAlert("Wiimote: Reporting mode < 0x30.");
|
||||
}
|
||||
|
||||
/* 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 Wiimote::HidOutputReport(const wm_report* const sr, const bool send_ack)
|
||||
{
|
||||
INFO_LOG(WIIMOTE, "HidOutputReport (page: %i, cid: 0x%02x, wm: 0x%02x)", m_index, m_reporting_channel, sr->wm);
|
||||
|
||||
// wiibrew:
|
||||
// In every single Output Report, bit 0 (0x01) of the first byte controls the Rumble feature.
|
||||
m_rumble_on = sr->rumble;
|
||||
|
||||
switch (sr->wm)
|
||||
{
|
||||
case WM_RUMBLE : // 0x10
|
||||
// this is handled above
|
||||
return; // no ack
|
||||
break;
|
||||
|
||||
case WM_LEDS : // 0x11
|
||||
//INFO_LOG(WIIMOTE, "Set LEDs: 0x%02x", sr->data[0]);
|
||||
m_status.leds = sr->data[0] >> 4;
|
||||
break;
|
||||
|
||||
case WM_REPORT_MODE : // 0x12
|
||||
ReportMode((wm_report_mode*)sr->data);
|
||||
break;
|
||||
|
||||
case WM_IR_PIXEL_CLOCK : // 0x13
|
||||
//INFO_LOG(WIIMOTE, "WM IR Clock: 0x%02x", sr->data[0]);
|
||||
//m_ir_clock = sr->enable;
|
||||
if (false == sr->ack)
|
||||
return;
|
||||
break;
|
||||
|
||||
case WM_SPEAKER_ENABLE : // 0x14
|
||||
//INFO_LOG(WIIMOTE, "WM Speaker Enable: 0x%02x", sr->data[0]);
|
||||
//PanicAlert( "WM Speaker Enable: %d", sr->data[0] );
|
||||
m_status.speaker = sr->enable;
|
||||
if (false == sr->ack)
|
||||
return;
|
||||
break;
|
||||
|
||||
case WM_REQUEST_STATUS : // 0x15
|
||||
RequestStatus((wm_request_status*)sr->data);
|
||||
return; // sends its own ack
|
||||
break;
|
||||
|
||||
case WM_WRITE_DATA : // 0x16
|
||||
WriteData((wm_write_data*)sr->data);
|
||||
break;
|
||||
|
||||
case WM_READ_DATA : // 0x17
|
||||
ReadData((wm_read_data*)sr->data);
|
||||
return; // sends its own ack
|
||||
break;
|
||||
|
||||
case WM_WRITE_SPEAKER_DATA : // 0x18
|
||||
#ifdef USE_WIIMOTE_EMU_SPEAKER
|
||||
SpeakerData((wm_speaker_data*)sr->data);
|
||||
#endif
|
||||
// TODO: Does this need an ack?
|
||||
return; // no ack
|
||||
break;
|
||||
|
||||
case WM_SPEAKER_MUTE : // 0x19
|
||||
//INFO_LOG(WIIMOTE, "WM Speaker Mute: 0x%02x", sr->data[0]);
|
||||
//PanicAlert( "WM Speaker Mute: %d", sr->data[0] & 0x04 );
|
||||
#ifdef USE_WIIMOTE_EMU_SPEAKER
|
||||
// testing
|
||||
if (sr->data[0] & 0x04)
|
||||
memset(&m_channel_status, 0, sizeof(m_channel_status));
|
||||
#endif
|
||||
m_speaker_mute = sr->enable;
|
||||
if (false == sr->ack)
|
||||
return;
|
||||
break;
|
||||
|
||||
case WM_IR_LOGIC: // 0x1a
|
||||
// comment from old plugin:
|
||||
// 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]);
|
||||
m_status.ir = sr->enable;
|
||||
if (false == sr->ack)
|
||||
return;
|
||||
break;
|
||||
|
||||
default:
|
||||
PanicAlert("HidOutputReport: Unknown channel 0x%02x", sr->wm);
|
||||
return; // no ack
|
||||
break;
|
||||
}
|
||||
|
||||
// send ack
|
||||
if (send_ack)
|
||||
SendAck(sr->wm);
|
||||
}
|
||||
|
||||
/* 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 Wiimote::SendAck(u8 _reportID)
|
||||
{
|
||||
u8 data[6];
|
||||
|
||||
data[0] = 0xA1;
|
||||
data[1] = WM_ACK_DATA;
|
||||
|
||||
wm_acknowledge* const ack = (wm_acknowledge*)(data + 2);
|
||||
|
||||
ack->buttons = m_status.buttons;
|
||||
ack->reportID = _reportID;
|
||||
ack->errorID = 0;
|
||||
|
||||
Core::Callback_WiimoteInterruptChannel( m_index, m_reporting_channel, data, sizeof(data));
|
||||
}
|
||||
|
||||
void Wiimote::HandleExtensionSwap()
|
||||
{
|
||||
// handle switch extension
|
||||
if (m_extension->active_extension != m_extension->switch_extension)
|
||||
{
|
||||
// if an extension is currently connected and we want to switch to a different extension
|
||||
if ((m_extension->active_extension > 0) && m_extension->switch_extension)
|
||||
// detach extension first, wait til next Update() or RequestStatus() call to change to the new extension
|
||||
m_extension->active_extension = 0;
|
||||
else
|
||||
// set the wanted extension
|
||||
m_extension->active_extension = m_extension->switch_extension;
|
||||
|
||||
// update status struct
|
||||
m_status.extension = m_extension->active_extension ? 1 : 0;
|
||||
|
||||
// set register, I hate this line
|
||||
m_register[0xa40000] = ((WiimoteEmu::Attachment*)m_extension->attachments[m_extension->active_extension])->reg;
|
||||
}
|
||||
}
|
||||
|
||||
// old comment
|
||||
/* 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 Wiimote::RequestStatus(const wm_request_status* const rs)
|
||||
{
|
||||
HandleExtensionSwap();
|
||||
|
||||
// set up report
|
||||
u8 data[8];
|
||||
data[0] = 0xA1;
|
||||
data[1] = WM_STATUS_REPORT;
|
||||
|
||||
// status values
|
||||
*(wm_status_report*)(data + 2) = m_status;
|
||||
|
||||
// hybrid wiimote stuff
|
||||
if (WIIMOTE_SRC_HYBRID == g_wiimote_sources[m_index] && (m_extension->switch_extension <= 0))
|
||||
{
|
||||
using namespace WiimoteReal;
|
||||
|
||||
g_refresh_critsec.Enter();
|
||||
if (g_wiimotes[m_index])
|
||||
{
|
||||
wm_request_status rpt;
|
||||
rpt.rumble = 0;
|
||||
g_wiimotes[m_index]->SendPacket(WM_REQUEST_STATUS, &rpt, sizeof(rpt));
|
||||
}
|
||||
g_refresh_critsec.Leave();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// send report
|
||||
Core::Callback_WiimoteInterruptChannel(m_index, m_reporting_channel, data, sizeof(data));
|
||||
}
|
||||
|
||||
/* Write data to Wiimote and Extensions registers. */
|
||||
void Wiimote::WriteData(const wm_write_data* const wd)
|
||||
{
|
||||
u32 address = swap24(wd->address);
|
||||
|
||||
// ignore the 0x010000 bit
|
||||
address &= 0xFEFFFF;
|
||||
|
||||
if (wd->size > 16)
|
||||
{
|
||||
PanicAlert("WriteData: size is > 16 bytes");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (wd->space)
|
||||
{
|
||||
case WM_SPACE_EEPROM :
|
||||
{
|
||||
// Write to EEPROM
|
||||
|
||||
if (address + wd->size > WIIMOTE_EEPROM_SIZE)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "WriteData: address + size out of bounds!");
|
||||
PanicAlert("WriteData: address + size out of bounds!");
|
||||
return;
|
||||
}
|
||||
memcpy(m_eeprom + address, wd->data, wd->size);
|
||||
|
||||
// write mii data to file
|
||||
// i need to improve this greatly
|
||||
if (address >= 0x0FCA && address < 0x12C0)
|
||||
{
|
||||
// writing the whole mii block each write :/
|
||||
std::ofstream file;
|
||||
file.open( (std::string(File::GetUserPath(D_WIIUSER_IDX)) + "mii.bin").c_str(), std::ios::binary | std::ios::out);
|
||||
file.write((char*)m_eeprom + 0x0FCA, 0x02f0);
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_SPACE_REGS1 :
|
||||
case WM_SPACE_REGS2 :
|
||||
{
|
||||
// Write to Control Register
|
||||
|
||||
// ignore second byte for extension area
|
||||
if (0xA4 == (address >> 16))
|
||||
address &= 0xFF00FF;
|
||||
|
||||
// write to the register
|
||||
m_register.Write(address, wd->data, wd->size);
|
||||
|
||||
switch (address >> 16)
|
||||
{
|
||||
// speaker
|
||||
case 0xa2 :
|
||||
//PanicAlert("Write to speaker!!");
|
||||
break;
|
||||
// extension register
|
||||
case 0xa4 :
|
||||
{
|
||||
// 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
|
||||
// I might have f'ed this up
|
||||
if ( address >= 0xa40040 && address <= 0xa4004c )
|
||||
wiimote_gen_key(&m_ext_key, m_reg_ext->encryption_key);
|
||||
//else if ( address >= 0xa40020 && address < 0xa40040 )
|
||||
// PanicAlert("Writing to extension calibration data! Extension may misbehave");
|
||||
}
|
||||
break;
|
||||
// ir
|
||||
case 0xB0 :
|
||||
if (5 == m_reg_ir->mode)
|
||||
PanicAlert("IR Full Mode is Unsupported!");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PanicAlert("WriteData: unimplemented parameters!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read data from Wiimote and Extensions registers. */
|
||||
void Wiimote::ReadData(const wm_read_data* const rd)
|
||||
{
|
||||
u32 address = swap24(rd->address);
|
||||
u16 size = Common::swap16(rd->size);
|
||||
|
||||
// ignore the 0x010000 bit
|
||||
address &= 0xFEFFFF;
|
||||
|
||||
// hybrid wiimote stuff
|
||||
// relay the read data request to real-wiimote
|
||||
if (WIIMOTE_SRC_HYBRID == g_wiimote_sources[m_index] && ((0xA4 != (address >> 16)) || (m_extension->switch_extension <= 0)))
|
||||
{
|
||||
WiimoteReal::InterruptChannel(m_index, m_reporting_channel, ((u8*)rd) - 2, sizeof(wm_read_data) + 2); // hacky
|
||||
|
||||
// don't want emu-wiimote to send reply
|
||||
return;
|
||||
}
|
||||
|
||||
ReadRequest rr;
|
||||
u8* block = new u8[size];
|
||||
|
||||
switch (rd->space)
|
||||
{
|
||||
case WM_SPACE_EEPROM :
|
||||
{
|
||||
//PanicAlert("ReadData: reading from EEPROM: address: 0x%x size: 0x%x", address, size);
|
||||
// Read from EEPROM
|
||||
if (address + size >= WIIMOTE_EEPROM_FREE_SIZE)
|
||||
{
|
||||
if (address + size > WIIMOTE_EEPROM_SIZE)
|
||||
{
|
||||
PanicAlert("ReadData: address + size out of bounds");
|
||||
return;
|
||||
}
|
||||
// generate a read error
|
||||
size = 0;
|
||||
}
|
||||
|
||||
// read mii data from file
|
||||
// i need to improve this greatly
|
||||
if (address >= 0x0FCA && address < 0x12C0)
|
||||
{
|
||||
// reading the whole mii block :/
|
||||
std::ifstream file;
|
||||
file.open( (std::string(File::GetUserPath(D_WIIUSER_IDX)) + "mii.bin").c_str(), std::ios::binary | std::ios::in);
|
||||
file.read((char*)m_eeprom + 0x0FCA, 0x02f0);
|
||||
file.close();
|
||||
}
|
||||
|
||||
// read mem to be sent to wii
|
||||
memcpy( block, m_eeprom + address, size);
|
||||
}
|
||||
break;
|
||||
case WM_SPACE_REGS1 :
|
||||
case WM_SPACE_REGS2 :
|
||||
{
|
||||
// Read from Control Register
|
||||
|
||||
// ignore second byte for extension area
|
||||
if (0xA4 == (address >> 16))
|
||||
address &= 0xFF00FF;
|
||||
|
||||
// read block to send to wii
|
||||
m_register.Read( address, block, size );
|
||||
|
||||
switch (address >> 16)
|
||||
{
|
||||
// speaker
|
||||
case 0xa2 :
|
||||
//PanicAlert("read from speaker!!");
|
||||
break;
|
||||
// extension
|
||||
case 0xa4 :
|
||||
{
|
||||
// Encrypt data read from extension register
|
||||
// Check if encrypted reads is on
|
||||
if (0xaa == m_reg_ext->encryption)
|
||||
wiimote_encrypt(&m_ext_key, block, address & 0xffff, (u8)size);
|
||||
|
||||
//if ( address >= 0xa40008 && address < 0xa40020 )
|
||||
// PanicAlert("Reading extension data from register");
|
||||
}
|
||||
break;
|
||||
// motion plus
|
||||
case 0xa6 :
|
||||
{
|
||||
// emulated motion plus is not yet supported
|
||||
// return read error
|
||||
size = 0;
|
||||
|
||||
// motion plus crap copied from old wiimote plugin
|
||||
//block[0xFC] = 0xA6;
|
||||
//block[0xFD] = 0x20;
|
||||
//block[0xFE] = 0x00;
|
||||
//block[0xFF] = 0x05;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :
|
||||
PanicAlert("WmReadData: unimplemented parameters (size: %i, addr: 0x%x)!", size, rd->space);
|
||||
break;
|
||||
}
|
||||
|
||||
// want the requested address, not the above modified one
|
||||
rr.address = swap24(rd->address);
|
||||
rr.size = size;
|
||||
//rr.channel = _channelID;
|
||||
rr.position = 0;
|
||||
rr.data = block;
|
||||
|
||||
// send up to 16 bytes
|
||||
SendReadDataReply(rr);
|
||||
|
||||
// if there is more data to be sent, add it to the queue
|
||||
if (rr.size)
|
||||
m_read_requests.push( rr );
|
||||
else
|
||||
delete[] rr.data;
|
||||
}
|
||||
|
||||
// old comment
|
||||
/* 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.
|
||||
*/
|
||||
void Wiimote::SendReadDataReply(ReadRequest& _request)
|
||||
{
|
||||
u8 data[23];
|
||||
data[0] = 0xA1;
|
||||
data[1] = WM_READ_DATA_REPLY;
|
||||
|
||||
wm_read_data_reply* const reply = (wm_read_data_reply*)(data + 2);
|
||||
reply->buttons = m_status.buttons;
|
||||
reply->address = Common::swap16(_request.address);
|
||||
|
||||
// generate a read error
|
||||
// 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 calibration 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 (0 == _request.size)
|
||||
{
|
||||
reply->size = 0x0f;
|
||||
reply->error = 0x08;
|
||||
|
||||
memset(reply->data, 0, sizeof(reply->data));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Limit the amt to 16 bytes
|
||||
// AyuanX: the MTU is 640B though... what a waste!
|
||||
const int amt = std::min( (unsigned int)16, _request.size );
|
||||
|
||||
// no error
|
||||
reply->error = 0;
|
||||
|
||||
// 0x1 means two bytes, 0xf means 16 bytes
|
||||
reply->size = amt - 1;
|
||||
|
||||
// Clear the mem first
|
||||
memset(reply->data, 0, sizeof(reply->data));
|
||||
|
||||
// copy piece of mem
|
||||
memcpy(reply->data, _request.data + _request.position, amt);
|
||||
|
||||
// update request struct
|
||||
_request.size -= amt;
|
||||
_request.position += amt;
|
||||
_request.address += amt;
|
||||
}
|
||||
|
||||
// Send a piece
|
||||
Core::Callback_WiimoteInterruptChannel(m_index, m_reporting_channel, data, sizeof(data));
|
||||
}
|
||||
|
||||
void Wiimote::DoState(PointerWrap& p)
|
||||
{
|
||||
// not working :(
|
||||
//if (p.MODE_READ == p.GetMode())
|
||||
//{
|
||||
// // LOAD
|
||||
// Reset(); // should cause a status report to be sent, then wii should re-setup wiimote
|
||||
//}
|
||||
//p.Do(m_reporting_channel);
|
||||
}
|
||||
|
||||
}
|
295
Source/Core/Core/Src/HW/WiimoteEmu/Encryption.cpp
Normal file
295
Source/Core/Core/Src/HW/WiimoteEmu/Encryption.cpp
Normal file
@ -0,0 +1,295 @@
|
||||
// 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 "Encryption.h"
|
||||
|
||||
|
||||
static const 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},
|
||||
};
|
||||
|
||||
static const 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,
|
||||
};
|
||||
|
||||
static const 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(const u8 a, const u8 b)
|
||||
{
|
||||
return (a>>b) | ((a<<(8-b))&0xff);
|
||||
}
|
||||
|
||||
|
||||
void genkey(const u8* const rand, const u8 idx, u8* const key)
|
||||
{
|
||||
const u8* const ans = ans_tbl[idx];
|
||||
u8 t0[10];
|
||||
|
||||
for(int 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(const u8* const rand, const u8* const key, const u8 idx, u8* const ft, u8* const 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* const key, const u8* const 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 (0 == 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
|
||||
}
|
||||
|
||||
// TODO: is there a reason these can only handle a length of 255?
|
||||
/* Encrypt data */
|
||||
void wiimote_encrypt(const wiimote_key* const key, u8* const data, int addr, const 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(const wiimote_key* const key, u8* const data, int addr, const u8 len)
|
||||
{
|
||||
for (int i = 0; i < len; ++i, ++addr)
|
||||
data[i] = (data[i] ^ key->sb[addr % 8]) + key->ft[addr % 8];
|
||||
}
|
41
Source/Core/Core/Src/HW/WiimoteEmu/Encryption.h
Normal file
41
Source/Core/Core/Src/HW/WiimoteEmu/Encryption.h
Normal file
@ -0,0 +1,41 @@
|
||||
// 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/
|
||||
|
||||
|
||||
#ifndef WIIMOTE_EXTENSION_ENCRYPTION_H
|
||||
#define WIIMOTE_EXTENSION_ENCRYPTION_H
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* They key structure to use with wiimote_gen_key() */
|
||||
// ----------------
|
||||
struct wiimote_key
|
||||
{
|
||||
u8 ft[8];
|
||||
u8 sb[8];
|
||||
};
|
||||
|
||||
|
||||
void wiimote_encrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len);
|
||||
void wiimote_decrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len);
|
||||
|
||||
void wiimote_gen_key(wiimote_key* const key, const u8* const keydata);
|
||||
|
||||
|
||||
#endif
|
||||
|
89
Source/Core/Core/Src/HW/WiimoteEmu/MatrixMath.h
Normal file
89
Source/Core/Core/Src/HW/WiimoteEmu/MatrixMath.h
Normal file
@ -0,0 +1,89 @@
|
||||
#ifndef MATRIXMATH_H
|
||||
#define MATRIXMATH_H
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
typedef double Matrix[4][4];
|
||||
typedef struct
|
||||
{
|
||||
double x,y,z;
|
||||
} Vertex;
|
||||
|
||||
inline void MatrixIdentity(Matrix & m)
|
||||
{
|
||||
m[0][0]=1; m[0][1]=0; m[0][2]=0; m[0][3]=0;
|
||||
m[1][0]=0; m[1][1]=1; m[1][2]=0; m[1][3]=0;
|
||||
m[2][0]=0; m[2][1]=0; m[2][2]=1; m[2][3]=0;
|
||||
m[3][0]=0; m[3][1]=0; m[3][2]=0; m[3][3]=1;
|
||||
}
|
||||
|
||||
inline void MatrixFrustum(Matrix &m, double l, double r, double b, double t, double n, double f)
|
||||
{
|
||||
m[0][0]=2*n/(r-l); m[0][1]=0; m[0][2]=0; m[0][3]=0;
|
||||
m[1][0]=0; m[1][1]=2*n/(t-b); m[1][2]=0; m[1][3]=0;
|
||||
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;
|
||||
|
||||
ymax = nplane * tan(fovy * M_PI / 360.0);
|
||||
ymin = -ymax;
|
||||
xmin = ymin * aspect;
|
||||
xmax = ymax * aspect;
|
||||
|
||||
MatrixFrustum(m,xmin,xmax,ymin,ymax,nplane,fplane);
|
||||
}
|
||||
|
||||
inline void MatrixRotationByZ(Matrix &m, double sin, double cos)
|
||||
{
|
||||
m[0][0]=cos; m[0][1]=-sin; m[0][2]=0; m[0][3]=0;
|
||||
m[1][0]=sin; m[1][1]=cos; m[1][2]=0; m[1][3]=0;
|
||||
m[2][0]=0; m[2][1]=0; m[2][2]=1; m[2][3]=0;
|
||||
m[3][0]=0; m[3][1]=0; m[3][2]=0; m[3][3]=1;
|
||||
}
|
||||
|
||||
inline void MatrixScale(Matrix &m, double xfact, double yfact, double zfact)
|
||||
{
|
||||
m[0][0]=xfact; m[0][1]=0; m[0][2]=0; m[0][3]=0;
|
||||
m[1][0]=0; m[1][1]=yfact; m[1][2]=0; m[1][3]=0;
|
||||
m[2][0]=0; m[2][1]=0; m[2][2]=zfact; m[2][3]=0;
|
||||
m[3][0]=0; m[3][1]=0; m[3][2]=0; m[3][3]=1;
|
||||
}
|
||||
|
||||
inline void MatrixMultiply(Matrix &r, const Matrix &a, const Matrix &b)
|
||||
{
|
||||
for (int i=0; i<16; i++)
|
||||
r[i>>2][i&3]=0.0f;
|
||||
for (int i=0; i<4; i++)
|
||||
for (int j=0; j<4; j++)
|
||||
for (int k=0; k<4; k++)
|
||||
r[i][j]+=a[i][k]*b[k][j];
|
||||
}
|
||||
|
||||
inline void MatrixTransformVertex(Matrix const & m, Vertex & v)
|
||||
{
|
||||
Vertex ov;
|
||||
double w;
|
||||
ov.x=v.x;
|
||||
ov.y=v.y;
|
||||
ov.z=v.z;
|
||||
v.x = m[0][0] * ov.x + m[0][1] * ov.y + m[0][2] * ov.z + m[0][3];
|
||||
v.y = m[1][0] * ov.x + m[1][1] * ov.y + m[1][2] * ov.z + m[1][3];
|
||||
v.z = m[2][0] * ov.x + m[2][1] * ov.y + m[2][2] * ov.z + m[2][3];
|
||||
w = m[3][0] * ov.x + m[3][1] * ov.y + m[3][2] * ov.z + m[3][3];
|
||||
if (w!=0)
|
||||
{
|
||||
v.x/=w;
|
||||
v.y/=w;
|
||||
v.z/=w;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
38
Source/Core/Core/Src/HW/WiimoteEmu/Speaker.cpp
Normal file
38
Source/Core/Core/Src/HW/WiimoteEmu/Speaker.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "WiimoteEmu.h"
|
||||
|
||||
#ifdef USE_WIIMOTE_EMU_SPEAKER
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
void Wiimote::SpeakerData(wm_speaker_data* sd)
|
||||
{
|
||||
SoundBuffer sb;
|
||||
sb.samples = new s16[sd->length * 2];
|
||||
|
||||
s16* s = sb.samples;
|
||||
const u8* const e = sd->data + sd->length;
|
||||
for ( const u8* i = sd->data; i<e; ++i )
|
||||
{
|
||||
*s++ = NGCADPCM::ADPDecodeSample(*i & 0x0F, sd->data[0] & 0x0F, &m_channel_status.hist1p, &m_channel_status.hist2p);
|
||||
*s++ = NGCADPCM::ADPDecodeSample(*i >> 4, sd->data[0] >> 4, &m_channel_status.hist1p, &m_channel_status.hist2p);
|
||||
}
|
||||
|
||||
alGenBuffers(1, &sb.buffer);
|
||||
// TODO make this not always 3000
|
||||
alBufferData(sb.buffer, AL_FORMAT_MONO16, sb.samples, (sd->length * sizeof(short) * 2), 3360);
|
||||
// testing
|
||||
//alBufferData(sb.buffer, AL_FORMAT_MONO16, sb.samples, (sd->length * sizeof(short) * 2), 48000/m_reg_speaker->sample_rate);
|
||||
alSourceQueueBuffers(m_audio_source, 1, &sb.buffer);
|
||||
|
||||
ALint state;
|
||||
alGetSourcei(m_audio_source, AL_SOURCE_STATE, &state);
|
||||
if (AL_PLAYING != state)
|
||||
alSourcePlay(m_audio_source);
|
||||
|
||||
m_audio_buffers.push(sb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
56
Source/Core/Core/Src/HW/WiimoteEmu/UDPTLayer.h
Normal file
56
Source/Core/Core/Src/HW/WiimoteEmu/UDPTLayer.h
Normal file
@ -0,0 +1,56 @@
|
||||
//UDP Wiimote Translation Layer
|
||||
|
||||
#if (defined(USE_UDP_WIIMOTE) && !defined(UDPTLAYER_H))
|
||||
#define UDPTLAYER_H
|
||||
|
||||
#include "UDPWiimote.h"
|
||||
#include "WiimoteEmu.h"
|
||||
|
||||
using WiimoteEmu::Wiimote;
|
||||
|
||||
namespace UDPTLayer
|
||||
{
|
||||
void GetButtons(UDPWrapper * m , wm_core * butt)
|
||||
{
|
||||
if (!(m->inst)) return;
|
||||
if (!(m->updButt)) return;
|
||||
u32 mask=m->inst->getButtons();
|
||||
*butt|=(mask&UDPWM_BA)?Wiimote::BUTTON_A:0;
|
||||
*butt|=(mask&UDPWM_BB)?Wiimote::BUTTON_B:0;
|
||||
*butt|=(mask&UDPWM_B1)?Wiimote::BUTTON_ONE:0;
|
||||
*butt|=(mask&UDPWM_B2)?Wiimote::BUTTON_TWO:0;
|
||||
*butt|=(mask&UDPWM_BP)?Wiimote::BUTTON_PLUS:0;
|
||||
*butt|=(mask&UDPWM_BM)?Wiimote::BUTTON_MINUS:0;
|
||||
*butt|=(mask&UDPWM_BH)?Wiimote::BUTTON_HOME:0;
|
||||
*butt|=(mask&UDPWM_BU)?Wiimote::PAD_UP:0;
|
||||
*butt|=(mask&UDPWM_BD)?Wiimote::PAD_DOWN:0;
|
||||
*butt|=(mask&UDPWM_BL)?Wiimote::PAD_LEFT:0;
|
||||
*butt|=(mask&UDPWM_BR)?Wiimote::PAD_RIGHT:0;
|
||||
}
|
||||
|
||||
void GetAcceleration(UDPWrapper * m , WiimoteEmu::AccelData * const data)
|
||||
{
|
||||
if (!(m->inst)) return;
|
||||
if (!(m->updAccel)) return;
|
||||
float x,y,z;
|
||||
m->inst->getAccel(x,y,z);
|
||||
data->x=x;
|
||||
data->y=y;
|
||||
data->z=z;
|
||||
}
|
||||
|
||||
void GetIR( UDPWrapper * m, float * x, float * y, float * z)
|
||||
{
|
||||
if (!(m->inst)) return;
|
||||
if (!(m->updIR)) return;
|
||||
if ((*x>=-0.999)&&(*x<=0.999)&&(*y>=-0.999)&&(*y<=0.999)) return; //the recieved values are used ONLY when the normal pointer is offscreen
|
||||
float _x,_y;
|
||||
m->inst->getIR(_x,_y);
|
||||
*x=_x*2-1;
|
||||
*y=-(_y*2-1);
|
||||
*z=0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
1012
Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp
Normal file
1012
Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp
Normal file
File diff suppressed because it is too large
Load Diff
243
Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.h
Normal file
243
Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.h
Normal file
@ -0,0 +1,243 @@
|
||||
#ifndef _CONEMU_WIIMOTE_H_
|
||||
#define _CONEMU_WIIMOTE_H_
|
||||
|
||||
//#define USE_WIIMOTE_EMU_SPEAKER
|
||||
|
||||
//#include <Core.h>
|
||||
//#include <HW/StreamADPCM.h>
|
||||
// just used to get the OpenAL includes :p
|
||||
//#include <OpenALStream.h>
|
||||
|
||||
#include "../../Core.h"
|
||||
|
||||
#include "ControllerEmu.h"
|
||||
#include "ChunkFile.h"
|
||||
|
||||
#include "WiimoteHid.h"
|
||||
#include "Encryption.h"
|
||||
#include "UDPWrapper.h"
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
|
||||
#define PI 3.14159265358979323846
|
||||
|
||||
// Registry sizes
|
||||
#define WIIMOTE_EEPROM_SIZE (16*1024)
|
||||
#define WIIMOTE_EEPROM_FREE_SIZE 0x1700
|
||||
#define WIIMOTE_REG_SPEAKER_SIZE 10
|
||||
#define WIIMOTE_REG_EXT_SIZE 0x100
|
||||
#define WIIMOTE_REG_IR_SIZE 0x34
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
struct ReportFeatures
|
||||
{
|
||||
u8 core, accel, ir, ext, size;
|
||||
};
|
||||
|
||||
struct AccelData
|
||||
{
|
||||
double x,y,z;
|
||||
};
|
||||
|
||||
extern const ReportFeatures reporting_mode_features[];
|
||||
|
||||
void EmulateShake(AccelData* const accel_data
|
||||
, ControllerEmu::Buttons* const buttons_group
|
||||
, unsigned int* const shake_step);
|
||||
|
||||
void EmulateTilt(AccelData* const accel
|
||||
, ControllerEmu::Tilt* const tilt_group
|
||||
, const bool focus, const bool sideways = false, const bool upright = false);
|
||||
|
||||
void EmulateSwing(AccelData* const accel
|
||||
, ControllerEmu::Force* const tilt_group
|
||||
, const bool sideways = false, const bool upright = false);
|
||||
|
||||
inline double trim(double a)
|
||||
{
|
||||
if (a<=0) return 0;
|
||||
if (a>=255) return 255;
|
||||
return a;
|
||||
}
|
||||
|
||||
class Wiimote : public ControllerEmu
|
||||
{
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
PAD_LEFT = 0x01,
|
||||
PAD_RIGHT = 0x02,
|
||||
PAD_DOWN = 0x04,
|
||||
PAD_UP = 0x08,
|
||||
BUTTON_PLUS = 0x10,
|
||||
|
||||
BUTTON_TWO = 0x0100,
|
||||
BUTTON_ONE = 0x0200,
|
||||
BUTTON_B = 0x0400,
|
||||
BUTTON_A = 0x0800,
|
||||
BUTTON_MINUS = 0x1000,
|
||||
BUTTON_HOME = 0x8000,
|
||||
};
|
||||
|
||||
Wiimote( const unsigned int index );
|
||||
std::string GetName() const;
|
||||
|
||||
void Update();
|
||||
void InterruptChannel(const u16 _channelID, const void* _pData, u32 _Size);
|
||||
void ControlChannel(const u16 _channelID, const void* _pData, u32 _Size);
|
||||
|
||||
void DoState(PointerWrap& p);
|
||||
|
||||
void LoadDefaults(const ControllerInterface& ciface);
|
||||
|
||||
protected:
|
||||
bool Step();
|
||||
void HidOutputReport(const wm_report* const sr, const bool send_ack = true);
|
||||
void HandleExtensionSwap();
|
||||
|
||||
void GetCoreData(u8* const data);
|
||||
void GetAccelData(u8* const data, u8* const buttons);
|
||||
void GetIRData(u8* const data, bool use_accel);
|
||||
void GetExtData(u8* const data);
|
||||
|
||||
bool HaveExtension() const { return m_extension->active_extension > 0; }
|
||||
bool WantExtension() const { return m_extension->switch_extension != 0; }
|
||||
|
||||
private:
|
||||
struct ReadRequest
|
||||
{
|
||||
//u16 channel;
|
||||
unsigned int address, size, position;
|
||||
u8* data;
|
||||
};
|
||||
|
||||
void Reset();
|
||||
|
||||
void ReportMode(const wm_report_mode* const dr);
|
||||
void SendAck(const u8 _reportID);
|
||||
void RequestStatus(const wm_request_status* const rs = NULL);
|
||||
void ReadData(const wm_read_data* const rd);
|
||||
void WriteData(const wm_write_data* const wd);
|
||||
void SendReadDataReply(ReadRequest& _request);
|
||||
|
||||
#ifdef USE_WIIMOTE_EMU_SPEAKER
|
||||
void SpeakerData(wm_speaker_data* sd);
|
||||
#endif
|
||||
|
||||
// control groups
|
||||
Buttons* m_buttons;
|
||||
Buttons* m_dpad;
|
||||
Buttons* m_shake;
|
||||
Cursor* m_ir;
|
||||
Tilt* m_tilt;
|
||||
Force* m_swing;
|
||||
ControlGroup* m_rumble;
|
||||
Extension* m_extension;
|
||||
ControlGroup* m_options;
|
||||
// WiiMote accel data
|
||||
AccelData m_accel;
|
||||
|
||||
// wiimote index, 0-3
|
||||
const unsigned int m_index;
|
||||
|
||||
double ir_sin,ir_cos; //for the low pass filter
|
||||
|
||||
#ifdef USE_UDP_WIIMOTE
|
||||
UDPWrapper* m_udp;
|
||||
#endif
|
||||
|
||||
bool m_rumble_on;
|
||||
bool m_speaker_mute;
|
||||
|
||||
bool m_reporting_auto;
|
||||
u8 m_reporting_mode;
|
||||
u16 m_reporting_channel;
|
||||
|
||||
unsigned int m_shake_step[3];
|
||||
|
||||
wm_status_report m_status;
|
||||
|
||||
class Register : public std::map< size_t, std::vector<u8> >
|
||||
{
|
||||
public:
|
||||
void Write( size_t address, const void* src, size_t length );
|
||||
void Read( size_t address, void* dst, size_t length );
|
||||
|
||||
} m_register;
|
||||
|
||||
// read data request queue
|
||||
// maybe it isn't actualy a queue
|
||||
// maybe read requests cancel any current requests
|
||||
std::queue< ReadRequest > m_read_requests;
|
||||
|
||||
#ifdef USE_WIIMOTE_EMU_SPEAKER
|
||||
// speaker stuff
|
||||
struct SoundBuffer
|
||||
{
|
||||
s16* samples;
|
||||
ALuint buffer;
|
||||
};
|
||||
std::queue<SoundBuffer> m_audio_buffers;
|
||||
ALuint m_audio_source;
|
||||
struct
|
||||
{
|
||||
int hist1p, hist2p;
|
||||
} m_channel_status;
|
||||
#endif
|
||||
|
||||
u8 m_eeprom[WIIMOTE_EEPROM_SIZE];
|
||||
|
||||
u8* m_reg_motion_plus;
|
||||
|
||||
struct IrReg
|
||||
{
|
||||
u8 data[0x33];
|
||||
u8 mode;
|
||||
|
||||
} *m_reg_ir;
|
||||
|
||||
struct ExtensionReg
|
||||
{
|
||||
u8 unknown1[0x08];
|
||||
|
||||
// address 0x08
|
||||
u8 controller_data[0x06];
|
||||
u8 unknown2[0x12];
|
||||
|
||||
// address 0x20
|
||||
u8 calibration[0x10];
|
||||
u8 unknown3[0x10];
|
||||
|
||||
// address 0x40
|
||||
u8 encryption_key[0x10];
|
||||
u8 unknown4[0xA0];
|
||||
|
||||
// address 0xF0
|
||||
u8 encryption;
|
||||
u8 unknown5[0x9];
|
||||
|
||||
// address 0xFA
|
||||
u8 constant_id[6];
|
||||
|
||||
} *m_reg_ext;
|
||||
|
||||
struct SpeakerReg
|
||||
{
|
||||
u16 unknown;
|
||||
u8 format;
|
||||
u16 sample_rate;
|
||||
u8 volume;
|
||||
u8 unk[4];
|
||||
|
||||
} *m_reg_speaker;
|
||||
|
||||
wiimote_key m_ext_key;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
382
Source/Core/Core/Src/HW/WiimoteEmu/WiimoteHid.h
Normal file
382
Source/Core/Core/Src/HW/WiimoteEmu/WiimoteHid.h
Normal file
@ -0,0 +1,382 @@
|
||||
// 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_HID_H
|
||||
#define WIIMOTE_HID_H
|
||||
|
||||
#include "CommonTypes.h"
|
||||
|
||||
// what is this ?
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4200)
|
||||
#endif
|
||||
#pragma pack(push, 1)
|
||||
|
||||
// Source: HID_010_SPC_PFL/1.0 (official HID specification)
|
||||
|
||||
struct hid_packet {
|
||||
u8 param : 4;
|
||||
u8 type : 4;
|
||||
u8 data[0];
|
||||
};
|
||||
|
||||
#define HID_TYPE_HANDSHAKE 0
|
||||
#define HID_TYPE_SET_REPORT 5
|
||||
#define HID_TYPE_DATA 0xA
|
||||
|
||||
#define HID_HANDSHAKE_SUCCESS 0
|
||||
|
||||
#define HID_PARAM_INPUT 1
|
||||
#define HID_PARAM_OUTPUT 2
|
||||
|
||||
//source: http://wiibrew.org/wiki/Wiimote
|
||||
|
||||
typedef u16 wm_core;
|
||||
|
||||
struct wm_accel
|
||||
{
|
||||
u8 x, y, z;
|
||||
};
|
||||
|
||||
// Four bytes for two objects. Filled with 0xFF if empty
|
||||
struct wm_ir_basic
|
||||
{
|
||||
u8 x1;
|
||||
u8 y1;
|
||||
u8 x2hi : 2;
|
||||
u8 y2hi : 2;
|
||||
u8 x1hi : 2;
|
||||
u8 y1hi : 2;
|
||||
u8 x2;
|
||||
u8 y2;
|
||||
};
|
||||
|
||||
// Three bytes for one object
|
||||
struct wm_ir_extended
|
||||
{
|
||||
u8 x;
|
||||
u8 y;
|
||||
u8 size : 4;
|
||||
u8 xhi : 2;
|
||||
u8 yhi : 2;
|
||||
};
|
||||
|
||||
struct wm_extension
|
||||
{
|
||||
u8 jx; // joystick x, y
|
||||
u8 jy;
|
||||
u8 ax; // accelerometer
|
||||
u8 ay;
|
||||
u8 az;
|
||||
u8 bt; // buttons
|
||||
};
|
||||
|
||||
struct wm_classic_extension
|
||||
{
|
||||
u8 lx : 6; // byte 0
|
||||
u8 rx3 : 2;
|
||||
u8 ly : 6; // byte 1
|
||||
u8 rx2 : 2;
|
||||
u8 ry : 5; // byte 2
|
||||
u8 lt2 : 2;
|
||||
u8 rx1 : 1;
|
||||
u8 rt : 5; // byte 3
|
||||
u8 lt1 : 3;
|
||||
u16 bt; // byte 4, 5
|
||||
};
|
||||
|
||||
struct wm_guitar_extension
|
||||
{
|
||||
u8 sx : 6;
|
||||
u8 pad1 : 2; // 1 on gh3, 0 on ghwt
|
||||
|
||||
u8 sy : 6;
|
||||
u8 pad2 : 2; // 1 on gh3, 0 on ghwt
|
||||
|
||||
u8 tb : 5; // not used in gh3
|
||||
u8 pad3 : 3; // always 0
|
||||
|
||||
u8 whammy : 5;
|
||||
u8 pad4 : 3; // always 0
|
||||
|
||||
u16 bt; // buttons
|
||||
};
|
||||
|
||||
struct wm_drums_extension
|
||||
{
|
||||
u8 sx : 6;
|
||||
u8 pad1 : 2; // always 0
|
||||
|
||||
u8 sy : 6;
|
||||
u8 pad2 : 2; // always 0
|
||||
|
||||
u8 pad3 : 1; // unknown
|
||||
u8 which : 5;
|
||||
u8 none : 1;
|
||||
u8 hhp : 1;
|
||||
|
||||
u8 pad4 : 1; // unknown
|
||||
u8 velocity : 4; // unknown
|
||||
u8 softness : 3;
|
||||
|
||||
u16 bt; // buttons
|
||||
};
|
||||
|
||||
struct wm_turntable_extension
|
||||
{
|
||||
u8 sx : 6;
|
||||
u8 rtable3 : 2;
|
||||
|
||||
u8 sy : 6;
|
||||
u8 rtable2 : 2;
|
||||
|
||||
u8 rtable4 : 1;
|
||||
u8 slider : 4;
|
||||
u8 dial2 : 2;
|
||||
u8 rtable1 : 1;
|
||||
|
||||
u8 ltable1 : 5;
|
||||
u8 dial1 : 3;
|
||||
|
||||
union
|
||||
{
|
||||
u16 ltable2 : 1;
|
||||
u16 bt; // buttons
|
||||
};
|
||||
};
|
||||
|
||||
struct wm_report
|
||||
{
|
||||
u8 wm;
|
||||
union
|
||||
{
|
||||
u8 data[0];
|
||||
struct
|
||||
{
|
||||
u8 rumble : 1; // enable/disable rumble
|
||||
// only valid for certain reports
|
||||
u8 ack : 1; // respond with an ack
|
||||
u8 enable : 1; // enable/disable certain features
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#define WM_RUMBLE 0x10
|
||||
|
||||
#define WM_LEDS 0x11
|
||||
struct wm_leds {
|
||||
u8 rumble : 1;
|
||||
u8 : 3;
|
||||
u8 leds : 4;
|
||||
};
|
||||
|
||||
#define WM_REPORT_MODE 0x12
|
||||
struct wm_report_mode {
|
||||
u8 rumble : 1;
|
||||
u8 continuous : 1; // these 2 seem to be named wrong
|
||||
u8 all_the_time : 1;
|
||||
u8 : 5;
|
||||
u8 mode;
|
||||
};
|
||||
|
||||
#define WM_IR_PIXEL_CLOCK 0x13
|
||||
#define WM_IR_LOGIC 0x1A
|
||||
|
||||
#define WM_REQUEST_STATUS 0x15
|
||||
struct wm_request_status {
|
||||
u8 rumble : 1;
|
||||
u8 : 7;
|
||||
};
|
||||
|
||||
#define WM_STATUS_REPORT 0x20
|
||||
struct wm_status_report {
|
||||
wm_core buttons;
|
||||
u8 battery_low : 1;
|
||||
u8 extension : 1;
|
||||
u8 speaker : 1;
|
||||
u8 ir : 1;
|
||||
u8 leds : 4;
|
||||
u8 padding2[2]; // two 00, TODO: this needs more investigation
|
||||
u8 battery;
|
||||
};
|
||||
|
||||
#define WM_WRITE_DATA 0x16
|
||||
struct wm_write_data
|
||||
{
|
||||
u8 rumble : 1;
|
||||
u8 space : 2; //see WM_SPACE_*
|
||||
u8 : 5;
|
||||
u8 address[3];
|
||||
u8 size;
|
||||
u8 data[16];
|
||||
};
|
||||
|
||||
#define WM_ACK_DATA 0x22
|
||||
struct wm_acknowledge
|
||||
{
|
||||
wm_core buttons;
|
||||
u8 reportID;
|
||||
u8 errorID;
|
||||
};
|
||||
|
||||
#define WM_READ_DATA 0x17
|
||||
struct wm_read_data {
|
||||
u8 rumble : 1;
|
||||
u8 space : 2; //see WM_SPACE_*
|
||||
u8 : 5;
|
||||
u8 address[3];
|
||||
u16 size;
|
||||
};
|
||||
|
||||
#define WM_SPACE_EEPROM 0
|
||||
#define WM_SPACE_REGS1 1
|
||||
#define WM_SPACE_REGS2 2
|
||||
#define WM_SPACE_INVALID 3
|
||||
|
||||
#define WM_READ_DATA_REPLY 0x21
|
||||
struct wm_read_data_reply {
|
||||
wm_core buttons;
|
||||
u8 error : 4; //see WM_RDERR_*
|
||||
u8 size : 4;
|
||||
u16 address;
|
||||
u8 data[16];
|
||||
};
|
||||
|
||||
#define WM_RDERR_WOREG 7
|
||||
#define WM_RDERR_NOMEM 8
|
||||
|
||||
|
||||
// Data reports
|
||||
|
||||
#define WM_REPORT_CORE 0x30
|
||||
struct wm_report_core {
|
||||
wm_core c;
|
||||
};
|
||||
|
||||
#define WM_REPORT_CORE_ACCEL 0x31
|
||||
struct wm_report_core_accel {
|
||||
wm_core c;
|
||||
wm_accel a;
|
||||
};
|
||||
|
||||
#define WM_REPORT_CORE_EXT8 0x32
|
||||
|
||||
#define WM_REPORT_CORE_ACCEL_IR12 0x33
|
||||
struct wm_report_core_accel_ir12 {
|
||||
wm_core c;
|
||||
wm_accel a;
|
||||
wm_ir_extended ir[4];
|
||||
};
|
||||
|
||||
#define WM_REPORT_CORE_EXT19 0x34
|
||||
#define WM_REPORT_CORE_ACCEL_EXT16 0x35
|
||||
struct wm_report_core_accel_ext16
|
||||
{
|
||||
wm_core c;
|
||||
wm_accel a;
|
||||
wm_extension ext;
|
||||
//wm_ir_basic ir[2];
|
||||
u8 pad[10];
|
||||
|
||||
};
|
||||
|
||||
#define WM_REPORT_CORE_IR10_EXT9 0x36
|
||||
|
||||
#define WM_REPORT_CORE_ACCEL_IR10_EXT6 0x37
|
||||
struct wm_report_core_accel_ir10_ext6
|
||||
{
|
||||
wm_core c;
|
||||
wm_accel a;
|
||||
wm_ir_basic ir[2];
|
||||
//u8 ext[6];
|
||||
wm_extension ext;
|
||||
};
|
||||
|
||||
#define WM_REPORT_EXT21 0x3d // never used?
|
||||
struct wm_report_ext21
|
||||
{
|
||||
u8 ext[21];
|
||||
};
|
||||
|
||||
#define WM_REPORT_INTERLEAVE1 0x3e
|
||||
#define WM_REPORT_INTERLEAVE2 0x3f
|
||||
|
||||
#define WM_SPEAKER_ENABLE 0x14
|
||||
#define WM_SPEAKER_MUTE 0x19
|
||||
#define WM_WRITE_SPEAKER_DATA 0x18
|
||||
struct wm_speaker_data {
|
||||
u8 unknown : 3;
|
||||
u8 length : 5;
|
||||
u8 data[20];
|
||||
};
|
||||
|
||||
// Custom structs
|
||||
|
||||
/**
|
||||
* @struct accel_t
|
||||
* @brief Accelerometer struct. For any device with an accelerometer.
|
||||
*/
|
||||
struct accel_cal
|
||||
{
|
||||
struct
|
||||
{
|
||||
u8 x, y, z;
|
||||
u8 xlo : 2;
|
||||
u8 ylo : 2;
|
||||
u8 zlo : 2;
|
||||
} zero_g;
|
||||
|
||||
struct
|
||||
{
|
||||
u8 x, y, z;
|
||||
u8 xlo : 2;
|
||||
u8 ylo : 2;
|
||||
u8 zlo : 2;
|
||||
} one_g;
|
||||
};
|
||||
|
||||
struct nu_js {
|
||||
u8 max, min, center;
|
||||
};
|
||||
struct cc_trigger {
|
||||
u8 neutral;
|
||||
};
|
||||
struct nu_cal
|
||||
{
|
||||
wm_accel cal_zero; // zero calibratio
|
||||
wm_accel cal_g; // g size
|
||||
nu_js jx; //
|
||||
nu_js jy; //
|
||||
};
|
||||
struct cc_cal
|
||||
{
|
||||
nu_js Lx; //
|
||||
nu_js Ly; //
|
||||
nu_js Rx; //
|
||||
nu_js Ry; //
|
||||
cc_trigger Tl; //
|
||||
cc_trigger Tr; //
|
||||
};
|
||||
struct gh3_cal
|
||||
{
|
||||
nu_js Lx;
|
||||
nu_js Ly;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif //WIIMOTE_HID_H
|
604
Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
Normal file
604
Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
Normal file
@ -0,0 +1,604 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "Common.h"
|
||||
#include "IniFile.h"
|
||||
#include "StringUtil.h"
|
||||
#include "Timer.h"
|
||||
|
||||
#include "wiiuse.h"
|
||||
#include "WiimoteReal.h"
|
||||
|
||||
#include "../WiimoteEmu/WiimoteHid.h"
|
||||
|
||||
// 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")
|
||||
#endif
|
||||
|
||||
unsigned int g_wiimote_sources[MAX_WIIMOTES];
|
||||
|
||||
namespace WiimoteReal
|
||||
{
|
||||
|
||||
bool g_real_wiimotes_initialized = false;
|
||||
wiimote_t** g_wiimotes_from_wiiuse = NULL;
|
||||
unsigned int g_wiimotes_found = 0;
|
||||
// removed g_wiimotes_lastfound because Refresh() isn't taking advantage of it
|
||||
|
||||
volatile bool g_run_wiimote_thread = false;
|
||||
Common::Thread *g_wiimote_threads[MAX_WIIMOTES] = {};
|
||||
Common::CriticalSection g_refresh_critsec;
|
||||
|
||||
|
||||
THREAD_RETURN WiimoteThreadFunc(void* arg);
|
||||
void StartWiimoteThreads();
|
||||
void StopWiimoteThreads();
|
||||
|
||||
Wiimote *g_wiimotes[MAX_WIIMOTES];
|
||||
|
||||
Wiimote::Wiimote(wiimote_t* const _wiimote, const unsigned int _index)
|
||||
: index(_index)
|
||||
, wiimote(_wiimote)
|
||||
, m_last_data_report(NULL)
|
||||
, m_channel(0)
|
||||
{
|
||||
// disable reporting
|
||||
DisableDataReporting();
|
||||
|
||||
// set LEDs
|
||||
wiiuse_set_leds(wiimote, WIIMOTE_LED_1 << index);
|
||||
|
||||
// TODO: make Dolphin connect wiimote, maybe
|
||||
}
|
||||
|
||||
Wiimote::~Wiimote()
|
||||
{
|
||||
ClearReadQueue();
|
||||
|
||||
// clear write queue
|
||||
Report rpt;
|
||||
while (m_write_reports.Pop(rpt))
|
||||
delete[] rpt.first;
|
||||
|
||||
// disable reporting / wiiuse might do this on shutdown anyway, o well, don't know for sure
|
||||
DisableDataReporting();
|
||||
}
|
||||
|
||||
// silly, copying data n stuff, o well, don't use this too often
|
||||
void Wiimote::SendPacket(const u8 rpt_id, const void* const data, const unsigned int size)
|
||||
{
|
||||
Report rpt;
|
||||
rpt.second = size + 2;
|
||||
rpt.first = new u8[rpt.second];
|
||||
rpt.first[0] = 0xA1;
|
||||
rpt.first[1] = rpt_id;
|
||||
memcpy(rpt.first + 2, data, size);
|
||||
m_write_reports.Push(rpt);
|
||||
}
|
||||
|
||||
void Wiimote::DisableDataReporting()
|
||||
{
|
||||
wm_report_mode rpt;
|
||||
rpt.mode = WM_REPORT_CORE;
|
||||
rpt.all_the_time = 0;
|
||||
rpt.continuous = 0;
|
||||
rpt.rumble = 0;
|
||||
SendPacket(WM_REPORT_MODE, &rpt, sizeof(rpt));
|
||||
}
|
||||
|
||||
void Wiimote::ClearReadQueue()
|
||||
{
|
||||
if (m_last_data_report)
|
||||
{
|
||||
delete[] m_last_data_report;
|
||||
m_last_data_report = NULL;
|
||||
}
|
||||
|
||||
u8 *rpt;
|
||||
while (m_read_reports.Pop(rpt))
|
||||
delete[] rpt;
|
||||
}
|
||||
|
||||
void Wiimote::ControlChannel(const u16 channel, const void* const data, const u32 size)
|
||||
{
|
||||
// Check for custom communication
|
||||
if (99 == channel)
|
||||
Disconnect();
|
||||
else
|
||||
{
|
||||
InterruptChannel(channel, data, size);
|
||||
const hid_packet* const hidp = (hid_packet*)data;
|
||||
if (hidp->type == HID_TYPE_SET_REPORT)
|
||||
{
|
||||
u8 handshake_ok = HID_HANDSHAKE_SUCCESS;
|
||||
Core::Callback_WiimoteInterruptChannel(index, channel, &handshake_ok, sizeof(handshake_ok));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Wiimote::InterruptChannel(const u16 channel, const void* const data, const u32 size)
|
||||
{
|
||||
if (0 == m_channel) // first interrupt/control channel sent
|
||||
{
|
||||
ClearReadQueue();
|
||||
|
||||
// request status
|
||||
wm_request_status rpt;
|
||||
rpt.rumble = 0;
|
||||
SendPacket(WM_REQUEST_STATUS, &rpt, sizeof(rpt));
|
||||
}
|
||||
|
||||
m_channel = channel; // this right?
|
||||
|
||||
Wiimote::Report rpt;
|
||||
rpt.first = new u8[size];
|
||||
rpt.second = (u8)size;
|
||||
memcpy(rpt.first, (u8*)data, size);
|
||||
|
||||
// some hax, since we just send the last data report to Dolphin on each Update() call
|
||||
// , make the wiimote only send updated data reports when data changes
|
||||
// == less bt traffic, eliminates some unneeded packets
|
||||
if (WM_REPORT_MODE == ((u8*)data)[1])
|
||||
{
|
||||
// also delete the last data report
|
||||
if (m_last_data_report)
|
||||
{
|
||||
delete[] m_last_data_report;
|
||||
m_last_data_report = NULL;
|
||||
}
|
||||
|
||||
// nice var names :p, this seems to be this one
|
||||
((wm_report_mode*)(rpt.first + 2))->all_the_time = false;
|
||||
//((wm_report_mode*)(data + 2))->continuous = false;
|
||||
}
|
||||
|
||||
m_write_reports.Push(rpt);
|
||||
}
|
||||
|
||||
bool Wiimote::Read()
|
||||
{
|
||||
if (wiiuse_io_read(wiimote))
|
||||
{
|
||||
if (m_channel)
|
||||
{
|
||||
// add it to queue
|
||||
u8* const rpt = new u8[MAX_PAYLOAD];
|
||||
memcpy(rpt, wiimote->event_buf, MAX_PAYLOAD);
|
||||
m_read_reports.Push(rpt);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Wiimote::Write()
|
||||
{
|
||||
Report rpt;
|
||||
if (m_write_reports.Pop(rpt))
|
||||
{
|
||||
wiiuse_io_write(wiimote, rpt.first, rpt.second);
|
||||
delete[] rpt.first;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns the next report that should be sent
|
||||
u8* Wiimote::ProcessReadQueue()
|
||||
{
|
||||
// pop through the queued reports
|
||||
u8* rpt = m_last_data_report;
|
||||
while (m_read_reports.Pop(rpt))
|
||||
{
|
||||
// a data report
|
||||
if (rpt[1] >= WM_REPORT_CORE)
|
||||
m_last_data_report = rpt;
|
||||
// some other kind of report
|
||||
else
|
||||
return rpt;
|
||||
}
|
||||
|
||||
// the queue was empty, or there were only data reports
|
||||
return rpt;
|
||||
}
|
||||
|
||||
void Wiimote::Update()
|
||||
{
|
||||
// pop through the queued reports
|
||||
u8* const rpt = ProcessReadQueue();
|
||||
|
||||
// send the report
|
||||
if (rpt && m_channel)
|
||||
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)
|
||||
delete[] rpt;
|
||||
}
|
||||
|
||||
void Wiimote::Disconnect()
|
||||
{
|
||||
m_channel = 0;
|
||||
|
||||
// disable reporting
|
||||
DisableDataReporting();
|
||||
}
|
||||
|
||||
void LoadSettings()
|
||||
{
|
||||
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + WIIMOTE_INI_NAME ".ini" );
|
||||
|
||||
IniFile inifile;
|
||||
inifile.Load(ini_filename);
|
||||
|
||||
for (unsigned int i=0; i<MAX_WIIMOTES; ++i)
|
||||
{
|
||||
std::string secname("Wiimote");
|
||||
secname += (char)('1' + i);
|
||||
IniFile::Section& sec = *inifile.GetOrCreateSection(secname.c_str());
|
||||
|
||||
sec.Get("Source", &g_wiimote_sources[i], WIIMOTE_SRC_EMU);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Initialize()
|
||||
{
|
||||
// return if already initialized
|
||||
if (g_real_wiimotes_initialized)
|
||||
return g_wiimotes_found;
|
||||
|
||||
memset(g_wiimotes, 0, sizeof(g_wiimotes));
|
||||
|
||||
// only call wiiuse_find with the number of slots configured for real wiimotes
|
||||
unsigned int wanted_wiimotes = 0;
|
||||
for (unsigned int i = 0; i < MAX_WIIMOTES; ++i)
|
||||
if (WIIMOTE_SRC_REAL & g_wiimote_sources[i])
|
||||
++wanted_wiimotes;
|
||||
|
||||
// don't bother initializing wiiuse if we don't want any real wiimotes
|
||||
if (0 == wanted_wiimotes)
|
||||
{
|
||||
g_wiimotes_found = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// initialized
|
||||
g_real_wiimotes_initialized = true;
|
||||
|
||||
#ifdef _WIN32
|
||||
// Alloc memory for wiimote structure only if we're starting fresh
|
||||
if(!g_wiimotes_from_wiiuse)
|
||||
g_wiimotes_from_wiiuse = wiiuse_init(MAX_WIIMOTES);
|
||||
// on windows wiiuse_find() expects as a 3rd parameter the amount of last connected wiimotes instead of the timeout,
|
||||
// a timeout parameter is useless on win32 here, since at this points we already have the wiimotes discovered and paired up, just not connected.
|
||||
g_wiimotes_found = wiiuse_find(g_wiimotes_from_wiiuse, wanted_wiimotes, 0);
|
||||
#else
|
||||
g_wiimotes_from_wiiuse = wiiuse_init(MAX_WIIMOTES);
|
||||
g_wiimotes_found = wiiuse_find(g_wiimotes_from_wiiuse, wanted_wiimotes, 5);
|
||||
#endif
|
||||
DEBUG_LOG(WIIMOTE, "Found %i Real Wiimotes, %i wanted",
|
||||
g_wiimotes_found, wanted_wiimotes);
|
||||
|
||||
g_wiimotes_found =
|
||||
wiiuse_connect(g_wiimotes_from_wiiuse, g_wiimotes_found);
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "Connected to %i Real Wiimotes", g_wiimotes_found);
|
||||
|
||||
// create real wiimote class instances, assign wiimotes
|
||||
for (unsigned int i = 0, w = 0; i<MAX_WIIMOTES && w<g_wiimotes_found; ++i)
|
||||
{
|
||||
// create/assign wiimote
|
||||
if (WIIMOTE_SRC_REAL & g_wiimote_sources[i])
|
||||
g_wiimotes[i] = new Wiimote(g_wiimotes_from_wiiuse[w++], i);
|
||||
}
|
||||
|
||||
StartWiimoteThreads();
|
||||
|
||||
return g_wiimotes_found;
|
||||
}
|
||||
|
||||
void Shutdown(void)
|
||||
{
|
||||
if (false == g_real_wiimotes_initialized)
|
||||
return;
|
||||
|
||||
// Uninitialized
|
||||
g_real_wiimotes_initialized = false;
|
||||
|
||||
StopWiimoteThreads();
|
||||
|
||||
// delete wiimotes
|
||||
for (unsigned int i=0; i<MAX_WIIMOTES; ++i)
|
||||
if (g_wiimotes[i])
|
||||
{
|
||||
delete g_wiimotes[i];
|
||||
g_wiimotes[i] = NULL;
|
||||
}
|
||||
|
||||
// Clean up wiiuse, win32: we cant just delete the struct on win32, since wiiuse_find() maintains it and
|
||||
// adds/removes wimotes directly to/from it to prevent problems, which would occur when using more than 1 wiimote if we create it from scratch everytime
|
||||
#ifndef _WIN32
|
||||
wiiuse_cleanup(g_wiimotes_from_wiiuse, MAX_WIIMOTES);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Refresh() // this gets called from the GUI thread
|
||||
{
|
||||
#ifdef __linux__
|
||||
// make sure real wiimotes have been initialized
|
||||
if (!g_real_wiimotes_initialized)
|
||||
{
|
||||
Initialize();
|
||||
return;
|
||||
}
|
||||
|
||||
// find the number of slots configured for real wiimotes
|
||||
unsigned int wanted_wiimotes = 0;
|
||||
for (unsigned int i = 0; i < MAX_WIIMOTES; ++i)
|
||||
if (WIIMOTE_SRC_REAL & g_wiimote_sources[i])
|
||||
++wanted_wiimotes;
|
||||
|
||||
// don't scan for wiimotes if we don't want any more
|
||||
if (wanted_wiimotes <= g_wiimotes_found)
|
||||
return;
|
||||
|
||||
// scan for wiimotes
|
||||
unsigned int num_wiimotes = wiiuse_find(g_wiimotes_from_wiiuse, wanted_wiimotes, 5);
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "Found %i Real Wiimotes, %i wanted", num_wiimotes, wanted_wiimotes);
|
||||
|
||||
int num_new_wiimotes = wiiuse_connect(g_wiimotes_from_wiiuse, num_wiimotes);
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "Connected to %i additional Real Wiimotes", num_new_wiimotes);
|
||||
|
||||
StopWiimoteThreads();
|
||||
|
||||
g_refresh_critsec.Enter();
|
||||
|
||||
// create real wiimote class instances, and assign wiimotes for the new wiimotes
|
||||
for (unsigned int i = g_wiimotes_found, w = g_wiimotes_found;
|
||||
i < MAX_WIIMOTES && w < num_wiimotes; ++i)
|
||||
{
|
||||
// create/assign wiimote
|
||||
if (WIIMOTE_SRC_REAL & g_wiimote_sources[i] && NULL == g_wiimotes[i])
|
||||
g_wiimotes[i] = new Wiimote(g_wiimotes_from_wiiuse[w++], i);
|
||||
}
|
||||
g_wiimotes_found = num_wiimotes;
|
||||
|
||||
g_refresh_critsec.Leave();
|
||||
|
||||
StartWiimoteThreads();
|
||||
|
||||
#else // windows/ OSX
|
||||
g_refresh_critsec.Enter();
|
||||
|
||||
// should be fine i think
|
||||
Shutdown();
|
||||
Initialize();
|
||||
|
||||
g_refresh_critsec.Leave();
|
||||
#endif
|
||||
}
|
||||
|
||||
void InterruptChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
g_refresh_critsec.Enter();
|
||||
|
||||
if (g_wiimotes[_WiimoteNumber])
|
||||
g_wiimotes[_WiimoteNumber]->InterruptChannel(_channelID, _pData, _Size);
|
||||
|
||||
g_refresh_critsec.Leave();
|
||||
}
|
||||
|
||||
void ControlChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
g_refresh_critsec.Enter();
|
||||
|
||||
if (g_wiimotes[_WiimoteNumber])
|
||||
g_wiimotes[_WiimoteNumber]->ControlChannel(_channelID, _pData, _Size);
|
||||
|
||||
g_refresh_critsec.Leave();
|
||||
}
|
||||
|
||||
|
||||
// Read the Wiimote once
|
||||
void Update(int _WiimoteNumber)
|
||||
{
|
||||
g_refresh_critsec.Enter();
|
||||
|
||||
if (g_wiimotes[_WiimoteNumber])
|
||||
g_wiimotes[_WiimoteNumber]->Update();
|
||||
|
||||
g_refresh_critsec.Leave();
|
||||
}
|
||||
|
||||
void StateChange(PLUGIN_EMUSTATE newState)
|
||||
{
|
||||
//g_refresh_critsec.Enter(); // enter
|
||||
|
||||
// TODO: disable/enable auto reporting, maybe
|
||||
|
||||
//g_refresh_critsec.Leave(); // leave
|
||||
}
|
||||
|
||||
void StartWiimoteThreads()
|
||||
{
|
||||
g_run_wiimote_thread = true;
|
||||
for (unsigned int i=0; i<MAX_WIIMOTES; ++i)
|
||||
if (g_wiimotes[i])
|
||||
g_wiimote_threads[i] = new Common::Thread(WiimoteThreadFunc, g_wiimotes[i]);
|
||||
}
|
||||
|
||||
void StopWiimoteThreads()
|
||||
{
|
||||
g_run_wiimote_thread = false;
|
||||
for (unsigned int i=0; i<MAX_WIIMOTES; ++i)
|
||||
if (g_wiimote_threads[i])
|
||||
{
|
||||
g_wiimote_threads[i]->WaitForDeath();
|
||||
delete g_wiimote_threads[i];
|
||||
g_wiimote_threads[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
THREAD_RETURN WiimoteThreadFunc(void* arg)
|
||||
{
|
||||
Wiimote* const wiimote = (Wiimote*)arg;
|
||||
|
||||
{
|
||||
char thname[] = "Wiimote # Thread";
|
||||
thname[8] = (char)('1' + wiimote->index);
|
||||
Common::SetCurrentThreadName(thname);
|
||||
}
|
||||
|
||||
// rumble briefly
|
||||
wiiuse_rumble(wiimote->wiimote, 1);
|
||||
SLEEP(200);
|
||||
wiiuse_rumble(wiimote->wiimote, 0);
|
||||
|
||||
// main loop
|
||||
while (g_run_wiimote_thread)
|
||||
{
|
||||
// hopefully this is alright
|
||||
while (wiimote->Write()) {}
|
||||
|
||||
// sleep if there was nothing to read
|
||||
if (false == wiimote->Read())
|
||||
Common::SleepCurrentThread(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
int nPaired = 0;
|
||||
|
||||
BLUETOOTH_DEVICE_SEARCH_PARAMS srch;
|
||||
srch.dwSize = sizeof(srch);
|
||||
srch.fReturnAuthenticated = true;
|
||||
srch.fReturnRemembered = true;
|
||||
srch.fReturnConnected = true; // does not filter properly somehow, so we've to do an additional check on fConnected BT Devices
|
||||
srch.fReturnUnknown = true;
|
||||
srch.fIssueInquiry = true;
|
||||
srch.cTimeoutMultiplier = 2; // == (2 * 1.28) seconds
|
||||
|
||||
BLUETOOTH_FIND_RADIO_PARAMS radioParam;
|
||||
radioParam.dwSize = sizeof(radioParam);
|
||||
|
||||
HANDLE hRadio;
|
||||
|
||||
// Enumerate BT radios
|
||||
HBLUETOOTH_RADIO_FIND hFindRadio = BluetoothFindFirstRadio(&radioParam, &hRadio);
|
||||
|
||||
if (NULL == hFindRadio)
|
||||
return -1;
|
||||
|
||||
while (hFindRadio)
|
||||
{
|
||||
BLUETOOTH_RADIO_INFO radioInfo;
|
||||
radioInfo.dwSize = sizeof(radioInfo);
|
||||
|
||||
// TODO: check for SUCCEEDED()
|
||||
BluetoothGetRadioInfo(hRadio, &radioInfo);
|
||||
|
||||
srch.hRadio = hRadio;
|
||||
|
||||
BLUETOOTH_DEVICE_INFO btdi;
|
||||
btdi.dwSize = sizeof(btdi);
|
||||
|
||||
// Enumerate BT devices
|
||||
HBLUETOOTH_DEVICE_FIND hFindDevice = BluetoothFindFirstDevice(&srch, &btdi);
|
||||
while (hFindDevice)
|
||||
{
|
||||
//btdi.szName is sometimes missings it's content - it's a bt feature..
|
||||
DEBUG_LOG(WIIMOTE, "authed %i connected %i remembered %i ", btdi.fAuthenticated, btdi.fConnected, btdi.fRemembered);
|
||||
|
||||
// TODO: Probably could just check for "Nintendo RVL"
|
||||
if (0 == wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || 0 == wcscmp(btdi.szName, L"Nintendo RVL-CNT-01"))
|
||||
{
|
||||
if (unpair)
|
||||
{
|
||||
if (SUCCEEDED(BluetoothRemoveDevice(&btdi.Address)))
|
||||
{
|
||||
NOTICE_LOG(WIIMOTE, "Pair-Up: Automatically removed BT Device on shutdown: %08x", GetLastError());
|
||||
++nPaired;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (false == btdi.fConnected)
|
||||
{
|
||||
//TODO: improve the read of the BT driver, esp. when batteries of the wiimote are removed while being fConnected
|
||||
if (btdi.fRemembered)
|
||||
{
|
||||
// Make Windows forget old expired pairing
|
||||
// we can pretty much ignore the return value here.
|
||||
// it either worked (ERROR_SUCCESS), or the device did not exist (ERROR_NOT_FOUND)
|
||||
// in both cases, there is nothing left.
|
||||
BluetoothRemoveDevice(&btdi.Address);
|
||||
}
|
||||
|
||||
// Activate service
|
||||
const DWORD hr = BluetoothSetServiceState(hRadio, &btdi, &HumanInterfaceDeviceServiceClass_UUID, BLUETOOTH_SERVICE_ENABLE);
|
||||
if (SUCCEEDED(hr))
|
||||
++nPaired;
|
||||
else
|
||||
ERROR_LOG(WIIMOTE, "Pair-Up: BluetoothSetServiceState() returned %08x", hr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (false == BluetoothFindNextDevice(hFindDevice, &btdi))
|
||||
{
|
||||
BluetoothFindDeviceClose(hFindDevice);
|
||||
hFindDevice = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (false == BluetoothFindNextRadio(hFindRadio, &hRadio))
|
||||
{
|
||||
BluetoothFindRadioClose(hFindRadio);
|
||||
hFindRadio = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return nPaired;
|
||||
}
|
||||
#endif
|
||||
|
||||
}; // end of namespace
|
92
Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
Normal file
92
Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
Normal file
@ -0,0 +1,92 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
#ifndef WIIMOTE_REAL_H
|
||||
#define WIIMOTE_REAL_H
|
||||
|
||||
#include "wiiuse.h"
|
||||
#include "ChunkFile.h"
|
||||
#include "Thread.h"
|
||||
#include "FifoQueue.h"
|
||||
|
||||
#include "../Wiimote.h"
|
||||
#include "../WiimoteEmu/WiimoteEmu.h"
|
||||
|
||||
#include "../../InputCommon/Src/InputConfig.h"
|
||||
|
||||
enum
|
||||
{
|
||||
WIIMOTE_SRC_NONE = 0,
|
||||
WIIMOTE_SRC_EMU = 1,
|
||||
WIIMOTE_SRC_REAL = 2,
|
||||
WIIMOTE_SRC_HYBRID = 3, // emu + real
|
||||
};
|
||||
|
||||
namespace WiimoteReal
|
||||
{
|
||||
|
||||
class Wiimote
|
||||
{
|
||||
friend class WiimoteEmu::Wiimote;
|
||||
public:
|
||||
Wiimote(wiimote_t* const wm, const unsigned int index);
|
||||
~Wiimote();
|
||||
|
||||
void ControlChannel(const u16 channel, const void* const data, const u32 size);
|
||||
void InterruptChannel(const u16 channel, const void* const data, const u32 size);
|
||||
void Update();
|
||||
|
||||
u8* ProcessReadQueue();
|
||||
|
||||
bool Read();
|
||||
bool Write();
|
||||
void Disconnect();
|
||||
void DisableDataReporting();
|
||||
|
||||
void SendPacket(const u8 rpt_id, const void* const data, const unsigned int size);
|
||||
|
||||
// pointer to data, and size of data
|
||||
typedef std::pair<u8*,u8> Report;
|
||||
|
||||
const unsigned int index;
|
||||
wiimote_t* const wiimote;
|
||||
|
||||
protected:
|
||||
u8 *m_last_data_report;
|
||||
u16 m_channel;
|
||||
|
||||
private:
|
||||
void ClearReadQueue();
|
||||
|
||||
Common::FifoQueue<u8*> m_read_reports;
|
||||
Common::FifoQueue<Report> m_write_reports;
|
||||
};
|
||||
|
||||
extern Common::CriticalSection g_refresh_critsec;
|
||||
extern Wiimote *g_wiimotes[4];
|
||||
|
||||
void InterruptChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size);
|
||||
void ControlChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size);
|
||||
void Update(int _WiimoteNumber);
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
void StateChange(PLUGIN_EMUSTATE newState);
|
||||
|
||||
}; // WiiMoteReal
|
||||
|
||||
#endif
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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',
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user