From a99e610443379e4707cef6632875ea9ebc4f5875 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Jun 2014 12:51:49 +0200 Subject: [PATCH] (Apple) Style nits --- apple/iOS/bluetooth/btdynamic.h | 6 ++-- apple/iOS/bluetooth/btpad.c | 55 +++++++++++++++++-------------- apple/iOS/bluetooth/btpad_queue.c | 21 ++++++------ apple/iOS/bluetooth/btpad_queue.h | 6 ++-- 4 files changed, 47 insertions(+), 41 deletions(-) diff --git a/apple/iOS/bluetooth/btdynamic.h b/apple/iOS/bluetooth/btdynamic.h index 4befc15881..334ea70b63 100644 --- a/apple/iOS/bluetooth/btdynamic.h +++ b/apple/iOS/bluetooth/btdynamic.h @@ -20,9 +20,9 @@ #include "btstack/utils.h" #include "btstack/btstack.h" -bool btstack_try_load(); +bool btstack_try_load(void); void btstack_set_poweron(bool on); -bool btstack_is_running(); +bool btstack_is_running(void); #ifndef BUILDING_BTDYNAMIC #define BTDIMPORT extern @@ -38,7 +38,7 @@ BTDIMPORT btstack_packet_handler_t (*bt_register_packet_handler_ptr)(btstack_pac 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); -BTDIMPORT void (*run_loop_execute_ptr)(); +BTDIMPORT void (*run_loop_execute_ptr)(void); BTDIMPORT const hci_cmd_t* btstack_set_power_mode_ptr; BTDIMPORT const hci_cmd_t* hci_delete_stored_link_key_ptr; diff --git a/apple/iOS/bluetooth/btpad.c b/apple/iOS/bluetooth/btpad.c index 13878f3a33..7264287165 100644 --- a/apple/iOS/bluetooth/btpad.c +++ b/apple/iOS/bluetooth/btpad.c @@ -26,7 +26,12 @@ #include "btpad_queue.h" // Private interface -enum btpad_state { BTPAD_EMPTY, BTPAD_CONNECTING, BTPAD_CONNECTED }; +enum btpad_state +{ + BTPAD_EMPTY, + BTPAD_CONNECTING, + BTPAD_CONNECTED +}; struct apple_pad_connection { @@ -48,11 +53,9 @@ void apple_pad_send_control(struct apple_pad_connection* connection, uint8_t* da bt_send_l2cap_ptr(connection->channels[0], data, size); } - static bool inquiry_off; static bool inquiry_running; -// External interface (MAIN THREAD ONLY) void btpad_set_inquiry_state(bool on) { inquiry_off = !on; @@ -64,7 +67,8 @@ void btpad_set_inquiry_state(bool on) // Internal interface: static struct apple_pad_connection* btpad_find_empty_connection() { - for (int i = 0; i != MAX_PLAYERS; i ++) + int i; + for (i = 0; i != MAX_PLAYERS; i ++) if (g_connections[i].state == BTPAD_EMPTY) return &g_connections[i]; @@ -73,7 +77,8 @@ static struct apple_pad_connection* btpad_find_empty_connection() static struct apple_pad_connection* btpad_find_connection_for(uint16_t handle, bd_addr_t address) { - for (int i = 0; i < MAX_PLAYERS; i ++) + int i; + for (i = 0; i < MAX_PLAYERS; i ++) { if (!g_connections[i].handle && !g_connections[i].has_address) continue; @@ -98,9 +103,10 @@ static void btpad_close_connection(struct apple_pad_connection* connection) memset(connection, 0, sizeof(struct apple_pad_connection)); } -static void btpad_close_all_connections() +static void btpad_close_all_connections(void) { - for (int i = 0; i < MAX_PLAYERS; i ++) + int i; + for (i = 0; i < MAX_PLAYERS; i ++) btpad_close_connection(&g_connections[i]); } @@ -138,9 +144,7 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet break; case HCI_EVENT_COMMAND_STATUS: - { - btpad_queue_run(packet[3]); - } + btpad_queue_run(packet[3]); break; case HCI_EVENT_COMMAND_COMPLETE: @@ -150,8 +154,10 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet 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]); + 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; @@ -162,7 +168,8 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet { bt_flip_addr_ptr(event_addr, &packet[3]); - struct apple_pad_connection* connection = btpad_find_empty_connection(); + struct apple_pad_connection* connection = (struct apple_pad_connection*)btpad_find_empty_connection(); + if (connection) { RARCH_LOG("BTpad: Inquiry found device\n"); @@ -196,7 +203,7 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet const uint16_t psm = READ_BT_16(packet, 11); const uint16_t channel_id = READ_BT_16(packet, 13); - struct apple_pad_connection* connection = btpad_find_connection_for(handle, event_addr); + struct apple_pad_connection* connection = (struct apple_pad_connection*)btpad_find_connection_for(handle, event_addr); if (!packet[2]) { @@ -234,7 +241,7 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet const uint32_t psm = READ_BT_16(packet, 10); const uint32_t channel_id = READ_BT_16(packet, 12); - struct apple_pad_connection* connection = btpad_find_connection_for(handle, event_addr); + struct apple_pad_connection* connection = (struct apple_pad_connection*)btpad_find_connection_for(handle, event_addr); if (!connection) { @@ -262,7 +269,7 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet { bt_flip_addr_ptr(event_addr, &packet[3]); - struct apple_pad_connection* connection = btpad_find_connection_for(0, event_addr); + struct apple_pad_connection* connection = (struct apple_pad_connection*)btpad_find_connection_for(0, event_addr); if (!connection) { @@ -278,12 +285,10 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet break; case HCI_EVENT_PIN_CODE_REQUEST: - { - RARCH_LOG("BTpad: Sending WiiMote PIN\n"); + 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]); - } + 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: @@ -292,7 +297,8 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet if (!packet[2]) { - struct apple_pad_connection* connection = btpad_find_connection_for(handle, 0); + struct apple_pad_connection* connection = (struct apple_pad_connection*)btpad_find_connection_for(handle, 0); + if (connection) { connection->handle = 0; @@ -316,9 +322,10 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet } else if (packet_type == L2CAP_DATA_PACKET) { - for (int i = 0; i < MAX_PLAYERS; i ++) + int i; + for (i = 0; i < MAX_PLAYERS; i ++) { - struct apple_pad_connection* connection = &g_connections[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); diff --git a/apple/iOS/bluetooth/btpad_queue.c b/apple/iOS/bluetooth/btpad_queue.c index 2141e7b49f..f51b9603cf 100644 --- a/apple/iOS/bluetooth/btpad_queue.c +++ b/apple/iOS/bluetooth/btpad_queue.c @@ -64,7 +64,7 @@ static uint32_t can_run; #define INCPOS(POS) { POS##_position = (POS##_position + 1) % 64; } -void btpad_queue_reset() +void btpad_queue_reset(void) { insert_position = 0; read_position = 0; @@ -78,11 +78,11 @@ void btpad_queue_run(uint32_t count) btpad_queue_process(); } -void btpad_queue_process() +void btpad_queue_process(void) { for (; can_run && (insert_position != read_position); can_run --) { - struct btpad_queue_command* cmd = &commands[read_position]; + struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[read_position]; if (cmd->command == btstack_set_power_mode_ptr) bt_send_cmd_ptr(cmd->command, cmd->btstack_set_power_mode.on); @@ -104,7 +104,7 @@ void btpad_queue_process() void btpad_queue_btstack_set_power_mode(uint8_t on) { - struct btpad_queue_command* cmd = &commands[insert_position]; + struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[insert_position]; cmd->command = btstack_set_power_mode_ptr; cmd->btstack_set_power_mode.on = on; @@ -113,9 +113,9 @@ void btpad_queue_btstack_set_power_mode(uint8_t on) btpad_queue_process(); } -void btpad_queue_hci_read_bd_addr() +void btpad_queue_hci_read_bd_addr(void) { - struct btpad_queue_command* cmd = &commands[insert_position]; + struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[insert_position]; cmd->command = hci_read_bd_addr_ptr; @@ -125,7 +125,7 @@ void btpad_queue_hci_read_bd_addr() void btpad_queue_hci_disconnect(uint16_t handle, uint8_t reason) { - struct btpad_queue_command* cmd = &commands[insert_position]; + struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[insert_position]; cmd->command = hci_disconnect_ptr; cmd->hci_disconnect.handle = handle; @@ -137,7 +137,7 @@ 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 = &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; @@ -150,7 +150,7 @@ 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) { - struct btpad_queue_command* cmd = &commands[insert_position]; + struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[insert_position]; cmd->command = hci_remote_name_request_ptr; memcpy(cmd->hci_remote_name_request.bd_addr, bd_addr, sizeof(bd_addr_t)); @@ -164,7 +164,7 @@ 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 = &commands[insert_position]; + struct btpad_queue_command* cmd = (struct btpad_queue_command*)&commands[insert_position]; cmd->command = hci_pin_code_request_reply_ptr; memcpy(cmd->hci_pin_code_request_reply.bd_addr, bd_addr, sizeof(bd_addr_t)); @@ -173,4 +173,3 @@ void btpad_queue_hci_pin_code_request_reply(bd_addr_t bd_addr, bd_addr_t pin) INCPOS(insert); btpad_queue_process(); } - diff --git a/apple/iOS/bluetooth/btpad_queue.h b/apple/iOS/bluetooth/btpad_queue.h index d226bf8214..43680a57e7 100644 --- a/apple/iOS/bluetooth/btpad_queue.h +++ b/apple/iOS/bluetooth/btpad_queue.h @@ -16,12 +16,12 @@ #ifndef __IOS_RARCH_BTPAD_QUEUE_H__ #define __IOS_RARCH_BTPAD_QUEUE_H__ -void btpad_queue_reset(); +void btpad_queue_reset(void); void btpad_queue_run(uint32_t count); -void btpad_queue_process(); +void btpad_queue_process(void); void btpad_queue_btstack_set_power_mode(uint8_t on); -void btpad_queue_hci_read_bd_addr(); +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);