mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
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
This commit is contained in:
@ -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;}
|
||||
///////////////////////////////////
|
||||
|
||||
|
||||
|
||||
// **************************************************************************************
|
||||
// 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
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
// ================
|
||||
|
||||
|
@ -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
|
||||
|
@ -60,6 +60,7 @@ namespace Core
|
||||
bool MakeScreenshot(const std::string& _rFilename);
|
||||
void* GetWindowHandle();
|
||||
bool GetRealWiimote();
|
||||
void ReconnectWiimote();
|
||||
|
||||
extern bool bReadTrace;
|
||||
extern bool bWriteTrace;
|
||||
|
@ -108,4 +108,10 @@ namespace HW
|
||||
AudioInterface::DoState(p);
|
||||
WII_IPCInterface::DoState(p);
|
||||
}
|
||||
|
||||
// Restart Wiimote
|
||||
void InitWiimote()
|
||||
{
|
||||
WII_IPCInterface::Init();
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace HW
|
||||
void Init();
|
||||
void Shutdown();
|
||||
void DoState(PointerWrap &p);
|
||||
void InitWiimote();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -19,12 +19,13 @@
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Include
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#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)
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user