mirror of
https://github.com/libretro/RetroArch
synced 2025-03-31 19:21:06 +00:00
(joypad_connection) start calling 'connect' function 'init'
and 'disconnect' 'deinit'
This commit is contained in:
parent
90e63bdae7
commit
f08f78e86a
@ -133,7 +133,7 @@ static void remove_device(void* context, IOReturn result, void* sender)
|
||||
apple->buttons[connection->slot] = 0;
|
||||
memset(apple->axes[connection->slot], 0, sizeof(apple->axes));
|
||||
|
||||
pad_connection_disconnect(&slots[connection->slot], connection->slot);
|
||||
pad_connection_pad_deinit(&slots[connection->slot], connection->slot);
|
||||
free(connection);
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ static void add_device(void* context, IOReturn result,
|
||||
productID = (CFNumberRef)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductIDKey));
|
||||
CFNumberGetValue(productID, kCFNumberIntType, &connection->p_id);
|
||||
|
||||
connection->slot = pad_connection_connect(slots, device_name,
|
||||
connection->slot = pad_connection_pad_init(slots, device_name,
|
||||
connection, &hid_pad_connection_send_control);
|
||||
|
||||
if (pad_connection_has_interface(slots, connection->slot))
|
||||
|
@ -54,9 +54,9 @@ static void hidpad_ps3_send_control(struct hidpad_ps3_data* device)
|
||||
device->send_control(device->connection, report_buffer, sizeof(report_buffer));
|
||||
}
|
||||
|
||||
static void* hidpad_ps3_connect(void *connect_data, uint32_t slot, send_control_t ptr)
|
||||
static void* hidpad_ps3_init(void *data, uint32_t slot, send_control_t ptr)
|
||||
{
|
||||
struct pad_connection* connection = (struct pad_connection*)connect_data;
|
||||
struct pad_connection* connection = (struct pad_connection*)data;
|
||||
struct hidpad_ps3_data* device = (struct hidpad_ps3_data*)
|
||||
calloc(1, sizeof(struct hidpad_ps3_data));
|
||||
|
||||
@ -75,8 +75,8 @@ static void* hidpad_ps3_connect(void *connect_data, uint32_t slot, send_control_
|
||||
|
||||
#ifdef IOS
|
||||
/* Magic packet to start reports. */
|
||||
static uint8_t data[] = {0x53, 0xF4, 0x42, 0x03, 0x00, 0x00};
|
||||
device->send_control(device->connection, data, 6);
|
||||
static uint8_t magic_data[] = {0x53, 0xF4, 0x42, 0x03, 0x00, 0x00};
|
||||
device->send_control(device->connection, magic_data, 6);
|
||||
#endif
|
||||
|
||||
/* Without this, the digital buttons won't be reported. */
|
||||
@ -85,7 +85,7 @@ static void* hidpad_ps3_connect(void *connect_data, uint32_t slot, send_control_
|
||||
return device;
|
||||
}
|
||||
|
||||
static void hidpad_ps3_disconnect(void *data)
|
||||
static void hidpad_ps3_deinit(void *data)
|
||||
{
|
||||
struct hidpad_ps3_data *device = (struct hidpad_ps3_data*)data;
|
||||
|
||||
@ -175,8 +175,8 @@ static void hidpad_ps3_set_rumble(void *data,
|
||||
}
|
||||
|
||||
pad_connection_interface_t pad_connection_ps3 = {
|
||||
hidpad_ps3_connect,
|
||||
hidpad_ps3_disconnect,
|
||||
hidpad_ps3_init,
|
||||
hidpad_ps3_deinit,
|
||||
hidpad_ps3_packet_handler,
|
||||
hidpad_ps3_set_rumble,
|
||||
hidpad_ps3_get_buttons,
|
||||
|
@ -47,10 +47,10 @@ static void hidpad_ps4_send_control(struct hidpad_ps4_data* device)
|
||||
device->send_control(device->connection, report_buffer, sizeof(report_buffer));
|
||||
}
|
||||
|
||||
static void* hidpad_ps4_connect(void *connect_data, uint32_t slot, send_control_t ptr)
|
||||
static void* hidpad_ps4_init(void *data, uint32_t slot, send_control_t ptr)
|
||||
{
|
||||
uint8_t data[0x25];
|
||||
struct pad_connection* connection = (struct pad_connection*)connect_data;
|
||||
uint8_t magic_data[0x25];
|
||||
struct pad_connection* connection = (struct pad_connection*)data;
|
||||
struct hidpad_ps4_data* device = (struct hidpad_ps4_data*)
|
||||
calloc(1, sizeof(struct hidpad_ps4_data));
|
||||
|
||||
@ -69,7 +69,7 @@ static void* hidpad_ps4_connect(void *connect_data, uint32_t slot, send_control_
|
||||
|
||||
/* TODO - unsure of this */
|
||||
/* This is needed to get full input packet over bluetooth. */
|
||||
device->send_control(device->connection, data, 0x2);
|
||||
device->send_control(device->connection, magic_data, 0x2);
|
||||
|
||||
/* Without this, the digital buttons won't be reported. */
|
||||
hidpad_ps4_send_control(device);
|
||||
@ -77,7 +77,7 @@ static void* hidpad_ps4_connect(void *connect_data, uint32_t slot, send_control_
|
||||
return device;
|
||||
}
|
||||
|
||||
static void hidpad_ps4_disconnect(void *data)
|
||||
static void hidpad_ps4_deinit(void *data)
|
||||
{
|
||||
struct hidpad_ps4_data *device = (struct hidpad_ps4_data*)data;
|
||||
|
||||
@ -179,8 +179,8 @@ static void hidpad_ps4_set_rumble(void *data,
|
||||
}
|
||||
|
||||
pad_connection_interface_t pad_connection_ps4 = {
|
||||
hidpad_ps4_connect,
|
||||
hidpad_ps4_disconnect,
|
||||
hidpad_ps4_init,
|
||||
hidpad_ps4_deinit,
|
||||
hidpad_ps4_packet_handler,
|
||||
hidpad_ps4_set_rumble
|
||||
};
|
||||
|
@ -456,7 +456,7 @@ static int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data,
|
||||
|
||||
#endif
|
||||
|
||||
static void* hidpad_wii_connect(void *data, uint32_t slot,
|
||||
static void* hidpad_wii_init(void *data, uint32_t slot,
|
||||
send_control_t ptr)
|
||||
{
|
||||
struct pad_connection *connection = (struct pad_connection*)data;
|
||||
@ -483,7 +483,7 @@ static void* hidpad_wii_connect(void *data, uint32_t slot,
|
||||
return device;
|
||||
}
|
||||
|
||||
static void hidpad_wii_disconnect(void *data)
|
||||
static void hidpad_wii_deinit(void *data)
|
||||
{
|
||||
struct wiimote_t* device = (struct wiimote_t*)data;
|
||||
|
||||
@ -561,8 +561,8 @@ static void hidpad_wii_set_rumble(void *data,
|
||||
}
|
||||
|
||||
pad_connection_interface_t pad_connection_wii = {
|
||||
hidpad_wii_connect,
|
||||
hidpad_wii_disconnect,
|
||||
hidpad_wii_init,
|
||||
hidpad_wii_deinit,
|
||||
hidpad_wii_packet_handler,
|
||||
hidpad_wii_set_rumble,
|
||||
hidpad_wii_get_buttons,
|
||||
|
@ -49,7 +49,7 @@ void *pad_connection_init(unsigned pads)
|
||||
return joyconn;
|
||||
}
|
||||
|
||||
int32_t pad_connection_connect(joypad_connection_t *joyconn,
|
||||
int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
|
||||
const char* name, void *data, send_control_t ptr)
|
||||
{
|
||||
int pad = find_vacant_pad(joyconn);
|
||||
@ -80,7 +80,7 @@ int32_t pad_connection_connect(joypad_connection_t *joyconn,
|
||||
if (strstr(name, pad_map[i].name))
|
||||
{
|
||||
s->iface = pad_map[i].iface;
|
||||
s->data = s->iface->connect(data, pad, ptr);
|
||||
s->data = s->iface->init(data, pad, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ int32_t apple_joypad_connect_gcapi(joypad_connection_t *joyconn)
|
||||
return pad;
|
||||
}
|
||||
|
||||
void pad_connection_disconnect(joypad_connection_t *s, uint32_t pad)
|
||||
void pad_connection_pad_deinit(joypad_connection_t *s, uint32_t pad)
|
||||
{
|
||||
if (!s || !s->used)
|
||||
return;
|
||||
@ -114,8 +114,8 @@ void pad_connection_disconnect(joypad_connection_t *s, uint32_t pad)
|
||||
{
|
||||
s->iface->set_rumble(s->data, RETRO_RUMBLE_STRONG, 0);
|
||||
s->iface->set_rumble(s->data, RETRO_RUMBLE_WEAK, 0);
|
||||
if (s->iface->disconnect)
|
||||
s->iface->disconnect(s->data);
|
||||
if (s->iface->deinit)
|
||||
s->iface->deinit(s->data);
|
||||
}
|
||||
|
||||
s->iface = NULL;
|
||||
@ -162,7 +162,7 @@ void pad_connection_destroy(joypad_connection_t *joyconn)
|
||||
for (i = 0; i < MAX_PLAYERS; i ++)
|
||||
{
|
||||
joypad_connection_t *s = (joypad_connection_t*)&joyconn[i];
|
||||
pad_connection_disconnect(s, i);
|
||||
pad_connection_pad_deinit(s, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ typedef void (*send_control_t)(void *data, uint8_t *buf, size_t size);
|
||||
|
||||
typedef struct pad_connection_interface
|
||||
{
|
||||
void* (*connect)(void *data, uint32_t slot, send_control_t ptr);
|
||||
void (*disconnect)(void* device);
|
||||
void* (*init)(void *data, uint32_t slot, send_control_t ptr);
|
||||
void (*deinit)(void* device);
|
||||
void (*packet_handler)(void* device, uint8_t *packet, uint16_t size);
|
||||
void (*set_rumble)(void* device, enum retro_rumble_effect effect,
|
||||
uint16_t strength);
|
||||
@ -46,7 +46,7 @@ typedef struct
|
||||
bool is_gcapi;
|
||||
} joypad_connection_t;
|
||||
|
||||
int32_t pad_connection_connect(joypad_connection_t *joyconn,
|
||||
int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
|
||||
const char* name, void *data, send_control_t ptr);
|
||||
|
||||
int32_t apple_joypad_connect_gcapi(joypad_connection_t *joyconn);
|
||||
@ -55,7 +55,7 @@ void *pad_connection_init(unsigned pads);
|
||||
|
||||
void pad_connection_destroy(joypad_connection_t *joyconn);
|
||||
|
||||
void pad_connection_disconnect(joypad_connection_t *joyconn,
|
||||
void pad_connection_pad_deinit(joypad_connection_t *joyconn,
|
||||
unsigned idx);
|
||||
|
||||
void pad_connection_packet(joypad_connection_t *joyconn,
|
||||
|
Loading…
x
Reference in New Issue
Block a user