(iOS) Clean up BTstack dynamic loading. Rename ios_joypad.m to ios_joypad.c, there wans't any objective c code there to begin with.

This commit is contained in:
meancoot 2013-03-19 19:04:51 -04:00
parent a012045a2e
commit ba9cb4e043
4 changed files with 53 additions and 42 deletions

View File

@ -20,7 +20,7 @@
963F5AC216CC522F009BBD19 /* RASettingsSubList.m in Sources */ = {isa = PBXBuildFile; fileRef = 963F5ABE16CC522F009BBD19 /* RASettingsSubList.m */; };
963F5AC316CC522F009BBD19 /* RASettingsList.m in Sources */ = {isa = PBXBuildFile; fileRef = 963F5ABF16CC522F009BBD19 /* RASettingsList.m */; };
963F5AC816CC523B009BBD19 /* RAGameView.m in Sources */ = {isa = PBXBuildFile; fileRef = 963F5AC516CC523B009BBD19 /* RAGameView.m */; };
966B9C8B16E40D44005B61E1 /* ios_joypad.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C8716E40D44005B61E1 /* ios_joypad.m */; };
966B9C8B16E40D44005B61E1 /* ios_joypad.c in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C8716E40D44005B61E1 /* ios_joypad.c */; };
966B9CA216E418B7005B61E1 /* BTDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C9116E418B7005B61E1 /* BTDevice.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
966B9CA416E418B7005B61E1 /* BTstackManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C9C16E418B7005B61E1 /* BTstackManager.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
966B9CA616E418B7005B61E1 /* wiimote.c in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C9E16E418B7005B61E1 /* wiimote.c */; };
@ -69,7 +69,7 @@
963F5ABF16CC522F009BBD19 /* RASettingsList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RASettingsList.m; sourceTree = "<group>"; };
963F5AC516CC523B009BBD19 /* RAGameView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RAGameView.m; sourceTree = "<group>"; };
9664F4A116E4409100FB28F9 /* keycode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keycode.h; sourceTree = "<group>"; };
966B9C8716E40D44005B61E1 /* ios_joypad.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ios_joypad.m; sourceTree = "<group>"; };
966B9C8716E40D44005B61E1 /* ios_joypad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ios_joypad.c; sourceTree = "<group>"; };
966B9C9016E418B7005B61E1 /* BTDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BTDevice.h; sourceTree = "<group>"; };
966B9C9116E418B7005B61E1 /* BTDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BTDevice.m; sourceTree = "<group>"; };
966B9C9516E418B7005B61E1 /* btstack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btstack.h; sourceTree = "<group>"; };
@ -157,7 +157,7 @@
966B9C8F16E418B7005B61E1 /* BTStack */,
96F9C26E16F91A64002455B3 /* ios_input.c */,
96F9C26B16F919CC002455B3 /* ios_input.h */,
966B9C8716E40D44005B61E1 /* ios_joypad.m */,
966B9C8716E40D44005B61E1 /* ios_joypad.c */,
9664F4A116E4409100FB28F9 /* keycode.h */,
);
path = input;
@ -419,7 +419,7 @@
963F5AC816CC523B009BBD19 /* RAGameView.m in Sources */,
96096DD816D1ABAF00BF4499 /* RAModuleInfoList.m in Sources */,
96C19C3016D7045700FE8D5A /* RAConfig.m in Sources */,
966B9C8B16E40D44005B61E1 /* ios_joypad.m in Sources */,
966B9C8B16E40D44005B61E1 /* ios_joypad.c in Sources */,
966B9CA216E418B7005B61E1 /* BTDevice.m in Sources */,
966B9CA416E418B7005B61E1 /* BTstackManager.m in Sources */,
966B9CA616E418B7005B61E1 /* wiimote.c in Sources */,

View File

