Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement hid_write_control, so we can use HidD_SetOutputReport on wi… #1

Merged
merged 1 commit into from
Apr 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions hidapi/hidapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ extern "C" {
*/
HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device);

/** RPCS3 EDIT: This attempts to write the output on the 'control' channel
Otherwise it's the exact same as hid_write
*/
int HID_API_EXPORT HID_API_CALL hid_write_control(hid_device *device, const unsigned char *data, size_t length);

#ifdef __cplusplus
}
#endif
Expand Down
5 changes: 5 additions & 0 deletions libusb/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,11 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path)
}
}

int HID_API_EXPORT hid_write_control(hid_device *dev, const unsigned char *data, size_t length)
{
//RPCS3 TODO: Test if this needs to be changed for control if we ever use it
return hid_write(dev, data, length);
}

int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length)
{
Expand Down
6 changes: 6 additions & 0 deletions linux/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,12 @@ int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t
return bytes_written;
}

int HID_API_EXPORT hid_write_control(hid_device *dev, const unsigned char *data, size_t length)
{
//RPCS3 TODO: Test if this needs to be changed for control if we ever use it
return hid_write(dev, data, length);
}


int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds)
{
Expand Down
6 changes: 6 additions & 0 deletions mac/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,12 @@ static int set_report(hid_device *dev, IOHIDReportType type, const unsigned char
return -1;
}

int HID_API_EXPORT hid_write_control(hid_device *dev, const unsigned char *data, size_t length)
{
//RPCS3 TODO: Test if this needs to be changed for control on mac if we ever use it
return hid_write(dev, data, length);
}

int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length)
{
return set_report(dev, kIOHIDReportTypeOutput, data, length);
Expand Down
17 changes: 17 additions & 0 deletions windows/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ extern "C" {
typedef BOOLEAN (__stdcall *HidD_FreePreparsedData_)(PHIDP_PREPARSED_DATA preparsed_data);
typedef NTSTATUS (__stdcall *HidP_GetCaps_)(PHIDP_PREPARSED_DATA preparsed_data, HIDP_CAPS *caps);
typedef BOOLEAN (__stdcall *HidD_SetNumInputBuffers_)(HANDLE handle, ULONG number_buffers);
typedef BOOLEAN(__stdcall *HidD_SetOutputReport_)(HANDLE handle, PVOID data, ULONG length);

static HidD_GetAttributes_ HidD_GetAttributes;
static HidD_GetSerialNumberString_ HidD_GetSerialNumberString;
Expand All @@ -126,6 +127,7 @@ extern "C" {
static HidD_FreePreparsedData_ HidD_FreePreparsedData;
static HidP_GetCaps_ HidP_GetCaps;
static HidD_SetNumInputBuffers_ HidD_SetNumInputBuffers;
static HidD_SetOutputReport_ HidD_SetOutputReport;

static HMODULE lib_handle = NULL;
static BOOLEAN initialized = FALSE;
Expand Down Expand Up @@ -216,6 +218,7 @@ static int lookup_functions()
RESOLVE(HidD_FreePreparsedData);
RESOLVE(HidP_GetCaps);
RESOLVE(HidD_SetNumInputBuffers);
RESOLVE(HidD_SetOutputReport);
#undef RESOLVE
}
else
Expand Down Expand Up @@ -663,6 +666,20 @@ int HID_API_EXPORT HID_API_CALL hid_write(hid_device *dev, const unsigned char *
return bytes_written;
}

int HID_API_EXPORT HID_API_CALL hid_write_control(hid_device *dev, const unsigned char *data, size_t length)
{
DWORD bytes_written = length;
BOOL res;

res = HidD_SetOutputReport(dev->device_handle, (PVOID)data, (ULONG)length);

if (!res) {
register_error(dev, "SetOutputReport");
bytes_written = -1;
}

return length;
}

int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds)
{
Expand Down