From 4934cd29b30b06fbe6f583660316e6713126d9ed Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Sun, 5 Dec 2010 16:18:09 +0000 Subject: [PATCH] Move NSAutoreleasePool handling into the proper entry/exit points for the real wiimote thread as for the other threads. Turns out we use OS X bluetooth API's that were introduced in 10.5.4. Remove vestiges of previously removed wiiuse_set_bluetooth_stack(). XXX We should probably have a Common equivalent of htonl and friends. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6531 8ced0084-cf51-0410-be5f-012b33b47a6e --- SConstruct | 2 +- .../Core/Src/HW/WiimoteReal/WiimoteReal.cpp | 11 ++++++++ Source/Core/DolphinWX/Src/SConscript | 4 +-- Source/Core/wiiuse/Src/io_osx.mm | 14 ++-------- Source/Core/wiiuse/Src/wiiuse.cpp | 26 ++++--------------- Source/Core/wiiuse/Src/wiiuse.h | 13 +++++----- 6 files changed, 27 insertions(+), 43 deletions(-) diff --git a/SConstruct b/SConstruct index 9502cf0e20..6a26eaba74 100644 --- a/SConstruct +++ b/SConstruct @@ -117,7 +117,7 @@ rev = utils.GenerateRevFile(env['flavor'], '.', None) # OS X specifics if sys.platform == 'darwin': - ccld = ['-arch', 'x86_64', '-arch', 'i386', '-mmacosx-version-min=10.5'] + ccld = ['-arch', 'x86_64', '-arch', 'i386', '-mmacosx-version-min=10.5.4'] ccld += ['--sysroot=/Developer/SDKs/MacOSX10.5.sdk'] system = '/System/Library/Frameworks' env['CCFLAGS'] += ccld diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp index 3bd89122f5..727cd29d48 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp @@ -36,6 +36,10 @@ #pragma comment(lib, "Bthprops.lib") #endif +#ifdef __APPLE__ +#import +#endif + unsigned int g_wiimote_sources[MAX_WIIMOTES]; namespace WiimoteReal @@ -468,6 +472,10 @@ void StopWiimoteThreads() THREAD_RETURN WiimoteThreadFunc(void* arg) { +#ifdef __APPLE__ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; +#endif + Wiimote* const wiimote = (Wiimote*)arg; { @@ -492,6 +500,9 @@ THREAD_RETURN WiimoteThreadFunc(void* arg) Common::SleepCurrentThread(1); } +#ifdef __APPLE__ + [pool release]; +#endif return 0; } diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index c0eb2a51cb..de87eb3a86 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -84,8 +84,8 @@ elif sys.platform == 'darwin' and env['HAVE_WX']: CFBundlePackageType = 'APPL', CFBundleShortVersionString = utils.GenerateRevFile('', Dir('#None').abspath, None), - CFBundleVersion = '2.0', - LSMinimumSystemVersion = '10.5.0', + CFBundleVersion = '3.0', + LSMinimumSystemVersion = '10.5.4', LSRequiresCarbon = True, ))) else: diff --git a/Source/Core/wiiuse/Src/io_osx.mm b/Source/Core/wiiuse/Src/io_osx.mm index c63925d4c3..a2f7e89251 100644 --- a/Source/Core/wiiuse/Src/io_osx.mm +++ b/Source/Core/wiiuse/Src/io_osx.mm @@ -34,10 +34,7 @@ #import extern "C" OSErr UpdateSystemActivity(UInt8 activity); #define BLUETOOTH_VERSION_USE_CURRENT -#import -#import -#import -#import +#import #include "Common.h" #include "wiiuse_internal.h" @@ -116,7 +113,7 @@ volatile int reader, writer, outstanding, watermark; CFRunLoopStop(CFRunLoopGetCurrent()); - UpdateSystemActivity(1); + (void)UpdateSystemActivity(1); } - (void) l2capChannelClosed: (IOBluetoothL2CAPChannel *) l2capChannel @@ -151,7 +148,6 @@ volatile int reader, writer, outstanding, watermark; */ int wiiuse_find(struct wiimote_t **wm, int max_wiimotes, int timeout) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; IOBluetoothHostController *bth; IOBluetoothDeviceInquiry *bti; SearchBT *sbt; @@ -199,7 +195,6 @@ int wiiuse_find(struct wiimote_t **wm, int max_wiimotes, int timeout) [bth release]; [bti release]; [sbt release]; - [pool release]; return found_devices; } @@ -247,7 +242,6 @@ int wiiuse_connect(struct wiimote_t **wm, int wiimotes) */ static int wiiuse_connect_single(struct wiimote_t *wm, char *address) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; ConnectBT *cbt = [[ConnectBT alloc] init]; if (wm == NULL || WIIMOTE_IS_CONNECTED(wm)) @@ -268,7 +262,6 @@ static int wiiuse_connect_single(struct wiimote_t *wm, char *address) wiiuse_set_report_type(wm); [cbt release]; - [pool release]; return 1; } @@ -284,8 +277,6 @@ static int wiiuse_connect_single(struct wiimote_t *wm, char *address) */ void wiiuse_disconnect(struct wiimote_t *wm) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - if (wm == NULL) return; @@ -297,7 +288,6 @@ void wiiuse_disconnect(struct wiimote_t *wm) [cchan closeChannel]; [ichan closeChannel]; [btd closeConnection]; - [pool release]; } int wiiuse_io_read(struct wiimote_t *wm) diff --git a/Source/Core/wiiuse/Src/wiiuse.cpp b/Source/Core/wiiuse/Src/wiiuse.cpp index 937ecf2123..1b9880a00c 100644 --- a/Source/Core/wiiuse/Src/wiiuse.cpp +++ b/Source/Core/wiiuse/Src/wiiuse.cpp @@ -300,7 +300,11 @@ int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte #endif /* the offset is in big endian */ - *(int*)(buf) = Common::swap32(addr); /* XXX only if little-endian */ +#ifdef __BIG_ENDIAN__ + *(int*)(buf) = addr; +#else + *(int*)(buf) = Common::swap32(addr); +#endif /* length */ *(byte*)(buf + 4) = len; @@ -366,26 +370,6 @@ int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len) { } - - -/** - * @brief Set the bluetooth stack type to use. - * - * @param wm Array of wiimote_t structures. - * @param wiimotes Number of objects in the wm array. - * @param type The type of bluetooth stack to use. - */ -void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type) { - #ifdef _WIN32 - int i; - - if (!wm) return; - - for (i = 0; i < wiimotes; ++i) - wm[i]->stack = type; - #endif -} - /** * @brief Set the normal and expansion handshake timeouts. * diff --git a/Source/Core/wiiuse/Src/wiiuse.h b/Source/Core/wiiuse/Src/wiiuse.h index a9049b0a59..9cc8ffb750 100644 --- a/Source/Core/wiiuse/Src/wiiuse.h +++ b/Source/Core/wiiuse/Src/wiiuse.h @@ -42,9 +42,7 @@ #ifdef _WIN32 #include #elif defined(__APPLE__) - #include - #include - #include + #import #elif defined(__linux__) #ifdef HAVE_CONFIG_H #include "config.h" @@ -154,16 +152,17 @@ typedef struct wiimote_t { WCONST int unid; /**< user specified id */ #if defined(__APPLE__) - WCONST IOBluetoothDeviceRef *device; - WCONST char bdaddr_str[18]; + WCONST IOBluetoothDevice *btd; + WCONST IOBluetoothL2CAPChannel *ichan; + WCONST IOBluetoothL2CAPChannel *cchan; #elif defined(__linux__) && HAVE_BLUEZ WCONST bdaddr_t bdaddr; /**< bt address (linux) */ WCONST char bdaddr_str[18]; /**< readable bt address */ WCONST int out_sock; /**< output socket */ WCONST int in_sock; /**< input socket */ #elif defined(_WIN32) - WCONST char devicepath[255]; /**< unique wiimote reference */ - //WCONST ULONGLONG btaddr; /**< bt address (windows) */ + WCONST char devicepath[255]; /**< unique wiimote reference */ + //WCONST ULONGLONG btaddr; /**< bt address (windows) */ WCONST HANDLE dev_handle; /**< HID handle */ WCONST OVERLAPPED hid_overlap; /**< overlap handle */ WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */