From 7ed3ca7f979c942f72049de362730939c7c64a20 Mon Sep 17 00:00:00 2001 From: Nathan Strong Date: Sat, 9 Oct 2021 22:27:09 -0700 Subject: [PATCH 1/3] WIP commit Start trying to adapt the linux DS3 driver instead of our hacked-together support. --- input/connect/connect_ps3.c | 299 ++++++++++++------------------------ 1 file changed, 95 insertions(+), 204 deletions(-) diff --git a/input/connect/connect_ps3.c b/input/connect/connect_ps3.c index 16f52d8647..73d4fa0c2e 100644 --- a/input/connect/connect_ps3.c +++ b/input/connect/connect_ps3.c @@ -23,8 +23,8 @@ #include "../input_defines.h" #include "verbosity.h" -#define DS3_ACTIVATION_REPORT_ID 0xf4 -#define DS3_RUMBLE_REPORT_ID 0x01 +#define SIXAXIS_REPORT_0xF2_SIZE 17 +#define SIXAXIS_REPORT_0xF5_SIZE 8 typedef struct ds3_instance { @@ -36,249 +36,140 @@ typedef struct ds3_instance int16_t analog_state[3][2]; uint16_t motors[2]; uint8_t data[64]; + uint8_t led_state[4]; } ds3_instance_t; -static void ds3_update_pad_state(ds3_instance_t *instance); -static void ds3_update_analog_state(ds3_instance_t *instance); +struct sixaxis_led { + uint8_t time_enabled; /* the total time the led is active (0xff means forever) */ + uint8_t duty_length; /* how long a cycle is in deciseconds (0 means "really fast") */ + uint8_t enabled; + uint8_t duty_off; /* % of duty_length the led is off (0xff means 100%) */ + uint8_t duty_on; /* % of duty_length the led is on (0xff mean 100%) */ +} __packed; -static uint8_t ds3_activation_packet[] = -{ -#if defined(IOS) - 0x53, 0xF4, -#elif defined(HAVE_WIIUSB_HID) - 0x02, -#endif - 0x42, 0x0c, 0x00, 0x00 +struct sixaxis_rumble { + uint8_t padding; + uint8_t right_duration; /* Right motor duration (0xff means forever) */ + uint8_t right_motor_on; /* Right (small) motor on/off, only supports values of 0 or 1 (off/on) */ + uint8_t left_duration; /* Left motor duration (0xff means forever) */ + uint8_t left_motor_force; /* left (large) motor, supports force values from 0 to 255 */ +} __packed; + +struct sixaxis_output_report { + uint8_t report_id; + struct sixaxis_rumble rumble; + uint8_t padding[4]; + uint8_t leds_bitmap; /* bitmap of enabled LEDs: LED_1 = 0x02, LED_2 = 0x04, ... */ + struct sixaxis_led led[4]; /* LEDx at (4 - x) */ + struct sixaxis_led _reserved; /* LED5, not actually soldered */ +} __packed; + +union sixaxis_output_report_01 { + struct sixaxis_output_report data; + uint8_t buf[36]; }; -#if defined(WIIU) -#define PACKET_OFFSET 2 -#elif defined(HAVE_WIIUSB_HID) -#define PACKET_OFFSET 1 -#else -#define PACKET_OFFSET 0 -#endif - -#define LED_OFFSET 11 -#define MOTOR1_OFFSET 4 -#define MOTOR2_OFFSET 6 - -static uint8_t ds3_control_packet[] = { - 0x52, 0x01, - 0x00, 0xff, 0x00, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00 +static const union sixaxis_output_report_01 default_report = { + .buf = { + 0x01, + 0x01, 0xff, 0x00, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0x27, 0x10, 0x00, 0x32, + 0xff, 0x27, 0x10, 0x00, 0x32, + 0xff, 0x27, 0x10, 0x00, 0x32, + 0xff, 0x27, 0x10, 0x00, 0x32, + 0x00, 0x00, 0x00, 0x00, 0x00 + } }; +/* forward declarations */ +static void set_leds_from_id(ds3_instance_t *instance); +static int ds3_set_operational(ds3_instance_t *instance); -static int32_t ds3_send_control_packet( - void *data, uint32_t slot, hid_driver_t *driver) -{ - int32_t result = 0; - uint8_t packet_buffer[64] = {0}; - memcpy(packet_buffer, ds3_control_packet, sizeof(ds3_control_packet)); - - packet_buffer[LED_OFFSET] = 0; - packet_buffer[LED_OFFSET] = 1 << ((slot % 4) + 1); - packet_buffer[MOTOR1_OFFSET] = 0; - packet_buffer[MOTOR2_OFFSET] = 0; - -#if defined(HAVE_WIIUSB_HID) - packet_buffer[1] = 0x03; -#endif - -#if defined(WIIU) - result = driver->set_report(data, HID_REPORT_OUTPUT, DS3_RUMBLE_REPORT_ID, packet_buffer+PACKET_OFFSET, 64-PACKET_OFFSET); -#else - driver->send_control(data, packet_buffer+PACKET_OFFSET, 64-PACKET_OFFSET); -#endif /* WIIU */ - return result; -} - -static int32_t ds3_send_activation_packet(void *data, - uint32_t slot, hid_driver_t *driver) -{ -#ifdef WIIU - return driver->set_report(data, HID_REPORT_FEATURE, DS3_ACTIVATION_REPORT_ID, ds3_activation_packet, sizeof(ds3_activation_packet)); -#else - driver->send_control(data, ds3_activation_packet, sizeof(ds3_activation_packet)); - return 0; -#endif -} - -static void *ds3_pad_init(void *data, uint32_t slot, hid_driver_t *driver) -{ - int errors = 0; - ds3_instance_t *instance = (ds3_instance_t *)calloc(1, sizeof(ds3_instance_t)); - - if(driver->set_protocol) { - driver->set_protocol(data, 1); +static void *ds3_init(void *handle, uint32_t slot, hid_driver_t *driver) { + ds3_instance_t *instance = (ds3_instance_t *)malloc(sizeof(ds3_instance_t)); + if(!instance) { + return NULL; } - if (ds3_send_control_packet(data, slot, driver) < 0) - errors++; - - /* Sending activation packet.. */ - if (ds3_send_activation_packet(data, slot, driver) < 0) - errors++; - - if (errors) - goto error; - + instance->handle = handle; instance->hid_driver = driver; - instance->handle = data; - instance->slot = slot; - instance->led_set = true; + instance->slot = slot; + set_leds_from_id(instance); - return instance; -error: - free(instance); - return NULL; } -static void ds3_pad_deinit(void *data) -{ - ds3_instance_t *pad = (ds3_instance_t *)data; - if (pad) - free(pad); +static void ds3_deinit(void *device_data) { + } -static void ds3_get_buttons(void *data, input_bits_t *state) -{ - ds3_instance_t *pad = (ds3_instance_t *)data; +static void ds3_packet_handler(void *device_data, uint8_t *packet, uint16_t size) { - if (pad) - { - BITS_COPY16_PTR(state, pad->buttons); - - if (pad->buttons & 0x10000) - BIT256_SET_PTR(state, RARCH_MENU_TOGGLE); - } - else - { - BIT256_CLEAR_ALL_PTR(state); - } } -static void ds3_packet_handler(void *data, - uint8_t *packet, uint16_t size) -{ - ds3_instance_t *instance = (ds3_instance_t *)data; - if(!instance) - return; +static void ds3_set_rumble(void *device_data, enum retro_rumble_effect effect, uint16_t strength) { - if (!instance->led_set) - { - ds3_send_control_packet(instance->handle, - instance->slot, instance->hid_driver); - instance->led_set = true; - } - - if (size > sizeof(instance->data)) - { - RARCH_ERR("[ds3]: Expecting packet to be %ld but was %d\n", - (long)sizeof(instance->data), size); - return; - } - - memcpy(instance->data, packet, size); - ds3_update_pad_state(instance); - ds3_update_analog_state(instance); } -const char * ds3_get_name(void *data) -{ - (void)data; - /* For now we return a single static name */ - return "PLAYSTATION(R)3 Controller"; +static void ds3_get_buttons(void *device_data, input_bits_t *state) { + } -static void ds3_set_rumble(void *data, - enum retro_rumble_effect effect, uint16_t strength) { } - -static int16_t ds3_get_axis(void *data, unsigned axis) -{ - axis_data axis_data; - ds3_instance_t *pad = (ds3_instance_t *)data; - - gamepad_read_axis_data(axis, &axis_data); - - if (!pad || axis_data.axis >= 4) - return 0; - - return gamepad_get_axis_value(pad->analog_state, &axis_data); +static int16_t ds3_get_axis(void *device_data, unsigned axis) { + return 0; } -static int32_t ds3_button(void *data, uint16_t joykey) -{ - ds3_instance_t *pad = (ds3_instance_t *)data; - if (!pad || joykey > 31) - return 0; - return pad->buttons & (1 << joykey); +static const char *ds3_get_name(void *device_data) { + return "PLAYSTATION(R)3 Controller"; } -static void ds3_update_pad_state(ds3_instance_t *instance) -{ - uint32_t i, pressed_keys; +static int32_t ds3_button(void *device_data, uint16_t joykey) { + return 0; +} - static const uint32_t button_mapping[17] = - { - RETRO_DEVICE_ID_JOYPAD_SELECT, - RETRO_DEVICE_ID_JOYPAD_L3, - RETRO_DEVICE_ID_JOYPAD_R3, - RETRO_DEVICE_ID_JOYPAD_START, - RETRO_DEVICE_ID_JOYPAD_UP, - RETRO_DEVICE_ID_JOYPAD_RIGHT, - RETRO_DEVICE_ID_JOYPAD_DOWN, - RETRO_DEVICE_ID_JOYPAD_LEFT, - RETRO_DEVICE_ID_JOYPAD_L2, - RETRO_DEVICE_ID_JOYPAD_R2, - RETRO_DEVICE_ID_JOYPAD_L, - RETRO_DEVICE_ID_JOYPAD_R, - RETRO_DEVICE_ID_JOYPAD_X, - RETRO_DEVICE_ID_JOYPAD_A, - RETRO_DEVICE_ID_JOYPAD_B, - RETRO_DEVICE_ID_JOYPAD_Y, - 16 /* PS button */ +static void set_leds_from_id(ds3_instance_t *instance) +{ + /* for pads 0-3, we just light up the appropriate LED. */ + /* for higher pads, we sum up the numbers on the LEDs */ + /* themselves, so e.g. pad 5 is 4 + 1, pad 6 is 4 + 2, */ + /* and so on. We max out at 10 because 4+3+2+1 = 10 */ + static const u8 sixaxis_leds[10][4] = { + { 0x01, 0x00, 0x00, 0x00 }, + { 0x00, 0x01, 0x00, 0x00 }, + { 0x00, 0x00, 0x01, 0x00 }, + { 0x00, 0x00, 0x00, 0x01 }, + { 0x01, 0x00, 0x00, 0x01 }, + { 0x00, 0x01, 0x00, 0x01 }, + { 0x00, 0x00, 0x01, 0x01 }, + { 0x01, 0x00, 0x01, 0x01 }, + { 0x00, 0x01, 0x01, 0x01 }, + { 0x01, 0x01, 0x01, 0x01 } }; - instance->buttons = 0; + int id = instance->slot; - pressed_keys = instance->data[2] | - (instance->data[3] << 8) | - ((instance->data[4] & 0x01) << 16); + if (id < 0) + return; - for (i = 0; i < 17; i++) - instance->buttons |= (pressed_keys & (1 << i)) ? - (1 << button_mapping[i]) : 0; + id %= 10; + memcpy(instance->led_state, sixaxis_leds[id], sizeof(sixaxis_leds[id])); } -static void ds3_update_analog_state(ds3_instance_t *instance) -{ - int pad_axis; - int16_t interpolated; - unsigned stick, axis; +static int ds3_set_operational(ds3_instance_t *instance) { + const int buf_size = SIXAXIS_REPORT_0xF2_SIZE; + uint8_t *buf = (uint8_t *)malloc(buf_size); - for (pad_axis = 0; pad_axis < 4; pad_axis++) - { - axis = pad_axis % 2 ? 0 : 1; - stick = pad_axis / 2; - interpolated = instance->data[6+pad_axis]; - instance->analog_state[stick][axis] = (interpolated - 128) * 256; + if(!buf) { + return -1; } + + instance->hid_driver->send_control(instance->handle,); } pad_connection_interface_t pad_connection_ps3 = { - ds3_pad_init, - ds3_pad_deinit, + ds3_init, + ds3_deinit, ds3_packet_handler, ds3_set_rumble, ds3_get_buttons, From 729c219f1acf7c5c671014d08dbae462e885ddc5 Mon Sep 17 00:00:00 2001 From: Nathan Strong Date: Fri, 15 Oct 2021 16:02:34 -0700 Subject: [PATCH 2/3] Rewrite DS3 driver == DETAILS The DS3 driver previously only worked with the Wii U HID implementation. I adapted this driver from the Linux driver for the DS3. It's not quite 100%--I haven't got the LEDs to work properly--but it's functional. Going to continue tweaking it to see if I can get the LEDs to work. --- input/common/input_hid_common.c | 16 ++- input/connect/connect_ps3.c | 187 +++++++++++++++++++++++++-- input/connect/joypad_connection.c | 5 +- input/drivers_hid/iohidmanager_hid.c | 53 +++++++- input/drivers_hid/wiiu_hid.c | 27 ++++ input/include/gamepad.h | 2 +- input/include/hid_driver.h | 5 +- 7 files changed, 273 insertions(+), 22 deletions(-) diff --git a/input/common/input_hid_common.c b/input/common/input_hid_common.c index 18a7669bb4..64780d307b 100644 --- a/input/common/input_hid_common.c +++ b/input/common/input_hid_common.c @@ -43,6 +43,11 @@ void gamepad_read_axis_data(uint32_t axis, axis_data *data) } int16_t gamepad_get_axis_value(int16_t state[3][2], axis_data *data) +{ + return gamepad_get_axis_value_raw(state, data, true); +} + +int16_t gamepad_get_axis_value_raw(int16_t state[3][2], axis_data *data, bool do_clamp) { int16_t value = 0; @@ -64,11 +69,12 @@ int16_t gamepad_get_axis_value(int16_t state[3][2], axis_data *data) value = state[RETRO_DEVICE_INDEX_ANALOG_RIGHT][0]; break; } - - if (data->is_negative && value > 0) - return 0; - if (!data->is_negative && value < 0) - return 0; + if(do_clamp) { + if (data->is_negative && value > 0) + return 0; + if (!data->is_negative && value < 0) + return 0; + } return value; } diff --git a/input/connect/connect_ps3.c b/input/connect/connect_ps3.c index 73d4fa0c2e..83b02c84f2 100644 --- a/input/connect/connect_ps3.c +++ b/input/connect/connect_ps3.c @@ -39,30 +39,30 @@ typedef struct ds3_instance uint8_t led_state[4]; } ds3_instance_t; -struct sixaxis_led { +struct __attribute__((__packed__)) sixaxis_led { uint8_t time_enabled; /* the total time the led is active (0xff means forever) */ uint8_t duty_length; /* how long a cycle is in deciseconds (0 means "really fast") */ uint8_t enabled; uint8_t duty_off; /* % of duty_length the led is off (0xff means 100%) */ uint8_t duty_on; /* % of duty_length the led is on (0xff mean 100%) */ -} __packed; +}; -struct sixaxis_rumble { +struct __attribute__((__packed__)) sixaxis_rumble { uint8_t padding; uint8_t right_duration; /* Right motor duration (0xff means forever) */ uint8_t right_motor_on; /* Right (small) motor on/off, only supports values of 0 or 1 (off/on) */ uint8_t left_duration; /* Left motor duration (0xff means forever) */ uint8_t left_motor_force; /* left (large) motor, supports force values from 0 to 255 */ -} __packed; +}; -struct sixaxis_output_report { +struct __attribute__((__packed__)) sixaxis_output_report { uint8_t report_id; struct sixaxis_rumble rumble; uint8_t padding[4]; uint8_t leds_bitmap; /* bitmap of enabled LEDs: LED_1 = 0x02, LED_2 = 0x04, ... */ struct sixaxis_led led[4]; /* LEDx at (4 - x) */ struct sixaxis_led _reserved; /* LED5, not actually soldered */ -} __packed; +}; union sixaxis_output_report_01 { struct sixaxis_output_report data; @@ -85,9 +85,13 @@ static const union sixaxis_output_report_01 default_report = { /* forward declarations */ static void set_leds_from_id(ds3_instance_t *instance); static int ds3_set_operational(ds3_instance_t *instance); +static int ds3_send_output_report(ds3_instance_t *instance); +static void ds3_update_pad_state(ds3_instance_t *instance); +static void ds3_update_analog_state(ds3_instance_t *instance); static void *ds3_init(void *handle, uint32_t slot, hid_driver_t *driver) { ds3_instance_t *instance = (ds3_instance_t *)malloc(sizeof(ds3_instance_t)); + int ret; if(!instance) { return NULL; } @@ -97,15 +101,56 @@ static void *ds3_init(void *handle, uint32_t slot, hid_driver_t *driver) { instance->slot = slot; set_leds_from_id(instance); + if((ret = ds3_set_operational(instance)) < 0) { + RARCH_LOG("Failed to set operational mode\n"); + goto error; + } + if((ret = ds3_send_output_report(instance)) < 0) { + RARCH_LOG("Failed to send output report\n"); + goto error; + } + return instance; +error: + free(instance); + return NULL; } static void ds3_deinit(void *device_data) { - + if(device_data) { + free(device_data); + } } static void ds3_packet_handler(void *device_data, uint8_t *packet, uint16_t size) { + ds3_instance_t *device = (ds3_instance_t *)device_data; + static long packet_count = 0; + if(!device) + return; + + if (!device->led_set) + { + ds3_send_output_report(device); + device->led_set = true; + } + + if (size > sizeof(device->data)) + { + RARCH_ERR("[ds3]: Expecting packet to be %ld but was %d\n", + (long)sizeof(device->data), size); + return; + } + packet_count++; + +#if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER) + packet++; + size -= 2; +#endif + + memcpy(device->data, packet, size); + ds3_update_pad_state(device); + ds3_update_analog_state(device); } static void ds3_set_rumble(void *device_data, enum retro_rumble_effect effect, uint16_t strength) { @@ -113,11 +158,35 @@ static void ds3_set_rumble(void *device_data, enum retro_rumble_effect effect, u } static void ds3_get_buttons(void *device_data, input_bits_t *state) { - + ds3_instance_t *device = (ds3_instance_t *)device_data; + if (device) + { + /* copy 32 bits : needed for PS button? */ + BITS_COPY32_PTR(state, device->buttons); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t ds3_get_axis(void *device_data, unsigned axis) { - return 0; + union joyaxis { + uint32_t encoded; + int16_t axis[2]; + } joyaxis; + axis_data axis_data = {0}; + ds3_instance_t *device = (ds3_instance_t *)device_data; + + joyaxis.encoded = axis; + gamepad_read_axis_data(axis, &axis_data); + + if (!device || axis_data.axis >= 4) + return 0; + + if(joyaxis.axis[0] < 0 || joyaxis.axis[1] < 0) { + return gamepad_get_axis_value(device->analog_state, &axis_data); + } else { + return gamepad_get_axis_value_raw(device->analog_state, &axis_data, false); + } } static const char *ds3_get_name(void *device_data) { @@ -125,7 +194,11 @@ static const char *ds3_get_name(void *device_data) { } static int32_t ds3_button(void *device_data, uint16_t joykey) { - return 0; + ds3_instance_t *device = (ds3_instance_t *)device_data; + + if (!device || joykey > 31) + return 0; + return device->buttons & (1 << joykey); } static void set_leds_from_id(ds3_instance_t *instance) @@ -134,7 +207,7 @@ static void set_leds_from_id(ds3_instance_t *instance) /* for higher pads, we sum up the numbers on the LEDs */ /* themselves, so e.g. pad 5 is 4 + 1, pad 6 is 4 + 2, */ /* and so on. We max out at 10 because 4+3+2+1 = 10 */ - static const u8 sixaxis_leds[10][4] = { + static const uint8_t sixaxis_leds[10][4] = { { 0x01, 0x00, 0x00, 0x00 }, { 0x00, 0x01, 0x00, 0x00 }, { 0x00, 0x00, 0x01, 0x00 }, @@ -159,12 +232,102 @@ static void set_leds_from_id(ds3_instance_t *instance) static int ds3_set_operational(ds3_instance_t *instance) { const int buf_size = SIXAXIS_REPORT_0xF2_SIZE; uint8_t *buf = (uint8_t *)malloc(buf_size); + int ret; if(!buf) { return -1; } - instance->hid_driver->send_control(instance->handle,); + ret = instance->hid_driver->get_report(instance->handle, HID_REPORT_FEATURE, 0xf2, buf, SIXAXIS_REPORT_0xF2_SIZE); + if(ret < 0) { + RARCH_LOG("Failed to set operational mode step 1\n"); + goto out; + } + + ret = instance->hid_driver->get_report(instance->handle, HID_REPORT_FEATURE, 0xf5, buf, SIXAXIS_REPORT_0xF5_SIZE); + if(ret < 0) { + RARCH_LOG("Failed to set operational mode step 2\n"); + goto out; + } + + ret = instance->hid_driver->set_report(instance->handle, HID_REPORT_OUTPUT, buf[0], buf, 1); + if(ret < 0) { + RARCH_LOG("Failed to set operational mode step 3, ignoring\n"); + ret = 0; + } +out: + free(buf); + return ret; +} + +static int ds3_send_output_report(ds3_instance_t *instance) { + struct sixaxis_output_report report = {0}; + int n; + + /* Initialize the report with default values */ + memcpy(&report, &default_report, sizeof(struct sixaxis_output_report)); + report.leds_bitmap |= instance->led_state[0] << 1; + report.leds_bitmap |= instance->led_state[1] << 2; + report.leds_bitmap |= instance->led_state[2] << 3; + report.leds_bitmap |= instance->led_state[3] << 4; + + return instance->hid_driver->set_report(instance->handle, HID_REPORT_OUTPUT, report.report_id, (uint8_t *)&report, sizeof(report)); +} + +static void ds3_update_pad_state(ds3_instance_t *instance) +{ + uint32_t i, pressed_keys; + + static const uint32_t button_mapping[17] = + { + RETRO_DEVICE_ID_JOYPAD_SELECT, + RETRO_DEVICE_ID_JOYPAD_L3, + RETRO_DEVICE_ID_JOYPAD_R3, + RETRO_DEVICE_ID_JOYPAD_START, + RETRO_DEVICE_ID_JOYPAD_UP, + RETRO_DEVICE_ID_JOYPAD_RIGHT, + RETRO_DEVICE_ID_JOYPAD_DOWN, + RETRO_DEVICE_ID_JOYPAD_LEFT, + RETRO_DEVICE_ID_JOYPAD_L2, + RETRO_DEVICE_ID_JOYPAD_R2, + RETRO_DEVICE_ID_JOYPAD_L, + RETRO_DEVICE_ID_JOYPAD_R, + RETRO_DEVICE_ID_JOYPAD_X, + RETRO_DEVICE_ID_JOYPAD_A, + RETRO_DEVICE_ID_JOYPAD_B, + RETRO_DEVICE_ID_JOYPAD_Y, + 16 /* PS button */ + }; + + instance->buttons = 0; + + pressed_keys = instance->data[2] | + (instance->data[3] << 8) | + ((instance->data[4] & 0x01) << 16); + + for (i = 0; i < 17; i++) + instance->buttons |= (pressed_keys & (1 << i)) ? + (1 << button_mapping[i]) : 0; +} + +static void ds3_update_analog_state(ds3_instance_t *instance) +{ + int pad_axis; + int16_t interpolated; + unsigned stick, axis; + + for (pad_axis = 0; pad_axis < 4; pad_axis++) + { + axis = (pad_axis % 2) ? 0 : 1; + stick = pad_axis / 2; + interpolated = instance->data[6 + pad_axis]; + + /* libretro requires "up" to be negative, so we invert the y axis */ + interpolated = (axis) ? + ((interpolated - 128) * 256) : + ((interpolated - 128) * -256); + instance->analog_state[stick][axis] = interpolated; + } } pad_connection_interface_t pad_connection_ps3 = { diff --git a/input/connect/joypad_connection.c b/input/connect/joypad_connection.c index 37731bb75c..5f42e649c5 100644 --- a/input/connect/joypad_connection.c +++ b/input/connect/joypad_connection.c @@ -406,8 +406,11 @@ void pad_connection_packet(joypad_connection_t *joyconn, uint32_t pad, if ( joyconn->connection && joyconn->iface - && joyconn->iface->packet_handler) + && joyconn->iface->packet_handler) { + joyconn->iface->packet_handler(joyconn->connection, data, length); + + } } void pad_connection_get_buttons(joypad_connection_t *joyconn, diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index 78f68d651e..3fc0602c75 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -59,6 +59,19 @@ struct iohidmanager_hid_adapter uint8_t data[2048]; }; +enum IOHIDReportType translate_hid_report_type(int report_type) { + switch(report_type) { + case HID_REPORT_FEATURE: + return kIOHIDReportTypeFeature; + case HID_REPORT_INPUT: + return kIOHIDReportTypeInput; + case HID_REPORT_OUTPUT: + return kIOHIDReportTypeOutput; + case HID_REPORT_COUNT: + return kIOHIDReportTypeCount; + } +} + CFComparisonResult iohidmanager_sort_elements(const void *val1, const void *val2, void *context) { uint32_t page1 = (uint32_t)IOHIDElementGetUsagePage((IOHIDElementRef)val1); @@ -683,13 +696,15 @@ static void iohidmanager_hid_device_add(IOHIDDeviceRef device, iohidmanager_hid_ if (string_is_empty(adapter->name)) strcpy(adapter->name, "Unknown Controller With No Name"); - if (pad_connection_has_interface(hid->slots, adapter->slot)) + if (pad_connection_has_interface(hid->slots, adapter->slot)) { IOHIDDeviceRegisterInputReportCallback(device, adapter->data + 1, sizeof(adapter->data) - 1, iohidmanager_hid_device_report, adapter); - else + } + else { IOHIDDeviceRegisterInputValueCallback(device, iohidmanager_hid_device_input_callback, adapter); + } /* scan for buttons, axis, hats */ elements_raw = IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone); @@ -1081,6 +1096,35 @@ static void iohidmanager_hid_poll(void *data) (void)data; } +static int32_t iohidmanager_set_report(void *handle, uint8_t report_type, uint8_t report_id, void *data_buf, uint32_t size) +{ + struct iohidmanager_hid_adapter *adapter = + (struct iohidmanager_hid_adapter*)handle; + + int retval = -1; + + if (adapter) { + retval = IOHIDDeviceSetReport(adapter->handle, translate_hid_report_type(report_type), report_type, data_buf + 1, size - 1); + } + + return retval; +} + +static int32_t iohidmanager_get_report(void *handle, uint8_t report_type, uint8_t report_id, void *data_buf, size_t size) +{ + struct iohidmanager_hid_adapter *adapter = + (struct iohidmanager_hid_adapter*)handle; + int retval = -1; + + if (adapter) { + CFIndex length = size; + + retval = IOHIDDeviceGetReport(adapter->handle, translate_hid_report_type(report_type), report_id, data_buf+1, &length); + } + + return retval; +} + hid_driver_t iohidmanager_hid = { iohidmanager_hid_init, iohidmanager_hid_joypad_query, @@ -1094,4 +1138,9 @@ hid_driver_t iohidmanager_hid = { iohidmanager_hid_joypad_name, "iohidmanager", iohidmanager_hid_device_send_control, + iohidmanager_set_report, + iohidmanager_get_report, + NULL, /* set_idle */ + NULL, /* set_protocol */ + NULL /* read */ }; diff --git a/input/drivers_hid/wiiu_hid.c b/input/drivers_hid/wiiu_hid.c index 844cbef651..bf152f27b4 100644 --- a/input/drivers_hid/wiiu_hid.c +++ b/input/drivers_hid/wiiu_hid.c @@ -239,6 +239,23 @@ static int32_t wiiu_hid_set_report(void *data, uint8_t report_type, NULL, NULL); } +static int32_t wiiu_hid_get_report(void *handle, uint8_t report_type, uint8_t report_id, void *data_buf, size_t size) +{ + wiiu_adapter_t *adapter = (wiiu_adapter_t *)handle; + if (!adapter || size > adapter->tx_size) + return -1; + + memset(adapter->tx_buffer, 0, adapter->tx_size); + memcpy(adapter->tx_buffer, data_buf, size); + + return HIDGetReport(adapter->handle, + report_type, + report_id, + adapter->tx_buffer, + adapter->tx_size, + NULL, NULL); +} + static int32_t wiiu_hid_set_idle(void *data, uint8_t duration) { wiiu_adapter_t *adapter = (wiiu_adapter_t *)data; @@ -910,6 +927,15 @@ void *alloc_zeroed(size_t alignment, size_t size) return result; } +/* + void (*send_control)(void *handle, uint8_t *buf, size_t size); + int32_t (*set_report)(void *handle, uint8_t, uint8_t, void *data, uint32_t size); + int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, void *buffer, size_t length); + int32_t (*set_idle)(void *handle, uint8_t amount); + int32_t (*set_protocol)(void *handle, uint8_t protocol); + int32_t (*read)(void *handle, void *buf, size_t size); +*/ + hid_driver_t wiiu_hid = { wiiu_hid_init, wiiu_hid_joypad_query, @@ -924,6 +950,7 @@ hid_driver_t wiiu_hid = { "wiiu", wiiu_hid_send_control, wiiu_hid_set_report, + wiiu_hid_get_report, wiiu_hid_set_idle, wiiu_hid_set_protocol, wiiu_hid_read, diff --git a/input/include/gamepad.h b/input/include/gamepad.h index 802f0b5718..c6170594e7 100644 --- a/input/include/gamepad.h +++ b/input/include/gamepad.h @@ -28,5 +28,5 @@ typedef struct _axis_data void gamepad_read_axis_data(uint32_t axis, axis_data *data); int16_t gamepad_get_axis_value(int16_t state[3][2], axis_data *data); - +int16_t gamepad_get_axis_value_raw(int16_t state[3][2], axis_data *data, bool do_clamp); #endif /* GAMEPAD_H__ */ diff --git a/input/include/hid_driver.h b/input/include/hid_driver.h index 127b477d94..64f21a1acd 100644 --- a/input/include/hid_driver.h +++ b/input/include/hid_driver.h @@ -22,8 +22,10 @@ #include "../input_driver.h" /* what is 1? */ -#define HID_REPORT_OUTPUT 2 +#define HID_REPORT_INPUT 1 +#define HID_REPORT_OUTPUT 2 #define HID_REPORT_FEATURE 3 +#define HID_REPORT_COUNT 4 /* are there more? */ /* @@ -49,6 +51,7 @@ struct hid_driver const char *ident; void (*send_control)(void *handle, uint8_t *buf, size_t size); int32_t (*set_report)(void *handle, uint8_t, uint8_t, void *data, uint32_t size); + int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, void *buffer, size_t length); int32_t (*set_idle)(void *handle, uint8_t amount); int32_t (*set_protocol)(void *handle, uint8_t protocol); int32_t (*read)(void *handle, void *buf, size_t size); From 81c6d3809a7e40132ed52d6665f2aebab63ebdd8 Mon Sep 17 00:00:00 2001 From: Nathan Strong Date: Sat, 16 Oct 2021 14:45:20 -0700 Subject: [PATCH 3/3] Finish up the OSX DS3 driver == DETAILS Put the finishing touches on getting the DS3 to work on Mac OSX. Basically, there's some differences in the HID interface bewtween wiiu and osx where OSX expects the first byte of the report to be the report ID, while wiiu expects that byte to be trimmed off. I was able to put this behavior in the respective HID implementations, which eliminated the confusing packet offset ifdefs. And, I was able to get the LEDs working again. --- input/connect/connect_ps3.c | 140 ++++++++++++++------------- input/connect/joypad_connection.c | 6 ++ input/drivers_hid/iohidmanager_hid.c | 8 +- input/drivers_hid/wiiu_hid.c | 44 +++------ input/include/hid_driver.h | 4 +- 5 files changed, 101 insertions(+), 101 deletions(-) diff --git a/input/connect/connect_ps3.c b/input/connect/connect_ps3.c index 83b02c84f2..2eb37adaf3 100644 --- a/input/connect/connect_ps3.c +++ b/input/connect/connect_ps3.c @@ -23,6 +23,8 @@ #include "../input_defines.h" #include "verbosity.h" +#define DS3_ACTIVATION_REPORT_ID 0xf4 + #define SIXAXIS_REPORT_0xF2_SIZE 17 #define SIXAXIS_REPORT_0xF5_SIZE 8 @@ -36,7 +38,6 @@ typedef struct ds3_instance int16_t analog_state[3][2]; uint16_t motors[2]; uint8_t data[64]; - uint8_t led_state[4]; } ds3_instance_t; struct __attribute__((__packed__)) sixaxis_led { @@ -48,7 +49,6 @@ struct __attribute__((__packed__)) sixaxis_led { }; struct __attribute__((__packed__)) sixaxis_rumble { - uint8_t padding; uint8_t right_duration; /* Right motor duration (0xff means forever) */ uint8_t right_motor_on; /* Right (small) motor on/off, only supports values of 0 or 1 (off/on) */ uint8_t left_duration; /* Left motor duration (0xff means forever) */ @@ -57,33 +57,54 @@ struct __attribute__((__packed__)) sixaxis_rumble { struct __attribute__((__packed__)) sixaxis_output_report { uint8_t report_id; + uint8_t padding1; struct sixaxis_rumble rumble; - uint8_t padding[4]; + uint8_t padding2[4]; uint8_t leds_bitmap; /* bitmap of enabled LEDs: LED_1 = 0x02, LED_2 = 0x04, ... */ struct sixaxis_led led[4]; /* LEDx at (4 - x) */ struct sixaxis_led _reserved; /* LED5, not actually soldered */ + uint8_t unknown[13]; +}; + +struct __attribute__((__packed__)) sixaxis_activation_report { + uint8_t report_id; + uint8_t unknown[4]; +}; + +union sixaxis_activation_report_f4 { + struct sixaxis_activation_report data; + uint8_t buf[5]; }; union sixaxis_output_report_01 { struct sixaxis_output_report data; - uint8_t buf[36]; + uint8_t buf[49]; }; static const union sixaxis_output_report_01 default_report = { .buf = { - 0x01, - 0x01, 0xff, 0x00, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0x00, 0x00, 0x00, 0x00, 0x00 + 0x01, /* report ID */ + 0x00, /* padding */ + 0xff, 0x00, /* right rumble */ + 0xff, 0x00, /* left rumble */ + 0x00, 0x00, 0x00, 0x00, /* padding */ + 0x00, /* LED bitmap */ + 0xff, 0x27, 0x10, 0x00, 0x32, /* LED 1 config */ + 0xff, 0x27, 0x10, 0x00, 0x32, /* LED 2 config */ + 0xff, 0x27, 0x10, 0x00, 0x32, /* LED 3 config */ + 0xff, 0x27, 0x10, 0x00, 0x32, /* LED 4 config */ + 0x00, 0x00, 0x00, 0x00, 0x00, /* LED 5 config (unusable/unsoldered) */ + 0x00, 0x00, 0x00, 0x00, 0x00, /* unknown */ + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00 } }; +static const union sixaxis_activation_report_f4 ds3_activation_packet = { + .buf = { 0xF4, 0x42, 0x0c, 0x00, 0x00 } +}; + /* forward declarations */ -static void set_leds_from_id(ds3_instance_t *instance); static int ds3_set_operational(ds3_instance_t *instance); static int ds3_send_output_report(ds3_instance_t *instance); static void ds3_update_pad_state(ds3_instance_t *instance); @@ -99,16 +120,20 @@ static void *ds3_init(void *handle, uint32_t slot, hid_driver_t *driver) { instance->handle = handle; instance->hid_driver = driver; instance->slot = slot; - set_leds_from_id(instance); + if(instance->hid_driver->set_protocol) { + instance->hid_driver->set_protocol(instance->handle, 1); + } + + if((ret = ds3_send_output_report(instance)) < 0) { + RARCH_LOG("Failed to send output report\n"); + goto error; + } if((ret = ds3_set_operational(instance)) < 0) { RARCH_LOG("Failed to set operational mode\n"); goto error; } - if((ret = ds3_send_output_report(instance)) < 0) { - RARCH_LOG("Failed to send output report\n"); - goto error; - } + return instance; error: @@ -201,36 +226,9 @@ static int32_t ds3_button(void *device_data, uint16_t joykey) { return device->buttons & (1 << joykey); } -static void set_leds_from_id(ds3_instance_t *instance) -{ - /* for pads 0-3, we just light up the appropriate LED. */ - /* for higher pads, we sum up the numbers on the LEDs */ - /* themselves, so e.g. pad 5 is 4 + 1, pad 6 is 4 + 2, */ - /* and so on. We max out at 10 because 4+3+2+1 = 10 */ - static const uint8_t sixaxis_leds[10][4] = { - { 0x01, 0x00, 0x00, 0x00 }, - { 0x00, 0x01, 0x00, 0x00 }, - { 0x00, 0x00, 0x01, 0x00 }, - { 0x00, 0x00, 0x00, 0x01 }, - { 0x01, 0x00, 0x00, 0x01 }, - { 0x00, 0x01, 0x00, 0x01 }, - { 0x00, 0x00, 0x01, 0x01 }, - { 0x01, 0x00, 0x01, 0x01 }, - { 0x00, 0x01, 0x01, 0x01 }, - { 0x01, 0x01, 0x01, 0x01 } - }; - - int id = instance->slot; - - if (id < 0) - return; - - id %= 10; - memcpy(instance->led_state, sixaxis_leds[id], sizeof(sixaxis_leds[id])); -} - static int ds3_set_operational(ds3_instance_t *instance) { const int buf_size = SIXAXIS_REPORT_0xF2_SIZE; + uint8_t *buf = (uint8_t *)malloc(buf_size); int ret; @@ -238,40 +236,48 @@ static int ds3_set_operational(ds3_instance_t *instance) { return -1; } - ret = instance->hid_driver->get_report(instance->handle, HID_REPORT_FEATURE, 0xf2, buf, SIXAXIS_REPORT_0xF2_SIZE); + ret = instance->hid_driver->set_report(instance->handle, HID_REPORT_FEATURE, ds3_activation_packet.data.report_id, ds3_activation_packet.buf, sizeof(ds3_activation_packet)); if(ret < 0) { - RARCH_LOG("Failed to set operational mode step 1\n"); - goto out; + RARCH_LOG("Failed to send activation packet\n"); } - ret = instance->hid_driver->get_report(instance->handle, HID_REPORT_FEATURE, 0xf5, buf, SIXAXIS_REPORT_0xF5_SIZE); - if(ret < 0) { - RARCH_LOG("Failed to set operational mode step 2\n"); - goto out; - } - - ret = instance->hid_driver->set_report(instance->handle, HID_REPORT_OUTPUT, buf[0], buf, 1); - if(ret < 0) { - RARCH_LOG("Failed to set operational mode step 3, ignoring\n"); - ret = 0; - } -out: free(buf); return ret; } +static uint8_t get_leds(unsigned slot) { + unsigned pad_number = slot+1; + switch(pad_number) { + case 1: + case 2: + case 3: + case 4: + return 1 << pad_number; + case 5: + return (1 << 1) | (1 << 4); + case 6: + return (1 << 2) | (1 << 4); + case 7: + return (1 << 3) | (1 << 4); + case 8: + return (1 << 3) | (1 << 1) | (1 << 4); + case 9: + return (1 << 2) | (1 << 3) | (1 << 4); + case 10: + default: + return (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4); + } +} + static int ds3_send_output_report(ds3_instance_t *instance) { struct sixaxis_output_report report = {0}; - int n; + uint8_t *packet = (uint8_t *)&report; /* Initialize the report with default values */ memcpy(&report, &default_report, sizeof(struct sixaxis_output_report)); - report.leds_bitmap |= instance->led_state[0] << 1; - report.leds_bitmap |= instance->led_state[1] << 2; - report.leds_bitmap |= instance->led_state[2] << 3; - report.leds_bitmap |= instance->led_state[3] << 4; + report.leds_bitmap = get_leds(instance->slot); - return instance->hid_driver->set_report(instance->handle, HID_REPORT_OUTPUT, report.report_id, (uint8_t *)&report, sizeof(report)); + return instance->hid_driver->set_report(instance->handle, HID_REPORT_OUTPUT, report.report_id, packet, sizeof(report)); } static void ds3_update_pad_state(ds3_instance_t *instance) diff --git a/input/connect/joypad_connection.c b/input/connect/joypad_connection.c index 5f42e649c5..6c108ed2d4 100644 --- a/input/connect/joypad_connection.c +++ b/input/connect/joypad_connection.c @@ -189,12 +189,17 @@ static int joypad_to_slot(joypad_connection_t *haystack, return -1; } +void release_joypad(joypad_connection_t *joypad) { + +} + void legacy_pad_connection_pad_deregister(joypad_connection_t *pad_list, pad_connection_interface_t *iface, void *pad_data) { int i; for(i = 0; !joypad_is_end_of_list(&pad_list[i]); i++) { if(pad_list[i].connection == pad_data) { input_autoconfigure_disconnect(i, iface->get_name(pad_data)); + memset(&pad_list[i], 0, sizeof(joypad_connection_t)); return; } } @@ -219,6 +224,7 @@ void pad_connection_pad_deregister(joypad_connection_t *joyconn, { input_autoconfigure_disconnect(slot, iface->get_name(joyconn[slot].connection)); iface->pad_deinit(joyconn[slot].connection); + memset(&joyconn[slot], 0, sizeof(joypad_connection_t)); } } } diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index 3fc0602c75..2ad1d33001 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -1096,7 +1096,7 @@ static void iohidmanager_hid_poll(void *data) (void)data; } -static int32_t iohidmanager_set_report(void *handle, uint8_t report_type, uint8_t report_id, void *data_buf, uint32_t size) +static int32_t iohidmanager_set_report(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data_buf, size_t size) { struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)handle; @@ -1104,7 +1104,7 @@ static int32_t iohidmanager_set_report(void *handle, uint8_t report_type, uint8_ int retval = -1; if (adapter) { - retval = IOHIDDeviceSetReport(adapter->handle, translate_hid_report_type(report_type), report_type, data_buf + 1, size - 1); + retval = IOHIDDeviceSetReport(adapter->handle, translate_hid_report_type(report_type), report_type, data_buf, size); } return retval; @@ -1119,7 +1119,7 @@ static int32_t iohidmanager_get_report(void *handle, uint8_t report_type, uint8_ if (adapter) { CFIndex length = size; - retval = IOHIDDeviceGetReport(adapter->handle, translate_hid_report_type(report_type), report_id, data_buf+1, &length); + retval = IOHIDDeviceGetReport(adapter->handle, translate_hid_report_type(report_type), report_id, data_buf, &length); } return retval; @@ -1141,6 +1141,6 @@ hid_driver_t iohidmanager_hid = { iohidmanager_set_report, iohidmanager_get_report, NULL, /* set_idle */ - NULL, /* set_protocol */ + NULL, /* set protocol */ NULL /* read */ }; diff --git a/input/drivers_hid/wiiu_hid.c b/input/drivers_hid/wiiu_hid.c index bf152f27b4..ccb928f6a3 100644 --- a/input/drivers_hid/wiiu_hid.c +++ b/input/drivers_hid/wiiu_hid.c @@ -135,7 +135,7 @@ static bool wiiu_hid_joypad_rumble(void *data, unsigned slot, static void *wiiu_hid_init(void) { - RARCH_LOG("[hid]: initializing HID subsystem\n"); + RARCH_LOG("[hid]: initializing\n"); wiiu_hid_t *hid = new_hid(); HIDClient *client = new_hidclient(); @@ -150,7 +150,6 @@ static void *wiiu_hid_init(void) HIDAddClient(client, wiiu_attach_callback); hid->client = client; - RARCH_LOG("[hid]: init success\n"); return hid; error: @@ -221,13 +220,22 @@ static void wiiu_hid_send_control(void *data, uint8_t *buf, size_t size) } } +static void _fixup_report_buffer(uint8_t **buffer, uint8_t report_id, size_t *length) { + if((*buffer)[0] == report_id) { + *buffer = (*buffer)+ 1; + *length = *length - 1; + } +} + static int32_t wiiu_hid_set_report(void *data, uint8_t report_type, - uint8_t report_id, void *report_data, uint32_t report_length) + uint8_t report_id, uint8_t *report_data, size_t report_length) { wiiu_adapter_t *adapter = (wiiu_adapter_t *)data; if (!adapter || report_length > adapter->tx_size) return -1; + _fixup_report_buffer(&report_data, report_id, &report_length); + memset(adapter->tx_buffer, 0, adapter->tx_size); memcpy(adapter->tx_buffer, report_data, report_length); @@ -239,14 +247,16 @@ static int32_t wiiu_hid_set_report(void *data, uint8_t report_type, NULL, NULL); } -static int32_t wiiu_hid_get_report(void *handle, uint8_t report_type, uint8_t report_id, void *data_buf, size_t size) +static int32_t wiiu_hid_get_report(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *report_data, size_t report_length) { wiiu_adapter_t *adapter = (wiiu_adapter_t *)handle; - if (!adapter || size > adapter->tx_size) + if (!adapter || report_length > adapter->tx_size) return -1; + _fixup_report_buffer(&report_data, report_id, &report_length); + memset(adapter->tx_buffer, 0, adapter->tx_size); - memcpy(adapter->tx_buffer, data_buf, size); + memcpy(adapter->tx_buffer, report_data, report_length); return HIDGetReport(adapter->handle, report_type, @@ -422,7 +432,6 @@ static uint8_t try_init_driver(wiiu_adapter_t *adapter) return ADAPTER_STATE_DONE; } - RARCH_LOG("driver initialized, registering pad\n"); pad_connection_pad_register(joypad_state.pads, adapter->pad_driver, adapter->pad_driver_data, adapter, &hidpad_driver, slot); return ADAPTER_STATE_READY; @@ -454,7 +463,6 @@ static void synchronized_process_adapters(wiiu_hid_t *hid) break; case ADAPTER_STATE_GC: { - RARCH_LOG("ADAPTER_STATE_GC"); /* remove from the list */ if (!prev) adapters.list = adapter->next; @@ -524,13 +532,8 @@ static int32_t wiiu_attach_callback(HIDClient *client, if (attach) { - RARCH_LOG("[hid]: Device attach event generated.\n"); log_device(device); } - else - { - RARCH_LOG("[hid]: Device detach event generated.\n"); - } if (device) event = new_attach_event(device); @@ -788,36 +791,30 @@ static OSThread *new_thread(void) static void wiiu_hid_init_lists(void) { - RARCH_LOG("[hid]: Initializing events list\n"); memset(&events, 0, sizeof(events)); OSFastMutex_Init(&(events.lock), "attach_events"); - RARCH_LOG("[hid]: Initializing adapters list\n"); memset(&adapters, 0, sizeof(adapters)); OSFastMutex_Init(&(adapters.lock), "adapters"); } static wiiu_hid_t *new_hid(void) { - RARCH_LOG("[hid]: new_hid()\n"); return alloc_zeroed(4, sizeof(wiiu_hid_t)); } static void delete_hid(wiiu_hid_t *hid) { - RARCH_LOG("[hid]: delete_hid()\n"); if (hid) free(hid); } static HIDClient *new_hidclient(void) { - RARCH_LOG("[hid]: new_hidclient()\n"); return alloc_zeroed(32, sizeof(HIDClient)); } static void delete_hidclient(HIDClient *client) { - RARCH_LOG("[hid]: delete_hidclient()\n"); if (client) free(client); } @@ -927,15 +924,6 @@ void *alloc_zeroed(size_t alignment, size_t size) return result; } -/* - void (*send_control)(void *handle, uint8_t *buf, size_t size); - int32_t (*set_report)(void *handle, uint8_t, uint8_t, void *data, uint32_t size); - int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, void *buffer, size_t length); - int32_t (*set_idle)(void *handle, uint8_t amount); - int32_t (*set_protocol)(void *handle, uint8_t protocol); - int32_t (*read)(void *handle, void *buf, size_t size); -*/ - hid_driver_t wiiu_hid = { wiiu_hid_init, wiiu_hid_joypad_query, diff --git a/input/include/hid_driver.h b/input/include/hid_driver.h index 64f21a1acd..b6e63dcfc1 100644 --- a/input/include/hid_driver.h +++ b/input/include/hid_driver.h @@ -50,8 +50,8 @@ struct hid_driver const char *(*name)(void *handle, unsigned pad); const char *ident; void (*send_control)(void *handle, uint8_t *buf, size_t size); - int32_t (*set_report)(void *handle, uint8_t, uint8_t, void *data, uint32_t size); - int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, void *buffer, size_t length); + int32_t (*set_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t length); + int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t length); int32_t (*set_idle)(void *handle, uint8_t amount); int32_t (*set_protocol)(void *handle, uint8_t protocol); int32_t (*read)(void *handle, void *buf, size_t size);