diff --git a/apple/iOS/bluetooth/btpad.c b/apple/iOS/bluetooth/btpad.c index 2e0bc6fdac..098c962703 100644 --- a/apple/iOS/bluetooth/btpad.c +++ b/apple/iOS/bluetooth/btpad.c @@ -33,7 +33,7 @@ enum btpad_state BTPAD_CONNECTED }; -struct apple_pad_connection +struct pad_connection { uint32_t slot; @@ -48,12 +48,11 @@ struct apple_pad_connection static bool inquiry_off; static bool inquiry_running; -static struct apple_pad_connection g_connections[MAX_PLAYERS]; +static struct 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 pad_connection *connection = (struct pad_connection*)data; if (connection) bt_send_l2cap_ptr(connection->channels[0], data_buf, size); @@ -68,7 +67,7 @@ void btpad_set_inquiry_state(bool on) } /* Internal interface. */ -static struct apple_pad_connection* btpad_find_empty_connection(void) +static struct pad_connection* btpad_find_empty_connection(void) { int i; for (i = 0; i != MAX_PLAYERS; i ++) @@ -78,7 +77,7 @@ static struct apple_pad_connection* btpad_find_empty_connection(void) return 0; } -static struct apple_pad_connection* btpad_find_connection_for( +static struct pad_connection* btpad_find_connection_for( uint16_t handle, bd_addr_t address) { int i; @@ -101,8 +100,7 @@ static struct apple_pad_connection* btpad_find_connection_for( return 0; } -static void btpad_close_connection( - struct apple_pad_connection* connection) +static void btpad_close_connection(struct pad_connection* connection) { if (!connection) return; @@ -110,7 +108,7 @@ static void btpad_close_connection( if (connection->handle) btpad_queue_hci_disconnect(connection->handle, 0x15); - memset(connection, 0, sizeof(struct apple_pad_connection)); + memset(connection, 0, sizeof(struct pad_connection)); } static void btpad_close_all_connections(void) @@ -131,8 +129,8 @@ void btpad_packet_handler(uint8_t packet_type, case L2CAP_DATA_PACKET: for (i = 0; i < MAX_PLAYERS; i ++) { - struct apple_pad_connection* connection = - (struct apple_pad_connection*)&g_connections[i]; + struct pad_connection* connection = + (struct pad_connection*)&g_connections[i]; if (connection && connection->state == BTPAD_CONNECTED && (connection->channels[0] == channel || @@ -198,14 +196,14 @@ void btpad_packet_handler(uint8_t packet_type, { bt_flip_addr_ptr(event_addr, &packet[3]); - struct apple_pad_connection* connection = - (struct apple_pad_connection*)btpad_find_empty_connection(); + struct pad_connection* connection = + (struct pad_connection*)btpad_find_empty_connection(); if (!connection) return; RARCH_LOG("BTpad: Inquiry found device\n"); - memset(connection, 0, sizeof(struct apple_pad_connection)); + memset(connection, 0, sizeof(struct pad_connection)); memcpy(connection->address, event_addr, sizeof(bd_addr_t)); connection->has_address = true; @@ -235,8 +233,8 @@ void btpad_packet_handler(uint8_t packet_type, 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( + struct pad_connection* connection = + (struct pad_connection*)btpad_find_connection_for( handle, event_addr); if (!packet[2]) @@ -277,8 +275,8 @@ void btpad_packet_handler(uint8_t packet_type, 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( + struct pad_connection* connection = + (struct pad_connection*)btpad_find_connection_for( handle, event_addr); if (!connection) @@ -290,7 +288,7 @@ void btpad_packet_handler(uint8_t packet_type, RARCH_LOG("BTpad: Got new incoming connection\n"); memset(connection, 0, - sizeof(struct apple_pad_connection)); + sizeof(struct pad_connection)); memcpy(connection->address, event_addr, sizeof(bd_addr_t)); @@ -309,8 +307,8 @@ void btpad_packet_handler(uint8_t packet_type, { bt_flip_addr_ptr(event_addr, &packet[3]); - struct apple_pad_connection* connection = - (struct apple_pad_connection*)btpad_find_connection_for( + struct pad_connection* connection = + (struct pad_connection*)btpad_find_connection_for( 0, event_addr); if (!connection) @@ -340,8 +338,8 @@ void btpad_packet_handler(uint8_t packet_type, if (!packet[2]) { - struct apple_pad_connection* connection = - (struct apple_pad_connection*)btpad_find_connection_for( + struct pad_connection* connection = + (struct pad_connection*)btpad_find_connection_for( handle, 0); if (connection) diff --git a/input/apple_input.h b/input/apple_input.h index 7e919fd4d2..c5861112ee 100644 --- a/input/apple_input.h +++ b/input/apple_input.h @@ -51,7 +51,7 @@ typedef struct const rarch_joypad_driver_t *joypad; } apple_input_data_t; -struct apple_pad_connection; +struct pad_connection; struct apple_pad_interface { diff --git a/input/apple_joypad_hid.c b/input/apple_joypad_hid.c index 43813ce144..47d05d6a84 100644 --- a/input/apple_joypad_hid.c +++ b/input/apple_joypad_hid.c @@ -31,7 +31,7 @@ typedef struct static joypad_slot_t slots[MAX_PLAYERS]; -struct apple_pad_connection +struct pad_connection { int v_id; int p_id; @@ -44,8 +44,7 @@ static IOHIDManagerRef g_hid_manager; 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 pad_connection* connection = (struct pad_connection*)data; if (connection) IOHIDDeviceSetReport(connection->device_handle, @@ -59,8 +58,7 @@ static void hid_device_input_callback(void* context, IOReturn result, void* sender, IOHIDValueRef value) { apple_input_data_t *apple = (apple_input_data_t*)driver.input_data; - struct apple_pad_connection* connection = (struct apple_pad_connection*) - context; + struct pad_connection* connection = (struct pad_connection*)context; IOHIDElementRef element = IOHIDValueGetElement(value); uint32_t type = IOHIDElementGetType(element); uint32_t page = IOHIDElementGetUsagePage(element); @@ -134,8 +132,7 @@ static void hid_device_input_callback(void* context, IOReturn result, static void remove_device(void* context, IOReturn result, void* sender) { apple_input_data_t *apple = (apple_input_data_t*)driver.input_data; - struct apple_pad_connection* connection = (struct apple_pad_connection*) - context; + struct pad_connection* connection = (struct pad_connection*)context; if (connection && connection->slot < MAX_PLAYERS) { @@ -159,8 +156,7 @@ static void hid_device_report(void* context, IOReturn result, void *sender, IOHIDReportType type, uint32_t reportID, uint8_t *report, CFIndex reportLength) { - struct apple_pad_connection* connection = (struct apple_pad_connection*) - context; + struct pad_connection* connection = (struct pad_connection*)context; if (connection) apple_joypad_packet(connection->slot, connection->data, reportLength + 1); @@ -172,7 +168,7 @@ static void add_device(void* context, IOReturn result, char device_name[PATH_MAX]; CFStringRef device_name_ref; CFNumberRef vendorID, productID; - struct apple_pad_connection* connection = (struct apple_pad_connection*) + struct pad_connection* connection = (struct pad_connection*) calloc(1, sizeof(*connection)); connection->device_handle = device; @@ -255,8 +251,7 @@ static int find_vacant_pad(void) int32_t apple_joypad_connect(const char* name, void *data) { - struct apple_pad_connection* connection = - (struct apple_pad_connection*)data; + struct pad_connection* connection = (struct pad_connection*)data; int pad = find_vacant_pad(); if (pad >= 0 && pad < MAX_PLAYERS) diff --git a/input/apple_joypad_ios.c b/input/apple_joypad_ios.c index 0e767aed2a..6fbabe7828 100644 --- a/input/apple_joypad_ios.c +++ b/input/apple_joypad_ios.c @@ -51,8 +51,7 @@ static int find_vacant_pad(void) int32_t apple_joypad_connect(const char* name, void *data) { - struct apple_pad_connection* connection = - (struct apple_pad_connection*)data; + struct pad_connection* connection = (struct pad_connection*)data; int pad = find_vacant_pad(); if (pad >= 0 && pad < MAX_PLAYERS) diff --git a/input/apple_joypad_ps3.c b/input/apple_joypad_ps3.c index 0846dc98a5..68eb76a4bd 100644 --- a/input/apple_joypad_ps3.c +++ b/input/apple_joypad_ps3.c @@ -22,7 +22,7 @@ struct hidpad_ps3_data { - struct apple_pad_connection* connection; + struct pad_connection* connection; uint8_t data[512]; uint32_t slot; bool have_led; @@ -55,8 +55,7 @@ static void hidpad_ps3_send_control(struct hidpad_ps3_data* device) static void* hidpad_ps3_connect(void *connect_data, uint32_t slot) { - struct apple_pad_connection* connection = - (struct apple_pad_connection*)connect_data; + struct pad_connection* connection = (struct pad_connection*)connect_data; struct hidpad_ps3_data* device = (struct hidpad_ps3_data*) calloc(1, sizeof(struct hidpad_ps3_data)); diff --git a/input/apple_joypad_ps4.c b/input/apple_joypad_ps4.c index a38961e53a..0f14cd7dc0 100644 --- a/input/apple_joypad_ps4.c +++ b/input/apple_joypad_ps4.c @@ -22,7 +22,7 @@ struct hidpad_ps4_data { - struct apple_pad_connection* connection; + struct pad_connection* connection; uint8_t data[512]; uint32_t slot; bool have_led; @@ -49,8 +49,7 @@ static void hidpad_ps4_send_control(struct hidpad_ps4_data* device) static void* hidpad_ps4_connect(void *connect_data, uint32_t slot) { - struct apple_pad_connection* connection = - (struct apple_pad_connection*)connect_data; + struct pad_connection* connection = (struct pad_connection*)connect_data; struct hidpad_ps4_data* device = (struct hidpad_ps4_data*) calloc(1, sizeof(struct hidpad_ps4_data)); diff --git a/input/apple_joypad_wii.c b/input/apple_joypad_wii.c index b917ff6043..4bf8ad5e31 100644 --- a/input/apple_joypad_wii.c +++ b/input/apple_joypad_wii.c @@ -22,8 +22,7 @@ static void* hidpad_wii_connect(void *data, uint32_t slot) { - struct apple_pad_connection *connection = - (struct apple_pad_connection*)data; + struct pad_connection *connection = (struct pad_connection*)data; struct wiimote_t *device = (struct wiimote_t*) calloc(1, sizeof(struct wiimote_t)); diff --git a/input/wiimote.h b/input/wiimote.h index 98120f98de..92358f044c 100644 --- a/input/wiimote.h +++ b/input/wiimote.h @@ -171,8 +171,9 @@ typedef struct wiimote_t { /* User specified ID. */ int unid; - /* TODO/FIXME - refactor */ - struct apple_pad_connection* connection; + + struct pad_connection* connection; + /* Various state flags. */ int state; /* Currently lit LEDs. */