Some Wiimote Cleanup, re/moved some globals to where they belong.

A few things could be solved differently/in a better way, but that would involve some classes and stuff (plus work)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5097 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
j4ck.fr0st
2010-02-21 18:53:11 +00:00
parent b6a3df2fcf
commit f7f11211a1
11 changed files with 56 additions and 826 deletions

View File

@ -49,6 +49,9 @@ extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteReal
{
bool g_RealWiiMoteInitialized = false;
bool g_RealWiiMoteAllocated = false;
// Forwarding
class CWiiMote;
@ -387,6 +390,8 @@ int Initialize()
// Allocate each Real WiiMote found to a WiiMote slot with Source set to "WiiMote Real"
void Allocate()
{
if (g_RealWiiMoteAllocated)
return;
if (!g_RealWiiMoteInitialized)
Initialize();
@ -469,6 +474,8 @@ void DoState(PointerWrap &p)
void Shutdown(void)
{
if (!g_RealWiiMoteInitialized)
return;
// Stop the loop in the thread
g_Shutdown = true; // not safe .. might crash when still @ReadWiimote
@ -553,6 +560,20 @@ THREAD_RETURN ReadWiimote_ThreadFunc(void* arg)
}
return 0;
}
// Returns whether SafeClose_ThreadFunc will take over closing of Recording dialog.
// FIXME: this whole threading stuff is bad, and should be removed.
// OSX is having problems with the threading anyways, since WiiUse is used
// from multiple threads, and not just the one where it was created on.
bool SafeClose()
{
if (!g_RealWiiMoteInitialized)
return false;
g_StopThreadTemporary.Set();
return true;
}
// Thread to avoid racing conditions by directly closing of ReadWiimote_ThreadFunc() resp. ReadWiimote()
// shutting down the Dlg while still beeing @ReadWiimote will result in a crash;
THREAD_RETURN SafeCloseReadWiimote_ThreadFunc(void* arg)