@ -15,34 +15,38 @@
#include <stdio.h>
#include <assert.h>
#include <dlfcn.h>
#define BUILDING_BTDYNAMIC
#include "btdynamic.h"
static bool bt_tested;
static bool bt_is_loaded;
#define GRAB(A) {#A, (void**)&A##_ptr}
static struct
{
const char* name;
void** target;
} grabbers[] =
{
{"bt_open", (void**)&bt_open_ptr},
{"bt_flip_addr", (void**)&bt_flip_addr_ptr},
{"bt_register_packet_handler", (void**)&bt_register_packet_handler_ptr},
{"bt_send_cmd", (void**)&bt_send_cmd_ptr},
{"bt_send_l2cap", (void**)&bt_send_l2cap_ptr},
{"run_loop_init", (void**)&run_loop_init_ptr},
{"btstack_get_system_bluetooth_enabled", (void**)&btstack_get_system_bluetooth_enabled_ptr},
{"btstack_set_power_mode", (void**)&btstack_set_power_mode_ptr},
{"btstack_set_system_bluetooth_enabled", (void**)&btstack_set_system_bluetooth_enabled_ptr},
{"hci_delete_stored_link_key", (void**)&hci_delete_stored_link_key_ptr},
{"hci_inquiry", (void**)&hci_inquiry_ptr},
{"hci_inquiry_cancel", (void**)&hci_inquiry_cancel_ptr},
{"hci_pin_code_request_reply", (void**)&hci_pin_code_request_reply_ptr},
{"hci_remote_name_request", (void**)&hci_remote_name_request_ptr},
{"hci_remote_name_request_cancel", (void**)&hci_remote_name_request_cancel_ptr},
{"hci_write_authentication_enable", (void**)&hci_write_authentication_enable_ptr},
{"hci_write_inquiry_mode", (void**)&hci_write_inquiry_mode_ptr},
{"l2cap_create_channel", (void**)&l2cap_create_channel_ptr},
GRAB(bt_open),
GRAB(bt_flip_addr),
GRAB(bt_register_packet_handler),
GRAB(bt_send_cmd),
GRAB(bt_send_l2cap),
GRAB(run_loop_init),
GRAB(btstack_get_system_bluetooth_enabled),
GRAB(btstack_set_power_mode),
GRAB(btstack_set_system_bluetooth_enabled),
GRAB(hci_delete_stored_link_key),
GRAB(hci_inquiry),
GRAB(hci_inquiry_cancel),
GRAB(hci_pin_code_request_reply),
GRAB(hci_remote_name_request),
GRAB(hci_remote_name_request_cancel),
GRAB(hci_write_authentication_enable),
GRAB(hci_write_inquiry_mode),
GRAB(l2cap_create_channel),
{0, 0}
};
@ -50,9 +54,10 @@ bool load_btstack()
{
assert(sizeof(void**) == sizeof(void(*)));
if (bt_is_loaded)
return true;
if (bt_tested)
return bt_is_loaded;
bt_tested = true;
void* btstack = dlopen("/usr/lib/libBTstack.dylib", RTLD_LAZY);
if (!btstack)

View File

@ -19,26 +19,32 @@
#include "btstack/utils.h"
#include "btstack/btstack.h"
#ifndef BUILDING_BTDYNAMIC
#define BTDIMPORT extern
#else
#define BTDIMPORT
#endif
bool load_btstack();
int (*bt_open_ptr)(void);
void (*bt_flip_addr_ptr)(bd_addr_t dest, bd_addr_t src);
btstack_packet_handler_t (*bt_register_packet_handler_ptr)(btstack_packet_handler_t handler);
int (*bt_send_cmd_ptr)(const hci_cmd_t *cmd, ...);
void (*bt_send_l2cap_ptr)(uint16_t local_cid, uint8_t *data, uint16_t len);
void (*run_loop_init_ptr)(RUN_LOOP_TYPE type);
BTDIMPORT int (*bt_open_ptr)(void);
BTDIMPORT void (*bt_flip_addr_ptr)(bd_addr_t dest, bd_addr_t src);
BTDIMPORT btstack_packet_handler_t (*bt_register_packet_handler_ptr)(btstack_packet_handler_t handler);
BTDIMPORT int (*bt_send_cmd_ptr)(const hci_cmd_t *cmd, ...);
BTDIMPORT void (*bt_send_l2cap_ptr)(uint16_t local_cid, uint8_t *data, uint16_t len);
BTDIMPORT void (*run_loop_init_ptr)(RUN_LOOP_TYPE type);
const hci_cmd_t* btstack_get_system_bluetooth_enabled_ptr;
const hci_cmd_t* btstack_set_power_mode_ptr;
const hci_cmd_t* btstack_set_system_bluetooth_enabled_ptr;
const hci_cmd_t* hci_delete_stored_link_key_ptr;
const hci_cmd_t* hci_inquiry_ptr;
const hci_cmd_t* hci_inquiry_cancel_ptr;
const hci_cmd_t* hci_pin_code_request_reply_ptr;
const hci_cmd_t* hci_remote_name_request_ptr;
const hci_cmd_t* hci_remote_name_request_cancel_ptr;
const hci_cmd_t* hci_write_authentication_enable_ptr;
const hci_cmd_t* hci_write_inquiry_mode_ptr;
const hci_cmd_t* l2cap_create_channel_ptr;
BTDIMPORT const hci_cmd_t* btstack_get_system_bluetooth_enabled_ptr;
BTDIMPORT const hci_cmd_t* btstack_set_power_mode_ptr;
BTDIMPORT const hci_cmd_t* btstack_set_system_bluetooth_enabled_ptr;
BTDIMPORT const hci_cmd_t* hci_delete_stored_link_key_ptr;
BTDIMPORT const hci_cmd_t* hci_inquiry_ptr;
BTDIMPORT const hci_cmd_t* hci_inquiry_cancel_ptr;
BTDIMPORT const hci_cmd_t* hci_pin_code_request_reply_ptr;
BTDIMPORT const hci_cmd_t* hci_remote_name_request_ptr;
BTDIMPORT const hci_cmd_t* hci_remote_name_request_cancel_ptr;
BTDIMPORT const hci_cmd_t* hci_write_authentication_enable_ptr;
BTDIMPORT const hci_cmd_t* hci_write_inquiry_mode_ptr;
BTDIMPORT const hci_cmd_t* l2cap_create_channel_ptr;
#endif