diff --git a/input/connect/connect_ps3.c b/input/connect/connect_ps3.c index b87c5e4ea6..55466d0ff8 100644 --- a/input/connect/connect_ps3.c +++ b/input/connect/connect_ps3.c @@ -22,6 +22,10 @@ #include "joypad_connection.h" #include "../input_defines.h" +#ifdef WIIU +#include +#endif + struct hidpad_ps3_data { struct pad_connection* connection; @@ -33,6 +37,13 @@ struct hidpad_ps3_data uint16_t motors[2]; }; +/* + * TODO: give these more meaningful names. + */ + +#define DS3_ACTIVATION_REPORT_ID 0xf4 +#define DS3_RUMBLE_REPORT_ID 0x01 + static void hidpad_ps3_send_control(struct hidpad_ps3_data* device) { /* TODO: Can this be modified to turn off motion tracking? */ @@ -49,12 +60,20 @@ static void hidpad_ps3_send_control(struct hidpad_ps3_data* device) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + // Turn on the appropriate LED report_buffer[11] = 1 << ((device->slot % 4) + 1); + // Set rumble state report_buffer[4] = device->motors[1] >> 8; report_buffer[6] = device->motors[0] >> 8; #ifdef HAVE_WIIUSB_HID report_buffer[1] = 0x03; /* send control message type */ device->driver->send_control(device->connection, &report_buffer[1], sizeof(report_buffer)-1); +#elif defined(WIIU) + device->driver->set_report(device->connection, + HID_REPORT_OUTPUT, + DS3_RUMBLE_REPORT_ID, + report_buffer+2, + sizeof(report_buffer) - (2*sizeof(uint8_t))); #else device->driver->send_control(device->connection, report_buffer, sizeof(report_buffer)); #endif @@ -62,7 +81,7 @@ static void hidpad_ps3_send_control(struct hidpad_ps3_data* device) static void* hidpad_ps3_init(void *data, uint32_t slot, hid_driver_t *driver) { -#ifdef HAVE_WIIUSB_HID +#if defined(HAVE_WIIUSB_HID) || defined(WIIU) /* Special command to enable Sixaxis, first byte defines the message type */ static uint8_t magic_data[] = {0x02, 0x42, 0x0c, 0x00, 0x00}; #elif defined(IOS) @@ -90,6 +109,16 @@ static void* hidpad_ps3_init(void *data, uint32_t slot, hid_driver_t *driver) device->driver->send_control(device->connection, magic_data, sizeof(magic_data)); #endif +#ifdef WIIU + device->driver->set_protocol(device->connection, 1); + hidpad_ps3_send_control(device); + device->driver->set_report(device->connection, + HID_REPORT_FEATURE, + DS3_ACTIVATION_REPORT_ID, + magic_data+1, + (sizeof(magic_data) - sizeof(uint8_t))); +#endif + #ifndef HAVE_WIIUSB_HID /* Without this, the digital buttons won't be reported. */ hidpad_ps3_send_control(device); diff --git a/input/input_driver.h b/input/input_driver.h index 22df4b1c60..28711502aa 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -196,7 +196,7 @@ struct hid_driver void (*send_control)(void *data, uint8_t *buf, size_t size); int32_t (*set_report)(void *, uint8_t, uint8_t, void *, uint32_t); int32_t (*set_idle)(void *, uint8_t, uint8_t); - int32_t (*set_protocol)(void *, uint8_t, uint8_t); + int32_t (*set_protocol)(void *, uint8_t); }; diff --git a/wiiu/include/wiiu/syshid.h b/wiiu/include/wiiu/syshid.h index 2c058e6765..385f42acab 100644 --- a/wiiu/include/wiiu/syshid.h +++ b/wiiu/include/wiiu/syshid.h @@ -1,6 +1,15 @@ #pragma once #include +/* + * Report types for the report_type parameter in HIDSetReport() + */ + +// what is 1? +#define HID_REPORT_OUTPUT 2 +#define HID_REPORT_FEATURE 3 +// are there more? + typedef struct { uint32_t handle;