(HID) Uniquely name symbols
This commit is contained in:
parent
277b5c9462
commit
5bf829339d
|
@ -30,7 +30,7 @@ typedef struct ds3_instance {
|
||||||
uint8_t data[64];
|
uint8_t data[64];
|
||||||
} ds3_instance_t;
|
} ds3_instance_t;
|
||||||
|
|
||||||
static uint8_t activation_packet[] = {
|
static uint8_t ds3_activation_packet[] = {
|
||||||
#if defined(IOS)
|
#if defined(IOS)
|
||||||
0x53, 0xF4,
|
0x53, 0xF4,
|
||||||
#elif defined(HAVE_WIIUSB_HID)
|
#elif defined(HAVE_WIIUSB_HID)
|
||||||
|
@ -51,7 +51,7 @@ static uint8_t activation_packet[] = {
|
||||||
#define MOTOR1_OFFSET 4
|
#define MOTOR1_OFFSET 4
|
||||||
#define MOTOR2_OFFSET 6
|
#define MOTOR2_OFFSET 6
|
||||||
|
|
||||||
static uint8_t control_packet[] = {
|
static uint8_t ds3_control_packet[] = {
|
||||||
0x52, 0x01,
|
0x52, 0x01,
|
||||||
0x00, 0xff, 0x00, 0xff, 0x00,
|
0x00, 0xff, 0x00, 0xff, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
@ -65,25 +65,23 @@ static uint8_t control_packet[] = {
|
||||||
0x00, 0x00, 0x00
|
0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
static int control_packet_size = sizeof(control_packet);
|
|
||||||
|
|
||||||
extern pad_connection_interface_t ds3_pad_connection;
|
extern pad_connection_interface_t ds3_pad_connection;
|
||||||
|
|
||||||
static void update_pad_state(ds3_instance_t *instance);
|
static void ds3_update_pad_state(ds3_instance_t *instance);
|
||||||
static void update_analog_state(ds3_instance_t *instance);
|
static void ds3_update_analog_state(ds3_instance_t *instance);
|
||||||
|
|
||||||
static int32_t send_activation_packet(ds3_instance_t *instance)
|
static int32_t ds3_send_activation_packet(ds3_instance_t *instance)
|
||||||
{
|
{
|
||||||
int32_t result;
|
int32_t result;
|
||||||
#if defined(WIIU)
|
#if defined(WIIU)
|
||||||
result = HID_SET_REPORT(instance->handle,
|
result = HID_SET_REPORT(instance->handle,
|
||||||
HID_REPORT_FEATURE,
|
HID_REPORT_FEATURE,
|
||||||
DS3_ACTIVATION_REPORT_ID,
|
DS3_ACTIVATION_REPORT_ID,
|
||||||
activation_packet,
|
ds3_activation_packet,
|
||||||
sizeof(activation_packet));
|
sizeof(ds3_activation_packet));
|
||||||
#else
|
#else
|
||||||
HID_SEND_CONTROL(instance->handle,
|
HID_SEND_CONTROL(instance->handle,
|
||||||
activation_packet, sizeof(activation_packet));
|
ds3_activation_packet, sizeof(ds3_activation_packet));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -99,11 +97,11 @@ static uint32_t set_protocol(ds3_instance_t *instance, int protocol)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t send_control_packet(ds3_instance_t *instance)
|
static int32_t ds3_send_control_packet(ds3_instance_t *instance)
|
||||||
{
|
{
|
||||||
uint8_t packet_buffer[control_packet_size];
|
uint8_t packet_buffer[sizeof(ds3_control_packet)];
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
memcpy(packet_buffer, control_packet, control_packet_size);
|
memcpy(packet_buffer, ds3_control_packet, sizeof(ds3_control_packet));
|
||||||
|
|
||||||
packet_buffer[LED_OFFSET] = 0;
|
packet_buffer[LED_OFFSET] = 0;
|
||||||
if(instance->pad) {
|
if(instance->pad) {
|
||||||
|
@ -121,11 +119,11 @@ static int32_t send_control_packet(ds3_instance_t *instance)
|
||||||
HID_REPORT_OUTPUT,
|
HID_REPORT_OUTPUT,
|
||||||
DS3_RUMBLE_REPORT_ID,
|
DS3_RUMBLE_REPORT_ID,
|
||||||
packet_buffer+PACKET_OFFSET,
|
packet_buffer+PACKET_OFFSET,
|
||||||
control_packet_size-PACKET_OFFSET);
|
sizeof(ds3_control_packet)-PACKET_OFFSET);
|
||||||
#else
|
#else
|
||||||
HID_SEND_CONTROL(instance->handle,
|
HID_SEND_CONTROL(instance->handle,
|
||||||
packet_buffer+PACKET_OFFSET,
|
packet_buffer+PACKET_OFFSET,
|
||||||
control_packet_size-PACKET_OFFSET);
|
sizeof(ds3_control_packet)-PACKET_OFFSET);
|
||||||
#endif /* WIIU */
|
#endif /* WIIU */
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -148,11 +146,11 @@ static void *ds3_init(void *handle)
|
||||||
set_protocol(instance, 1);
|
set_protocol(instance, 1);
|
||||||
|
|
||||||
RARCH_LOG("[ds3]: sending control packet\n");
|
RARCH_LOG("[ds3]: sending control packet\n");
|
||||||
if(send_control_packet(instance) < 0)
|
if(ds3_send_control_packet(instance) < 0)
|
||||||
errors++;
|
errors++;
|
||||||
|
|
||||||
RARCH_LOG("[ds3]: sending activation packet\n");
|
RARCH_LOG("[ds3]: sending activation packet\n");
|
||||||
if(send_activation_packet(instance) < 0)
|
if(ds3_send_activation_packet(instance) < 0)
|
||||||
errors++;
|
errors++;
|
||||||
|
|
||||||
if(errors)
|
if(errors)
|
||||||
|
@ -246,23 +244,23 @@ static void ds3_packet_handler(void *data, uint8_t *packet, uint16_t size)
|
||||||
|
|
||||||
if(instance->pad && !instance->led_set)
|
if(instance->pad && !instance->led_set)
|
||||||
{
|
{
|
||||||
send_control_packet(instance);
|
ds3_send_control_packet(instance);
|
||||||
instance->led_set = true;
|
instance->led_set = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(size > control_packet_size)
|
if(size > sizeof(ds3_control_packet))
|
||||||
{
|
{
|
||||||
RARCH_ERR("[ds3]: Expecting packet to be %d but was %d\n",
|
RARCH_ERR("[ds3]: Expecting packet to be %d but was %d\n",
|
||||||
control_packet_size, size);
|
sizeof(ds3_control_packet), size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(instance->data, packet, size);
|
memcpy(instance->data, packet, size);
|
||||||
update_pad_state(instance);
|
ds3_update_pad_state(instance);
|
||||||
update_analog_state(instance);
|
ds3_update_analog_state(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_analog_state(ds3_instance_t *instance)
|
static void ds3_update_analog_state(ds3_instance_t *instance)
|
||||||
{
|
{
|
||||||
int pad_axis;
|
int pad_axis;
|
||||||
int16_t interpolated;
|
int16_t interpolated;
|
||||||
|
@ -277,7 +275,7 @@ static void update_analog_state(ds3_instance_t *instance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_pad_state(ds3_instance_t *instance)
|
static void ds3_update_pad_state(ds3_instance_t *instance)
|
||||||
{
|
{
|
||||||
uint32_t i, pressed_keys;
|
uint32_t i, pressed_keys;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "hid_device_driver.h"
|
#include "hid_device_driver.h"
|
||||||
|
|
||||||
extern pad_connection_interface_t null_pad_connection;
|
extern pad_connection_interface_t hid_null_pad_connection;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the instance data structure for the pad you are implementing.
|
* This is the instance data structure for the pad you are implementing.
|
||||||
|
@ -24,7 +24,8 @@ extern pad_connection_interface_t null_pad_connection;
|
||||||
* sense for the pad you're writing for. The pointer to this structure
|
* sense for the pad you're writing for. The pointer to this structure
|
||||||
* will be passed in as a void pointer to the methods you implement below.
|
* will be passed in as a void pointer to the methods you implement below.
|
||||||
*/
|
*/
|
||||||
typedef struct null_instance {
|
typedef struct hid_null_instance
|
||||||
|
{
|
||||||
void *handle; /* a handle to the HID subsystem adapter */
|
void *handle; /* a handle to the HID subsystem adapter */
|
||||||
joypad_connection_t *pad; /* a pointer to the joypad connection you assign
|
joypad_connection_t *pad; /* a pointer to the joypad connection you assign
|
||||||
in init() */
|
in init() */
|
||||||
|
@ -33,7 +34,7 @@ typedef struct null_instance {
|
||||||
uint16_t motors[2]; /* rumble strength, if appropriate */
|
uint16_t motors[2]; /* rumble strength, if appropriate */
|
||||||
uint8_t data[64]; /* a buffer large enough to hold the device's
|
uint8_t data[64]; /* a buffer large enough to hold the device's
|
||||||
max rx packet */
|
max rx packet */
|
||||||
} null_instance_t;
|
} hid_null_instance_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use the HID_ macros (see input/include/hid_driver.h) to send data packets
|
* Use the HID_ macros (see input/include/hid_driver.h) to send data packets
|
||||||
|
@ -49,14 +50,13 @@ typedef struct null_instance {
|
||||||
*/
|
*/
|
||||||
static void *null_init(void *handle)
|
static void *null_init(void *handle)
|
||||||
{
|
{
|
||||||
null_instance_t *instance;
|
hid_null_instance_t *instance = (hid_null_instance_t *)calloc(1, sizeof(hid_null_instance_t));
|
||||||
instance = (null_instance_t *)calloc(1, sizeof(null_instance_t));
|
|
||||||
if (!instance)
|
if (!instance)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
memset(instance, 0, sizeof(null_instance_t));
|
memset(instance, 0, sizeof(hid_null_instance_t));
|
||||||
instance->handle = handle;
|
instance->handle = handle;
|
||||||
instance->pad = hid_pad_register(instance, &null_pad_connection);
|
instance->pad = hid_pad_register(instance, &hid_null_pad_connection);
|
||||||
if (!instance->pad)
|
if (!instance->pad)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -77,9 +77,10 @@ static void *null_init(void *handle)
|
||||||
*/
|
*/
|
||||||
static void null_free(void *data)
|
static void null_free(void *data)
|
||||||
{
|
{
|
||||||
null_instance_t *instance = (null_instance_t *)data;
|
hid_null_instance_t *instance = (hid_null_instance_t *)data;
|
||||||
|
|
||||||
if(instance) {
|
if (instance)
|
||||||
|
{
|
||||||
hid_pad_deregister(instance->pad);
|
hid_pad_deregister(instance->pad);
|
||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +93,7 @@ static void null_free(void *data)
|
||||||
*/
|
*/
|
||||||
static void null_handle_packet(void *data, uint8_t *buffer, size_t size)
|
static void null_handle_packet(void *data, uint8_t *buffer, size_t size)
|
||||||
{
|
{
|
||||||
null_instance_t *instance = (null_instance_t *)data;
|
hid_null_instance_t *instance = (hid_null_instance_t *)data;
|
||||||
|
|
||||||
if (instance && instance->pad)
|
if (instance && instance->pad)
|
||||||
instance->pad->iface->packet_handler(instance->pad->data, buffer, size);
|
instance->pad->iface->packet_handler(instance->pad->data, buffer, size);
|
||||||
|
@ -123,9 +124,9 @@ hid_device_t null_hid_device = {
|
||||||
* But if you need to track multiple pads attached to the same HID device
|
* But if you need to track multiple pads attached to the same HID device
|
||||||
* (see: Wii U GC adapter), you can allocate that memory here.
|
* (see: Wii U GC adapter), you can allocate that memory here.
|
||||||
*/
|
*/
|
||||||
static void *null_pad_init(void *data, uint32_t slot, hid_driver_t *driver)
|
static void *hid_null_pad_init(void *data, uint32_t slot, hid_driver_t *driver)
|
||||||
{
|
{
|
||||||
null_instance_t *instance = (null_instance_t *)data;
|
hid_null_instance_t *instance = (hid_null_instance_t *)data;
|
||||||
|
|
||||||
if (!instance)
|
if (!instance)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -135,9 +136,9 @@ static void *null_pad_init(void *data, uint32_t slot, hid_driver_t *driver)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If you allocate any memory in null_pad_init() above, de-allocate it here.
|
* If you allocate any memory in hid_null_pad_init() above, de-allocate it here.
|
||||||
*/
|
*/
|
||||||
static void null_pad_deinit(void *data)
|
static void hid_null_pad_deinit(void *data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,9 +146,9 @@ static void null_pad_deinit(void *data)
|
||||||
* Translate the button data from the pad into the input_bits_t format
|
* Translate the button data from the pad into the input_bits_t format
|
||||||
* that RetroArch can use.
|
* that RetroArch can use.
|
||||||
*/
|
*/
|
||||||
static void null_get_buttons(void *data, input_bits_t *state)
|
static void hid_null_get_buttons(void *data, input_bits_t *state)
|
||||||
{
|
{
|
||||||
null_instance_t *instance = (null_instance_t *)data;
|
hid_null_instance_t *instance = (hid_null_instance_t *)data;
|
||||||
if (!instance)
|
if (!instance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -157,9 +158,9 @@ static void null_get_buttons(void *data, input_bits_t *state)
|
||||||
/**
|
/**
|
||||||
* Handle a single packet for the pad.
|
* Handle a single packet for the pad.
|
||||||
*/
|
*/
|
||||||
static void null_packet_handler(void *data, uint8_t *packet, uint16_t size)
|
static void hid_null_packet_handler(void *data, uint8_t *packet, uint16_t size)
|
||||||
{
|
{
|
||||||
null_instance_t *instance = (null_instance_t *)data;
|
hid_null_instance_t *instance = (hid_null_instance_t *)data;
|
||||||
if (!instance)
|
if (!instance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -169,7 +170,7 @@ static void null_packet_handler(void *data, uint8_t *packet, uint16_t size)
|
||||||
/**
|
/**
|
||||||
* If the pad doesn't support rumble, then this can just be a no-op.
|
* If the pad doesn't support rumble, then this can just be a no-op.
|
||||||
*/
|
*/
|
||||||
static void null_set_rumble(void *data, enum retro_rumble_effect effect, uint16_t strength)
|
static void hid_null_set_rumble(void *data, enum retro_rumble_effect effect, uint16_t strength)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +183,7 @@ static void null_set_rumble(void *data, enum retro_rumble_effect effect, uint16_
|
||||||
* - (-32768,-32768) is top-left
|
* - (-32768,-32768) is top-left
|
||||||
* - (32767,32767) is bottom-right
|
* - (32767,32767) is bottom-right
|
||||||
*/
|
*/
|
||||||
static int16_t null_get_axis(void *data, unsigned axis)
|
static int16_t hid_null_get_axis(void *data, unsigned axis)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +192,7 @@ static int16_t null_get_axis(void *data, unsigned axis)
|
||||||
* The name the pad will show up as in the UI, also used to auto-assign
|
* The name the pad will show up as in the UI, also used to auto-assign
|
||||||
* buttons in input/input_autodetect_builtin.c
|
* buttons in input/input_autodetect_builtin.c
|
||||||
*/
|
*/
|
||||||
static const char *null_get_name(void *data)
|
static const char *hid_null_get_name(void *data)
|
||||||
{
|
{
|
||||||
return "Null HID Pad";
|
return "Null HID Pad";
|
||||||
}
|
}
|
||||||
|
@ -199,7 +200,7 @@ static const char *null_get_name(void *data)
|
||||||
/**
|
/**
|
||||||
* Read the state of a single button.
|
* Read the state of a single button.
|
||||||
*/
|
*/
|
||||||
static bool null_button(void *data, uint16_t joykey)
|
static bool hid_null_button(void *data, uint16_t joykey)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -207,13 +208,13 @@ static bool null_button(void *data, uint16_t joykey)
|
||||||
/**
|
/**
|
||||||
* Fill in the joypad interface
|
* Fill in the joypad interface
|
||||||
*/
|
*/
|
||||||
pad_connection_interface_t null_pad_connection = {
|
pad_connection_interface_t hid_null_pad_connection = {
|
||||||
null_pad_init,
|
hid_null_pad_init,
|
||||||
null_pad_deinit,
|
hid_null_pad_deinit,
|
||||||
null_packet_handler,
|
hid_null_packet_handler,
|
||||||
null_set_rumble,
|
hid_null_set_rumble,
|
||||||
null_get_buttons,
|
hid_null_get_buttons,
|
||||||
null_get_axis,
|
hid_null_get_axis,
|
||||||
null_get_name,
|
hid_null_get_name,
|
||||||
null_button
|
hid_null_button
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,12 +27,13 @@ static uint8_t activation_packet[] = { 0x13 };
|
||||||
#define GCA_PORT_CONNECTED 0x10
|
#define GCA_PORT_CONNECTED 0x10
|
||||||
#define GCA_WAVEBIRD_CONNECTED 0x22
|
#define GCA_WAVEBIRD_CONNECTED 0x22
|
||||||
|
|
||||||
typedef struct wiiu_gca_instance {
|
typedef struct hid_wiiu_gca_instance
|
||||||
|
{
|
||||||
void *handle;
|
void *handle;
|
||||||
bool online;
|
bool online;
|
||||||
uint8_t device_state[37];
|
uint8_t device_state[37];
|
||||||
joypad_connection_t *pads[4];
|
joypad_connection_t *pads[4];
|
||||||
} wiiu_gca_instance_t;
|
} hid_wiiu_gca_instance_t;
|
||||||
|
|
||||||
typedef struct gca_pad_data
|
typedef struct gca_pad_data
|
||||||
{
|
{
|
||||||
|
@ -44,17 +45,18 @@ typedef struct gca_pad_data
|
||||||
int16_t analog_state[3][2]; // analog state
|
int16_t analog_state[3][2]; // analog state
|
||||||
} gca_pad_t;
|
} gca_pad_t;
|
||||||
|
|
||||||
static void update_pad_state(wiiu_gca_instance_t *instance);
|
static void wiiu_gca_update_pad_state(hid_wiiu_gca_instance_t *instance);
|
||||||
static void unregister_pad(wiiu_gca_instance_t *instance, int port);
|
static void wiiu_gca_unregister_pad(hid_wiiu_gca_instance_t *instance, int port);
|
||||||
|
|
||||||
extern pad_connection_interface_t wiiu_gca_pad_connection;
|
extern pad_connection_interface_t wiiu_gca_pad_connection;
|
||||||
|
|
||||||
static void *wiiu_gca_init(void *handle)
|
static void *wiiu_gca_init(void *handle)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[gca]: allocating driver instance...\n");
|
RARCH_LOG("[gca]: allocating driver instance...\n");
|
||||||
wiiu_gca_instance_t *instance = calloc(1, sizeof(wiiu_gca_instance_t));
|
hid_wiiu_gca_instance_t *instance = calloc(1, sizeof(hid_wiiu_gca_instance_t));
|
||||||
if(instance == NULL) goto error;
|
if(instance == NULL)
|
||||||
memset(instance, 0, sizeof(wiiu_gca_instance_t));
|
return NULL;
|
||||||
|
memset(instance, 0, sizeof(hid_wiiu_gca_instance_t));
|
||||||
instance->handle = handle;
|
instance->handle = handle;
|
||||||
|
|
||||||
hid_instance.os_driver->send_control(handle, activation_packet, sizeof(activation_packet));
|
hid_instance.os_driver->send_control(handle, activation_packet, sizeof(activation_packet));
|
||||||
|
@ -71,15 +73,17 @@ static void *wiiu_gca_init(void *handle)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wiiu_gca_free(void *data) {
|
static void wiiu_gca_free(void *data)
|
||||||
wiiu_gca_instance_t *instance = (wiiu_gca_instance_t *)data;
|
{
|
||||||
|
hid_wiiu_gca_instance_t *instance = (hid_wiiu_gca_instance_t *)data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(instance) {
|
if(instance)
|
||||||
|
{
|
||||||
instance->online = false;
|
instance->online = false;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
unregister_pad(instance, i);
|
wiiu_gca_unregister_pad(instance, i);
|
||||||
|
|
||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +91,7 @@ static void wiiu_gca_free(void *data) {
|
||||||
|
|
||||||
static void wiiu_gca_handle_packet(void *data, uint8_t *buffer, size_t size)
|
static void wiiu_gca_handle_packet(void *data, uint8_t *buffer, size_t size)
|
||||||
{
|
{
|
||||||
wiiu_gca_instance_t *instance = (wiiu_gca_instance_t *)data;
|
hid_wiiu_gca_instance_t *instance = (hid_wiiu_gca_instance_t *)data;
|
||||||
if(!instance || !instance->online)
|
if(!instance || !instance->online)
|
||||||
{
|
{
|
||||||
RARCH_WARN("[gca]: instance null or not ready yet.\n");
|
RARCH_WARN("[gca]: instance null or not ready yet.\n");
|
||||||
|
@ -102,10 +106,10 @@ static void wiiu_gca_handle_packet(void *data, uint8_t *buffer, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(instance->device_state, buffer, size);
|
memcpy(instance->device_state, buffer, size);
|
||||||
update_pad_state(instance);
|
wiiu_gca_update_pad_state(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_pad_state(wiiu_gca_instance_t *instance)
|
static void wiiu_gca_update_pad_state(hid_wiiu_gca_instance_t *instance)
|
||||||
{
|
{
|
||||||
int i, port;
|
int i, port;
|
||||||
unsigned char port_connected;
|
unsigned char port_connected;
|
||||||
|
@ -114,6 +118,7 @@ static void update_pad_state(wiiu_gca_instance_t *instance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
joypad_connection_t *pad;
|
joypad_connection_t *pad;
|
||||||
|
|
||||||
/* process each pad */
|
/* process each pad */
|
||||||
for (i = 1; i < 37; i += 9)
|
for (i = 1; i < 37; i += 9)
|
||||||
{
|
{
|
||||||
|
@ -140,13 +145,13 @@ static void update_pad_state(wiiu_gca_instance_t *instance)
|
||||||
} else {
|
} else {
|
||||||
if(pad != NULL) {
|
if(pad != NULL) {
|
||||||
RARCH_LOG("[gca]: Gamepad at port %d disconnected.\n", port+1);
|
RARCH_LOG("[gca]: Gamepad at port %d disconnected.\n", port+1);
|
||||||
unregister_pad(instance, port);
|
wiiu_gca_unregister_pad(instance, port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unregister_pad(wiiu_gca_instance_t *instance, int slot)
|
static void wiiu_gca_unregister_pad(hid_wiiu_gca_instance_t *instance, int slot)
|
||||||
{
|
{
|
||||||
if(!instance || slot < 0 || slot >= 4 || instance->pads[slot] == NULL)
|
if(!instance || slot < 0 || slot >= 4 || instance->pads[slot] == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
#include "../include/gamepad.h"
|
#include "../include/gamepad.h"
|
||||||
|
|
||||||
enum pad_axes {
|
enum gamepad_pad_axes
|
||||||
|
{
|
||||||
AXIS_LEFT_ANALOG_X,
|
AXIS_LEFT_ANALOG_X,
|
||||||
AXIS_LEFT_ANALOG_Y,
|
AXIS_LEFT_ANALOG_Y,
|
||||||
AXIS_RIGHT_ANALOG_X,
|
AXIS_RIGHT_ANALOG_X,
|
||||||
|
@ -24,7 +25,7 @@ enum pad_axes {
|
||||||
AXIS_INVALID
|
AXIS_INVALID
|
||||||
};
|
};
|
||||||
|
|
||||||
static int16_t clamp_axis(int16_t value, bool is_negative)
|
static int16_t gamepad_clamp_axis(int16_t value, bool is_negative)
|
||||||
{
|
{
|
||||||
if (is_negative && value > 0)
|
if (is_negative && value > 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -72,5 +73,5 @@ int16_t gamepad_get_axis_value(int16_t state[3][2], axis_data *data)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return clamp_axis(value, data->is_negative);
|
return gamepad_clamp_axis(value, data->is_negative);
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ static void wiiu_hid_free(const void *data)
|
||||||
static void wiiu_hid_poll(void *data)
|
static void wiiu_hid_poll(void *data)
|
||||||
{
|
{
|
||||||
wiiu_hid_t *hid = (wiiu_hid_t *)data;
|
wiiu_hid_t *hid = (wiiu_hid_t *)data;
|
||||||
if(hid == NULL)
|
if (!hid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
synchronized_process_adapters(hid);
|
synchronized_process_adapters(hid);
|
||||||
|
@ -159,7 +159,8 @@ static void wiiu_hid_send_control(void *data, uint8_t *buf, size_t size)
|
||||||
wiiu_adapter_t *adapter = (wiiu_adapter_t *)data;
|
wiiu_adapter_t *adapter = (wiiu_adapter_t *)data;
|
||||||
int32_t result;
|
int32_t result;
|
||||||
|
|
||||||
if (!adapter) {
|
if (!adapter)
|
||||||
|
{
|
||||||
RARCH_ERR("[hid]: send_control: bad adapter.\n");
|
RARCH_ERR("[hid]: send_control: bad adapter.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +294,8 @@ static void stop_polling_thread(wiiu_hid_t *hid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Unregister our HID client so we don't get any new events. */
|
/* Unregister our HID client so we don't get any new events. */
|
||||||
if(hid->client) {
|
if (hid->client)
|
||||||
|
{
|
||||||
HIDDelClient(hid->client);
|
HIDDelClient(hid->client);
|
||||||
hid->client = NULL;
|
hid->client = NULL;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +331,8 @@ static void log_device(HIDDevice *device)
|
||||||
static uint8_t try_init_driver(wiiu_adapter_t *adapter)
|
static uint8_t try_init_driver(wiiu_adapter_t *adapter)
|
||||||
{
|
{
|
||||||
adapter->driver_handle = adapter->driver->init(adapter);
|
adapter->driver_handle = adapter->driver->init(adapter);
|
||||||
if(adapter->driver_handle == NULL) {
|
if (adapter->driver_handle == NULL)
|
||||||
|
{
|
||||||
RARCH_ERR("[hid]: Failed to initialize driver: %s\n",
|
RARCH_ERR("[hid]: Failed to initialize driver: %s\n",
|
||||||
adapter->driver->name);
|
adapter->driver->name);
|
||||||
return ADAPTER_STATE_DONE;
|
return ADAPTER_STATE_DONE;
|
||||||
|
@ -345,6 +348,7 @@ static void synchronized_process_adapters(wiiu_hid_t *hid)
|
||||||
bool keep_prev = false;
|
bool keep_prev = false;
|
||||||
|
|
||||||
OSFastMutex_Lock(&(adapters.lock));
|
OSFastMutex_Lock(&(adapters.lock));
|
||||||
|
|
||||||
for (adapter = adapters.list; adapter != NULL; adapter = adapter_next)
|
for (adapter = adapters.list; adapter != NULL; adapter = adapter_next)
|
||||||
{
|
{
|
||||||
adapter_next = adapter->next;
|
adapter_next = adapter->next;
|
||||||
|
@ -360,7 +364,7 @@ static void synchronized_process_adapters(wiiu_hid_t *hid)
|
||||||
break;
|
break;
|
||||||
case ADAPTER_STATE_GC:
|
case ADAPTER_STATE_GC:
|
||||||
/* remove from the list */
|
/* remove from the list */
|
||||||
if(prev == NULL)
|
if (!prev)
|
||||||
adapters.list = adapter->next;
|
adapters.list = adapter->next;
|
||||||
else
|
else
|
||||||
prev->next = adapter->next;
|
prev->next = adapter->next;
|
||||||
|
@ -423,10 +427,13 @@ static int32_t wiiu_attach_callback(HIDClient *client,
|
||||||
{
|
{
|
||||||
wiiu_attach_event *event = NULL;
|
wiiu_attach_event *event = NULL;
|
||||||
|
|
||||||
if(attach) {
|
if (attach)
|
||||||
|
{
|
||||||
RARCH_LOG("[hid]: Device attach event generated.\n");
|
RARCH_LOG("[hid]: Device attach event generated.\n");
|
||||||
log_device(device);
|
log_device(device);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
RARCH_LOG("[hid]: Device detach event generated.\n");
|
RARCH_LOG("[hid]: Device detach event generated.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,10 +501,12 @@ static void wiiu_hid_read_loop_callback(uint32_t handle, int32_t error,
|
||||||
report_hid_error("async read failed", adapter, error);
|
report_hid_error("async read failed", adapter, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(adapter->state == ADAPTER_STATE_READING) {
|
if (adapter->state == ADAPTER_STATE_READING)
|
||||||
|
{
|
||||||
adapter->state = ADAPTER_STATE_READY;
|
adapter->state = ADAPTER_STATE_READY;
|
||||||
|
|
||||||
if(error == 0) {
|
if (error == 0)
|
||||||
|
{
|
||||||
adapter->driver->handle_packet(adapter->driver_handle,
|
adapter->driver->handle_packet(adapter->driver_handle,
|
||||||
buffer, buffer_size);
|
buffer, buffer_size);
|
||||||
}
|
}
|
||||||
|
@ -622,7 +631,8 @@ static void wiiu_handle_attach_events(wiiu_hid_t *hid, wiiu_attach_event *list)
|
||||||
|
|
||||||
static void wiiu_poll_adapter(wiiu_adapter_t *adapter)
|
static void wiiu_poll_adapter(wiiu_adapter_t *adapter)
|
||||||
{
|
{
|
||||||
if(!adapter->connected) {
|
if (!adapter->connected)
|
||||||
|
{
|
||||||
adapter->state = ADAPTER_STATE_DONE;
|
adapter->state = ADAPTER_STATE_DONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue