diff --git a/cpp/wiiscan/.cproject b/cpp/wiiscan/.cproject
new file mode 100644
index 0000000..17050d9
--- /dev/null
+++ b/cpp/wiiscan/.cproject
@@ -0,0 +1,152 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cpp/wiiscan/.project b/cpp/wiiscan/.project
new file mode 100644
index 0000000..1368c5c
--- /dev/null
+++ b/cpp/wiiscan/.project
@@ -0,0 +1,71 @@
+
+
+ Wiiscan
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ make
+
+
+ org.eclipse.cdt.make.core.buildLocation
+ ${workspace_loc:/Wiiscan/Release}
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ true
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.core.ccnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+
+
diff --git a/cpp/wiiscan/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/cpp/wiiscan/.settings/org.eclipse.cdt.managedbuilder.core.prefs
new file mode 100644
index 0000000..14ad3ce
--- /dev/null
+++ b/cpp/wiiscan/.settings/org.eclipse.cdt.managedbuilder.core.prefs
@@ -0,0 +1,14 @@
+#Sat Oct 15 11:50:13 CEST 2011
+eclipse.preferences.version=1
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/CPATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/CPATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/CPLUS_INCLUDE_PATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/CPLUS_INCLUDE_PATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/C_INCLUDE_PATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/C_INCLUDE_PATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/append=true
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/appendContributed=true
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/LIBRARY_PATH/delimiter=;
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/LIBRARY_PATH/operation=remove
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/append=true
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1147005981/appendContributed=true
diff --git a/cpp/wiiscan/_Lib/Debug/WiimoteLib.dll b/cpp/wiiscan/_Lib/Debug/WiimoteLib.dll
deleted file mode 100644
index da8e126..0000000
Binary files a/cpp/wiiscan/_Lib/Debug/WiimoteLib.dll and /dev/null differ
diff --git a/cpp/wiiscan/_Lib/Debug/WiimoteWhiteboard.exe b/cpp/wiiscan/_Lib/Debug/WiimoteWhiteboard.exe
deleted file mode 100644
index 28f2c9f..0000000
Binary files a/cpp/wiiscan/_Lib/Debug/WiimoteWhiteboard.exe and /dev/null differ
diff --git a/cpp/wiiscan/_Lib/Debug/wiimotelibpoll.exe b/cpp/wiiscan/_Lib/Debug/wiimotelibpoll.exe
deleted file mode 100644
index 72937a2..0000000
Binary files a/cpp/wiiscan/_Lib/Debug/wiimotelibpoll.exe and /dev/null differ
diff --git a/cpp/wiiscan/_Lib/DelcomDLL.dll b/cpp/wiiscan/_Lib/DelcomDLL.dll
deleted file mode 100644
index ecfa470..0000000
Binary files a/cpp/wiiscan/_Lib/DelcomDLL.dll and /dev/null differ
diff --git a/cpp/wiiscan/_Lib/DelcomDLL.lib b/cpp/wiiscan/_Lib/DelcomDLL.lib
deleted file mode 100644
index 0c540c6..0000000
Binary files a/cpp/wiiscan/_Lib/DelcomDLL.lib and /dev/null differ
diff --git a/cpp/wiiscan/_Lib/Release/WiimoteLib.dll b/cpp/wiiscan/_Lib/Release/WiimoteLib.dll
deleted file mode 100644
index 4408358..0000000
Binary files a/cpp/wiiscan/_Lib/Release/WiimoteLib.dll and /dev/null differ
diff --git a/cpp/wiiscan/_Lib/Release/WiimoteWhiteboard.exe b/cpp/wiiscan/_Lib/Release/WiimoteWhiteboard.exe
deleted file mode 100644
index 1ca21b8..0000000
Binary files a/cpp/wiiscan/_Lib/Release/WiimoteWhiteboard.exe and /dev/null differ
diff --git a/cpp/wiiscan/_Lib/Release/wiimotelibpoll.exe b/cpp/wiiscan/_Lib/Release/wiimotelibpoll.exe
deleted file mode 100644
index 7e13580..0000000
Binary files a/cpp/wiiscan/_Lib/Release/wiimotelibpoll.exe and /dev/null differ
diff --git a/cpp/wiiscan/_Lib/USBm.dll b/cpp/wiiscan/_Lib/USBm.dll
deleted file mode 100644
index 1460ff3..0000000
Binary files a/cpp/wiiscan/_Lib/USBm.dll and /dev/null differ
diff --git a/cpp/wiiscan/_Lib/wiiuse.dll b/cpp/wiiscan/_Lib/wiiuse.dll
deleted file mode 100644
index a7e228c..0000000
Binary files a/cpp/wiiscan/_Lib/wiiuse.dll and /dev/null differ
diff --git a/cpp/wiiscan/_Lib/wiiuse.lib b/cpp/wiiscan/_Lib/wiiuse.lib
deleted file mode 100644
index 4f1b69b..0000000
Binary files a/cpp/wiiscan/_Lib/wiiuse.lib and /dev/null differ
diff --git a/cpp/wiiscan/include/BluetoothAPIs.h b/cpp/wiiscan/include/BluetoothAPIs.h
new file mode 100644
index 0000000..0027b2b
--- /dev/null
+++ b/cpp/wiiscan/include/BluetoothAPIs.h
@@ -0,0 +1,1540 @@
+
+//
+// Copyright 2002 - Microsoft Corporation
+//
+// Created By:
+// Geoff Pease (GPease) 12-JAN-2002
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#define BLUETOOTH_MAX_NAME_SIZE (248)
+#define BLUETOOTH_MAX_PASSKEY_SIZE (16)
+#define BLUETOOTH_MAX_PASSKEY_BUFFER_SIZE (BLUETOOTH_MAX_PASSKEY_SIZE + 1)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ***************************************************************************
+//
+// Bluetooth Address
+//
+// ***************************************************************************
+
+typedef ULONGLONG BTH_ADDR;
+
+typedef struct _BLUETOOTH_ADDRESS {
+ union {
+ BTH_ADDR ullLong; // easier to compare again BLUETOOTH_NULL_ADDRESS
+ BYTE rgBytes[ 6 ]; // easier to format when broken out
+ };
+
+} BLUETOOTH_ADDRESS_STRUCT;
+
+#define BLUETOOTH_ADDRESS BLUETOOTH_ADDRESS_STRUCT
+
+#define BLUETOOTH_NULL_ADDRESS ( (ULONGLONG) 0x0 )
+
+// ***************************************************************************
+//
+// Radio Enumeration
+//
+// Description:
+// This group of APIs enumerates the installed Bluetooth radios.
+//
+// Sample Usage:
+// HANDLE hRadio;
+// BLUETOOTH_FIND_RADIO_PARAMS btfrp = { sizeof(btfrp) };
+//
+// HBLUETOOTH_RADIO_FIND hFind = BluetoothFindFirstRadio( &btfrp, &hRadio );
+// if ( NULL != hFind )
+// {
+// do
+// {
+// //
+// // TODO: Do something with the radio handle.
+// //
+//
+// CloseHandle( hRadio );
+//
+// } while( BluetoothFindNextRadio( hFind, &hRadio ) );
+//
+// BluetoothFindRadioClose( hFind );
+// }
+//
+// ***************************************************************************
+
+typedef struct _BLUETOOTH_FIND_RADIO_PARAMS {
+ DWORD dwSize; // IN sizeof this structure
+
+} BLUETOOTH_FIND_RADIO_PARAMS;
+
+typedef HANDLE HBLUETOOTH_RADIO_FIND;
+
+//
+// Description:
+// Begins the enumeration of local Bluetooth radios.
+//
+// Parameters:
+// pbtfrp
+// A pointer to a BLUETOOTH_FIND_RADIO_PARAMS structure. The dwSize
+// member of this structure must match the sizeof the of the structure.
+//
+// phRadio
+// A pointer where the first radio HANDLE enumerated will be returned.
+//
+// Return Values:
+// NULL
+// Error opening radios or no devices found. Use GetLastError() for
+// more info.
+//
+// ERROR_INVALID_PARAMETER
+// pbtfrp parameter is NULL.
+//
+// ERROR_REVISION_MISMATCH
+// The pbtfrp structure is not the right length.
+//
+// ERROR_OUTOFMEMORY
+// Out of memory.
+//
+// other Win32 errors.
+//
+// any other
+// Success. The return handle is valid and phRadio points to a valid handle.
+//
+HBLUETOOTH_RADIO_FIND
+WINAPI
+BluetoothFindFirstRadio(
+ BLUETOOTH_FIND_RADIO_PARAMS * pbtfrp,
+ HANDLE * phRadio
+ );
+
+//
+// Description:
+// Finds the next installed Bluetooth radio.
+//
+// Parameters:
+// hFind
+// The handle returned by BluetoothFindFirstRadio().
+//
+// phRadio
+// A pointer where the next radio HANDLE enumerated will be returned.
+//
+// Return Values:
+// TRUE
+// Next device succesfully found. pHandleOut points to valid handle.
+//
+// FALSE
+// No device found. pHandleOut points to an invalid handle. Call
+// GetLastError() for more details.
+//
+// ERROR_INVALID_HANDLE
+// The handle is NULL.
+//
+// ERROR_NO_MORE_ITEMS
+// No more radios found.
+//
+// ERROR_OUTOFMEMORY
+// Out of memory.
+//
+// other Win32 errors
+//
+BOOL
+WINAPI
+BluetoothFindNextRadio(
+ HBLUETOOTH_RADIO_FIND hFind,
+ HANDLE * phRadio
+ );
+
+//
+// Description:
+// Closes the enumeration handle.
+//
+// Parameters
+// hFind
+// The handle returned by BluetoothFindFirstRadio().
+//
+// Return Values:
+// TRUE
+// Handle succesfully closed.
+//
+// FALSE
+// Failure. Check GetLastError() for details.
+//
+// ERROR_INVALID_HANDLE
+// The handle is NULL.
+//
+BOOL
+WINAPI
+BluetoothFindRadioClose(
+ HBLUETOOTH_RADIO_FIND hFind
+ );
+
+// ***************************************************************************
+//
+// Radio Information
+//
+// ***************************************************************************
+
+typedef struct _BLUETOOTH_RADIO_INFO {
+ DWORD dwSize; // Size, in bytes, of this entire data structure
+
+ BLUETOOTH_ADDRESS address; // Address of the local radio
+
+ WCHAR szName[ BLUETOOTH_MAX_NAME_SIZE ]; // Name of the local radio
+
+ ULONG ulClassofDevice; // Class of device for the local radio
+
+ USHORT lmpSubversion; // lmpSubversion, manufacturer specifc.
+ USHORT manufacturer; // Manufacturer of the radio, BTH_MFG_Xxx value. For the most up to date
+ // list, goto the Bluetooth specification website and get the Bluetooth
+ // assigned numbers document.
+} BLUETOOTH_RADIO_INFO, *PBLUETOOTH_RADIO_INFO;
+
+//
+// Description:
+// Retrieves the information about the radio represented by the handle.
+//
+// Parameters:
+// hRadio
+// Handle to a local radio retrieved through BluetoothFindFirstRadio()
+// et al or SetupDiEnumerateDeviceInterfaces()
+//
+// pRadioInfo
+// Radio information to be filled in. The dwSize member must match the
+// size of the structure.
+//
+// Return Values:
+// ERROR_SUCCESS
+// The information was retrieved successfully.
+//
+// ERROR_INVALID_PARAMETER
+// pRadioInfo or hRadio is NULL.
+//
+// ERROR_REVISION_MISMATCH
+// pRadioInfo->dwSize is invalid.
+//
+// other Win32 error codes.
+//
+DWORD
+WINAPI
+BluetoothGetRadioInfo(
+ HANDLE hRadio,
+ PBLUETOOTH_RADIO_INFO pRadioInfo
+ );
+
+// ***************************************************************************
+//
+// Device Information Stuctures
+//
+// ***************************************************************************
+
+typedef struct _BLUETOOTH_DEVICE_INFO {
+ DWORD dwSize; // size, in bytes, of this structure - must be the sizeof(BLUETOOTH_DEVICE_INFO)
+
+ BLUETOOTH_ADDRESS Address; // Bluetooth address
+
+ ULONG ulClassofDevice; // Bluetooth "Class of Device"
+
+ BOOL fConnected; // Device connected/in use
+ BOOL fRemembered; // Device remembered
+ BOOL fAuthenticated; // Device authenticated/paired/bonded
+
+ SYSTEMTIME stLastSeen; // Last time the device was seen
+ SYSTEMTIME stLastUsed; // Last time the device was used for other than RNR, inquiry, or SDP
+
+ WCHAR szName[ BLUETOOTH_MAX_NAME_SIZE ]; // Name of the device
+
+} BLUETOOTH_DEVICE_INFO_STRUCT;
+
+#define BLUETOOTH_DEVICE_INFO BLUETOOTH_DEVICE_INFO_STRUCT
+
+typedef BLUETOOTH_DEVICE_INFO * PBLUETOOTH_DEVICE_INFO;
+
+// ***************************************************************************
+//
+// Device Enumeration
+//
+// Description:
+// Enumerates the Bluetooth devices. The types of returned device depends
+// on the flags set in the BLUETOOTH_DEVICE_SEARCH_PARAMS (see structure
+// definition for details).
+//
+// Sample Usage:
+// HBLUETOOTH_DEVICE_FIND hFind;
+// BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = { sizeof(btsp) };
+// BLUETOOTH_DEVICE_INFO btdi = { sizeof(btdi) };
+//
+// btsp.fReturnAuthenticated = TRUE;
+// btsp.fReturnRemembered = TRUE;
+//
+// hFind = BluetoothFindFirstDevice( &btsp, &btdi );
+// if ( NULL != hFind )
+// {
+// do
+// {
+// //
+// // TODO: Do something useful with the device info.
+// //
+//
+// } while( BluetoothFindNextDevice( hFind, &btdi ) );
+//
+// BluetoothFindDeviceClose( hFind );
+// }
+//
+// ***************************************************************************
+
+typedef struct _BLUETOOTH_DEVICE_SEARCH_PARAMS {
+ DWORD dwSize; // IN sizeof this structure
+
+ BOOL fReturnAuthenticated; // IN return authenticated devices
+ BOOL fReturnRemembered; // IN return remembered devices
+ BOOL fReturnUnknown; // IN return unknown devices
+ BOOL fReturnConnected; // IN return connected devices
+
+ BOOL fIssueInquiry; // IN issue a new inquiry
+ UCHAR cTimeoutMultiplier; // IN timeout for the inquiry
+
+ HANDLE hRadio; // IN handle to radio to enumerate - NULL == all radios will be searched
+
+} BLUETOOTH_DEVICE_SEARCH_PARAMS;
+
+typedef HANDLE HBLUETOOTH_DEVICE_FIND;
+
+//
+// Description:
+// Begins the enumeration of Bluetooth devices.
+//
+// Parameters:
+// pbtsp
+// A pointer to a BLUETOOTH_DEVICE_SEARCH_PARAMS structure. This
+// structure contains the flags and inputs used to conduct the search.
+// See BLUETOOTH_DEVICE_SEARCH_PARAMS for details.
+//
+// pbtdi
+// A pointer to a BLUETOOTH_DEVICE_INFO structure to return information
+// about the first Bluetooth device found. Note that the dwSize member
+// of the structure must be the sizeof(BLUETOOTH_DEVICE_INFO) before
+// calling because the APIs hast to know the size of the buffer being
+// past in. The dwSize member must also match the exact
+// sizeof(BLUETOOTH_DEVICE_INFO) or the call will fail.
+//
+// Return Values:
+// NULL
+// Error opening radios or not devices found. Use GetLastError for more info.
+//
+// ERROR_INVALID_PARAMETER
+// pbtsp parameter or pbtdi parameter is NULL.
+//
+// ERROR_REVISION_MISMATCH
+// The pbtfrp structure is not the right length.
+//
+// other Win32 errors
+//
+// any other value
+// Success. The return handle is valid and pbtdi points to valid data.
+//
+HBLUETOOTH_DEVICE_FIND
+WINAPI
+BluetoothFindFirstDevice(
+ BLUETOOTH_DEVICE_SEARCH_PARAMS * pbtsp,
+ BLUETOOTH_DEVICE_INFO * pbtdi
+ );
+
+//
+// Description:
+// Finds the next Bluetooth device in the enumeration.
+//
+// Parameters:
+// hFind
+// The handle returned from BluetoothFindFirstDevice().
+//
+// pbtdi
+// A pointer to a BLUETOOTH_DEVICE_INFO structure to return information
+// about the first Bluetooth device found. Note that the dwSize member
+// of the structure must be the sizeof(BLUETOOTH_DEVICE_INFO) before
+// calling because the APIs hast to know the size of the buffer being
+// past in. The dwSize member must also match the exact
+// sizeof(BLUETOOTH_DEVICE_INFO) or the call will fail.
+//
+// Return Values:
+// TRUE
+// Next device succesfully found. pHandleOut points to valid handle.
+//
+// FALSE
+// No device found. pHandleOut points to an invalid handle. Call
+// GetLastError() for more details.
+//
+// ERROR_INVALID_HANDLE
+// The handle is NULL.
+//
+// ERROR_NO_MORE_ITEMS
+// No more radios found.
+//
+// ERROR_OUTOFMEMORY
+// Out of memory.
+//
+// other Win32 errors
+//
+BOOL
+WINAPI
+BluetoothFindNextDevice(
+ HBLUETOOTH_DEVICE_FIND hFind,
+ BLUETOOTH_DEVICE_INFO * pbtdi
+ );
+
+//
+// Description:
+// Closes the enumeration handle.
+//
+// Parameters:
+// hFind
+// The handle returned from BluetoothFindFirstDevice().
+//
+// Return Values:
+// TRUE
+// Handle succesfully closed.
+//
+// FALSE
+// Failure. Check GetLastError() for details.
+//
+// ERROR_INVALID_HANDLE
+// The handle is NULL.
+//
+BOOL
+WINAPI
+BluetoothFindDeviceClose(
+ HBLUETOOTH_DEVICE_FIND hFind
+ );
+
+//
+// Description:
+// Retrieves information about a remote device.
+//
+// Fill in the dwSize and the Address members of the pbtdi structure
+// being passed in. On success, the rest of the members will be filled
+// out with the information that the system knows.
+//
+// Parameters:
+// hRadio
+// Handle to a local radio retrieved through BluetoothFindFirstRadio()
+// et al or SetupDiEnumerateDeviceInterfaces()
+//
+// pbtdi
+// A pointer to a BLUETOOTH_DEVICE_INFO structure to return information
+// about the first Bluetooth device found. The dwSize member of the
+// structure must be the sizeof the structure in bytes. The Address
+// member must be filled out with the Bluetooth address of the remote
+// device.
+//
+// Return Values:
+// ERROR_SUCCESS
+// Success. Information returned.
+//
+// ERROR_REVISION_MISMATCH
+// The size of the BLUETOOTH_DEVICE_INFO isn't compatible. Check
+// the dwSize member of the BLUETOOTH_DEVICE_INFO structure you
+// passed in.
+//
+// ERROR_NOT_FOUND
+// The radio is not known by the system or the Address field of
+// the BLUETOOTH_DEVICE_INFO structure is all zeros.
+//
+// ERROR_INVALID_PARAMETER
+// pbtdi is NULL.
+//
+// other error codes
+//
+DWORD
+WINAPI
+BluetoothGetDeviceInfo(
+ HANDLE hRadio,
+ BLUETOOTH_DEVICE_INFO * pbtdi
+ );
+
+//
+// Description:
+// Updates the computer local cache about the device.
+//
+// Parameters:
+// pbtdi
+// A pointer to the BLUETOOTH_DEVICE_INFO structure to be updated.
+// The following members must be valid:
+// dwSize
+// Must match the size of the structure.
+// Address
+// Must be a previously found radio address.
+// szName
+// New name to be stored.
+//
+// Return Values:
+// ERROR_SUCCESS
+// The device information was updated successfully.
+//
+// ERROR_INVALID_PARAMETER
+// pbtdi is NULL.
+//
+// ERROR_REVISION_MISMATCH
+// pbtdi->dwSize is invalid.
+//
+// other Win32 error codes.
+//
+DWORD
+WINAPI
+BluetoothUpdateDeviceRecord(
+ BLUETOOTH_DEVICE_INFO * pbtdi
+ );
+
+//
+// Description:
+// Delete the authentication (aka "bond") between the computer and the
+// device. Also purges any cached information about the device.
+//
+// Return Values:
+// ERROR_SUCCESS
+// The device was removed successfully.
+//
+// ERROR_NOT_FOUND
+// The device was not found. If no Bluetooth radio is installed,
+// the devices could not be enumerated or removed.
+//
+DWORD
+WINAPI
+BluetoothRemoveDevice(
+ BLUETOOTH_ADDRESS * pAddress
+ );
+
+// ***************************************************************************
+//
+// Device Picker Dialog
+//
+// Description:
+// Invokes a common dialog for selecting Bluetooth devices. The list
+// of devices displayed to the user is determined by the flags and
+// settings the caller specifies in the BLUETOOTH_SELECT_DEVICE_PARAMS
+// (see structure definition for more details).
+//
+// If BluetoothSelectDevices() returns TRUE, the caller must call
+// BluetoothSelectDevicesFree() or memory will be leaked within the
+// process.
+//
+// Sample Usage:
+//
+// BLUETOOTH_SELECT_DEVICE_PARAMS btsdp = { sizeof(btsdp) };
+//
+// btsdp.hwndParent = hDlg;
+// btsdp.fShowUnknown = TRUE;
+// btsdp.fAddNewDeviceWizard = TRUE;
+//
+// BOOL b = BluetoothSelectDevices( &btsdp );
+// if ( b )
+// {
+// BLUETOOTH_DEVICE_INFO * pbtdi = btsdp.pDevices;
+// for ( ULONG cDevice = 0; cDevice < btsdp.cNumDevices; cDevice ++ )
+// {
+// if ( pbtdi->fAuthenticated || pbtdi->fRemembered )
+// {
+// //
+// // TODO: Do something usefull with the device info
+// //
+// }
+//
+// pbtdi = (BLUETOOTH_DEVICE_INFO *) ((LPBYTE)pbtdi + pbtdi->dwSize);
+// }
+//
+// BluetoothSelectDevicesFree( &btsdp );
+// }
+//
+// ***************************************************************************
+
+
+typedef struct _BLUETOOTH_COD_PAIRS {
+ ULONG ulCODMask; // ClassOfDevice mask to compare
+ LPCWSTR pcszDescription; // Descriptive string of mask
+
+} BLUETOOTH_COD_PAIRS;
+
+typedef BOOL (WINAPI *PFN_DEVICE_CALLBACK)(LPVOID pvParam, PBLUETOOTH_DEVICE_INFO pDevice);
+
+typedef struct _BLUETOOTH_SELECT_DEVICE_PARAMS {
+ DWORD dwSize; // IN sizeof this structure
+
+ ULONG cNumOfClasses; // IN Number in prgClassOfDevice - if ZERO search for all devices
+ BLUETOOTH_COD_PAIRS * prgClassOfDevices; // IN Array of CODs to find.
+
+ LPWSTR pszInfo; // IN If not NULL, sets the "information" text
+
+ HWND hwndParent; // IN parent window - NULL == no parent
+
+ BOOL fForceAuthentication; // IN If TRUE, authenication will be forced before returning
+ BOOL fShowAuthenticated; // IN If TRUE, authenticated devices will be shown in the picker
+ BOOL fShowRemembered; // IN If TRUE, remembered devices will be shown in the picker
+ BOOL fShowUnknown; // IN If TRUE, unknown devices that are not authenticated or "remember" will be shown.
+
+ BOOL fAddNewDeviceWizard; // IN If TRUE, invokes the add new device wizard.
+ BOOL fSkipServicesPage; // IN If TRUE, skips the "Services" page in the wizard.
+
+ PFN_DEVICE_CALLBACK pfnDeviceCallback; // IN If non-NULL, a callback that will be called for each device. If the
+ // the callback returns TRUE, the item will be added. If the callback is
+ // is FALSE, the item will not be shown.
+ LPVOID pvParam; // IN Parameter to be passed to pfnDeviceCallback as the pvParam.
+
+ DWORD cNumDevices; // IN number calles wants - ZERO == no limit.
+ // OUT the number of devices returned.
+
+ PBLUETOOTH_DEVICE_INFO pDevices; // OUT pointer to an array for BLUETOOTH_DEVICE_INFOs.
+ // call BluetoothSelectDevicesFree() to free
+
+} BLUETOOTH_SELECT_DEVICE_PARAMS;
+
+//
+// Description:
+// (See header above)
+//
+// Return Values:
+// TRUE
+// User selected a device. pbtsdp->pDevices points to valid data.
+// Caller should check the fAuthenticated && fRemembered flags to
+// determine which devices we successfuly authenticated or valid
+// selections by the user.
+//
+// Use BluetoothSelectDevicesFree() to free the nessecary data
+// such as pDevices only if this function returns TRUE.
+//
+// FALSE
+// No valid data returned. Call GetLastError() for possible details
+// of the failure. If GLE() is:
+//
+// ERROR_CANCELLED
+// The user cancelled the request.
+//
+// ERROR_INVALID_PARAMETER
+// The pbtsdp is NULL.
+//
+// ERROR_REVISION_MISMATCH
+// The structure passed in as pbtsdp is of an unknown size.
+//
+// other WIN32 errors
+//
+BOOL
+WINAPI
+BluetoothSelectDevices(
+ BLUETOOTH_SELECT_DEVICE_PARAMS * pbtsdp
+ );
+
+//
+// Description:
+// This function should only be called if BluetoothSelectDevices() returns
+// TRUE. This function will free any memory and resource returned by the
+// BluetoothSelectDevices() in the BLUETOOTH_SELECT_DEVICE_PARAMS
+// structure.
+//
+// Return Values:
+// TRUE
+// Success.
+//
+// FALSE
+// Nothing to free.
+//
+BOOL
+WINAPI
+BluetoothSelectDevicesFree(
+ BLUETOOTH_SELECT_DEVICE_PARAMS * pbtsdp
+ );
+
+// ***************************************************************************
+//
+// Device Property Sheet
+//
+// ***************************************************************************
+
+//
+// Description:
+// Invokes the CPLs device info property sheet.
+//
+// Parameters:
+// hwndParent
+// HWND to parent the property sheet.
+//
+// pbtdi
+// A pointer to a BLUETOOTH_DEVICE_INFO structure of the device
+// to be displayed.
+//
+// Return Values:
+// TRUE
+// The property page was successfully displayed.
+//
+// FALSE
+// Failure. The property page was not displayed. Check GetLastError
+// for more details.
+//
+BOOL
+WINAPI
+BluetoothDisplayDeviceProperties(
+ HWND hwndParent,
+ BLUETOOTH_DEVICE_INFO * pbtdi
+ );
+
+
+// ***************************************************************************
+//
+// Radio Authentication
+//
+// ***************************************************************************
+
+//
+// Description:
+// Sends an authentication request to a remote device.
+//
+// There are two modes of operation. "Wizard mode" and "Blind mode."
+//
+// "Wizard mode" is invoked when the pszPasskey is NULL. This will cause
+// the "Bluetooth Connection Wizard" to be invoked. The user will be
+// prompted to enter a passkey during the wizard after which the
+// authentication request will be sent. The user will see the success
+// or failure of the authentication attempt. The user will also be
+// given the oppurtunity to try to fix a failed authentication.
+//
+// "Blind mode" is invoked when the pszPasskey is non-NULL. This will
+// cause the computer to send a authentication request to the remote
+// device. No UI is ever displayed. The Bluetooth status code will be
+// mapped to a Win32 Error code.
+//
+// Parameters:
+//
+// hwndParent
+// The window to parent the authentication wizard. If NULL, the
+// wizard will be parented off the desktop.
+//
+// hRadio
+// A valid local radio handle or NULL. If NULL, then all radios will
+// be tired. If any of the radios succeed, then the call will
+// succeed.
+//
+// pbtdi
+// BLUETOOTH_DEVICE_INFO record of the device to be authenticated.
+//
+// pszPasskey
+// PIN to be used to authenticate the device. If NULL, then UI is
+// displayed and the user steps through the authentication process.
+// If not NULL, no UI is shown. The passkey is NOT NULL terminated.
+//
+// ulPasskeyLength
+// Length of szPassKey in bytes. The length must be less than or
+// equal to BLUETOOTH_MAX_PASSKEY_SIZE * sizeof(WCHAR).
+//
+// Return Values:
+//
+// ERROR_SUCCESS
+// Success.
+//
+// ERROR_CANCELLED
+// User aborted the operation.
+//
+// ERROR_INVALID_PARAMETER
+// The device structure in pbtdi is invalid.
+//
+// ERROR_NO_MORE_ITEMS
+// The device in pbtdi is already been marked as authenticated.
+//
+// other WIN32 error
+// Failure. Return value is the error code.
+//
+// For "Blind mode," here is the current mapping of Bluetooth status
+// code to Win32 error codes:
+//
+// { BTH_ERROR_SUCCESS, ERROR_SUCCESS },
+// { BTH_ERROR_NO_CONNECTION, ERROR_DEVICE_NOT_CONNECTED },
+// { BTH_ERROR_PAGE_TIMEOUT, WAIT_TIMEOUT },
+// { BTH_ERROR_HARDWARE_FAILURE, ERROR_GEN_FAILURE },
+// { BTH_ERROR_AUTHENTICATION_FAILURE, ERROR_NOT_AUTHENTICATED },
+// { BTH_ERROR_MEMORY_FULL, ERROR_NOT_ENOUGH_MEMORY },
+// { BTH_ERROR_CONNECTION_TIMEOUT, WAIT_TIMEOUT },
+// { BTH_ERROR_LMP_RESPONSE_TIMEOUT, WAIT_TIMEOUT },
+// { BTH_ERROR_MAX_NUMBER_OF_CONNECTIONS, ERROR_REQ_NOT_ACCEP },
+// { BTH_ERROR_PAIRING_NOT_ALLOWED, ERROR_ACCESS_DENIED },
+// { BTH_ERROR_UNSPECIFIED_ERROR, ERROR_NOT_READY },
+// { BTH_ERROR_LOCAL_HOST_TERMINATED_CONNECTION, ERROR_VC_DISCONNECTED },
+//
+DWORD
+WINAPI
+BluetoothAuthenticateDevice(
+ HWND hwndParent,
+ HANDLE hRadio,
+ BLUETOOTH_DEVICE_INFO * pbtbi,
+ PWCHAR pszPasskey,
+ ULONG ulPasskeyLength
+ );
+
+//
+// Description:
+// Allows the caller to prompt for multiple devices to be authenticated
+// within a single instance of the "Bluetooth Connection Wizard."
+//
+// Parameters:
+//
+// hwndParent
+// The window to parent the authentication wizard. If NULL, the
+// wizard will be parented off the desktop.
+//
+// hRadio
+// A valid local radio handle or NULL. If NULL, then all radios will
+// be tired. If any of the radios succeed, then the call will
+// succeed.
+//
+// cDevices
+// Number of devices in the rgbtdi array.
+//
+// rgbtdi
+// An array BLUETOOTH_DEVICE_INFO records of the devices to be
+// authenticated.
+//
+// Return Values:
+//
+// ERROR_SUCCESS
+// Success. Check the fAuthenticate flag on each of the devices.
+//
+// ERROR_CANCELLED
+// User aborted the operation. Check the fAuthenticate flags on
+// each device to determine if any of the devices were authenticated
+// before the user cancelled the operation.
+//
+// ERROR_INVALID_PARAMETER
+// One of the items in the array of devices is invalid.
+//
+// ERROR_NO_MORE_ITEMS
+// All the devices in the array of devices are already been marked as
+// being authenticated.
+//
+// other WIN32 error
+// Failure. Return value is the error code.
+//
+DWORD
+WINAPI
+BluetoothAuthenticateMultipleDevices(
+ HWND hwndParent,
+ HANDLE hRadio,
+ DWORD cDevices,
+ BLUETOOTH_DEVICE_INFO * pbtdi
+ );
+
+// ***************************************************************************
+//
+// Bluetooth Services
+//
+// ***************************************************************************
+
+#define BLUETOOTH_SERVICE_DISABLE 0x00
+#define BLUETOOTH_SERVICE_ENABLE 0x01
+#define BLUETOOTH_SERVICE_MASK ( BLUETOOTH_ENABLE_SERVICE | BLUETOOTH_DISABLE_SERVICE )
+
+//
+// Description:
+// Enables/disables the services for a particular device.
+//
+// The system maintains a mapping of service guids to supported drivers for
+// Bluetooth-enabled devices. Enabling a service installs the corresponding
+// device driver. Disabling a service removes the corresponding device driver.
+//
+// If a non-supported service is enabled, a driver will not be installed.
+//
+// Parameters
+// hRadio
+// Handle of the local Bluetooth radio device.
+//
+// pbtdi
+// Pointer to a BLUETOOTH_DEVICE_INFO record.
+//
+// pGuidService
+// The service GUID on the remote device.
+//
+// dwServiceFlags
+// Flags to adjust the service.
+// BLUETOOTH_SERVICE_DISABLE - disable the service
+// BLUETOOTH_SERVICE_ENABLE - enables the service
+//
+// Return Values:
+// ERROR_SUCCESS
+// The call was successful.
+//
+// ERROR_INVALID_PARAMETER
+// dwServiceFlags are invalid.
+//
+// ERROR_SERVICE_DOES_NOT_EXIST
+// The GUID in pGuidService is not supported.
+//
+// other WIN32 error
+// The call failed.
+//
+DWORD
+WINAPI
+BluetoothSetServiceState(
+ HANDLE hRadio,
+ BLUETOOTH_DEVICE_INFO * pbtdi,
+ GUID * pGuidService,
+ DWORD dwServiceFlags
+ );
+
+//
+// Description:
+// Enumerates the services guids enabled on a particular device. If hRadio
+// is NULL, all device will be searched for the device and all the services
+// enabled will be returned.
+//
+// Parameters:
+// hRadio
+// Handle of the local Bluetooth radio device. If NULL, it will search
+// all the radios for the address in the pbtdi.
+//
+// pbtdi
+// Pointer to a BLUETOOTH_DEVICE_INFO record.
+//
+// pcService
+// On input, the number of records pointed to by pGuidServices.
+// On output, the number of valid records return in pGuidServices.
+//
+// pGuidServices
+// Pointer to memory that is at least *pcService in length.
+//
+// Return Values:
+// ERROR_SUCCESS
+// The call succeeded. pGuidServices is valid.
+//
+// ERROR_MORE_DATA
+// The call succeeded. pGuidService contains an incomplete list of
+// enabled service GUIDs.
+//
+// other WIN32 errors
+// The call failed.
+//
+DWORD
+WINAPI
+BluetoothEnumerateInstalledServices(
+ HANDLE hRadio,
+ BLUETOOTH_DEVICE_INFO * pbtdi,
+ DWORD * pcServices,
+ GUID * pGuidServices
+ );
+
+//
+// Description:
+// Change the discovery state of the local radio(s).
+// If hRadio is NULL, all the radios will be set.
+//
+// Use BluetoothIsDiscoverable() to determine the radios current state.
+//
+// The system ensures that a discoverable system is connectable, thus
+// the radio must allow incoming connections (see
+// BluetoothEnableIncomingConnections) prior to making a radio
+// discoverable. Failure to do so will result in this call failing
+// (returns FALSE).
+//
+// Parameters:
+// hRadio
+// If not NULL, changes the state of a specific radio.
+// If NULL, the API will interate through all the radios.
+//
+// fEnabled
+// If FALSE, discovery will be disabled.
+//
+// Return Values
+// TRUE
+// State was successfully changed. If the caller specified NULL for
+// hRadio, at least of the radios accepted the state change.
+//
+// FALSE
+// State was not changed. If the caller specified NULL for hRadio, all
+// of the radios did not accept the state change.
+//
+BOOL
+WINAPI
+BluetoothEnableDiscovery(
+ HANDLE hRadio,
+ BOOL fEnabled
+ );
+
+//
+// Description:
+// Determines if the Bluetooth radios are discoverable. If there are
+// multiple radios, the first one to say it is discoverable will cause
+// this function to return TRUE.
+//
+// Parameters:
+// hRadio
+// Handle of the radio to check. If NULL, it will check all local
+// radios.
+//
+// Return Values:
+// TRUE
+// A least one radio is discoverable.
+//
+// FALSE
+// No radios are discoverable.
+//
+BOOL
+WINAPI
+BluetoothIsDiscoverable(
+ HANDLE hRadio
+ );
+
+//
+// Description:
+// Enables/disables the state of a radio to accept incoming connections.
+// If hRadio is NULL, all the radios will be set.
+//
+// Use BluetoothIsConnectable() to determine the radios current state.
+//
+// The system enforces that a radio that is not connectable is not
+// discoverable too. The radio must be made non-discoverable (see
+// BluetoothEnableDiscovery) prior to making a radio non-connectionable.
+// Failure to do so will result in this call failing (returns FALSE).
+//
+// Parameters:
+// hRadio
+// If not NULL, changes the state of a specific radio.
+// If NULL, the API will interate through all the radios.
+//
+// fEnabled
+// If FALSE, incoming connection will be disabled.
+//
+// Return Values
+// TRUE
+// State was successfully changed. If the caller specified NULL for
+// hRadio, at least of the radios accepted the state change.
+//
+// FALSE
+// State was not changed. If the caller specified NULL for hRadio, all
+// of the radios did not accept the state change.
+//
+BOOL
+WINAPI
+BluetoothEnableIncomingConnections(
+ HANDLE hRadio,
+ BOOL fEnabled
+ );
+
+//
+// Description:
+// Determines if the Bluetooth radios are connectable. If there are
+// multiple radios, the first one to say it is connectable will cause
+// this function to return TRUE.
+//
+// Parameters:
+// hRadio
+// Handle of the radio to check. If NULL, it will check all local
+// radios.
+//
+// Return Values:
+// TRUE
+// A least one radio is allowing incoming connections.
+//
+// FALSE
+// No radios are allowing incoming connections.
+//
+BOOL
+WINAPI
+BluetoothIsConnectable(
+ HANDLE hRadio
+ );
+
+// ***************************************************************************
+//
+// Authentication Registration
+//
+// ***************************************************************************
+
+typedef HANDLE HBLUETOOTH_AUTHENTICATION_REGISTRATION;
+
+typedef BOOL (*PFN_AUTHENTICATION_CALLBACK)(LPVOID pvParam, PBLUETOOTH_DEVICE_INFO pDevice);
+
+//
+// Description:
+// Registers a callback function to be called when a particular device
+// requests authentication. The request is sent to the last application
+// that requested authentication for a particular device.
+//
+// Parameters:
+// pbtdi
+// A pointer to a BLUETOOTH_DEVICE_INFO structure. The Bluetooth
+// address will be used for comparision.
+//
+// phRegHandle
+// A pointer to where the registration HANDLE value will be
+// stored. Call BluetoothUnregisterAuthentication() to close
+// the handle.
+//
+// pfnCallback
+// The function that will be called when the authentication event
+// occurs. This function should match PFN_AUTHENTICATION_CALLBACK's
+// prototype.
+//
+// pvParam
+// Optional parameter to be past through to the callback function.
+// This can be anything the application was to define.
+//
+// Return Values:
+// ERROR_SUCCESS
+// Success. A valid registration handle was returned.
+//
+// ERROR_OUTOFMEMORY
+// Out of memory.
+//
+// other Win32 error.
+// Failure. The registration handle is invalid.
+//
+DWORD
+WINAPI
+BluetoothRegisterForAuthentication(
+ BLUETOOTH_DEVICE_INFO * pbtdi,
+ HBLUETOOTH_AUTHENTICATION_REGISTRATION * phRegHandle,
+ PFN_AUTHENTICATION_CALLBACK pfnCallback,
+ PVOID pvParam
+ );
+
+//
+// Description:
+// Unregisters an authentication callback and closes the handle. See
+// BluetoothRegisterForAuthentication() for more information about
+// authentication registration.
+//
+// Parameters:
+// hRegHandle
+// Handle returned by BluetoothRegisterForAuthentication().
+//
+// Return Value:
+// TRUE
+// The handle was successfully closed.
+//
+// FALSE
+// The handle was not successfully closed. Check GetLastError for
+// more details.
+//
+// ERROR_INVALID_HANDLE
+// The handle is NULL.
+//
+// other Win32 errors.
+//
+BOOL
+WINAPI
+BluetoothUnregisterAuthentication(
+ HBLUETOOTH_AUTHENTICATION_REGISTRATION hRegHandle
+ );
+
+//
+// Description:
+// This function should be called after receiving an authentication request
+// to send the passkey response.
+//
+// Parameters:
+//
+// hRadio
+// Optional handle to the local radio. If NULL, the function will try
+// each radio until one succeeds.
+//
+// pbtdi
+// A pointer to a BLUETOOTH_DEVICE_INFO structure describing the device
+// being authenticated. This can be the same structure passed to the
+// callback function.
+//
+// pszPasskey
+// A pointer to UNICODE zero-terminated string of the passkey response
+// that should be sent back to the authenticating device.
+//
+// Return Values:
+// ERROR_SUCESS
+// The device accepted the passkey response. The device is authenticated.
+//
+// ERROR_CANCELED
+// The device denied the passkey reponse. This also will returned if there
+// is a communications problem with the local radio.
+//
+// E_FAIL
+// The device returned a failure code during authentication.
+//
+// other Win32 error codes
+//
+DWORD
+WINAPI
+BluetoothSendAuthenticationResponse(
+ HANDLE hRadio,
+ BLUETOOTH_DEVICE_INFO * pbtdi,
+ LPWSTR pszPasskey
+ );
+
+// ***************************************************************************
+//
+// SDP Parsing Functions
+//
+// ***************************************************************************
+
+typedef struct _SDP_ELEMENT_DATA {
+ //
+ // Enumeration of SDP element types. Generic element types will have a
+ // specificType value other then SDP_ST_NONE. The generic types are:
+ // o SDP_TYPE_UINT
+ // o SDP_TYPE_INT
+ // o SDP_TYPE_UUID
+ //
+ SDP_TYPE type;
+
+ //
+ // Specific types for the generic SDP element types.
+ //
+ SDP_SPECIFICTYPE specificType;
+
+ //
+ // Union of all possible data types. type and specificType will indicate
+ // which field is valid. For types which do not have a valid specificType,
+ // specific type will be SDP_ST_NONE.
+ //
+ union {
+ // type == SDP_TYPE_INT
+ SDP_LARGE_INTEGER_16 int128; // specificType == SDP_ST_INT128
+ LONGLONG int64; // specificType == SDP_ST_INT64
+ LONG int32; // specificType == SDP_ST_INT32
+ SHORT int16; // specificType == SDP_ST_INT16
+ CHAR int8; // specificType == SDP_ST_INT8
+
+ // type == SDP_TYPE_UINT
+ SDP_ULARGE_INTEGER_16 uint128; // specificType == SDP_ST_UINT128
+ ULONGLONG uint64; // specificType == SDP_ST_UINT64
+ ULONG uint32; // specificType == SDP_ST_UINT32
+ USHORT uint16; // specificType == SDP_ST_UINT16
+ UCHAR uint8; // specificType == SDP_ST_UINT8
+
+ // type == SDP_TYPE_BOOLEAN
+ UCHAR booleanVal;
+
+ // type == SDP_TYPE_UUID
+ GUID uuid128; // specificType == SDP_ST_UUID128
+ ULONG uuid32; // specificType == SDP_ST_UUID32
+ USHORT uuid16; // specificType == SDP_ST_UUID32
+
+ // type == SDP_TYPE_STRING
+ struct {
+ // raw string buffer, may not be encoded as ANSI, use
+ // BluetoothSdpGetString to convert the value if it is described
+ // by the base language attribute ID list
+ LPBYTE value;
+
+ // raw length of the string, may not be NULL terminuated
+ ULONG length;
+ } string;
+
+ // type == SDP_TYPE_URL
+ struct {
+ LPBYTE value;
+ ULONG length;
+ } url;
+
+ // type == SDP_TYPE_SEQUENCE
+ struct {
+ // raw sequence, starts at sequence element header
+ LPBYTE value;
+
+ // raw sequence length
+ ULONG length;
+ } sequence;
+
+ // type == SDP_TYPE_ALTERNATIVE
+ struct {
+ // raw alternative, starts at alternative element header
+ LPBYTE value;
+
+ // raw alternative length
+ ULONG length;
+ } alternative;
+
+ } data;
+
+} SDP_ELEMENT_DATA, *PSDP_ELEMENT_DATA;
+
+//
+// Description:
+// Retrieves and parses the element found at pSdpStream
+//
+// Parameters:
+// IN pSdpStream
+// pointer to valid SDP stream
+//
+// IN cbSdpStreamLength
+// length of pSdpStream in bytes
+//
+// OUT pData
+// pointer to be filled in with the data of the SDP element at the
+// beginning of pSdpStream
+//
+// Return Values:
+// ERROR_INVALID_PARAMETER
+// one of required parameters is NULL or the pSdpStream is invalid
+//
+// ERROR_SUCCESS
+// the sdp element was parsed correctly
+//
+DWORD
+WINAPI
+BluetoothSdpGetElementData(
+ LPBYTE pSdpStream,
+ ULONG cbSdpStreamLength,
+ PSDP_ELEMENT_DATA pData
+ );
+
+typedef HANDLE HBLUETOOTH_CONTAINER_ELEMENT;
+
+//
+// Description:
+// Iterates over a container stream, returning each elemetn contained with
+// in the container element at the beginning of pContainerStream
+//
+// Parameters:
+// IN pContainerStream
+// pointer to valid SDP stream whose first element is either a sequence
+// or alternative
+//
+// IN cbContainerlength
+// length in bytes of pContainerStream
+//
+// IN OUT pElement
+// Value used to keep track of location within the stream. The first
+// time this function is called for a particular container, *pElement
+// should equal NULL. Upon subsequent calls, the value should be
+// unmodified.
+//
+// OUT pData
+// pointer to be filled in with the data of the SDP element at the
+// current element of pContainerStream
+//
+// Return Values:
+// ERROR_SUCCESS
+// The call succeeded, pData contains the data
+//
+// ERROR_NO_MORE_ITEMS
+// There are no more items in the list, the caller should cease calling
+// BluetoothSdpGetContainerElementData for this container.
+//
+// ERROR_INVALID_PARAMETER
+// A required pointer is NULL or the container is not a valid SDP
+// stream
+//
+// Usage example:
+//
+// HBLUETOOTH_CONTAINER_ELEMENT element;
+// SDP_ELEMENT_DATA data;
+// ULONG result;
+//
+// element = NULL;
+//
+// while (TRUE) {
+// result = BluetoothSdpGetContainerElementData(
+// pContainer, ulContainerLength, &element, &data);
+//
+// if (result == ERROR_NO_MORE_ITEMS) {
+// // We are done
+// break;
+// }
+// else if (result != ERROR_SUCCESS) {
+// // error
+// }
+//
+// // do something with data ...
+// }
+//
+//
+DWORD
+WINAPI
+BluetoothSdpGetContainerElementData(
+ LPBYTE pContainerStream,
+ ULONG cbContainerLength,
+ HBLUETOOTH_CONTAINER_ELEMENT* pElement,
+ PSDP_ELEMENT_DATA pData
+ );
+
+//
+// Description:
+// Retrieves the attribute value for the given attribute ID. pRecordStream
+// must be an SDP stream that is formatted as an SDP record, a SEQUENCE
+// containing UINT16 + element pairs.
+//
+// Parameters:
+// IN pRecordStream
+// pointer to a valid SDP stream which is formatted as a singl SDP
+// record
+//
+// IN cbRecordlnegh
+// length of pRecordStream in bytes
+//
+// IN usAttributeId
+// the attribute ID to search for. see bthdef.h for SDP_ATTRIB_Xxx
+// values.
+//
+// OUT pAttributeData
+// pointer that will contain the attribute ID's value
+//
+// Return Values:
+// ERRROR_SUCCESS
+// Call succeeded, pAttributeData contains the attribute value
+//
+// ERROR_INVALID_PARAMETER
+// One of the required pointers was NULL, pRecordStream was not a valid
+// SDP stream, or pRecordStream was not a properly formatted SDP record
+//
+// ERROR_FILE_NOT_FOUND
+// usAttributeId was not found in the record
+//
+// Usage:
+//
+// ULONG result;
+// SDP_DATA_ELEMENT data;
+//
+// result = BluetoothSdpGetAttributeValue(
+// pRecordStream, cbRecordLength, SDP_ATTRIB_RECORD_HANDLE, &data);
+// if (result == ERROR_SUCCESS) {
+// printf("record handle is 0x%x\n", data.data.uint32);
+// }
+//
+DWORD
+WINAPI
+BluetoothSdpGetAttributeValue(
+ LPBYTE pRecordStream,
+ ULONG cbRecordLength,
+ USHORT usAttributeId,
+ PSDP_ELEMENT_DATA pAttributeData
+ );
+
+//
+// These three fields correspond one to one with the triplets defined in the
+// SDP specification for the language base attribute ID list.
+//
+typedef struct _SDP_STRING_TYPE_DATA {
+ //
+ // How the string is encoded according to ISO 639:1988 (E/F): "Code
+ // for the representation of names of languages".
+ //
+ USHORT encoding;
+
+ //
+ // MIBE number from IANA database
+ //
+ USHORT mibeNum;
+
+ //
+ // The base attribute where the string is to be found in the record
+ //
+ USHORT attributeId;
+
+} SDP_STRING_TYPE_DATA, *PSDP_STRING_TYPE_DATA;
+
+//
+// Description:
+// Converts a raw string embedded in the SDP record into a UNICODE string
+//
+// Parameters:
+// IN pRecordStream
+// a valid SDP stream which is formatted as an SDP record
+//
+// IN cbRecordLength
+// length of pRecordStream in bytes
+//
+// IN pStringData
+// if NULL, then the calling thread's locale will be used to search
+// for a matching string in the SDP record. If not NUL, the mibeNum
+// and attributeId will be used to find the string to convert.
+//
+// IN usStringOffset
+// the SDP string type offset to convert. usStringOffset is added to
+// the base attribute id of the string. SDP specification defined
+// offsets are: STRING_NAME_OFFSET, STRING_DESCRIPTION_OFFSET, and
+// STRING_PROVIDER_NAME_OFFSET (found in bthdef.h).
+//
+// OUT pszString
+// if NULL, pcchStringLength will be filled in with the required number
+// of characters (not bytes) to retrieve the converted string.
+//
+// IN OUT pcchStringLength
+// Upon input, if pszString is not NULL, will contain the length of
+// pszString in characters. Upon output, it will contain either the
+// number of required characters including NULL if an error is returned
+// or the number of characters written to pszString (including NULL).
+//
+// Return Values:
+// ERROR_SUCCES
+// Call was successful and pszString contains the converted string
+//
+// ERROR_MORE_DATA
+// pszString was NULL or too small to contain the converted string,
+// pccxhStringLength contains the required length in characters
+//
+// ERROR_INVALID_DATA
+// Could not perform the conversion
+//
+// ERROR_NO_SYSTEM_RESOURCES
+// Could not allocate memory internally to perform the conversion
+//
+// ERROR_INVALID_PARAMETER
+// One of the rquired pointers was NULL, pRecordStream was not a valid
+// SDP stream, pRecordStream was not a properly formatted record, or
+// the desired attribute + offset was not a string.
+//
+// Other HRESULTs returned by COM
+//
+DWORD
+WINAPI
+BluetoothSdpGetString(
+ LPBYTE pRecordStream,
+ ULONG cbRecordLength,
+ PSDP_STRING_TYPE_DATA pStringData,
+ USHORT usStringOffset,
+ PWCHAR pszString,
+ PULONG pcchStringLength
+ );
+
+// ***************************************************************************
+//
+// Raw Attribute Enumeration
+//
+// ***************************************************************************
+
+typedef BOOL (CALLBACK *PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK)(
+ ULONG uAttribId,
+ LPBYTE pValueStream,
+ ULONG cbStreamSize,
+ LPVOID pvParam
+ );
+
+//
+// Description:
+// Enumerates through the SDP record stream calling the Callback function
+// for each attribute in the record. If the Callback function returns
+// FALSE, the enumeration is stopped.
+//
+// Return Values:
+// TRUE
+// Success! Something was enumerated.
+//
+// FALSE
+// Failure. GetLastError() could be one of the following:
+//
+// ERROR_INVALID_PARAMETER
+// pSDPStream or pfnCallback is NULL.
+//
+// ERROR_INVALID_DATA
+// The SDP stream is corrupt.
+//
+// other Win32 errors.
+//
+#define BluetoothEnumAttributes BluetoothSdpEnumAttributes
+
+BOOL
+WINAPI
+BluetoothSdpEnumAttributes(
+ LPBYTE pSDPStream,
+ ULONG cbStreamSize,
+ PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK pfnCallback,
+ LPVOID pvParam
+ );
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/cpp/wiiscan/include/DelcomDLL.h b/cpp/wiiscan/include/DelcomDLL.h
index 8fd16b5..eb48350 100644
--- a/cpp/wiiscan/include/DelcomDLL.h
+++ b/cpp/wiiscan/include/DelcomDLL.h
@@ -66,7 +66,7 @@ DWORD __stdcall DelcomGetDeviceCount( DWORD Type );
DWORD __stdcall DelcomReadDeviceVersion(HANDLE );
DWORD __stdcall DelcomReadDeviceSerialNum(LPSTR, HANDLE );
-DWORD __stdcall DelcomSendPacket( HANDLE, pPacketStruct, pPacketStruct);
+DWORD __stdcall DelcomSendPacket( HANDLE, pPacketStruct, pPacketStruct);
// USBDELVI - Visual Indicator Functions
@@ -123,6 +123,3 @@ DWORD __stdcall DelcomNumericDouble(HANDLE hUsb, double Number, DWORD Base );
#endif
-
-
-
diff --git a/cpp/wiiscan/include/bthdef.h b/cpp/wiiscan/include/bthdef.h
new file mode 100644
index 0000000..37b3f5d
--- /dev/null
+++ b/cpp/wiiscan/include/bthdef.h
@@ -0,0 +1,858 @@
+/*++
+
+Copyright (c) 2000 Microsoft Corporation
+
+Module Name:
+
+ bthdef.h
+
+Abstract:
+
+ This module contains the Bluetooth common structures and definitions
+
+Author:
+
+Notes:
+
+Environment:
+
+ Kernel mode only
+
+
+Revision History:
+
+ --*/
+
+#ifndef __BTHDEF_H__
+#define __BTHDEF_H__
+
+#ifndef GUID_DEFS_ONLY
+ #ifndef NO_BTHSDPDEF_INC
+ #include "bthsdpdef.h"
+ #endif // NO_BTHSDPDEF_INC
+#endif // GUID_DEFS_ONLY
+
+#ifndef NO_GUID_DEFS
+
+// {0850302A-B344-4fda-9BE9-90576B8D46F0}
+DEFINE_GUID(GUID_BTHPORT_DEVICE_INTERFACE, 0x850302a, 0xb344, 0x4fda, 0x9b, 0xe9, 0x90, 0x57, 0x6b, 0x8d, 0x46, 0xf0);
+
+// {EA3B5B82-26EE-450E-B0D8-D26FE30A3869}
+DEFINE_GUID(GUID_BLUETOOTH_RADIO_IN_RANGE, 0xea3b5b82, 0x26ee, 0x450e, 0xb0, 0xd8, 0xd2, 0x6f, 0xe3, 0x0a, 0x38, 0x69);
+
+// {E28867C9-C2AA-4CED-B969-4570866037C4}
+DEFINE_GUID(GUID_BLUETOOTH_RADIO_OUT_OF_RANGE, 0xe28867c9, 0xc2aa, 0x4ced, 0xb9, 0x69, 0x45, 0x70, 0x86, 0x60, 0x37, 0xc4);
+
+// BD198B7C-24AB-4B9A-8C0D-A8EA8349AA16
+DEFINE_GUID(GUID_BLUETOOTH_PIN_REQUEST, 0xbd198b7c, 0x24ab, 0x4b9a, 0x8c, 0x0d, 0xa8, 0xea, 0x83, 0x49, 0xaa, 0x16);
+
+// {7EAE4030-B709-4AA8-AC55-E953829C9DAA}
+DEFINE_GUID(GUID_BLUETOOTH_L2CAP_EVENT, 0x7eae4030, 0xb709, 0x4aa8, 0xac, 0x55, 0xe9, 0x53, 0x82, 0x9c, 0x9d, 0xaa);
+
+// {FC240062-1541-49BE-B463-84C4DCD7BF7F}
+DEFINE_GUID(GUID_BLUETOOTH_HCI_EVENT, 0xfc240062, 0x1541, 0x49be, 0xb4, 0x63, 0x84, 0xc4, 0xdc, 0xd7, 0xbf, 0x7f);
+
+//
+// Bluetooth base UUID for service discovery
+//
+DEFINE_GUID(Bluetooth_Base_UUID, 0x00000000, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+
+//
+// UUID for the root of the browse group list
+//
+
+DEFINE_GUID(SDP_PROTOCOL_UUID, 0x00000001, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(UDP_PROTOCOL_UUID, 0x00000002, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(RFCOMM_PROTOCOL_UUID, 0x00000003, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(TCP_PROTOCOL_UUID, 0x00000004, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(TCSBIN_PROTOCOL_UUID, 0x00000005, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(TCSAT_PROTOCOL_UUID, 0x00000006, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(OBEX_PROTOCOL_UUID, 0x00000008, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(IP_PROTOCOL_UUID, 0x00000009, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(FTP_PROTOCOL_UUID, 0x0000000A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HTTP_PROTOCOL_UUID, 0x0000000C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(WSP_PROTOCOL_UUID, 0x0000000E, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(BNEP_PROTOCOL_UUID, 0x0000000F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(UPNP_PROTOCOL_UUID, 0x00000010, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HID_PROTOCOL_UUID, 0x00000011, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HCCC_PROTOCOL_UUID, 0x00000012, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HCDC_PROTOCOL_UUID, 0x00000014, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HN_PROTOCOL_UUID, 0x00000016, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(AVCTP_PROTOCOL_UUID, 0x00000017, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(AVDTP_PROTOCOL_UUID, 0x00000019, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(CMPT_PROTOCOL_UUID, 0x0000001B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(UDI_C_PLANE_PROTOCOL_UUID, 0x0000001D, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(L2CAP_PROTOCOL_UUID, 0x00000100, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+
+#define SDP_PROTOCOL_UUID16 (0x0001)
+#define UDP_PROTOCOL_UUID16 (0x0002)
+#define RFCOMM_PROTOCOL_UUID16 (0x0003)
+#define TCP_PROTOCOL_UUID16 (0x0004)
+#define TCSBIN_PROTOCOL_UUID16 (0x0005)
+#define TCSAT_PROTOCOL_UUID16 (0x0006)
+#define OBEX_PROTOCOL_UUID16 (0x0008)
+#define IP_PROTOCOL_UUID16 (0x0009)
+#define FTP_PROTOCOL_UUID16 (0x000A)
+#define HTTP_PROTOCOL_UUID16 (0x000C)
+#define WSP_PROTOCOL_UUID16 (0x000E)
+#define BNEP_PROTOCOL_UUID16 (0x000F)
+#define UPNP_PROTOCOL_UUID16 (0x0010)
+#define HID_PROTOCOL_UUID16 (0x0011)
+#define HCCC_PROTOCOL_UUID16 (0x0012)
+#define HCDC_PROTOCOL_UUID16 (0x0014)
+#define HCN_PROTOCOL_UUID16 (0x0016)
+#define AVCTP_PROTOCOL_UUID16 (0x0017)
+#define AVDTP_PROTOCOL_UUID16 (0x0019)
+#define CMPT_PROTOCOL_UUID16 (0x001B)
+#define UDI_C_PLANE_PROTOCOL_UUID16 (0x001D)
+#define L2CAP_PROTOCOL_UUID16 (0x0100)
+
+DEFINE_GUID(ServiceDiscoveryServerServiceClassID_UUID, 0x00001000, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(BrowseGroupDescriptorServiceClassID_UUID, 0x00001001, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(PublicBrowseGroupServiceClass_UUID, 0x00001002, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(SerialPortServiceClass_UUID, 0x00001101, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(LANAccessUsingPPPServiceClass_UUID, 0x00001102, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(DialupNetworkingServiceClass_UUID, 0x00001103, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(IrMCSyncServiceClass_UUID, 0x00001104, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(OBEXObjectPushServiceClass_UUID, 0x00001105, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(OBEXFileTransferServiceClass_UUID, 0x00001106, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(IrMCSyncCommandServiceClass_UUID, 0x00001107, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HeadsetServiceClass_UUID, 0x00001108, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(CordlessTelephonyServiceClass_UUID, 0x00001109, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(AudioSourceServiceClass_UUID, 0x0000110A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(AudioSinkServiceClass_UUID, 0x0000110B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(AVRemoteControlTargetServiceClass_UUID, 0x0000110C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(AdvancedAudioDistributionServiceClass_UUID,0x0000110D, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(AVRemoteControlServiceClass_UUID, 0x0000110E, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(VideoConferencingServiceClass_UUID, 0x0000110F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(IntercomServiceClass_UUID, 0x00001110, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(FaxServiceClass_UUID, 0x00001111, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HeadsetAudioGatewayServiceClass_UUID, 0x00001112, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(WAPServiceClass_UUID, 0x00001113, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(WAPClientServiceClass_UUID, 0x00001114, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(PANUServiceClass_UUID, 0x00001115, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(NAPServiceClass_UUID, 0x00001116, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(GNServiceClass_UUID, 0x00001117, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(DirectPrintingServiceClass_UUID, 0x00001118, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(ReferencePrintingServiceClass_UUID, 0x00001119, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(ImagingServiceClass_UUID, 0x0000111A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(ImagingResponderServiceClass_UUID, 0x0000111B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(ImagingAutomaticArchiveServiceClass_UUID, 0x0000111C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(ImagingReferenceObjectsServiceClass_UUID, 0x0000111D, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HandsfreeServiceClass_UUID, 0x0000111E, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HandsfreeAudioGatewayServiceClass_UUID, 0x0000111F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(DirectPrintingReferenceObjectsServiceClass_UUID,
+ 0x00001120, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(ReflectedUIServiceClass_UUID, 0x00001121, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(BasicPringingServiceClass_UUID, 0x00001122, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(PrintingStatusServiceClass_UUID, 0x00001123, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HumanInterfaceDeviceServiceClass_UUID, 0x00001124, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HardcopyCableReplacementServiceClass_UUID, 0x00001125, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HCRPrintServiceClass_UUID, 0x00001126, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(HCRScanServiceClass_UUID, 0x00001127, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(CommonISDNAccessServiceClass_UUID, 0x00001128, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(VideoConferencingGWServiceClass_UUID, 0x00001129, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(UDIMTServiceClass_UUID, 0x0000112A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(UDITAServiceClass_UUID, 0x0000112B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(AudioVideoServiceClass_UUID, 0x0000112C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(PnPInformationServiceClass_UUID, 0x00001200, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(GenericNetworkingServiceClass_UUID, 0x00001201, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(GenericFileTransferServiceClass_UUID, 0x00001202, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(GenericAudioServiceClass_UUID, 0x00001203, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+DEFINE_GUID(GenericTelephonyServiceClass_UUID, 0x00001204, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
+
+#define ServiceDiscoveryServerServiceClassID_UUID16 (0x1000)
+#define BrowseGroupDescriptorServiceClassID_UUID16 (0x1001)
+#define PublicBrowseGroupServiceClassID_UUID16 (0x1002)
+#define SerialPortServiceClassID_UUID16 (0x1101)
+#define LANAccessUsingPPPServiceClassID_UUID16 (0x1102)
+#define DialupNetworkingServiceClassID_UUID16 (0x1103)
+#define IrMCSyncServiceClassID_UUID16 (0x1104)
+#define OBEXObjectPushServiceClassID_UUID16 (0x1105)
+#define OBEXFileTransferServiceClassID_UUID16 (0x1106)
+#define IrMcSyncCommandServiceClassID_UUID16 (0x1107)
+#define HeadsetServiceClassID_UUID16 (0x1108)
+#define CordlessServiceClassID_UUID16 (0x1109)
+#define AudioSourceServiceClassID_UUID16 (0x110A)
+#define AudioSinkSourceServiceClassID_UUID16 (0x110B)
+#define AVRemoteControlTargetServiceClassID_UUID16 (0x110C)
+#define AdvancedAudioDistributionServiceClassID_UUID16 (0x110D)
+#define AVRemoteControlServiceClassID_UUID16 (0x110E)
+#define VideoConferencingServiceClassID_UUID16 (0x110F)
+#define IntercomServiceClassID_UUID16 (0x1110)
+#define FaxServiceClassID_UUID16 (0x1111)
+#define HeadsetAudioGatewayServiceClassID_UUID16 (0x1112)
+#define WAPServiceClassID_UUID16 (0x1113)
+#define WAPClientServiceClassID_UUID16 (0x1114)
+#define PANUServiceClassID_UUID16 (0x1115)
+#define NAPServiceClassID_UUID16 (0x1116)
+#define GNServiceClassID_UUID16 (0x1117)
+#define DirectPrintingServiceClassID_UUID16 (0x1118)
+#define ReferencePrintingServiceClassID_UUID16 (0x1119)
+#define ImagingServiceClassID_UUID16 (0x111A)
+#define ImagingResponderServiceClassID_UUID16 (0x111B)
+#define ImagingAutomaticArchiveServiceClassID_UUID16 (0x111C)
+#define ImagingReferenceObjectsServiceClassID_UUID16 (0x111D)
+#define HandsfreeServiceClassID_UUID16 (0x111E)
+#define HandsfreeAudioGatewayServiceClassID_UUID16 (0x111F)
+#define DirectPrintingReferenceObjectsServiceClassID_UUID16 \
+ (0x1120)
+#define ReflectsUIServiceClassID_UUID16 (0x1121)
+#define BasicPrintingServiceClassID_UUID16 (0x1122)
+#define PrintingStatusServiceClassID_UUID16 (0x1123)
+#define HumanInterfaceDeviceServiceClassID_UUID16 (0x1124)
+#define HardcopyCableReplacementServiceClassID_UUID16 (0x1125)
+#define HCRPrintServiceClassID_UUID16 (0x1126)
+#define HCRScanServiceClassID_UUID16 (0x1127)
+#define CommonISDNAccessServiceClass_UUID16 (0x1128)
+#define VideoConferencingGWServiceClass_UUID16 (0x1129)
+#define UDIMTServiceClass_UUID16 (0x112A)
+#define UDITAServiceClass_UUID16 (0x112B)
+#define AudioVideoServiceClass_UUID16 (0x112C)
+
+#define PnPInformationServiceClassID_UUID16 (0x1200)
+#define GenericNetworkingServiceClassID_UUID16 (0x1201)
+#define GenericFileTransferServiceClassID_UUID16 (0x1202)
+#define GenericAudioServiceClassID_UUID16 (0x1203)
+#define GenericTelephonyServiceClassID_UUID16 (0x1204)
+
+#endif // NO_GUID_DEFS
+
+#ifndef GUID_DEFS_ONLY
+
+//
+// max length of device friendly name.
+//
+#define BTH_MAX_NAME_SIZE (248)
+
+#define BTH_MAX_PIN_SIZE (16)
+#define BTH_LINK_KEY_LENGTH (16)
+
+#define BTH_MFG_ERICSSON (0)
+#define BTH_MFG_NOKIA (1)
+#define BTH_MFG_INTEL (2)
+#define BTH_MFG_IBM (3)
+#define BTH_MFG_TOSHIBA (4)
+#define BTH_MFG_3COM (5)
+#define BTH_MFG_MICROSOFT (6)
+#define BTH_MFG_LUCENT (7)
+#define BTH_MFG_MOTOROLA (8)
+#define BTH_MFG_INFINEON (9)
+#define BTH_MFG_CSR (10)
+#define BTH_MFG_SILICONWAVE (11)
+#define BTH_MFG_DIGIANSWER (12)
+#define BTH_MFG_TI (13)
+#define BTH_MFG_PARTHUS (14)
+#define BTH_MFG_BROADCOM (15)
+#define BTH_MFG_MITEL (16)
+#define BTH_MFG_WIDCOMM (17)
+#define BTH_MFG_ZEEVO (18)
+#define BTH_MFG_ATMEL (19)
+#define BTH_MFG_MITSIBUSHI (20)
+#define BTH_MFG_RTX_TELECOM (21)
+#define BTH_MFG_KC_TECHNOLOGY (22)
+#define BTH_MFG_NEWLOGIC (23)
+#define BTH_MFG_TRANSILICA (24)
+#define BTH_MFG_ROHDE_SCHWARZ (25)
+#define BTH_MFG_TTPCOM (26)
+#define BTH_MFG_SIGNIA (27)
+#define BTH_MFG_CONEXANT (28)
+#define BTH_MFG_QUALCOMM (29)
+#define BTH_MFG_INVENTEL (30)
+#define BTH_MFG_AVM_BERLIN (31)
+#define BTH_MFG_BANDSPEED (32)
+#define BTH_MFG_MANSELLA (33)
+#define BTH_MFG_NEC (34)
+#define BTH_MFG_WAVEPLUS_TECHNOLOGY_CO (35)
+#define BTH_MFG_ALCATEL (36)
+#define BTH_MFG_PHILIPS_SEMICONDUCTOR (37)
+#define BTH_MFG_C_TECHNOLOGIES (38)
+#define BTH_MFG_OPEN_INTERFACE (39)
+#define BTH_MFG_RF_MICRO_DEVICES (40)
+#define BTH_MFG_HITACHI (41)
+#define BTH_MFG_SYMBOL_TECHNOLOGIES (42)
+#define BTH_MFG_TENOVIS (43)
+#define BTH_MFG_MACRONIX_INTERNATIONAL (44)
+#define BTH_MFG_INTERNAL_USE (65535)
+
+typedef ULONGLONG BTH_ADDR, *PBTH_ADDR;
+typedef ULONG BTH_COD, *PBTH_COD;
+typedef ULONG BTH_LAP, *PBTH_LAP;
+
+#define BTH_ADDR_NULL ((ULONGLONG) 0x0000000000000000)
+
+#define NAP_MASK ((ULONGLONG) 0xFFFF00000000)
+#define SAP_MASK ((ULONGLONG) 0x0000FFFFFFFF)
+
+#define NAP_BIT_OFFSET (8 * 4)
+#define SAP_BIT_OFFSET (0)
+
+#define GET_NAP(_bth_addr) ((USHORT) (((_bth_addr) & NAP_MASK) >> NAP_BIT_OFFSET))
+#define GET_SAP(_bth_addr) ((ULONG) (((_bth_addr) & SAP_MASK) >> SAP_BIT_OFFSET))
+
+#define SET_NAP(_nap) (((ULONGLONG) ((USHORT) (_nap))) << NAP_BIT_OFFSET)
+#define SET_SAP(_sap) (((ULONGLONG) ((ULONG) (_sap))) << SAP_BIT_OFFSET)
+
+#define SET_NAP_SAP(_nap, _sap) (SET_NAP(_nap) | SET_SAP(_sap))
+
+#define COD_FORMAT_BIT_OFFSET (0)
+#define COD_MINOR_BIT_OFFSET (2)
+#define COD_MAJOR_BIT_OFFSET (8 * 1)
+#define COD_SERVICE_BIT_OFFSET (8 * 1 + 5)
+
+#define COD_FORMAT_MASK (0x000003)
+#define COD_MINOR_MASK (0x0000FC)
+#define COD_MAJOR_MASK (0x001F00)
+#define COD_SERVICE_MASK (0xFFE000)
+
+
+#define GET_COD_FORMAT(_cod) ( (_cod) & COD_FORMAT_MASK >> COD_FORMAT_BIT_OFFSET)
+#define GET_COD_MINOR(_cod) (((_cod) & COD_MINOR_MASK) >> COD_MINOR_BIT_OFFSET)
+#define GET_COD_MAJOR(_cod) (((_cod) & COD_MAJOR_MASK) >> COD_MAJOR_BIT_OFFSET)
+#define GET_COD_SERVICE(_cod) (((_cod) & COD_SERVICE_MASK) >> COD_SERVICE_BIT_OFFSET)
+
+#define SET_COD_MINOR(_cod, _minor) (_cod) = ((_cod) & ~COD_MINOR_MASK) | ((_minor) << COD_MINOR_BIT_OFFSET)
+#define SET_COD_MAJOR(_cod, _major) (_cod) = ((_cod) & ~COD_MAJOR_MASK) | ((_major) << COD_MAJOR_BIT_OFFSET)
+#define SET_COD_SERVICE(_cod, _service) (_cod) = ((_cod) & ~COD_SERVICE_MASK) | ((_service) << COD_SERVICE_BIT_OFFSET)
+
+#define COD_VERSION (0x0)
+
+#define COD_SERVICE_LIMITED (0x0001)
+#define COD_SERVICE_POSITIONING (0x0008)
+#define COD_SERVICE_NETWORKING (0x0010)
+#define COD_SERVICE_RENDERING (0x0020)
+#define COD_SERVICE_CAPTURING (0x0040)
+#define COD_SERVICE_OBJECT_XFER (0x0080)
+#define COD_SERVICE_AUDIO (0x0100)
+#define COD_SERVICE_TELEPHONY (0x0200)
+#define COD_SERVICE_INFORMATION (0x0400)
+
+#define COD_SERVICE_VALID_MASK (COD_SERVICE_LIMITED | \
+ COD_SERVICE_POSITIONING | \
+ COD_SERVICE_NETWORKING | \
+ COD_SERVICE_RENDERING | \
+ COD_SERVICE_CAPTURING | \
+ COD_SERVICE_OBJECT_XFER |\
+ COD_SERVICE_AUDIO |\
+ COD_SERVICE_TELEPHONY |\
+ COD_SERVICE_INFORMATION)
+
+#define COD_SERVICE_MAX_COUNT (9)
+
+//
+// Major class codes
+//
+#define COD_MAJOR_MISCELLANEOUS (0x00)
+#define COD_MAJOR_COMPUTER (0x01)
+#define COD_MAJOR_PHONE (0x02)
+#define COD_MAJOR_LAN_ACCESS (0x03)
+#define COD_MAJOR_AUDIO (0x04)
+#define COD_MAJOR_PERIPHERAL (0x05)
+#define COD_MAJOR_IMAGING (0x06)
+#define COD_MAJOR_UNCLASSIFIED (0x1F)
+
+//
+// Minor class codes specific to each major class
+//
+#define COD_COMPUTER_MINOR_UNCLASSIFIED (0x00)
+#define COD_COMPUTER_MINOR_DESKTOP (0x01)
+#define COD_COMPUTER_MINOR_SERVER (0x02)
+#define COD_COMPUTER_MINOR_LAPTOP (0x03)
+#define COD_COMPUTER_MINOR_HANDHELD (0x04)
+#define COD_COMPUTER_MINOR_PALM (0x05)
+#define COD_COMPUTER_MINOR_WEARABLE (0x06)
+
+#define COD_PHONE_MINOR_UNCLASSIFIED (0x00)
+#define COD_PHONE_MINOR_CELLULAR (0x01)
+#define COD_PHONE_MINOR_CORDLESS (0x02)
+#define COD_PHONE_MINOR_SMART (0x03)
+#define COD_PHONE_MINOR_WIRED_MODEM (0x04)
+
+#define COD_AUDIO_MINOR_UNCLASSIFIED (0x00)
+#define COD_AUDIO_MINOR_HEADSET (0x01)
+#define COD_AUDIO_MINOR_HANDS_FREE (0x02)
+#define COD_AUDIO_MINOR_HEADSET_HANDS_FREE (0x03)
+#define COD_AUDIO_MINOR_MICROPHONE (0x04)
+#define COD_AUDIO_MINOR_LOUDSPEAKER (0x05)
+#define COD_AUDIO_MINOR_HEADPHONES (0x06)
+#define COD_AUDIO_MINOR_PORTABLE_AUDIO (0x07)
+#define COD_AUDIO_MINOR_CAR_AUDIO (0x08)
+#define COD_AUDIO_MINOR_SET_TOP_BOX (0x09)
+#define COD_AUDIO_MINOR_HIFI_AUDIO (0x0A)
+#define COD_AUDIO_MINOR_VCR (0x0B)
+#define COD_AUDIO_MINOR_VIDEO_CAMERA (0x0C)
+#define COD_AUDIO_MINOR_CAMCORDER (0x0D)
+#define COD_AUDIO_MINOR_VIDEO_MONITOR (0x0E)
+#define COD_AUDIO_MINOR_VIDEO_DISPLAY_LOUDSPEAKER \
+ (0x0F)
+#define COD_AUDIO_MINOR_VIDEO_DISPLAY_CONFERENCING \
+ (0x10)
+// #define COD_AUDIO_MINOR_RESERVED (0x11)
+#define COD_AUDIO_MINOR_GAMING_TOY (0x12)
+
+#define COD_PERIPHERAL_MINOR_KEYBOARD_MASK (0x10)
+#define COD_PERIPHERAL_MINOR_POINTER_MASK (0x20)
+
+#define COD_PERIPHERAL_MINOR_NO_CATEGORY (0x00)
+#define COD_PERIPHERAL_MINOR_JOYSTICK (0x01)
+#define COD_PERIPHERAL_MINOR_GAMEPAD (0x02)
+#define COD_PERIPHERAL_MINOR_REMOTE_CONTROL (0x03)
+#define COD_PERIPHERAL_MINOR_SENSING (0x04)
+
+#define COD_IMAGING_MINOR_DISPLAY_MASK (0x04)
+#define COD_IMAGING_MINOR_CAMERA_MASK (0x08)
+#define COD_IMAGING_MINOR_SCANNER_MASK (0x10)
+#define COD_IMAGING_MINOR_PRINTER_MASK (0x20)
+
+//
+// Cannot use GET_COD_MINOR for this b/c it is embedded in a different manner
+// than the rest of the major classes
+//
+
+#define COD_LAN_ACCESS_BIT_OFFSET (5)
+
+#define COD_LAN_MINOR_MASK (0x00001C)
+#define COD_LAN_ACCESS_MASK (0x0000E0)
+
+#define GET_COD_LAN_MINOR(_cod) (((_cod) & COD_LAN_MINOR_MASK) >> COD_MINOR_BIT_OFFSET)
+#define GET_COD_LAN_ACCESS(_cod) (((_cod) & COD_LAN_ACCESS_MASK) >> COD_LAN_ACCESS_BIT_OFFSET)
+
+//
+// LAN access percent usage subcodes
+//
+#define COD_LAN_MINOR_UNCLASSIFIED (0x00)
+
+#define COD_LAN_ACCESS_0_USED (0x00)
+#define COD_LAN_ACCESS_17_USED (0x01)
+#define COD_LAN_ACCESS_33_USED (0x02)
+#define COD_LAN_ACCESS_50_USED (0x03)
+#define COD_LAN_ACCESS_67_USED (0x04)
+#define COD_LAN_ACCESS_83_USED (0x05)
+#define COD_LAN_ACCESS_99_USED (0x06)
+#define COD_LAN_ACCESS_FULL (0x07)
+
+//
+// Used as an initializer of LAP_DATA
+//
+#define LAP_GIAC_INIT { 0x33, 0x8B, 0x9E }
+#define LAP_LIAC_INIT { 0x00, 0x8B, 0x9E }
+
+//
+// General Inquiry Access Code.
+//
+#define LAP_GIAC_VALUE (0x009E8B33)
+
+//
+// Limited Inquiry Access Code.
+//
+#define LAP_LIAC_VALUE (0x009E8B00)
+
+#define BTH_ADDR_IAC_FIRST (0x9E8B00)
+#define BTH_ADDR_IAC_LAST (0x9E8B3f)
+#define BTH_ADDR_LIAC (0x9E8B00)
+#define BTH_ADDR_GIAC (0x9E8B33)
+
+typedef UCHAR BTHSTATUS, *PBTHSTATUS;
+
+#define BTH_ERROR(_btStatus) ((_btStatus) != BTH_ERROR_SUCCESS)
+#define BTH_SUCCESS(_btStatus) ((_btStatus) == BTH_ERROR_SUCCESS)
+
+#define BTH_ERROR_SUCCESS (0x00)
+#define BTH_ERROR_UNKNOWN_HCI_COMMAND (0x01)
+#define BTH_ERROR_NO_CONNECTION (0x02)
+#define BTH_ERROR_HARDWARE_FAILURE (0x03)
+#define BTH_ERROR_PAGE_TIMEOUT (0x04)
+#define BTH_ERROR_AUTHENTICATION_FAILURE (0x05)
+#define BTH_ERROR_KEY_MISSING (0x06)
+#define BTH_ERROR_MEMORY_FULL (0x07)
+#define BTH_ERROR_CONNECTION_TIMEOUT (0x08)
+#define BTH_ERROR_MAX_NUMBER_OF_CONNECTIONS (0x09)
+#define BTH_ERROR_MAX_NUMBER_OF_SCO_CONNECTIONS (0x0a)
+#define BTH_ERROR_ACL_CONNECTION_ALREADY_EXISTS (0x0b)
+#define BTH_ERROR_COMMAND_DISALLOWED (0x0c)
+#define BTH_ERROR_HOST_REJECTED_LIMITED_RESOURCES (0x0d)
+#define BTH_ERROR_HOST_REJECTED_SECURITY_REASONS (0x0e)
+#define BTH_ERROR_HOST_REJECTED_PERSONAL_DEVICE (0x0f)
+#define BTH_ERROR_HOST_TIMEOUT (0x10)
+#define BTH_ERROR_UNSUPPORTED_FEATURE_OR_PARAMETER (0x11)
+#define BTH_ERROR_INVALID_HCI_PARAMETER (0x12)
+#define BTH_ERROR_REMOTE_USER_ENDED_CONNECTION (0x13)
+#define BTH_ERROR_REMOTE_LOW_RESOURCES (0x14)
+#define BTH_ERROR_REMOTE_POWERING_OFF (0x15)
+#define BTH_ERROR_LOCAL_HOST_TERMINATED_CONNECTION (0x16)
+#define BTH_ERROR_REPEATED_ATTEMPTS (0x17)
+#define BTH_ERROR_PAIRING_NOT_ALLOWED (0x18)
+#define BTH_ERROR_UKNOWN_LMP_PDU (0x19)
+#define BTH_ERROR_UNSUPPORTED_REMOTE_FEATURE (0x1a)
+#define BTH_ERROR_SCO_OFFSET_REJECTED (0x1b)
+#define BTH_ERROR_SCO_INTERVAL_REJECTED (0x1c)
+#define BTH_ERROR_SCO_AIRMODE_REJECTED (0x1d)
+#define BTH_ERROR_INVALID_LMP_PARAMETERS (0x1e)
+#define BTH_ERROR_UNSPECIFIED_ERROR (0x1f)
+#define BTH_ERROR_UNSUPPORTED_LMP_PARM_VALUE (0x20)
+#define BTH_ERROR_ROLE_CHANGE_NOT_ALLOWED (0x21)
+#define BTH_ERROR_LMP_RESPONSE_TIMEOUT (0x22)
+#define BTH_ERROR_LMP_TRANSACTION_COLLISION (0x23)
+#define BTH_ERROR_LMP_PDU_NOT_ALLOWED (0x24)
+#define BTH_ERROR_ENCRYPTION_MODE_NOT_ACCEPTABLE (0x25)
+#define BTH_ERROR_UNIT_KEY_NOT_USED (0x26)
+#define BTH_ERROR_QOS_IS_NOT_SUPPORTED (0x27)
+#define BTH_ERROR_INSTANT_PASSED (0x28)
+#define BTH_ERROR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED (0x29)
+
+#define BTH_ERROR_UNSPECIFIED (0xFF)
+
+//
+// Min, max, and default L2cap MTU.
+//
+#define L2CAP_MIN_MTU (48)
+#define L2CAP_MAX_MTU (0xFFFF)
+#define L2CAP_DEFAULT_MTU (672)
+
+//
+// Max l2cap signal size (48) - size of signal header (4)
+//
+#define MAX_L2CAP_PING_DATA_LENGTH (44)
+#define MAX_L2CAP_INFO_DATA_LENGTH (44)
+
+//
+// the following two structures provides information about
+// disocvered remote radios.
+//
+
+#define BDIF_ADDRESS (0x00000001)
+#define BDIF_COD (0x00000002)
+#define BDIF_NAME (0x00000004)
+#define BDIF_PAIRED (0x00000008)
+#define BDIF_PERSONAL (0x00000010)
+#define BDIF_CONNECTED (0x00000020)
+
+#define BDIF_VALID_FLAGS \
+ (BDIF_ADDRESS | BDIF_COD | BDIF_NAME | BDIF_PAIRED | BDIF_PERSONAL | \
+ BDIF_CONNECTED)
+
+typedef struct _BTH_DEVICE_INFO {
+ //
+ // Combination BDIF_Xxx flags
+ //
+ ULONG flags;
+
+ //
+ // Address of remote device.
+ //
+ BTH_ADDR address;
+
+ //
+ // Class Of Device.
+ //
+ BTH_COD classOfDevice;
+
+ //
+ // name of the device
+ //
+ CHAR name[BTH_MAX_NAME_SIZE];
+
+} BTH_DEVICE_INFO, *PBTH_DEVICE_INFO;
+
+//
+// Buffer associated with GUID_BLUETOOTH_RADIO_IN_RANGE
+//
+typedef struct _BTH_RADIO_IN_RANGE {
+ //
+ // Information about the remote radio
+ //
+ BTH_DEVICE_INFO deviceInfo;
+
+ //
+ // The previous flags value for the BTH_DEVICE_INFO. The receiver of this
+ // notification can compare the deviceInfo.flags and previousDeviceFlags
+ // to determine what has changed about this remote radio.
+ //
+ // For instance, if BDIF_NAME is set in deviceInfo.flags and not in
+ // previousDeviceFlags, the remote radio's has just been retrieved.
+ //
+ ULONG previousDeviceFlags;
+
+} BTH_RADIO_IN_RANGE, *PBTH_RADIO_IN_RANGE;
+
+//
+// Buffer associated with GUID_BLUETOOTH_L2CAP_EVENT
+//
+typedef struct _BTH_L2CAP_EVENT_INFO {
+ //
+ // Remote radio address which the L2CAP event is associated with
+ //
+ BTH_ADDR bthAddress;
+
+ //
+ // The PSM that is either being connected to or disconnected from
+ //
+ USHORT psm;
+
+ //
+ // If != 0, then the channel has just been established. If == 0, then the
+ // channel has been destroyed. Notifications for a destroyed channel will
+ // only be sent for channels successfully established.
+ //
+ UCHAR connected;
+
+ //
+ // If != 0, then the local host iniated the l2cap connection. If == 0, then
+ // the remote host initated the connection. This field is only valid if
+ // connect is != 0.
+ //
+ UCHAR initiated;
+
+} BTH_L2CAP_EVENT_INFO, *PBTH_L2CAP_EVENT_INFO;
+
+#define HCI_CONNNECTION_TYPE_ACL (1)
+#define HCI_CONNNECTION_TYPE_SCO (2)
+
+//
+// Buffer associated with GUID_BLUETOOTH_HCI_EVENT
+//
+typedef struct _BTH_HCI_EVENT_INFO {
+ //
+ // Remote radio address which the HCI event is associated with
+ //
+ BTH_ADDR bthAddress;
+
+ //
+ // HCI_CONNNECTION_TYPE_XXX value
+ //
+ UCHAR connectionType;
+
+ //
+ // If != 0, then the underlying connection to the remote radio has just
+ // been estrablished. If == 0, then the underlying conneciton has just been
+ // destroyed.
+ //
+ UCHAR connected;
+
+} BTH_HCI_EVENT_INFO, *PBTH_HCI_EVENT_INFO;
+
+#define MAX_UUIDS_IN_QUERY (12)
+
+#define BTH_VID_DEFAULT_VALUE (0xFFFF)
+
+#define SDP_ERROR_INVALID_SDP_VERSION (0x0001)
+#define SDP_ERROR_INVALID_RECORD_HANDLE (0x0002)
+#define SDP_ERROR_INVALID_REQUEST_SYNTAX (0x0003)
+#define SDP_ERROR_INVALID_PDU_SIZE (0x0004)
+#define SDP_ERROR_INVALID_CONTINUATION_STATE (0x0005)
+#define SDP_ERROR_INSUFFICIENT_RESOURCES (0x0006)
+
+//
+// Defined by windows to handle server errors that are not described by the
+// above errors. Start at 0x0100 so we don't go anywhere near the spec
+// defined values.
+//
+
+//
+// Success, nothing went wrong
+//
+#define SDP_ERROR_SUCCESS ((SDP_ERROR) 0x0000)
+
+//
+// The SDP PDU or parameters other than the SDP stream response was not correct
+//
+#define SDP_ERROR_SERVER_INVALID_RESPONSE ((SDP_ERROR) 0x0100)
+
+//
+// The SDP response stream did not parse correctly.
+//
+#define SDP_ERROR_SERVER_RESPONSE_DID_NOT_PARSE ((SDP_ERROR) 0x0200)
+
+//
+// The SDP response stream was successfully parsed, but did not match the
+// required format for the query.
+//
+#define SDP_ERROR_SERVER_BAD_FORMAT ((SDP_ERROR) 0x0300)
+
+//
+// SDP was unable to send a continued query back to the server
+//
+#define SDP_ERROR_COULD_NOT_SEND_CONTINUE ((SDP_ERROR) 0x0400)
+
+//
+// Server sent a response that was too large to fit in the caller's buffer.
+//
+#define SDP_ERROR_RESPONSE_TOO_LARGE ((SDP_ERROR) 0x0500)
+
+
+#define SDP_ATTRIB_RECORD_HANDLE (0x0000)
+#define SDP_ATTRIB_CLASS_ID_LIST (0x0001)
+#define SDP_ATTRIB_RECORD_STATE (0x0002)
+#define SDP_ATTRIB_SERVICE_ID (0x0003)
+#define SDP_ATTRIB_PROTOCOL_DESCRIPTOR_LIST (0x0004)
+#define SDP_ATTRIB_BROWSE_GROUP_LIST (0x0005)
+#define SDP_ATTRIB_LANG_BASE_ATTRIB_ID_LIST (0x0006)
+#define SDP_ATTRIB_INFO_TIME_TO_LIVE (0x0007)
+#define SDP_ATTRIB_AVAILABILITY (0x0008)
+#define SDP_ATTRIB_PROFILE_DESCRIPTOR_LIST (0x0009)
+#define SDP_ATTRIB_DOCUMENTATION_URL (0x000A)
+#define SDP_ATTRIB_CLIENT_EXECUTABLE_URL (0x000B)
+#define SDP_ATTRIB_ICON_URL (0x000C)
+#define SDP_ATTRIB_ADDITIONAL_PROTOCOL_DESCRIPTOR_LIST \
+ (0x000D)
+
+//
+// Attribute IDs in the range of 0x000D - 0x01FF are reserved for future use
+//
+#define SDP_ATTRIB_PROFILE_SPECIFIC (0x0200)
+
+#define LANG_BASE_LANGUAGE_INDEX (0x0000)
+#define LANG_BASE_ENCODING_INDEX (0x0001)
+#define LANG_BASE_OFFSET_INDEX (0x0002)
+#define LANG_DEFAULT_ID (0x0100)
+
+#define STRING_NAME_OFFSET (0x0000)
+#define STRING_DESCRIPTION_OFFSET (0x0001)
+#define STRING_PROVIDER_NAME_OFFSET (0x0002)
+
+#define SDP_ATTRIB_SDP_VERSION_NUMBER_LIST (0x0200)
+#define SDP_ATTRIB_SDP_DATABASE_STATE (0x0201)
+
+#define SDP_ATTRIB_BROWSE_GROUP_ID (0x0200)
+
+#define SDP_ATTRIB_CORDLESS_EXTERNAL_NETWORK (0x0301)
+
+#define SDP_ATTRIB_FAX_CLASS_1_SUPPORT (0x0302)
+#define SDP_ATTRIB_FAX_CLASS_2_0_SUPPORT (0x0303)
+#define SDP_ATTRIB_FAX_CLASS_2_SUPPORT (0x0304)
+#define SDP_ATTRIB_FAX_AUDIO_FEEDBACK_SUPPORT (0x0305)
+
+#define SDP_ATTRIB_HEADSET_REMOTE_AUDIO_VOLUME_CONTROL (0x0302)
+
+#define SDP_ATTRIB_LAN_LPSUBNET (0x0200)
+
+#define SDP_ATTRIB_OBJECT_PUSH_SUPPORTED_FORMATS_LIST (0x0303)
+
+#define SDP_ATTRIB_SYNCH_SUPPORTED_DATA_STORES_LIST (0x0301)
+
+// this is in the assigned numbers doc, but it does not show up in any profile
+#define SDP_ATTRIB_SERVICE_VERSION (0x0300)
+
+#define SDP_ATTRIB_PAN_NETWORK_ADDRESS (0x0306)
+#define SDP_ATTRIB_PAN_WAP_GATEWAY (0x0307)
+#define SDP_ATTRIB_PAN_HOME_PAGE_URL (0x0308)
+#define SDP_ATTRIB_PAN_WAP_STACK_TYPE (0x0309)
+#define SDP_ATTRIB_PAN_SECURITY_DESCRIPTION (0x030A)
+#define SDP_ATTRIB_PAN_NET_ACCESS_TYPE (0x030B)
+#define SDP_ATTRIB_PAN_MAX_NET_ACCESS_RATE (0x030C)
+
+#define SDP_ATTRIB_IMAGING_SUPPORTED_CAPABILITIES (0x0310)
+#define SDP_ATTRIB_IMAGING_SUPPORTED_FEATURES (0x0311)
+#define SDP_ATTRIB_IMAGING_SUPPORTED_FUNCTIONS (0x0312)
+#define SDP_ATTRIB_IMAGING_TOTAL_DATA_CAPACITY (0x0313)
+
+#define SDP_ATTRIB_DI_SPECIFICATION_ID (0x0200)
+#define SDP_ATTRIB_DI_VENDOR_ID (0x0201)
+#define SDP_ATTRIB_DI_PRODUCT_ID (0x0202)
+#define SDP_ATTRIB_DI_VERSION (0x0203)
+#define SDP_ATTRIB_DI_PRIMARY_RECORD (0x0204)
+#define SDP_ATTRIB_DI_VENDOR_ID_SOURCE (0x0205)
+
+#define SDP_ATTRIB_HID_DEVICE_RELEASE_NUMBER (0x0200)
+#define SDP_ATTRIB_HID_PARSER_VERSION (0x0201)
+#define SDP_ATTRIB_HID_DEVICE_SUBCLASS (0x0202)
+#define SDP_ATTRIB_HID_COUNTRY_CODE (0x0203)
+#define SDP_ATTRIB_HID_VIRTUAL_CABLE (0x0204)
+#define SDP_ATTRIB_HID_RECONNECT_INITIATE (0x0205)
+#define SDP_ATTRIB_HID_DESCRIPTOR_LIST (0x0206)
+#define SDP_ATTRIB_HID_LANG_ID_BASE_LIST (0x0207)
+#define SDP_ATTRIB_HID_SDP_DISABLE (0x0208)
+#define SDP_ATTRIB_HID_BATTERY_POWER (0x0209)
+#define SDP_ATTRIB_HID_REMOTE_WAKE (0x020A)
+#define SDP_ATTRIB_HID_REPORT_LIST (0x020B)
+#define SDP_ATTRIB_HID_SUPERVISION_TIMEOUT (0x020C)
+#define SDP_ATTRIB_HID_NORMALLY_CONNECTABLE (0x020D)
+#define SDP_ATTRIB_HID_BOOT_DEVICE (0x020E)
+
+//
+// Profile specific values
+//
+#define CORDLESS_EXTERNAL_NETWORK_PSTN (0x01)
+#define CORDLESS_EXTERNAL_NETWORK_ISDN (0x02)
+#define CORDLESS_EXTERNAL_NETWORK_GSM (0x03)
+#define CORDLESS_EXTERNAL_NETWORK_CDMA (0x04)
+#define CORDLESS_EXTERNAL_NETWORK_ANALOG_CELLULAR (0x05)
+#define CORDLESS_EXTERNAL_NETWORK_PACKET_SWITCHED (0x06)
+#define CORDLESS_EXTERNAL_NETWORK_OTHER (0x07)
+
+#define OBJECT_PUSH_FORMAT_VCARD_2_1 (0x01)
+#define OBJECT_PUSH_FORMAT_VCARD_3_0 (0x02)
+#define OBJECT_PUSH_FORMAT_VCAL_1_0 (0x03)
+#define OBJECT_PUSH_FORMAT_ICAL_2_0 (0x04)
+#define OBJECT_PUSH_FORMAT_VNOTE (0x05)
+#define OBJECT_PUSH_FORMAT_VMESSAGE (0x06)
+#define OBJECT_PUSH_FORMAT_ANY (0xFF)
+
+#define SYNCH_DATA_STORE_PHONEBOOK (0x01)
+#define SYNCH_DATA_STORE_CALENDAR (0x03)
+#define SYNCH_DATA_STORE_NOTES (0x05)
+#define SYNCH_DATA_STORE_MESSAGES (0x06)
+
+#define DI_VENDOR_ID_SOURCE_BLUETOOTH_SIG (0x0001)
+#define DI_VENDOR_ID_SOURCE_USB_IF (0x0002)
+
+#define PSM_SDP (0x0001)
+#define PSM_RFCOMM (0x0003)
+#define PSM_TCS_BIN (0x0005)
+#define PSM_TCS_BIN_CORDLESS (0x0007)
+#define PSM_BNEP (0x000F)
+#define PSM_HID_CONTROL (0x0011)
+#define PSM_HID_INTERRUPT (0x0013)
+#define PSM_AVCTP (0x0017)
+#define PSM_AVDTP (0x0019)
+#define PSM_UDI_C_PLANE (0x001D)
+
+//
+// Strings
+//
+#define STR_ADDR_FMTA "(%02x:%02x:%02x:%02x:%02x:%02x)"
+#define STR_ADDR_FMTW L"(%02x:%02x:%02x:%02x:%02x:%02x)"
+
+#define STR_ADDR_SHORT_FMTA "%04x%08x"
+#define STR_ADDR_SHORT_FMTW L"%04x%08x"
+
+#if defined(UNICODE) || defined(BTH_KERN)
+
+#define STR_ADDR_FMT STR_ADDR_FMTW
+#define STR_ADDR_SHORT_FMT STR_ADDR_SHORT_FMTW
+
+#else // UNICODE
+
+#define STR_ADDR_FMT STR_ADDR_FMTA
+#define STR_ADDR_SHORT_FMT STR_ADDR_SHORT_FMTA
+
+#endif // UNICODE
+
+#define GET_BITS(field,offset,mask) ( ( (field) >> (offset) ) & (mask) )
+#define GET_BIT(field,offset) ( GET_BITS(field,offset,0x1) )
+
+#define LMP_3_SLOT_PACKETS(x) (GET_BIT(x, 0))
+#define LMP_5_SLOT_PACKETS(x) (GET_BIT(x, 1))
+#define LMP_ENCRYPTION(x) (GET_BIT(x, 2))
+#define LMP_SLOT_OFFSET(x) (GET_BIT(x, 3))
+#define LMP_TIMING_ACCURACY(x) (GET_BIT(x, 4))
+#define LMP_SWITCH(x) (GET_BIT(x, 5))
+#define LMP_HOLD_MODE(x) (GET_BIT(x, 6))
+#define LMP_SNIFF_MODE(x) (GET_BIT(x, 7))
+#define LMP_PARK_MODE(x) (GET_BIT(x, 8))
+#define LMP_RSSI(x) (GET_BIT(x, 9))
+#define LMP_CHANNEL_QUALITY_DRIVEN_MODE(x) (GET_BIT(x,10))
+#define LMP_SCO_LINK(x) (GET_BIT(x,11))
+#define LMP_HV2_PACKETS(x) (GET_BIT(x,12))
+#define LMP_HV3_PACKETS(x) (GET_BIT(x,13))
+#define LMP_MU_LAW_LOG(x) (GET_BIT(x,14))
+#define LMP_A_LAW_LOG(x) (GET_BIT(x,15))
+#define LMP_CVSD(x) (GET_BIT(x,16))
+#define LMP_PAGING_SCHEME(x) (GET_BIT(x,17))
+#define LMP_POWER_CONTROL(x) (GET_BIT(x,18))
+#define LMP_TRANSPARENT_SCO_DATA(x) (GET_BIT(x,19))
+#define LMP_FLOW_CONTROL_LAG(x) (GET_BITS(x,20,0x3))
+
+#endif // GUID_DEFS_ONLY
+
+#endif // __BTHDEF_H__
diff --git a/cpp/wiiscan/include/bthsdpdef.h b/cpp/wiiscan/include/bthsdpdef.h
new file mode 100644
index 0000000..1764816
--- /dev/null
+++ b/cpp/wiiscan/include/bthsdpdef.h
@@ -0,0 +1,111 @@
+#ifndef __BTHSDPDEF_H__
+#define __BTHSDPDEF_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct SDP_LARGE_INTEGER_16 {
+ ULONGLONG LowPart;
+ LONGLONG HighPart;
+};
+
+
+struct SDP_ULARGE_INTEGER_16 {
+ ULONGLONG LowPart;
+ ULONGLONG HighPart;
+};
+
+typedef struct SDP_ULARGE_INTEGER_16 SDP_ULARGE_INTEGER_16, *PSDP_ULARGE_INTEGER_16, *LPSDP_ULARGE_INTEGER_16;
+typedef struct SDP_LARGE_INTEGER_16 SDP_LARGE_INTEGER_16, *PSDP_LARGE_INTEGER_16, *LPSDP_LARGE_INTEGER_16;
+
+enum NodeContainerType {
+ NodeContainerTypeSequence,
+ NodeContainerTypeAlternative
+};
+
+typedef enum NodeContainerType NodeContainerType;
+
+typedef USHORT SDP_ERROR, *PSDP_ERROR;
+
+enum SDP_TYPE {
+ SDP_TYPE_NIL = 0x00,
+ SDP_TYPE_UINT = 0x01,
+ SDP_TYPE_INT = 0x02,
+ SDP_TYPE_UUID = 0x03,
+ SDP_TYPE_STRING = 0x04,
+ SDP_TYPE_BOOLEAN = 0x05,
+ SDP_TYPE_SEQUENCE = 0x06,
+ SDP_TYPE_ALTERNATIVE = 0x07,
+ SDP_TYPE_URL = 0x08,
+ SDP_TYPE_CONTAINER = 0x20
+};
+// 9 - 31 are reserved
+typedef enum SDP_TYPE SDP_TYPE;
+
+// allow for a little easier type checking / sizing for integers and UUIDs
+// ((SDP_ST_XXX & 0xF0) >> 4) == SDP_TYPE_XXX
+// size of the data (in bytes) is encoded as ((SDP_ST_XXX & 0xF0) >> 8)
+enum SDP_SPECIFICTYPE {
+ SDP_ST_NONE = 0x0000,
+
+ SDP_ST_UINT8 = 0x0010,
+ SDP_ST_UINT16 = 0x0110,
+ SDP_ST_UINT32 = 0x0210,
+ SDP_ST_UINT64 = 0x0310,
+ SDP_ST_UINT128 = 0x0410,
+
+ SDP_ST_INT8 = 0x0020,
+ SDP_ST_INT16 = 0x0120,
+ SDP_ST_INT32 = 0x0220,
+ SDP_ST_INT64 = 0x0320,
+ SDP_ST_INT128 = 0x0420,
+
+ SDP_ST_UUID16 = 0x0130,
+ SDP_ST_UUID32 = 0x0220,
+ SDP_ST_UUID128 = 0x0430
+};
+typedef enum SDP_SPECIFICTYPE SDP_SPECIFICTYPE;
+
+typedef struct _SdpAttributeRange {
+ USHORT minAttribute;
+ USHORT maxAttribute;
+} SdpAttributeRange;
+
+
+typedef
+#ifdef USE_MIDL_SYNTAX
+ [switch_type(unsigned short)]
+#endif
+ union SdpQueryUuidUnion {
+#ifdef USE_MIDL_SYNTAX
+ [case(SDP_ST_UUID128)]
+#endif
+ GUID uuid128;
+
+#ifdef USE_MIDL_SYNTAX
+ [case(SDP_ST_UUID32)]
+#endif _NTDDK_
+ ULONG uuid32;
+
+#ifdef USE_MIDL_SYNTAX
+ [case(SDP_ST_UUID16)]
+#endif _NTDDK_
+ USHORT uuid16;
+} SdpQueryUuidUnion;
+
+typedef struct _SdpQueryUuid {
+#ifdef USE_MIDL_SYNTAX
+ [switch_is(uuidType)]
+#endif
+ SdpQueryUuidUnion u;
+
+ USHORT uuidType;
+} SdpQueryUuid;
+
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif // __BTHSDPDEF_H__
diff --git a/cpp/wiiscan/include/wiiuse.h b/cpp/wiiscan/include/wiiuse.h
index 9dff81c..bd3c27f 100644
--- a/cpp/wiiscan/include/wiiuse.h
+++ b/cpp/wiiscan/include/wiiuse.h
@@ -128,6 +128,7 @@
#define EXP_NUNCHUK 1
#define EXP_CLASSIC 2
#define EXP_GUITAR_HERO_3 3
+#define EXP_BALANCE_BOARD 4
/* IR correction types */
typedef enum ir_position_t {
@@ -371,6 +372,17 @@ typedef struct ir_t {
} ir_t;
+/**
+ * @struct speaker_t
+ */
+typedef struct speaker_t {
+ byte format;
+ byte rate;
+ byte freq;
+ byte vol;
+} speaker_t;
+
+
/**
* @struct joystick_t
* @brief Joystick calibration structure.
@@ -451,6 +463,34 @@ typedef struct guitar_hero_3_t {
} guitar_hero_3_t;
+/**
+ * @struct balance_board_data_t
+ * @brief Balance board l/r, t/b corner data data.
+ */
+typedef struct balance_board_data_t {
+ int tr;
+ int br;
+ int tl;
+ int bl;
+} balance_board_data_t;
+
+
+/**
+ * @struct balance_board_t
+ * @brief Balance board expansion device.
+ */
+typedef struct balance_board_t {
+ float tr; /** Top Right weight */
+ float br; /** Bottom Right weight */
+ float tl; /** Top Left weight */
+ float bl; /** Bottom Left weight */
+ struct balance_board_data_t raw; /** Raw actual values */
+ struct balance_board_data_t cal_0; /** Calibration values at 0kg */
+ struct balance_board_data_t cal_17; /** Calibration values at 17kg */
+ struct balance_board_data_t cal_34; /** Calibration values at 34kg */
+} balance_board_t;
+
+
/**
* @struct expansion_t
* @brief Generic expansion device plugged into wiimote.
@@ -462,6 +502,7 @@ typedef struct expansion_t {
struct nunchuk_t nunchuk;
struct classic_ctrl_t classic;
struct guitar_hero_3_t gh3;
+ struct balance_board_t bb;
};
} expansion_t;
@@ -492,6 +533,7 @@ typedef struct wiimote_state_t {
struct vec3b_t exp_accel;
float exp_r_shoulder;
float exp_l_shoulder;
+ struct balance_board_data_t exp_bb_raw;
/* ir_t */
int ir_ax;
@@ -522,7 +564,9 @@ typedef enum WIIUSE_EVENT_TYPE {
WIIUSE_CLASSIC_CTRL_INSERTED,
WIIUSE_CLASSIC_CTRL_REMOVED,
WIIUSE_GUITAR_HERO_3_CTRL_INSERTED,
- WIIUSE_GUITAR_HERO_3_CTRL_REMOVED
+ WIIUSE_GUITAR_HERO_3_CTRL_REMOVED,
+ WIIUSE_BALANCE_BOARD_CTRL_INSERTED,
+ WIIUSE_BALANCE_BOARD_CTRL_REMOVED
} WIIUSE_EVENT_TYPE;
/**
@@ -563,6 +607,7 @@ typedef struct wiimote_t {
WCONST struct gforce_t gforce; /**< current gravity forces on each axis */
WCONST struct ir_t ir; /**< IR data */
+ WCONST struct speaker_t speaker; /**< speaker */
WCONST unsigned short btns; /**< what buttons have just been pressed */
WCONST unsigned short btns_held; /**< what buttons are being held down */
@@ -643,6 +688,18 @@ WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int le
WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold);
WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold);
+/* speaker.c */
+WIIUSE_EXPORT extern void wiiuse_speaker_enable(struct wiimote_t* wm);
+WIIUSE_EXPORT extern void wiiuse_speaker_disable(struct wiimote_t* wm);
+WIIUSE_EXPORT extern void wiiuse_speaker_mute(struct wiimote_t* wm);
+WIIUSE_EXPORT extern void wiiuse_speaker_unmute(struct wiimote_t* wm);
+WIIUSE_EXPORT extern void wiiuse_speaker_activate(struct wiimote_t* wm);
+WIIUSE_EXPORT extern void wiiuse_speaker_deactivate(struct wiimote_t* wm);
+WIIUSE_EXPORT extern void wiiuse_speaker_format(struct wiimote_t* wm, byte format);
+WIIUSE_EXPORT extern void wiiuse_speaker_volume(struct wiimote_t* wm, double vol);
+WIIUSE_EXPORT extern void wiiuse_speaker_rate(struct wiimote_t* wm, byte rate, byte freq);
+WIIUSE_EXPORT extern void wiiuse_speaker_config(struct wiimote_t* wm);
+WIIUSE_EXPORT extern void wiiuse_speaker_data(struct wiimote_t* wm, byte* data, int len);
#ifdef __cplusplus
}
diff --git a/cpp/wiiscan/lib/irprops.lib b/cpp/wiiscan/lib/irprops.lib
new file mode 100644
index 0000000..1761118
Binary files /dev/null and b/cpp/wiiscan/lib/irprops.lib differ
diff --git a/cpp/wiiscan/msvc/wiiscan.sln b/cpp/wiiscan/msvc/wiiscan.sln
deleted file mode 100644
index a35473f..0000000
--- a/cpp/wiiscan/msvc/wiiscan.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual C++ Express 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wiiscan", "wiiscan.vcxproj", "{6E522A84-9956-44F9-B30A-CF44F3CED276}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {6E522A84-9956-44F9-B30A-CF44F3CED276}.Debug|Win32.ActiveCfg = Debug|Win32
- {6E522A84-9956-44F9-B30A-CF44F3CED276}.Debug|Win32.Build.0 = Debug|Win32
- {6E522A84-9956-44F9-B30A-CF44F3CED276}.Release|Win32.ActiveCfg = Release|Win32
- {6E522A84-9956-44F9-B30A-CF44F3CED276}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/cpp/wiiscan/msvc/wiiscan.vcxproj b/cpp/wiiscan/msvc/wiiscan.vcxproj
deleted file mode 100644
index 3eb33d2..0000000
--- a/cpp/wiiscan/msvc/wiiscan.vcxproj
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {6E522A84-9956-44F9-B30A-CF44F3CED276}
- wiiscan
- Win32Proj
-
-
-
- Application
- MultiByte
- true
-
-
- Application
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
- true
- false
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
- false
- false
- ..\include;$(IncludePath)
- ..\lib;$(LibraryPath)
- ..\include;$(IncludePath)
- ..\lib;$(LibraryPath)
-
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
-
-
- Level3
- ProgramDatabase
- false
-
-
- true
- Console
- MachineX86
-
-
-
-
-
-
- MaxSpeed
- AnySuitable
- false
- Speed
- true
- %(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- MultiThreaded
- true
-
-
- Level3
-
-
- false
-
-
- true
- Console
- true
- true
- MachineX86
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cpp/wiiscan/msvc/wiiscan.vcxproj.user b/cpp/wiiscan/msvc/wiiscan.vcxproj.user
deleted file mode 100644
index 695b5c7..0000000
--- a/cpp/wiiscan/msvc/wiiscan.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/cpp/wiiscan/args.h b/cpp/wiiscan/src/args.h
similarity index 100%
rename from cpp/wiiscan/args.h
rename to cpp/wiiscan/src/args.h
diff --git a/cpp/wiiscan/configfile.h b/cpp/wiiscan/src/configfile.h
similarity index 96%
rename from cpp/wiiscan/configfile.h
rename to cpp/wiiscan/src/configfile.h
index 574d738..859b802 100644
--- a/cpp/wiiscan/configfile.h
+++ b/cpp/wiiscan/src/configfile.h
@@ -41,7 +41,7 @@ class Configfile {
throw_("bad stream in configfile input operator, missing end tag");
}
- string Strip(const string& s) const
+ void Strip(const string& s) const
{
for(size_t i=0;i
+#include
+
#define Unimplemented throw_("Function unimplemented")
#define Dontgethere throw_("Dontgethere")
@@ -116,7 +119,7 @@ inline int Message(const string& title,const string& msg,const int type)
// 4 = MB_YESNO
// 5 = MB_RETRYCANCEL
// 6 = MB_CANCELTRYCONTINUE: if(WINVER >= 0x0500)
- const long hr=MessageBox(NULL,msg.c_str(),title.c_str(),type);
+ MessageBox(NULL,msg.c_str(),title.c_str(),type);
#else
Unimplemented;
#endif
@@ -226,11 +229,10 @@ inline string System(const string& cmd,const bool throwexception=true,const bool
if (pret!=0) *pret=n;
return "";
} else {
- static size_t n=0;
#ifdef WIN32
const string rm="del ";
char tmp[1024];
- if (tmpnam_s(tmp,1024)) throw_("error in creating win32 temp name");
+ if (tmpnam(tmp)) throw_("error in creating win32 temp name");
const string file(tmp);
#else
const string rm="rm ";
@@ -261,11 +263,9 @@ string Getlocaltime()
FUNSTACK;
time_t rawtime;
time(&rawtime);
- struct tm timeinfo;
- localtime_s(&timeinfo,&rawtime);
- char buff[1024];
- asctime_s(buff,1014,&timeinfo);
- return string(buff);
+ struct tm* timeinfo;
+ timeinfo = localtime(&rawtime);
+ return asctime(timeinfo);
}
class timer
diff --git a/cpp/wiiscan/process.h b/cpp/wiiscan/src/process.h
similarity index 100%
rename from cpp/wiiscan/process.h
rename to cpp/wiiscan/src/process.h
diff --git a/cpp/wiiscan/reg.h b/cpp/wiiscan/src/reg.h
similarity index 100%
rename from cpp/wiiscan/reg.h
rename to cpp/wiiscan/src/reg.h
diff --git a/cpp/wiiscan/stringfun.h b/cpp/wiiscan/src/stringfun.h
similarity index 100%
rename from cpp/wiiscan/stringfun.h
rename to cpp/wiiscan/src/stringfun.h
diff --git a/cpp/wiiscan/templatefun.h b/cpp/wiiscan/src/templatefun.h
similarity index 94%
rename from cpp/wiiscan/templatefun.h
rename to cpp/wiiscan/src/templatefun.h
index 0cb60e9..5212732 100644
--- a/cpp/wiiscan/templatefun.h
+++ b/cpp/wiiscan/src/templatefun.h
@@ -1,6 +1,8 @@
#ifndef __TEMPLATE_FUN__
#define __TEMPLATE_FUN__
+#define __stdcall
+
template
class Autobool
{
@@ -26,7 +28,7 @@ private:
void operator=(const DeviceAutoClose&);
public:
- DeviceAutoClose(T dev,R(__stdcall *fun)(void*)) : m_dev(dev), m_fun(fun), m_init(true)
+ DeviceAutoClose(T dev,R(__stdcall *fun)(void*)) : m_dev(dev), m_fun(fun), m_init(true)
{
FUNSTACK;
assert(m_fun!=NULL);
@@ -49,4 +51,4 @@ public:
};
-#endif // __TEMPLATE_FUN__
\ No newline at end of file
+#endif // __TEMPLATE_FUN__
diff --git a/cpp/wiiscan/toolsfun.h b/cpp/wiiscan/src/toolsfun.h
similarity index 100%
rename from cpp/wiiscan/toolsfun.h
rename to cpp/wiiscan/src/toolsfun.h
diff --git a/cpp/wiiscan/usbm.h b/cpp/wiiscan/src/usbm.h
similarity index 100%
rename from cpp/wiiscan/usbm.h
rename to cpp/wiiscan/src/usbm.h
diff --git a/cpp/wiiscan/wiiscan.cpp b/cpp/wiiscan/src/wiiscan.cpp
similarity index 100%
rename from cpp/wiiscan/wiiscan.cpp
rename to cpp/wiiscan/src/wiiscan.cpp
diff --git a/cpp/wiiscan/wiiscan.h b/cpp/wiiscan/src/wiiscan.h
similarity index 95%
rename from cpp/wiiscan/wiiscan.h
rename to cpp/wiiscan/src/wiiscan.h
index 4b65804..69d9de0 100644
--- a/cpp/wiiscan/wiiscan.h
+++ b/cpp/wiiscan/src/wiiscan.h
@@ -24,6 +24,8 @@
#define VC_EXTRALEAN
+#define sprintf_s snprintf
+
#include "toolsfun.h"
#include "wiiuse.h"
#include "usbm.h"
@@ -169,7 +171,7 @@ bool USB_microio_updown(const bool up,const bool dbg)
return true;
}
-bool __stdcall CloseDelcomhandle(HANDLE h){return DelcomCloseDevice(h)==0;}
+bool CloseDelcomhandle(HANDLE h){return DelcomCloseDevice(h)==0;}
void do_cmd(HANDLE di, int ma, int mi, int lsb, int msb, unsigned char *data, unsigned datalen)
{
@@ -206,7 +208,7 @@ bool USB_delconio_updown(const bool up,const bool dbg)
log << " USB Delcon info:" << (char*)&names[0] << "\n SN=" << DelcomReadDeviceSerialNum((char*)&names[0], NULL) << endl;
}
- DeviceAutoClose h(DelcomOpenDevice((char*)&names[0],0),CloseDelcomhandle);
+ DeviceAutoClose h(DelcomOpenDevice((char*)&names[0],0), CloseDelcomhandle);
if(up) do_cmd(h(),10,1,0xFE,0,0,0);
else do_cmd(h(),10,1,0xFF,0,0,0);
@@ -460,7 +462,7 @@ bool ReachedMax(const int i)
return false;
}
-bool RemoveDev(const BLUETOOTH_DEVICE_INFO& bdi)
+bool RemoveDev(BLUETOOTH_DEVICE_INFO& bdi)
{
FUNSTACK;
DWORD status=BluetoothUpdateDeviceRecord(&bdi);
@@ -481,7 +483,9 @@ HANDLE RadioInfo(const string& btr,const bool dbg)
HANDLE hRadio=NULL;
BLUETOOTH_FIND_RADIO_PARAMS btfrp=Get_BLUETOOTH_FIND_RADIO_PARAMS();
- DeviceAutoClose hbf(BluetoothFindFirstRadio(&btfrp,&hRadio),&BluetoothFindRadioClose);
+ DeviceAutoClose hbf(
+ BluetoothFindFirstRadio(&btfrp,&hRadio),
+ BluetoothFindRadioClose);
if (hbf()==NULL) {
if (dbg) log << " " << endl;
@@ -526,8 +530,9 @@ bool ScanDevices(const int timeout)
BLUETOOTH_DEVICE_SEARCH_PARAMS bdsp=Get_BLUETOOTH_DEVICE_SEARCH_PARAMS(timeout);
BLUETOOTH_DEVICE_INFO bdi=Get_BLUETOOTH_DEVICE_INFO();
- DeviceAutoClose hbf(BluetoothFindFirstDevice(&bdsp,&bdi),&BluetoothFindDeviceClose);
- const DWORD dwErr = GetLastError();
+ DeviceAutoClose hbf(BluetoothFindFirstDevice(&bdsp,&bdi),
+ BluetoothFindDeviceClose);
+ //const DWORD dwErr = GetLastError();
if (hbf()==NULL) {
log << " ** warning: no devices found" << endl << "Done [FAILED]" << endl;
@@ -579,9 +584,9 @@ bool RemoveDevice(const string& d,const bool dbg)
bdsp.fReturnUnknown = FALSE;
bdsp.fReturnConnected = TRUE;
- DeviceAutoClose hbf(BluetoothFindFirstDevice(&bdsp,&bdi),&BluetoothFindDeviceClose);
+ DeviceAutoClose hbf(BluetoothFindFirstDevice(&bdsp,&bdi),BluetoothFindDeviceClose);
- const DWORD dwErr = GetLastError();
+ //const DWORD dwErr = GetLastError();
if (hbf()==NULL) {
log << " ** error: failed to find device" << endl << "Done [FAILED]" << endl;
@@ -699,7 +704,7 @@ bool OpenDevice(const string& d,const string& btr,const int timeout,const int wi
// DWORD status=GetLastError();
unsigned long tid=0;
- DeviceAutoClose h(CreateThread(0,0,BluetoothFindFirstDevice_thread,&p,0,&tid),CloseHandle);
+ DeviceAutoClose h(CreateThread(0,0,BluetoothFindFirstDevice_thread,&p,0,&tid),CloseHandle);
timer tthread;
Sleep(timeout);
@@ -717,7 +722,7 @@ bool OpenDevice(const string& d,const string& btr,const int timeout,const int wi
assert(p.hbf!=0);
BLUETOOTH_DEVICE_INFO bdi=p.bdi;
- DeviceAutoClose hbf(p.hbf,&BluetoothFindDeviceClose);
+ DeviceAutoClose hbf(p.hbf,BluetoothFindDeviceClose);
if (hbf()==NULL) {
log << " ** error: no devices found" << endl << "Done [FAILED]" << endl;
@@ -744,11 +749,11 @@ bool OpenDevice(const string& d,const string& btr,const int timeout,const int wi
if (dbg) log << " BluetoothUpdateDeviceRecord()...OK" << endl;
{
- DeviceAutoClose hRadio(RadioInfo(btr,dbg),&CloseHandle);
+ DeviceAutoClose hRadio(RadioInfo(btr,dbg),CloseHandle);
if (hRadio()==NULL) throw_("failed to get radio");
if (dbg) log << " RadioInfo()...OK" << endl;
- const GUID service=HumanInterfaceDeviceServiceClass_UUID;
+ GUID service=HumanInterfaceDeviceServiceClass_UUID;
status=BluetoothSetServiceState(hRadio(),&bdi,&service,BLUETOOTH_SERVICE_ENABLE);
if (dbg && status==ERROR_SUCCESS) log << " BluetoothSetServiceState()...OK" << endl;
diff --git a/cpp/wiiscan/wiiscan.test.h b/cpp/wiiscan/src/wiiscan.test.h
similarity index 100%
rename from cpp/wiiscan/wiiscan.test.h
rename to cpp/wiiscan/src/wiiscan.test.h
diff --git a/cpp/wiiuse/Debug/copy.bat b/cpp/wiiuse/Debug/copy.bat
index bb541cd..f33aec8 100644
--- a/cpp/wiiuse/Debug/copy.bat
+++ b/cpp/wiiuse/Debug/copy.bat
@@ -1,3 +1,5 @@
-copy ..\src\wiiuse.h ..\..\WiiuseJ\src\wiiuse.h
+copy ..\src\wiiuse.h ..\..\WiiuseJ\include\wiiuse.h
+copy ..\src\wiiuse.h ..\..\Wiiscan\include\wiiuse.h
copy wiiuse.lib ..\..\WiiuseJ\lib\wiiuse.lib
+copy wiiuse.lib ..\..\Wiiscan\lib\wiiuse.lib
copy wiiuse.dll ..\..\Mimis\wiiuse.dll
\ No newline at end of file
diff --git a/cpp/wiiuse/Release/copy.bat b/cpp/wiiuse/Release/copy.bat
index bb541cd..f33aec8 100644
--- a/cpp/wiiuse/Release/copy.bat
+++ b/cpp/wiiuse/Release/copy.bat
@@ -1,3 +1,5 @@
-copy ..\src\wiiuse.h ..\..\WiiuseJ\src\wiiuse.h
+copy ..\src\wiiuse.h ..\..\WiiuseJ\include\wiiuse.h
+copy ..\src\wiiuse.h ..\..\Wiiscan\include\wiiuse.h
copy wiiuse.lib ..\..\WiiuseJ\lib\wiiuse.lib
+copy wiiuse.lib ..\..\Wiiscan\lib\wiiuse.lib
copy wiiuse.dll ..\..\Mimis\wiiuse.dll
\ No newline at end of file
diff --git a/cpp/wiiuse/src/balance_board.c b/cpp/wiiuse/src/balance_board.c
new file mode 100644
index 0000000..502005f
--- /dev/null
+++ b/cpp/wiiuse/src/balance_board.c
@@ -0,0 +1,140 @@
+/*
+ * wiiuse
+ *
+ * Written By:
+ * Michael Laforest < para >
+ * Email: < thepara (--AT--) g m a i l [--DOT--] com >
+ * This file:
+ * Bertho Stultiens < para >
+ *
+ * Copyright 2009
+ *
+ * This file is part of wiiuse.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * $Header$
+ *
+ */
+
+/**
+ * @file
+ * @brief Balance Board expansion device.
+ */
+
+#include
+#include
+#include
+
+#ifdef WIN32
+ #include
+#endif
+
+#include "definitions.h"
+#include "wiiuse_internal.h"
+#include "dynamics.h"
+#include "events.h"
+#include "balance_board.h"
+
+/**
+ * @brief Handle the handshake data from the guitar.
+ *
+ * @param cc A pointer to a classic_ctrl_t structure.
+ * @param data The data read in from the device.
+ * @param len The length of the data block, in bytes.
+ *
+ * @return Returns 1 if handshake was successful, 0 if not.
+ */
+int balance_board_handshake(struct wiimote_t* wm, struct balance_board_t* bb, byte* data, unsigned short len) {
+ int i;
+
+ bb->tr = 0.0;
+ bb->br = 0.0;
+ bb->tl = 0.0;
+ bb->br = 0.0;
+
+ if (len < 0xe0)
+ return 0;
+
+ if (data[0xdc] != 0xa4) {
+ /* decrypt data */
+ for (i = 0; i < len; ++i)
+ data[i] = (data[i] ^ 0x17) + 0x17;
+ }
+
+ /* See: http://wiibrew.org/wiki/Wii_Balance_Board */
+ /* Unknown data at 0xa40020..23 (mine says: 0x44 0x69 0x00 0x00) */
+ bb->cal_0.tr = (data[0x04] << 8) + data[0x05];
+ bb->cal_0.br = (data[0x06] << 8) + data[0x07];
+ bb->cal_0.tl = (data[0x08] << 8) + data[0x09];
+ bb->cal_0.bl = (data[0x0a] << 8) + data[0x0b];
+ bb->cal_17.tr = (data[0x0c] << 8) + data[0x0d];
+ bb->cal_17.br = (data[0x0e] << 8) + data[0x0f];
+ bb->cal_17.tl = (data[0x10] << 8) + data[0x11];
+ bb->cal_17.bl = (data[0x12] << 8) + data[0x13];
+ bb->cal_34.tr = (data[0x14] << 8) + data[0x15];
+ bb->cal_34.br = (data[0x16] << 8) + data[0x17];
+ bb->cal_34.tl = (data[0x18] << 8) + data[0x19];
+ bb->cal_34.bl = (data[0x1a] << 8) + data[0x1b];
+ /* Unknown data at 0xa4003c..3f (mine says: 0x4c 0x81 0x59 0x95) */
+
+ WIIUSE_DEBUG("calibration 0: %04x %04x %04x %04x\n", bb->cal_0.tr, bb->cal_0.br, bb->cal_0.tl, bb->cal_0.br);
+ WIIUSE_DEBUG("calibration 17: %04x %04x %04x %04x\n", bb->cal_17.tr, bb->cal_17.br, bb->cal_17.tl, bb->cal_17.br);
+ WIIUSE_DEBUG("calibration 34: %04x %04x %04x %04x\n", bb->cal_34.tr, bb->cal_34.br, bb->cal_34.tl, bb->cal_34.br);
+
+ /* handshake done */
+ wm->exp.type = EXP_BALANCE_BOARD;
+
+ #ifdef WIN32
+ wm->timeout = WIIMOTE_DEFAULT_TIMEOUT;
+ #endif
+
+ return 1;
+}
+
+
+/**
+ * @brief The balance board disconnected.
+ *
+ * @param cc A pointer to a balance_board_t structure.
+ */
+void balance_board_disconnected(struct balance_board_t* bb) {
+ memset(bb, 0, sizeof(*bb));
+}
+
+
+
+/**
+ * @brief Handle balance board event.
+ *
+ * @param cc A pointer to a balance board_t structure.
+ * @param msg The message specified in the event packet.
+ */
+#define set_bbval(x) do {\
+ if(bb->raw.x < bb->cal_17.x) \
+ bb->x = 17.0 * (float)(bb->raw.x - bb->cal_0.x) / (float)(bb->cal_17.x - bb->cal_0.x); \
+ else \
+ bb->x = 17.0 * (1.0 + (float)(bb->raw.x - bb->cal_17.x) / (float)(bb->cal_34.x - bb->cal_17.x)); \
+ } while(0)
+void balance_board_event(struct balance_board_t* bb, byte* msg) {
+ bb->raw.tr = (msg[0] << 8) + msg[1];
+ bb->raw.br = (msg[2] << 8) + msg[3];
+ bb->raw.tl = (msg[4] << 8) + msg[5];
+ bb->raw.bl = (msg[6] << 8) + msg[7];
+ set_bbval(tr);
+ set_bbval(br);
+ set_bbval(tl);
+ set_bbval(bl);
+}
+
diff --git a/cpp/wiiuse/src/balance_board.h b/cpp/wiiuse/src/balance_board.h
new file mode 100644
index 0000000..a3d2ca5
--- /dev/null
+++ b/cpp/wiiuse/src/balance_board.h
@@ -0,0 +1,53 @@
+/*
+ * wiiuse
+ *
+ * Written By:
+ * Michael Laforest < para >
+ * Email: < thepara (--AT--) g m a i l [--DOT--] com >
+ * This file:
+ * Bertho Stultiens < para >
+ *
+ * Copyright 2009
+ *
+ * This file is part of wiiuse.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * $Header$
+ *
+ */
+
+/**
+ * @file
+ * @brief Balance Board expansion device.
+ */
+
+#ifndef BALANCE_BOARD_H_INCLUDED
+#define BALANCE_BOARD_H_INCLUDED
+
+#include "wiiuse_internal.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int balance_board_handshake(struct wiimote_t* wm, struct balance_board_t* bb, byte* data, unsigned short len);
+void balance_board_disconnected(struct balance_board_t* bb);
+void balance_board_event(struct balance_board_t* bb, byte* msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // BALANCE_BOARD_H_INCLUDED
diff --git a/cpp/wiiuse/src/events.c b/cpp/wiiuse/src/events.c
index 01d8a6a..26a822c 100644
--- a/cpp/wiiuse/src/events.c
+++ b/cpp/wiiuse/src/events.c
@@ -56,6 +56,7 @@
#include "nunchuk.h"
#include "classic.h"
#include "guitar_hero_3.h"
+#include "balance_board.h"
#include "events.h"
static void idle_cycle(struct wiimote_t* wm);
@@ -612,6 +613,9 @@ static void handle_expansion(struct wiimote_t* wm, byte* msg) {
case EXP_GUITAR_HERO_3:
guitar_hero_3_event(&wm->exp.gh3, msg);
break;
+ case EXP_BALANCE_BOARD:
+ balance_board_event(&wm->exp.bb, msg);
+ break;
default:
break;
}
@@ -681,6 +685,12 @@ void handshake_expansion(struct wiimote_t* wm, byte* data, unsigned short len) {
wm->event = WIIUSE_GUITAR_HERO_3_CTRL_INSERTED;
break;
}
+ case EXP_ID_CODE_BALANCE_BOARD:
+ {
+ if (balance_board_handshake(wm, &wm->exp.bb, data, len))
+ wm->event = WIIUSE_BALANCE_BOARD_CTRL_INSERTED;
+ break;
+ }
default:
{
WIIUSE_WARNING("Unknown expansion type. Code: 0x%x", id);
@@ -721,6 +731,10 @@ void disable_expansion(struct wiimote_t* wm) {
guitar_hero_3_disconnected(&wm->exp.gh3);
wm->event = WIIUSE_GUITAR_HERO_3_CTRL_REMOVED;
break;
+ case EXP_BALANCE_BOARD:
+ balance_board_disconnected(&wm->exp.bb);
+ wm->event = WIIUSE_BALANCE_BOARD_CTRL_REMOVED;
+ break;
default:
break;
}
@@ -772,6 +786,10 @@ static void save_state(struct wiimote_t* wm) {
wm->lstate.exp_btns = wm->exp.gh3.btns;
break;
+ case EXP_BALANCE_BOARD:
+ wm->lstate.exp_bb_raw = wm->exp.bb.raw;
+ break;
+
case EXP_NONE:
break;
}
@@ -867,6 +885,14 @@ static int state_changed(struct wiimote_t* wm) {
STATE_CHANGED(wm->lstate.exp_btns, wm->exp.gh3.btns);
break;
}
+ case EXP_BALANCE_BOARD:
+ {
+ STATE_CHANGED(wm->lstate.exp_bb_raw.tr, wm->exp.bb.raw.tr);
+ STATE_CHANGED(wm->lstate.exp_bb_raw.br, wm->exp.bb.raw.br);
+ STATE_CHANGED(wm->lstate.exp_bb_raw.tl, wm->exp.bb.raw.tl);
+ STATE_CHANGED(wm->lstate.exp_bb_raw.bl, wm->exp.bb.raw.bl);
+ break;
+ }
case EXP_NONE:
{
break;
diff --git a/cpp/wiiuse/src/ir.c b/cpp/wiiuse/src/ir.c
index 7a9bb68..4cc2e2d 100644
--- a/cpp/wiiuse/src/ir.c
+++ b/cpp/wiiuse/src/ir.c
@@ -623,11 +623,10 @@ static void reorder_ir_dots(struct ir_dot_t* dot) {
dot[i].order = 0;
for (order = 1; order < 5; ++order) {
- i = 0;
-
- for (; !dot[i].visible || dot[i].order; ++i)
- if (i > 4)
+ for (i = 0; i < 4 && (!dot[i].visible || dot[i].order); ++i) {
+ if (i >= 4)
return;
+ }
for (j = 0; j < 4; ++j) {
if (dot[j].visible && !dot[j].order && (dot[j].x < dot[i].x))
diff --git a/cpp/wiiuse/src/wiiuse.h b/cpp/wiiuse/src/wiiuse.h
index b27637f..bd3c27f 100644
--- a/cpp/wiiuse/src/wiiuse.h
+++ b/cpp/wiiuse/src/wiiuse.h
@@ -128,6 +128,7 @@
#define EXP_NUNCHUK 1
#define EXP_CLASSIC 2
#define EXP_GUITAR_HERO_3 3
+#define EXP_BALANCE_BOARD 4
/* IR correction types */
typedef enum ir_position_t {
@@ -462,6 +463,34 @@ typedef struct guitar_hero_3_t {
} guitar_hero_3_t;
+/**
+ * @struct balance_board_data_t
+ * @brief Balance board l/r, t/b corner data data.
+ */
+typedef struct balance_board_data_t {
+ int tr;
+ int br;
+ int tl;
+ int bl;
+} balance_board_data_t;
+
+
+/**
+ * @struct balance_board_t
+ * @brief Balance board expansion device.
+ */
+typedef struct balance_board_t {
+ float tr; /** Top Right weight */
+ float br; /** Bottom Right weight */
+ float tl; /** Top Left weight */
+ float bl; /** Bottom Left weight */
+ struct balance_board_data_t raw; /** Raw actual values */
+ struct balance_board_data_t cal_0; /** Calibration values at 0kg */
+ struct balance_board_data_t cal_17; /** Calibration values at 17kg */
+ struct balance_board_data_t cal_34; /** Calibration values at 34kg */
+} balance_board_t;
+
+
/**
* @struct expansion_t
* @brief Generic expansion device plugged into wiimote.
@@ -473,6 +502,7 @@ typedef struct expansion_t {
struct nunchuk_t nunchuk;
struct classic_ctrl_t classic;
struct guitar_hero_3_t gh3;
+ struct balance_board_t bb;
};
} expansion_t;
@@ -503,6 +533,7 @@ typedef struct wiimote_state_t {
struct vec3b_t exp_accel;
float exp_r_shoulder;
float exp_l_shoulder;
+ struct balance_board_data_t exp_bb_raw;
/* ir_t */
int ir_ax;
@@ -533,7 +564,9 @@ typedef enum WIIUSE_EVENT_TYPE {
WIIUSE_CLASSIC_CTRL_INSERTED,
WIIUSE_CLASSIC_CTRL_REMOVED,
WIIUSE_GUITAR_HERO_3_CTRL_INSERTED,
- WIIUSE_GUITAR_HERO_3_CTRL_REMOVED
+ WIIUSE_GUITAR_HERO_3_CTRL_REMOVED,
+ WIIUSE_BALANCE_BOARD_CTRL_INSERTED,
+ WIIUSE_BALANCE_BOARD_CTRL_REMOVED
} WIIUSE_EVENT_TYPE;
/**
diff --git a/cpp/wiiuse/src/wiiuse_internal.h b/cpp/wiiuse/src/wiiuse_internal.h
index 1b2f423..25357a4 100644
--- a/cpp/wiiuse/src/wiiuse_internal.h
+++ b/cpp/wiiuse/src/wiiuse_internal.h
@@ -152,6 +152,7 @@
#define EXP_ID_CODE_NUNCHUK 0x9A1EFEFE
#define EXP_ID_CODE_CLASSIC_CONTROLLER 0x9A1EFDFD
#define EXP_ID_CODE_GUITAR 0x9A1EFDFB
+#define EXP_ID_CODE_BALANCE_BOARD 0xA4200402
#define EXP_HANDSHAKE_LEN 224
diff --git a/cpp/wiiusej/.cproject b/cpp/wiiusej/.cproject
index 80c883a..7d4e8d1 100644
--- a/cpp/wiiusej/.cproject
+++ b/cpp/wiiusej/.cproject
@@ -48,6 +48,7 @@
@@ -62,7 +63,8 @@
-
+
+
@@ -120,6 +122,7 @@
@@ -134,7 +137,8 @@
-
+
+
@@ -165,4 +169,5 @@
+
diff --git a/cpp/wiiusej/.project b/cpp/wiiusej/.project
index 5d0c701..0b1461f 100644
--- a/cpp/wiiusej/.project
+++ b/cpp/wiiusej/.project
@@ -27,7 +27,7 @@
org.eclipse.cdt.make.core.buildLocation
- ${workspace_loc:/WiiuseJ/Release}
+ ${workspace_loc:/WiiuseJ/Debug}
org.eclipse.cdt.make.core.contents
diff --git a/cpp/wiiusej/Release/libwiiusej.dll b/cpp/wiiusej/Release/libwiiusej.dll
index 0d194a4..0e213fa 100644
Binary files a/cpp/wiiusej/Release/libwiiusej.dll and b/cpp/wiiusej/Release/libwiiusej.dll differ
diff --git a/cpp/wiiusej/src/wiiuse.h b/cpp/wiiusej/include/wiiuse.h
similarity index 92%
rename from cpp/wiiusej/src/wiiuse.h
rename to cpp/wiiusej/include/wiiuse.h
index b27637f..bd3c27f 100644
--- a/cpp/wiiusej/src/wiiuse.h
+++ b/cpp/wiiusej/include/wiiuse.h
@@ -128,6 +128,7 @@
#define EXP_NUNCHUK 1
#define EXP_CLASSIC 2
#define EXP_GUITAR_HERO_3 3
+#define EXP_BALANCE_BOARD 4
/* IR correction types */
typedef enum ir_position_t {
@@ -462,6 +463,34 @@ typedef struct guitar_hero_3_t {
} guitar_hero_3_t;
+/**
+ * @struct balance_board_data_t
+ * @brief Balance board l/r, t/b corner data data.
+ */
+typedef struct balance_board_data_t {
+ int tr;
+ int br;
+ int tl;
+ int bl;
+} balance_board_data_t;
+
+
+/**
+ * @struct balance_board_t
+ * @brief Balance board expansion device.
+ */
+typedef struct balance_board_t {
+ float tr; /** Top Right weight */
+ float br; /** Bottom Right weight */
+ float tl; /** Top Left weight */
+ float bl; /** Bottom Left weight */
+ struct balance_board_data_t raw; /** Raw actual values */
+ struct balance_board_data_t cal_0; /** Calibration values at 0kg */
+ struct balance_board_data_t cal_17; /** Calibration values at 17kg */
+ struct balance_board_data_t cal_34; /** Calibration values at 34kg */
+} balance_board_t;
+
+
/**
* @struct expansion_t
* @brief Generic expansion device plugged into wiimote.
@@ -473,6 +502,7 @@ typedef struct expansion_t {
struct nunchuk_t nunchuk;
struct classic_ctrl_t classic;
struct guitar_hero_3_t gh3;
+ struct balance_board_t bb;
};
} expansion_t;
@@ -503,6 +533,7 @@ typedef struct wiimote_state_t {
struct vec3b_t exp_accel;
float exp_r_shoulder;
float exp_l_shoulder;
+ struct balance_board_data_t exp_bb_raw;
/* ir_t */
int ir_ax;
@@ -533,7 +564,9 @@ typedef enum WIIUSE_EVENT_TYPE {
WIIUSE_CLASSIC_CTRL_INSERTED,
WIIUSE_CLASSIC_CTRL_REMOVED,
WIIUSE_GUITAR_HERO_3_CTRL_INSERTED,
- WIIUSE_GUITAR_HERO_3_CTRL_REMOVED
+ WIIUSE_GUITAR_HERO_3_CTRL_REMOVED,
+ WIIUSE_BALANCE_BOARD_CTRL_INSERTED,
+ WIIUSE_BALANCE_BOARD_CTRL_REMOVED
} WIIUSE_EVENT_TYPE;
/**
diff --git a/cpp/wiiusej/lib/wiiuse.lib b/cpp/wiiusej/lib/wiiuse.lib
index 29d3a0f..a23c43d 100644
Binary files a/cpp/wiiusej/lib/wiiuse.lib and b/cpp/wiiusej/lib/wiiuse.lib differ
diff --git a/java/src/mimis/device/wiimote/WiimoteDevice.java b/java/src/mimis/device/wiimote/WiimoteDevice.java
index 61c092e..317e289 100644
--- a/java/src/mimis/device/wiimote/WiimoteDevice.java
+++ b/java/src/mimis/device/wiimote/WiimoteDevice.java
@@ -25,8 +25,9 @@ import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
public class WiimoteDevice extends Device implements GestureListener {
protected static final String TITLE = "Wiimote";
protected static final int RUMBLE = 50;
- protected static final int TIMEOUT = 200;
- protected static final int LED_SLEEP = 50;
+ protected static final int CONNECTED_TIMEOUT = 500;
+ protected static final int LED_TIMEOUT = 1000;
+ protected static final int LED_SLEEP = 20;
protected static WiimoteService wiimoteService;
protected WiimoteEventMapCycle eventMapCycle;
@@ -36,6 +37,7 @@ public class WiimoteDevice extends Device implements GestureListener {
protected GestureDevice gestureDevice;
protected int gestureId;
protected LedWorker ledWorker;
+ protected boolean disconnect;
static {
WiimoteDevice.wiimoteService = new WiimoteService();
@@ -55,34 +57,32 @@ public class WiimoteDevice extends Device implements GestureListener {
/* Worker */
protected void activate() throws ActivateException {
add(eventMapCycle.player);
- connect();
+ wiimote = null;
try {
- wiimote = wiimoteService.getDevice(this);
- ledWorker.start();
+ connect();
} catch (DeviceNotFoundException e) {
- log.error(e);
- throw new ActivateException();
+ wiimoteDiscovery.start();
}
super.activate();
}
- public boolean active() {
+ public synchronized boolean active() {
if (wiimote != null) {
- if (!ledWorker.active()) {
- ledWorker.start();
- }
connected = false;
wiimote.getStatus();
- synchronized (this) {
- try {
- wait(TIMEOUT);
- } catch (InterruptedException e) {
- log.error(e);
- }
+ try {
+ wait(CONNECTED_TIMEOUT);
+ } catch (InterruptedException e) {
+ log.error(e);
}
- if (!connected) {
- active = false;
- ledWorker.stop();
+ if (!connected) {
+ try {
+ log.debug("!");
+ connect();
+ } catch (DeviceNotFoundException e) {
+ disconnect = true;
+ stop();
+ }
}
}
return active;
@@ -90,16 +90,25 @@ public class WiimoteDevice extends Device implements GestureListener {
protected void deactivate() throws DeactivateException {
super.deactivate();
- ledWorker.deactivate();
- wiimoteDiscovery.deactivate();
+ ledWorker.stop();
+ wiimoteDiscovery.stop();
+ if (disconnect) {
+ if (wiimote != null) {
+ wiimote.disconnect();
+ }
+ wiimoteDiscovery.disconnect();
+ disconnect = false;
+ //start();
+ }
}
public void exit() {
super.exit();
ledWorker.exit();
- /*if (wiimote != null) {
- disconnect();
- }*/
+ if (wiimote != null) {
+ wiimote.disconnect();
+ wiimote = null;
+ }
wiimoteService.exit();
wiimoteDiscovery.exit();
}
@@ -109,13 +118,13 @@ public class WiimoteDevice extends Device implements GestureListener {
switch (action) {
case SHIFT:
log.debug("Shift");
- /*reset();
+ reset();
add(eventMapCycle.mimis);
- add(eventMapCycle.like);*/
+ add(eventMapCycle.like);
break;
case UNSHIFT:
log.debug("Unshift");
- //reset();
+ reset();
add(eventMapCycle.player);
break;
case TRAIN:
@@ -159,36 +168,11 @@ public class WiimoteDevice extends Device implements GestureListener {
}
/* Connectivity */
- public void connect() throws ActivateException {
- wiimote = null;
- try {
- wiimote = wiimoteService.getDevice(this);
- ledWorker.start();
- } catch (DeviceNotFoundException e) {
- wiimoteDiscovery.activate();
- }
- }
-
- public void connected() {
- try {
- wiimote = wiimoteService.getDevice(this);
- wiimoteDiscovery.stop();
- } catch (DeviceNotFoundException e) {
- log.error(e);
- }
- }
-
- public void disconnect() {
- wiimote.disconnect();
- wiimote = null;
- }
-
- public void disconnected() {
- try {
- wiimoteDiscovery.activate();
- } catch (ActivateException e) {
- log.error(e);
- }
+ public void connect() throws DeviceNotFoundException {
+ wiimote = wiimoteService.getDevice(this);
+ log.debug("Connected");
+ wiimoteDiscovery.stop();
+ ledWorker.start();
}
/* Listeners */
@@ -200,10 +184,10 @@ public class WiimoteDevice extends Device implements GestureListener {
Button button = WiimoteButton.create(pressed);
log.trace("Press: " + button);
add(new Press(button));
- } else if (pressed == 0 && released != 0) {
+ } else if (pressed == 0 && released != 0) {
Button button = WiimoteButton.create(released);
log.trace("Release: " + button);
- add(new Release(button));
+ add(new Release(button));
}
} catch (UnknownButtonException e) {}
}
@@ -223,6 +207,7 @@ public class WiimoteDevice extends Device implements GestureListener {
public LedWorker() {
ledCycle = new ArrayCycle();
+ ledCycle.add(1);
ledCycle.add(3);
ledCycle.add(6);
ledCycle.add(12);
@@ -230,9 +215,15 @@ public class WiimoteDevice extends Device implements GestureListener {
ledCycle.add(12);
ledCycle.add(6);
ledCycle.add(3);
+ ledCycle.add(1);
}
- public void deactivate() throws DeactivateException {
+ public void activate() throws ActivateException {
+ sleep(LED_TIMEOUT);
+ super.activate();
+ }
+
+ public void deactivate() throws DeactivateException {
super.deactivate();
setLeds(1);
}
@@ -244,12 +235,8 @@ public class WiimoteDevice extends Device implements GestureListener {
protected void setLeds(int leds) {
if (wiimote != null) {
- wiimote.setLeds(
- (leds & 1) > 0,
- (leds & 2) > 0,
- (leds & 4) > 0,
- (leds & 8) > 0);
- sleep(leds == 8 ? 200 : 100);
+ wiimote.setLeds((leds & 1) > 0, (leds & 2) > 0, (leds & 4) > 0, (leds & 8) > 0);
+ sleep((leds == 8 ? 2 : 1) * LED_SLEEP);
}
}
}
diff --git a/java/src/mimis/device/wiimote/WiimoteDiscovery.java b/java/src/mimis/device/wiimote/WiimoteDiscovery.java
index 5bd8995..11edd5f 100644
--- a/java/src/mimis/device/wiimote/WiimoteDiscovery.java
+++ b/java/src/mimis/device/wiimote/WiimoteDiscovery.java
@@ -4,24 +4,27 @@ import java.io.IOException;
import java.util.Scanner;
import mimis.Worker;
+import mimis.exception.device.DeviceNotFoundException;
import mimis.exception.worker.ActivateException;
import mimis.exception.worker.DeactivateException;
public class WiimoteDiscovery extends Worker {
+ protected static final int TIMEOUT = 1000;
protected WiimoteDevice wiimoteDevice;
protected Process process;
protected boolean disconnect;
public WiimoteDiscovery(WiimoteDevice wiimoteDevice) {
this.wiimoteDevice = wiimoteDevice;
- disconnect = true;
}
protected boolean connect() {
- return execute("-c nintendo");
+ log.debug("Connect");
+ return execute("-c nintendo"); // Nintendo RVL-CNT-01 RVL-WBC-01
}
protected boolean disconnect() {
+ log.debug("Disconnect");
return execute("-d nintendo");
}
@@ -31,7 +34,11 @@ public class WiimoteDiscovery extends Worker {
process = Runtime.getRuntime().exec(command);
Scanner scanner = new Scanner(process.getInputStream());
while (scanner.hasNext()) {
- if (scanner.next().equals("[OK]")) {
+ String line = scanner.nextLine();
+ if (line.contains("error: BluetoothSetServiceState()")) {
+ disconnect = true;
+ return false;
+ } else if (line.contains("[OK]")) {
return true;
}
}
@@ -43,15 +50,6 @@ public class WiimoteDiscovery extends Worker {
return false;
}
- protected void work() {
- if (connect()) {
- wiimoteDevice.connected();
- } else if (disconnect) {
- disconnect();
- disconnect = false;
- }
- }
-
public void activate() throws ActivateException {
super.activate();
}
@@ -62,4 +60,20 @@ public class WiimoteDiscovery extends Worker {
process.destroy();
}
}
+
+ protected void work() {
+ if (disconnect) {
+ disconnect();
+ disconnect = false;
+ }
+ if (connect()) {
+ log.debug("Connected");
+ try {
+ sleep(TIMEOUT);
+ wiimoteDevice.connect();
+ } catch (DeviceNotFoundException e) {
+ disconnect = true;
+ }
+ }
+ }
}
diff --git a/java/src/mimis/device/wiimote/WiimoteService.java b/java/src/mimis/device/wiimote/WiimoteService.java
index 43e7dc0..10f6b7e 100644
--- a/java/src/mimis/device/wiimote/WiimoteService.java
+++ b/java/src/mimis/device/wiimote/WiimoteService.java
@@ -27,6 +27,14 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
public class WiimoteService extends WiiUseApiManager implements WiimoteListener {
protected Log log = LogFactory.getLog(getClass());
+
+ public static void main(String[] args) {
+ Log log = LogFactory.getLog(WiimoteService.class);
+ WiimoteService wiimoteService = new WiimoteService();
+ for (Wiimote wm : wiimoteService.getWiimotes(1, false)) {
+ log.debug(wm);
+ }
+ }
protected final boolean RUMBLE = false;
@@ -57,8 +65,8 @@ public class WiimoteService extends WiiUseApiManager implements WiimoteListener
wiimote.addWiiMoteEventListeners(this);
wiimoteList.add(id);
wiimoteDeviceMap.put(id, wiimoteDevice);
- return wiimote;
}
+ return wiimote;
}
throw new DeviceNotFoundException();
}
diff --git a/java/wiiscan-bb.exe b/java/wiiscan-bb.exe
new file mode 100644
index 0000000..7822c04
Binary files /dev/null and b/java/wiiscan-bb.exe differ
diff --git a/java/wiiuse.dll b/java/wiiuse.dll
index 024c623..b6356cd 100644
Binary files a/java/wiiuse.dll and b/java/wiiuse.dll differ
diff --git a/java/wiiusej.dll b/java/wiiusej.dll
index f494123..0d9093f 100644
Binary files a/java/wiiusej.dll and b/java/wiiusej.dll differ