2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
// 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/
|
|
|
|
|
|
|
|
|
2009-01-17 14:28:09 +00:00
|
|
|
#include "Common.h" // Common
|
2009-07-12 21:58:32 +00:00
|
|
|
#include "LogManager.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "StringUtil.h"
|
2009-01-28 16:09:08 +00:00
|
|
|
#include "Timer.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-01-28 16:09:08 +00:00
|
|
|
#define EXCLUDEMAIN_H // Avoid certain declarations in main.h
|
2009-02-01 13:01:50 +00:00
|
|
|
#include "EmuDefinitions.h" // Local
|
|
|
|
#include "wiimote_hid.h"
|
|
|
|
#include "main.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-07-05 04:29:00 +00:00
|
|
|
#include "ConfigPadDlg.h"
|
|
|
|
#include "ConfigRecordingDlg.h"
|
|
|
|
#include "ConfigBasicDlg.h"
|
|
|
|
|
|
|
|
WiimotePadConfigDialog *m_PadConfigFrame = NULL;
|
|
|
|
WiimoteRecordingConfigDialog *m_RecordingConfigFrame = NULL;
|
|
|
|
WiimoteBasicConfigDialog *m_BasicConfigFrame = NULL;
|
2008-12-08 05:25:12 +00:00
|
|
|
#endif
|
2009-01-28 16:09:08 +00:00
|
|
|
#include "Config.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "pluginspecs_wiimote.h"
|
|
|
|
#include "EmuMain.h"
|
|
|
|
#if HAVE_WIIUSE
|
2009-01-25 23:07:15 +00:00
|
|
|
#include "wiimote_real.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#endif
|
2009-01-07 02:59:19 +00:00
|
|
|
|
2009-08-02 08:53:54 +00:00
|
|
|
#if defined(HAVE_X11) && HAVE_X11
|
|
|
|
Display* WMdisplay;
|
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
SWiimoteInitialize g_WiimoteInitialize;
|
2009-03-18 17:17:58 +00:00
|
|
|
PLUGIN_GLOBALS* globals = NULL;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-02-01 13:01:50 +00:00
|
|
|
// General
|
2009-01-25 23:07:15 +00:00
|
|
|
bool g_EmulatorRunning = false;
|
2009-02-20 03:13:22 +00:00
|
|
|
u32 g_ISOId = 0;
|
2010-01-01 03:19:46 +00:00
|
|
|
bool g_SearchDeviceDone = false;
|
2009-01-25 23:07:15 +00:00
|
|
|
bool g_RealWiiMotePresent = false;
|
|
|
|
bool g_RealWiiMoteInitialized = false;
|
2010-01-01 16:50:11 +00:00
|
|
|
bool g_RealWiiMoteAllocated = false;
|
2009-01-26 07:01:43 +00:00
|
|
|
bool g_EmulatedWiiMoteInitialized = false;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-02-01 13:01:50 +00:00
|
|
|
// Settings
|
2009-02-20 13:14:23 +00:00
|
|
|
accel_cal g_wm;
|
2009-02-07 03:16:41 +00:00
|
|
|
nu_cal g_nu;
|
2009-07-04 07:28:48 +00:00
|
|
|
cc_cal g_ClassicContCalibration;
|
|
|
|
gh3_cal g_GH3Calibration;
|
2009-02-01 13:01:50 +00:00
|
|
|
|
|
|
|
// Debugging
|
|
|
|
bool g_DebugAccelerometer = false;
|
|
|
|
bool g_DebugData = false;
|
2009-12-27 19:31:02 +00:00
|
|
|
bool g_DebugComm = false;
|
|
|
|
bool g_DebugSoundData = false;
|
2009-02-07 03:16:41 +00:00
|
|
|
bool g_DebugCustom = false;
|
2009-02-01 13:01:50 +00:00
|
|
|
|
2009-01-28 16:09:08 +00:00
|
|
|
// Update speed
|
|
|
|
int g_UpdateCounter = 0;
|
|
|
|
double g_UpdateTime = 0;
|
|
|
|
int g_UpdateRate = 0;
|
|
|
|
int g_UpdateWriteScreen = 0;
|
|
|
|
std::vector<int> g_UpdateTimeList (5, 0);
|
|
|
|
|
|
|
|
// Movement recording
|
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
|
|
|
std::vector<SRecordingAll> VRecording(RECORDING_ROWS);
|
|
|
|
|
|
|
|
PLUGIN_EMUSTATE g_EmulatorState = PLUGIN_EMUSTATE_STOP;
|
2009-01-28 16:09:08 +00:00
|
|
|
|
2009-07-02 19:00:27 +00:00
|
|
|
// Standard crap to make wxWidgets happy
|
2009-02-07 03:16:41 +00:00
|
|
|
#ifdef _WIN32
|
2009-07-02 19:00:27 +00:00
|
|
|
HINSTANCE g_hInstance;
|
2009-02-07 03:16:41 +00:00
|
|
|
|
2008-12-14 23:52:01 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-07-02 19:00:27 +00:00
|
|
|
class wxDLLApp : public wxApp
|
|
|
|
{
|
|
|
|
bool OnInit()
|
2009-01-26 07:01:43 +00:00
|
|
|
{
|
2009-07-02 19:00:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
|
|
|
|
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
2008-12-14 23:52:01 +00:00
|
|
|
#endif
|
2009-01-07 02:59:19 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
|
|
|
|
DWORD dwReason, // reason called
|
|
|
|
LPVOID lpvReserved) // reserved
|
|
|
|
{
|
|
|
|
switch (dwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2009-07-02 19:00:27 +00:00
|
|
|
{
|
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2008-12-08 05:25:12 +00:00
|
|
|
wxSetInstance((HINSTANCE)hinstDLL);
|
|
|
|
int argc = 0;
|
|
|
|
char **argv = NULL;
|
|
|
|
wxEntryStart(argc, argv);
|
2009-02-21 12:53:10 +00:00
|
|
|
if (!wxTheApp || !wxTheApp->CallOnInit())
|
2008-12-08 05:25:12 +00:00
|
|
|
return FALSE;
|
2009-07-02 19:00:27 +00:00
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-07-05 05:59:03 +00:00
|
|
|
break;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
2009-07-02 19:00:27 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
|
|
|
wxEntryCleanup();
|
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_hInstance = hinstDLL;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
2009-01-07 02:59:19 +00:00
|
|
|
|
2009-07-02 19:00:27 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
|
|
|
wxWindow* GetParentedWxWindow(HWND Parent)
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
wxSetInstance((HINSTANCE)g_hInstance);
|
|
|
|
#endif
|
|
|
|
wxWindow *win = new wxWindow();
|
|
|
|
#ifdef _WIN32
|
|
|
|
win->SetHWND((WXHWND)Parent);
|
|
|
|
win->AdoptAttributesFromHWND();
|
|
|
|
#endif
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
#endif
|
2009-01-07 02:59:19 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
// Exports
|
2009-07-02 19:00:27 +00:00
|
|
|
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
|
|
|
_PluginInfo->Version = 0x0100;
|
|
|
|
_PluginInfo->Type = PLUGIN_TYPE_WIIMOTE;
|
2009-07-02 19:00:27 +00:00
|
|
|
#ifdef DEBUGFAST
|
|
|
|
sprintf(_PluginInfo->Name, "Dolphin Wiimote Plugin (DebugFast)");
|
|
|
|
#else
|
|
|
|
#ifndef _DEBUG
|
|
|
|
sprintf(_PluginInfo->Name, "Dolphin Wiimote Plugin");
|
|
|
|
#else
|
|
|
|
sprintf(_PluginInfo->Name, "Dolphin Wiimote Plugin (Debug)");
|
|
|
|
#endif
|
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-03-18 17:17:58 +00:00
|
|
|
void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals)
|
|
|
|
{
|
|
|
|
globals = _pPluginGlobals;
|
|
|
|
LogManager::SetInstance((LogManager *)globals->logManager);
|
|
|
|
}
|
2009-01-08 12:12:15 +00:00
|
|
|
|
2009-01-25 23:07:15 +00:00
|
|
|
void DllDebugger(HWND _hParent, bool Show) {}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-01-07 20:45:43 +00:00
|
|
|
void DllConfig(HWND _hParent)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2010-01-01 03:19:46 +00:00
|
|
|
if (!g_SearchDeviceDone)
|
2009-12-29 13:38:34 +00:00
|
|
|
{
|
|
|
|
// Load settings
|
|
|
|
g_Config.Load();
|
|
|
|
// We do a pad search before creating the dialog
|
|
|
|
WiiMoteEmu::Search_Devices(WiiMoteEmu::joyinfo, WiiMoteEmu::NumPads, WiiMoteEmu::NumGoodPads);
|
2010-01-01 03:19:46 +00:00
|
|
|
g_SearchDeviceDone = true;
|
2009-12-29 13:38:34 +00:00
|
|
|
}
|
2009-12-27 19:31:02 +00:00
|
|
|
|
2009-12-14 02:23:14 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-01-28 16:09:08 +00:00
|
|
|
|
2010-01-24 03:50:40 +00:00
|
|
|
m_BasicConfigFrame = new WiimoteBasicConfigDialog(GetParentedWxWindow(_hParent));
|
|
|
|
m_BasicConfigFrame->ShowModal();
|
|
|
|
m_BasicConfigFrame->Destroy();
|
2010-01-24 14:41:53 +00:00
|
|
|
delete m_BasicConfigFrame;
|
|
|
|
m_BasicConfigFrame = NULL;
|
2009-11-29 17:58:52 +00:00
|
|
|
|
2008-12-14 23:52:01 +00:00
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-12-14 02:23:14 +00:00
|
|
|
// Start emulation
|
2009-07-02 19:00:27 +00:00
|
|
|
void Initialize(void *init)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-25 23:07:15 +00:00
|
|
|
g_EmulatorRunning = true;
|
2009-12-27 19:31:02 +00:00
|
|
|
g_WiimoteInitialize = *(SWiimoteInitialize *)init;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-02-20 03:13:22 +00:00
|
|
|
// Update the GUI if the configuration window is already open
|
2009-01-26 07:01:43 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2010-01-24 14:41:53 +00:00
|
|
|
if (m_BasicConfigFrame)
|
2009-02-20 03:13:22 +00:00
|
|
|
{
|
|
|
|
// Save the settings
|
|
|
|
g_Config.Save();
|
2009-12-27 19:31:02 +00:00
|
|
|
// Load the ISO Id
|
2009-02-20 03:13:22 +00:00
|
|
|
g_ISOId = g_WiimoteInitialize.ISOId;
|
|
|
|
// Load the settings
|
|
|
|
g_Config.Load();
|
2009-07-05 04:29:00 +00:00
|
|
|
if(m_BasicConfigFrame) m_BasicConfigFrame->UpdateGUI();
|
2009-02-20 03:13:22 +00:00
|
|
|
}
|
2009-01-26 07:01:43 +00:00
|
|
|
#endif
|
2009-08-02 08:53:54 +00:00
|
|
|
#if defined(HAVE_X11) && HAVE_X11
|
2009-12-27 19:31:02 +00:00
|
|
|
WMdisplay = (Display*)g_WiimoteInitialize.hWnd;
|
2009-08-02 08:53:54 +00:00
|
|
|
#endif
|
2009-01-26 07:01:43 +00:00
|
|
|
|
2009-02-20 03:13:22 +00:00
|
|
|
g_ISOId = g_WiimoteInitialize.ISOId;
|
2009-12-27 19:31:02 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "ISOId: %08x %s", g_WiimoteInitialize.ISOId, Hex2Ascii(g_WiimoteInitialize.ISOId).c_str());
|
2009-02-20 03:13:22 +00:00
|
|
|
|
2010-01-16 22:37:38 +00:00
|
|
|
// Load IR settings, as this is a per-game setting and the user might have loaded a different game
|
|
|
|
g_Config.LoadIR();
|
|
|
|
|
2009-12-27 19:31:02 +00:00
|
|
|
// Run this first so that WiiMoteReal::Initialize() overwrites g_Eeprom
|
|
|
|
WiiMoteEmu::Initialize();
|
2009-02-20 03:13:22 +00:00
|
|
|
|
2009-12-27 19:31:02 +00:00
|
|
|
/* We will run WiiMoteReal::Initialize() even if we are not using a real
|
|
|
|
wiimote, to check if there is a real wiimote connected. We will initiate
|
|
|
|
wiiuse.dll, but we will return before creating a new thread for it if we
|
|
|
|
find no real Wiimotes. Then g_RealWiiMotePresent will also be
|
|
|
|
false. This function call will be done instantly whether there is a real
|
|
|
|
Wiimote connected or not. It takes no time for Wiiuse to check for
|
|
|
|
connected Wiimotes. */
|
|
|
|
#if HAVE_WIIUSE
|
2010-01-01 16:50:11 +00:00
|
|
|
//if (g_Config.bConnectRealWiimote) WiiMoteReal::Initialize();
|
|
|
|
if(!g_RealWiiMoteInitialized)
|
|
|
|
WiiMoteReal::Initialize();
|
|
|
|
if(!g_RealWiiMoteAllocated)
|
|
|
|
WiiMoteReal::Allocate();
|
2009-12-27 19:31:02 +00:00
|
|
|
#endif
|
2009-01-25 23:07:15 +00:00
|
|
|
}
|
|
|
|
|
2009-01-26 07:29:04 +00:00
|
|
|
// If a game is not running this is called by the Configuration window when it's closed
|
2009-07-02 19:00:27 +00:00
|
|
|
void Shutdown(void)
|
2009-01-25 23:07:15 +00:00
|
|
|
{
|
2009-01-26 07:29:04 +00:00
|
|
|
// Not running
|
|
|
|
g_EmulatorRunning = false;
|
|
|
|
|
2009-02-20 03:13:22 +00:00
|
|
|
// Reset the game ID in all cases
|
|
|
|
g_ISOId = 0;
|
|
|
|
|
2009-01-25 23:07:15 +00:00
|
|
|
#if HAVE_WIIUSE
|
2009-02-21 12:53:10 +00:00
|
|
|
if (g_RealWiiMoteInitialized) WiiMoteReal::Shutdown();
|
2009-01-25 23:07:15 +00:00
|
|
|
#endif
|
|
|
|
WiiMoteEmu::Shutdown();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-02 19:00:27 +00:00
|
|
|
void DoState(unsigned char **ptr, int mode)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-07-03 12:22:32 +00:00
|
|
|
PointerWrap p(ptr, mode);
|
|
|
|
|
|
|
|
// TODO: Shorten the list
|
2009-11-24 05:03:47 +00:00
|
|
|
|
2009-07-03 12:22:32 +00:00
|
|
|
//p.Do(g_EmulatorRunning);
|
|
|
|
//p.Do(g_ISOId);
|
2009-12-27 19:31:02 +00:00
|
|
|
//p.Do(g_RealWiiMotePresent);
|
|
|
|
//p.Do(g_RealWiiMoteInitialized);
|
|
|
|
//p.Do(g_EmulatedWiiMoteInitialized);
|
2009-11-24 05:03:47 +00:00
|
|
|
//p.Do(g_UpdateCounter);
|
|
|
|
//p.Do(g_UpdateTime);
|
|
|
|
//p.Do(g_UpdateRate);
|
|
|
|
//p.Do(g_UpdateWriteScreen);
|
|
|
|
//p.Do(g_UpdateTimeList);
|
2009-07-03 12:22:32 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
#if HAVE_WIIUSE
|
2009-07-03 12:22:32 +00:00
|
|
|
WiiMoteReal::DoState(p);
|
2008-12-08 05:25:12 +00:00
|
|
|
#endif
|
2009-07-03 12:22:32 +00:00
|
|
|
WiiMoteEmu::DoState(p);
|
2009-11-24 05:03:47 +00:00
|
|
|
|
|
|
|
return;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
|
|
|
void EmuStateChange(PLUGIN_EMUSTATE newState)
|
|
|
|
{
|
|
|
|
g_EmulatorState = newState;
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
/* This function produce Wiimote Input (reports from the Wiimote) in response
|
2009-01-26 07:01:43 +00:00
|
|
|
to Output from the Wii. It's called from WII_IPC_HLE_WiiMote.cpp.
|
|
|
|
|
|
|
|
Switch between real and emulated wiimote: We send all this Input to WiiMoteEmu::InterruptChannel()
|
|
|
|
so that it knows the channel ID and the data reporting mode at all times.
|
|
|
|
*/
|
2009-12-25 22:10:56 +00:00
|
|
|
void Wiimote_InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
2009-01-15 06:48:15 +00:00
|
|
|
{
|
2008-12-08 05:25:12 +00:00
|
|
|
// Debugging
|
2009-12-27 19:31:02 +00:00
|
|
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
|
|
DEBUG_LOG(WIIMOTE, "Wiimote_InterruptChannel");
|
|
|
|
DEBUG_LOG(WIIMOTE, " Channel ID: %04x", _channelID);
|
|
|
|
std::string Temp = ArrayToString((const u8*)_pData, _Size);
|
|
|
|
DEBUG_LOG(WIIMOTE, " Data: %s", Temp.c_str());
|
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-01-07 02:59:19 +00:00
|
|
|
// Decice where to send the message
|
2010-01-01 03:19:46 +00:00
|
|
|
if (WiiMoteEmu::WiiMapping[_number].Source <= 1)
|
2009-12-25 22:10:56 +00:00
|
|
|
WiiMoteEmu::InterruptChannel(_number, _channelID, _pData, _Size);
|
2008-12-08 05:25:12 +00:00
|
|
|
#if HAVE_WIIUSE
|
2009-12-07 12:48:39 +00:00
|
|
|
else if (g_RealWiiMotePresent)
|
2010-01-01 00:38:24 +00:00
|
|
|
WiiMoteReal::InterruptChannel(_number, _channelID, _pData, _Size);
|
2008-12-08 05:25:12 +00:00
|
|
|
#endif
|
|
|
|
}
|
2009-01-25 23:07:15 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-07-05 05:59:03 +00:00
|
|
|
// Function: Used for the initial Bluetooth HID handshake.
|
2009-12-25 22:10:56 +00:00
|
|
|
void Wiimote_ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
|
|
|
// Debugging
|
2009-12-26 14:16:21 +00:00
|
|
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
|
|
DEBUG_LOG(WIIMOTE, "Wiimote_ControlChannel");
|
2009-12-27 19:31:02 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, " Channel ID: %04x", _channelID);
|
2009-12-26 14:16:21 +00:00
|
|
|
std::string Temp = ArrayToString((const u8*)_pData, _Size);
|
|
|
|
DEBUG_LOG(WIIMOTE, " Data: %s", Temp.c_str());
|
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-01-03 23:05:52 +00:00
|
|
|
// Check for custom communication
|
|
|
|
if(_channelID == 99 && *(const u8*)_pData == WIIMOTE_DISCONNECT)
|
|
|
|
{
|
|
|
|
WiiMoteEmu::g_ReportingAuto[_number] = false;
|
|
|
|
WARN_LOG(WIIMOTE, "Wiimote: #%i Disconnected", _number);
|
|
|
|
#ifdef _WIN32
|
|
|
|
PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, _number);
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-01 03:19:46 +00:00
|
|
|
if (WiiMoteEmu::WiiMapping[_number].Source <= 1)
|
2009-12-25 22:10:56 +00:00
|
|
|
WiiMoteEmu::ControlChannel(_number, _channelID, _pData, _Size);
|
2008-12-08 05:25:12 +00:00
|
|
|
#if HAVE_WIIUSE
|
2009-12-07 12:48:39 +00:00
|
|
|
else if (g_RealWiiMotePresent)
|
2010-01-01 00:38:24 +00:00
|
|
|
WiiMoteReal::ControlChannel(_number, _channelID, _pData, _Size);
|
2008-12-08 05:25:12 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-01-07 02:59:19 +00:00
|
|
|
|
2009-12-27 19:31:02 +00:00
|
|
|
// This sends a Data Report from the Wiimote. See SystemTimers.cpp for the documentation of this update.
|
2009-12-25 22:10:56 +00:00
|
|
|
void Wiimote_Update(int _number)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-28 16:09:08 +00:00
|
|
|
// Tell us about the update rate, but only about once every second to avoid a major slowdown
|
2009-02-17 22:06:40 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-07-05 04:29:00 +00:00
|
|
|
if (m_RecordingConfigFrame)
|
2009-01-28 16:09:08 +00:00
|
|
|
{
|
|
|
|
GetUpdateRate();
|
|
|
|
if (g_UpdateWriteScreen > g_UpdateRate)
|
|
|
|
{
|
2009-07-05 04:29:00 +00:00
|
|
|
m_RecordingConfigFrame->m_TextUpdateRate->SetLabel(wxString::Format(wxT("Update rate: %03i times/s"), g_UpdateRate));
|
2009-01-28 16:09:08 +00:00
|
|
|
g_UpdateWriteScreen = 0;
|
|
|
|
}
|
|
|
|
g_UpdateWriteScreen++;
|
|
|
|
}
|
2009-02-17 22:06:40 +00:00
|
|
|
#endif
|
2009-11-24 05:03:47 +00:00
|
|
|
|
2009-02-01 13:01:50 +00:00
|
|
|
// This functions will send:
|
|
|
|
// Emulated Wiimote: Only data reports 0x30-0x37
|
|
|
|
// Real Wiimote: Both data reports 0x30-0x37 and all other read reports
|
2010-01-01 03:19:46 +00:00
|
|
|
if (WiiMoteEmu::WiiMapping[_number].Source <= 1)
|
2009-12-25 22:10:56 +00:00
|
|
|
WiiMoteEmu::Update(_number);
|
2008-12-08 05:25:12 +00:00
|
|
|
#if HAVE_WIIUSE
|
2009-01-25 23:07:15 +00:00
|
|
|
else if (g_RealWiiMotePresent)
|
2010-01-01 00:38:24 +00:00
|
|
|
WiiMoteReal::Update(_number);
|
2008-12-08 05:25:12 +00:00
|
|
|
#endif
|
2009-02-01 13:01:50 +00:00
|
|
|
|
2009-12-27 19:31:02 +00:00
|
|
|
/*
|
2009-02-01 13:01:50 +00:00
|
|
|
// Debugging
|
|
|
|
#ifdef _WIN32
|
2009-02-07 03:16:41 +00:00
|
|
|
if( GetAsyncKeyState(VK_HOME) && g_DebugComm ) g_DebugComm = false; // Page Down
|
2009-02-01 13:01:50 +00:00
|
|
|
else if (GetAsyncKeyState(VK_HOME) && !g_DebugComm ) g_DebugComm = true;
|
|
|
|
|
2009-02-07 03:16:41 +00:00
|
|
|
if( GetAsyncKeyState(VK_PRIOR) && g_DebugData ) g_DebugData = false; // Page Up
|
2009-02-01 13:01:50 +00:00
|
|
|
else if (GetAsyncKeyState(VK_PRIOR) && !g_DebugData ) g_DebugData = true;
|
|
|
|
|
2009-02-07 03:16:41 +00:00
|
|
|
if( GetAsyncKeyState(VK_NEXT) && g_DebugAccelerometer ) g_DebugAccelerometer = false; // Home
|
2009-02-01 13:01:50 +00:00
|
|
|
else if (GetAsyncKeyState(VK_NEXT) && !g_DebugAccelerometer ) g_DebugAccelerometer = true;
|
2009-02-07 03:16:41 +00:00
|
|
|
|
2009-09-15 02:12:55 +00:00
|
|
|
if( GetAsyncKeyState(VK_END) && g_DebugCustom ) { g_DebugCustom = false; DEBUG_LOG(WIIMOTE, "Custom Debug: Off");} // End
|
|
|
|
else if (GetAsyncKeyState(VK_END) && !g_DebugCustom ) {g_DebugCustom = true; DEBUG_LOG(WIIMOTE, "Custom Debug: Off");}
|
2009-02-01 13:01:50 +00:00
|
|
|
#endif
|
2009-12-27 19:31:02 +00:00
|
|
|
*/
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-07-02 19:00:27 +00:00
|
|
|
unsigned int Wiimote_GetAttachedControllers()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-15 18:23:42 +00:00
|
|
|
|
2009-01-25 23:07:15 +00:00
|
|
|
// Supporting functions
|
2009-02-15 02:01:43 +00:00
|
|
|
|
2009-02-01 15:40:13 +00:00
|
|
|
// Check if Dolphin is in focus
|
2009-07-05 05:59:03 +00:00
|
|
|
|
2009-02-01 15:40:13 +00:00
|
|
|
bool IsFocus()
|
|
|
|
{
|
2009-02-01 15:58:33 +00:00
|
|
|
#ifdef _WIN32
|
2009-02-09 13:10:29 +00:00
|
|
|
HWND RenderingWindow = g_WiimoteInitialize.hWnd;
|
|
|
|
HWND Parent = GetParent(RenderingWindow);
|
2009-02-01 15:40:13 +00:00
|
|
|
HWND TopLevel = GetParent(Parent);
|
|
|
|
// Support both rendering to main window and not
|
2010-01-19 09:54:21 +00:00
|
|
|
if (GetForegroundWindow() == TopLevel || GetForegroundWindow() == RenderingWindow)
|
2009-02-01 15:40:13 +00:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
2009-02-01 15:58:33 +00:00
|
|
|
#else
|
2009-02-01 16:32:31 +00:00
|
|
|
return true;
|
2009-02-01 15:58:33 +00:00
|
|
|
#endif
|
2009-02-01 15:40:13 +00:00
|
|
|
}
|
|
|
|
|
2009-12-27 19:31:02 +00:00
|
|
|
/* Returns a timestamp with three decimals for precise time comparisons. The return format is
|
|
|
|
of the form seconds.milleseconds for example 1234.123. The leding seconds have no particular meaning
|
|
|
|
but are just there to enable use to tell if we have entered a new second or now. */
|
|
|
|
// -----------------
|
|
|
|
|
|
|
|
/* Calculate the current update frequency. Calculate the time between ten updates, and average
|
|
|
|
five such rates. If we assume there are 60 updates per second if the game is running at full
|
|
|
|
speed then we get this measure on average once every second. The reason to have a few updates
|
|
|
|
between each measurement is becase the milliseconds may not be perfectly accurate and may return
|
|
|
|
the same time even when a milliseconds has actually passed, for example.*/
|
|
|
|
int GetUpdateRate()
|
|
|
|
{
|
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
|
|
|
if(g_UpdateCounter == 10)
|
|
|
|
{
|
|
|
|
// Erase the old ones
|
|
|
|
if(g_UpdateTimeList.size() == 5) g_UpdateTimeList.erase(g_UpdateTimeList.begin() + 0);
|
|
|
|
|
|
|
|
// Calculate the time and save it
|
|
|
|
int Time = (int)(10 / (Common::Timer::GetDoubleTime() - g_UpdateTime));
|
|
|
|
g_UpdateTimeList.push_back(Time);
|
|
|
|
//DEBUG_LOG(WIIMOTE, "Time: %i %f", Time, Common::Timer::GetDoubleTime());
|
|
|
|
|
|
|
|
int TotalTime = 0;
|
|
|
|
for (int i = 0; i < (int)g_UpdateTimeList.size(); i++)
|
|
|
|
TotalTime += g_UpdateTimeList.at(i);
|
|
|
|
g_UpdateRate = TotalTime / 5;
|
|
|
|
|
|
|
|
// Write the new update time
|
|
|
|
g_UpdateTime = Common::Timer::GetDoubleTime();
|
|
|
|
|
|
|
|
g_UpdateCounter = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_UpdateCounter++;
|
|
|
|
|
|
|
|
return g_UpdateRate;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-02-07 03:16:41 +00:00
|
|
|
// Turn off all extensions
|
|
|
|
void DisableExtensions()
|
|
|
|
{
|
2009-07-05 04:29:00 +00:00
|
|
|
g_Config.iExtensionConnected = EXT_NONE;
|
2009-02-07 03:16:41 +00:00
|
|
|
}
|
|
|
|
|
2009-02-04 06:40:05 +00:00
|
|
|
void ReadDebugging(bool Emu, const void* _pData, int Size)
|
2009-02-01 13:01:50 +00:00
|
|
|
{
|
|
|
|
//
|
2009-02-04 06:40:05 +00:00
|
|
|
//const u8* data = (const u8*)_pData;
|
2009-02-15 02:01:43 +00:00
|
|
|
//u8* data = (u8*)_pData;
|
|
|
|
// Copy the data to a new location that we know are the right size
|
|
|
|
u8 data[32];
|
|
|
|
memset(data, 0, sizeof(data));
|
|
|
|
memcpy(data, _pData, Size);
|
2009-02-01 13:01:50 +00:00
|
|
|
|
|
|
|
int size;
|
|
|
|
bool DataReport = false;
|
2009-02-07 03:16:41 +00:00
|
|
|
std::string Name, TmpData;
|
2009-02-01 13:01:50 +00:00
|
|
|
switch(data[1])
|
|
|
|
{
|
|
|
|
case WM_STATUS_REPORT: // 0x20
|
|
|
|
size = sizeof(wm_status_report);
|
|
|
|
Name = "WM_STATUS_REPORT";
|
|
|
|
{
|
2009-02-07 03:16:41 +00:00
|
|
|
wm_status_report* pStatus = (wm_status_report*)(data + 2);
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, ""
|
|
|
|
"Extension Controller: %i "
|
|
|
|
//"Speaker enabled: %i "
|
|
|
|
//"IR camera enabled: %i "
|
|
|
|
//"LED 1: %i "
|
|
|
|
//"LED 2: %i "
|
|
|
|
//"LED 3: %i "
|
|
|
|
//"LED 4: %i "
|
|
|
|
"Battery low: %i",
|
2009-02-01 13:01:50 +00:00
|
|
|
pStatus->extension,
|
2009-02-07 03:16:41 +00:00
|
|
|
//pStatus->speaker,
|
|
|
|
//pStatus->ir,
|
|
|
|
//(pStatus->leds >> 0),
|
|
|
|
//(pStatus->leds >> 1),
|
|
|
|
//(pStatus->leds >> 2),
|
|
|
|
//(pStatus->leds >> 3),
|
2009-02-01 13:01:50 +00:00
|
|
|
pStatus->battery_low
|
2009-02-07 03:16:41 +00:00
|
|
|
);
|
2009-12-25 22:10:56 +00:00
|
|
|
// Update the global (for both the real and emulated) extension settings from whatever
|
|
|
|
// the real Wiimote use. We will enable the extension from the 0x21 report.
|
2009-02-07 03:16:41 +00:00
|
|
|
if(!Emu && !pStatus->extension)
|
|
|
|
{
|
|
|
|
DisableExtensions();
|
2009-02-17 22:06:40 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-07-05 04:29:00 +00:00
|
|
|
if (m_BasicConfigFrame) m_BasicConfigFrame->UpdateGUI();
|
2009-02-17 22:06:40 +00:00
|
|
|
#endif
|
2009-02-07 03:16:41 +00:00
|
|
|
}
|
2009-02-01 13:01:50 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_READ_DATA_REPLY: // 0x21
|
|
|
|
size = sizeof(wm_read_data_reply);
|
|
|
|
Name = "REPLY";
|
2009-02-04 06:40:05 +00:00
|
|
|
// data[4]: Size and error
|
|
|
|
// data[5, 6]: The registry offset
|
|
|
|
|
2009-02-07 03:16:41 +00:00
|
|
|
// Show the extension ID
|
|
|
|
if ((data[4] == 0x10 || data[4] == 0x20 || data[4] == 0x50) && data[5] == 0x00 && (data[6] == 0xfa || data[6] == 0xfe))
|
2009-02-04 06:40:05 +00:00
|
|
|
{
|
2009-02-07 03:16:41 +00:00
|
|
|
if(data[4] == 0x10)
|
2009-09-15 02:12:55 +00:00
|
|
|
TmpData.append(StringFromFormat("Game got the encrypted extension ID: %02x%02x", data[7], data[8]));
|
2009-02-07 03:16:41 +00:00
|
|
|
else if(data[4] == 0x50)
|
2009-09-15 02:12:55 +00:00
|
|
|
TmpData.append(StringFromFormat("Game got the encrypted extension ID: %02x%02x%02x%02x%02x%02x", data[7], data[8], data[9], data[10], data[11], data[12]));
|
2009-02-07 03:16:41 +00:00
|
|
|
|
|
|
|
// We have already sent the data report so we can safely decrypt it now
|
|
|
|
if(WiiMoteEmu::g_Encryption)
|
|
|
|
{
|
|
|
|
if(data[4] == 0x10)
|
|
|
|
wiimote_decrypt(&WiiMoteEmu::g_ExtKey, &data[0x07], 0x06, (data[4] >> 0x04) + 1);
|
|
|
|
if(data[4] == 0x50)
|
|
|
|
wiimote_decrypt(&WiiMoteEmu::g_ExtKey, &data[0x07], 0x02, (data[4] >> 0x04) + 1);
|
|
|
|
}
|
|
|
|
|
2009-12-25 22:10:56 +00:00
|
|
|
// Update the global extension settings. Enable the emulated extension from reading
|
|
|
|
// what the real Wiimote has connected. To keep the emulated and real Wiimote in sync.
|
2009-02-07 03:16:41 +00:00
|
|
|
if(data[4] == 0x10)
|
|
|
|
{
|
|
|
|
if (!Emu) DisableExtensions();
|
2009-07-05 04:29:00 +00:00
|
|
|
if (!Emu && data[7] == 0x00 && data[8] == 0x00)
|
|
|
|
g_Config.iExtensionConnected = EXT_NUNCHUCK;
|
|
|
|
if (!Emu && data[7] == 0x01 && data[8] == 0x01)
|
|
|
|
g_Config.iExtensionConnected = EXT_CLASSIC_CONTROLLER;
|
2009-02-07 03:16:41 +00:00
|
|
|
g_Config.Save();
|
|
|
|
WiiMoteEmu::UpdateEeprom();
|
2009-02-17 22:06:40 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-07-05 04:29:00 +00:00
|
|
|
if (m_BasicConfigFrame) m_BasicConfigFrame->UpdateGUI();
|
2009-02-17 22:06:40 +00:00
|
|
|
#endif
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "%s", TmpData.c_str());
|
|
|
|
DEBUG_LOG(WIIMOTE, "Game got the decrypted extension ID: %02x%02x", data[7], data[8]);
|
2009-02-07 03:16:41 +00:00
|
|
|
}
|
|
|
|
else if(data[4] == 0x50)
|
|
|
|
{
|
|
|
|
if (!Emu) DisableExtensions();
|
2009-07-05 04:29:00 +00:00
|
|
|
if (!Emu && data[11] == 0x00 && data[12] == 0x00)
|
|
|
|
g_Config.iExtensionConnected = EXT_NUNCHUCK;
|
|
|
|
if (!Emu && data[11] == 0x01 && data[12] == 0x01)
|
|
|
|
g_Config.iExtensionConnected = EXT_CLASSIC_CONTROLLER;
|
2009-02-07 03:16:41 +00:00
|
|
|
g_Config.Save();
|
|
|
|
WiiMoteEmu::UpdateEeprom();
|
2009-02-17 22:06:40 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-07-05 04:29:00 +00:00
|
|
|
if (m_BasicConfigFrame) m_BasicConfigFrame->UpdateGUI();
|
2009-02-17 22:06:40 +00:00
|
|
|
#endif
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "%s", TmpData.c_str());
|
|
|
|
DEBUG_LOG(WIIMOTE, "Game got the decrypted extension ID: %02x%02x%02x%02x%02x%02x", data[7], data[8], data[9], data[10], data[11], data[12]);
|
2009-02-07 03:16:41 +00:00
|
|
|
}
|
2009-02-04 06:40:05 +00:00
|
|
|
}
|
2009-02-20 09:57:17 +00:00
|
|
|
|
|
|
|
// Show the Wiimote neutral values
|
2009-12-25 22:10:56 +00:00
|
|
|
// The only difference between the Nunchuck and Wiimote that we go
|
|
|
|
// after is calibration here is the offset in memory. If needed we can
|
|
|
|
// check the preceding 0x17 request to.
|
2009-02-20 09:57:17 +00:00
|
|
|
if(data[4] == 0xf0 && data[5] == 0x00 && data[6] == 0x10)
|
|
|
|
{
|
|
|
|
if(data[6] == 0x10)
|
|
|
|
{
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Game got the Wiimote calibration:");
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_zero.x: %i", data[7 + 6]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_zero.y: %i", data[7 + 7]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_zero.z: %i", data[7 + 8]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_g.x: %i", data[7 + 10]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_g.y: %i", data[7 + 11]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_g.z: %i", data[7 +12]);
|
2009-02-20 09:57:17 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-07 03:16:41 +00:00
|
|
|
|
2009-02-20 09:57:17 +00:00
|
|
|
// Show the Nunchuck neutral values
|
2009-02-07 03:16:41 +00:00
|
|
|
if(data[4] == 0xf0 && data[5] == 0x00 && (data[6] == 0x20 || data[6] == 0x30))
|
2009-02-04 06:40:05 +00:00
|
|
|
{
|
2009-02-07 03:16:41 +00:00
|
|
|
// Save the encrypted data
|
2009-09-15 02:12:55 +00:00
|
|
|
TmpData = StringFromFormat("Read[%s] (enc): %s", (Emu ? "Emu" : "Real"), ArrayToString(data, size + 2, 0, 30).c_str());
|
2009-02-07 03:16:41 +00:00
|
|
|
|
|
|
|
// We have already sent the data report so we can safely decrypt it now
|
|
|
|
if(WiiMoteEmu::g_Encryption)
|
|
|
|
wiimote_decrypt(&WiiMoteEmu::g_ExtKey, &data[0x07], 0x00, (data[4] >> 0x04) + 1);
|
|
|
|
|
2009-07-05 04:29:00 +00:00
|
|
|
if (g_Config.iExtensionConnected == EXT_NUNCHUCK)
|
2009-02-24 18:37:53 +00:00
|
|
|
{
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Game got the Nunchuck calibration:");
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_zero.x: %i", data[7 + 0]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_zero.y: %i", data[7 + 1]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_zero.z: %i", data[7 + 2]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_g.x: %i", data[7 + 4]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_g.y: %i", data[7 + 5]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Cal_g.z: %i", data[7 + 6]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Js.Max.x: %i", data[7 + 8]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Js.Min.x: %i", data[7 + 9]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Js.Center.x: %i", data[7 + 10]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Js.Max.y: %i", data[7 + 11]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Js.Min.y: %i", data[7 + 12]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "JS.Center.y: %i", data[7 + 13]);
|
2009-02-24 18:37:53 +00:00
|
|
|
}
|
|
|
|
else // g_Config.bClassicControllerConnected
|
|
|
|
{
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Game got the Classic Controller calibration:");
|
|
|
|
DEBUG_LOG(WIIMOTE, "Lx.Max: %i", data[7 + 0]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Lx.Min: %i", data[7 + 1]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Lx.Center: %i", data[7 + 2]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Ly.Max: %i", data[7 + 3]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Ly.Min: %i", data[7 + 4]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Ly.Center: %i", data[7 + 5]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Rx.Max.x: %i", data[7 + 6]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Rx.Min.x: %i", data[7 + 7]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Rx.Center.x: %i", data[7 + 8]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Ry.Max.y: %i", data[7 + 9]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Ry.Min: %i", data[7 + 10]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Ry.Center: %i", data[7 + 11]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Lt.Neutral: %i", data[7 + 12]);
|
|
|
|
DEBUG_LOG(WIIMOTE, "Rt.Neutral %i", data[7 + 13]);
|
2009-02-24 18:37:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Save the values if they come from the real Wiimote
|
2009-02-07 04:19:52 +00:00
|
|
|
if (!Emu)
|
2009-02-07 03:16:41 +00:00
|
|
|
{
|
2009-02-07 04:19:52 +00:00
|
|
|
// Save the values from the Nunchuck
|
|
|
|
if(data[7 + 0] != 0xff)
|
|
|
|
{
|
|
|
|
memcpy(WiiMoteEmu::g_RegExt + 0x20, &data[7], 0x10);
|
|
|
|
memcpy(WiiMoteEmu::g_RegExt + 0x30, &data[7], 0x10);
|
|
|
|
|
|
|
|
}
|
|
|
|
// Save the default values that should work with Wireless Nunchucks
|
|
|
|
else
|
|
|
|
{
|
2009-09-15 02:12:55 +00:00
|
|
|
WiiMoteEmu::UpdateExtRegisterBlocks();
|
2009-02-07 04:19:52 +00:00
|
|
|
}
|
|
|
|
WiiMoteEmu::UpdateEeprom();
|
2009-02-07 03:16:41 +00:00
|
|
|
}
|
|
|
|
// We got a third party nunchuck
|
|
|
|
else if(data[7 + 0] == 0xff)
|
|
|
|
{
|
|
|
|
memcpy(WiiMoteEmu::g_RegExt + 0x20, WiiMoteEmu::wireless_nunchuck_calibration, sizeof(WiiMoteEmu::wireless_nunchuck_calibration));
|
|
|
|
memcpy(WiiMoteEmu::g_RegExt + 0x30, WiiMoteEmu::wireless_nunchuck_calibration, sizeof(WiiMoteEmu::wireless_nunchuck_calibration));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show the encrypted data
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "%s", TmpData.c_str());
|
2009-02-04 06:40:05 +00:00
|
|
|
}
|
2009-02-04 13:35:28 +00:00
|
|
|
|
2009-02-01 13:01:50 +00:00
|
|
|
break;
|
2009-11-24 05:03:47 +00:00
|
|
|
case WM_ACK_DATA: // 0x22
|
2009-02-01 13:01:50 +00:00
|
|
|
size = sizeof(wm_acknowledge) - 1;
|
|
|
|
Name = "REPLY";
|
|
|
|
break;
|
|
|
|
case WM_REPORT_CORE: // 0x30-0x37
|
|
|
|
size = sizeof(wm_report_core);
|
|
|
|
DataReport = true;
|
|
|
|
break;
|
|
|
|
case WM_REPORT_CORE_ACCEL:
|
|
|
|
size = sizeof(wm_report_core_accel);
|
|
|
|
DataReport = true;
|
|
|
|
break;
|
|
|
|
case WM_REPORT_CORE_EXT8:
|
|
|
|
size = sizeof(wm_report_core_accel_ir12);
|
|
|
|
DataReport = true;
|
|
|
|
break;
|
|
|
|
case WM_REPORT_CORE_ACCEL_IR12:
|
|
|
|
size = sizeof(wm_report_core_accel_ir12);
|
|
|
|
DataReport = true;
|
|
|
|
break;
|
|
|
|
case WM_REPORT_CORE_EXT19:
|
|
|
|
size = sizeof(wm_report_core_accel_ext16);
|
|
|
|
DataReport = true;
|
|
|
|
break;
|
|
|
|
case WM_REPORT_CORE_ACCEL_EXT16:
|
|
|
|
size = sizeof(wm_report_core_accel_ext16);
|
|
|
|
DataReport = true;
|
|
|
|
break;
|
|
|
|
case WM_REPORT_CORE_IR10_EXT9:
|
|
|
|
size = sizeof(wm_report_core_accel_ir10_ext6);
|
|
|
|
DataReport = true;
|
|
|
|
break;
|
|
|
|
case WM_REPORT_CORE_ACCEL_IR10_EXT6:
|
|
|
|
size = sizeof(wm_report_core_accel_ir10_ext6);
|
|
|
|
DataReport = true;
|
|
|
|
break;
|
|
|
|
default:
|
2009-02-07 03:16:41 +00:00
|
|
|
//PanicAlert("%s ReadDebugging: Unknown channel 0x%02x", (Emu ? "Emu" : "Real"), data[1]);
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "%s ReadDebugging: Unknown channel 0x%02x", (Emu ? "Emu" : "Real"), data[1]);
|
2009-02-01 13:01:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!DataReport && g_DebugComm)
|
|
|
|
{
|
2009-07-05 05:59:03 +00:00
|
|
|
std::string tmpData = ArrayToString(data, size + 2, 0, 30);
|
2009-09-15 02:12:55 +00:00
|
|
|
//LOGV(WIIMOTE, 3, " Data: %s", Temp.c_str());
|
|
|
|
DEBUG_LOG(WIIMOTE, "Read[%s] %s: %s", (Emu ? "Emu" : "Real"), Name.c_str(), tmpData.c_str()); // No timestamp
|
|
|
|
//DEBUG_LOG(WIIMOTE, " (%s): %s", Tm(true).c_str(), Temp.c_str()); // Timestamp
|
2009-02-01 13:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (DataReport && g_DebugData)
|
|
|
|
{
|
2009-02-04 06:40:05 +00:00
|
|
|
// Decrypt extension data
|
|
|
|
if(WiiMoteEmu::g_ReportingMode == 0x37)
|
|
|
|
wiimote_decrypt(&WiiMoteEmu::g_ExtKey, &data[17], 0x00, 0x06);
|
2009-02-24 18:37:53 +00:00
|
|
|
if(WiiMoteEmu::g_ReportingMode == 0x35)
|
|
|
|
wiimote_decrypt(&WiiMoteEmu::g_ExtKey, &data[7], 0x00, 0x06);
|
2009-02-04 06:40:05 +00:00
|
|
|
|
|
|
|
// Produce string
|
2009-02-15 02:01:43 +00:00
|
|
|
//std::string TmpData = ArrayToString(data, size + 2, 0, 30);
|
2009-09-15 02:12:55 +00:00
|
|
|
//LOGV(WIIMOTE, 3, " Data: %s", Temp.c_str());
|
2009-02-24 18:37:53 +00:00
|
|
|
std::string TmpCore = "", TmpAccel = "", TmpIR = "", TmpExt = "", CCData = "";
|
2009-02-24 02:40:17 +00:00
|
|
|
TmpCore = StringFromFormat(
|
|
|
|
"%02x %02x %02x %02x",
|
|
|
|
data[0], data[1], data[2], data[3]); // Header and core buttons
|
2009-02-01 13:01:50 +00:00
|
|
|
|
2009-02-24 02:40:17 +00:00
|
|
|
TmpAccel = StringFromFormat(
|
|
|
|
"%03i %03i %03i",
|
|
|
|
data[4], data[5], data[6]); // Wiimote accelerometer
|
|
|
|
|
|
|
|
if (data[1] == 0x33) // WM_REPORT_CORE_ACCEL_IR12
|
|
|
|
{
|
|
|
|
TmpIR = StringFromFormat(
|
|
|
|
"%02x %02x %02x %02x %02x %02x"
|
|
|
|
" %02x %02x %02x %02x %02x %02x",
|
|
|
|
data[7], data[8], data[9], data[10], data[11], data[12],
|
|
|
|
data[13], data[14], data[15], data[16], data[17], data[18]);
|
|
|
|
}
|
|
|
|
if (data[1] == 0x35) // WM_REPORT_CORE_ACCEL_EXT16
|
|
|
|
{
|
|
|
|
TmpExt = StringFromFormat(
|
|
|
|
"%02x %02x %02x %02x %02x %02x",
|
|
|
|
data[7], data[8], // Nunchuck stick
|
|
|
|
data[9], data[10], data[11], // Nunchuck Accelerometer
|
|
|
|
data[12]); // Nunchuck buttons
|
2009-02-24 18:37:53 +00:00
|
|
|
|
|
|
|
CCData = WiiMoteEmu::CCData2Values(&data[7]);
|
2009-02-24 02:40:17 +00:00
|
|
|
}
|
|
|
|
if (data[1] == 0x37) // WM_REPORT_CORE_ACCEL_IR10_EXT6
|
|
|
|
{
|
|
|
|
TmpIR = StringFromFormat(
|
|
|
|
"%02x %02x %02x %02x %02x"
|
|
|
|
" %02x %02x %02x %02x %02x",
|
|
|
|
data[7], data[8], data[9], data[10], data[11],
|
|
|
|
data[12], data[13], data[14], data[15], data[16]);
|
|
|
|
TmpExt = StringFromFormat(
|
|
|
|
"%02x %02x %02x %02x %02x %02x",
|
|
|
|
data[17], data[18], // Nunchuck stick
|
|
|
|
data[19], data[20], data[21], // Nunchuck Accelerometer
|
|
|
|
data[22]); // Nunchuck buttons
|
2009-02-24 18:37:53 +00:00
|
|
|
CCData = WiiMoteEmu::CCData2Values(&data[17]);
|
2009-02-24 02:40:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
2009-02-11 10:30:02 +00:00
|
|
|
// Calculate the Wiimote roll and pitch in degrees
|
2009-02-24 02:40:17 +00:00
|
|
|
// -----------
|
2009-02-12 08:46:48 +00:00
|
|
|
int Roll, Pitch, RollAdj, PitchAdj;
|
|
|
|
WiiMoteEmu::PitchAccelerometerToDegree(data[4], data[5], data[6], Roll, Pitch, RollAdj, PitchAdj);
|
|
|
|
std::string RollPitch = StringFromFormat("%s %s %s %s",
|
|
|
|
(Roll >= 0) ? StringFromFormat(" %03i", Roll).c_str() : StringFromFormat("%04i", Roll).c_str(),
|
|
|
|
(Pitch >= 0) ? StringFromFormat(" %03i", Pitch).c_str() : StringFromFormat("%04i", Pitch).c_str(),
|
2009-02-14 01:15:35 +00:00
|
|
|
(RollAdj == Roll) ? " " : StringFromFormat("%04i*", RollAdj).c_str(),
|
|
|
|
(PitchAdj == Pitch) ? " " : StringFromFormat("%04i*", PitchAdj).c_str());
|
2009-02-24 02:40:17 +00:00
|
|
|
// -------------------------
|
2009-02-12 08:46:48 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------
|
2009-02-12 16:43:35 +00:00
|
|
|
// Test the angles to x, y, z values formula by calculating the values back and forth
|
2009-02-12 08:46:48 +00:00
|
|
|
// -----------
|
2009-11-28 05:59:46 +00:00
|
|
|
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
|
|
|
|
Console->ClearScreen();
|
2009-02-12 08:46:48 +00:00
|
|
|
// Show a test of our calculations
|
|
|
|
WiiMoteEmu::TiltTest(data[4], data[5], data[6]);
|
2009-11-14 17:08:32 +00:00
|
|
|
u8 x, y, z;
|
2009-11-28 05:59:46 +00:00
|
|
|
//WiiMoteEmu::Tilt(x, y, z);
|
|
|
|
//WiiMoteEmu::TiltTest(x, y, z);
|
2009-12-25 22:10:56 +00:00
|
|
|
|
2009-02-12 08:46:48 +00:00
|
|
|
// -------------------------
|
2009-02-14 01:15:35 +00:00
|
|
|
|
2009-02-24 02:40:17 +00:00
|
|
|
// ---------------------------------------------
|
2009-02-14 01:15:35 +00:00
|
|
|
// Show the number of g forces on the axes
|
2009-02-24 02:40:17 +00:00
|
|
|
// -----------
|
2009-02-20 13:14:23 +00:00
|
|
|
float Gx = WiiMoteEmu::AccelerometerToG((float)data[4], (float)g_wm.cal_zero.x, (float)g_wm.cal_g.x);
|
|
|
|
float Gy = WiiMoteEmu::AccelerometerToG((float)data[5], (float)g_wm.cal_zero.y, (float)g_wm.cal_g.y);
|
|
|
|
float Gz = WiiMoteEmu::AccelerometerToG((float)data[6], (float)g_wm.cal_zero.z, (float)g_wm.cal_g.z);
|
2009-02-14 01:15:35 +00:00
|
|
|
std::string GForce = StringFromFormat("%s %s %s",
|
2009-02-20 09:57:17 +00:00
|
|
|
((int)Gx >= 0) ? StringFromFormat(" %i", (int)Gx).c_str() : StringFromFormat("%i", (int)Gx).c_str(),
|
|
|
|
((int)Gy >= 0) ? StringFromFormat(" %i", (int)Gy).c_str() : StringFromFormat("%i", (int)Gy).c_str(),
|
|
|
|
((int)Gz >= 0) ? StringFromFormat(" %i", (int)Gz).c_str() : StringFromFormat("%i", (int)Gz).c_str());
|
2009-02-24 02:40:17 +00:00
|
|
|
// -------------------------
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
2009-02-20 09:57:17 +00:00
|
|
|
// Calculate the IR data
|
2009-02-24 02:40:17 +00:00
|
|
|
// -----------
|
2009-02-20 09:57:17 +00:00
|
|
|
if (data[1] == WM_REPORT_CORE_ACCEL_IR10_EXT6) WiiMoteEmu::IRData2DotsBasic(&data[7]); else WiiMoteEmu::IRData2Dots(&data[7]);
|
2009-02-20 03:13:22 +00:00
|
|
|
std::string IRData;
|
2009-02-20 09:57:17 +00:00
|
|
|
// Create a shortcut
|
2009-07-04 07:28:48 +00:00
|
|
|
struct WiiMoteEmu::SDot* Dot = WiiMoteEmu::g_Wiimote_kbd.IR.Dot;
|
2009-02-20 03:13:22 +00:00
|
|
|
for (int i = 0; i < 4; ++i)
|
|
|
|
{
|
2009-02-20 09:57:17 +00:00
|
|
|
if(Dot[i].Visible)
|
|
|
|
IRData += StringFromFormat("[%i] X:%04i Y:%04i Size:%i ", Dot[i].Order, Dot[i].Rx, Dot[i].Ry, Dot[i].Size);
|
2009-02-20 03:13:22 +00:00
|
|
|
else
|
2009-02-20 09:57:17 +00:00
|
|
|
IRData += StringFromFormat("[%i]", Dot[i].Order);
|
2009-02-20 03:13:22 +00:00
|
|
|
}
|
2009-02-20 09:57:17 +00:00
|
|
|
// Dot distance
|
2009-07-04 07:28:48 +00:00
|
|
|
IRData += StringFromFormat(" | Distance:%i", WiiMoteEmu::g_Wiimote_kbd.IR.Distance);
|
2009-02-24 02:40:17 +00:00
|
|
|
// -------------------------
|
2009-02-20 03:13:22 +00:00
|
|
|
|
2009-02-24 18:37:53 +00:00
|
|
|
// Classic Controller data
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Read[%s]: %s | %s | %s | %s | %s", (Emu ? "Emu" : "Real"),
|
2009-02-24 18:37:53 +00:00
|
|
|
TmpCore.c_str(), TmpAccel.c_str(), TmpIR.c_str(), TmpExt.c_str(), CCData.c_str());
|
|
|
|
// Formatted data only
|
2009-09-15 02:12:55 +00:00
|
|
|
//DEBUG_LOG(WIIMOTE, "Read[%s]: 0x%02x | %s | %s | %s", (Emu ? "Emu" : "Real"), data[1], RollPitch.c_str(), GForce.c_str(), IRData.c_str());
|
2009-02-24 18:37:53 +00:00
|
|
|
// IR data
|
2009-09-15 02:12:55 +00:00
|
|
|
//DEBUG_LOG(WIIMOTE, "Read[%s]: %s | %s", (Emu ? "Emu" : "Real"), TmpData.c_str(), IRData.c_str());
|
2009-02-24 18:37:53 +00:00
|
|
|
// Accelerometer data
|
2009-09-15 02:12:55 +00:00
|
|
|
//DEBUG_LOG(WIIMOTE, "Read[%s]: %s | %s | %s | %s | %s | %s | %s", (Emu ? "Emu" : "Real"),
|
2009-02-24 18:37:53 +00:00
|
|
|
// TmpCore.c_str(), TmpAccel.c_str(), TmpIR.c_str(), TmpExt.c_str(), RollPitch.c_str(), GForce.c_str(), CCData.c_str());
|
|
|
|
// Timestamp
|
2009-09-15 02:12:55 +00:00
|
|
|
//DEBUG_LOG(WIIMOTE, " (%s): %s", Tm(true).c_str(), Temp.c_str());
|
2009-02-12 08:46:48 +00:00
|
|
|
|
2009-02-01 13:01:50 +00:00
|
|
|
}
|
|
|
|
if(g_DebugAccelerometer)
|
|
|
|
{
|
|
|
|
// Accelerometer only
|
2009-03-18 17:17:58 +00:00
|
|
|
// Console::ClearScreen();
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Accel x, y, z: %03u %03u %03u", data[4], data[5], data[6]);
|
2009-02-01 13:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterruptDebugging(bool Emu, const void* _pData)
|
|
|
|
{
|
|
|
|
const u8* data = (const u8*)_pData;
|
|
|
|
|
2009-02-07 03:16:41 +00:00
|
|
|
std::string Name;
|
2009-02-01 13:01:50 +00:00
|
|
|
int size;
|
2009-02-08 10:15:55 +00:00
|
|
|
u16 SampleValue;
|
|
|
|
bool SoundData = false;
|
2009-02-07 03:16:41 +00:00
|
|
|
|
|
|
|
if (g_DebugComm) Name += StringFromFormat("Write[%s] ", (Emu ? "Emu" : "Real"));
|
|
|
|
|
2009-02-01 13:01:50 +00:00
|
|
|
switch(data[1])
|
|
|
|
{
|
|
|
|
case 0x10:
|
|
|
|
size = 4; // I don't know the size
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append("0x10");
|
2009-02-01 13:01:50 +00:00
|
|
|
break;
|
|
|
|
case WM_LEDS: // 0x11
|
|
|
|
size = sizeof(wm_leds);
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append("WM_LEDS");
|
2009-02-01 13:01:50 +00:00
|
|
|
break;
|
2009-11-24 05:03:47 +00:00
|
|
|
case WM_REPORT_MODE: // 0x12
|
|
|
|
size = sizeof(wm_report_mode);
|
|
|
|
if (g_DebugComm) Name.append("WM_REPORT_MODE");
|
2009-02-01 13:01:50 +00:00
|
|
|
break;
|
|
|
|
case WM_REQUEST_STATUS: // 0x15
|
|
|
|
size = sizeof(wm_request_status);
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append("WM_REQUEST_STATUS");
|
2009-02-01 13:01:50 +00:00
|
|
|
break;
|
|
|
|
case WM_WRITE_DATA: // 0x16
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append("WM_WRITE_DATA");
|
2009-02-01 13:01:50 +00:00
|
|
|
size = sizeof(wm_write_data);
|
2009-02-04 06:40:05 +00:00
|
|
|
// data[2]: The address space 0, 1 or 2
|
|
|
|
// data[3]: The registry type
|
|
|
|
// data[5]: The registry offset
|
|
|
|
// data[6]: The number of bytes
|
2009-02-01 13:01:50 +00:00
|
|
|
switch(data[2] >> 0x01)
|
|
|
|
{
|
|
|
|
case WM_SPACE_EEPROM:
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append(" REG_EEPROM"); break;
|
2009-02-01 13:01:50 +00:00
|
|
|
case WM_SPACE_REGS1:
|
|
|
|
case WM_SPACE_REGS2:
|
|
|
|
switch(data[3])
|
|
|
|
{
|
|
|
|
case 0xa2:
|
2009-02-08 10:15:55 +00:00
|
|
|
// data[8]: FF, 0x00 or 0x40
|
|
|
|
// data[9, 10]: RR RR, 0xd007 or 0x401f
|
|
|
|
// data[11]: VV, 0x00 to 0xff or 0x00 to 0x40
|
|
|
|
if (g_DebugComm)
|
|
|
|
{
|
|
|
|
Name.append(" REG_SPEAKER");
|
|
|
|
if(data[6] == 7)
|
|
|
|
{
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Sound configuration:");
|
2009-02-08 10:15:55 +00:00
|
|
|
if(data[8] == 0x00)
|
|
|
|
{
|
|
|
|
memcpy(&SampleValue, &data[9], 2);
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, " Data format: 4-bit ADPCM (%i Hz)", 6000000 / SampleValue);
|
|
|
|
DEBUG_LOG(WIIMOTE, " Volume: %02i%%", (data[11] / 0x40) * 100);
|
2009-02-08 10:15:55 +00:00
|
|
|
}
|
|
|
|
else if (data[8] == 0x40)
|
|
|
|
{
|
|
|
|
memcpy(&SampleValue, &data[9], 2);
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, " Data format: 8-bit PCM (%i Hz)", 12000000 / SampleValue);
|
|
|
|
DEBUG_LOG(WIIMOTE, " Volume: %02i%%", (data[11] / 0xff) * 100);
|
2009-02-08 10:15:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-02-01 13:01:50 +00:00
|
|
|
case 0xa4:
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append(" REG_EXT");
|
|
|
|
// Update the encryption mode
|
|
|
|
if (data[3] == 0xa4 && data[5] == 0xf0)
|
|
|
|
{
|
|
|
|
if (data[7] == 0xaa)
|
|
|
|
WiiMoteEmu::g_Encryption = true;
|
|
|
|
else if (data[7] == 0x55)
|
|
|
|
WiiMoteEmu::g_Encryption = false;
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Extension enryption turned %s", WiiMoteEmu::g_Encryption ? "On" : "Off");
|
2009-02-07 03:16:41 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-02-01 13:01:50 +00:00
|
|
|
case 0xb0:
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append(" REG_IR"); break;
|
2009-02-01 13:01:50 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_READ_DATA: // 0x17
|
|
|
|
size = sizeof(wm_read_data);
|
2009-02-04 06:40:05 +00:00
|
|
|
// data[2]: The address space 0, 1 or 2
|
|
|
|
// data[3]: The registry type
|
|
|
|
// data[5]: The registry offset
|
|
|
|
// data[7]: The number of bytes, 6 and 7 together
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append("WM_READ_DATA");
|
2009-02-01 13:01:50 +00:00
|
|
|
switch(data[2] >> 0x01)
|
|
|
|
{
|
|
|
|
case WM_SPACE_EEPROM:
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append(" REG_EEPROM"); break;
|
2009-02-01 13:01:50 +00:00
|
|
|
case WM_SPACE_REGS1:
|
|
|
|
case WM_SPACE_REGS2:
|
|
|
|
switch(data[3])
|
|
|
|
{
|
|
|
|
case 0xa2:
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append(" REG_SPEAKER"); break;
|
2009-02-01 13:01:50 +00:00
|
|
|
case 0xa4:
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append(" REG_EXT"); break;
|
2009-02-01 13:01:50 +00:00
|
|
|
case 0xb0:
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append(" REG_IR"); break;
|
2009-02-01 13:01:50 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2009-02-08 10:15:55 +00:00
|
|
|
|
2009-02-01 13:01:50 +00:00
|
|
|
case WM_IR_PIXEL_CLOCK: // 0x13
|
|
|
|
case WM_IR_LOGIC: // 0x1a
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append("WM_IR");
|
2009-02-01 13:01:50 +00:00
|
|
|
size = 1;
|
|
|
|
break;
|
|
|
|
case WM_SPEAKER_ENABLE: // 0x14
|
2009-02-08 10:15:55 +00:00
|
|
|
case WM_SPEAKER_MUTE: // 0x19
|
2009-02-07 03:16:41 +00:00
|
|
|
if (g_DebugComm) Name.append("WM_SPEAKER");
|
2009-02-01 13:01:50 +00:00
|
|
|
size = 1;
|
2009-03-18 17:17:58 +00:00
|
|
|
if(data[1] == 0x14) {
|
2009-11-26 05:01:24 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Speaker %s", (data[2] & 4) ? "On" : "Off");
|
2009-03-18 17:17:58 +00:00
|
|
|
} else if(data[1] == 0x19) {
|
2009-11-26 05:01:24 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Speaker %s", (data[2] & 4) ? "Muted" : "Unmuted");
|
2009-03-18 17:17:58 +00:00
|
|
|
}
|
2009-02-01 13:01:50 +00:00
|
|
|
break;
|
2009-02-08 10:15:55 +00:00
|
|
|
case WM_WRITE_SPEAKER_DATA: // 0x18
|
|
|
|
if (g_DebugComm) Name.append("WM_SPEAKER_DATA");
|
|
|
|
size = 21;
|
|
|
|
break;
|
|
|
|
|
2009-02-01 13:01:50 +00:00
|
|
|
default:
|
|
|
|
size = 15;
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "%s InterruptDebugging: Unknown channel 0x%02x", (Emu ? "Emu" : "Real"), data[1]);
|
2009-02-01 13:01:50 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-02-08 10:15:55 +00:00
|
|
|
if (g_DebugComm && !SoundData)
|
2009-02-01 13:01:50 +00:00
|
|
|
{
|
|
|
|
std::string Temp = ArrayToString(data, size + 2, 0, 30);
|
2009-09-15 02:12:55 +00:00
|
|
|
//LOGV(WIIMOTE, 3, " Data: %s", Temp.c_str());
|
2009-12-27 19:31:02 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "%s: %s", Name.c_str(), Temp.c_str());
|
|
|
|
//DEBUG_LOG(WIIMOTE, " (%s): %s", Tm(true).c_str(), Temp.c_str());
|
2009-02-01 13:01:50 +00:00
|
|
|
}
|
2009-02-08 10:15:55 +00:00
|
|
|
if (g_DebugSoundData && SoundData)
|
|
|
|
{
|
|
|
|
std::string Temp = ArrayToString(data, size + 2, 0, 30);
|
2009-09-15 02:12:55 +00:00
|
|
|
//LOGV(WIIMOTE, 3, " Data: %s", Temp.c_str());
|
2009-12-27 19:31:02 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "%s: %s", Name.c_str(), Temp.c_str());
|
|
|
|
//DEBUG_LOG(WIIMOTE, " (%s): %s", Tm(true).c_str(), Temp.c_str());
|
2009-02-08 10:15:55 +00:00
|
|
|
}
|
|
|
|
|
2009-02-01 13:01:50 +00:00
|
|
|
}
|
2009-12-27 19:31:02 +00:00
|
|
|
*/
|