diff --git a/Externals/WiiUse/Win32/wiiuse.dll b/Externals/WiiUse/Win32/wiiuse.dll index 6a7d581c08..9b86e1aa18 100644 Binary files a/Externals/WiiUse/Win32/wiiuse.dll and b/Externals/WiiUse/Win32/wiiuse.dll differ diff --git a/Externals/WiiUse/Win32/wiiuse.lib b/Externals/WiiUse/Win32/wiiuse.lib index 08b322dc03..d4d8af08d5 100644 Binary files a/Externals/WiiUse/Win32/wiiuse.lib and b/Externals/WiiUse/Win32/wiiuse.lib differ diff --git a/Externals/WiiUse/X64/wiiuse.dll b/Externals/WiiUse/X64/wiiuse.dll index 3eb2c29b98..8a8191bac9 100644 Binary files a/Externals/WiiUse/X64/wiiuse.dll and b/Externals/WiiUse/X64/wiiuse.dll differ diff --git a/Externals/WiiUse/X64/wiiuse.lib b/Externals/WiiUse/X64/wiiuse.lib index fe5e434aaa..d98cbbff85 100644 Binary files a/Externals/WiiUse/X64/wiiuse.lib and b/Externals/WiiUse/X64/wiiuse.lib differ diff --git a/Externals/WiiUseSrc/Src/io_win.c b/Externals/WiiUseSrc/Src/io_win.c index ab08183ba9..15c68b0d84 100644 --- a/Externals/WiiUseSrc/Src/io_win.c +++ b/Externals/WiiUseSrc/Src/io_win.c @@ -38,6 +38,7 @@ #include #include +#include #include #include "definitions.h" @@ -283,4 +284,68 @@ int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) { return 0; } +//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; + + 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) + { + 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; + } + + 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 0; + } + + default: + return 0; + + } + return 0; +} + +//register a handle for device notifications +int wiiuse_register_system_notification(HWND hwnd) { + DEV_BROADCAST_DEVICEINTERFACE Filter; + ZeroMemory( &Filter, sizeof(Filter) ); + + //GUID wiimoteguid; + //CLSIDFromString(_T("745a17a0-74d3-11d0-b6fe-00a0c90f57da"),&wiimoteguid); + Filter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); + Filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; + //Filter.dbcc_classguid = wiimoteguid; + + return RegisterDeviceNotification(hwnd,&Filter, DEVICE_NOTIFY_ALL_INTERFACE_CLASSES); +} #endif /* ifdef WIN32 */ diff --git a/Externals/WiiUseSrc/Src/wiiuse.h b/Externals/WiiUseSrc/Src/wiiuse.h index 5633fbed90..1df11b06b0 100644 --- a/Externals/WiiUseSrc/Src/wiiuse.h +++ b/Externals/WiiUseSrc/Src/wiiuse.h @@ -673,10 +673,12 @@ WIIUSE_EXPORT extern void wiiuse_resync(struct wiimote_t* wm); WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout); WIIUSE_EXPORT extern void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold); -/* connect.c */ +/* connect.c / io_win.c */ WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout); 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 int wiiuse_check_system_notification(unsigned int nMsg, WPARAM wParam, LPARAM lParam); +WIIUSE_EXPORT extern int wiiuse_register_system_notification(HWND hwnd); /* events.c */ WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes);