(Apple/iOS) Cleanups

This commit is contained in:
twinaphex 2014-10-04 18:11:39 +02:00
parent 93f54db7fa
commit 09e27f523d
6 changed files with 323 additions and 240 deletions

View File

@ -57,7 +57,8 @@ static struct
{0, 0}
};
extern void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
extern void btpad_packet_handler(uint8_t packet_type,
uint16_t channel, uint8_t *packet, uint16_t size);
static bool btstack_tested;
static bool btstack_loaded;
@ -65,7 +66,7 @@ static bool btstack_loaded;
static pthread_t btstack_thread;
static CFRunLoopSourceRef btstack_quit_source;
bool btstack_try_load()
bool btstack_try_load(void)
{
assert(sizeof(void**) == sizeof(void(*)()));
@ -109,7 +110,7 @@ bool btstack_try_load()
return true;
}
void btstack_thread_stop()
void btstack_thread_stop(void)
{
bt_send_cmd_ptr(btstack_set_power_mode_ptr, HCI_POWER_OFF);
}

View File

@ -1,5 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2013-2014 - Jason Fetters
* Copyright (C) 2011-2014 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
@ -34,7 +35,8 @@ BTDIMPORT int (*bt_open_ptr)(void);
BTDIMPORT void (*bt_close_ptr)(void);
BTDIMPORT void (*bt_flip_addr_ptr)(bd_addr_t dest, bd_addr_t src);
BTDIMPORT char* (*bd_addr_to_str_ptr)(bd_addr_t addr);
BTDIMPORT btstack_packet_handler_t (*bt_register_packet_handler_ptr)(btstack_packet_handler_t handler);
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);

View File

