Some clean up in io_osx.m, the if not confused me in the SConscript. I made the frames work with WX 2.9. Disabled rumble in Wiimote in OSX. Wiimote MAY work in Dolphin in OSX, not 100% sure. Made a test app and it works in that. Couldn't build a WX build of Dolphin in OSX because Macports doesn't compile in AUI apparently

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4904 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2010-01-20 11:49:11 +00:00
parent f76e9db1a7
commit 40ac160f37
6 changed files with 50 additions and 62 deletions

View File

@ -3,7 +3,7 @@
import sys import sys
Import('env') Import('env')
if not (env['HAVE_BLUEZ'] and sys.platform != 'darwin'): if (env['HAVE_BLUEZ'] != 1 and sys.platform != 'darwin'):
env['HAVE_WIIUSE'] = 0 env['HAVE_WIIUSE'] = 0
Return() Return()

View File

@ -31,7 +31,6 @@
* @brief Handles device I/O for *nix. * @brief Handles device I/O for *nix.
*/ */
#ifndef WIN32
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -89,9 +88,8 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
#pragma mark - #pragma mark -
#pragma mark Bluetooth #pragma mark Bluetooth
- (void) l2capChannelOpenComplete:(IOBluetoothL2CAPChannel*) l2capChannel status:(IOReturn) error - (void) l2capChannelOpenComplete:(IOBluetoothL2CAPChannel*) l2capChannel status:(IOReturn) error {
{ //channel opened
//channel opened
//something to do here ? //something to do here ?
} }
@ -99,10 +97,7 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
- (void)l2capChannelData:(IOBluetoothL2CAPChannel *) l2capChannel data:(byte *)BtData length:(NSUInteger)length { - (void)l2capChannelData:(IOBluetoothL2CAPChannel *) l2capChannel data:(byte *)BtData length:(NSUInteger)length {
//here we got data from wiimote //here we got data from wiimote
for (int o=0; o<MAX_PAYLOAD; o++) memcpy(DataFromWiimote, BtData, MAX_PAYLOAD);
{
DataFromWiimote[o] = BtData[o];
}
//stop the main loop after reading //stop the main loop after reading
CFRunLoopStop( CFRunLoopGetCurrent() ); CFRunLoopStop( CFRunLoopGetCurrent() );
@ -110,8 +105,7 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
- (void) l2capChannelClosed:(IOBluetoothL2CAPChannel*) l2capChannel - (void) l2capChannelClosed:(IOBluetoothL2CAPChannel*) l2capChannel {
{
//channel closed //channel closed
printf("Bt channel closed\n"); printf("Bt channel closed\n");
if (l2capChannel == _cchan) if (l2capChannel == _cchan)
@ -122,14 +116,13 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
} }
#pragma mark - #pragma mark -
- (IOBluetoothL2CAPChannel *) openL2CAPChannelWithPSM:(BluetoothL2CAPPSM) psm delegate:(id) delegate - (IOBluetoothL2CAPChannel *) openL2CAPChannelWithPSM:(BluetoothL2CAPPSM) psm delegate:(id) delegate {
{
IOBluetoothL2CAPChannel * channel = nil; IOBluetoothL2CAPChannel * channel = nil;
IOReturn ret = kIOReturnSuccess; IOReturn ret = kIOReturnSuccess;
printf("Open channel (PSM:%i) ...", psm); WIIUSE_INFO("Open channel (PSM:%i) ...", psm);
if ((ret = (IOReturn)[btd openL2CAPChannelSync:&channel withPSM:psm delegate:delegate]) != kIOReturnSuccess) { if ((ret = (IOReturn)[btd openL2CAPChannelSync:&channel withPSM:psm delegate:delegate]) != kIOReturnSuccess) {
printf("Could not open L2CAP channel (psm:%i)", psm); WIIUSE_INFO("Could not open L2CAP channel (psm:%i)", psm);
channel = nil; channel = nil;
//TODO : close the connection //TODO : close the connection
} }
@ -138,8 +131,7 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
} }
-(void) connectToWiimotes -(void) connectToWiimotes {
{
NSEnumerator * en = [[bti foundDevices] objectEnumerator]; NSEnumerator * en = [[bti foundDevices] objectEnumerator];
@ -150,14 +142,14 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
[btd openL2CAPChannelSync:&_cchan withPSM:kBluetoothL2CAPPSMHIDControl delegate:self]; [btd openL2CAPChannelSync:&_cchan withPSM:kBluetoothL2CAPPSMHIDControl delegate:self];
if (!_cchan) if (!_cchan)
printf("error when initialised cchan\n"); WIIUSE_INFO("error when initialised cchan");
usleep (20000); usleep (20000);
[btd openL2CAPChannelSync:&_ichan withPSM:kBluetoothL2CAPPSMHIDInterrupt delegate:self]; [btd openL2CAPChannelSync:&_ichan withPSM:kBluetoothL2CAPPSMHIDInterrupt delegate:self];
if (!_ichan) if (!_ichan)
printf("error when initialised ichan\n"); WIIUSE_INFO("error when initialised ichan");
usleep (20000); usleep (20000);
@ -180,7 +172,7 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
-(void) deviceInquiryDeviceFound: (IOBluetoothDeviceInquiry*) sender -(void) deviceInquiryDeviceFound: (IOBluetoothDeviceInquiry*) sender
device: (IOBluetoothDevice*) device device: (IOBluetoothDevice*) device
{ {
printf("discovered one wiimote%s\n", [[device getAddressString] UTF8String]); WIIUSE_INFO("discovered one wiimote: %s", [[device getAddressString] UTF8String]);
[bti stop]; [bti stop];
} }
@ -191,8 +183,7 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
SearchBT *sbt; SearchBT *sbt;
ConnectBT *cbt; ConnectBT *cbt;
void detectWiimote() void detectWiimote() {
{
[bti setDelegate: sbt]; [bti setDelegate: sbt];
[bti setInquiryLength:20]; [bti setInquiryLength:20];
@ -201,14 +192,12 @@ void detectWiimote()
IOReturn ret = [bti start]; IOReturn ret = [bti start];
if (ret == kIOReturnSuccess) if (ret == kIOReturnSuccess)
{
[bti retain]; [bti retain];
}
else else
{ {
printf("error when detecting wiimote\n"); WIIUSE_INFO("error when detecting wiimote");
[bti setDelegate: nil]; [bti setDelegate: nil];
bti= nil; bti = nil;
} }
@ -251,10 +240,10 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
WIIMOTE_ENABLE_STATE(wm[found_wiimotes], WIIMOTE_STATE_DEV_FOUND); WIIMOTE_ENABLE_STATE(wm[found_wiimotes], WIIMOTE_STATE_DEV_FOUND);
[bti release]; [bti release];
[sbt release]; [sbt release];
[pool release]; [pool release];
return 1; return 1;
@ -312,19 +301,19 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address) {
return 0; return 0;
//connect to the wiimote //connect to the wiimote
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
cbt = [[ConnectBT alloc] init]; cbt = [[ConnectBT alloc] init];
//start to connect to the wiimotes //start to connect to the wiimotes
[cbt connectToWiimotes]; [cbt connectToWiimotes];
WIIUSE_INFO("Connected to wiimote [id %i].", wm->unid); WIIUSE_INFO("Connected to wiimote [id %i].", wm->unid);
/* do the handshake */ /* do the handshake */
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_CONNECTED); WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
wiiuse_handshake(wm, NULL, 0); wiiuse_handshake(wm, NULL, 0);
wiiuse_set_report_type(wm); wiiuse_set_report_type(wm);
@ -359,15 +348,15 @@ int wiiuse_io_read(struct wiimote_t* wm) {
return 0; return 0;
/* if this wiimote is not connected, skip it */ /* if this wiimote is not connected, skip it */
if (!WIIMOTE_IS_CONNECTED(wm)) if (!WIIMOTE_IS_CONNECTED(wm))
return 0; return 0;
//run the main loop to get bt data //run the main loop to get bt data
CFRunLoopRun(); CFRunLoopRun();
memcpy(wm->event_buf,DataFromWiimote,sizeof(wm->event_buf)); memcpy(wm->event_buf,DataFromWiimote,sizeof(wm->event_buf));
return 1; return 1;
} }
@ -378,5 +367,3 @@ int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
} }
#endif /* ifndef WIN32 */

View File

@ -1,6 +1,7 @@
# -*- python -*- # -*- python -*-
Import('env') Import('env')
import sys
if not env['HAVE_WX']: if not env['HAVE_WX']:
Return() Return()

View File

@ -550,18 +550,18 @@ void CFrame::PostEvent(wxCommandEvent& event)
) )
{ {
event.StopPropagation(); event.StopPropagation();
g_pCodeWindow->AddPendingEvent(event); g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
} }
else else
event.Skip(); event.Skip();
} }
void CFrame::PostMenuEvent(wxMenuEvent& event) void CFrame::PostMenuEvent(wxMenuEvent& event)
{ {
if (g_pCodeWindow) g_pCodeWindow->AddPendingEvent(event); if (g_pCodeWindow) g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
} }
void CFrame::PostUpdateUIEvent(wxUpdateUIEvent& event) void CFrame::PostUpdateUIEvent(wxUpdateUIEvent& event)
{ {
if (g_pCodeWindow) g_pCodeWindow->AddPendingEvent(event); if (g_pCodeWindow) g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
} }
void CFrame::OnMove(wxMoveEvent& event) void CFrame::OnMove(wxMoveEvent& event)

