Just a small WIIUSE[WIN32] update to avoid dependencies @wiimote_plugin in my next commit.
You can check whether WM_DEVICECHANGE got triggered by a Wiimote.(Pair-up arrival/removal) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5410 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
98bd41385d
commit
06f0bc91ee
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include <windows.h>
|
||||
#include <hidsdi.h>
|
||||
#include <dbt.h>
|
||||
#include <setupapi.h>
|
||||
|
||||
#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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue