(HID) Fix some warnings

This commit is contained in:
twinaphex 2021-10-20 02:23:01 +02:00
parent 1dc77507a8
commit 5ec93d2493
2 changed files with 20 additions and 23 deletions

View File

@ -226,20 +226,18 @@ static int32_t ds3_button(void *device_data, uint16_t joykey) {
return device->buttons & (1 << joykey);
}
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);
static int ds3_set_operational(ds3_instance_t *instance)
{
int ret;
const int buf_size = SIXAXIS_REPORT_0xF2_SIZE;
uint8_t *buf = (uint8_t *)malloc(buf_size);
if(!buf) {
if(!buf)
return -1;
}
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) {
ret = instance->hid_driver->set_report(instance->handle, HID_REPORT_FEATURE, ds3_activation_packet.data.report_id, (uint8_t*)ds3_activation_packet.buf, sizeof(ds3_activation_packet));
if(ret < 0)
RARCH_LOG("Failed to send activation packet\n");
}
free(buf);
return ret;

View File

@ -59,8 +59,11 @@ struct iohidmanager_hid_adapter
uint8_t data[2048];
};
enum IOHIDReportType translate_hid_report_type(int report_type) {
switch(report_type) {
enum IOHIDReportType translate_hid_report_type(
int report_type)
{
switch (report_type)
{
case HID_REPORT_FEATURE:
return kIOHIDReportTypeFeature;
case HID_REPORT_INPUT:
@ -1101,28 +1104,24 @@ static int32_t iohidmanager_set_report(void *handle, uint8_t report_type, uint8_
struct iohidmanager_hid_adapter *adapter =
(struct iohidmanager_hid_adapter*)handle;
int retval = -1;
if (adapter)
return IOHIDDeviceSetReport(adapter->handle, translate_hid_report_type(report_type), report_type, data_buf, size);
if (adapter) {
retval = IOHIDDeviceSetReport(adapter->handle, translate_hid_report_type(report_type), report_type, data_buf, size);
}
return retval;
return -1;
}
static int32_t iohidmanager_get_report(void *handle, uint8_t report_type, uint8_t report_id, void *data_buf, size_t size)
static int32_t iohidmanager_get_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;
int retval = -1;
if (adapter) {
if (adapter)
{
CFIndex length = size;
retval = IOHIDDeviceGetReport(adapter->handle, translate_hid_report_type(report_type), report_id, data_buf, &length);
return IOHIDDeviceGetReport(adapter->handle, translate_hid_report_type(report_type), report_id, data_buf, &length);
}
return retval;
return -1;
}
hid_driver_t iohidmanager_hid = {