diff options
| author | Matthew Parlane <parlane@gmail.com> | 2012-12-24 12:58:11 +1300 |
|---|---|---|
| committer | Matthew Parlane <parlane@gmail.com> | 2012-12-24 12:58:11 +1300 |
| commit | d9dd94ac8b696ceb0e6b32eaafcc302b41f43bd1 (patch) | |
| tree | 17fe951a8ce15c8dfeda08d84551053fe123db46 /Source | |
| parent | c626d5aae3f34ee93626c4d26c76bf5fbd7ef76a (diff) | |
Add Libusb to cmake and HID files.
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp | 48 | ||||
| -rw-r--r-- | Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h | 8 |
3 files changed, 40 insertions, 23 deletions
diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 734d966781..dd19d36d36 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -138,6 +138,7 @@ set(SRCS Src/ActionReplay.cpp Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp + Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -194,6 +195,12 @@ set(SRCS Src/ActionReplay.cpp set(LIBS bdisasm inputcommon videoogl videosoftware sfml-network) + +if(LIBUSB_FOUND) + # Using shared LibUSB + set(LIBS ${LIBS} ${LIBUSB_LIBRARIES}) +endif(LIBUSB_FOUND) + if(WIN32) set(SRCS ${SRCS} Src/HW/BBA-TAP/TAP_Win32.cpp Src/stdafx.cpp Src/HW/WiimoteReal/IOWin.cpp) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp index 486ec062e6..250ff7021e 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp @@ -64,7 +64,7 @@ bool CWII_IPC_HLE_Device_hid::Close(u32 _CommandAddress, bool _bForce) u32 CWII_IPC_HLE_Device_hid::Update() { u32 work_done = 0; - int ret = -4; + //int ret = -4; //timeval tv; @@ -214,16 +214,15 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) case IOCTL_HID_INTERRUPT_OUT: case IOCTL_HID_INTERRUPT_IN: { - + + int transfered = 0; u32 dev_num = Memory::Read_U32(BufferIn+0x10); u32 endpoint = Memory::Read_U32(BufferIn+0x14); u32 length = Memory::Read_U32(BufferIn+0x18); u32 data = Memory::Read_U32(BufferIn+0x1C); - DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Interrupt %s)(%d,%d,%p) = %d (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", + DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Interrupt %s)(%d,%d,%X) = %d (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", Parameter == IOCTL_HID_INTERRUPT_IN ? "In" : "Out", endpoint, length, data, ReturnValue, BufferIn, BufferInSize, BufferOut, BufferOutSize); - int ret = 0; - void * context = NULL; ReturnValue = -4; libusb_device_handle * dev_handle = GetDeviceByDevNum(dev_num); @@ -233,7 +232,6 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) ReturnValue = -4; goto int_in_end_print; } - int transfered = 0; if(libusb_interrupt_transfer(dev_handle, endpoint, (unsigned char*)Memory::GetPointer(data), length, &transfered, 0 ) == 0) { @@ -251,7 +249,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) int_in_end_print: - DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Interrupt %s)(%d,%d,%p) = %d (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", + DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Interrupt %s)(%d,%d,%X) = %d (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", Parameter == IOCTL_HID_INTERRUPT_IN ? "In" : "Out", endpoint, length, data, ReturnValue, BufferIn, BufferInSize, BufferOut, BufferOutSize); break; @@ -333,11 +331,11 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize) { int OffsetBuffer = BufferOut; int OffsetStart = 0; - int OffsetDevice = 0; - int d, c,ic,i,e; /* config, interface container, interface, endpoint */ + //int OffsetDevice = 0; + int d,c,ic,i,e; /* config, interface container, interface, endpoint */ libusb_device **list; - libusb_device *found = NULL; + //libusb_device *found = NULL; ssize_t cnt = libusb_get_device_list(NULL, &list); for (d = 0; d < cnt; d++) @@ -346,17 +344,18 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize) struct libusb_device_descriptor desc; int dRet = libusb_get_device_descriptor (device, &desc); - DEBUG_LOG(WII_IPC_HID, "Vendor: %d Product: %X Devnum: %X",desc.idVendor, desc.idProduct); + u32 devNum = (libusb_get_bus_number (device) << 8) | libusb_get_device_address (device); + + DEBUG_LOG(WII_IPC_HID, "Vendor: %d Product: %X Devnum: %X",desc.idVendor, desc.idProduct, devNum); if (desc.idVendor != 0x21A4) continue; - u32 devNum = 0;//(libusb_get_bus_number (device) << 8) | libusb_get_device_address (device); DEBUG_LOG(WII_IPC_HID, "Found device with Vendor: %d Product: %d Devnum: %d, Error: %d",desc.idVendor, desc.idProduct, devNum, dRet); OffsetStart = OffsetBuffer; OffsetBuffer += 4; // skip length for now, fill at end - Memory::Write_U32(devNum, OffsetBuffer); //write device num + Memory::Write_U32( 0/*devNum*/, OffsetBuffer); //write device num OffsetBuffer += 4; WiiHIDDeviceDescriptor wii_device; @@ -413,7 +412,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize) } - libusb_free_device_list(list, TRUE); + libusb_free_device_list(list, 1); Memory::Write_U32(0xFFFFFFFF, OffsetBuffer); // no more devices @@ -439,6 +438,8 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) libusb_device_handle *handle = NULL; ssize_t cnt; + devNum = 0x204; + if (open_devices.find(devNum) != open_devices.end()) return open_devices[devNum]; @@ -449,13 +450,22 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) for (i = 0; i < cnt; i++) { libusb_device *device = list[i]; - - if (libusb_open(device, &handle)) - break; + int ret = libusb_open(device, &handle); + if (ret) + { + + DEBUG_LOG(WII_IPC_HID, "Failed to open device with error = %d", ret); + continue; + } + //struct libusb_device_descriptor desc; u32 deviceID = (libusb_get_bus_number (device) << 8) | libusb_get_device_address (device); + DEBUG_LOG(WII_IPC_HID, "Testing device id == %d", deviceID); if (deviceID == devNum) + { open_devices[devNum] = handle; + break; + } else { libusb_close(handle); @@ -463,8 +473,8 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) } } - libusb_free_device_list(list, TRUE); + libusb_free_device_list(list, 1); return handle; -}
\ No newline at end of file +} diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h index be7e1b5926..7f70324772 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h @@ -21,7 +21,7 @@ #include "WII_IPC_HLE_Device.h" #include <list> -/* Connection timed out */ #define ETRANSFER_TIMEDOUT -116 +/* Connection timed out */ class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device { @@ -45,8 +45,8 @@ private: IOCTL_HID_SET_SUSPEND = 0x01, IOCTL_HID_CONTROL = 0x02, IOCTL_HID_INTERRUPT_IN = 0x03, - IOCTL_HID_INTERRUPT_OUT = 0x04, - IOCTL_HID_GET_US_STRING = 0x05, + IOCTL_HID_INTERRUPT_OUT = 0x04, + IOCTL_HID_GET_US_STRING = 0x05, IOCTL_HID_OPEN = 0x06, IOCTL_HID_SHUTDOWN = 0x07, IOCTL_HID_CANCEL_INTERRUPT = 0x08, @@ -113,7 +113,7 @@ private: } WiiHIDEndpointDescriptor; - void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize); + void FillOutDevices(u32 BufferOut, u32 BufferOutSize); void ConvertDeviceToWii(WiiHIDDeviceDescriptor *dest, const struct libusb_device_descriptor *src); void ConvertConfigToWii(WiiHIDConfigDescriptor *dest, const struct libusb_config_descriptor *src); |
