Start adapting the dual shock 3 driver to use the new driver format.

== DETAILS

The handshake stuff is derived from the old HID2VPAD, just in knowing
what data goes in what report.

- Added the HID_REPORT_ flags to syshid.h
- Renamed the generic "REPORT_TYPE" flags to be meaningful
- also fixed incorrect parameter list for set_protocol
== TESTING
The functions aren't implemented in wiiu_hid.c just yet,
so this is gonna crash if you try to run it.
This commit is contained in:
gblues 2017-12-14 00:01:49 -08:00 committed by twinaphex
parent 982d6893b0
commit 678c4093c1
3 changed files with 40 additions and 2 deletions

View File

@ -22,6 +22,10 @@
#include "joypad_connection.h"
#include "../input_defines.h"
#ifdef WIIU
#include <wiiu/syshid.h>
#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);

View File

@ -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);
};

View File

@ -1,6 +1,15 @@
#pragma once
#include <wiiu/types.h>
/*
* 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;