Fix noWX compiling, Fix OSX crashing when opening options because of dumb code. Fix OSX Wiimote, will fix multi-wiimote in OSX later.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5154 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2010-03-05 07:03:44 +00:00
parent e2316087f7
commit e79dc93a5c
8 changed files with 55 additions and 16 deletions

View File

@ -53,6 +53,7 @@ IOBluetoothL2CAPChannel * _cchan;
#include "io.h"
byte DataFromWiimote[MAX_PAYLOAD];
NSUInteger g_length;
static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
@ -99,6 +100,7 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
//here we got data from wiimote
memcpy(DataFromWiimote, BtData, MAX_PAYLOAD);
g_length = length;
//stop the main loop after reading
CFRunLoopStop( CFRunLoopGetCurrent() );
@ -319,6 +321,7 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address) {
//start to connect to the wiimotes
[cbt connectToWiimotes];
usleep (200000); // Little delay, or else the device isn't ready!
WIIUSE_INFO("Connected to wiimote [id %i].", wm->unid);
/* do the handshake */
@ -367,8 +370,11 @@ int wiiuse_io_read(struct wiimote_t* wm) {
//run the main loop to get bt data
CFRunLoopRun();
memcpy(wm->event_buf,DataFromWiimote,sizeof(wm->event_buf));
memcpy(wm->event_buf,DataFromWiimote, g_length);
if(!g_length || !wm->event_buf[0]) // no packet
return 0;
wm->event_buf[0] = 0xa2; // Make sure it's 0xa2, just in case
return 1;
}

View File

@ -132,7 +132,10 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low)
pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
u32 netValues[2] = {0};
int NetPlay = GetNetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues);
int NetPlay = 2;
#if defined(HAVE_WX) && HAVE_WX
NetPlay = GetNetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues);
#endif
if (NetPlay != 2)
{

View File

@ -165,9 +165,13 @@ void DllConfig(HWND _hParent)
}
// Only allow one open at a time
#ifdef _WIN32
frame->Disable();
m_ConfigFrame->ShowModal();
frame->Enable();
#else
m_ConfigFrame->ShowModal();
#endif
#ifdef _WIN32
frame->SetFocus();

View File

@ -147,9 +147,13 @@ void DllConfig(HWND _hParent)
}
// Only allow one open at a time
#ifdef _WIN32
frame->Disable();
m_ConfigFrame->ShowModal();
frame->Enable();
#else
m_ConfigFrame->ShowModal();
#endif
#ifdef _WIN32
frame->SetFocus();

View File

@ -164,9 +164,13 @@ void DllConfig(HWND _hParent)
wxWindow *frame = GetParentedWxWindow(_hParent);
m_ConfigFrame = new GCPadConfigDialog(frame);
#ifdef _WIN32
frame->Disable();
m_ConfigFrame->ShowModal();
frame->Enable();
#else
m_ConfigFrame->ShowModal();
#endif
#ifdef _WIN32
frame->SetFocus();

View File

@ -291,10 +291,15 @@ void DllConfig(HWND _hParent)
#endif
// Prevent user to show more than 1 config window at same time
#ifdef _WIN32
frame->Disable();
m_ConfigFrame->CreateGUIControls();
m_ConfigFrame->ShowModal();
frame->Enable();
#else
m_ConfigFrame->CreateGUIControls();
m_ConfigFrame->ShowModal();
#endif
#ifdef _WIN32
frame->SetFocus();

View File

@ -168,10 +168,13 @@ void DllConfig(HWND _hParent)
#if defined(HAVE_WX) && HAVE_WX
wxWindow *frame = GetParentedWxWindow(_hParent);
m_BasicConfigFrame = new WiimoteBasicConfigDialog(frame);
#ifdef _WIN32
frame->Disable();
m_BasicConfigFrame->ShowModal();
frame->Enable();
#else
m_BasicConfigFrame->ShowModal();
#endif
#ifdef _WIN32
frame->SetFocus();

View File

@ -77,6 +77,8 @@ bool g_RunTemporary = false;
int g_RunTemporaryCountdown = 0;
u8 g_EventBuffer[32];
bool g_WiimoteInUse[MAX_WIIMOTES];
Common::Event NeedsConnect;
Common::Event Connected;
// Probably this class should be in its own file
@ -315,6 +317,8 @@ int Initialize()
// Return if already initialized
if (g_RealWiiMoteInitialized)
return g_NumberOfWiiMotes;
NeedsConnect.Init();
Connected.Init();
// Clear the wiimote classes
memset(g_WiiMotes, 0, sizeof(CWiiMote*) * MAX_WIIMOTES);
@ -329,7 +333,15 @@ int Initialize()
g_NumberOfWiiMotes = wiiuse_find(g_WiiMotesFromWiiUse, MAX_WIIMOTES, 5);
DEBUG_LOG(WIIMOTE, "Found No of Wiimotes: %i", g_NumberOfWiiMotes);
if (g_NumberOfWiiMotes > 0)
{
g_RealWiiMotePresent = true;
// Create a new thread for listening for Wiimote data
// and also connecting in Linux/OSX.
// Windows connects to Wiimote in the wiiuse_find function
g_pReadThread = new Common::Thread(ReadWiimote_ThreadFunc, NULL);
NeedsConnect.Set();
Connected.Wait();
}
else
return 0;
@ -349,21 +361,10 @@ int Initialize()
// Will test soon
//wiiuse_set_timeout(g_WiiMotesFromWiiUse, g_NumberOfWiiMotes, 220, 220);
// WiiUse initializes the Wiimotes in Windows right from the wiiuse_find function
// The Functionality should REALLY be changed
#ifndef _WIN32
int Connect;
Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES);
DEBUG_LOG(WIIMOTE, "Connected: %i", Connect);
#endif
// If we are connecting from the config window without a game running we set the LEDs
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY && g_RealWiiMotePresent)
FlashLights(true);
// Create a new thread and start listening for Wiimote data
if (g_NumberOfWiiMotes > 0)
g_pReadThread = new Common::Thread(ReadWiimote_ThreadFunc, NULL);
/* Allocate memory and copy the Wiimote eeprom accelerometer neutral values
to g_Eeprom. Unlike with and extension we have to do this here, because
@ -534,6 +535,15 @@ THREAD_RETURN ReadWiimote_ThreadFunc(void* arg)
{
g_StopThreadTemporary.Init();
g_StartThread.Init();
NeedsConnect.Wait();
#ifndef _WIN32
int Connect;
// WiiUse initializes the Wiimotes in Windows right from the wiiuse_find function
// The Functionality should REALLY be changed
Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES);
DEBUG_LOG(WIIMOTE, "Connected: %i", Connect);
#endif
Connected.Set();
while (!g_Shutdown)
{