diff --git a/Externals/WiiUse/Win32/wiiuse.lib b/Externals/WiiUse/Win32/wiiuse.lib
deleted file mode 100644
index b412d5d3fb..0000000000
Binary files a/Externals/WiiUse/Win32/wiiuse.lib and /dev/null differ
diff --git a/Externals/WiiUse/Win32/wiiused.lib b/Externals/WiiUse/Win32/wiiused.lib
deleted file mode 100644
index d515dc9124..0000000000
Binary files a/Externals/WiiUse/Win32/wiiused.lib and /dev/null differ
diff --git a/Externals/WiiUse/X64/wiiuse.lib b/Externals/WiiUse/X64/wiiuse.lib
deleted file mode 100644
index 9df7f0a997..0000000000
Binary files a/Externals/WiiUse/X64/wiiuse.lib and /dev/null differ
diff --git a/Externals/WiiUse/X64/wiiused.lib b/Externals/WiiUse/X64/wiiused.lib
deleted file mode 100644
index dbe44bf67a..0000000000
Binary files a/Externals/WiiUse/X64/wiiused.lib and /dev/null differ
diff --git a/SConstruct b/SConstruct
index 9307cfa773..18913e571d 100644
--- a/SConstruct
+++ b/SConstruct
@@ -344,7 +344,6 @@ dirs = [
'Externals/Bochs_disasm',
#'Externals/CLRun',
'Externals/Lua',
- 'Externals/WiiUse/Src',
'Externals/GLew',
'Externals/LZO',
#'Externals/OpenAL',
@@ -364,6 +363,7 @@ dirs = [
'Source/Core/InputCommon/Src',
'Source/Core/InputUICommon/Src',
'Source/Core/VideoCommon/Src',
+ 'Source/Core/wiiuse/Src',
'Source/DSPTool/Src',
'Source/Plugins/Plugin_DSP_HLE/Src',
'Source/Plugins/Plugin_DSP_LLE/Src',
diff --git a/Source/Core/CMakeLists.txt b/Source/Core/CMakeLists.txt
index ff9b5c9ae9..beef930d70 100644
--- a/Source/Core/CMakeLists.txt
+++ b/Source/Core/CMakeLists.txt
@@ -13,3 +13,4 @@ add_subdirectory(DolphinWX)
add_subdirectory(DSPCore)
add_subdirectory(InputCommon)
add_subdirectory(VideoCommon)
+add_subdirectory(wiiuse)
diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj
index 49d525b76a..779540b73a 100644
--- a/Source/Core/Core/Core.vcproj
+++ b/Source/Core/Core/Core.vcproj
@@ -45,7 +45,7 @@
#ifndef _WIN32
#include /* htons() */
@@ -46,13 +46,6 @@
#endif // _WIN32
-// NOTICE_LEVEL is more appropriate for the uses of WIIUSE_INFO than INFO_LEVEL
-// as long as we don't provide adequate GUI feedback for bluetooth events.
-#define WIIUSE_INFO(...) { GENERIC_LOG(WIIMOTE, NOTICE_LEVEL, __VA_ARGS__) }
-#define WIIUSE_ERROR(...) { GENERIC_LOG(WIIMOTE, ERROR_LEVEL, __VA_ARGS__) }
-#define WIIUSE_WARNING(...) { GENERIC_LOG(WIIMOTE, WARNING_LEVEL, __VA_ARGS__) }
-#define WIIUSE_DEBUG(...) { GENERIC_LOG(WIIMOTE, DEBUG_LEVEL, __VA_ARGS__) }
-
/* Convert to big endian */
#define BIG_ENDIAN_LONG(i) (htonl(i))
#define BIG_ENDIAN_SHORT(i) (htons(i))
diff --git a/Externals/WiiUse/Src/io_dummy.c b/Source/Core/wiiuse/Src/io_dummy.cpp
similarity index 100%
rename from Externals/WiiUse/Src/io_dummy.c
rename to Source/Core/wiiuse/Src/io_dummy.cpp
diff --git a/Externals/WiiUse/Src/io_nix.c b/Source/Core/wiiuse/Src/io_nix.cpp
similarity index 94%
rename from Externals/WiiUse/Src/io_nix.c
rename to Source/Core/wiiuse/Src/io_nix.cpp
index 237d1751dc..6e7fe2bd56 100644
--- a/Externals/WiiUse/Src/io_nix.c
+++ b/Source/Core/wiiuse/Src/io_nix.cpp
@@ -99,7 +99,7 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout)
return 0;
}
- WIIUSE_INFO("Found %i bluetooth device(s).", found_devices);
+ NOTICE_LOG(WIIMOTE, "Found %i bluetooth device(s).", found_devices);
// display discovered devices
for (i = 0; (i < found_devices) && (found_wiimotes < max_wiimotes); ++i)
@@ -123,7 +123,7 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout)
// found a new device
ba2str(&scan_info[i].bdaddr, wm[found_wiimotes]->bdaddr_str);
- WIIUSE_INFO("Found wiimote (%s) [id %i].",
+ NOTICE_LOG(WIIMOTE, "Found wiimote (%s) [id %i].",
wm[found_wiimotes]->bdaddr_str, wm[found_wiimotes]->unid);
wm[found_wiimotes]->bdaddr = scan_info[i].bdaddr;
@@ -225,7 +225,7 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address)
return 0;
}
- WIIUSE_INFO("Connected to wiimote [id %i].", wm->unid);
+ NOTICE_LOG(WIIMOTE, "Connected to wiimote [id %i].", wm->unid);
// do the handshake
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
@@ -278,7 +278,7 @@ int wiiuse_io_read(struct wiimote_t* wm)
if (select(wm->in_sock + 1, &fds, NULL, NULL, &tv) == -1)
{
- WIIUSE_ERROR("Unable to select() the wiimote interrupt socket(s).");
+ ERROR_LOG(WIIMOTE, "Unable to select() the wiimote interrupt socket(s).");
perror("Error Details");
return 0;
}
@@ -295,13 +295,13 @@ int wiiuse_io_read(struct wiimote_t* wm)
if (r == -1)
{
// error reading data
- WIIUSE_ERROR("Receiving wiimote data (id %i).", wm->unid);
+ ERROR_LOG(WIIMOTE, "Receiving wiimote data (id %i).", wm->unid);
perror("Error Details");
if (errno == ENOTCONN)
{
// this can happen if the bluetooth dongle is disconnected
- WIIUSE_ERROR("Bluetooth appears to be disconnected. Wiimote unid %i will be disconnected.", wm->unid);
+ ERROR_LOG(WIIMOTE, "Bluetooth appears to be disconnected. Wiimote unid %i will be disconnected.", wm->unid);
wiiuse_disconnect(wm);
wm->event = WIIUSE_UNEXPECTED_DISCONNECT;
}
diff --git a/Externals/WiiUse/Src/io_osx.m b/Source/Core/wiiuse/Src/io_osx.m
similarity index 91%
rename from Externals/WiiUse/Src/io_osx.m
rename to Source/Core/wiiuse/Src/io_osx.m
index c89b69523c..3ad835b7ea 100644
--- a/Externals/WiiUse/Src/io_osx.m
+++ b/Source/Core/wiiuse/Src/io_osx.m
@@ -72,7 +72,7 @@ volatile int reader, writer, outstanding, watermark;
- (void) deviceInquiryDeviceFound: (IOBluetoothDeviceInquiry *) sender
device: (IOBluetoothDevice *) device
{
- WIIUSE_INFO("Discovered bluetooth device at %s: %s",
+ NOTICE_LOG(WIIMOTE, "Discovered bluetooth device at %s: %s",
[[device getAddressString] UTF8String],
[[device getName] UTF8String]);
@@ -92,12 +92,12 @@ volatile int reader, writer, outstanding, watermark;
// IOBluetoothDevice *device = [l2capChannel getDevice];
if (length > MAX_PAYLOAD) {
- WIIUSE_WARNING("Dropping wiimote packet - too large");
+ WARN_LOG(WIIMOTE, "Dropping wiimote packet - too large");
return;
}
if (queue[writer].len != 0) {
- WIIUSE_WARNING("Dropping wiimote packet - queue full");
+ WARN_LOG(WIIMOTE, "Dropping wiimote packet - queue full");
return;
}
@@ -111,7 +111,7 @@ volatile int reader, writer, outstanding, watermark;
if (outstanding > watermark) {
watermark = outstanding;
- WIIUSE_WARNING("New wiimote queue watermark %d", watermark);
+ WARN_LOG(WIIMOTE, "New wiimote queue watermark %d", watermark);
}
CFRunLoopStop(CFRunLoopGetCurrent());
@@ -123,7 +123,7 @@ volatile int reader, writer, outstanding, watermark;
{
// IOBluetoothDevice *device = [l2capChannel getDevice];
- WIIUSE_WARNING("L2CAP channel was closed");
+ WARN_LOG(WIIMOTE, "L2CAP channel was closed");
if (l2capChannel == cchan)
cchan = nil;
@@ -161,7 +161,7 @@ int wiiuse_find(struct wiimote_t **wm, int max_wiimotes, int timeout)
bth = [[IOBluetoothHostController alloc] init];
if ([bth addressAsString] == nil)
{
- WIIUSE_WARNING("No bluetooth host controller");
+ WARN_LOG(WIIMOTE, "No bluetooth host controller");
[bth release];
return 0;
}
@@ -181,14 +181,14 @@ int wiiuse_find(struct wiimote_t **wm, int max_wiimotes, int timeout)
if (ret == kIOReturnSuccess)
[bti retain];
else
- WIIUSE_ERROR("Unable to do bluetooth discovery");
+ ERROR_LOG(WIIMOTE, "Unable to do bluetooth discovery");
CFRunLoopRun();
[bti stop];
found_devices = [[bti foundDevices] count];
- WIIUSE_INFO("Found %i bluetooth device(s).", found_devices);
+ NOTICE_LOG(WIIMOTE, "Found %i bluetooth device(s).", found_devices);
en = [[bti foundDevices] objectEnumerator];
for (i = 0; i < found_devices; i++) {
@@ -258,11 +258,11 @@ static int wiiuse_connect_single(struct wiimote_t *wm, char *address)
[btd openL2CAPChannelSync: &ichan
withPSM: kBluetoothL2CAPPSMHIDInterrupt delegate: cbt];
if (ichan == NULL || cchan == NULL) {
- WIIUSE_ERROR("Unable to open L2CAP channels");
+ ERROR_LOG(WIIMOTE, "Unable to open L2CAP channels");
wiiuse_disconnect(wm);
}
- WIIUSE_INFO("Connected to wiimote [id %i].", wm->unid);
+ NOTICE_LOG(WIIMOTE, "Connected to wiimote [id %i].", wm->unid);
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
wiiuse_set_report_type(wm);
@@ -289,7 +289,7 @@ void wiiuse_disconnect(struct wiimote_t *wm)
if (wm == NULL)
return;
- WIIUSE_INFO("Disconnecting wiimote [id %i]", wm->unid);
+ NOTICE_LOG(WIIMOTE, "Disconnecting wiimote [id %i]", wm->unid);
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
diff --git a/Externals/WiiUse/Src/io_win.c b/Source/Core/wiiuse/Src/io_win.cpp
similarity index 68%
rename from Externals/WiiUse/Src/io_win.c
rename to Source/Core/wiiuse/Src/io_win.cpp
index 4ce16d46b5..4ec7a05b0f 100644
--- a/Externals/WiiUse/Src/io_win.c
+++ b/Source/Core/wiiuse/Src/io_win.cpp
@@ -37,13 +37,57 @@
#include
#include
-#include
#include
#include
#include "definitions.h"
#include "wiiuse_internal.h"
+#include
+
+typedef struct _HIDD_ATTRIBUTES {
+ ULONG Size;
+ USHORT VendorID;
+ USHORT ProductID;
+ USHORT VersionNumber;
+} HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
+
+typedef VOID (__stdcall *PHidD_GetHidGuid)(LPGUID);
+typedef BOOLEAN (__stdcall *PHidD_GetAttributes)(HANDLE, PHIDD_ATTRIBUTES);
+typedef BOOLEAN (__stdcall *PHidD_SetOutputReport)(HANDLE, PVOID, ULONG);
+
+PHidD_GetHidGuid HidD_GetHidGuid = NULL;
+PHidD_GetAttributes HidD_GetAttributes = NULL;
+PHidD_SetOutputReport HidD_SetOutputReport = NULL;
+
+HINSTANCE hid_lib = NULL;
+
+static int initialized = 0;
+
+inline void init_lib()
+{
+ if (!initialized)
+ {
+ hid_lib = LoadLibrary(L"hid.dll");
+ if (!hid_lib)
+ {
+ PanicAlert("Failed to load hid.dll");
+ exit(EXIT_FAILURE);
+ }
+
+ HidD_GetHidGuid = (PHidD_GetHidGuid)GetProcAddress(hid_lib, "HidD_GetHidGuid");
+ HidD_GetAttributes = (PHidD_GetAttributes)GetProcAddress(hid_lib, "HidD_GetAttributes");
+ HidD_SetOutputReport = (PHidD_SetOutputReport)GetProcAddress(hid_lib, "HidD_SetOutputReport");
+ if (!HidD_GetHidGuid || !HidD_GetAttributes || !HidD_SetOutputReport)
+ {
+ PanicAlert("Failed to load hid.dll");
+ exit(EXIT_FAILURE);
+ }
+
+ initialized = true;
+ }
+}
+
int wiiuse_remove(struct wiimote_t** wm, int wiimotes, int max_wiimotes);
int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int wiimotes) {
@@ -56,6 +100,7 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int wiimotes) {
PSP_DEVICE_INTERFACE_DETAIL_DATA detail_data = NULL;
HIDD_ATTRIBUTES attr;
+ init_lib();
// todo: handle/remove (unexpected and forced) disconnected wiimotes here
@@ -85,7 +130,7 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int wiimotes) {
// get the size of the data block required
i = SetupDiGetDeviceInterfaceDetail(device_info, &device_data, NULL, 0, &len, NULL);
- detail_data = malloc(len);
+ detail_data = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(len);
detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
// query the data for this device
@@ -143,7 +188,7 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int wiimotes) {
}
memcpy(wm[wiimotes]->devicepath,detail_data->DevicePath,197);
- WIIUSE_INFO("Connected to wiimote [id %i].", wm[wiimotes]->unid);
+ NOTICE_LOG(WIIMOTE, "Connected to wiimote [id %i].", wm[wiimotes]->unid);
++wiimotes;
} else {
@@ -160,9 +205,14 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int wiimotes) {
return wiimotes;
}
-int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
- int i,connected=0;
- for (i = 0; i < wiimotes; ++i) {
+int wiiuse_connect(struct wiimote_t** wm, int wiimotes)
+{
+ int i, connected = 0;
+
+ init_lib();
+
+ for (i = 0; i < wiimotes; ++i)
+ {
if (WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_CONNECTED))
++connected;
}
@@ -170,7 +220,10 @@ int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
return connected;
}
-void wiiuse_disconnect(struct wiimote_t* wm) {
+void wiiuse_disconnect(struct wiimote_t* wm)
+{
+ init_lib();
+
if (!wm || WIIMOTE_IS_CONNECTED(wm))
return;
@@ -185,9 +238,12 @@ void wiiuse_disconnect(struct wiimote_t* wm) {
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
}
-int wiiuse_io_read(struct wiimote_t* wm) {
+int wiiuse_io_read(struct wiimote_t* wm)
+{
DWORD b, r;
+ init_lib();
+
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return 0;
@@ -207,13 +263,13 @@ int wiiuse_io_read(struct wiimote_t* wm) {
/* timeout - cancel and continue */
if (*wm->event_buf)
- WIIUSE_WARNING("Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
+ WARN_LOG(WIIMOTE, "Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
CancelIo(wm->dev_handle);
ResetEvent(wm->hid_overlap.hEvent);
return 0;
} else if (r == WAIT_FAILED) {
- WIIUSE_WARNING("A wait error occured on reading from wiimote %i.", wm->unid);
+ WARN_LOG(WIIMOTE, "A wait error occured on reading from wiimote %i.", wm->unid);
return 0;
}
@@ -230,10 +286,13 @@ int wiiuse_io_read(struct wiimote_t* wm) {
return 1;
}
-int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
+int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len)
+{
DWORD bytes, dw;
int i;
+ init_lib();
+
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return 0;
@@ -257,20 +316,20 @@ int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
//995 = The I/O operation has been aborted because of either a thread exit or an application request.
if ( (dw == 121) || (dw == 995) ) {
- WIIUSE_INFO("wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: WIIUSE_UNEXPECTED_DISCONNECT");
+ NOTICE_LOG(WIIMOTE, "wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: WIIUSE_UNEXPECTED_DISCONNECT");
wiiuse_disconnected(wm);
wm->event = WIIUSE_UNEXPECTED_DISCONNECT;
}
- else WIIUSE_ERROR("wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: WIIUSE_UNEXPECTED_DISCONNECT ERROR: %08x", dw);
+ else ERROR_LOG(WIIMOTE, "wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: WIIUSE_UNEXPECTED_DISCONNECT ERROR: %08x", dw);
--------------------------------------------------------------*/
//If the part below causes trouble on WIDCOMM/TOSHIBA stack uncomment the lines above, and comment out the 3 lines below instead.
- WIIUSE_INFO("wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: WIIUSE_UNEXPECTED_DISCONNECT - time out");
+ NOTICE_LOG(WIIMOTE, "wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: WIIUSE_UNEXPECTED_DISCONNECT - time out");
wiiuse_disconnected(wm);
wm->event = WIIUSE_UNEXPECTED_DISCONNECT;
- //WIIUSE_ERROR("wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: Unable to determine bluetooth stack type || Wiimote timed out.");
+ //ERROR_LOG(WIIMOTE, "wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: Unable to determine bluetooth stack type || Wiimote timed out.");
return 0;
}
@@ -279,12 +338,12 @@ int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
dw = GetLastError();
if (dw == 121) { // semaphore timeout
- WIIUSE_INFO("wiiuse_io_write[WIIUSE_STACK_MS]: WIIUSE_UNEXPECTED_DISCONNECT");
+ NOTICE_LOG(WIIMOTE, "wiiuse_io_write[WIIUSE_STACK_MS]: WIIUSE_UNEXPECTED_DISCONNECT");
wiiuse_disconnected(wm);
wm->event = WIIUSE_UNEXPECTED_DISCONNECT;
return 0;
}/* else if (dw)
- WIIUSE_ERROR("wiiuse_io_write[WIIUSE_STACK_MS]: WIIUSE_UNEXPECTED_DISCONNECT ERROR: %08x", dw);
+ ERROR_LOG(WIIMOTE, "wiiuse_io_write[WIIUSE_STACK_MS]: WIIUSE_UNEXPECTED_DISCONNECT ERROR: %08x", dw);
*/
// it is not important to catch all errors here at this place, rest will be covered by io_reads.
return i;
@@ -298,58 +357,67 @@ int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
//Checks if the corresponding device to a system notification is a wiimote
//I placed the code here to avoid ddk/wdk dependencies @wiimote plugin
-int wiiuse_check_system_notification(unsigned int nMsg, WPARAM wParam, LPARAM lParam) {
- PDEV_BROADCAST_HDR pDevice = (PDEV_BROADCAST_HDR)lParam;
+int wiiuse_check_system_notification(unsigned int nMsg, WPARAM wParam, LPARAM lParam)
+{
+ PDEV_BROADCAST_HDR pDevice = (PDEV_BROADCAST_HDR)lParam;
- switch( pDevice->dbch_devicetype ) {
+ init_lib();
- case DBT_DEVTYP_DEVICEINTERFACE:
+ switch(pDevice->dbch_devicetype)
+ {
+ case DBT_DEVTYP_DEVICEINTERFACE:
+ {
+ PDEV_BROADCAST_DEVICEINTERFACE pDeviceInfo = (PDEV_BROADCAST_DEVICEINTERFACE)pDevice;
+ HIDD_ATTRIBUTES attr;
+ char stringbuf[255];
+
+ HANDLE dev = CreateFile(pDeviceInfo->dbcc_name,
+ 0,(FILE_SHARE_READ | FILE_SHARE_WRITE),
+ NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
+
+ if (dev != INVALID_HANDLE_VALUE)
{
- PDEV_BROADCAST_DEVICEINTERFACE pDeviceInfo = (PDEV_BROADCAST_DEVICEINTERFACE)pDevice;
- HIDD_ATTRIBUTES attr;
- char stringbuf[255];
-
- HANDLE dev = CreateFile(pDeviceInfo->dbcc_name,
- 0,(FILE_SHARE_READ | FILE_SHARE_WRITE),
- NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
-
- if (dev != INVALID_HANDLE_VALUE)
- {
- attr.Size = sizeof(attr);
- HidD_GetAttributes(dev, &attr);
-
- //Checking PID&VID
- if ((attr.VendorID == WM_VENDOR_ID) && (attr.ProductID == WM_PRODUCT_ID)) {
- CloseHandle(dev);
- return 1;
- }
+ attr.Size = sizeof(attr);
+ HidD_GetAttributes(dev, &attr);
+ //Checking PID&VID
+ if ((attr.VendorID == WM_VENDOR_ID) && (attr.ProductID == WM_PRODUCT_ID)) {
CloseHandle(dev);
- }
- else { //different method to acquire the "wiimote vid/pid" for a comparison when the device is already unavailable @CreateFile()
-
- wcstombs(stringbuf, pDeviceInfo->dbcc_name, 255);
- //ms bt stack + bluesoleil vid/pid dbccname format
- if ( (strstr(stringbuf, "VID&0002057e_PID&0306") != NULL) || (strstr(stringbuf, "VID_057e&PID_0306") != NULL) )
- {
- return 1;
- }
+ return 1;
}
- return 0;
+ CloseHandle(dev);
+ }
+ else
+ {
+ // different method to acquire the "wiimote vid/pid" for a
+ // comparison when the device is already unavailable @CreateFile()
+ wcstombs(stringbuf, pDeviceInfo->dbcc_name, 255);
+ //ms bt stack + bluesoleil vid/pid dbccname format
+ if ( (strstr(stringbuf, "VID&0002057e_PID&0306") != NULL) ||
+ (strstr(stringbuf, "VID_057e&PID_0306") != NULL) )
+ {
+ return 1;
+ }
}
- default:
return 0;
-
}
+
+ default:
+ return 0;
+
+ }
return 0;
}
//register a handle for device notifications
-int wiiuse_register_system_notification(HWND hwnd) {
+int wiiuse_register_system_notification(HWND hwnd)
+{
DEV_BROADCAST_DEVICEINTERFACE Filter;
- ZeroMemory( &Filter, sizeof(Filter) );
+ ZeroMemory(&Filter, sizeof(Filter));
+
+ init_lib();
//GUID wiimoteguid;
//CLSIDFromString(_T("745a17a0-74d3-11d0-b6fe-00a0c90f57da"),&wiimoteguid);
@@ -357,12 +425,13 @@ int wiiuse_register_system_notification(HWND hwnd) {
Filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
//Filter.dbcc_classguid = wiimoteguid;
- return RegisterDeviceNotification(hwnd,&Filter, DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);
+ return (int)RegisterDeviceNotification(hwnd, &Filter, DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);
}
-int wiiuse_remove(struct wiimote_t** wm, int wiimotes, int max_wiimotes) {
+int wiiuse_remove(struct wiimote_t** wm, int wiimotes, int max_wiimotes)
+{
int i = 0;
- WIIUSE_INFO("Remove Wiimotes, WM: %i MAX_WM: %i",wiimotes, max_wiimotes);
+ NOTICE_LOG(WIIMOTE, "Remove Wiimotes, WM: %i MAX_WM: %i",wiimotes, max_wiimotes);
//No cleanup needed, less wiimotes available than needed
if (wiimotes <= max_wiimotes)
diff --git a/Externals/WiiUse/Src/ir.c b/Source/Core/wiiuse/Src/ir.cpp
similarity index 97%
rename from Externals/WiiUse/Src/ir.c
rename to Source/Core/wiiuse/Src/ir.cpp
index 9e9206bbbb..f1bcb31bf0 100644
--- a/Externals/WiiUse/Src/ir.c
+++ b/Source/Core/wiiuse/Src/ir.cpp
@@ -131,5 +131,5 @@ void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level) {
wiiuse_write_data(wm, WM_REG_IR_BLOCK1, (byte*)block1, 9);
wiiuse_write_data(wm, WM_REG_IR_BLOCK2, (byte*)block2, 2);
- WIIUSE_DEBUG("Set IR sensitivity to level %i (unid %i)", level, wm->unid);
+ DEBUG_LOG(WIIMOTE, "Set IR sensitivity to level %i (unid %i)", level, wm->unid);
}
diff --git a/Externals/WiiUse/Src/wiiuse.c b/Source/Core/wiiuse/Src/wiiuse.cpp
similarity index 96%
rename from Externals/WiiUse/Src/wiiuse.c
rename to Source/Core/wiiuse/Src/wiiuse.cpp
index a54c1610aa..cc45638b4e 100644
--- a/Externals/WiiUse/Src/wiiuse.c
+++ b/Source/Core/wiiuse/Src/wiiuse.cpp
@@ -68,7 +68,7 @@ void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes) {
if (!wm)
return;
- WIIUSE_INFO("wiiuse clean up...");
+ NOTICE_LOG(WIIMOTE, "wiiuse clean up...");
for (; i < wiimotes; ++i) {
wiiuse_disconnect(wm[i]);
@@ -150,7 +150,7 @@ struct wiimote_t** wiiuse_init(int wiimotes) {
void wiiuse_disconnected(struct wiimote_t* wm) {
if (!wm) return;
- WIIUSE_INFO("Wiimote disconnected [id %i].", wm->unid);
+ NOTICE_LOG(WIIMOTE, "Wiimote disconnected [id %i].", wm->unid);
/* disable the connected flag */
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
@@ -188,11 +188,11 @@ void wiiuse_rumble(struct wiimote_t* wm, int status) {
buf = wm->leds;
if (status) {
- WIIUSE_DEBUG("Starting rumble...");
+ DEBUG_LOG(WIIMOTE, "Starting rumble...");
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_RUMBLE);
buf |= 0x01;
} else {
- WIIUSE_DEBUG("Stopping rumble...");
+ DEBUG_LOG(WIIMOTE, "Stopping rumble...");
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_RUMBLE);
}
@@ -261,7 +261,7 @@ int wiiuse_set_report_type(struct wiimote_t* wm) {
buf[1] = 0x30;
- WIIUSE_DEBUG("Setting report type: 0x%x", buf[1]);
+ DEBUG_LOG(WIIMOTE, "Setting report type: 0x%x", buf[1]);
expansion = wiiuse_send(wm, WM_CMD_REPORT_TYPE, buf, 2);
if (expansion <= 0)
@@ -288,7 +288,7 @@ int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte
if (!data || !len)
return 0;
- WIIUSE_DEBUG("Writing %i bytes to memory location 0x%x...", len, addr);
+ DEBUG_LOG(WIIMOTE, "Writing %i bytes to memory location 0x%x...", len, addr);
#ifdef WITH_WIIUSE_DEBUG
{
diff --git a/Externals/WiiUse/Src/wiiuse.h b/Source/Core/wiiuse/Src/wiiuse.h
similarity index 74%
rename from Externals/WiiUse/Src/wiiuse.h
rename to Source/Core/wiiuse/Src/wiiuse.h
index a7b18ce174..a9049b0a59 100644
--- a/Externals/WiiUse/Src/wiiuse.h
+++ b/Source/Core/wiiuse/Src/wiiuse.h
@@ -185,63 +185,37 @@ typedef struct wiimote_t {
*
*****************************************/
-#define WIIUSE_COMPILE_LIB
-
-#ifdef _WIN32
- #define WIIUSE_EXPORT_DECL __declspec(dllexport)
- #define WIIUSE_IMPORT_DECL __declspec(dllimport)
-#else
- #define WIIUSE_EXPORT_DECL
- #define WIIUSE_IMPORT_DECL
-#endif
-
-#ifdef WIIUSE_COMPILE_LIB
- #define WIIUSE_EXPORT WIIUSE_EXPORT_DECL
-#else
- #define WIIUSE_EXPORT WIIUSE_IMPORT_DECL
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* wiiuse.c */
-WIIUSE_EXPORT extern const char* wiiuse_version();
+extern const char* wiiuse_version();
-WIIUSE_EXPORT extern struct wiimote_t** wiiuse_init(int wiimotes);
-WIIUSE_EXPORT extern void wiiuse_disconnected(struct wiimote_t* wm);
-WIIUSE_EXPORT extern void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes);
-WIIUSE_EXPORT extern void wiiuse_rumble(struct wiimote_t* wm, int status);
-WIIUSE_EXPORT extern void wiiuse_set_leds(struct wiimote_t* wm, int leds);
-WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len);
+extern struct wiimote_t** wiiuse_init(int wiimotes);
+extern void wiiuse_disconnected(struct wiimote_t* wm);
+extern void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes);
+extern void wiiuse_rumble(struct wiimote_t* wm, int status);
+extern void wiiuse_set_leds(struct wiimote_t* wm, int leds);
+extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len);
/* connect.c / io_win.c */
#ifdef _WIN32
-WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int wiimotes);
+extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int wiimotes);
#else
-WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout);
+extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout);
#endif
-WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes);
-WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm);
-WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte timeout);
+extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes);
+extern void wiiuse_disconnect(struct wiimote_t* wm);
+extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte timeout);
#ifdef _WIN32
-WIIUSE_EXPORT extern int wiiuse_check_system_notification(unsigned int nMsg, WPARAM wParam, LPARAM lParam);
-WIIUSE_EXPORT extern int wiiuse_register_system_notification(HWND hwnd);
+extern int wiiuse_check_system_notification(unsigned int nMsg, WPARAM wParam, LPARAM lParam);
+extern int wiiuse_register_system_notification(HWND hwnd);
#endif
/* ir.c */
-WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level);
+extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level);
/* io.c */
-WIIUSE_EXPORT extern int wiiuse_io_read(struct wiimote_t* wm);
-WIIUSE_EXPORT extern int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len);
-
-
-#ifdef __cplusplus
-}
-#endif
-
+extern int wiiuse_io_read(struct wiimote_t* wm);
+extern int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len);
#endif /* WIIUSE_H_INCLUDED */
diff --git a/Externals/WiiUse/Src/wiiuse_internal.h b/Source/Core/wiiuse/Src/wiiuse_internal.h
similarity index 98%
rename from Externals/WiiUse/Src/wiiuse_internal.h
rename to Source/Core/wiiuse/Src/wiiuse_internal.h
index 2308632cc3..391bbd89c9 100644
--- a/Externals/WiiUse/Src/wiiuse_internal.h
+++ b/Source/Core/wiiuse/Src/wiiuse_internal.h
@@ -156,16 +156,8 @@
#include "wiiuse.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* not part of the api */
int wiiuse_set_report_type(struct wiimote_t* wm);
int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* WIIUSE_INTERNAL_H_INCLUDED */
diff --git a/Externals/WiiUse/wiiuse.sln b/Source/Core/wiiuse/wiiuse.sln
similarity index 100%
rename from Externals/WiiUse/wiiuse.sln
rename to Source/Core/wiiuse/wiiuse.sln
diff --git a/Externals/WiiUse/wiiuse.vcproj b/Source/Core/wiiuse/wiiuse.vcproj
similarity index 84%
rename from Externals/WiiUse/wiiuse.vcproj
rename to Source/Core/wiiuse/wiiuse.vcproj
index 278d350943..d9bc4337d6 100644
--- a/Externals/WiiUse/wiiuse.vcproj
+++ b/Source/Core/wiiuse/wiiuse.vcproj
@@ -43,7 +43,8 @@
@@ -374,7 +378,7 @@
Name="Wiimote Data"
>
@@ -383,7 +387,7 @@
>