Fix USB gamepad support
1. get_axis() didn't use AXIS_NEG_GET() / AXIS_POS_GET() 2. packet_handler() needs byte shift 3. log messages need SWAP_IF_BIG()
This commit is contained in:
parent
b6ae697fad
commit
78e7d23c14
|
@ -14,6 +14,7 @@
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <retro_endianness.h>
|
||||||
#include "../include/wiiu/hid.h"
|
#include "../include/wiiu/hid.h"
|
||||||
#include <wiiu/os/atomic.h>
|
#include <wiiu/os/atomic.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
@ -83,7 +84,21 @@ static int16_t wiiu_hid_joypad_axis(void *data, unsigned slot, uint32_t joyaxis)
|
||||||
if (!pad)
|
if (!pad)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return pad->iface->get_axis(pad->connection, joyaxis);
|
if (AXIS_NEG_GET(joyaxis) < 4)
|
||||||
|
{
|
||||||
|
int16_t val = pad->iface->get_axis(pad->connection, AXIS_NEG_GET(joyaxis));
|
||||||
|
|
||||||
|
if (val < 0)
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
else if (AXIS_POS_GET(joyaxis) < 4)
|
||||||
|
{
|
||||||
|
int16_t val = pad->iface->get_axis(pad->connection, AXIS_POS_GET(joyaxis));
|
||||||
|
|
||||||
|
if (val > 0)
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t wiiu_hid_joypad_state(
|
static int16_t wiiu_hid_joypad_state(
|
||||||
|
@ -385,8 +400,8 @@ static void log_device(HIDDevice *device)
|
||||||
|
|
||||||
RARCH_LOG(" handle: %d\n", device->handle);
|
RARCH_LOG(" handle: %d\n", device->handle);
|
||||||
RARCH_LOG(" physical_device_inst: %d\n", device->physical_device_inst);
|
RARCH_LOG(" physical_device_inst: %d\n", device->physical_device_inst);
|
||||||
RARCH_LOG(" vid: 0x%x\n", device->vid);
|
RARCH_LOG(" vid: 0x%04x\n", SWAP_IF_BIG(device->vid));
|
||||||
RARCH_LOG(" pid: 0x%x\n", device->pid);
|
RARCH_LOG(" pid: 0x%04x\n", SWAP_IF_BIG(device->pid));
|
||||||
RARCH_LOG(" interface_index: %d\n", device->interface_index);
|
RARCH_LOG(" interface_index: %d\n", device->interface_index);
|
||||||
RARCH_LOG(" sub_class: %d\n", device->sub_class);
|
RARCH_LOG(" sub_class: %d\n", device->sub_class);
|
||||||
RARCH_LOG(" protocol: %d\n", device->protocol);
|
RARCH_LOG(" protocol: %d\n", device->protocol);
|
||||||
|
@ -411,9 +426,11 @@ static uint8_t try_init_driver(wiiu_adapter_t *adapter)
|
||||||
|
|
||||||
entry = find_connection_entry(adapter->vendor_id, adapter->product_id, adapter->device_name);
|
entry = find_connection_entry(adapter->vendor_id, adapter->product_id, adapter->device_name);
|
||||||
if(!entry) {
|
if(!entry) {
|
||||||
RARCH_LOG("Failed to find entry for vid: 0x%x, pid: 0x%x, name: %s\n", adapter->vendor_id, adapter->product_id, adapter->device_name);
|
RARCH_LOG("Failed to find entry for vid: 0x%04x, pid: 0x%04x, name: %s\n", SWAP_IF_BIG(adapter->vendor_id), SWAP_IF_BIG(adapter->product_id), adapter->device_name);
|
||||||
return ADAPTER_STATE_DONE;
|
return ADAPTER_STATE_DONE;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
RARCH_LOG("Found entry for: vid: 0x%04x, pid: 0x%04x, name: %s\n", SWAP_IF_BIG(adapter->vendor_id), SWAP_IF_BIG(adapter->product_id), adapter->device_name);
|
||||||
|
|
||||||
adapter->pad_driver = entry->iface;
|
adapter->pad_driver = entry->iface;
|
||||||
|
|
||||||
|
@ -607,7 +624,10 @@ static void wiiu_hid_read_loop_callback(uint32_t handle, int32_t error,
|
||||||
|
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
{
|
{
|
||||||
adapter->pad_driver->packet_handler(adapter->pad_driver_data, buffer, buffer_size);
|
/* 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue