diff --git a/input/connect/connect_nesusb.c b/input/connect/connect_nesusb.c index 5437770575..b2ee5ac81d 100644 --- a/input/connect/connect_nesusb.c +++ b/input/connect/connect_nesusb.c @@ -118,7 +118,7 @@ static void hidpad_nesusb_packet_handler(void *data, memcpy(device->data, packet, size); device->buttons = 0; - pressed_keys = device->data[7] | (device->data[6] << 8); + pressed_keys = device->data[6] | (device->data[5] << 8); for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) diff --git a/input/connect/connect_ps3.c b/input/connect/connect_ps3.c index ed0f044d5e..a845970cb4 100644 --- a/input/connect/connect_ps3.c +++ b/input/connect/connect_ps3.c @@ -300,11 +300,6 @@ static void ds3_packet_handler(void *device_data, return; } -#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); diff --git a/input/connect/connect_ps4.c b/input/connect/connect_ps4.c index d64ab7fb52..ae9e79cb20 100644 --- a/input/connect/connect_ps4.c +++ b/input/connect/connect_ps4.c @@ -266,7 +266,7 @@ static void hidpad_ps4_packet_handler(void *data, } #endif - memcpy(&device->data, &packet[2], sizeof(struct ps4)); + memcpy(&device->data, packet+1, sizeof(struct ps4)); } static void hidpad_ps4_set_rumble(void *data, diff --git a/input/connect/connect_ps4_hori_mini.c b/input/connect/connect_ps4_hori_mini.c index 2981809d44..d30fe0478e 100644 --- a/input/connect/connect_ps4_hori_mini.c +++ b/input/connect/connect_ps4_hori_mini.c @@ -86,7 +86,7 @@ static int16_t hidpad_ps4_hori_mini_get_axis(void *data, unsigned axis) if (!device || axis >= 4) return 0; - val = (device->data[2 + axis] << 8) - 0x8000; + val = (device->data[1 + axis] << 8) - 0x8000; if (abs(val) > 0x1000) return val; @@ -126,7 +126,7 @@ static void hidpad_ps4_hori_mini_packet_handler(void *data, device->buttons = 0; - dpad = device->data[6] & 0xF; + dpad = device->data[5] & 0xF; switch(dpad) { @@ -160,9 +160,9 @@ static void hidpad_ps4_hori_mini_packet_handler(void *data, break; } - pressed_keys = ((device->data[6] & 0xF0) >> 4) | - (device->data[7] << 4) | - (device->data[8] << 12); + pressed_keys = ((device->data[5] & 0xF0) >> 4) | + (device->data[6] << 4) | + (device->data[7] << 12); for (i = 0; i < 15; i++) { diff --git a/input/connect/connect_psxadapter.c b/input/connect/connect_psxadapter.c index e0f6820f3f..ca0a12725e 100644 --- a/input/connect/connect_psxadapter.c +++ b/input/connect/connect_psxadapter.c @@ -148,7 +148,7 @@ static void hidpad_psxadapter_packet_handler(void *data, device->buttons = 0; - pressed_keys = device->data[7] | (device->data[6] << 8); + pressed_keys = device->data[6] | (device->data[5] << 8); for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) @@ -157,15 +157,15 @@ static void hidpad_psxadapter_packet_handler(void *data, if (device->data[2]==0x7F) /* digital mode detection */ { /* We're in digital mode, process the dpad values */ - device->buttons |= (device->data[4]==0x00) ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; - device->buttons |= (device->data[4]==0xFF) ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; - device->buttons |= (device->data[5]==0x00) ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0; - device->buttons |= (device->data[5]==0xFF) ? (1 << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; + device->buttons |= (device->data[3]==0x00) ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; + device->buttons |= (device->data[3]==0xFF) ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; + device->buttons |= (device->data[4]==0x00) ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0; + device->buttons |= (device->data[4]==0xFF) ? (1 << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; } else { /* We're in analog mode, process the hat values as if they were pad buttons */ - hat_value = PSX_H_GET(device->data[6]); + hat_value = PSX_H_GET(device->data[5]); device->buttons |= PSX_H_LEFT(hat_value) ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; device->buttons |= PSX_H_RIGHT(hat_value) ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; device->buttons |= PSX_H_UP(hat_value) ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0; diff --git a/input/connect/connect_retrode.c b/input/connect/connect_retrode.c index 23e75ff4eb..d56e7ee455 100644 --- a/input/connect/connect_retrode.c +++ b/input/connect/connect_retrode.c @@ -156,7 +156,7 @@ static void retrode_update_button_state(retrode_pad_data_t *pad) if (!pad) return; - pressed_keys = pad->data[4]; + pressed_keys = pad->data[3]; pad->buttons = 0; for (i = 0; i < 8; i ++) @@ -180,14 +180,14 @@ static void hidpad_retrode_packet_handler(void *device_data, uint8_t *packet, ui memcpy(device->data, packet, size); /* - * packet[1] contains Retrode port number + * packet[0] contains Retrode port number * 1 = left SNES * 2 = right SNES * 3 = left Genesis/MD * 4 = right Genesis/MD */ - hidpad_retrode_pad_packet_handler(&device->pad_data[packet[1] - 1], &device->data[0], size); + hidpad_retrode_pad_packet_handler(&device->pad_data[packet[0] - 1], &device->data[0], size); } static void hidpad_retrode_set_rumble(void *data, diff --git a/input/connect/connect_snesusb.c b/input/connect/connect_snesusb.c index 7c17547361..e12b214ac7 100644 --- a/input/connect/connect_snesusb.c +++ b/input/connect/connect_snesusb.c @@ -118,7 +118,7 @@ static void hidpad_snesusb_packet_handler(void *data, uint8_t *packet, uint16_t device->buttons = 0; - pressed_keys = device->data[7] | (device->data[6] << 8); + pressed_keys = device->data[6] | (device->data[5] << 8); for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) diff --git a/input/connect/connect_wii.c b/input/connect/connect_wii.c index f5983705b0..d91d7054bb 100644 --- a/input/connect/connect_wii.c +++ b/input/connect/connect_wii.c @@ -649,12 +649,12 @@ static void hidpad_wii_packet_handler(void *data, uint8_t *packet, uint16_t size) { struct connect_wii_wiimote_t* device = (struct connect_wii_wiimote_t*)data; - uint8_t *msg = packet + 2; + uint8_t *msg = packet + 1; if (!device) return; - switch (packet[1]) + switch (packet[0]) { case WM_RPT_BTN: wiimote_pressed_buttons(device, msg); diff --git a/input/connect/connect_wiiugca.c b/input/connect/connect_wiiugca.c index ab02d0720f..a5c48e72f7 100644 --- a/input/connect/connect_wiiugca.c +++ b/input/connect/connect_wiiugca.c @@ -216,14 +216,6 @@ static void hidpad_wiiugca_packet_handler(void *device_data, uint8_t *packet, ui if (!device) return; -/* Mac OSX reads a 39-byte packet which has both a leading and trailing byte from - * the actual packet data. - */ -#if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER) - packet++; - size = 37; -#endif - memcpy(device->data, packet, size); for (i = 1; i < 37; i += 9) diff --git a/input/connect/joypad_connection.c b/input/connect/joypad_connection.c index 6500849d2b..0e595f7429 100644 --- a/input/connect/joypad_connection.c +++ b/input/connect/joypad_connection.c @@ -41,6 +41,11 @@ static joypad_connection_entry_t pad_map[] = { PID_SONY_DS4, &pad_connection_ps4 }, + { "Wireless Controller", + VID_SONY, + PID_SONY_DS4_R2, + &pad_connection_ps4 + }, { "PLAYSTATION(R)3 Controller", VID_SONY, PID_SONY_DS3, @@ -182,7 +187,7 @@ joypad_connection_entry_t *find_connection_entry(uint16_t vid, uint16_t pid, con SWAP_IF_BIG(vid), SWAP_IF_BIG(pid), name, pad_map[i].name); } else if (!string_is_equal(pad_map[i].name, name)) - continue; + continue; } if (name_match || (pad_map[i].vid == vid && pad_map[i].pid == pid)) diff --git a/input/connect/joypad_connection.h b/input/connect/joypad_connection.h index 711fc0b469..c585740ba5 100644 --- a/input/connect/joypad_connection.h +++ b/input/connect/joypad_connection.h @@ -46,6 +46,7 @@ #define PID_NINTENDO_PRO SWAP_IF_BIG(0x0330) #define PID_SONY_DS3 SWAP_IF_BIG(0x0268) #define PID_SONY_DS4 SWAP_IF_BIG(0x05c4) +#define PID_SONY_DS4_R2 SWAP_IF_BIG(0x09cc) #define PID_DS3_CLONE SWAP_IF_BIG(0x20d6) #define PID_SNES_CLONE SWAP_IF_BIG(0xe401) #define PID_MICRONTEK_NES SWAP_IF_BIG(0x0011) diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index 4618435c31..6e1a9057ca 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -701,7 +701,7 @@ static void iohidmanager_hid_device_add(IOHIDDeviceRef device, iohidmanager_hid_ if (pad_connection_has_interface(hid->slots, adapter->slot)) { IOHIDDeviceRegisterInputReportCallback(device, - adapter->data + 1, sizeof(adapter->data) - 1, + adapter->data, sizeof(adapter->data), iohidmanager_hid_device_report, adapter); } else { @@ -1105,7 +1105,7 @@ static int32_t iohidmanager_set_report(void *handle, uint8_t report_type, uint8_ (struct iohidmanager_hid_adapter*)handle; if (adapter) - return IOHIDDeviceSetReport(adapter->handle, translate_hid_report_type(report_type), report_id, data_buf, size); + return IOHIDDeviceSetReport(adapter->handle, translate_hid_report_type(report_type), report_id, data_buf + 1, size - 1); return -1; } diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index 4fa5743e69..d943b6944c 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -113,12 +113,12 @@ static void adapter_thread(void *data) slock_unlock(adapter->send_control_lock); libusb_interrupt_transfer(adapter->handle, - adapter->endpoint_in, &adapter->data[1], + adapter->endpoint_in, &adapter->data[0], adapter->endpoint_in_max_size, &size, 1000); if (adapter && hid && hid->slots && size) pad_connection_packet(&hid->slots[adapter->slot], adapter->slot, - adapter->data, size+1); + adapter->data, size); } } diff --git a/input/drivers_hid/wiiu_hid.c b/input/drivers_hid/wiiu_hid.c index 639874e4ed..60bb22ab76 100644 --- a/input/drivers_hid/wiiu_hid.c +++ b/input/drivers_hid/wiiu_hid.c @@ -624,10 +624,7 @@ static void wiiu_hid_read_loop_callback(uint32_t handle, int32_t error, if (error == 0) { - /* NOTE: packet_handler() expects that packet[1] is the first byte, so added -1. - * The Wii version puts the slot number in packet[0], which is not possible here: - * packet[0] is undefined! */ - adapter->pad_driver->packet_handler(adapter->pad_driver_data, buffer-1, buffer_size+1); + adapter->pad_driver->packet_handler(adapter->pad_driver_data, buffer, buffer_size); } } } diff --git a/input/drivers_hid/wiiusb_hid.c b/input/drivers_hid/wiiusb_hid.c index c6e63437d4..836f266288 100644 --- a/input/drivers_hid/wiiusb_hid.c +++ b/input/drivers_hid/wiiusb_hid.c @@ -111,7 +111,7 @@ static int32_t wiiusb_hid_read_cb(int32_t size, void *data) if (hid && hid->connections && size > 0) pad_connection_packet(&hid->connections[adapter->slot], - adapter->slot, adapter->data-1, size+1); + adapter->slot, adapter->data, size); if (adapter) adapter->busy = false;