@ -1,5 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2013-2014 - Jason Fetters
* Copyright (C) 2011-2014 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
@ -24,7 +25,7 @@
#include "btpad.h"
#include "btpad_queue.h"
// Private interface
/* Private interface. */
enum btpad_state
{
BTPAD_EMPTY,
@ -42,7 +43,7 @@ struct apple_pad_connection
bd_addr_t address;
uint16_t handle;
uint16_t channels[2]; //0: Control, 1: Interrupt
uint16_t channels[2]; /* 0: Control, 1: Interrupt */
};
static bool inquiry_off;
@ -52,7 +53,8 @@ static struct apple_pad_connection g_connections[MAX_PLAYERS];
void apple_pad_send_control(void *data, uint8_t* data_buf, size_t size)
{
struct apple_pad_connection *connection =
(struct apple_pad_connection*)data;
(struct apple_pad_connection*)data;
if (connection)
bt_send_l2cap_ptr(connection->channels[0], data_buf, size);
}
@ -65,18 +67,19 @@ void btpad_set_inquiry_state(bool on)
btpad_queue_hci_inquiry(HCI_INQUIRY_LAP, 3, 1);
}
// Internal interface:
static struct apple_pad_connection* btpad_find_empty_connection()
/* Internal interface. */
static struct apple_pad_connection* btpad_find_empty_connection(void)
{
int i;
for (i = 0; i != MAX_PLAYERS; i ++)
if (g_connections[i].state == BTPAD_EMPTY)
return &g_connections[i];
return 0;
}
static struct apple_pad_connection* btpad_find_connection_for(uint16_t handle, bd_addr_t address)
static struct apple_pad_connection* btpad_find_connection_for(
uint16_t handle, bd_addr_t address)
{
int i;
for (i = 0; i < MAX_PLAYERS; i ++)
@ -84,10 +87,12 @@ static struct apple_pad_connection* btpad_find_connection_for(uint16_t handle, b
if (!g_connections[i].handle && !g_connections[i].has_address)
continue;
if (handle && g_connections[i].handle && handle != g_connections[i].handle)
if (handle && g_connections[i].handle
&& handle != g_connections[i].handle)
continue;
if (address && g_connections[i].has_address && (BD_ADDR_CMP(address, g_connections[i].address)))
if (address && g_connections[i].has_address
&& (BD_ADDR_CMP(address, g_connections[i].address)))
continue;
return &g_connections[i];
@ -96,8 +101,12 @@ static struct apple_pad_connection* btpad_find_connection_for(uint16_t handle, b
return 0;
}
static void btpad_close_connection(struct apple_pad_connection* connection)
static void btpad_close_connection(
struct apple_pad_connection* connection)
{
if (!connection)
return;
if (connection->handle)
btpad_queue_hci_disconnect(connection->handle, 0x15);
@ -111,225 +120,249 @@ static void btpad_close_all_connections(void)
btpad_close_connection(&g_connections[i]);
}
void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)
void btpad_packet_handler(uint8_t packet_type,
uint16_t channel, uint8_t *packet, uint16_t size)
{
int i;
bd_addr_t event_addr;
if (packet_type == HCI_EVENT_PACKET)
switch (packet_type)
{
switch (packet[0])
{
case BTSTACK_EVENT_STATE:
case L2CAP_DATA_PACKET:
for (i = 0; i < MAX_PLAYERS; i ++)
{
RARCH_LOG("BTstack: HCI State %d\n", packet[2]);
switch (packet[2])
{
case HCI_STATE_WORKING:
btpad_queue_reset();
struct apple_pad_connection* connection =
(struct apple_pad_connection*)&g_connections[i];
btpad_queue_hci_read_bd_addr();
bt_send_cmd_ptr(l2cap_register_service_ptr, PSM_HID_CONTROL, 672); // TODO: Where did I get 672 for mtu?
bt_send_cmd_ptr(l2cap_register_service_ptr, PSM_HID_INTERRUPT, 672);
btpad_queue_hci_inquiry(HCI_INQUIRY_LAP, 3, 1);
btpad_queue_run(1);
break;
case HCI_STATE_HALTING:
btpad_close_all_connections();
CFRunLoopStop(CFRunLoopGetCurrent());
break;
}
if (connection && connection->state == BTPAD_CONNECTED
&& (connection->channels[0] == channel ||
connection->channels[1] == channel))
apple_joypad_packet(connection->slot, packet, size);
}
break;
case HCI_EVENT_COMMAND_STATUS:
btpad_queue_run(packet[3]);
break;
case HCI_EVENT_COMMAND_COMPLETE:
case HCI_EVENT_PACKET:
switch (packet[0])
{
btpad_queue_run(packet[2]);
if (COMMAND_COMPLETE_EVENT(packet, (*hci_read_bd_addr_ptr)))
{
bt_flip_addr_ptr(event_addr, &packet[6]);
if (!packet[5])
RARCH_LOG("BTpad: Local address is %s\n", bd_addr_to_str_ptr(event_addr));
else
RARCH_LOG("BTpad: Failed to get local address (Status: %02X)\n", packet[5]);
}
}
break;
case HCI_EVENT_INQUIRY_RESULT:
{
if (packet[2])
{
bt_flip_addr_ptr(event_addr, &packet[3]);
struct apple_pad_connection* connection = (struct apple_pad_connection*)btpad_find_empty_connection();
if (connection)
case BTSTACK_EVENT_STATE:
{
RARCH_LOG("BTpad: Inquiry found device\n");
memset(connection, 0, sizeof(struct apple_pad_connection));
RARCH_LOG("BTstack: HCI State %d\n", packet[2]);
memcpy(connection->address, event_addr, sizeof(bd_addr_t));
connection->has_address = true;
connection->state = BTPAD_CONNECTING;
switch (packet[2])
{
case HCI_STATE_WORKING:
btpad_queue_reset();
bt_send_cmd_ptr(l2cap_create_channel_ptr, connection->address, PSM_HID_CONTROL);
bt_send_cmd_ptr(l2cap_create_channel_ptr, connection->address, PSM_HID_INTERRUPT);
btpad_queue_hci_read_bd_addr();
/* TODO: Where did I get 672 for MTU? */
bt_send_cmd_ptr(l2cap_register_service_ptr,
PSM_HID_CONTROL, 672);
bt_send_cmd_ptr(l2cap_register_service_ptr,
PSM_HID_INTERRUPT, 672);
btpad_queue_hci_inquiry(HCI_INQUIRY_LAP, 3, 1);
btpad_queue_run(1);
break;
case HCI_STATE_HALTING:
btpad_close_all_connections();
CFRunLoopStop(CFRunLoopGetCurrent());
break;
}
}
}
}
break;
case HCI_EVENT_INQUIRY_COMPLETE:
{
// This must be turned off during gameplay as it causes a ton of lag
inquiry_running = !inquiry_off;
if (inquiry_running)
btpad_queue_hci_inquiry(HCI_INQUIRY_LAP, 3, 1);
}
break;
case L2CAP_EVENT_CHANNEL_OPENED:
{
bt_flip_addr_ptr(event_addr, &packet[3]);
const uint16_t handle = READ_BT_16(packet, 9);
const uint16_t psm = READ_BT_16(packet, 11);
const uint16_t channel_id = READ_BT_16(packet, 13);
struct apple_pad_connection* connection = (struct apple_pad_connection*)btpad_find_connection_for(handle, event_addr);
if (!packet[2])
{
if (!connection)
{
RARCH_LOG("BTpad: Got L2CAP 'Channel Opened' event for unrecognized device\n");
break;
}
RARCH_LOG("BTpad: L2CAP channel opened: (PSM: %02X)\n", psm);
connection->handle = handle;
if (psm == PSM_HID_CONTROL)
connection->channels[0] = channel_id;
else if (psm == PSM_HID_INTERRUPT)
connection->channels[1] = channel_id;
else
RARCH_LOG("BTpad: Got unknown L2CAP PSM, ignoring (PSM: %02X)\n", psm);
if (connection->channels[0] && connection->channels[1])
{
RARCH_LOG("BTpad: Got both L2CAP channels, requesting name\n");
btpad_queue_hci_remote_name_request(connection->address, 0, 0, 0);
}
}
else
RARCH_LOG("BTpad: Got failed L2CAP 'Channel Opened' event (PSM: %02X, Status: %02X)\n", psm, packet[2]);
}
break;
case L2CAP_EVENT_INCOMING_CONNECTION:
{
bt_flip_addr_ptr(event_addr, &packet[2]);
const uint16_t handle = READ_BT_16(packet, 8);
const uint32_t psm = READ_BT_16(packet, 10);
const uint32_t channel_id = READ_BT_16(packet, 12);
struct apple_pad_connection* connection = (struct apple_pad_connection*)btpad_find_connection_for(handle, event_addr);
if (!connection)
{
connection = btpad_find_empty_connection();
if (connection)
{
RARCH_LOG("BTpad: Got new incoming connection\n");
memset(connection, 0, sizeof(struct apple_pad_connection));
memcpy(connection->address, event_addr, sizeof(bd_addr_t));
connection->has_address = true;
connection->handle = handle;
connection->state = BTPAD_CONNECTING;
}
else break;
}
RARCH_LOG("BTpad: Incoming L2CAP connection (PSM: %02X)\n", psm);
bt_send_cmd_ptr(l2cap_accept_connection_ptr, channel_id);
}
break;
case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE:
{
bt_flip_addr_ptr(event_addr, &packet[3]);
struct apple_pad_connection* connection = (struct apple_pad_connection*)btpad_find_connection_for(0, event_addr);
if (!connection)
{
RARCH_LOG("BTpad: Got unexpected remote name, ignoring\n");
break;
}
RARCH_LOG("BTpad: Got %.200s\n", (char*)&packet[9]);
connection->slot = apple_joypad_connect((char*)packet + 9, connection);
connection->state = BTPAD_CONNECTED;
}
break;
case HCI_EVENT_COMMAND_STATUS:
btpad_queue_run(packet[3]);
break;
case HCI_EVENT_PIN_CODE_REQUEST:
RARCH_LOG("BTpad: Sending WiiMote PIN\n");
bt_flip_addr_ptr(event_addr, &packet[2]);
btpad_queue_hci_pin_code_request_reply(event_addr, &packet[2]);
break;
case HCI_EVENT_DISCONNECTION_COMPLETE:
{
const uint32_t handle = READ_BT_16(packet, 3);
if (!packet[2])
{
struct apple_pad_connection* connection = (struct apple_pad_connection*)btpad_find_connection_for(handle, 0);
if (connection)
case HCI_EVENT_COMMAND_COMPLETE:
{
connection->handle = 0;
apple_joypad_disconnect(connection->slot);
btpad_close_connection(connection);
}
}
else
RARCH_LOG("BTpad: Got failed 'Disconnection Complete' event (Status: %02X)\n", packet[2]);
}
break;
btpad_queue_run(packet[2]);
case L2CAP_EVENT_SERVICE_REGISTERED:
{
if (packet[2])
RARCH_LOG("BTpad: Got failed 'Service Registered' event (PSM: %02X, Status: %02X)\n", READ_BT_16(packet, 3), packet[2]);
if (COMMAND_COMPLETE_EVENT(packet, (*hci_read_bd_addr_ptr)))
{
bt_flip_addr_ptr(event_addr, &packet[6]);
if (!packet[5])
RARCH_LOG("BTpad: Local address is %s\n",
bd_addr_to_str_ptr(event_addr));
else
RARCH_LOG("BTpad: Failed to get local address (Status: %02X)\n",
packet[5]);
}
}
break;
case HCI_EVENT_INQUIRY_RESULT:
{
if (packet[2])
{
bt_flip_addr_ptr(event_addr, &packet[3]);
struct apple_pad_connection* connection =
(struct apple_pad_connection*)btpad_find_empty_connection();
if (!connection)
return;
RARCH_LOG("BTpad: Inquiry found device\n");
memset(connection, 0, sizeof(struct apple_pad_connection));
memcpy(connection->address, event_addr, sizeof(bd_addr_t));
connection->has_address = true;
connection->state = BTPAD_CONNECTING;
bt_send_cmd_ptr(l2cap_create_channel_ptr, connection->address, PSM_HID_CONTROL);
bt_send_cmd_ptr(l2cap_create_channel_ptr, connection->address, PSM_HID_INTERRUPT);
}
}
break;
case HCI_EVENT_INQUIRY_COMPLETE:
{
/* This must be turned off during gameplay
* as it causes a ton of lag. */
inquiry_running = !inquiry_off;
if (inquiry_running)
btpad_queue_hci_inquiry(HCI_INQUIRY_LAP, 3, 1);
}
break;
case L2CAP_EVENT_CHANNEL_OPENED:
{
bt_flip_addr_ptr(event_addr, &packet[3]);
const uint16_t handle = READ_BT_16(packet, 9);
const uint16_t psm = READ_BT_16(packet, 11);
const uint16_t channel_id = READ_BT_16(packet, 13);
struct apple_pad_connection* connection =
(struct apple_pad_connection*)btpad_find_connection_for(
handle, event_addr);
if (!packet[2])
{
if (!connection)
{
RARCH_LOG("BTpad: Got L2CAP 'Channel Opened' event for unrecognized device\n");
break;
}
RARCH_LOG("BTpad: L2CAP channel opened: (PSM: %02X)\n", psm);
connection->handle = handle;
if (psm == PSM_HID_CONTROL)
connection->channels[0] = channel_id;
else if (psm == PSM_HID_INTERRUPT)
connection->channels[1] = channel_id;
else
RARCH_LOG("BTpad: Got unknown L2CAP PSM, ignoring (PSM: %02X)\n", psm);
if (connection->channels[0]
&& connection->channels[1])
{
RARCH_LOG("BTpad: Got both L2CAP channels, requesting name\n");
btpad_queue_hci_remote_name_request(
connection->address, 0, 0, 0);
}
}
else
RARCH_LOG("BTpad: Got failed L2CAP 'Channel Opened' event (PSM: %02X, Status: %02X)\n", psm, packet[2]);
}
break;
case L2CAP_EVENT_INCOMING_CONNECTION:
{
bt_flip_addr_ptr(event_addr, &packet[2]);
const uint16_t handle = READ_BT_16(packet, 8);
const uint32_t psm = READ_BT_16(packet, 10);
const uint32_t channel_id = READ_BT_16(packet, 12);
struct apple_pad_connection* connection =
(struct apple_pad_connection*)btpad_find_connection_for(
handle, event_addr);
if (!connection)
{
connection = btpad_find_empty_connection();
if (!connection)
break;
RARCH_LOG("BTpad: Got new incoming connection\n");
memset(connection, 0,
sizeof(struct apple_pad_connection));
memcpy(connection->address, event_addr,
sizeof(bd_addr_t));
connection->has_address = true;
connection->handle = handle;
connection->state = BTPAD_CONNECTING;
}
RARCH_LOG("BTpad: Incoming L2CAP connection (PSM: %02X)\n",
psm);
bt_send_cmd_ptr(l2cap_accept_connection_ptr, channel_id);
}
break;
case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE:
{
bt_flip_addr_ptr(event_addr, &packet[3]);
struct apple_pad_connection* connection =
(struct apple_pad_connection*)btpad_find_connection_for(
0, event_addr);
if (!connection)
{
RARCH_LOG("BTpad: Got unexpected remote name, ignoring\n");
break;
}
RARCH_LOG("BTpad: Got %.200s\n", (char*)&packet[9]);
connection->slot = apple_joypad_connect(
(char*)packet + 9, connection);
connection->state = BTPAD_CONNECTED;
}
break;
case HCI_EVENT_PIN_CODE_REQUEST:
RARCH_LOG("BTpad: Sending WiiMote PIN\n");
bt_flip_addr_ptr(event_addr, &packet[2]);
btpad_queue_hci_pin_code_request_reply(event_addr, &packet[2]);
break;
case HCI_EVENT_DISCONNECTION_COMPLETE:
{
const uint32_t handle = READ_BT_16(packet, 3);
if (!packet[2])
{
struct apple_pad_connection* connection =
(struct apple_pad_connection*)btpad_find_connection_for(
handle, 0);
if (connection)
{
connection->handle = 0;
apple_joypad_disconnect(connection->slot);
btpad_close_connection(connection);
}
}
else
RARCH_LOG("BTpad: Got failed 'Disconnection Complete' event (Status: %02X)\n", packet[2]);
}
break;
case L2CAP_EVENT_SERVICE_REGISTERED:
if (packet[2])
RARCH_LOG("BTpad: Got failed 'Service Registered' event (PSM: %02X, Status: %02X)\n",
READ_BT_16(packet, 3), packet[2]);
break;
}
break;
}
}
else if (packet_type == L2CAP_DATA_PACKET)
{
int i;
for (i = 0; i < MAX_PLAYERS; i ++)
{
struct apple_pad_connection* connection = (struct apple_pad_connection*)&g_connections[i];
if (connection->state == BTPAD_CONNECTED && (connection->channels[0] == channel || connection->channels[1] == channel))
apple_joypad_packet(connection->slot, packet, size);
}
}
}

