summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJohn Peterson <jpeterson57@gmail.com>2009-02-07 03:16:41 +0000
committerJohn Peterson <jpeterson57@gmail.com>2009-02-07 03:16:41 +0000
commitfcdd2a8e17714e8a6485ae06a6c67e696a06e438 (patch)
tree4b7f2f7537caa06d6312c4dfec2fe5f7b1218277 /Source/Core
parent1d0e8ddf84f261ce2a43a318cd3c7c72b09ccf4e (diff)
Wiimote:
1. Fixed the dual mode. You should now be able to change between the real and emulated Wiimote at any time, even when the Nunchuck is connected. It also supports third party Wireless Nunchucks that never sends any calibration values. The Nunchuck status should be automatically updated. The Nunchuck stick may get stuck, but that should fix itself if you disconnect and reconnect again. The only important problems seems to be that the real Wiimote fails to answer sometimes so that the Core functions disconnect it. 2. Began looking at how to reconnect the Wiimote after an unwanted HCI disconnect command git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2129 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/Src/Common.h67
-rw-r--r--Source/Core/Common/Src/ConsoleWindow.cpp7
-rw-r--r--Source/Core/Common/Src/StringUtil.cpp12
-rw-r--r--Source/Core/Core/Src/Core.cpp8
-rw-r--r--Source/Core/Core/Src/Core.h1
-rw-r--r--Source/Core/Core/Src/HW/HW.cpp6
-rw-r--r--Source/Core/Core/Src/HW/HW.h1
-rw-r--r--Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp13
-rw-r--r--Source/Core/DolphinWX/Src/Frame.cpp15
9 files changed, 98 insertions, 32 deletions
diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h
index 646f335027..ac8f57e772 100644
--- a/Source/Core/Common/Src/Common.h
+++ b/Source/Core/Common/Src/Common.h
@@ -18,11 +18,19 @@
#ifndef _COMMON_H
#define _COMMON_H
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Settings
+// -----------------
#define _CRTDBG_MAP_ALLOC
#define _CRTDBG_MAP_ALLOC_NEW
-
#define CHECK_HEAP_INTEGRITY()
+//////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Include
+// -----------------
#ifdef _WIN32
#ifdef _DEBUG
#include <crtdbg.h>
@@ -49,30 +57,37 @@
#include <string.h>
#include "Paths.h"
+///////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Settings
+// -----------------
// Darwin ABI requires that stack frames be aligned to 16-byte boundaries.
// This probably wouldn't break anyone either, but hey
#ifdef __APPLE__
-#define STACKALIGN __attribute__((__force_align_arg_pointer__))
+ #define STACKALIGN __attribute__((__force_align_arg_pointer__))
#else
-#define STACKALIGN
+ #define STACKALIGN
#endif
+
// Function Cross-Compatibility
#ifdef _WIN32
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define unlink _unlink
-#define snprintf _snprintf
+ #define strcasecmp _stricmp
+ #define strncasecmp _strnicmp
+ #define unlink _unlink
+ #define snprintf _snprintf
#else
-#define _stricmp strcasecmp
-#define _strnicmp strncasecmp
-#define _unlink unlink
-#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
+ #define _stricmp strcasecmp
+ #define _strnicmp strncasecmp
+ #define _unlink unlink
+ #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
#endif
-#ifdef _WIN32
+#ifdef _WIN32
// By default, MS' stdio implementation does not support 64-bit offsets.
// This little hack fixes that, keeping the code portable to linux where fseek and fread
// do support 64-bit offsets in modern distributions.
@@ -164,9 +179,19 @@ template<class T>
inline T min(const T& a, const T& b) {return a > b ? b : a;}
template<class T>
inline T max(const T& a, const T& b) {return a > b ? a : b;}
+///////////////////////////////////
+
-// Byte ordering
+// **************************************************************************************
+// Utility functions
+// **************************************************************************************
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Byte ordering
+// -----------------
namespace Common
{
inline u8 swap8(u8 _data) {return(_data);}
@@ -194,12 +219,12 @@ inline u64 swap64(u64 data) {return(((u64)swap32(data) << 32) | swap32(data >> 3
#endif
} // end of namespace Common
+///////////////////////////////////
-// Utility functions
-
-
+//////////////////////////////////////////////////////////////////////////////////////////
// Message alerts
+// -----------------
enum MSG_TYPE
{
INFORMATION,
@@ -223,10 +248,12 @@ extern bool MsgAlert(const char* caption, bool yes_no, int Style, const char* fo
#define PanicYesNo(format, ...) MsgAlert("PANIC", true, WARNING, format, ##__VA_ARGS__)
#define AskYesNo(format, ...) MsgAlert("ASK", true, QUESTION, format, ##__VA_ARGS__)
#endif
+///////////////////////////////////
-
+//////////////////////////////////////////////////////////////////////////////////////////
// Logging
+// -----------------
// dummy class
class LogTypes
@@ -328,9 +355,12 @@ void Host_UpdateLogDisplay();
#define _assert_(a)
#define _assert_msg_(...)
#endif
+///////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////
// Compile time asserts
+// -----------------
namespace
{
@@ -346,8 +376,9 @@ namespace
#endif
#endif
}
+///////////////////////////////////////
-#endif // #ifndef _COMMON_H
+#endif // _COMMON_H
diff --git a/Source/Core/Common/Src/ConsoleWindow.cpp b/Source/Core/Common/Src/ConsoleWindow.cpp
index 9e6404b9fe..68273e013d 100644
--- a/Source/Core/Common/Src/ConsoleWindow.cpp
+++ b/Source/Core/Common/Src/ConsoleWindow.cpp
@@ -95,16 +95,19 @@ void Close()
// Print to screen and file
int Print(const char *fmt, ...)
{
+ // Maximum bytes, mind this value to avoid an overrun
+ static const int MAX_BYTES = 1024*20;
+
#if defined(_WIN32)
if(__hStdOut)
{
#endif
- char s[1024*20]; // Warning, mind this value
+ char s[MAX_BYTES];
va_list argptr;
int cnt; // To store the vsnprintf return message
va_start(argptr, fmt);
- cnt = vsnprintf(s, 500, fmt, argptr);
+ cnt = vsnprintf(s, MAX_BYTES, fmt, argptr);
va_end(argptr);
diff --git a/Source/Core/Common/Src/StringUtil.cpp b/Source/Core/Common/Src/StringUtil.cpp
index 27ec6a7a2d..9a7da21740 100644
--- a/Source/Core/Common/Src/StringUtil.cpp
+++ b/Source/Core/Common/Src/StringUtil.cpp
@@ -151,16 +151,14 @@ std::string StringFromFormat(const char* format, ...)
// ----------------
std::string ArrayToString(const u8 *data, u32 size, u32 offset, int line_len, bool Spaces)
{
- std::string Temp;
+ std::string Tmp, Spc;
+ if (Spaces) Spc = " "; else Spc = "";
for (u32 i = 0; i < size; i++)
{
- char Buffer[128];
- if (Spaces) sprintf(Buffer, "%02x ", data[i + offset]);
- else sprintf(Buffer, "%02x", data[i + offset]);
- if(i > 0 && i % line_len == 0) Temp.append("\n"); // break long lines
- Temp.append(Buffer);
+ Tmp += StringFromFormat("%02x%s", data[i + offset], Spc.c_str());
+ if(i > 1 && (i + 1) % line_len == 0) Tmp.append("\n"); // break long lines
}
- return Temp;
+ return Tmp;
}
// ================
diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp
index a8c20f33b3..381fda36c0 100644
--- a/Source/Core/Core/Src/Core.cpp
+++ b/Source/Core/Core/Src/Core.cpp
@@ -144,6 +144,12 @@ bool GetRealWiimote()
{
return g_bRealWiimote;
}
+// This doesn't work yet, I don't understand how the connection work yet
+void ReconnectWiimote()
+{
+ HW::InitWiimote();
+ Console::Print("ReconnectWiimote()\n");
+}
/////////////////////////////////////
@@ -293,7 +299,7 @@ THREAD_RETURN EmuThread(void *pArg)
LOG(OSREPORT, "Dualcore = %s", _CoreParameter.bUseDualCore ? "Yes" : "No");
HW::Init();
-
+
emuThreadGoing.Set();
// Load the VideoPlugin
diff --git a/Source/Core/Core/Src/Core.h b/Source/Core/Core/Src/Core.h
index d784882e6f..3dcf8ae49b 100644
--- a/Source/Core/Core/Src/Core.h
+++ b/Source/Core/Core/Src/Core.h
@@ -60,6 +60,7 @@ namespace Core
bool MakeScreenshot(const std::string& _rFilename);
void* GetWindowHandle();
bool GetRealWiimote();
+ void ReconnectWiimote();
extern bool bReadTrace;
extern bool bWriteTrace;
diff --git a/Source/Core/Core/Src/HW/HW.cpp b/Source/Core/Core/Src/HW/HW.cpp
index d861f77082..15c3f8fe5d 100644
--- a/Source/Core/Core/Src/HW/HW.cpp
+++ b/Source/Core/Core/Src/HW/HW.cpp
@@ -108,4 +108,10 @@ namespace HW
AudioInterface::DoState(p);
WII_IPCInterface::DoState(p);
}
+
+ // Restart Wiimote
+ void InitWiimote()
+ {
+ WII_IPCInterface::Init();
+ }
}
diff --git a/Source/Core/Core/Src/HW/HW.h b/Source/Core/Core/Src/HW/HW.h
index 131f08072f..667e60f4d3 100644
--- a/Source/Core/Core/Src/HW/HW.h
+++ b/Source/Core/Core/Src/HW/HW.h
@@ -26,6 +26,7 @@ namespace HW
void Init();
void Shutdown();
void DoState(PointerWrap &p);
+ void InitWiimote();
}
#endif
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
index 718d85f95e..b71f8fbce8 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
@@ -19,12 +19,13 @@
//////////////////////////////////////////////////////////////////////////////////////////
// Include
// ŻŻŻŻŻŻŻŻŻŻŻŻŻ
-#include "WII_IPC_HLE_Device_usb.h"
-#include "../PluginManager.h"
+#include "ConsoleWindow.h" // Common
#include "../Core.h" // Local core functions
#include "../Debugger/Debugger_SymbolMap.h"
#include "../Host.h"
+#include "../PluginManager.h"
+#include "WII_IPC_HLE_Device_usb.h"
///////////////////////
@@ -1783,6 +1784,14 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandDisconnect(u8* _Input)
"anyway. It is strongly recommed to save and/or restart the\n"
"emulation.");
}
+ Console::Print("IPC CommandDisconnect\n");
+
+ // Send message to plugin
+ /*
+ Common::PluginWiimote* mote = CPluginManager::GetInstance().GetWiimote(0);
+ u8 Message = WIIMOTE_RECONNECT;
+ mote->Wiimote_ControlChannel(99, &Message, 0);
+ */
}
void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteLinkSupervisionTimeout(u8* _Input)
diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp
index 254c469763..17ae644c67 100644
--- a/Source/Core/DolphinWX/Src/Frame.cpp
+++ b/Source/Core/DolphinWX/Src/Frame.cpp
@@ -47,6 +47,7 @@ be accessed from Core::GetWindowHandle().
#include "Common.h" // Common
#include "FileUtil.h"
#include "Timer.h"
+#include "ConsoleWindow.h"
#include "ConfigManager.h" // Core
#include "Core.h"
@@ -170,16 +171,26 @@ int abc = 0;
switch(wParam)
{
// Stop
- case 5:
+ case OPENGL_WM_USER_STOP:
main_frame->DoStop();
return 0; // Don't bother letting wxWidgets process this at all
- case 15:
+ case OPENGL_WM_USER_CREATE:
// We don't have a local setting for bRenderToMain but we can detect it this way instead
//PanicAlert("main call %i %i %i %i", lParam, (HWND)Core::GetWindowHandle(), MSWGetParent_((HWND)Core::GetWindowHandle()), (HWND)this->GetHWND());
if (lParam == NULL) main_frame->bRenderToMain = false;
else main_frame->bRenderToMain = true;
return 0;
+
+ case NJOY_RELOAD:
+ // DirectInput in nJoy has failed
+ return 0;
+
+ case WIIMOTE_RECONNECT:
+ // The Wiimote plugin has been shut down, now reconnect the Wiimote
+ Console::Print("WIIMOTE_RECONNECT\n");
+ Core::ReconnectWiimote();
+ return 0;
}
break;