msvc: resolve all warnings in Core.

Note: vs14 will support empty macro parameter as used by MMIO.
This commit is contained in:
Shawn Hoffman
2014-08-19 20:15:56 -07:00
parent 317e63e7ba
commit 043ea31f14
13 changed files with 63 additions and 52 deletions

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <errno.h>
#include <libusb.h>
#include "Core/Core.h"
#include "Core/Debugger/Debugger_SymbolMap.h"
@ -25,7 +26,7 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid)
static u16 timeToFill = 0;
if (timeToFill == 0)
{
std::lock_guard<std::mutex> lk(hid->s_device_list_reply);
std::lock_guard<std::mutex> lk(hid->m_device_list_reply_mutex);
if (hid->deviceCommandAddress != 0){
hid->FillOutDevices(Memory::Read_U32(hid->deviceCommandAddress + 0x18), Memory::Read_U32(hid->deviceCommandAddress + 0x1C));
@ -97,11 +98,11 @@ CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid()
deinit_libusb = true;
}
for (const auto& device : open_devices)
for (const auto& device : m_open_devices)
{
libusb_close(device.second);
}
open_devices.clear();
m_open_devices.clear();
if (deinit_libusb)
libusb_exit(nullptr);
@ -238,7 +239,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
}
case IOCTL_HID_SHUTDOWN:
{
std::lock_guard<std::mutex> lk(s_device_list_reply);
std::lock_guard<std::mutex> lk(m_device_list_reply_mutex);
if (deviceCommandAddress != 0){
Memory::Write_U32(0xFFFFFFFF, Memory::Read_U32(deviceCommandAddress + 0x18));
@ -479,12 +480,12 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
if (hidDeviceAliases[i] != 0 && check_cur != check)
{
DEBUG_LOG(WII_IPC_HID, "Removing: device %d %hX %hX", i, check, check_cur);
std::lock_guard<std::mutex> lk(s_open_devices);
if (open_devices.find(i) != open_devices.end())
std::lock_guard<std::mutex> lk(m_open_devices_mutex);
if (m_open_devices.find(i) != m_open_devices.end())
{
libusb_device_handle *handle = open_devices[i];
libusb_device_handle *handle = m_open_devices[i];
libusb_close(handle);
open_devices.erase(i);
m_open_devices.erase(i);
}
hidDeviceAliases[i] = 0;
}
@ -514,11 +515,11 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum)
return nullptr;
std::lock_guard<std::mutex> lk(s_open_devices);
std::lock_guard<std::mutex> lk(m_open_devices_mutex);
if (open_devices.find(devNum) != open_devices.end())
if (m_open_devices.find(devNum) != m_open_devices.end())
{
handle = open_devices[devNum];
handle = m_open_devices[devNum];
if (libusb_kernel_driver_active(handle, 0) != LIBUSB_ERROR_NO_DEVICE)
{
return handle;
@ -526,7 +527,7 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum)
else
{
libusb_close(handle);
open_devices.erase(devNum);
m_open_devices.erase(devNum);
}
}
@ -597,7 +598,7 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum)
continue;
}
open_devices[devNum] = handle;
m_open_devices[devNum] = handle;
break;
}
else

View File

@ -4,20 +4,31 @@
#pragma once
#include <libusb.h>
#include <list>
#include "Common/Thread.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
// Forward declare things which we need from libusb header.
// This prevents users of this file from indirectly pulling in libusb.
#if defined(_WIN32)
#define LIBUSB_CALL WINAPI
#else
#define LIBUSB_CALL
#endif
struct libusb_device_handle;
struct libusb_device_descriptor;
struct libusb_config_descriptor;
struct libusb_interface_descriptor;
struct libusb_endpoint_descriptor;
struct libusb_transfer;
#define HID_ID_MASK 0x0000FFFFFFFFFFFF
#define MAX_HID_INTERFACES 1
#define HIDERR_NO_DEVICE_FOUND -4
/* Connection timed out */
class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device
{
public:
@ -45,7 +56,6 @@ private:
IOCTL_HID_CANCEL_INTERRUPT = 0x08,
};
/* Device descriptor */
struct WiiHIDDeviceDescriptor
{
u8 bLength;
@ -108,32 +118,22 @@ private:
u32 deviceCommandAddress;
void FillOutDevices(u32 BufferOut, u32 BufferOutSize);
int GetAvaiableDevNum(u16 idVendor, u16 idProduct, u8 bus, u8 port, u16 check);
bool ClaimDevice(libusb_device_handle * dev);
bool ClaimDevice(libusb_device_handle* dev);
void ConvertDeviceToWii(WiiHIDDeviceDescriptor *dest, const struct libusb_device_descriptor *src);
void ConvertConfigToWii(WiiHIDConfigDescriptor *dest, const struct libusb_config_descriptor *src);
void ConvertInterfaceToWii(WiiHIDInterfaceDescriptor *dest, const struct libusb_interface_descriptor *src);
void ConvertEndpointToWii(WiiHIDEndpointDescriptor *dest, const struct libusb_endpoint_descriptor *src);
void ConvertDeviceToWii(WiiHIDDeviceDescriptor* dest, const libusb_device_descriptor* src);
void ConvertConfigToWii(WiiHIDConfigDescriptor* dest, const libusb_config_descriptor* src);
void ConvertInterfaceToWii(WiiHIDInterfaceDescriptor* dest, const libusb_interface_descriptor* src);
void ConvertEndpointToWii(WiiHIDEndpointDescriptor* dest, const libusb_endpoint_descriptor* src);
int Align(int num, int alignment);
static void checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid);
static void LIBUSB_CALL handleUsbUpdates(struct libusb_transfer *transfer);
static void LIBUSB_CALL handleUsbUpdates(libusb_transfer* transfer);
struct libusb_device_handle * GetDeviceByDevNum(u32 devNum);
std::map<u32,libusb_device_handle*> open_devices;
std::mutex s_open_devices;
std::mutex s_device_list_reply;
std::map<std::string,int> device_identifiers;
libusb_device_handle* GetDeviceByDevNum(u32 devNum);
std::map<u32, libusb_device_handle*> m_open_devices;
std::mutex m_open_devices_mutex;
std::mutex m_device_list_reply_mutex;
std::thread usb_thread;
bool usb_thread_running;
typedef struct
{
u32 enq_address;
u32 type;
void * context;
} _hidevent;
std::list<_hidevent> event_list;
};