mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 05:40:01 -06:00
Some clean up
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3377 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -16,9 +16,7 @@
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#include <iostream> // System
|
||||
#include <queue>
|
||||
|
||||
@ -35,15 +33,13 @@
|
||||
#include "Config.h"
|
||||
#include "EmuMain.h"
|
||||
#include "EmuDefinitions.h"
|
||||
#define EXCLUDE_H // Avoid certain declarations in wiimote_real.h
|
||||
#include "Thread.h"
|
||||
#include "wiimote_real.h"
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
#include "ConfigDlg.h"
|
||||
#endif
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
////////////////////////////////////////
|
||||
|
||||
|
||||
namespace WiiMoteReal
|
||||
{
|
||||
@ -54,11 +50,8 @@ namespace WiiMoteReal
|
||||
|
||||
class CWiiMote;
|
||||
|
||||
#ifdef _WIN32
|
||||
DWORD WINAPI ReadWiimote_ThreadFunc(void* arg);
|
||||
#else
|
||||
void* ReadWiimote_ThreadFunc(void* arg);
|
||||
#endif
|
||||
THREAD_RETURN ReadWiimote_ThreadFunc(void* arg);
|
||||
|
||||
//******************************************************************************
|
||||
// Variable declarations
|
||||
//******************************************************************************
|
||||
@ -86,15 +79,12 @@ class CWiiMote
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////
|
||||
// On create and on uncreate
|
||||
// ---------------
|
||||
CWiiMote(u8 _WiimoteNumber, wiimote_t* _pWiimote)
|
||||
: m_WiimoteNumber(_WiimoteNumber)
|
||||
, m_channelID(0)
|
||||
, m_pWiiMote(_pWiimote)
|
||||
, m_pCriticalSection(NULL)
|
||||
, m_LastReportValid(false)
|
||||
, m_pWiiMote(_pWiimote)
|
||||
{
|
||||
m_pCriticalSection = new Common::CriticalSection();
|
||||
|
||||
@ -110,12 +100,9 @@ virtual ~CWiiMote()
|
||||
{
|
||||
delete m_pCriticalSection;
|
||||
};
|
||||
//////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Queue raw HID data from the core to the wiimote
|
||||
// ---------------
|
||||
void SendData(u16 _channelID, const u8* _pData, u32 _Size)
|
||||
{
|
||||
m_channelID = _channelID;
|
||||
@ -132,12 +119,9 @@ void SendData(u16 _channelID, const u8* _pData, u32 _Size)
|
||||
}
|
||||
m_pCriticalSection->Leave();
|
||||
}
|
||||
/////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
/* Read and write data to the Wiimote */
|
||||
// ---------------
|
||||
void ReadData()
|
||||
{
|
||||
m_pCriticalSection->Enter();
|
||||
@ -193,12 +177,9 @@ void ReadData()
|
||||
}
|
||||
}
|
||||
};
|
||||
/////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Send queued data to the core
|
||||
// ---------------
|
||||
void Update()
|
||||
{
|
||||
// Thread function
|
||||
@ -218,12 +199,9 @@ void Update()
|
||||
|
||||
m_pCriticalSection->Leave();
|
||||
};
|
||||
/////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Clear events
|
||||
// ---------------
|
||||
void ClearEvents()
|
||||
{
|
||||
while (!m_EventReadQueue.empty())
|
||||
@ -231,7 +209,6 @@ void ClearEvents()
|
||||
while (!m_EventWriteQueue.empty())
|
||||
m_EventWriteQueue.pop();
|
||||
}
|
||||
/////////////////////
|
||||
|
||||
private:
|
||||
|
||||
@ -254,9 +231,7 @@ private:
|
||||
SEvent m_LastReport;
|
||||
wiimote_t* m_pWiiMote; // This is g_WiiMotesFromWiiUse[]
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Send queued data to the core
|
||||
// ---------------
|
||||
void SendEvent(SEvent& _rEvent)
|
||||
{
|
||||
// We don't have an answer channel
|
||||
@ -272,8 +247,9 @@ void SendEvent(SEvent& _rEvent)
|
||||
|
||||
// Create the buffer
|
||||
memcpy(&Buffer[Offset], _rEvent.m_PayLoad, MAX_PAYLOAD);
|
||||
/* This Offset value is not exactly correct like it is for the emulated Wiimote reports. It's
|
||||
often to big, but I guess that's okay. The game will know how big the actual data is. */
|
||||
/* This Offset value is not exactly correct like it is for the emulated
|
||||
Wiimote reports. It's often to big, but I guess that's okay. The game
|
||||
will know how big the actual data is. */
|
||||
Offset += MAX_PAYLOAD;
|
||||
|
||||
// Send it
|
||||
@ -282,7 +258,6 @@ void SendEvent(SEvent& _rEvent)
|
||||
// Debugging
|
||||
// ReadDebugging(false, Buffer, Offset);
|
||||
}
|
||||
/////////////////////
|
||||
};
|
||||
|
||||
|
||||
@ -385,11 +360,13 @@ int Initialize()
|
||||
// If we are not using the emulated wiimote we can run the thread temporary until the data has beeen copied
|
||||
if(g_Config.bUseRealWiimote) g_RunTemporary = true;
|
||||
|
||||
/* Allocate memory and copy the Wiimote eeprom accelerometer neutral values to g_Eeprom. Unlike with
|
||||
and extension we have to do this here, because this data is only read once when the Wiimote
|
||||
is connected. Also, we can't change the neutral values the wiimote will report, I think, unless
|
||||
we update its eeprom? In any case it's probably better to let the current calibration be where it
|
||||
is and adjust the global values after that to avoid overwriting critical data on any Wiimote. */
|
||||
/* Allocate memory and copy the Wiimote eeprom accelerometer neutral values
|
||||
to g_Eeprom. Unlike with and extension we have to do this here, because
|
||||
this data is only read once when the Wiimote is connected. Also, we
|
||||
can't change the neutral values the wiimote will report, I think, unless
|
||||
we update its eeprom? In any case it's probably better to let the
|
||||
current calibration be where it is and adjust the global values after
|
||||
that to avoid overwriting critical data on any Wiimote. */
|
||||
// TODO: Update for multiple wiimotes?
|
||||
byte *data = (byte*)malloc(sizeof(byte) * sizeof(WiiMoteEmu::EepromData_0));
|
||||
wiiuse_read_data(g_WiiMotesFromWiiUse[0], data, 0, sizeof(WiiMoteEmu::EepromData_0));
|
||||
@ -450,9 +427,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
// Read the Wiimote once
|
||||
// ---------------
|
||||
void Update()
|
||||
{
|
||||
//INFO_LOG(CONSOLE, "Real Update\n");
|
||||
@ -462,16 +437,11 @@ void Update()
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
/* Continuously read the Wiimote status. However, the actual sending of data occurs in Update(). If we are
|
||||
not currently using the real Wiimote we allow the separate ReadWiimote() function to run. Wo don't use
|
||||
them at the same time to avoid a potential collision. */
|
||||
// ---------------
|
||||
#ifdef _WIN32
|
||||
DWORD WINAPI ReadWiimote_ThreadFunc(void* arg)
|
||||
#else
|
||||
void *ReadWiimote_ThreadFunc(void* arg)
|
||||
#endif
|
||||
/* Continuously read the Wiimote status. However, the actual sending of data
|
||||
occurs in Update(). If we are not currently using the real Wiimote we allow
|
||||
the separate ReadWiimote() function to run. Wo don't use them at the same
|
||||
time to avoid a potential collision. */
|
||||
THREAD_RETURN ReadWiimote_ThreadFunc(void* arg)
|
||||
{
|
||||
while (!g_Shutdown)
|
||||
{
|
||||
|
Reference in New Issue
Block a user