View File

@ -490,11 +490,11 @@ void Host_Message(int Id)
void Host_NotifyMapLoaded() void Host_NotifyMapLoaded()
{ {
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_NOTIFYMAPLOADED); wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_NOTIFYMAPLOADED);
main_frame->AddPendingEvent(event); main_frame->GetEventHandler()->AddPendingEvent(event);
if (main_frame->g_pCodeWindow) if (main_frame->g_pCodeWindow)
{ {
main_frame->g_pCodeWindow->AddPendingEvent(event); main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
} }
} }
@ -502,11 +502,11 @@ void Host_NotifyMapLoaded()
void Host_UpdateLogDisplay() void Host_UpdateLogDisplay()
{ {
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATELOGDISPLAY); wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATELOGDISPLAY);
main_frame->AddPendingEvent(event); main_frame->GetEventHandler()->AddPendingEvent(event);
if (main_frame->g_pCodeWindow) if (main_frame->g_pCodeWindow)
{ {
main_frame->g_pCodeWindow->AddPendingEvent(event); main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
} }
} }
@ -514,11 +514,11 @@ void Host_UpdateLogDisplay()
void Host_UpdateDisasmDialog() void Host_UpdateDisasmDialog()
{ {
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEDISASMDIALOG); wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEDISASMDIALOG);
main_frame->AddPendingEvent(event); main_frame->GetEventHandler()->AddPendingEvent(event);
if (main_frame->g_pCodeWindow) if (main_frame->g_pCodeWindow)
{ {
main_frame->g_pCodeWindow->AddPendingEvent(event); main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
} }
} }
@ -531,22 +531,22 @@ void Host_ShowJitResults(unsigned int address)
void Host_UpdateMainFrame() void Host_UpdateMainFrame()
{ {
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEGUI); wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEGUI);
main_frame->AddPendingEvent(event); main_frame->GetEventHandler()->AddPendingEvent(event);
if (main_frame->g_pCodeWindow) if (main_frame->g_pCodeWindow)
{ {
main_frame->g_pCodeWindow->AddPendingEvent(event); main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
} }
} }
void Host_UpdateBreakPointView() void Host_UpdateBreakPointView()
{ {
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEBREAKPOINTS); wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEBREAKPOINTS);
main_frame->AddPendingEvent(event); main_frame->GetEventHandler()->AddPendingEvent(event);
if (main_frame->g_pCodeWindow) if (main_frame->g_pCodeWindow)
{ {
main_frame->g_pCodeWindow->AddPendingEvent(event); main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
} }
} }
@ -623,7 +623,7 @@ void Host_UpdateStatusBar(const char* _pText, int Field)
// Post message // Post message
// TODO : this has been said to cause hang (??) how is that even possible ? :d // TODO : this has been said to cause hang (??) how is that even possible ? :d
event.StopPropagation(); event.StopPropagation();
main_frame->AddPendingEvent(event); main_frame->GetEventHandler()->AddPendingEvent(event);
// Process the event before continue // Process the event before continue
wxGetApp().ProcessPendingEvents(); wxGetApp().ProcessPendingEvents();
} }
@ -646,6 +646,6 @@ void Host_SetWiiMoteConnectionState(int _State)
// Update field 1 or 2 // Update field 1 or 2
event.SetInt(1); event.SetInt(1);
main_frame->AddPendingEvent(event); main_frame->GetEventHandler()->AddPendingEvent(event);
} }
#endif // HAVE_WX #endif // HAVE_WX

View File

@ -38,7 +38,7 @@ namespace WiiMoteEmu
// SDL Haptic fails on windows, it just doesn't work (even the sample doesn't work) // SDL Haptic fails on windows, it just doesn't work (even the sample doesn't work)
// So until i can make it work, this is all disabled >:( // So until i can make it work, this is all disabled >:(
#if SDL_VERSION_ATLEAST(1, 3, 0) && !defined(_WIN32) #if SDL_VERSION_ATLEAST(1, 3, 0) && !defined(_WIN32) && !defined(__APPLE__)
#define SDL_RUMBLE #define SDL_RUMBLE
#else #else
#ifdef _WIN32 #ifdef _WIN32