View File

@ -49,7 +49,11 @@ struct btpad_queue_command
uint16_t clock_offset;
} hci_remote_name_request;
struct // For wiimote only
/* For wiimote only.
* TODO - should we repurpose this so
* that it's for more than just Wiimote?
* */
struct
{
bd_addr_t bd_addr;
bd_addr_t pin;
@ -82,21 +86,31 @@ void btpad_queue_process(void)
{
for (; can_run && (insert_position != read_position); can_run --)
{
struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[read_position];
struct btpad_queue_command* cmd = (struct btpad_queue_command*)
&commands[read_position];
if (cmd->command == btstack_set_power_mode_ptr)
if (!cmd)
return;
if (cmd->command == btstack_set_power_mode_ptr)
bt_send_cmd_ptr(cmd->command, cmd->btstack_set_power_mode.on);
else if (cmd->command == hci_read_bd_addr_ptr)
bt_send_cmd_ptr(cmd->command);
else if (cmd->command == hci_disconnect_ptr)
bt_send_cmd_ptr(cmd->command, cmd->hci_disconnect.handle, cmd->hci_disconnect.reason);
bt_send_cmd_ptr(cmd->command, cmd->hci_disconnect.handle,
cmd->hci_disconnect.reason);
else if (cmd->command == hci_inquiry_ptr)
bt_send_cmd_ptr(cmd->command, cmd->hci_inquiry.lap, cmd->hci_inquiry.length, cmd->hci_inquiry.num_responses);
bt_send_cmd_ptr(cmd->command, cmd->hci_inquiry.lap,
cmd->hci_inquiry.length, cmd->hci_inquiry.num_responses);
else if (cmd->command == hci_remote_name_request_ptr)
bt_send_cmd_ptr(cmd->command, cmd->hci_remote_name_request.bd_addr, cmd->hci_remote_name_request.page_scan_repetition_mode,
cmd->hci_remote_name_request.reserved, cmd->hci_remote_name_request.clock_offset);
bt_send_cmd_ptr(cmd->command, cmd->hci_remote_name_request.bd_addr,
cmd->hci_remote_name_request.page_scan_repetition_mode,
cmd->hci_remote_name_request.reserved,
cmd->hci_remote_name_request.clock_offset);
else if (cmd->command == hci_pin_code_request_reply_ptr)
bt_send_cmd_ptr(cmd->command, cmd->hci_pin_code_request_reply.bd_addr, 6, cmd->hci_pin_code_request_reply.pin);
bt_send_cmd_ptr(cmd->command, cmd->hci_pin_code_request_reply.bd_addr,
6, cmd->hci_pin_code_request_reply.pin);
INCPOS(read);
}
@ -104,9 +118,13 @@ void btpad_queue_process(void)
void btpad_queue_btstack_set_power_mode(uint8_t on)
{
struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[insert_position];
struct btpad_queue_command* cmd = (struct btpad_queue_command*)
&commands[insert_position];
cmd->command = btstack_set_power_mode_ptr;
if (!cmd)
return;
cmd->command = btstack_set_power_mode_ptr;
cmd->btstack_set_power_mode.on = on;
INCPOS(insert);
@ -115,7 +133,11 @@ void btpad_queue_btstack_set_power_mode(uint8_t on)
void btpad_queue_hci_read_bd_addr(void)
{
struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[insert_position];
struct btpad_queue_command* cmd = (struct btpad_queue_command*)
&commands[insert_position];
if (!cmd)
return;
cmd->command = hci_read_bd_addr_ptr;
@ -125,9 +147,13 @@ void btpad_queue_hci_read_bd_addr(void)
void btpad_queue_hci_disconnect(uint16_t handle, uint8_t reason)
{
struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[insert_position];
struct btpad_queue_command* cmd = (struct btpad_queue_command*)
&commands[insert_position];
cmd->command = hci_disconnect_ptr;
if (!cmd)
return;
cmd->command = hci_disconnect_ptr;
cmd->hci_disconnect.handle = handle;
cmd->hci_disconnect.reason = reason;
@ -137,20 +163,30 @@ void btpad_queue_hci_disconnect(uint16_t handle, uint8_t reason)
void btpad_queue_hci_inquiry(uint32_t lap, uint8_t length, uint8_t num_responses)
{
struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[insert_position];
struct btpad_queue_command* cmd = (struct btpad_queue_command*)
&commands[insert_position];
cmd->command = hci_inquiry_ptr;
cmd->hci_inquiry.lap = lap;
cmd->hci_inquiry.length = length;
if (!cmd)
return;
cmd->command = hci_inquiry_ptr;
cmd->hci_inquiry.lap = lap;
cmd->hci_inquiry.length = length;
cmd->hci_inquiry.num_responses = num_responses;
INCPOS(insert);
btpad_queue_process();
}
void btpad_queue_hci_remote_name_request(bd_addr_t bd_addr, uint8_t page_scan_repetition_mode, uint8_t reserved, uint16_t clock_offset)
void btpad_queue_hci_remote_name_request(bd_addr_t bd_addr,
uint8_t page_scan_repetition_mode,
uint8_t reserved, uint16_t clock_offset)
{
struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[insert_position];
struct btpad_queue_command* cmd = (struct btpad_queue_command*)
&commands[insert_position];
if (!cmd)
return;
cmd->command = hci_remote_name_request_ptr;
memcpy(cmd->hci_remote_name_request.bd_addr, bd_addr, sizeof(bd_addr_t));
@ -164,7 +200,11 @@ void btpad_queue_hci_remote_name_request(bd_addr_t bd_addr, uint8_t page_scan_re
void btpad_queue_hci_pin_code_request_reply(bd_addr_t bd_addr, bd_addr_t pin)
{
struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[insert_position];
struct btpad_queue_command* cmd = (struct btpad_queue_command*)
&commands[insert_position];
if (!cmd)
return;
cmd->command = hci_pin_code_request_reply_ptr;
memcpy(cmd->hci_pin_code_request_reply.bd_addr, bd_addr, sizeof(bd_addr_t));

View File

@ -1,5 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2013-2014 - Jason Fetters
* Copyright (C) 2011-2014 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
@ -13,18 +14,26 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __IOS_RARCH_BTPAD_QUEUE_H__
#define __IOS_RARCH_BTPAD_QUEUE_H__
#ifndef __BTPAD_QUEUE_H__
#define __BTPAD_QUEUE_H__
void btpad_queue_reset(void);
void btpad_queue_run(uint32_t count);
void btpad_queue_process(void);
void btpad_queue_btstack_set_power_mode(uint8_t on);
void btpad_queue_hci_read_bd_addr(void);
void btpad_queue_hci_disconnect(uint16_t handle, uint8_t reason);
void btpad_queue_hci_inquiry(uint32_t lap, uint8_t length, uint8_t num_responses);
void btpad_queue_hci_remote_name_request(bd_addr_t bd_addr, uint8_t page_scan_repetition_mode, uint8_t reserved, uint16_t clock_offset);
void btpad_queue_hci_remote_name_request(bd_addr_t bd_addr,
uint8_t page_scan_repetition_mode, uint8_t reserved, uint16_t clock_offset);
void btpad_queue_hci_pin_code_request_reply(bd_addr_t bd_addr, bd_addr_t pin);
#endif

View File

@ -17,13 +17,11 @@
#include "apple_input.h"
#include "input_common.h"
#include "../general.h"
#include "../apple/common/apple_gamecontroller.h"
#include "../apple/iOS/bluetooth/btdynamic.c"
#include "../apple/iOS/bluetooth/btpad.c"
#include "../apple/iOS/bluetooth/btpad_queue.c"
#include "../apple/common/apple_gamecontroller.h"
typedef struct
{