mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 15:49:25 +01:00
Add Libusb to cmake and HID files.
This commit is contained in:
parent
c626d5aae3
commit
d9dd94ac8b
@ -414,6 +414,16 @@ else(SDL2_FOUND)
|
|||||||
endif(SDL_FOUND)
|
endif(SDL_FOUND)
|
||||||
endif(SDL2_FOUND)
|
endif(SDL2_FOUND)
|
||||||
|
|
||||||
|
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
include(FindLibUSB OPTIONAL)
|
||||||
|
endif()
|
||||||
|
if(LIBUSB_FOUND)
|
||||||
|
message("Using shared LibUSB")
|
||||||
|
include_directories(${LIBUSB_INCLUDE_DIR})
|
||||||
|
else(LIBUSB_FOUND)
|
||||||
|
|
||||||
|
endif(LIBUSB_FOUND)
|
||||||
|
|
||||||
set(SFML_FIND_VERSION TRUE)
|
set(SFML_FIND_VERSION TRUE)
|
||||||
set(SFML_FIND_VERSION_MAJOR 1)
|
set(SFML_FIND_VERSION_MAJOR 1)
|
||||||
set(SFML_FIND_VERSION_MINOR 5)
|
set(SFML_FIND_VERSION_MINOR 5)
|
||||||
|
39
CMakeTests/FindLibUSB.cmake
Normal file
39
CMakeTests/FindLibUSB.cmake
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# - Find libusb-1.0 library
|
||||||
|
# This module defines
|
||||||
|
# LIBUSB_INCLUDE_DIR, where to find bluetooth.h
|
||||||
|
# LIBUSB_LIBRARIES, the libraries needed to use libusb-1.0.
|
||||||
|
# LIBUSB_FOUND, If false, do not try to use libusb-1.0.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009, Michal Cihar, <michal@cihar.com>
|
||||||
|
#
|
||||||
|
# vim: expandtab sw=4 ts=4 sts=4:
|
||||||
|
|
||||||
|
if (NOT LIBUSB_FOUND)
|
||||||
|
pkg_check_modules (LIBUSB_PKG libusb-1.0)
|
||||||
|
|
||||||
|
find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||||
|
PATHS
|
||||||
|
${LIBUSB_PKG_INCLUDE_DIRS}
|
||||||
|
/usr/include/libusb-1.0
|
||||||
|
/usr/include
|
||||||
|
/usr/local/include
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(LIBUSB_LIBRARIES NAMES usb-1.0
|
||||||
|
PATHS
|
||||||
|
${LIBUSB_PKG_LIBRARY_DIRS}
|
||||||
|
/usr/lib
|
||||||
|
/usr/local/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
if(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
|
||||||
|
set(LIBUSB_FOUND TRUE CACHE INTERNAL "libusb-1.0 found")
|
||||||
|
message(STATUS "Found libusb-1.0: ${LIBUSB_INCLUDE_DIR}, ${LIBUSB_LIBRARIES}")
|
||||||
|
else(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
|
||||||
|
set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found")
|
||||||
|
message(STATUS "libusb-1.0 not found.")
|
||||||
|
endif(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
|
||||||
|
|
||||||
|
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES)
|
||||||
|
endif (NOT LIBUSB_FOUND)
|
||||||
|
|
@ -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_es.cpp
|
||||||
Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.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_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_net.cpp
|
||||||
Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp
|
Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp
|
||||||
Src/IPC_HLE/WII_IPC_HLE_Device_usb.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)
|
set(LIBS bdisasm inputcommon videoogl videosoftware sfml-network)
|
||||||
|
|
||||||
|
|
||||||
|
if(LIBUSB_FOUND)
|
||||||
|
# Using shared LibUSB
|
||||||
|
set(LIBS ${LIBS} ${LIBUSB_LIBRARIES})
|
||||||
|
endif(LIBUSB_FOUND)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(SRCS ${SRCS} Src/HW/BBA-TAP/TAP_Win32.cpp Src/stdafx.cpp
|
set(SRCS ${SRCS} Src/HW/BBA-TAP/TAP_Win32.cpp Src/stdafx.cpp
|
||||||
Src/HW/WiimoteReal/IOWin.cpp)
|
Src/HW/WiimoteReal/IOWin.cpp)
|
||||||
|
@ -64,7 +64,7 @@ bool CWII_IPC_HLE_Device_hid::Close(u32 _CommandAddress, bool _bForce)
|
|||||||
u32 CWII_IPC_HLE_Device_hid::Update()
|
u32 CWII_IPC_HLE_Device_hid::Update()
|
||||||
{
|
{
|
||||||
u32 work_done = 0;
|
u32 work_done = 0;
|
||||||
int ret = -4;
|
//int ret = -4;
|
||||||
//timeval tv;
|
//timeval tv;
|
||||||
|
|
||||||
|
|
||||||
@ -215,15 +215,14 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
|
|||||||
case IOCTL_HID_INTERRUPT_IN:
|
case IOCTL_HID_INTERRUPT_IN:
|
||||||
{
|
{
|
||||||
|
|
||||||
|
int transfered = 0;
|
||||||
u32 dev_num = Memory::Read_U32(BufferIn+0x10);
|
u32 dev_num = Memory::Read_U32(BufferIn+0x10);
|
||||||
u32 endpoint = Memory::Read_U32(BufferIn+0x14);
|
u32 endpoint = Memory::Read_U32(BufferIn+0x14);
|
||||||
u32 length = Memory::Read_U32(BufferIn+0x18);
|
u32 length = Memory::Read_U32(BufferIn+0x18);
|
||||||
|
|
||||||
u32 data = Memory::Read_U32(BufferIn+0x1C);
|
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);
|
Parameter == IOCTL_HID_INTERRUPT_IN ? "In" : "Out", endpoint, length, data, ReturnValue, BufferIn, BufferInSize, BufferOut, BufferOutSize);
|
||||||
int ret = 0;
|
|
||||||
void * context = NULL;
|
|
||||||
ReturnValue = -4;
|
ReturnValue = -4;
|
||||||
|
|
||||||
libusb_device_handle * dev_handle = GetDeviceByDevNum(dev_num);
|
libusb_device_handle * dev_handle = GetDeviceByDevNum(dev_num);
|
||||||
@ -233,7 +232,6 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
|
|||||||
ReturnValue = -4;
|
ReturnValue = -4;
|
||||||
goto int_in_end_print;
|
goto int_in_end_print;
|
||||||
}
|
}
|
||||||
int transfered = 0;
|
|
||||||
|
|
||||||
if(libusb_interrupt_transfer(dev_handle, endpoint, (unsigned char*)Memory::GetPointer(data), length, &transfered, 0 ) == 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:
|
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);
|
Parameter == IOCTL_HID_INTERRUPT_IN ? "In" : "Out", endpoint, length, data, ReturnValue, BufferIn, BufferInSize, BufferOut, BufferOutSize);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -333,11 +331,11 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
|
|||||||
{
|
{
|
||||||
int OffsetBuffer = BufferOut;
|
int OffsetBuffer = BufferOut;
|
||||||
int OffsetStart = 0;
|
int OffsetStart = 0;
|
||||||
int OffsetDevice = 0;
|
//int OffsetDevice = 0;
|
||||||
int d, c,ic,i,e; /* config, interface container, interface, endpoint */
|
int d,c,ic,i,e; /* config, interface container, interface, endpoint */
|
||||||
|
|
||||||
libusb_device **list;
|
libusb_device **list;
|
||||||
libusb_device *found = NULL;
|
//libusb_device *found = NULL;
|
||||||
ssize_t cnt = libusb_get_device_list(NULL, &list);
|
ssize_t cnt = libusb_get_device_list(NULL, &list);
|
||||||
|
|
||||||
for (d = 0; d < cnt; d++)
|
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;
|
struct libusb_device_descriptor desc;
|
||||||
int dRet = libusb_get_device_descriptor (device, &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)
|
if (desc.idVendor != 0x21A4)
|
||||||
continue;
|
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);
|
DEBUG_LOG(WII_IPC_HID, "Found device with Vendor: %d Product: %d Devnum: %d, Error: %d",desc.idVendor, desc.idProduct, devNum, dRet);
|
||||||
|
|
||||||
OffsetStart = OffsetBuffer;
|
OffsetStart = OffsetBuffer;
|
||||||
OffsetBuffer += 4; // skip length for now, fill at end
|
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;
|
OffsetBuffer += 4;
|
||||||
|
|
||||||
WiiHIDDeviceDescriptor wii_device;
|
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
|
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;
|
libusb_device_handle *handle = NULL;
|
||||||
ssize_t cnt;
|
ssize_t cnt;
|
||||||
|
|
||||||
|
devNum = 0x204;
|
||||||
|
|
||||||
if (open_devices.find(devNum) != open_devices.end())
|
if (open_devices.find(devNum) != open_devices.end())
|
||||||
return open_devices[devNum];
|
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++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
libusb_device *device = list[i];
|
libusb_device *device = list[i];
|
||||||
|
int ret = libusb_open(device, &handle);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
|
||||||
|
DEBUG_LOG(WII_IPC_HID, "Failed to open device with error = %d", ret);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (libusb_open(device, &handle))
|
|
||||||
break;
|
|
||||||
//struct libusb_device_descriptor desc;
|
//struct libusb_device_descriptor desc;
|
||||||
u32 deviceID = (libusb_get_bus_number (device) << 8) | libusb_get_device_address (device);
|
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)
|
if (deviceID == devNum)
|
||||||
|
{
|
||||||
open_devices[devNum] = handle;
|
open_devices[devNum] = handle;
|
||||||
|
break;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
libusb_close(handle);
|
libusb_close(handle);
|
||||||
@ -463,7 +473,7 @@ 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;
|
return handle;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "WII_IPC_HLE_Device.h"
|
#include "WII_IPC_HLE_Device.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
/* Connection timed out */ #define ETRANSFER_TIMEDOUT -116
|
/* Connection timed out */
|
||||||
|
|
||||||
class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device
|
class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device
|
||||||
{
|
{
|
||||||
@ -113,7 +113,7 @@ private:
|
|||||||
} WiiHIDEndpointDescriptor;
|
} 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 ConvertDeviceToWii(WiiHIDDeviceDescriptor *dest, const struct libusb_device_descriptor *src);
|
||||||
void ConvertConfigToWii(WiiHIDConfigDescriptor *dest, const struct libusb_config_descriptor *src);
|
void ConvertConfigToWii(WiiHIDConfigDescriptor *dest, const struct libusb_config_descriptor *src);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user