Export native projects for wii related binaries to separate repositories

This commit is contained in:
2014-10-29 21:41:16 +00:00
parent d46892fbd0
commit 9c45eaa7b9
70 changed files with 0 additions and 20090 deletions

View File

@@ -1,151 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.debug.1313294112">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.debug.1313294112" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<macros>
<stringMacro name="target" type="VALUE_TEXT" value="wiipair"/>
</macros>
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.debug.1313294112" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.1313294112." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.1606459632" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.1400801069" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.debug"/>
<builder buildPath="${workspace_loc:/Wiiscan/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1038745333" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool command="as" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.312047017" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1633887679" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.467778333" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug.480343089" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug">
<option id="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level.1217318328" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level.1686233059" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.1929858827" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
</option>
<option id="gnu.cpp.compiler.option.other.other.1746557196" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -fpermissive" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1020795710" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.226403212" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.exe.debug.option.optimization.level.805230373" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.exe.debug.option.debugging.level.958575927" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.15033032" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug.1193975353" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug.945221910" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug">
<option id="gnu.cpp.link.option.paths.1277553684" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
</option>
<option id="gnu.cpp.link.option.libs.683496236" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="bthprops"/>
<listOptionValue builtIn="false" value="odbccp32"/>
<listOptionValue builtIn="false" value="irprops"/>
<listOptionValue builtIn="false" value="libcpmt"/>
</option>
<option id="gnu.cpp.link.option.flags.941494999" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="" valueType="string"/>
<option id="gnu.cpp.link.option.strip.132174675" name="Omit all symbol information (-s)" superClass="gnu.cpp.link.option.strip" value="false" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1294514710" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.release.1147005981">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.release.1147005981" moduleId="org.eclipse.cdt.core.settings" name="Release">
<macros>
<stringMacro name="target" type="VALUE_TEXT" value="wiipair"/>
</macros>
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.release.1147005981" name="Release" parent="cdt.managedbuild.config.gnu.mingw.exe.release">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.release.1147005981." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.release.1457737133" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.release.1320357259" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.release"/>
<builder buildPath="${workspace_loc:/Wiiscan/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1900936223" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool command="as" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release.1320132974" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.2118467120" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.24300882" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
<tool command="g++" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release.1597340797" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release">
<option id="gnu.cpp.compiler.mingw.exe.release.option.optimization.level.434289127" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.exe.release.option.debugging.level.925028123" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.1857921938" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
</option>
<option id="gnu.cpp.compiler.option.other.other.1784522890" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -fpermissive" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1090014067" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.481111125" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.exe.release.option.optimization.level.1533075923" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.exe.release.option.debugging.level.1946013826" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1764704290" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release.98347709" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release.1801877662" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release">
<option id="gnu.cpp.link.option.libs.1604900232" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="bthprops"/>
<listOptionValue builtIn="false" value="odbccp32"/>
<listOptionValue builtIn="false" value="irprops"/>
<listOptionValue builtIn="false" value="libcpmt"/>
</option>
<option id="gnu.cpp.link.option.paths.1267841202" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
</option>
<option id="gnu.cpp.link.option.flags.755517020" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="" valueType="string"/>
<option id="gnu.cpp.link.option.strip.1519066152" name="Omit all symbol information (-s)" superClass="gnu.cpp.link.option.strip" value="false" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1431555461" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="Wiiscan.cdt.managedbuild.target.gnu.mingw.exe.1693973787" name="Executable" projectType="cdt.managedbuild.target.gnu.mingw.exe"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.debug.1313294112;cdt.managedbuild.config.gnu.mingw.exe.debug.1313294112.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug.480343089;cdt.managedbuild.tool.gnu.cpp.compiler.input.1020795710">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.release.1147005981;cdt.managedbuild.config.gnu.mingw.exe.release.1147005981.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release.1597340797;cdt.managedbuild.tool.gnu.cpp.compiler.input.1090014067">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.debug.1313294112;cdt.managedbuild.config.gnu.mingw.exe.debug.1313294112.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.226403212;cdt.managedbuild.tool.gnu.c.compiler.input.15033032">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.release.1147005981;cdt.managedbuild.config.gnu.mingw.exe.release.1147005981.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.481111125;cdt.managedbuild.tool.gnu.c.compiler.input.1764704290">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.pathentry"/>
<storageModule moduleId="refreshScope" versionNumber="1">
<resource resourceType="PROJECT" workspacePath="/Wiiscan"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>

View File

@@ -1,71 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cpp.wiipair</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/Wiiscan/Release}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,858 +0,0 @@
/*++
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__

View File

@@ -1,111 +0,0 @@
#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__

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,212 +0,0 @@
#include <windows.h>
#include <bthsdpdef.h>
#include <bthdef.h>
#include <BluetoothAPIs.h>
#include <strsafe.h>
#include <tchar.h>
DWORD ShowErrorCode(LPTSTR msg, DWORD dw)
{
// Retrieve the system error message for the last-error code
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0,
NULL
);
_tprintf(_T("%s: %s"), msg, lpMsgBuf);
LocalFree(lpMsgBuf);
return dw;
}
_TCHAR * FormatBTAddress(BLUETOOTH_ADDRESS address)
{
static _TCHAR ret[20];
_stprintf(ret, _T("%02x:%02x:%02x:%02x:%02x:%02x"),
address.rgBytes[5],
address.rgBytes[4],
address.rgBytes[3],
address.rgBytes[2],
address.rgBytes[1],
address.rgBytes[0]
);
return ret;
}
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hRadios[256];
int nRadios;
int nPaired = 0;
///////////////////////////////////////////////////////////////////////
// Enumerate BT radios
///////////////////////////////////////////////////////////////////////
{
HBLUETOOTH_RADIO_FIND hFindRadio;
BLUETOOTH_FIND_RADIO_PARAMS radioParam;
_tprintf(_T("Enumerating radios...\n"));
radioParam.dwSize = sizeof(BLUETOOTH_FIND_RADIO_PARAMS);
nRadios = 0;
hFindRadio = BluetoothFindFirstRadio(&radioParam, &hRadios[nRadios++]);
if (hFindRadio)
{
while (BluetoothFindNextRadio(&radioParam, &hRadios[nRadios++]));
BluetoothFindRadioClose(hFindRadio);
}
else
{
ShowErrorCode(_T("Error enumerating radios"), GetLastError());
return (1);
}
nRadios--;
_tprintf(_T("Found %d radios\n"), nRadios);
}
///////////////////////////////////////////////////////////////////////
// Keep looping until we pair with a Wii device
///////////////////////////////////////////////////////////////////////
while (nPaired == 0)
{
int radio;
for (radio = 0; radio < nRadios; radio++)
{
BLUETOOTH_RADIO_INFO radioInfo;
HBLUETOOTH_DEVICE_FIND hFind;
BLUETOOTH_DEVICE_INFO btdi;
BLUETOOTH_DEVICE_SEARCH_PARAMS srch;
radioInfo.dwSize = sizeof(radioInfo);
btdi.dwSize = sizeof(btdi);
srch.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS);
ShowErrorCode(_T("BluetoothGetRadioInfo"), BluetoothGetRadioInfo(hRadios[radio], &radioInfo));
_tprintf(_T("Radio %d: %ls %s\n"),
radio,
radioInfo.szName,
FormatBTAddress(radioInfo.address)
);
srch.fReturnAuthenticated = TRUE;
srch.fReturnRemembered = TRUE;
srch.fReturnConnected = TRUE;
srch.fReturnUnknown = TRUE;
srch.fIssueInquiry = TRUE;
srch.cTimeoutMultiplier = 2;
srch.hRadio = hRadios[radio];
_tprintf(_T("Scanning...\n"));
hFind = BluetoothFindFirstDevice(&srch, &btdi);
if (hFind == NULL)
{
if (GetLastError() == ERROR_NO_MORE_ITEMS)
{
_tprintf(_T("No bluetooth devices found.\n"));
}
else
{
ShowErrorCode(_T("Error enumerating devices"), GetLastError());
return (1);
}
}
else
{
do
{
_tprintf(_T("Found: %s\n"), btdi.szName);
if (!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01"))
{
WCHAR pass[6];
DWORD pcServices = 16;
GUID guids[16];
BOOL error = FALSE;
if (!error)
{
if (btdi.fRemembered)
{
// Make Windows forget pairing
if (ShowErrorCode(_T("BluetoothRemoveDevice"), BluetoothRemoveDevice(&btdi.Address)) != ERROR_SUCCESS)
error = TRUE;
}
}
// MAC address is passphrase
pass[0] = radioInfo.address.rgBytes[0];
pass[1] = radioInfo.address.rgBytes[1];
pass[2] = radioInfo.address.rgBytes[2];
pass[3] = radioInfo.address.rgBytes[3];
pass[4] = radioInfo.address.rgBytes[4];
pass[5] = radioInfo.address.rgBytes[5];
if (!error)
{
// Pair with Wii device
if (ShowErrorCode(_T("BluetoothAuthenticateDevice"), BluetoothAuthenticateDevice(NULL, hRadios[radio], &btdi, pass, 6)) != ERROR_SUCCESS)
error = TRUE;
}
if (!error)
{
// If this is not done, the Wii device will not remember the pairing
if (ShowErrorCode(_T("BluetoothEnumerateInstalledServices"), BluetoothEnumerateInstalledServices(hRadios[radio], &btdi, &pcServices, guids)) != ERROR_SUCCESS)
error = TRUE;
}
/*if (!error)
{
// Activate service
if (ShowErrorCode(_T("BluetoothSetServiceState"), BluetoothSetServiceState(hRadios[radio], &btdi, &HumanInterfaceDeviceServiceClass_UUID, BLUETOOTH_SERVICE_ENABLE)) != ERROR_SUCCESS)
error = TRUE;
}*/
if (!error)
{
nPaired++;
}
} // if (!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01"))
}
while (BluetoothFindNextDevice(hFind, &btdi));
} // if (hFind == NULL)
} // for (radio = 0; radio < nRadios; radio++)
Sleep(1000);
}
///////////////////////////////////////////////////////////////////////
// Clean up
///////////////////////////////////////////////////////////////////////
{
int radio;
for (radio = 0; radio < nRadios; radio++)
{
CloseHandle(hRadios[radio]);
}
}
_tprintf(_T("=============================================\n"), nPaired);
_tprintf(_T("%d Wii devices paired\n"), nPaired);
return 0;
}

View File

@@ -1,187 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<macros>
<stringMacro name="target" type="VALUE_TEXT" value="wiiuse"/>
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.6.0_26"/>
</macros>
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Wiiuse"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Wiiuse/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="wiiuse" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.so.debug" postbuildStep="./copy.bat">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.debug.540248766" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.debug.763602244" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.debug"/>
<builder buildPath="${workspace_loc:/Wiiuse/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1458906080" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool command="as" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug.1226602461" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.131768531" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1802027" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.1760584596" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.so.debug.option.optimization.level.655662583" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.debug.option.optimization.level" value="gnu.c.optimization.level.most" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.so.debug.option.debugging.level.277209318" name="Debug Level" superClass="gnu.c.compiler.mingw.so.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.203394821" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
</option>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.993291047" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="WIIUSE_COMPILE_LIB"/>
<listOptionValue builtIn="false" value="WITH_WIIUSE_DEBUG"/>
</option>
<option id="gnu.c.compiler.option.misc.other.650784187" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2123798748" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.2136680964" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug">
<option defaultValue="true" id="gnu.c.link.mingw.so.debug.option.shared.1865152845" name="Shared (-shared)" superClass="gnu.c.link.mingw.so.debug.option.shared" valueType="boolean"/>
<option id="gnu.c.link.option.libs.584957318" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="hid"/>
<listOptionValue builtIn="false" value="Ws2_32"/>
<listOptionValue builtIn="false" value="Setupapi"/>
</option>
<option id="gnu.c.link.option.ldflags.1119328813" name="Linker flags" superClass="gnu.c.link.option.ldflags" value="" valueType="string"/>
<option id="gnu.c.link.option.implname.339020882" name="Import Library name (-Wl,--out-implib=)" superClass="gnu.c.link.option.implname" value="${target}.lib" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.119816846" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
<outputType id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.output.556110947" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.output"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.1884243654" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug">
<option id="gnu.cpp.compiler.mingw.so.debug.option.optimization.level.1243107261" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.so.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.so.debug.option.debugging.level.709323517" name="Debug Level" superClass="gnu.cpp.compiler.mingw.so.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.457060538" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.1524780060" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug">
<option defaultValue="true" id="gnu.cpp.link.mingw.so.debug.option.shared.1805658321" name="Shared (-shared)" superClass="gnu.cpp.link.mingw.so.debug.option.shared" valueType="boolean"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339" moduleId="org.eclipse.cdt.core.settings" name="Release">
<macros>
<stringMacro name="target" type="VALUE_TEXT" value="wiiuse"/>
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.6.0_26"/>
</macros>
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Wiiuse"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Wiiuse/Release"/>
<entry flags="RESOLVED" kind="libraryFile" name="wiiuse" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339" name="Release" parent="cdt.managedbuild.config.gnu.mingw.so.release" postbuildStep="./copy.bat" prebuildStep="">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.release.1012515545" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.release.834409978" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.release"/>
<builder buildPath="${workspace_loc:/Wiiuse/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1338589304" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool command="as" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.assembler.mingw.so.release.207990127" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1594234021" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1939704952" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base">
<outputType id="cdt.managedbuild.tool.gnu.archiver.output.1238104425" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.archiver.output"/>
</tool>
<tool command="gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.982483224" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.so.release.option.optimization.level.508635058" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.release.option.optimization.level" value="gnu.c.optimization.level.most" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.so.release.option.debugging.level.818549324" name="Debug Level" superClass="gnu.c.compiler.mingw.so.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.489733690" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
</option>
<option id="gnu.c.compiler.option.misc.other.1519667719" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0" valueType="string"/>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1671121896" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="WIIUSE_COMPILE_LIB"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1337607488" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release.388712238" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release">
<option defaultValue="true" id="gnu.c.link.mingw.so.release.option.shared.2009969022" name="Shared (-shared)" superClass="gnu.c.link.mingw.so.release.option.shared" valueType="boolean"/>
<option id="gnu.c.link.option.libs.1723116539" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="hid"/>
<listOptionValue builtIn="false" value="Ws2_32"/>
<listOptionValue builtIn="false" value="Setupapi"/>
</option>
<option id="gnu.c.link.option.ldflags.1077843674" name="Linker flags" superClass="gnu.c.link.option.ldflags" value="" valueType="string"/>
<option id="gnu.c.link.option.implname.1912270887" name="Import Library name (-Wl,--out-implib=)" superClass="gnu.c.link.option.implname" value="${target}.lib" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1240500014" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
<outputType id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release.output.383184444" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release.output"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release.1958353257" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release">
<option id="gnu.cpp.compiler.mingw.so.release.option.optimization.level.467548947" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.so.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.so.release.option.debugging.level.1989712247" name="Debug Level" superClass="gnu.cpp.compiler.mingw.so.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.2100141987" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.691051373" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release">
<option defaultValue="true" id="gnu.cpp.link.mingw.so.release.option.shared.1601519874" name="Shared (-shared)" superClass="gnu.cpp.link.mingw.so.release.option.shared" valueType="boolean"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="Wiiuse.cdt.managedbuild.target.gnu.mingw.so.1029253646" name="Shared Library" projectType="cdt.managedbuild.target.gnu.mingw.so"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.debug.820991892;cdt.managedbuild.config.gnu.mingw.so.debug.820991892.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.648734613;cdt.managedbuild.tool.gnu.cpp.compiler.input.1746419441">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.release.1074641339;cdt.managedbuild.config.gnu.mingw.so.release.1074641339.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release.201845193;cdt.managedbuild.tool.gnu.cpp.compiler.input.2121749170">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.release.1518879746;cdt.managedbuild.config.gnu.mingw.so.release.1518879746.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.1741778648;cdt.managedbuild.tool.gnu.c.compiler.input.1235903639">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574;cdt.managedbuild.config.gnu.mingw.so.debug.1116435574.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.1508978209;cdt.managedbuild.tool.gnu.cpp.compiler.input.152553856">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.debug.820991892;cdt.managedbuild.config.gnu.mingw.so.debug.820991892.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.460267674;cdt.managedbuild.tool.gnu.c.compiler.input.677382570">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.release.1074641339;cdt.managedbuild.config.gnu.mingw.so.release.1074641339.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.982483224;cdt.managedbuild.tool.gnu.c.compiler.input.1337607488">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.release.1518879746;cdt.managedbuild.config.gnu.mingw.so.release.1518879746.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release.529524480;cdt.managedbuild.tool.gnu.cpp.compiler.input.1256422254">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574;cdt.managedbuild.config.gnu.mingw.so.debug.1116435574.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.1760584596;cdt.managedbuild.tool.gnu.c.compiler.input.2123798748">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>

View File

@@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cpp.wiiuse</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/Wiiuse/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@@ -1,28 +0,0 @@
#Wed Oct 19 11:47:57 CEST 2011
eclipse.preferences.version=1
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/CPATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/CPATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/C_INCLUDE_PATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/C_INCLUDE_PATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/append=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/appendContributed=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/CPATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/CPATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/C_INCLUDE_PATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/C_INCLUDE_PATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/append=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/appendContributed=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/CPATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/CPATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/C_INCLUDE_PATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/C_INCLUDE_PATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/append=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/appendContributed=true
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/LIBRARY_PATH/delimiter=;
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/LIBRARY_PATH/operation=remove
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/append=true
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/appendContributed=true
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/LIBRARY_PATH/delimiter=;
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/LIBRARY_PATH/operation=remove
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/append=true
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/appendContributed=true

View File

@@ -1,5 +0,0 @@
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 ..\..\..\java\wiiusej\wiiuse.dll

Binary file not shown.

View File

@@ -1,5 +0,0 @@
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 ..\..\..\java\wiiusej\wiiuse.dll

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,487 +0,0 @@
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
HIDSDI.H
Abstract:
This module contains the PUBLIC definitions for the
code that implements the HID dll.
Environment:
Kernel & user mode
--*/
#ifndef _HIDSDI_H
#define _HIDSDI_H
#include <pshpack4.h>
//#include "wtypes.h"
//#include <windef.h>
//#include <win32.h>
//#include <basetyps.h>
typedef LONG NTSTATUS;
#include "hidusage.h"
#include "hidpi.h"
typedef struct _HIDD_CONFIGURATION {
PVOID cookie;
ULONG size;
ULONG RingBufferSize;
} HIDD_CONFIGURATION, *PHIDD_CONFIGURATION;
typedef struct _HIDD_ATTRIBUTES {
ULONG Size; // = sizeof (struct _HIDD_ATTRIBUTES)
//
// Vendor ids of this hid device
//
USHORT VendorID;
USHORT ProductID;
USHORT VersionNumber;
//
// Additional fields will be added to the end of this structure.
//
} HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
BOOLEAN __stdcall
HidD_GetAttributes (
IN HANDLE HidDeviceObject,
OUT PHIDD_ATTRIBUTES Attributes
);
/*++
Routine Description:
Fill in the given HIDD_ATTRIBUTES structure with the attributes of the
given hid device.
--*/
void __stdcall
HidD_GetHidGuid (
OUT LPGUID HidGuid
);
BOOLEAN __stdcall
HidD_GetPreparsedData (
IN HANDLE HidDeviceObject,
OUT PHIDP_PREPARSED_DATA * PreparsedData
);
/*++
Routine Description:
Given a handle to a valid Hid Class Device Object, retrieve the preparsed
data for the device. This routine will allocate the appropriately
sized buffer to hold this preparsed data. It is up to client to call
HidP_FreePreparsedData to free the memory allocated to this structure when
it is no longer needed.
Arguments:
HidDeviceObject A handle to a Hid Device that the client obtains using
a call to CreateFile on a valid Hid device string name.
The string name can be obtained using standard PnP calls.
PreparsedData An opaque data structure used by other functions in this
library to retrieve information about a given device.
Return Value:
TRUE if successful.
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_FreePreparsedData (
IN PHIDP_PREPARSED_DATA PreparsedData
);
BOOLEAN __stdcall
HidD_FlushQueue (
IN HANDLE HidDeviceObject
);
/*++
Routine Description:
Flush the input queue for the given HID device.
Arguments:
HidDeviceObject A handle to a Hid Device that the client obtains using
a call to CreateFile on a valid Hid device string name.
The string name can be obtained using standard PnP calls.
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_GetConfiguration (
IN HANDLE HidDeviceObject,
OUT PHIDD_CONFIGURATION Configuration,
IN ULONG ConfigurationLength
);
/*++
Routine Description:
Get the configuration information for this Hid device
Arguments:
HidDeviceObject A handle to a Hid Device Object.
Configuration A configuration structure. HidD_GetConfiguration MUST
be called before the configuration can be modified and
set using HidD_SetConfiguration
ConfigurationLength That is ``sizeof (HIDD_CONFIGURATION)''. Using this
parameter, we can later increase the length of the
configuration array and not break older apps.
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_SetConfiguration (
IN HANDLE HidDeviceObject,
IN PHIDD_CONFIGURATION Configuration,
IN ULONG ConfigurationLength
);
/*++
Routine Description:
Set the configuration information for this Hid device...
NOTE: HidD_GetConfiguration must be called to retrieve the current
configuration information before this information can be modified
and set.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
Configuration A configuration structure. HidD_GetConfiguration MUST
be called before the configuration can be modified and
set using HidD_SetConfiguration
ConfigurationLength That is ``sizeof (HIDD_CONFIGURATION)''. Using this
parameter, we can later increase the length of the
configuration array and not break older apps.
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_GetFeature (
IN HANDLE HidDeviceObject,
OUT PVOID ReportBuffer,
IN ULONG ReportBufferLength
);
/*++
Routine Description:
Retrieve a feature report from a HID device.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
ReportBuffer The buffer that the feature report should be placed
into. The first byte of the buffer should be set to
the report ID of the desired report
ReportBufferLength The size (in bytes) of ReportBuffer. This value
should be greater than or equal to the
FeatureReportByteLength field as specified in the
HIDP_CAPS structure for the device
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_SetFeature (
IN HANDLE HidDeviceObject,
IN PVOID ReportBuffer,
IN ULONG ReportBufferLength
);
/*++
Routine Description:
Send a feature report to a HID device.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
ReportBuffer The buffer of the feature report to send to the device
ReportBufferLength The size (in bytes) of ReportBuffer. This value
should be greater than or equal to the
FeatureReportByteLength field as specified in the
HIDP_CAPS structure for the device
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_GetInputReport (
IN HANDLE HidDeviceObject,
OUT PVOID ReportBuffer,
IN ULONG ReportBufferLength
);
/*++
Routine Description:
Retrieve an input report from a HID device.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
ReportBuffer The buffer that the input report should be placed
into. The first byte of the buffer should be set to
the report ID of the desired report
ReportBufferLength The size (in bytes) of ReportBuffer. This value
should be greater than or equal to the
InputReportByteLength field as specified in the
HIDP_CAPS structure for the device
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_SetOutputReport (
IN HANDLE HidDeviceObject,
IN PVOID ReportBuffer,
IN ULONG ReportBufferLength
);
/*++
Routine Description:
Send an output report to a HID device.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
ReportBuffer The buffer of the output report to send to the device
ReportBufferLength The size (in bytes) of ReportBuffer. This value
should be greater than or equal to the
OutputReportByteLength field as specified in the
HIDP_CAPS structure for the device
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_GetNumInputBuffers (
IN HANDLE HidDeviceObject,
OUT PULONG NumberBuffers
);
/*++
Routine Description:
This function returns the number of input buffers used by the specified
file handle to the Hid device. Each file object has a number of buffers
associated with it to queue reports read from the device but which have
not yet been read by the user-mode app with a handle to that device.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
NumberBuffers Number of buffers currently being used for this file
handle to the Hid device
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_SetNumInputBuffers (
IN HANDLE HidDeviceObject,
OUT ULONG NumberBuffers
);
/*++
Routine Description:
This function sets the number of input buffers used by the specified
file handle to the Hid device. Each file object has a number of buffers
associated with it to queue reports read from the device but which have
not yet been read by the user-mode app with a handle to that device.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
NumberBuffers New number of buffers to use for this file handle to
the Hid device
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_GetPhysicalDescriptor (
IN HANDLE HidDeviceObject,
OUT PVOID Buffer,
IN ULONG BufferLength
);
/*++
Routine Description:
This function retrieves the raw physical descriptor for the specified
Hid device.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
Buffer Buffer which on return will contain the physical
descriptor if one exists for the specified device
handle
BufferLength Length of buffer (in bytes)
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_GetManufacturerString (
IN HANDLE HidDeviceObject,
OUT PVOID Buffer,
IN ULONG BufferLength
);
/*++
Routine Description:
This function retrieves the manufacturer string from the specified
Hid device.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
Buffer Buffer which on return will contain the manufacturer
string returned from the device. This string is a
wide-character string
BufferLength Length of Buffer (in bytes)
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_GetProductString (
IN HANDLE HidDeviceObject,
OUT PVOID Buffer,
IN ULONG BufferLength
);
/*++
Routine Description:
This function retrieves the product string from the specified
Hid device.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
Buffer Buffer which on return will contain the product
string returned from the device. This string is a
wide-character string
BufferLength Length of Buffer (in bytes)
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_GetIndexedString (
IN HANDLE HidDeviceObject,
IN ULONG StringIndex,
OUT PVOID Buffer,
IN ULONG BufferLength
);
/*++
Routine Description:
This function retrieves a string from the specified Hid device that is
specified with a certain string index.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
StringIndex Index of the string to retrieve
Buffer Buffer which on return will contain the product
string returned from the device. This string is a
wide-character string
BufferLength Length of Buffer (in bytes)
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_GetSerialNumberString (
IN HANDLE HidDeviceObject,
OUT PVOID Buffer,
IN ULONG BufferLength
);
/*++
Routine Description:
This function retrieves the serial number string from the specified
Hid device.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
Buffer Buffer which on return will contain the serial number
string returned from the device. This string is a
wide-character string
BufferLength Length of Buffer (in bytes)
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
BOOLEAN __stdcall
HidD_GetMsGenreDescriptor (
IN HANDLE HidDeviceObject,
OUT PVOID Buffer,
IN ULONG BufferLength
);
/*++
Routine Description:
This function retrieves the Microsoft Genre descriptor from the specified
Hid device.
Arguments:
HidDeviceObject A handle to a Hid Device Object.
Buffer Buffer which on return will contain the descriptor
returned from the device.
BufferLength Length of Buffer (in bytes)
Return Value:
TRUE if successful
FALSE otherwise -- Use GetLastError() to get extended error information
--*/
#include <poppack.h>
#endif

View File

@@ -1,271 +0,0 @@
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
HIDUSAGE.H
Abstract:
Public Definitions of HID USAGES.
Environment:
Kernel & user mode
--*/
#ifndef __HIDUSAGE_H__
#define __HIDUSAGE_H__
//
// Usage Pages
//
typedef USHORT USAGE, *PUSAGE;
#define HID_USAGE_PAGE_UNDEFINED ((USAGE) 0x00)
#define HID_USAGE_PAGE_GENERIC ((USAGE) 0x01)
#define HID_USAGE_PAGE_SIMULATION ((USAGE) 0x02)
#define HID_USAGE_PAGE_VR ((USAGE) 0x03)
#define HID_USAGE_PAGE_SPORT ((USAGE) 0x04)
#define HID_USAGE_PAGE_GAME ((USAGE) 0x05)
#define HID_USAGE_PAGE_KEYBOARD ((USAGE) 0x07)
#define HID_USAGE_PAGE_LED ((USAGE) 0x08)
#define HID_USAGE_PAGE_BUTTON ((USAGE) 0x09)
#define HID_USAGE_PAGE_ORDINAL ((USAGE) 0x0A)
#define HID_USAGE_PAGE_TELEPHONY ((USAGE) 0x0B)
#define HID_USAGE_PAGE_CONSUMER ((USAGE) 0x0C)
#define HID_USAGE_PAGE_DIGITIZER ((USAGE) 0x0D)
#define HID_USAGE_PAGE_UNICODE ((USAGE) 0x10)
#define HID_USAGE_PAGE_ALPHANUMERIC ((USAGE) 0x14)
//
// Usages from Generic Desktop Page (0x01)
//
#define HID_USAGE_GENERIC_POINTER ((USAGE) 0x01)
#define HID_USAGE_GENERIC_MOUSE ((USAGE) 0x02)
#define HID_USAGE_GENERIC_JOYSTICK ((USAGE) 0x04)
#define HID_USAGE_GENERIC_GAMEPAD ((USAGE) 0x05)
#define HID_USAGE_GENERIC_KEYBOARD ((USAGE) 0x06)
#define HID_USAGE_GENERIC_KEYPAD ((USAGE) 0x07)
#define HID_USAGE_GENERIC_SYSTEM_CTL ((USAGE) 0x80)
#define HID_USAGE_GENERIC_X ((USAGE) 0x30)
#define HID_USAGE_GENERIC_Y ((USAGE) 0x31)
#define HID_USAGE_GENERIC_Z ((USAGE) 0x32)
#define HID_USAGE_GENERIC_RX ((USAGE) 0x33)
#define HID_USAGE_GENERIC_RY ((USAGE) 0x34)
#define HID_USAGE_GENERIC_RZ ((USAGE) 0x35)
#define HID_USAGE_GENERIC_SLIDER ((USAGE) 0x36)
#define HID_USAGE_GENERIC_DIAL ((USAGE) 0x37)
#define HID_USAGE_GENERIC_WHEEL ((USAGE) 0x38)
#define HID_USAGE_GENERIC_HATSWITCH ((USAGE) 0x39)
#define HID_USAGE_GENERIC_COUNTED_BUFFER ((USAGE) 0x3A)
#define HID_USAGE_GENERIC_BYTE_COUNT ((USAGE) 0x3B)
#define HID_USAGE_GENERIC_MOTION_WAKEUP ((USAGE) 0x3C)
#define HID_USAGE_GENERIC_VX ((USAGE) 0x40)
#define HID_USAGE_GENERIC_VY ((USAGE) 0x41)
#define HID_USAGE_GENERIC_VZ ((USAGE) 0x42)
#define HID_USAGE_GENERIC_VBRX ((USAGE) 0x43)
#define HID_USAGE_GENERIC_VBRY ((USAGE) 0x44)
#define HID_USAGE_GENERIC_VBRZ ((USAGE) 0x45)
#define HID_USAGE_GENERIC_VNO ((USAGE) 0x46)
#define HID_USAGE_GENERIC_SYSCTL_POWER ((USAGE) 0x81)
#define HID_USAGE_GENERIC_SYSCTL_SLEEP ((USAGE) 0x82)
#define HID_USAGE_GENERIC_SYSCTL_WAKE ((USAGE) 0x83)
#define HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU ((USAGE) 0x84)
#define HID_USAGE_GENERIC_SYSCTL_MAIN_MENU ((USAGE) 0x85)
#define HID_USAGE_GENERIC_SYSCTL_APP_MENU ((USAGE) 0x86)
#define HID_USAGE_GENERIC_SYSCTL_HELP_MENU ((USAGE) 0x87)
#define HID_USAGE_GENERIC_SYSCTL_MENU_EXIT ((USAGE) 0x88)
#define HID_USAGE_GENERIC_SYSCTL_MENU_SELECT ((USAGE) 0x89)
#define HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT ((USAGE) 0x8A)
#define HID_USAGE_GENERIC_SYSCTL_MENU_LEFT ((USAGE) 0x8B)
#define HID_USAGE_GENERIC_SYSCTL_MENU_UP ((USAGE) 0x8C)
#define HID_USAGE_GENERIC_SYSCTL_MENU_DOWN ((USAGE) 0x8D)
//
// Usages from Simulation Controls Page (0x02)
//
#define HID_USAGE_SIMULATION_RUDDER ((USAGE) 0xBA)
#define HID_USAGE_SIMULATION_THROTTLE ((USAGE) 0xBB)
//
// Virtual Reality Controls Page (0x03)
//
//
// Sport Controls Page (0x04)
//
//
// Game Controls Page (0x05)
//
//
// Keyboard/Keypad Page (0x07)
//
// Error "keys"
#define HID_USAGE_KEYBOARD_NOEVENT ((USAGE) 0x00)
#define HID_USAGE_KEYBOARD_ROLLOVER ((USAGE) 0x01)
#define HID_USAGE_KEYBOARD_POSTFAIL ((USAGE) 0x02)
#define HID_USAGE_KEYBOARD_UNDEFINED ((USAGE) 0x03)
// Letters
#define HID_USAGE_KEYBOARD_aA ((USAGE) 0x04)
#define HID_USAGE_KEYBOARD_zZ ((USAGE) 0x1D)
// Numbers
#define HID_USAGE_KEYBOARD_ONE ((USAGE) 0x1E)
#define HID_USAGE_KEYBOARD_ZERO ((USAGE) 0x27)
// Modifier Keys
#define HID_USAGE_KEYBOARD_LCTRL ((USAGE) 0xE0)
#define HID_USAGE_KEYBOARD_LSHFT ((USAGE) 0xE1)
#define HID_USAGE_KEYBOARD_LALT ((USAGE) 0xE2)
#define HID_USAGE_KEYBOARD_LGUI ((USAGE) 0xE3)
#define HID_USAGE_KEYBOARD_RCTRL ((USAGE) 0xE4)
#define HID_USAGE_KEYBOARD_RSHFT ((USAGE) 0xE5)
#define HID_USAGE_KEYBOARD_RALT ((USAGE) 0xE6)
#define HID_USAGE_KEYBOARD_RGUI ((USAGE) 0xE7)
#define HID_USAGE_KEYBOARD_SCROLL_LOCK ((USAGE) 0x47)
#define HID_USAGE_KEYBOARD_NUM_LOCK ((USAGE) 0x53)
#define HID_USAGE_KEYBOARD_CAPS_LOCK ((USAGE) 0x39)
// Funtion keys
#define HID_USAGE_KEYBOARD_F1 ((USAGE) 0x3A)
#define HID_USAGE_KEYBOARD_F12 ((USAGE) 0x45)
#define HID_USAGE_KEYBOARD_RETURN ((USAGE) 0x28)
#define HID_USAGE_KEYBOARD_ESCAPE ((USAGE) 0x29)
#define HID_USAGE_KEYBOARD_DELETE ((USAGE) 0x2A)
#define HID_USAGE_KEYBOARD_PRINT_SCREEN ((USAGE) 0x46)
// and hundreds more...
//
// LED Page (0x08)
//
#define HID_USAGE_LED_NUM_LOCK ((USAGE) 0x01)
#define HID_USAGE_LED_CAPS_LOCK ((USAGE) 0x02)
#define HID_USAGE_LED_SCROLL_LOCK ((USAGE) 0x03)
#define HID_USAGE_LED_COMPOSE ((USAGE) 0x04)
#define HID_USAGE_LED_KANA ((USAGE) 0x05)
#define HID_USAGE_LED_POWER ((USAGE) 0x06)
#define HID_USAGE_LED_SHIFT ((USAGE) 0x07)
#define HID_USAGE_LED_DO_NOT_DISTURB ((USAGE) 0x08)
#define HID_USAGE_LED_MUTE ((USAGE) 0x09)
#define HID_USAGE_LED_TONE_ENABLE ((USAGE) 0x0A)
#define HID_USAGE_LED_HIGH_CUT_FILTER ((USAGE) 0x0B)
#define HID_USAGE_LED_LOW_CUT_FILTER ((USAGE) 0x0C)
#define HID_USAGE_LED_EQUALIZER_ENABLE ((USAGE) 0x0D)
#define HID_USAGE_LED_SOUND_FIELD_ON ((USAGE) 0x0E)
#define HID_USAGE_LED_SURROUND_FIELD_ON ((USAGE) 0x0F)
#define HID_USAGE_LED_REPEAT ((USAGE) 0x10)
#define HID_USAGE_LED_STEREO ((USAGE) 0x11)
#define HID_USAGE_LED_SAMPLING_RATE_DETECT ((USAGE) 0x12)
#define HID_USAGE_LED_SPINNING ((USAGE) 0x13)
#define HID_USAGE_LED_CAV ((USAGE) 0x14)
#define HID_USAGE_LED_CLV ((USAGE) 0x15)
#define HID_USAGE_LED_RECORDING_FORMAT_DET ((USAGE) 0x16)
#define HID_USAGE_LED_OFF_HOOK ((USAGE) 0x17)
#define HID_USAGE_LED_RING ((USAGE) 0x18)
#define HID_USAGE_LED_MESSAGE_WAITING ((USAGE) 0x19)
#define HID_USAGE_LED_DATA_MODE ((USAGE) 0x1A)
#define HID_USAGE_LED_BATTERY_OPERATION ((USAGE) 0x1B)
#define HID_USAGE_LED_BATTERY_OK ((USAGE) 0x1C)
#define HID_USAGE_LED_BATTERY_LOW ((USAGE) 0x1D)
#define HID_USAGE_LED_SPEAKER ((USAGE) 0x1E)
#define HID_USAGE_LED_HEAD_SET ((USAGE) 0x1F)
#define HID_USAGE_LED_HOLD ((USAGE) 0x20)
#define HID_USAGE_LED_MICROPHONE ((USAGE) 0x21)
#define HID_USAGE_LED_COVERAGE ((USAGE) 0x22)
#define HID_USAGE_LED_NIGHT_MODE ((USAGE) 0x23)
#define HID_USAGE_LED_SEND_CALLS ((USAGE) 0x24)
#define HID_USAGE_LED_CALL_PICKUP ((USAGE) 0x25)
#define HID_USAGE_LED_CONFERENCE ((USAGE) 0x26)
#define HID_USAGE_LED_STAND_BY ((USAGE) 0x27)
#define HID_USAGE_LED_CAMERA_ON ((USAGE) 0x28)
#define HID_USAGE_LED_CAMERA_OFF ((USAGE) 0x29)
#define HID_USAGE_LED_ON_LINE ((USAGE) 0x2A)
#define HID_USAGE_LED_OFF_LINE ((USAGE) 0x2B)
#define HID_USAGE_LED_BUSY ((USAGE) 0x2C)
#define HID_USAGE_LED_READY ((USAGE) 0x2D)
#define HID_USAGE_LED_PAPER_OUT ((USAGE) 0x2E)
#define HID_USAGE_LED_PAPER_JAM ((USAGE) 0x2F)
#define HID_USAGE_LED_REMOTE ((USAGE) 0x30)
#define HID_USAGE_LED_FORWARD ((USAGE) 0x31)
#define HID_USAGE_LED_REVERSE ((USAGE) 0x32)
#define HID_USAGE_LED_STOP ((USAGE) 0x33)
#define HID_USAGE_LED_REWIND ((USAGE) 0x34)
#define HID_USAGE_LED_FAST_FORWARD ((USAGE) 0x35)
#define HID_USAGE_LED_PLAY ((USAGE) 0x36)
#define HID_USAGE_LED_PAUSE ((USAGE) 0x37)
#define HID_USAGE_LED_RECORD ((USAGE) 0x38)
#define HID_USAGE_LED_ERROR ((USAGE) 0x39)
#define HID_USAGE_LED_SELECTED_INDICATOR ((USAGE) 0x3A)
#define HID_USAGE_LED_IN_USE_INDICATOR ((USAGE) 0x3B)
#define HID_USAGE_LED_MULTI_MODE_INDICATOR ((USAGE) 0x3C)
#define HID_USAGE_LED_INDICATOR_ON ((USAGE) 0x3D)
#define HID_USAGE_LED_INDICATOR_FLASH ((USAGE) 0x3E)
#define HID_USAGE_LED_INDICATOR_SLOW_BLINK ((USAGE) 0x3F)
#define HID_USAGE_LED_INDICATOR_FAST_BLINK ((USAGE) 0x40)
#define HID_USAGE_LED_INDICATOR_OFF ((USAGE) 0x41)
#define HID_USAGE_LED_FLASH_ON_TIME ((USAGE) 0x42)
#define HID_USAGE_LED_SLOW_BLINK_ON_TIME ((USAGE) 0x43)
#define HID_USAGE_LED_SLOW_BLINK_OFF_TIME ((USAGE) 0x44)
#define HID_USAGE_LED_FAST_BLINK_ON_TIME ((USAGE) 0x45)
#define HID_USAGE_LED_FAST_BLINK_OFF_TIME ((USAGE) 0x46)
#define HID_USAGE_LED_INDICATOR_COLOR ((USAGE) 0x47)
#define HID_USAGE_LED_RED ((USAGE) 0x48)
#define HID_USAGE_LED_GREEN ((USAGE) 0x49)
#define HID_USAGE_LED_AMBER ((USAGE) 0x4A)
#define HID_USAGE_LED_GENERIC_INDICATOR ((USAGE) 0x3B)
//
// Button Page (0x09)
//
// There is no need to label these usages.
//
//
// Ordinal Page (0x0A)
//
// There is no need to label these usages.
//
//
// Telephony Device Page (0x0B)
//
#define HID_USAGE_TELEPHONY_PHONE ((USAGE) 0x01)
#define HID_USAGE_TELEPHONY_ANSWERING_MACHINE ((USAGE) 0x02)
#define HID_USAGE_TELEPHONY_MESSAGE_CONTROLS ((USAGE) 0x03)
#define HID_USAGE_TELEPHONY_HANDSET ((USAGE) 0x04)
#define HID_USAGE_TELEPHONY_HEADSET ((USAGE) 0x05)
#define HID_USAGE_TELEPHONY_KEYPAD ((USAGE) 0x06)
#define HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON ((USAGE) 0x07)
//
// and others...
//
#define HID_USAGE_CONSUMERCTRL ((USAGE)0x01)
#define HID_USAGE_DIGITIZER_PEN ((USAGE)0x02)
#define HID_USAGE_DIGITIZER_IN_RANGE ((USAGE)0x32)
#define HID_USAGE_DIGITIZER_TIP_SWITCH ((USAGE)0x42)
#define HID_USAGE_DIGITIZER_BARREL_SWITCH ((USAGE)0x44)
#endif

Binary file not shown.

View File

@@ -1,140 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Balance Board expansion device.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#ifdef WIN32
#include <Winsock2.h>
#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);
}

View File

@@ -1,53 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
* $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

View File

@@ -1,190 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Classic controller expansion device.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#ifdef WIN32
#include <Winsock2.h>
#endif
#include "definitions.h"
#include "wiiuse_internal.h"
#include "dynamics.h"
#include "events.h"
#include "classic.h"
static void classic_ctrl_pressed_buttons(struct classic_ctrl_t* cc, short now);
/**
* @brief Handle the handshake data from the classic controller.
*
* @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 classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len) {
int i;
int offset = 0;
cc->btns = 0;
cc->btns_held = 0;
cc->btns_released = 0;
cc->r_shoulder = 0;
cc->l_shoulder = 0;
/* decrypt data */
for (i = 0; i < len; ++i)
data[i] = (data[i] ^ 0x17) + 0x17;
if (data[offset] == 0xFF) {
/*
* Sometimes the data returned here is not correct.
* This might happen because the wiimote is lagging
* behind our initialization sequence.
* To fix this just request the handshake again.
*
* Other times it's just the first 16 bytes are 0xFF,
* but since the next 16 bytes are the same, just use
* those.
*/
if (data[offset + 16] == 0xFF) {
/* get the calibration data */
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
WIIUSE_DEBUG("Classic controller handshake appears invalid, trying again.");
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
return 0;
} else
offset += 16;
}
/* joystick stuff */
cc->ljs.max.x = data[0 + offset] / 4;
cc->ljs.min.x = data[1 + offset] / 4;
cc->ljs.center.x = data[2 + offset] / 4;
cc->ljs.max.y = data[3 + offset] / 4;
cc->ljs.min.y = data[4 + offset] / 4;
cc->ljs.center.y = data[5 + offset] / 4;
cc->rjs.max.x = data[6 + offset] / 8;
cc->rjs.min.x = data[7 + offset] / 8;
cc->rjs.center.x = data[8 + offset] / 8;
cc->rjs.max.y = data[9 + offset] / 8;
cc->rjs.min.y = data[10 + offset] / 8;
cc->rjs.center.y = data[11 + offset] / 8;
/* handshake done */
wm->exp.type = EXP_CLASSIC;
#ifdef WIN32
wm->timeout = WIIMOTE_DEFAULT_TIMEOUT;
#endif
return 1;
}
/**
* @brief The classic controller disconnected.
*
* @param cc A pointer to a classic_ctrl_t structure.
*/
void classic_ctrl_disconnected(struct classic_ctrl_t* cc) {
memset(cc, 0, sizeof(struct classic_ctrl_t));
}
/**
* @brief Handle classic controller event.
*
* @param cc A pointer to a classic_ctrl_t structure.
* @param msg The message specified in the event packet.
*/
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg) {
int i, lx, ly, rx, ry;
byte l, r;
/* decrypt data */
for (i = 0; i < 6; ++i)
msg[i] = (msg[i] ^ 0x17) + 0x17;
classic_ctrl_pressed_buttons(cc, BIG_ENDIAN_SHORT(*(short*)(msg + 4)));
/* left/right buttons */
l = (((msg[2] & 0x60) >> 2) | ((msg[3] & 0xE0) >> 5));
r = (msg[3] & 0x1F);
/*
* TODO - LR range hardcoded from 0x00 to 0x1F.
* This is probably in the calibration somewhere.
*/
cc->r_shoulder = ((float)r / 0x1F);
cc->l_shoulder = ((float)l / 0x1F);
/* calculate joystick orientation */
lx = (msg[0] & 0x3F);
ly = (msg[1] & 0x3F);
rx = ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7);
ry = (msg[2] & 0x1F);
calc_joystick_state(&cc->ljs, lx, ly);
calc_joystick_state(&cc->rjs, rx, ry);
}
/**
* @brief Find what buttons are pressed.
*
* @param cc A pointer to a classic_ctrl_t structure.
* @param msg The message byte specified in the event packet.
*/
static void classic_ctrl_pressed_buttons(struct classic_ctrl_t* cc, short now) {
/* message is inverted (0 is active, 1 is inactive) */
now = ~now & CLASSIC_CTRL_BUTTON_ALL;
/* pressed now & were pressed, then held */
cc->btns_held = (now & cc->btns);
/* were pressed or were held & not pressed now, then released */
cc->btns_released = ((cc->btns | cc->btns_held) & ~now);
/* buttons pressed now */
cc->btns = now;
}

View File

@@ -1,53 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Classic controller expansion device.
*/
#ifndef CLASSIC_H_INCLUDED
#define CLASSIC_H_INCLUDED
#include "wiiuse_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len);
void classic_ctrl_disconnected(struct classic_ctrl_t* cc);
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg);
#ifdef __cplusplus
}
#endif
#endif // CLASSIC_H_INCLUDED

View File

@@ -1,78 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief General definitions.
*/
#ifndef DEFINITIONS_H_INCLUDED
#define DEFINITIONS_H_INCLUDED
/* this is wiiuse - used to distinguish from third party programs using wiiuse.h */
#include "os.h"
#define WIIMOTE_PI 3.14159265f
/* Error output macros */
#define WIIUSE_ERROR(fmt, ...) //fprintf(stderr, "[ERROR] " fmt "\n", ##__VA_ARGS__)
/* Warning output macros */
#define WIIUSE_WARNING(fmt, ...) //fprintf(stderr, "[WARNING] " fmt "\n", ##__VA_ARGS__)
/* Information output macros */
#define WIIUSE_INFO(fmt, ...) //fprintf(stderr, "[INFO] " fmt "\n", ##__VA_ARGS__)
#ifdef WITH_WIIUSE_DEBUG
#ifdef WIN32
#define WIIUSE_DEBUG(fmt, ...) do { \
char* file = __FILE__; \
int i = strlen(file) - 1; \
for (; i && (file[i] != '\\'); --i); \
fprintf(stdout, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \
fflush(stdout); \
} while (0)
#else
#define WIIUSE_DEBUG(fmt, ...) fprintf(stderr, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__)
#endif
#else
#define WIIUSE_DEBUG(fmt, ...)
#endif
/* Convert between radians and degrees */
#define RAD_TO_DEGREE(r) ((r * 180.0f) / WIIMOTE_PI)
#define DEGREE_TO_RAD(d) (d * (WIIMOTE_PI / 180.0f))
/* Convert to big endian */
#define BIG_ENDIAN_LONG(i) (htonl(i))
#define BIG_ENDIAN_SHORT(i) (htons(i))
#define absf(x) ((x >= 0) ? (x) : (x * -1.0f))
#define diff_f(x, y) ((x >= y) ? (absf(x - y)) : (absf(y - x)))
#endif // DEFINITIONS_H_INCLUDED

View File

@@ -1,228 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Handles the dynamics of the wiimote.
*
* The file includes functions that handle the dynamics
* of the wiimote. Such dynamics include orientation and
* motion sensing.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#ifdef WIN32
#include <float.h>
#endif
#include "definitions.h"
#include "wiiuse_internal.h"
#include "ir.h"
#include "dynamics.h"
/**
* @brief Calculate the roll, pitch, yaw.
*
* @param ac An accelerometer (accel_t) structure.
* @param accel [in] Pointer to a vec3b_t structure that holds the raw acceleration data.
* @param orient [out] Pointer to a orient_t structure that will hold the orientation data.
* @param rorient [out] Pointer to a orient_t structure that will hold the non-smoothed orientation data.
* @param smooth If smoothing should be performed on the angles calculated. 1 to enable, 0 to disable.
*
* Given the raw acceleration data from the accelerometer struct, calculate
* the orientation of the device and set it in the \a orient parameter.
*/
void calculate_orientation(struct accel_t* ac, struct vec3b_t* accel, struct orient_t* orient, int smooth) {
float xg, yg, zg;
float x, y, z;
/*
* roll - use atan(z / x) [ ranges from -180 to 180 ]
* pitch - use atan(z / y) [ ranges from -180 to 180 ]
* yaw - impossible to tell without IR
*/
/* yaw - set to 0, IR will take care of it if it's enabled */
orient->yaw = 0.0f;
/* find out how much it has to move to be 1g */
xg = (float)ac->cal_g.x;
yg = (float)ac->cal_g.y;
zg = (float)ac->cal_g.z;
/* find out how much it actually moved and normalize to +/- 1g */
x = ((float)accel->x - (float)ac->cal_zero.x) / xg;
y = ((float)accel->y - (float)ac->cal_zero.y) / yg;
z = ((float)accel->z - (float)ac->cal_zero.z) / zg;
/* make sure x,y,z are between -1 and 1 for the tan functions */
if (x < -1.0f) x = -1.0f;
else if (x > 1.0f) x = 1.0f;
if (y < -1.0f) y = -1.0f;
else if (y > 1.0f) y = 1.0f;
if (z < -1.0f) z = -1.0f;
else if (z > 1.0f) z = 1.0f;
/* if it is over 1g then it is probably accelerating and not reliable */
if (abs(accel->x - ac->cal_zero.x) <= ac->cal_g.x) {
/* roll */
x = RAD_TO_DEGREE(atan2f(x, z));
orient->roll = x;
orient->a_roll = x;
}
if (abs(accel->y - ac->cal_zero.y) <= ac->cal_g.y) {
/* pitch */
y = RAD_TO_DEGREE(atan2f(y, z));
orient->pitch = y;
orient->a_pitch = y;
}
/* smooth the angles if enabled */
if (smooth) {
apply_smoothing(ac, orient, SMOOTH_ROLL);
apply_smoothing(ac, orient, SMOOTH_PITCH);
}
}
/**
* @brief Calculate the gravity forces on each axis.
*
* @param ac An accelerometer (accel_t) structure.
* @param accel [in] Pointer to a vec3b_t structure that holds the raw acceleration data.
* @param gforce [out] Pointer to a gforce_t structure that will hold the gravity force data.
*/
void calculate_gforce(struct accel_t* ac, struct vec3b_t* accel, struct gforce_t* gforce) {
float xg, yg, zg;
/* find out how much it has to move to be 1g */
xg = (float)ac->cal_g.x;
yg = (float)ac->cal_g.y;
zg = (float)ac->cal_g.z;
/* find out how much it actually moved and normalize to +/- 1g */
gforce->x = ((float)accel->x - (float)ac->cal_zero.x) / xg;
gforce->y = ((float)accel->y - (float)ac->cal_zero.y) / yg;
gforce->z = ((float)accel->z - (float)ac->cal_zero.z) / zg;
}
/**
* @brief Calculate the angle and magnitude of a joystick.
*
* @param js [out] Pointer to a joystick_t structure.
* @param x The raw x-axis value.
* @param y The raw y-axis value.
*/
void calc_joystick_state(struct joystick_t* js, float x, float y) {
float rx, ry, ang;
/*
* Since the joystick center may not be exactly:
* (min + max) / 2
* Then the range from the min to the center and the center to the max
* may be different.
* Because of this, depending on if the current x or y value is greater
* or less than the assoicated axis center value, it needs to be interpolated
* between the center and the minimum or maxmimum rather than between
* the minimum and maximum.
*
* So we have something like this:
* (x min) [-1] ---------*------ [0] (x center) [0] -------- [1] (x max)
* Where the * is the current x value.
* The range is therefore -1 to 1, 0 being the exact center rather than
* the middle of min and max.
*/
if (x == js->center.x)
rx = 0;
else if (x >= js->center.x)
rx = ((float)(x - js->center.x) / (float)(js->max.x - js->center.x));
else
rx = ((float)(x - js->min.x) / (float)(js->center.x - js->min.x)) - 1.0f;
if (y == js->center.y)
ry = 0;
else if (y >= js->center.y)
ry = ((float)(y - js->center.y) / (float)(js->max.y - js->center.y));
else
ry = ((float)(y - js->min.y) / (float)(js->center.y - js->min.y)) - 1.0f;
/* calculate the joystick angle and magnitude */
ang = RAD_TO_DEGREE(atanf(ry / rx));
ang -= 90.0f;
if (rx < 0.0f)
ang -= 180.0f;
js->ang = absf(ang);
js->mag = (float) sqrt((rx * rx) + (ry * ry));
}
void apply_smoothing(struct accel_t* ac, struct orient_t* orient, int type) {
switch (type) {
case SMOOTH_ROLL:
{
/* it's possible last iteration was nan or inf, so set it to 0 if that happened */
if (isnan(ac->st_roll) || isinf(ac->st_roll))
ac->st_roll = 0.0f;
/*
* If the sign changes (which will happen if going from -180 to 180)
* or from (-1 to 1) then don't smooth, just use the new angle.
*/
if (((ac->st_roll < 0) && (orient->roll > 0)) || ((ac->st_roll > 0) && (orient->roll < 0))) {
ac->st_roll = orient->roll;
} else {
orient->roll = ac->st_roll + (ac->st_alpha * (orient->a_roll - ac->st_roll));
ac->st_roll = orient->roll;
}
return;
}
case SMOOTH_PITCH:
{
if (isnan(ac->st_pitch) || isinf(ac->st_pitch))
ac->st_pitch = 0.0f;
if (((ac->st_pitch < 0) && (orient->pitch > 0)) || ((ac->st_pitch > 0) && (orient->pitch < 0))) {
ac->st_pitch = orient->pitch;
} else {
orient->pitch = ac->st_pitch + (ac->st_alpha * (orient->a_pitch - ac->st_pitch));
ac->st_pitch = orient->pitch;
}
return;
}
}
}

View File

@@ -1,56 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Handles the dynamics of the wiimote.
*
* The file includes functions that handle the dynamics
* of the wiimote. Such dynamics include orientation and
* motion sensing.
*/
#ifndef DYNAMICS_H_INCLUDED
#define DYNAMICS_H_INCLUDED
#include "wiiuse_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
void calculate_orientation(struct accel_t* ac, struct vec3b_t* accel, struct orient_t* orient, int smooth);
void calculate_gforce(struct accel_t* ac, struct vec3b_t* accel, struct gforce_t* gforce);
void calc_joystick_state(struct joystick_t* js, float x, float y);
void apply_smoothing(struct accel_t* ac, struct orient_t* orient, int type);
#ifdef __cplusplus
}
#endif
#endif // DYNAMICS_H_INCLUDED

View File

@@ -1,907 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Handles wiimote events.
*
* The file includes functions that handle the events
* that are sent from the wiimote to us.
*/
#include <stdio.h>
#ifndef WIN32
#include <sys/time.h>
#include <unistd.h>
#include <errno.h>
#else
#include <winsock2.h>
#endif
#include <sys/types.h>
#include <stdlib.h>
#include <math.h>
#include "definitions.h"
#include "io.h"
#include "wiiuse_internal.h"
#include "dynamics.h"
#include "ir.h"
#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);
static void clear_dirty_reads(struct wiimote_t* wm);
static void propagate_event(struct wiimote_t* wm, byte event, byte* msg);
static void event_data_read(struct wiimote_t* wm, byte* msg);
static void event_status(struct wiimote_t* wm, byte* msg);
static void handle_expansion(struct wiimote_t* wm, byte* msg);
static void save_state(struct wiimote_t* wm);
static int state_changed(struct wiimote_t* wm);
/**
* @brief Poll the wiimotes for any events.
*
* @param wm An array of pointers to wiimote_t structures.
* @param wiimotes The number of wiimote_t structures in the \a wm array.
*
* @return Returns number of wiimotes that an event has occured on.
*
* It is necessary to poll the wiimote devices for events
* that occur. If an event occurs on a particular wiimote,
* the event variable will be set.
*/
int wiiuse_poll(struct wiimote_t** wm, int wiimotes) {
int evnt = 0;
#ifndef WIN32
/*
* *nix
*/
struct timeval tv;
fd_set fds;
int r;
int i;
int highest_fd = -1;
if (!wm) return 0;
/* block select() for 1/2000th of a second */
tv.tv_sec = 0;
tv.tv_usec = 500;
FD_ZERO(&fds);
for (i = 0; i < wiimotes; ++i) {
/* only poll it if it is connected */
if (WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_CONNECTED)) {
FD_SET(wm[i]->in_sock, &fds);
/* find the highest fd of the connected wiimotes */
if (wm[i]->in_sock > highest_fd)
highest_fd = wm[i]->in_sock;
}
wm[i]->event = WIIUSE_NONE;
}
if (highest_fd == -1)
/* nothing to poll */
return 0;
if (select(highest_fd + 1, &fds, NULL, NULL, &tv) == -1) {
WIIUSE_ERROR("Unable to select() the wiimote interrupt socket(s).");
perror("Error Details");
return 0;
}
/* check each socket for an event */
for (i = 0; i < wiimotes; ++i) {
/* if this wiimote is not connected, skip it */
if (!WIIMOTE_IS_CONNECTED(wm[i]))
continue;
if (FD_ISSET(wm[i]->in_sock, &fds)) {
/* clear out the event buffer */
memset(wm[i]->event_buf, 0, sizeof(wm[i]->event_buf));
/* clear out any old read requests */
clear_dirty_reads(wm[i]);
/* read the pending message into the buffer */
r = read(wm[i]->in_sock, wm[i]->event_buf, sizeof(wm[i]->event_buf));
if (r == -1) {
/* error reading data */
WIIUSE_ERROR("Receiving wiimote data (id %i).", wm[i]->unid);
perror("Error Details");
if (errno == ENOTCONN) {
/* this can happen if the bluetooth dongle is disconnected */
WIIUSE_ERROR("Bluetooth appears to be disconnected. Wiimote unid %i will be disconnected.", wm[i]->unid);
wiiuse_disconnect(wm[i]);
wm[i]->event = WIIUSE_UNEXPECTED_DISCONNECT;
}
continue;
}
if (!r) {
/* remote disconnect */
wiiuse_disconnected(wm[i]);
evnt = 1;
continue;
}
/* propagate the event */
propagate_event(wm[i], wm[i]->event_buf[1], wm[i]->event_buf+2);
evnt += (wm[i]->event != WIIUSE_NONE);
} else {
idle_cycle(wm[i]);
}
}
#else
/*
* Windows
*/
int i;
if (!wm) return 0;
for (i = 0; i < wiimotes; ++i) {
wm[i]->event = WIIUSE_NONE;
if (wiiuse_io_read(wm[i])) {
/* propagate the event */
propagate_event(wm[i], wm[i]->event_buf[0], wm[i]->event_buf+1);
evnt += (wm[i]->event != WIIUSE_NONE);
/* clear out the event buffer */
memset(wm[i]->event_buf, 0, sizeof(wm[i]->event_buf));
} else {
idle_cycle(wm[i]);
}
}
#endif
return evnt;
}
/**
* @brief Called on a cycle where no significant change occurs.
*
* @param wm Pointer to a wiimote_t structure.
*/
static void idle_cycle(struct wiimote_t* wm) {
/*
* Smooth the angles.
*
* This is done to make sure that on every cycle the orientation
* angles are smoothed. Normally when an event occurs the angles
* are updated and smoothed, but if no packet comes in then the
* angles remain the same. This means the angle wiiuse reports
* is still an old value. Smoothing needs to be applied in this
* case in order for the angle it reports to converge to the true
* angle of the device.
*/
if (WIIUSE_USING_ACC(wm) && WIIMOTE_IS_FLAG_SET(wm, WIIUSE_SMOOTHING)) {
apply_smoothing(&wm->accel_calib, &wm->orient, SMOOTH_ROLL);
apply_smoothing(&wm->accel_calib, &wm->orient, SMOOTH_PITCH);
}
/* clear out any old read requests */
clear_dirty_reads(wm);
}
/**
* @brief Clear out all old 'dirty' read requests.
*
* @param wm Pointer to a wiimote_t structure.
*/
static void clear_dirty_reads(struct wiimote_t* wm) {
struct read_req_t* req = wm->read_req;
while (req && req->dirty) {
WIIUSE_DEBUG("Cleared old read request for address: %x", req->addr);
wm->read_req = req->next;
free(req);
req = wm->read_req;
}
}
/**
* @brief Analyze the event that occured on a wiimote.
*
* @param wm An array of pointers to wiimote_t structures.
* @param event The event that occured.
* @param msg The message specified in the event packet.
*
* Pass the event to the registered event callback.
*/
static void propagate_event(struct wiimote_t* wm, byte event, byte* msg) {
save_state(wm);
switch (event) {
case WM_RPT_BTN:
{
/* button */
wiiuse_pressed_buttons(wm, msg);
break;
}
case WM_RPT_BTN_ACC:
{
/* button - motion */
wiiuse_pressed_buttons(wm, msg);
wm->accel.x = msg[2];
wm->accel.y = msg[3];
wm->accel.z = msg[4];
/* calculate the remote orientation */
calculate_orientation(&wm->accel_calib, &wm->accel, &wm->orient, WIIMOTE_IS_FLAG_SET(wm, WIIUSE_SMOOTHING));
/* calculate the gforces on each axis */
calculate_gforce(&wm->accel_calib, &wm->accel, &wm->gforce);
break;
}
case WM_RPT_READ:
{
/* data read */
event_data_read(wm, msg);
/* yeah buttons may be pressed, but this wasn't an "event" */
return;
}
case WM_RPT_CTRL_STATUS:
{
/* controller status */
event_status(wm, msg);
/* don't execute the event callback */
return;
}
case WM_RPT_BTN_EXP:
{
/* button - expansion */
wiiuse_pressed_buttons(wm, msg);
handle_expansion(wm, msg+2);
break;
}
case WM_RPT_BTN_ACC_EXP:
{
/* button - motion - expansion */
wiiuse_pressed_buttons(wm, msg);
wm->accel.x = msg[2];
wm->accel.y = msg[3];
wm->accel.z = msg[4];
calculate_orientation(&wm->accel_calib, &wm->accel, &wm->orient, WIIMOTE_IS_FLAG_SET(wm, WIIUSE_SMOOTHING));
calculate_gforce(&wm->accel_calib, &wm->accel, &wm->gforce);
handle_expansion(wm, msg+5);
break;
}
case WM_RPT_BTN_ACC_IR:
{
/* button - motion - ir */
wiiuse_pressed_buttons(wm, msg);
wm->accel.x = msg[2];
wm->accel.y = msg[3];
wm->accel.z = msg[4];
calculate_orientation(&wm->accel_calib, &wm->accel, &wm->orient, WIIMOTE_IS_FLAG_SET(wm, WIIUSE_SMOOTHING));
calculate_gforce(&wm->accel_calib, &wm->accel, &wm->gforce);
/* ir */
calculate_extended_ir(wm, msg+5);
break;
}
case WM_RPT_BTN_IR_EXP:
{
/* button - ir - expansion */
wiiuse_pressed_buttons(wm, msg);
handle_expansion(wm, msg+12);
/* ir */
calculate_basic_ir(wm, msg+2);
break;
}
case WM_RPT_BTN_ACC_IR_EXP:
{
/* button - motion - ir - expansion */
wiiuse_pressed_buttons(wm, msg);
wm->accel.x = msg[2];
wm->accel.y = msg[3];
wm->accel.z = msg[4];
calculate_orientation(&wm->accel_calib, &wm->accel, &wm->orient, WIIMOTE_IS_FLAG_SET(wm, WIIUSE_SMOOTHING));
calculate_gforce(&wm->accel_calib, &wm->accel, &wm->gforce);
handle_expansion(wm, msg+15);
/* ir */
calculate_basic_ir(wm, msg+5);
break;
}
case WM_RPT_WRITE:
{
/* write feedback - safe to skip */
break;
}
default:
{
WIIUSE_WARNING("Unknown event, can not handle it [Code 0x%x].", event);
return;
}
}
/* was there an event? */
if (state_changed(wm))
wm->event = WIIUSE_EVENT;
}
/**
* @brief Find what buttons are pressed.
*
* @param wm Pointer to a wiimote_t structure.
* @param msg The message specified in the event packet.
*/
void wiiuse_pressed_buttons(struct wiimote_t* wm, byte* msg) {
short now;
/* convert to big endian */
now = BIG_ENDIAN_SHORT(*(short*)msg) & WIIMOTE_BUTTON_ALL;
/* pressed now & were pressed, then held */
wm->btns_held = (now & wm->btns);
/* were pressed or were held & not pressed now, then released */
wm->btns_released = ((wm->btns | wm->btns_held) & ~now);
/* buttons pressed now */
wm->btns = now;
}
/**
* @brief Received a data packet from a read request.
*
* @param wm Pointer to a wiimote_t structure.
* @param msg The message specified in the event packet.
*
* Data from the wiimote comes in packets. If the requested
* data segment size is bigger than one packet can hold then
* several packets will be received. These packets are first
* reassembled into one, then the registered callback function
* that handles data reads is invoked.
*/
static void event_data_read(struct wiimote_t* wm, byte* msg) {
/* we must always assume the packet received is from the most recent request */
byte err;
byte len;
unsigned short offset;
struct read_req_t* req = wm->read_req;
wiiuse_pressed_buttons(wm, msg);
/* find the next non-dirty request */
while (req && req->dirty)
req = req->next;
/* if we don't have a request out then we didn't ask for this packet */
if (!req) {
WIIUSE_WARNING("Received data packet when no request was made.");
return;
}
err = msg[2] & 0x0F;
if (err == 0x08)
WIIUSE_WARNING("Unable to read data - address does not exist.");
else if (err == 0x07)
WIIUSE_WARNING("Unable to read data - address is for write-only registers.");
else if (err)
WIIUSE_WARNING("Unable to read data - unknown error code %x.", err);
if (err) {
/* this request errored out, so skip it and go to the next one */
/* delete this request */
wm->read_req = req->next;
free(req);
/* if another request exists send it to the wiimote */
if (wm->read_req)
wiiuse_send_next_pending_read_request(wm);
return;
}
len = ((msg[2] & 0xF0) >> 4) + 1;
offset = BIG_ENDIAN_SHORT(*(unsigned short*)(msg + 3));
req->addr = (req->addr & 0xFFFF);
req->wait -= len;
if (req->wait >= req->size)
/* this should never happen */
req->wait = 0;
WIIUSE_DEBUG("Received read packet:");
WIIUSE_DEBUG(" Packet read offset: %i bytes", offset);
WIIUSE_DEBUG(" Request read offset: %i bytes", req->addr);
WIIUSE_DEBUG(" Read offset into buf: %i bytes", offset - req->addr);
WIIUSE_DEBUG(" Read data size: %i bytes", len);
WIIUSE_DEBUG(" Still need: %i bytes", req->wait);
/* reconstruct this part of the data */
memcpy((req->buf + offset - req->addr), (msg + 5), len);
#ifdef WITH_WIIUSE_DEBUG
{
int i = 0;
fprintf(stderr, "[DEBUG] Read: ");
for (; i < req->size - req->wait; ++i)
fprintf(stderr, "%x ", req->buf[i]);
fprintf(stderr, "\n");
fflush(stderr);
}
#endif
/* if all data has been received, execute the read event callback or generate event */
if (!req->wait) {
if (req->cb) {
/* this was a callback, so invoke it now */
req->cb(wm, req->buf, req->size);
/* delete this request */
wm->read_req = req->next;
free(req);
} else {
/*
* This should generate an event.
* We need to leave the event in the array so the client
* can access it still. We'll flag is as being 'dirty'
* and give the client one cycle to use it. Next event
* we will remove it from the list.
*/
wm->event = WIIUSE_READ_DATA;
req->dirty = 1;
}
/* if another request exists send it to the wiimote */
if (wm->read_req)
wiiuse_send_next_pending_read_request(wm);
}
}
/**
* @brief Read the controller status.
*
* @param wm Pointer to a wiimote_t structure.
* @param msg The message specified in the event packet.
*
* Read the controller status and execute the registered status callback.
*/
static void event_status(struct wiimote_t* wm, byte* msg) {
int led[4] = {0};
int attachment = 0;
int ir = 0;
int exp_changed = 0;
/*
* An event occured.
* This event can be overwritten by a more specific
* event type during a handshake or expansion removal.
*/
wm->event = WIIUSE_STATUS;
wiiuse_pressed_buttons(wm, msg);
/* find what LEDs are lit */
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_1) led[0] = 1;
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_2) led[1] = 1;
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_3) led[2] = 1;
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_4) led[3] = 1;
/* is an attachment connected to the expansion port? */
if ((msg[2] & WM_CTRL_STATUS_BYTE1_ATTACHMENT) == WM_CTRL_STATUS_BYTE1_ATTACHMENT)
attachment = 1;
/* is the speaker enabled? */
if ((msg[2] & WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED) == WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED)
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_SPEAKER);
/* is IR sensing enabled? */
if ((msg[2] & WM_CTRL_STATUS_BYTE1_IR_ENABLED) == WM_CTRL_STATUS_BYTE1_IR_ENABLED)
ir = 1;
/* find the battery level and normalize between 0 and 1 */
wm->battery_level = (msg[5] / (float)WM_MAX_BATTERY_CODE);
/* expansion port */
if (attachment && !WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP)) {
/* send the initialization code for the attachment */
handshake_expansion(wm, NULL, 0);
exp_changed = 1;
} else if (!attachment && WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP)) {
/* attachment removed */
disable_expansion(wm);
exp_changed = 1;
}
#ifdef WIN32
if (!attachment) {
WIIUSE_DEBUG("Setting timeout to normal %i ms.", wm->normal_timeout);
wm->timeout = wm->normal_timeout;
}
#endif
/*
* From now on the remote will only send status packets.
* We need to send a WIIMOTE_CMD_REPORT_TYPE packet to
* reenable other incoming reports.
*/
if (exp_changed && WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
/*
* Since the expansion status changed IR needs to
* be reset for the new IR report mode.
*/
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_IR);
wiiuse_set_ir(wm, 1);
} else
wiiuse_set_report_type(wm);
}
/**
* @brief Handle data from the expansion.
*
* @param wm A pointer to a wiimote_t structure.
* @param msg The message specified in the event packet for the expansion.
*/
static void handle_expansion(struct wiimote_t* wm, byte* msg) {
switch (wm->exp.type) {
case EXP_NUNCHUK:
nunchuk_event(&wm->exp.nunchuk, msg);
break;
case EXP_CLASSIC:
classic_ctrl_event(&wm->exp.classic, msg);
break;
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;
}
}
/**
* @brief Handle the handshake data from the expansion device.
*
* @param wm A pointer to a wiimote_t structure.
* @param data The data read in from the device.
* @param len The length of the data block, in bytes.
*
* Tries to determine what kind of expansion was attached
* and invoke the correct handshake function.
*
* If the data is NULL then this function will try to start
* a handshake with the expansion.
*/
void handshake_expansion(struct wiimote_t* wm, byte* data, unsigned short len) {
int id;
if (!data) {
byte* handshake_buf;
byte buf = 0x55;
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP))
disable_expansion(wm);
/* increase the timeout until the handshake completes */
#ifdef WIN32
WIIUSE_DEBUG("Setting timeout to expansion %i ms.", wm->exp_timeout);
wm->timeout = wm->exp_timeout;
#endif
wiiuse_write_data(wm, WM_EXP_MEM_ENABLE1, &buf, 1);
buf = 0x00;
wiiuse_write_data(wm, WM_EXP_MEM_ENABLE2, &buf, 1);
/* get the calibration data */
handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
/* tell the wiimote to send expansion data */
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_EXP);
return;
}
id = BIG_ENDIAN_LONG(*(int*)(data + 220));
/* call the corresponding handshake function for this expansion */
switch (id) {
case EXP_ID_CODE_NUNCHUK:
{
if (nunchuk_handshake(wm, &wm->exp.nunchuk, data, len))
wm->event = WIIUSE_NUNCHUK_INSERTED;
break;
}
case EXP_ID_CODE_CLASSIC_CONTROLLER:
{
if (classic_ctrl_handshake(wm, &wm->exp.classic, data, len))
wm->event = WIIUSE_CLASSIC_CTRL_INSERTED;
break;
}
case EXP_ID_CODE_GUITAR:
{
if (guitar_hero_3_handshake(wm, &wm->exp.gh3, data, 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);
break;
}
}
free(data);
}
/**
* @brief Disable the expansion device if it was enabled.
*
* @param wm A pointer to a wiimote_t structure.
* @param data The data read in from the device.
* @param len The length of the data block, in bytes.
*
* If the data is NULL then this function will try to start
* a handshake with the expansion.
*/
void disable_expansion(struct wiimote_t* wm) {
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP))
return;
/* tell the assoicated module the expansion was removed */
switch (wm->exp.type) {
case EXP_NUNCHUK:
nunchuk_disconnected(&wm->exp.nunchuk);
wm->event = WIIUSE_NUNCHUK_REMOVED;
break;
case EXP_CLASSIC:
classic_ctrl_disconnected(&wm->exp.classic);
wm->event = WIIUSE_CLASSIC_CTRL_REMOVED;
break;
case EXP_GUITAR_HERO_3:
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;
}
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP);
wm->exp.type = EXP_NONE;
}
/**
* @brief Save important state data.
* @param wm A pointer to a wiimote_t structure.
*/
static void save_state(struct wiimote_t* wm) {
/* wiimote */
wm->lstate.btns = wm->btns;
wm->lstate.accel = wm->accel;
/* ir */
if (WIIUSE_USING_IR(wm)) {
wm->lstate.ir_ax = wm->ir.ax;
wm->lstate.ir_ay = wm->ir.ay;
wm->lstate.ir_distance = wm->ir.distance;
}
/* expansion */
switch (wm->exp.type) {
case EXP_NUNCHUK:
wm->lstate.exp_ljs_ang = wm->exp.nunchuk.js.ang;
wm->lstate.exp_ljs_mag = wm->exp.nunchuk.js.mag;
wm->lstate.exp_btns = wm->exp.nunchuk.btns;
wm->lstate.exp_accel = wm->exp.nunchuk.accel;
break;
case EXP_CLASSIC:
wm->lstate.exp_ljs_ang = wm->exp.classic.ljs.ang;
wm->lstate.exp_ljs_mag = wm->exp.classic.ljs.mag;
wm->lstate.exp_rjs_ang = wm->exp.classic.rjs.ang;
wm->lstate.exp_rjs_mag = wm->exp.classic.rjs.mag;
wm->lstate.exp_r_shoulder = wm->exp.classic.r_shoulder;
wm->lstate.exp_l_shoulder = wm->exp.classic.l_shoulder;
wm->lstate.exp_btns = wm->exp.classic.btns;
break;
case EXP_GUITAR_HERO_3:
wm->lstate.exp_ljs_ang = wm->exp.gh3.js.ang;
wm->lstate.exp_ljs_mag = wm->exp.gh3.js.mag;
wm->lstate.exp_r_shoulder = wm->exp.gh3.whammy_bar;
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;
}
}
/**
* @brief Determine if the current state differs significantly from the previous.
* @param wm A pointer to a wiimote_t structure.
* @return 1 if a significant change occured, 0 if not.
*/
static int state_changed(struct wiimote_t* wm) {
#define STATE_CHANGED(a, b) if (a != b) return 1
#define CROSS_THRESH(last, now, thresh) \
do { \
if (WIIMOTE_IS_FLAG_SET(wm, WIIUSE_ORIENT_THRESH)) { \
if ((diff_f(last.roll, now.roll) >= thresh) || \
(diff_f(last.pitch, now.pitch) >= thresh) || \
(diff_f(last.yaw, now.yaw) >= thresh)) \
{ \
last = now; \
return 1; \
} \
} else { \
if (last.roll != now.roll) return 1; \
if (last.pitch != now.pitch) return 1; \
if (last.yaw != now.yaw) return 1; \
} \
} while (0)
#define CROSS_THRESH_XYZ(last, now, thresh) \
do { \
if (WIIMOTE_IS_FLAG_SET(wm, WIIUSE_ORIENT_THRESH)) { \
if ((diff_f(last.x, now.x) >= thresh) || \
(diff_f(last.y, now.y) >= thresh) || \
(diff_f(last.z, now.z) >= thresh)) \
{ \
last = now; \
return 1; \
} \
} else { \
if (last.x != now.x) return 1; \
if (last.y != now.y) return 1; \
if (last.z != now.z) return 1; \
} \
} while (0)
/* ir */
if (WIIUSE_USING_IR(wm)) {
STATE_CHANGED(wm->lstate.ir_ax, wm->ir.ax);
STATE_CHANGED(wm->lstate.ir_ay, wm->ir.ay);
STATE_CHANGED(wm->lstate.ir_distance, wm->ir.distance);
}
/* accelerometer */
if (WIIUSE_USING_ACC(wm)) {
/* raw accelerometer */
CROSS_THRESH_XYZ(wm->lstate.accel, wm->accel, wm->accel_threshold);
/* orientation */
CROSS_THRESH(wm->lstate.orient, wm->orient, wm->orient_threshold);
}
/* expansion */
switch (wm->exp.type) {
case EXP_NUNCHUK:
{
STATE_CHANGED(wm->lstate.exp_ljs_ang, wm->exp.nunchuk.js.ang);
STATE_CHANGED(wm->lstate.exp_ljs_mag, wm->exp.nunchuk.js.mag);
STATE_CHANGED(wm->lstate.exp_btns, wm->exp.nunchuk.btns);
CROSS_THRESH(wm->lstate.exp_orient, wm->exp.nunchuk.orient, wm->exp.nunchuk.orient_threshold);
CROSS_THRESH_XYZ(wm->lstate.exp_accel, wm->exp.nunchuk.accel, wm->exp.nunchuk.accel_threshold);
break;
}
case EXP_CLASSIC:
{
STATE_CHANGED(wm->lstate.exp_ljs_ang, wm->exp.classic.ljs.ang);
STATE_CHANGED(wm->lstate.exp_ljs_mag, wm->exp.classic.ljs.mag);
STATE_CHANGED(wm->lstate.exp_rjs_ang, wm->exp.classic.rjs.ang);
STATE_CHANGED(wm->lstate.exp_rjs_mag, wm->exp.classic.rjs.mag);
STATE_CHANGED(wm->lstate.exp_r_shoulder, wm->exp.classic.r_shoulder);
STATE_CHANGED(wm->lstate.exp_l_shoulder, wm->exp.classic.l_shoulder);
STATE_CHANGED(wm->lstate.exp_btns, wm->exp.classic.btns);
break;
}
case EXP_GUITAR_HERO_3:
{
STATE_CHANGED(wm->lstate.exp_ljs_ang, wm->exp.gh3.js.ang);
STATE_CHANGED(wm->lstate.exp_ljs_mag, wm->exp.gh3.js.mag);
STATE_CHANGED(wm->lstate.exp_r_shoulder, wm->exp.gh3.whammy_bar);
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;
}
}
STATE_CHANGED(wm->lstate.btns, wm->btns);
return 0;
}

View File

@@ -1,54 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Handles wiimote events.
*
* The file includes functions that handle the events
* that are sent from the wiimote to us.
*/
#ifndef EVENTS_H_INCLUDED
#define EVENTS_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
void wiiuse_pressed_buttons(struct wiimote_t* wm, byte* msg);
void handshake_expansion(struct wiimote_t* wm, byte* data, unsigned short len);
void disable_expansion(struct wiimote_t* wm);
#ifdef __cplusplus
}
#endif
#endif // EVENTS_H_INCLUDED

View File

@@ -1,172 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Guitar Hero 3 expansion device.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#ifdef WIN32
#include <Winsock2.h>
#endif
#include "definitions.h"
#include "wiiuse_internal.h"
#include "dynamics.h"
#include "events.h"
#include "guitar_hero_3.h"
static void guitar_hero_3_pressed_buttons(struct guitar_hero_3_t* gh3, short now);
/**
* @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 guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, byte* data, unsigned short len) {
int i;
int offset = 0;
/*
* The good fellows that made the Guitar Hero 3 controller
* failed to factory calibrate the devices. There is no
* calibration data on the device.
*/
gh3->btns = 0;
gh3->btns_held = 0;
gh3->btns_released = 0;
gh3->whammy_bar = 0.0f;
/* decrypt data */
for (i = 0; i < len; ++i)
data[i] = (data[i] ^ 0x17) + 0x17;
if (data[offset] == 0xFF) {
/*
* Sometimes the data returned here is not correct.
* This might happen because the wiimote is lagging
* behind our initialization sequence.
* To fix this just request the handshake again.
*
* Other times it's just the first 16 bytes are 0xFF,
* but since the next 16 bytes are the same, just use
* those.
*/
if (data[offset + 16] == 0xFF) {
/* get the calibration data */
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
WIIUSE_DEBUG("Guitar Hero 3 handshake appears invalid, trying again.");
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
return 0;
} else
offset += 16;
}
/* joystick stuff */
gh3->js.max.x = GUITAR_HERO_3_JS_MAX_X;
gh3->js.min.x = GUITAR_HERO_3_JS_MIN_X;
gh3->js.center.x = GUITAR_HERO_3_JS_CENTER_X;
gh3->js.max.y = GUITAR_HERO_3_JS_MAX_Y;
gh3->js.min.y = GUITAR_HERO_3_JS_MIN_Y;
gh3->js.center.y = GUITAR_HERO_3_JS_CENTER_Y;
/* handshake done */
wm->exp.type = EXP_GUITAR_HERO_3;
#ifdef WIN32
wm->timeout = WIIMOTE_DEFAULT_TIMEOUT;
#endif
return 1;
}
/**
* @brief The guitar disconnected.
*
* @param cc A pointer to a classic_ctrl_t structure.
*/
void guitar_hero_3_disconnected(struct guitar_hero_3_t* gh3) {
memset(gh3, 0, sizeof(struct guitar_hero_3_t));
}
/**
* @brief Handle guitar event.
*
* @param cc A pointer to a classic_ctrl_t structure.
* @param msg The message specified in the event packet.
*/
void guitar_hero_3_event(struct guitar_hero_3_t* gh3, byte* msg) {
int i;
/* decrypt data */
for (i = 0; i < 6; ++i)
msg[i] = (msg[i] ^ 0x17) + 0x17;
guitar_hero_3_pressed_buttons(gh3, BIG_ENDIAN_SHORT(*(short*)(msg + 4)));
/* whammy bar */
gh3->whammy_bar = (msg[3] - GUITAR_HERO_3_WHAMMY_BAR_MIN) / (float)(GUITAR_HERO_3_WHAMMY_BAR_MAX - GUITAR_HERO_3_WHAMMY_BAR_MIN);
/* joy stick */
calc_joystick_state(&gh3->js, msg[0], msg[1]);
}
/**
* @brief Find what buttons are pressed.
*
* @param cc A pointer to a classic_ctrl_t structure.
* @param msg The message byte specified in the event packet.
*/
static void guitar_hero_3_pressed_buttons(struct guitar_hero_3_t* gh3, short now) {
/* message is inverted (0 is active, 1 is inactive) */
now = ~now & GUITAR_HERO_3_BUTTON_ALL;
/* pressed now & were pressed, then held */
gh3->btns_held = (now & gh3->btns);
/* were pressed or were held & not pressed now, then released */
gh3->btns_released = ((gh3->btns | gh3->btns_held) & ~now);
/* buttons pressed now */
gh3->btns = now;
}

View File

@@ -1,62 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Guitar Hero 3 expansion device.
*/
#ifndef GUITAR_HERO_3_H_INCLUDED
#define GUITAR_HERO_3_H_INCLUDED
#include "wiiuse_internal.h"
#define GUITAR_HERO_3_JS_MIN_X 0xC5
#define GUITAR_HERO_3_JS_MAX_X 0xFC
#define GUITAR_HERO_3_JS_CENTER_X 0xE0
#define GUITAR_HERO_3_JS_MIN_Y 0xC5
#define GUITAR_HERO_3_JS_MAX_Y 0xFA
#define GUITAR_HERO_3_JS_CENTER_Y 0xE0
#define GUITAR_HERO_3_WHAMMY_BAR_MIN 0xEF
#define GUITAR_HERO_3_WHAMMY_BAR_MAX 0xFA
#ifdef __cplusplus
extern "C" {
#endif
int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, byte* data, unsigned short len);
void guitar_hero_3_disconnected(struct guitar_hero_3_t* gh3);
void guitar_hero_3_event(struct guitar_hero_3_t* gh3, byte* msg);
#ifdef __cplusplus
}
#endif
#endif // GUITAR_HERO_3_H_INCLUDED

View File

@@ -1,119 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Handles device I/O (non-OS specific).
*/
#include <stdio.h>
#include <stdlib.h>
#include "definitions.h"
#include "wiiuse_internal.h"
#include "io.h"
/**
* @brief Get initialization data from the wiimote.
*
* @param wm Pointer to a wiimote_t structure.
* @param data unused
* @param len unused
*
* When first called for a wiimote_t structure, a request
* is sent to the wiimote for initialization information.
* This includes factory set accelerometer data.
* The handshake will be concluded when the wiimote responds
* with this data.
*/
void wiiuse_handshake(struct wiimote_t* wm, byte* data, unsigned short len) {
if (!wm) return;
switch (wm->handshake_state) {
case 0:
{
/* send request to wiimote for accelerometer calibration */
byte* buf;
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
wiiuse_set_leds(wm, WIIMOTE_LED_NONE);
buf = (byte*)malloc(sizeof(byte) * 8);
wiiuse_read_data_cb(wm, wiiuse_handshake, buf, WM_MEM_OFFSET_CALIBRATION, 7);
wm->handshake_state++;
wiiuse_set_leds(wm, WIIMOTE_LED_NONE);
break;
}
case 1:
{
struct read_req_t* req = wm->read_req;
struct accel_t* accel = &wm->accel_calib;
/* received read data */
accel->cal_zero.x = req->buf[0];
accel->cal_zero.y = req->buf[1];
accel->cal_zero.z = req->buf[2];
accel->cal_g.x = req->buf[4] - accel->cal_zero.x;
accel->cal_g.y = req->buf[5] - accel->cal_zero.y;
accel->cal_g.z = req->buf[6] - accel->cal_zero.z;
/* done with the buffer */
free(req->buf);
/* handshake is done */
WIIUSE_DEBUG("Handshake finished. Calibration: Idle: X=%x Y=%x Z=%x\t+1g: X=%x Y=%x Z=%x",
accel->cal_zero.x, accel->cal_zero.y, accel->cal_zero.z,
accel->cal_g.x, accel->cal_g.y, accel->cal_g.z);
/* request the status of the wiimote to see if there is an expansion */
wiiuse_status(wm);
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE);
wm->handshake_state++;
/* now enable IR if it was set before the handshake completed */
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
WIIUSE_DEBUG("Handshake finished, enabling IR.");
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_IR);
wiiuse_set_ir(wm, 1);
}
break;
}
default:
{
break;
}
}
}

View File

@@ -1,56 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Handles device I/O.
*/
#ifndef CONNECT_H_INCLUDED
#define CONNECT_H_INCLUDED
#ifndef WIN32
#include <bluetooth/bluetooth.h>
#endif
#include "wiiuse_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
void wiiuse_handshake(struct wiimote_t* wm, byte* data, unsigned short len);
int wiiuse_io_read(struct wiimote_t* wm);
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len);
#ifdef __cplusplus
}
#endif
#endif // CONNECT_H_INCLUDED

View File

@@ -1,270 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Handles device I/O for *nix.
*/
#ifndef WIN32
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
#include <bluetooth/l2cap.h>
#include "definitions.h"
#include "wiiuse_internal.h"
#include "io.h"
static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
/**
* @brief Find a wiimote or wiimotes.
*
* @param wm An array of wiimote_t structures.
* @param max_wiimotes The number of wiimote structures in \a wm.
* @param timeout The number of seconds before the search times out.
*
* @return The number of wiimotes found.
*
* @see wiimote_connect()
*
* This function will only look for wiimote devices. \n
* When a device is found the address in the structures will be set. \n
* You can then call wiimote_connect() to connect to the found \n
* devices.
*/
int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
int device_id;
int device_sock;
int found_devices;
int found_wiimotes;
/* reset all wiimote bluetooth device addresses */
for (found_wiimotes = 0; found_wiimotes < max_wiimotes; ++found_wiimotes)
wm[found_wiimotes]->bdaddr = *BDADDR_ANY;
found_wiimotes = 0;
/* get the id of the first bluetooth device. */
device_id = hci_get_route(NULL);
if (device_id < 0) {
perror("hci_get_route");
return 0;
}
/* create a socket to the device */
device_sock = hci_open_dev(device_id);
if (device_sock < 0) {
perror("hci_open_dev");
return 0;
}
inquiry_info scan_info_arr[128];
inquiry_info* scan_info = scan_info_arr;
memset(&scan_info_arr, 0, sizeof(scan_info_arr));
/* scan for bluetooth devices for 'timeout' seconds */
found_devices = hci_inquiry(device_id, timeout, 128, NULL, &scan_info, IREQ_CACHE_FLUSH);
if (found_devices < 0) {
perror("hci_inquiry");
return 0;
}
WIIUSE_INFO("Found %i bluetooth device(s).", found_devices);
int i = 0;
/* display discovered devices */
for (; (i < found_devices) && (found_wiimotes < max_wiimotes); ++i) {
if ((scan_info[i].dev_class[0] == WM_DEV_CLASS_0) &&
(scan_info[i].dev_class[1] == WM_DEV_CLASS_1) &&
(scan_info[i].dev_class[2] == WM_DEV_CLASS_2))
{
/* found a device */
ba2str(&scan_info[i].bdaddr, wm[found_wiimotes]->bdaddr_str);
WIIUSE_INFO("Found wiimote (%s) [id %i].", wm[found_wiimotes]->bdaddr_str, wm[found_wiimotes]->unid);
wm[found_wiimotes]->bdaddr = scan_info[i].bdaddr;
WIIMOTE_ENABLE_STATE(wm[found_wiimotes], WIIMOTE_STATE_DEV_FOUND);
++found_wiimotes;
}
}
close(device_sock);
return found_wiimotes;
}
/**
* @brief Connect to a wiimote or wiimotes once an address is known.
*
* @param wm An array of wiimote_t structures.
* @param wiimotes The number of wiimote structures in \a wm.
*
* @return The number of wiimotes that successfully connected.
*
* @see wiiuse_find()
* @see wiiuse_connect_single()
* @see wiiuse_disconnect()
*
* Connect to a number of wiimotes when the address is already set
* in the wiimote_t structures. These addresses are normally set
* by the wiiuse_find() function, but can also be set manually.
*/
int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
int connected = 0;
int i = 0;
for (; i < wiimotes; ++i) {
if (!WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_DEV_FOUND))
/* if the device address is not set, skip it */
continue;
if (wiiuse_connect_single(wm[i], NULL))
++connected;
}
return connected;
}
/**
* @brief Connect to a wiimote with a known address.
*
* @param wm Pointer to a wiimote_t structure.
* @param address The address of the device to connect to.
* If NULL, use the address in the struct set by wiiuse_find().
*
* @return 1 on success, 0 on failure
*/
static int wiiuse_connect_single(struct wiimote_t* wm, char* address) {
struct sockaddr_l2 addr;
if (!wm || WIIMOTE_IS_CONNECTED(wm))
return 0;
addr.l2_family = AF_BLUETOOTH;
if (address)
/* use provided address */
str2ba(address, &addr.l2_bdaddr);
else
/* use address of device discovered */
addr.l2_bdaddr = wm->bdaddr;
/*
* OUTPUT CHANNEL
*/
wm->out_sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
if (wm->out_sock == -1)
return 0;
addr.l2_psm = htobs(WM_OUTPUT_CHANNEL);
/* connect to wiimote */
if (connect(wm->out_sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
perror("connect() output sock");
return 0;
}
/*
* INPUT CHANNEL
*/
wm->in_sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
if (wm->in_sock == -1) {
close(wm->out_sock);
wm->out_sock = -1;
return 0;
}
addr.l2_psm = htobs(WM_INPUT_CHANNEL);
/* connect to wiimote */
if (connect(wm->in_sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
perror("connect() interrupt sock");
close(wm->out_sock);
wm->out_sock = -1;
return 0;
}
WIIUSE_INFO("Connected to wiimote [id %i].", wm->unid);
/* do the handshake */
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
wiiuse_handshake(wm, NULL, 0);
wiiuse_set_report_type(wm);
return 1;
}
/**
* @brief Disconnect a wiimote.
*
* @param wm Pointer to a wiimote_t structure.
*
* @see wiiuse_connect()
*
* Note that this will not free the wiimote structure.
*/
void wiiuse_disconnect(struct wiimote_t* wm) {
if (!wm || WIIMOTE_IS_CONNECTED(wm))
return;
close(wm->out_sock);
close(wm->in_sock);
wm->out_sock = -1;
wm->in_sock = -1;
wm->event = WIIUSE_NONE;
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
}
int wiiuse_io_read(struct wiimote_t* wm) {
/* not used */
return 0;
}
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
return write(wm->out_sock, buf, len);
}
#endif /* ifndef WIN32 */

View File

@@ -1,247 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Handles device I/O for Windows.
*/
#ifdef WIN32
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <hidsdi.h>
#include <setupapi.h>
#include "definitions.h"
#include "wiiuse_internal.h"
#include "io.h"
int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
GUID device_id;
HANDLE dev;
HDEVINFO device_info;
int i, index;
DWORD len;
SP_DEVICE_INTERFACE_DATA device_data;
PSP_DEVICE_INTERFACE_DETAIL_DATA detail_data = NULL;
HIDD_ATTRIBUTES attr;
int found = 0;
(void) timeout; // unused
device_data.cbSize = sizeof(device_data);
index = 0;
/* get the device id */
HidD_GetHidGuid(&device_id);
/* get all hid devices connected */
device_info = SetupDiGetClassDevs(&device_id, NULL, NULL, (DIGCF_DEVICEINTERFACE | DIGCF_PRESENT));
for (;; ++index) {
if (detail_data) {
free(detail_data);
detail_data = NULL;
}
/* query the next hid device info */
if (!SetupDiEnumDeviceInterfaces(device_info, NULL, &device_id, index, &device_data))
break;
/* get the size of the data block required */
i = SetupDiGetDeviceInterfaceDetail(device_info, &device_data, NULL, 0, &len, NULL);
detail_data = malloc(len);
detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
/* query the data for this device */
if (!SetupDiGetDeviceInterfaceDetail(device_info, &device_data, detail_data, len, NULL, NULL))
continue;
/* open the device */
dev = CreateFile(detail_data->DevicePath,
(GENERIC_READ | GENERIC_WRITE),
(FILE_SHARE_READ | FILE_SHARE_WRITE),
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if (dev == INVALID_HANDLE_VALUE)
continue;
/* get device attributes */
attr.Size = sizeof(attr);
i = HidD_GetAttributes(dev, &attr);
if ((attr.VendorID == WM_VENDOR_ID) && (attr.ProductID == WM_PRODUCT_ID)) {
/* this is a wiimote */
wm[found]->dev_handle = dev;
wm[found]->hid_overlap.hEvent = CreateEvent(NULL, 1, 1, "");
wm[found]->hid_overlap.Offset = 0;
wm[found]->hid_overlap.OffsetHigh = 0;
WIIMOTE_ENABLE_STATE(wm[found], WIIMOTE_STATE_DEV_FOUND);
WIIMOTE_ENABLE_STATE(wm[found], WIIMOTE_STATE_CONNECTED);
/* try to set the output report to see if the device is actually connected */
if (!wiiuse_set_report_type(wm[found])) {
WIIMOTE_DISABLE_STATE(wm[found], WIIMOTE_STATE_CONNECTED);
continue;
}
/* do the handshake */
wiiuse_handshake(wm[found], NULL, 0);
WIIUSE_INFO("Connected to wiimote [id %i].", wm[found]->unid);
++found;
if (found >= max_wiimotes)
break;
} else {
/* not a wiimote */
CloseHandle(dev);
}
}
if (detail_data)
free(detail_data);
SetupDiDestroyDeviceInfoList(device_info);
return found;
}
int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
int connected = 0;
int i = 0;
for (; i < wiimotes; ++i) {
if (WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_CONNECTED))
++connected;
}
return connected;
}
void wiiuse_disconnect(struct wiimote_t* wm) {
if (!wm || WIIMOTE_IS_CONNECTED(wm))
return;
CloseHandle(wm->dev_handle);
wm->dev_handle = 0;
ResetEvent(&wm->hid_overlap);
wm->event = WIIUSE_NONE;
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
}
int wiiuse_io_read(struct wiimote_t* wm) {
DWORD b, r;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return 0;
if (!ReadFile(wm->dev_handle, wm->event_buf, sizeof(wm->event_buf), &b, &wm->hid_overlap)) {
/* partial read */
b = GetLastError();
if ((b == ERROR_HANDLE_EOF) || (b == ERROR_DEVICE_NOT_CONNECTED)) {
/* remote disconnect */
wiiuse_disconnected(wm);
return 0;
}
r = WaitForSingleObject(wm->hid_overlap.hEvent, wm->timeout);
if (r == WAIT_TIMEOUT) {
/* timeout - cancel and continue */
if (*wm->event_buf)
WIIUSE_WARNING("Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
CancelIo(wm->dev_handle);
ResetEvent(wm->hid_overlap.hEvent);
return 0;
} else if (r == WAIT_FAILED) {
WIIUSE_WARNING("A wait error occured on reading from wiimote %i.", wm->unid);
return 0;
}
if (!GetOverlappedResult(wm->dev_handle, &wm->hid_overlap, &b, 0))
return 0;
}
ResetEvent(wm->hid_overlap.hEvent);
return 1;
}
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
DWORD bytes;
int i;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return 0;
switch (wm->stack) {
case WIIUSE_STACK_UNKNOWN:
{
/* try to auto-detect the stack type */
if ((i = WriteFile(wm->dev_handle, buf, 22, &bytes, &wm->hid_overlap))) {
/* bluesoleil will always return 1 here, even if it's not connected */
wm->stack = WIIUSE_STACK_BLUESOLEIL;
return i;
}
if ((i = HidD_SetOutputReport(wm->dev_handle, buf, len))) {
wm->stack = WIIUSE_STACK_MS;
return i;
}
WIIUSE_ERROR("Unable to determine bluetooth stack type.");
return 0;
}
case WIIUSE_STACK_MS:
return HidD_SetOutputReport(wm->dev_handle, buf, len);
case WIIUSE_STACK_BLUESOLEIL:
return WriteFile(wm->dev_handle, buf, 22, &bytes, &wm->hid_overlap);
}
return 0;
}
#endif /* ifdef WIN32 */

View File

@@ -1,747 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Handles IR data.
*/
#include <stdio.h>
#include <math.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include "definitions.h"
#include "wiiuse_internal.h"
#include "ir.h"
static int get_ir_sens(struct wiimote_t* wm, char** block1, char** block2);
static void interpret_ir_data(struct wiimote_t* wm);
static void fix_rotated_ir_dots(struct ir_dot_t* dot, float ang);
static void get_ir_dot_avg(struct ir_dot_t* dot, int* x, int* y);
static void reorder_ir_dots(struct ir_dot_t* dot);
static float ir_distance(struct ir_dot_t* dot);
static int ir_correct_for_bounds(int* x, int* y, enum aspect_t aspect, int offset_x, int offset_y);
static void ir_convert_to_vres(int* x, int* y, enum aspect_t aspect, int vx, int vy);
/**
* @brief Set if the wiimote should track IR targets.
*
* @param wm Pointer to a wiimote_t structure.
* @param status 1 to enable, 0 to disable.
*/
void wiiuse_set_ir(struct wiimote_t* wm, int status) {
byte buf;
char* block1 = NULL;
char* block2 = NULL;
int ir_level;
if (!wm)
return;
/*
* Wait for the handshake to finish first.
* When it handshake finishes and sees that
* IR is enabled, it will call this function
* again to actually enable IR.
*/
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE)) {
WIIUSE_DEBUG("Tried to enable IR, will wait until handshake finishes.");
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_IR);
return;
}
/*
* Check to make sure a sensitivity setting is selected.
*/
ir_level = get_ir_sens(wm, &block1, &block2);
if (!ir_level) {
WIIUSE_ERROR("No IR sensitivity setting selected.");
return;
}
if (status) {
/* if already enabled then stop */
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR))
return;
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_IR);
} else {
/* if already disabled then stop */
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR))
return;
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_IR);
}
/* set camera 1 and 2 */
buf = (status ? 0x04 : 0x00);
wiiuse_send(wm, WM_CMD_IR, &buf, 1);
wiiuse_send(wm, WM_CMD_IR_2, &buf, 1);
if (!status) {
WIIUSE_DEBUG("Disabled IR cameras for wiimote id %i.", wm->unid);
wiiuse_set_report_type(wm);
return;
}
/* enable IR, set sensitivity */
buf = 0x08;
wiiuse_write_data(wm, WM_REG_IR, &buf, 1);
/* wait for the wiimote to catch up */
#ifndef WIN32
usleep(50000);
#else
Sleep(50);
#endif
/* write sensitivity blocks */
wiiuse_write_data(wm, WM_REG_IR_BLOCK1, (byte*)block1, 9);
wiiuse_write_data(wm, WM_REG_IR_BLOCK2, (byte*)block2, 2);
/* set the IR mode */
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP))
buf = WM_IR_TYPE_BASIC;
else
buf = WM_IR_TYPE_EXTENDED;
wiiuse_write_data(wm, WM_REG_IR_MODENUM, &buf, 1);
#ifndef WIN32
usleep(50000);
#else
Sleep(50);
#endif
/* set the wiimote report type */
wiiuse_set_report_type(wm);
WIIUSE_DEBUG("Enabled IR camera for wiimote id %i (sensitivity level %i).", wm->unid, ir_level);
}
/**
* @brief Get the IR sensitivity settings.
*
* @param wm Pointer to a wiimote_t structure.
* @param block1 [out] Pointer to where block1 will be set.
* @param block2 [out] Pointer to where block2 will be set.
*
* @return Returns the sensitivity level.
*/
static int get_ir_sens(struct wiimote_t* wm, char** block1, char** block2) {
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR_SENS_LVL1)) {
*block1 = WM_IR_BLOCK1_LEVEL1;
*block2 = WM_IR_BLOCK2_LEVEL1;
return 1;
} else if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR_SENS_LVL2)) {
*block1 = WM_IR_BLOCK1_LEVEL2;
*block2 = WM_IR_BLOCK2_LEVEL2;
return 2;
} else if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR_SENS_LVL3)) {
*block1 = WM_IR_BLOCK1_LEVEL3;
*block2 = WM_IR_BLOCK2_LEVEL3;
return 3;
} else if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR_SENS_LVL4)) {
*block1 = WM_IR_BLOCK1_LEVEL4;
*block2 = WM_IR_BLOCK2_LEVEL4;
return 4;
} else if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR_SENS_LVL5)) {
*block1 = WM_IR_BLOCK1_LEVEL5;
*block2 = WM_IR_BLOCK2_LEVEL5;
return 5;
}
*block1 = NULL;
*block2 = NULL;
return 0;
}
/**
* @brief Set the virtual screen resolution for IR tracking.
*
* @param wm Pointer to a wiimote_t structure.
* @param status 1 to enable, 0 to disable.
*/
void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y) {
if (!wm) return;
wm->ir.vres[0] = (x-1);
wm->ir.vres[1] = (y-1);
}
/**
* @brief Set the XY position for the IR cursor.
*
* @param wm Pointer to a wiimote_t structure.
*/
void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos) {
if (!wm) return;
wm->ir.pos = pos;
switch (pos) {
case WIIUSE_IR_ABOVE:
wm->ir.offset[0] = 0;
if (wm->ir.aspect == WIIUSE_ASPECT_16_9)
wm->ir.offset[1] = WM_ASPECT_16_9_Y/2 - 70;
else if (wm->ir.aspect == WIIUSE_ASPECT_4_3)
wm->ir.offset[1] = WM_ASPECT_4_3_Y/2 - 100;
return;
case WIIUSE_IR_BELOW:
wm->ir.offset[0] = 0;
if (wm->ir.aspect == WIIUSE_ASPECT_16_9)
wm->ir.offset[1] = -WM_ASPECT_16_9_Y/2 + 100;
else if (wm->ir.aspect == WIIUSE_ASPECT_4_3)
wm->ir.offset[1] = -WM_ASPECT_4_3_Y/2 + 70;
return;
default:
return;
};
}
/**
* @brief Set the aspect ratio of the TV/monitor.
*
* @param wm Pointer to a wiimote_t structure.
* @param aspect Either WIIUSE_ASPECT_16_9 or WIIUSE_ASPECT_4_3
*/
void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect) {
if (!wm) return;
wm->ir.aspect = aspect;
if (aspect == WIIUSE_ASPECT_4_3) {
wm->ir.vres[0] = WM_ASPECT_4_3_X;
wm->ir.vres[1] = WM_ASPECT_4_3_Y;
} else {
wm->ir.vres[0] = WM_ASPECT_16_9_X;
wm->ir.vres[1] = WM_ASPECT_16_9_Y;
}
/* reset the position offsets */
wiiuse_set_ir_position(wm, wm->ir.pos);
}
/**
* @brief Set the IR sensitivity.
*
* @param wm Pointer to a wiimote_t structure.
* @param level 1-5, same as Wii system sensitivity setting.
*
* If the level is < 1, then level will be set to 1.
* If the level is > 5, then level will be set to 5.
*/
void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level) {
char* block1 = NULL;
char* block2 = NULL;
if (!wm) return;
if (level > 5) level = 5;
if (level < 1) level = 1;
WIIMOTE_DISABLE_STATE(wm, (WIIMOTE_STATE_IR_SENS_LVL1 |
WIIMOTE_STATE_IR_SENS_LVL2 |
WIIMOTE_STATE_IR_SENS_LVL3 |
WIIMOTE_STATE_IR_SENS_LVL4 |
WIIMOTE_STATE_IR_SENS_LVL5));
switch (level) {
case 1:
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_IR_SENS_LVL1);
break;
case 2:
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_IR_SENS_LVL2);
break;
case 3:
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_IR_SENS_LVL3);
break;
case 4:
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_IR_SENS_LVL4);
break;
case 5:
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_IR_SENS_LVL5);
break;
default:
return;
}
/* set the new sensitivity */
get_ir_sens(wm, &block1, &block2);
wiiuse_write_data(wm, WM_REG_IR_BLOCK1, (byte*)block1, 9);
wiiuse_write_data(wm, WM_REG_IR_BLOCK2, (byte*)block2, 2);
WIIUSE_DEBUG("Set IR sensitivity to level %i (unid %i)", level, wm->unid);
}
/**
* @brief Calculate the data from the IR spots. Basic IR mode.
*
* @param wm Pointer to a wiimote_t structure.
* @param data Data returned by the wiimote for the IR spots.
*/
void calculate_basic_ir(struct wiimote_t* wm, byte* data) {
struct ir_dot_t* dot = wm->ir.dot;
int i;
dot[0].rx = 1023 - (data[0] | ((data[2] & 0x30) << 4));
dot[0].ry = data[1] | ((data[2] & 0xC0) << 2);
dot[1].rx = 1023 - (data[3] | ((data[2] & 0x03) << 8));
dot[1].ry = data[4] | ((data[2] & 0x0C) << 6);
dot[2].rx = 1023 - (data[5] | ((data[7] & 0x30) << 4));
dot[2].ry = data[6] | ((data[7] & 0xC0) << 2);
dot[3].rx = 1023 - (data[8] | ((data[7] & 0x03) << 8));
dot[3].ry = data[9] | ((data[7] & 0x0C) << 6);
/* set each IR spot to visible if spot is in range */
for (i = 0; i < 4; ++i) {
if (dot[i].ry == 1023)
dot[i].visible = 0;
else {
dot[i].visible = 1;
dot[i].size = 0; /* since we don't know the size, set it as 0 */
}
}
interpret_ir_data(wm);
}
/**
* @brief Calculate the data from the IR spots. Extended IR mode.
*
* @param wm Pointer to a wiimote_t structure.
* @param data Data returned by the wiimote for the IR spots.
*/
void calculate_extended_ir(struct wiimote_t* wm, byte* data) {
struct ir_dot_t* dot = wm->ir.dot;
int i;
for (i = 0; i < 4; ++i) {
dot[i].rx = 1023 - (data[3*i] | ((data[(3*i)+2] & 0x30) << 4));
dot[i].ry = data[(3*i)+1] | ((data[(3*i)+2] & 0xC0) << 2);
dot[i].size = data[(3*i)+2] & 0x0F;
/* if in range set to visible */
if (dot[i].ry == 1023)
dot[i].visible = 0;
else
dot[i].visible = 1;
}
interpret_ir_data(wm);
}
/**
* @brief Interpret IR data into more user friendly variables.
*
* @param wm Pointer to a wiimote_t structure.
*/
static void interpret_ir_data(struct wiimote_t* wm) {
struct ir_dot_t* dot = wm->ir.dot;
int i;
float roll = 0.0f;
int last_num_dots = wm->ir.num_dots;
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_ACC))
roll = wm->orient.roll;
/* count visible dots */
wm->ir.num_dots = 0;
for (i = 0; i < 4; ++i) {
if (dot[i].visible)
wm->ir.num_dots++;
}
switch (wm->ir.num_dots) {
case 0:
{
wm->ir.state = 0;
/* reset the dot ordering */
for (i = 0; i < 4; ++i)
dot[i].order = 0;
wm->ir.x = 0;
wm->ir.y = 0;
wm->ir.z = 0.0f;
return;
}
case 1:
{
fix_rotated_ir_dots(wm->ir.dot, roll);
if (wm->ir.state < 2) {
/*
* Only 1 known dot, so use just that.
*/
for (i = 0; i < 4; ++i) {
if (dot[i].visible) {
wm->ir.x = dot[i].x;
wm->ir.y = dot[i].y;
wm->ir.ax = wm->ir.x;
wm->ir.ay = wm->ir.y;
/* can't calculate yaw because we don't have the distance */
//wm->orient.yaw = calc_yaw(&wm->ir);
ir_convert_to_vres(&wm->ir.x, &wm->ir.y, wm->ir.aspect, wm->ir.vres[0], wm->ir.vres[1]);
break;
}
}
} else {
/*
* Only see 1 dot but know theres 2.
* Try to estimate where the other one
* should be and use that.
*/
for (i = 0; i < 4; ++i) {
if (dot[i].visible) {
int ox = 0;
int x, y;
if (dot[i].order == 1)
/* visible is the left dot - estimate where the right is */
ox = dot[i].x + wm->ir.distance;
else if (dot[i].order == 2)
/* visible is the right dot - estimate where the left is */
ox = dot[i].x - wm->ir.distance;
x = ((signed int)dot[i].x + ox) / 2;
y = dot[i].y;
wm->ir.ax = x;
wm->ir.ay = y;
wm->orient.yaw = calc_yaw(&wm->ir);
if (ir_correct_for_bounds(&x, &y, wm->ir.aspect, wm->ir.offset[0], wm->ir.offset[1])) {
ir_convert_to_vres(&x, &y, wm->ir.aspect, wm->ir.vres[0], wm->ir.vres[1]);
wm->ir.x = x;
wm->ir.y = y;
}
break;
}
}
}
break;
}
case 2:
case 3:
case 4:
{
/*
* Two (or more) dots known and seen.
* Average them together to estimate the true location.
*/
int x, y;
wm->ir.state = 2;
fix_rotated_ir_dots(wm->ir.dot, roll);
/* if there is at least 1 new dot, reorder them all */
if (wm->ir.num_dots > last_num_dots) {
reorder_ir_dots(dot);
wm->ir.x = 0;
wm->ir.y = 0;
}
wm->ir.distance = ir_distance(dot);
wm->ir.z = 1023 - wm->ir.distance;
get_ir_dot_avg(wm->ir.dot, &x, &y);
wm->ir.ax = x;
wm->ir.ay = y;
wm->orient.yaw = calc_yaw(&wm->ir);
if (ir_correct_for_bounds(&x, &y, wm->ir.aspect, wm->ir.offset[0], wm->ir.offset[1])) {
ir_convert_to_vres(&x, &y, wm->ir.aspect, wm->ir.vres[0], wm->ir.vres[1]);
wm->ir.x = x;
wm->ir.y = y;
}
break;
}
default:
{
break;
}
}
#ifdef WITH_WIIUSE_DEBUG
{
int ir_level;
WIIUSE_GET_IR_SENSITIVITY(wm, &ir_level);
WIIUSE_DEBUG("IR sensitivity: %i", ir_level);
WIIUSE_DEBUG("IR visible dots: %i", wm->ir.num_dots);
for (i = 0; i < 4; ++i)
if (dot[i].visible)
WIIUSE_DEBUG("IR[%i][order %i] (%.3i, %.3i) -> (%.3i, %.3i)", i, dot[i].order, dot[i].rx, dot[i].ry, dot[i].x, dot[i].y);
WIIUSE_DEBUG("IR[absolute]: (%i, %i)", wm->ir.x, wm->ir.y);
}
#endif
}
/**
* @brief Fix the rotation of the IR dots.
*
* @param dot An array of 4 ir_dot_t objects.
* @param ang The roll angle to correct by (-180, 180)
*
* If there is roll then the dots are rotated
* around the origin and give a false cursor
* position. Correct for the roll.
*
* If the accelerometer is off then obviously
* this will not do anything and the cursor
* position may be inaccurate.
*/
static void fix_rotated_ir_dots(struct ir_dot_t* dot, float ang) {
float s, c;
int x, y;
int i;
if (!ang) {
for (i = 0; i < 4; ++i) {
dot[i].x = dot[i].rx;
dot[i].y = dot[i].ry;
}
return;
}
s = sin(DEGREE_TO_RAD(ang));
c = cos(DEGREE_TO_RAD(ang));
/*
* [ cos(theta) -sin(theta) ][ ir->rx ]
* [ sin(theta) cos(theta) ][ ir->ry ]
*/
for (i = 0; i < 4; ++i) {
if (!dot[i].visible)
continue;
x = dot[i].rx - (1024/2);
y = dot[i].ry - (768/2);
dot[i].x = (c * x) + (-s * y);
dot[i].y = (s * x) + (c * y);
dot[i].x += (1024/2);
dot[i].y += (768/2);
}
}
/**
* @brief Average IR dots.
*
* @param dot An array of 4 ir_dot_t objects.
* @param x [out] Average X
* @param y [out] Average Y
*/
static void get_ir_dot_avg(struct ir_dot_t* dot, int* x, int* y) {
int vis = 0, i = 0;
*x = 0;
*y = 0;
for (; i < 4; ++i) {
if (dot[i].visible) {
*x += dot[i].x;
*y += dot[i].y;
++vis;
}
}
*x /= vis;
*y /= vis;
}
/**
* @brief Reorder the IR dots.
*
* @param dot An array of 4 ir_dot_t objects.
*/
static void reorder_ir_dots(struct ir_dot_t* dot) {
int i, j, order;
/* reset the dot ordering */
for (i = 0; i < 4; ++i)
dot[i].order = 0;
for (order = 1; order < 5; ++order) {
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))
i = j;
}
dot[i].order = order;
}
}
/**
* @brief Calculate the distance between the first 2 visible IR dots.
*
* @param dot An array of 4 ir_dot_t objects.
*/
static float ir_distance(struct ir_dot_t* dot) {
int i1, i2;
int xd, yd;
for (i1 = 0; i1 < 4; ++i1)
if (dot[i1].visible)
break;
if (i1 == 4)
return 0.0f;
for (i2 = i1+1; i2 < 4; ++i2)
if (dot[i2].visible)
break;
if (i2 == 4)
return 0.0f;
xd = dot[i2].x - dot[i1].x;
yd = dot[i2].y - dot[i1].y;
return sqrt(xd*xd + yd*yd);
}
/**
* @brief Correct for the IR bounding box.
*
* @param x [out] The current X, it will be updated if valid.
* @param y [out] The current Y, it will be updated if valid.
* @param aspect Aspect ratio of the screen.
* @param offset_x The X offset of the bounding box.
* @param offset_y The Y offset of the bounding box.
*
* @return Returns 1 if the point is valid and was updated.
*
* Nintendo was smart with this bit. They sacrifice a little
* precision for a big increase in usability.
*/
static int ir_correct_for_bounds(int* x, int* y, enum aspect_t aspect, int offset_x, int offset_y) {
int x0, y0;
int xs, ys;
if (aspect == WIIUSE_ASPECT_16_9) {
xs = WM_ASPECT_16_9_X;
ys = WM_ASPECT_16_9_Y;
} else {
xs = WM_ASPECT_4_3_X;
ys = WM_ASPECT_4_3_Y;
}
x0 = ((1024 - xs) / 2) + offset_x;
y0 = ((768 - ys) / 2) + offset_y;
if ((*x >= x0)
&& (*x <= (x0 + xs))
&& (*y >= y0)
&& (*y <= (y0 + ys)))
{
*x -= offset_x;
*y -= offset_y;
return 1;
}
return 0;
}
/**
* @brief Interpolate the point to the user defined virtual screen resolution.
*/
static void ir_convert_to_vres(int* x, int* y, enum aspect_t aspect, int vx, int vy) {
int xs, ys;
if (aspect == WIIUSE_ASPECT_16_9) {
xs = WM_ASPECT_16_9_X;
ys = WM_ASPECT_16_9_Y;
} else {
xs = WM_ASPECT_4_3_X;
ys = WM_ASPECT_4_3_Y;
}
*x -= ((1024-xs)/2);
*y -= ((768-ys)/2);
*x = (*x / (float)xs) * vx;
*y = (*y / (float)ys) * vy;
}
/**
* @brief Calculate yaw given the IR data.
*
* @param ir IR data structure.
*/
float calc_yaw(struct ir_t* ir) {
float x;
x = ir->ax - 512;
x = x * (ir->z / 1024.0f);
return RAD_TO_DEGREE( atanf(x / ir->z) );
}

View File

@@ -1,56 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Handles IR data.
*/
#ifndef IR_H_INCLUDED
#define IR_H_INCLUDED
#include "wiiuse_internal.h"
#define WII_VRES_X 560
#define WII_VRES_Y 340
#ifdef __cplusplus
extern "C" {
#endif
void calculate_basic_ir(struct wiimote_t* wm, byte* data);
void calculate_extended_ir(struct wiimote_t* wm, byte* data);
float calc_yaw(struct ir_t* ir);
#ifdef __cplusplus
}
#endif
#endif // IR_H_INCLUDED

View File

@@ -1,199 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Nunchuk expansion device.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "definitions.h"
#include "wiiuse_internal.h"
#include "dynamics.h"
#include "events.h"
#include "nunchuk.h"
static void nunchuk_pressed_buttons(struct nunchuk_t* nc, byte now);
/**
* @brief Handle the handshake data from the nunchuk.
*
* @param nc A pointer to a nunchuk_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 nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, unsigned short len) {
int offset = 0;
nc->btns = 0;
nc->btns_held = 0;
nc->btns_released = 0;
/* set the smoothing to the same as the wiimote */
nc->flags = &wm->flags;
nc->accel_calib.st_alpha = wm->accel_calib.st_alpha;
if (data[offset] == 0xFF) {
/*
* Sometimes the data returned here is not correct.
* This might happen because the wiimote is lagging
* behind our initialization sequence.
* To fix this just request the handshake again.
*
* Other times it's just the first 16 bytes are 0xFF,
* but since the next 16 bytes are the same, just use
* those.
*/
if (data[offset + 16] == 0xFF) {
/* get the calibration data */
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
WIIUSE_DEBUG("Nunchuk handshake appears invalid, trying again.");
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
return 0;
} else
offset += 16;
}
nc->accel_calib.cal_zero.x = data[offset + 0];
nc->accel_calib.cal_zero.y = data[offset + 1];
nc->accel_calib.cal_zero.z = data[offset + 2];
nc->accel_calib.cal_g.x = data[offset + 4];
nc->accel_calib.cal_g.y = data[offset + 5];
nc->accel_calib.cal_g.z = data[offset + 6];
nc->js.max.x = data[offset + 8];
nc->js.min.x = data[offset + 9];
nc->js.center.x = data[offset + 10];
nc->js.max.y = data[offset + 11];
nc->js.min.y = data[offset + 12];
nc->js.center.y = data[offset + 13];
/* default the thresholds to the same as the wiimote */
nc->orient_threshold = wm->orient_threshold;
nc->accel_threshold = wm->accel_threshold;
/* handshake done */
wm->exp.type = EXP_NUNCHUK;
#ifdef WIN32
wm->timeout = WIIMOTE_DEFAULT_TIMEOUT;
#endif
return 1;
}
/**
* @brief The nunchuk disconnected.
*
* @param nc A pointer to a nunchuk_t structure.
*/
void nunchuk_disconnected(struct nunchuk_t* nc) {
memset(nc, 0, sizeof(struct nunchuk_t));
}
/**
* @brief Handle nunchuk event.
*
* @param nc A pointer to a nunchuk_t structure.
* @param msg The message specified in the event packet.
*/
void nunchuk_event(struct nunchuk_t* nc, byte* msg) {
/* get button states */
nunchuk_pressed_buttons(nc, msg[5]);
/* calculate joystick state */
calc_joystick_state(&nc->js, msg[0], msg[1]);
/* calculate orientation */
nc->accel.x = msg[2];
nc->accel.y = msg[3];
nc->accel.z = msg[4];
calculate_orientation(&nc->accel_calib, &nc->accel, &nc->orient, NUNCHUK_IS_FLAG_SET(nc, WIIUSE_SMOOTHING));
calculate_gforce(&nc->accel_calib, &nc->accel, &nc->gforce);
}
/**
* @brief Find what buttons are pressed.
*
* @param nc Pointer to a nunchuk_t structure.
* @param msg The message byte specified in the event packet.
*/
static void nunchuk_pressed_buttons(struct nunchuk_t* nc, byte now) {
/* message is inverted (0 is active, 1 is inactive) */
now = ~now & NUNCHUK_BUTTON_ALL;
/* pressed now & were pressed, then held */
nc->btns_held = (now & nc->btns);
/* were pressed or were held & not pressed now, then released */
nc->btns_released = ((nc->btns | nc->btns_held) & ~now);
/* buttons pressed now */
nc->btns = now;
}
/**
* @brief Set the orientation event threshold for the nunchuk.
*
* @param wm Pointer to a wiimote_t structure with a nunchuk attached.
* @param threshold The decimal place that should be considered a significant change.
*
* See wiiuse_set_orient_threshold() for details.
*/
void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold) {
if (!wm) return;
wm->exp.nunchuk.orient_threshold = threshold;
}
/**
* @brief Set the accelerometer event threshold for the nunchuk.
*
* @param wm Pointer to a wiimote_t structure with a nunchuk attached.
* @param threshold The decimal place that should be considered a significant change.
*
* See wiiuse_set_orient_threshold() for details.
*/
void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold) {
if (!wm) return;
wm->exp.nunchuk.accel_threshold = threshold;
}

View File

@@ -1,53 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Nunchuk expansion device.
*/
#ifndef NUNCHUK_H_INCLUDED
#define NUNCHUK_H_INCLUDED
#include "wiiuse_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, unsigned short len);
void nunchuk_disconnected(struct nunchuk_t* nc);
void nunchuk_event(struct nunchuk_t* nc, byte* msg);
#ifdef __cplusplus
}
#endif
#endif // NUNCHUK_H_INCLUDED

View File

@@ -1,56 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief Operating system related definitions.
*
* This file is an attempt to separate operating system
* dependent functions and choose what should be used
* at compile time.
*/
#ifndef OS_H_INCLUDED
#define OS_H_INCLUDED
#ifdef WIN32
/* windows */
//#define isnan(x) _isnan(x)
//#define isinf(x) !_finite(x)
/* disable warnings I don't care about */
//#pragma warning(disable:4244) /* possible loss of data conversion */
//#pragma warning(disable:4273) /* inconsistent dll linkage */
//#pragma warning(disable:4217)
#else
/* nix */
#endif
#endif // OS_H_INCLUDED

View File

@@ -1,86 +0,0 @@
#include <stdio.h>
#include "definitions.h"
#include "wiiuse_internal.h"
#include "wiiuse.h"
#include "speaker.h"
void wiiuse_speaker_init(struct wiimote_t* wm) {
wiiuse_speaker_format(wm, 0x00);
wiiuse_speaker_rate(wm, 0x00, 0x00);
wiiuse_speaker_volume(wm, 0x00);
}
void wiiuse_speaker_enable(struct wiimote_t* wm) {
byte buf = WIIMOTE_GET_RUMBLE(wm) | WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED;
wiiuse_send(wm, WM_CMD_SPEAKER_ENABLE, &buf, 1);
}
void wiiuse_speaker_disable(struct wiimote_t* wm) {
byte buf = WIIMOTE_GET_RUMBLE(wm);
wiiuse_send(wm, WM_CMD_SPEAKER_ENABLE, &buf, 1);
}
void wiiuse_speaker_mute(struct wiimote_t* wm) {
byte buf = WIIMOTE_GET_RUMBLE(wm) | WM_CTRL_STATUS_BYTE1_SPEAKER_MUTE;
wiiuse_send(wm, WM_CMD_SPEAKER_MUTE, &buf , 1);
}
void wiiuse_speaker_unmute(struct wiimote_t* wm) {
byte buf = WIIMOTE_GET_RUMBLE(wm);
wiiuse_send(wm, WM_CMD_SPEAKER_MUTE, &buf, 1);
}
void wiiuse_speaker_activate(struct wiimote_t* wm) {
wiiuse_speaker_enable(wm);
wiiuse_speaker_mute(wm);
#if 0
byte buf = 0x01;
wiiuse_write_data(wm, WM_REG_SPEAKER + 8, &buf, 1);
buf = 0x08;
wiiuse_write_data(wm, WM_REG_SPEAKER, &buf, 1);
wiiuse_speaker_config(wm);
buf = 0x01;
wiiuse_write_data(wm, WM_REG_SPEAKER + 7, &buf, 1);
#else
byte buf[9] = {0x00, wm->speaker.format, wm->speaker.rate, wm->speaker.freq, wm->speaker.vol, 0x00, 0x00, 0x01, 0x01};
wiiuse_write_data(wm, WM_REG_SPEAKER, buf, 9);
#endif
wiiuse_speaker_unmute(wm);
}
void wiiuse_speaker_deactivate(struct wiimote_t* wm) {
wiiuse_speaker_mute(wm);
wiiuse_speaker_disable(wm);
}
void wiiuse_speaker_format(struct wiimote_t* wm, byte format) {
wm->speaker.format = format;
}
void wiiuse_speaker_rate(struct wiimote_t* wm, byte rate, byte freq) {
// Check: pcm_sample_rate = 12000000 / rate_value adpcm_sample_rate = 6000000 / rate_value
wm->speaker.rate = rate;
//wm->speaker.freq = freq;
}
void wiiuse_speaker_volume(struct wiimote_t* wm, double vol) {
wm->speaker.vol = vol * WIIMOTE_GET_SPEAKER_MAX_VOLUME(wm);
}
void wiiuse_speaker_config(struct wiimote_t* wm) {
WIIUSE_DEBUG("speaker_config()");
WIIUSE_DEBUG("format: %2x", wm->speaker.format);
WIIUSE_DEBUG("rate: %2x", wm->speaker.rate);
WIIUSE_DEBUG("freq: %2x", wm->speaker.freq);
WIIUSE_DEBUG("vol: %2x", wm->speaker.vol);
byte cfg[7] = {0x00, wm->speaker.format, wm->speaker.rate, wm->speaker.freq, wm->speaker.vol, 0x00, 0x00};
wiiuse_write_data(wm, WM_REG_SPEAKER, cfg, 7);
}
void wiiuse_speaker_data(struct wiimote_t* wm, byte* data, int len) {
byte buf[21] = {0x00};
buf[0] = len << 3;
//WIIUSE_DEBUG("speaker_data(): length = %d", len);
memcpy(buf + 1, data, len);
wiiuse_send(wm, WM_CMD_STREAM_DATA, buf, 21);
}

View File

@@ -1,14 +0,0 @@
#include "wiiuse.h"
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define WIIMOTE_GET_RUMBLE(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE) ? 0x01 : 0x00)
#define WIIMOTE_GET_SPEAKER_MAX_VOLUME(wm) (wm->speaker.format == 0x00 ? 0x40 : 0xff)
#define WM_CMD_SPEAKER_ENABLE 0x14
#define WM_CMD_STREAM_DATA 0x18
#define WM_CMD_SPEAKER_MUTE 0x19
#define WM_CTRL_STATUS_BYTE1_SPEAKER_MUTE 0x04
#define WM_REG_SPEAKER 0x04a20001

View File

@@ -1,768 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief General wiimote operations.
*
* The file includes functions that handle general
* tasks. Most of these are functions that are part
* of the API.
*/
#include <stdio.h>
#include <stdlib.h>
#ifndef WIN32
#include <unistd.h>
#else
#include <Winsock2.h>
#endif
#include "definitions.h"
#include "wiiuse_internal.h"
#include "wiiuse.h"
#include "events.h"
#include "io.h"
static int g_banner = 1;
/**
* @breif Returns the version of the library.
*/
const char* wiiuse_version() {
return WIIUSE_VERSION;
}
/**
* @brief Clean up wiimote_t array created by wiiuse_init()
*/
void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes) {
int i = 0;
if (!wm)
return;
WIIUSE_INFO("wiiuse clean up...");
for (; i < wiimotes; ++i) {
wiiuse_disconnect(wm[i]);
free(wm[i]);
}
free(wm);
return;
}
/**
* @brief Initialize an array of wiimote structures.
*
* @param wiimotes Number of wiimote_t structures to create.
*
* @return An array of initialized wiimote_t structures.
*
* @see wiiuse_connect()
*
* The array returned by this function can be passed to various
* functions, including wiiuse_connect().
*/
struct wiimote_t** wiiuse_init(int wiimotes) {
int i = 0;
struct wiimote_t** wm = NULL;
/*
* Please do not remove this banner.
* GPL asks that you please leave output credits intact.
* Thank you.
*
* This banner is only displayed once so that if you need
* to call this function again it won't be intrusive.
*/
if (!g_banner) {
printf( "wiiuse v" WIIUSE_VERSION " loaded.\n"
" By: Michael Laforest <thepara[at]gmail{dot}com>\n"
" http://wiiuse.net http://wiiuse.sf.net\n");
g_banner = 1;
}
if (!wiimotes)
return NULL;
wm = malloc(sizeof(struct wiimote_t*) * wiimotes);
for (i = 0; i < wiimotes; ++i) {
wm[i] = malloc(sizeof(struct wiimote_t));
memset(wm[i], 0, sizeof(struct wiimote_t));
wm[i]->unid = i+1;
#ifndef WIN32
wm[i]->bdaddr = *BDADDR_ANY;
wm[i]->out_sock = -1;
wm[i]->in_sock = -1;
#else
wm[i]->dev_handle = 0;
wm[i]->stack = WIIUSE_STACK_UNKNOWN;
wm[i]->normal_timeout = WIIMOTE_DEFAULT_TIMEOUT;
wm[i]->exp_timeout = WIIMOTE_EXP_TIMEOUT;
wm[i]->timeout = wm[i]->normal_timeout;
#endif
wm[i]->state = WIIMOTE_INIT_STATES;
wm[i]->flags = WIIUSE_INIT_FLAGS;
wm[i]->event = WIIUSE_NONE;
wm[i]->exp.type = EXP_NONE;
wiiuse_set_aspect_ratio(wm[i], WIIUSE_ASPECT_4_3);
wiiuse_set_ir_position(wm[i], WIIUSE_IR_ABOVE);
wm[i]->orient_threshold = 0.5f;
wm[i]->accel_threshold = 5;
wm[i]->accel_calib.st_alpha = WIIUSE_DEFAULT_SMOOTH_ALPHA;
}
return wm;
}
/**
* @brief The wiimote disconnected.
*
* @param wm Pointer to a wiimote_t structure.
*/
void wiiuse_disconnected(struct wiimote_t* wm) {
if (!wm) return;
WIIUSE_INFO("Wiimote disconnected [id %i].", wm->unid);
/* disable the connected flag */
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
/* reset a bunch of stuff */
#ifndef WIN32
wm->out_sock = -1;
wm->in_sock = -1;
#else
wm->dev_handle = 0;
#endif
wm->leds = 0;
wm->state = WIIMOTE_INIT_STATES;
wm->read_req = NULL;
wm->handshake_state = 0;
wm->btns = 0;
wm->btns_held = 0;
wm->btns_released = 0;
memset(wm->event_buf, 0, sizeof(wm->event_buf));
wm->event = WIIUSE_DISCONNECT;
}
/**
* @brief Enable or disable the rumble.
*
* @param wm Pointer to a wiimote_t structure.
* @param status 1 to enable, 0 to disable.
*/
void wiiuse_rumble(struct wiimote_t* wm, int status) {
byte buf;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return;
/* make sure to keep the current lit leds */
buf = wm->leds;
if (status) {
WIIUSE_DEBUG("Starting rumble...");
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_RUMBLE);
buf |= 0x01;
} else {
WIIUSE_DEBUG("Stopping rumble...");
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_RUMBLE);
}
/* preserve IR state */
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR))
buf |= 0x04;
wiiuse_send(wm, WM_CMD_RUMBLE, &buf, 1);
}
/**
* @brief Toggle the state of the rumble.
*
* @param wm Pointer to a wiimote_t structure.
*/
void wiiuse_toggle_rumble(struct wiimote_t* wm) {
if (!wm) return;
wiiuse_rumble(wm, !WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE));
}
/**
* @brief Set the enabled LEDs.
*
* @param wm Pointer to a wiimote_t structure.
* @param leds What LEDs to enable.
*
* \a leds is a bitwise or of WIIMOTE_LED_1, WIIMOTE_LED_2, WIIMOTE_LED_3, or WIIMOTE_LED_4.
*/
void wiiuse_set_leds(struct wiimote_t* wm, int leds) {
byte buf;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return;
/* remove the lower 4 bits because they control rumble */
wm->leds = (leds & 0xF0);
/* make sure if the rumble is on that we keep it on */
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE))
wm->leds |= 0x01;
buf = wm->leds;
wiiuse_send(wm, WM_CMD_LED, &buf, 1);
}
/**
* @brief Set if the wiimote should report motion sensing.
*
* @param wm Pointer to a wiimote_t structure.
* @param status 1 to enable, 0 to disable.
*
* Since reporting motion sensing sends a lot of data,
* the wiimote saves power by not transmitting it
* by default.
*/
void wiiuse_motion_sensing(struct wiimote_t* wm, int status) {
if (status)
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_ACC);
else
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_ACC);
wiiuse_set_report_type(wm);
}
/**
* @brief Set the report type based on the current wiimote state.
*
* @param wm Pointer to a wiimote_t structure.
*
* @return The report type sent.
*
* The wiimote reports formatted packets depending on the
* report type that was last requested. This function will
* update the type of report that should be sent based on
* the current state of the device.
*/
int wiiuse_set_report_type(struct wiimote_t* wm) {
byte buf[2];
int motion, exp, ir;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return 0;
buf[0] = (WIIMOTE_IS_FLAG_SET(wm, WIIUSE_CONTINUOUS) ? 0x04 : 0x00); /* set to 0x04 for continuous reporting */
buf[1] = 0x00;
/* if rumble is enabled, make sure we keep it */
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE))
buf[0] |= 0x01;
motion = WIIMOTE_IS_SET(wm, WIIMOTE_STATE_ACC);
exp = WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP);
ir = WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR);
if (motion && ir && exp) buf[1] = WM_RPT_BTN_ACC_IR_EXP;
else if (motion && exp) buf[1] = WM_RPT_BTN_ACC_EXP;
else if (motion && ir) buf[1] = WM_RPT_BTN_ACC_IR;
else if (ir && exp) buf[1] = WM_RPT_BTN_IR_EXP;
else if (ir) buf[1] = WM_RPT_BTN_ACC_IR;
else if (exp) buf[1] = WM_RPT_BTN_EXP;
else if (motion) buf[1] = WM_RPT_BTN_ACC;
else buf[1] = WM_RPT_BTN;
WIIUSE_DEBUG("Setting report type: 0x%x", buf[1]);
exp = wiiuse_send(wm, WM_CMD_REPORT_TYPE, buf, 2);
if (exp <= 0)
return exp;
return buf[1];
}
/**
* @brief Read data from the wiimote (callback version).
*
* @param wm Pointer to a wiimote_t structure.
* @param read_cb Function pointer to call when the data arrives from the wiimote.
* @param buffer An allocated buffer to store the data as it arrives from the wiimote.
* Must be persistent in memory and large enough to hold the data.
* @param addr The address of wiimote memory to read from.
* @param len The length of the block to be read.
*
* The library can only handle one data read request at a time
* because it must keep track of the buffer and other
* events that are specific to that request. So if a request
* has already been made, subsequent requests will be added
* to a pending list and be sent out when the previous
* finishes.
*/
int wiiuse_read_data_cb(struct wiimote_t* wm, wiiuse_read_cb read_cb, byte* buffer, unsigned int addr, unsigned short len) {
struct read_req_t* req;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return 0;
if (!buffer || !len || !read_cb)
return 0;
/* make this request structure */
req = (struct read_req_t*)malloc(sizeof(struct read_req_t));
req->cb = read_cb;
req->buf = buffer;
req->addr = addr;
req->size = len;
req->wait = len;
req->dirty = 0;
req->next = NULL;
/* add this to the request list */
if (!wm->read_req) {
/* root node */
wm->read_req = req;
WIIUSE_DEBUG("Data read request can be sent out immediately.");
/* send the request out immediately */
wiiuse_send_next_pending_read_request(wm);
} else {
struct read_req_t* nptr = wm->read_req;
for (; nptr->next; nptr = nptr->next);
nptr->next = req;
WIIUSE_DEBUG("Added pending data read request.");
}
return 1;
}
/**
* @brief Read data from the wiimote (event version).
*
* @param wm Pointer to a wiimote_t structure.
* @param buffer An allocated buffer to store the data as it arrives from the wiimote.
* Must be persistent in memory and large enough to hold the data.
* @param addr The address of wiimote memory to read from.
* @param len The length of the block to be read.
*
* The library can only handle one data read request at a time
* because it must keep track of the buffer and other
* events that are specific to that request. So if a request
* has already been made, subsequent requests will be added
* to a pending list and be sent out when the previous
* finishes.
*/
int wiiuse_read_data(struct wiimote_t* wm, byte* buffer, unsigned int addr, unsigned short len) {
struct read_req_t* req;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return 0;
if (!buffer || !len)
return 0;
/* make this request structure */
req = (struct read_req_t*)malloc(sizeof(struct read_req_t));
req->cb = NULL;
req->buf = buffer;
req->addr = addr;
req->size = len;
req->wait = len;
req->dirty = 0;
req->next = NULL;
/* add this to the request list */
if (!wm->read_req) {
/* root node */
wm->read_req = req;
WIIUSE_DEBUG("Data read request can be sent out immediately.");
/* send the request out immediately */
wiiuse_send_next_pending_read_request(wm);
} else {
struct read_req_t* nptr = wm->read_req;
for (; nptr->next; nptr = nptr->next);
nptr->next = req;
WIIUSE_DEBUG("Added pending data read request.");
}
return 1;
}
/**
* @brief Send the next pending data read request to the wiimote.
*
* @param wm Pointer to a wiimote_t structure.
*
* @see wiiuse_read_data()
*
* This function is not part of the wiiuse API.
*/
void wiiuse_send_next_pending_read_request(struct wiimote_t* wm) {
byte buf[6];
struct read_req_t* req;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return;
if (!wm->read_req) return;
/* skip over dirty ones since they have already been read */
req = wm->read_req;
while (req && req->dirty)
req = req->next;
if (!req)
return;
/* the offset is in big endian */
*(int*)(buf) = BIG_ENDIAN_LONG(req->addr);
/* the length is in big endian */
*(short*)(buf + 4) = BIG_ENDIAN_SHORT(req->size);
WIIUSE_DEBUG("Request read at address: 0x%x length: %i", req->addr, req->size);
wiiuse_send(wm, WM_CMD_READ_DATA, buf, 6);
}
/**
* @brief Request the wiimote controller status.
*
* @param wm Pointer to a wiimote_t structure.
*
* Controller status includes: battery level, LED status, expansions
*/
void wiiuse_status(struct wiimote_t* wm) {
byte buf = 0;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return;
WIIUSE_DEBUG("Requested wiimote status.");
wiiuse_send(wm, WM_CMD_CTRL_STATUS, &buf, 1);
}
/**
* @brief Find a wiimote_t structure by its unique identifier.
*
* @param wm Pointer to a wiimote_t structure.
* @param wiimotes The number of wiimote_t structures in \a wm.
* @param unid The unique identifier to search for.
*
* @return Pointer to a wiimote_t structure, or NULL if not found.
*/
struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid) {
int i = 0;
for (; i < wiimotes; ++i) {
if (wm[i]->unid == unid)
return wm[i];
}
return NULL;
}
/**
* @brief Write data to the wiimote.
*
* @param wm Pointer to a wiimote_t structure.
* @param addr The address to write to.
* @param data The data to be written to the memory location.
* @param len The length of the block to be written.
*/
int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len) {
byte buf[21] = {0}; /* the payload is always 23 */
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return 0;
if (!data || !len)
return 0;
WIIUSE_DEBUG("Writing %i bytes to memory location 0x%x...", len, addr);
#ifdef WITH_WIIUSE_DEBUG
{
int i = 0;
fprintf(stderr, "[DEBUG} Write data is: ");
for (; i < len; ++i)
fprintf(stderr, "%x ", data[i]);
fprintf(stderr, "\n");
fflush(stderr);
}
#endif
/* the offset is in big endian */
*(int*)(buf) = BIG_ENDIAN_LONG(addr);
/* length */
*(byte*)(buf + 4) = len;
/* data */
memcpy(buf + 5, data, len);
wiiuse_send(wm, WM_CMD_WRITE_DATA, buf, 21);
return 1;
}
/**
* @brief Send a packet to the wiimote.
*
* @param wm Pointer to a wiimote_t structure.
* @param report_type The report type to send (WIIMOTE_CMD_LED, WIIMOTE_CMD_RUMBLE, etc). Found in wiiuse.h
* @param msg The payload.
* @param len Length of the payload in bytes.
*
* This function should replace any write()s directly to the wiimote device.
*/
int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len) {
byte buf[32]; /* no payload is better than this */
int rumble = 0;
#ifndef WIN32
buf[0] = WM_SET_REPORT | WM_BT_OUTPUT;
buf[1] = report_type;
#else
buf[0] = report_type;
#endif
switch (report_type) {
case WM_CMD_LED:
case WM_CMD_RUMBLE:
case WM_CMD_CTRL_STATUS:
{
/* Rumble flag for: 0x11, 0x13, 0x14, 0x15, 0x19 or 0x1a */
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE))
rumble = 1;
break;
}
default:
break;
}
#ifndef WIN32
memcpy(buf+2, msg, len);
if (rumble)
buf[2] |= 0x01;
#else
memcpy(buf+1, msg, len);
if (rumble)
buf[1] |= 0x01;
#endif
#ifdef WITH_WIIUSE_DEBUG
{
int x = 2;
fprintf(stderr, "[DEBUG] (id %i) SEND: (%x) %.2x ", wm->unid, buf[0], buf[1]);
#ifndef WIN32
for (; x < len+2; ++x)
#else
for (; x < len+1; ++x)
#endif
fprintf(stderr, "%.2x ", buf[x]);
fprintf(stderr, "\n");
fflush(stderr);
}
#endif
#ifndef WIN32
return wiiuse_io_write(wm, buf, len+2);
#else
return wiiuse_io_write(wm, buf, len+1);
#endif
}
/**
* @brief Set flags for the specified wiimote.
*
* @param wm Pointer to a wiimote_t structure.
* @param enable Flags to enable.
* @param disable Flags to disable.
*
* @return The flags set after 'enable' and 'disable' have been applied.
*
* The values 'enable' and 'disable' may be any flags OR'ed together.
* Flags are defined in wiiuse.h.
*/
int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable) {
if (!wm) return 0;
/* remove mutually exclusive flags */
enable &= ~disable;
disable &= ~enable;
wm->flags |= enable;
wm->flags &= ~disable;
return wm->flags;
}
/**
* @brief Set the wiimote smoothing alpha value.
*
* @param wm Pointer to a wiimote_t structure.
* @param alpha The alpha value to set. Between 0 and 1.
*
* @return Returns the old alpha value.
*
* The alpha value is between 0 and 1 and is used in an exponential
* smoothing algorithm.
*
* Smoothing is only performed if the WIIMOTE_USE_SMOOTHING is set.
*/
float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha) {
float old;
if (!wm) return 0.0f;
old = wm->accel_calib.st_alpha;
wm->accel_calib.st_alpha = alpha;
/* if there is a nunchuk set that too */
if (wm->exp.type == EXP_NUNCHUK)
wm->exp.nunchuk.accel_calib.st_alpha = alpha;
return old;
}
/**
* @brief Set the bluetooth stack type to use.
*
* @param wm Array of wiimote_t structures.
* @param wiimotes Number of objects in the wm array.
* @param type The type of bluetooth stack to use.
*/
void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type) {
#ifdef WIN32
int i;
if (!wm) return;
for (i = 0; i < wiimotes; ++i)
wm[i]->stack = type;
#endif
}
/**
* @brief Set the orientation event threshold.
*
* @param wm Pointer to a wiimote_t structure.
* @param threshold The decimal place that should be considered a significant change.
*
* If threshold is 0.01, and any angle changes by 0.01 then a significant change
* has occured and the event callback will be invoked. If threshold is 1 then
* the angle has to change by a full degree to generate an event.
*/
void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold) {
if (!wm) return;
wm->orient_threshold = threshold;
}
/**
* @brief Set the accelerometer event threshold.
*
* @param wm Pointer to a wiimote_t structure.
* @param threshold The decimal place that should be considered a significant change.
*/
void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold) {
if (!wm) return;
wm->accel_threshold = threshold;
}
/**
* @brief Try to resync with the wiimote by starting a new handshake.
*
* @param wm Pointer to a wiimote_t structure.
*/
void wiiuse_resync(struct wiimote_t* wm) {
if (!wm) return;
wm->handshake_state = 0;
wiiuse_handshake(wm, NULL, 0);
}
/**
* @brief Set the normal and expansion handshake timeouts.
*
* @param wm Array of wiimote_t structures.
* @param wiimotes Number of objects in the wm array.
* @param normal_timeout The timeout in milliseconds for a normal read.
* @param exp_timeout The timeout in millisecondsd to wait for an expansion handshake.
*/
void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout) {
#ifdef WIN32
int i;
if (!wm) return;
for (i = 0; i < wiimotes; ++i) {
wm[i]->normal_timeout = normal_timeout;
wm[i]->exp_timeout = exp_timeout;
}
#endif
}

View File

@@ -1,710 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
*
* @brief API header file.
*
* If this file is included from inside the wiiuse source
* and not from a third party program, then wiimote_internal.h
* is also included which extends this file.
*/
#ifndef WIIUSE_H_INCLUDED
#define WIIUSE_H_INCLUDED
#ifdef _WIN32
/* windows */
#include <windows.h>
#else
/* nix */
#include <bluetooth/bluetooth.h>
#endif
#ifdef WIIUSE_INTERNAL_H_INCLUDED
#define WCONST
#else
#define WCONST const
#endif
/* led bit masks */
#define WIIMOTE_LED_NONE 0x00
#define WIIMOTE_LED_1 0x10
#define WIIMOTE_LED_2 0x20
#define WIIMOTE_LED_3 0x40
#define WIIMOTE_LED_4 0x80
/* button codes */
#define WIIMOTE_BUTTON_TWO 0x0001
#define WIIMOTE_BUTTON_ONE 0x0002
#define WIIMOTE_BUTTON_B 0x0004
#define WIIMOTE_BUTTON_A 0x0008
#define WIIMOTE_BUTTON_MINUS 0x0010
#define WIIMOTE_BUTTON_ZACCEL_BIT6 0x0020
#define WIIMOTE_BUTTON_ZACCEL_BIT7 0x0040
#define WIIMOTE_BUTTON_HOME 0x0080
#define WIIMOTE_BUTTON_LEFT 0x0100
#define WIIMOTE_BUTTON_RIGHT 0x0200
#define WIIMOTE_BUTTON_DOWN 0x0400
#define WIIMOTE_BUTTON_UP 0x0800
#define WIIMOTE_BUTTON_PLUS 0x1000
#define WIIMOTE_BUTTON_ZACCEL_BIT4 0x2000
#define WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000
#define WIIMOTE_BUTTON_UNKNOWN 0x8000
#define WIIMOTE_BUTTON_ALL 0x1F9F
/* nunchul button codes */
#define NUNCHUK_BUTTON_Z 0x01
#define NUNCHUK_BUTTON_C 0x02
#define NUNCHUK_BUTTON_ALL 0x03
/* classic controller button codes */
#define CLASSIC_CTRL_BUTTON_UP 0x0001
#define CLASSIC_CTRL_BUTTON_LEFT 0x0002
#define CLASSIC_CTRL_BUTTON_ZR 0x0004
#define CLASSIC_CTRL_BUTTON_X 0x0008
#define CLASSIC_CTRL_BUTTON_A 0x0010
#define CLASSIC_CTRL_BUTTON_Y 0x0020
#define CLASSIC_CTRL_BUTTON_B 0x0040
#define CLASSIC_CTRL_BUTTON_ZL 0x0080
#define CLASSIC_CTRL_BUTTON_FULL_R 0x0200
#define CLASSIC_CTRL_BUTTON_PLUS 0x0400
#define CLASSIC_CTRL_BUTTON_HOME 0x0800
#define CLASSIC_CTRL_BUTTON_MINUS 0x1000
#define CLASSIC_CTRL_BUTTON_FULL_L 0x2000
#define CLASSIC_CTRL_BUTTON_DOWN 0x4000
#define CLASSIC_CTRL_BUTTON_RIGHT 0x8000
#define CLASSIC_CTRL_BUTTON_ALL 0xFEFF
/* guitar hero 3 button codes */
#define GUITAR_HERO_3_BUTTON_STRUM_UP 0x0001
#define GUITAR_HERO_3_BUTTON_YELLOW 0x0008
#define GUITAR_HERO_3_BUTTON_GREEN 0x0010
#define GUITAR_HERO_3_BUTTON_BLUE 0x0020
#define GUITAR_HERO_3_BUTTON_RED 0x0040
#define GUITAR_HERO_3_BUTTON_ORANGE 0x0080
#define GUITAR_HERO_3_BUTTON_PLUS 0x0400
#define GUITAR_HERO_3_BUTTON_MINUS 0x1000
#define GUITAR_HERO_3_BUTTON_STRUM_DOWN 0x4000
#define GUITAR_HERO_3_BUTTON_ALL 0xFEFF
/* wiimote option flags */
#define WIIUSE_SMOOTHING 0x01
#define WIIUSE_CONTINUOUS 0x02
#define WIIUSE_ORIENT_THRESH 0x04
#define WIIUSE_INIT_FLAGS (WIIUSE_SMOOTHING | WIIUSE_ORIENT_THRESH)
#define WIIUSE_ORIENT_PRECISION 100.0f
/* expansion codes */
#define EXP_NONE 0
#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 {
WIIUSE_IR_ABOVE,
WIIUSE_IR_BELOW
} ir_position_t;
/**
* @brief Check if a button is pressed.
* @param dev Pointer to a wiimote_t or expansion structure.
* @param button The button you are interested in.
* @return 1 if the button is pressed, 0 if not.
*/
#define IS_PRESSED(dev, button) ((dev->btns & button) == button)
/**
* @brief Check if a button is being held.
* @param dev Pointer to a wiimote_t or expansion structure.
* @param button The button you are interested in.
* @return 1 if the button is held, 0 if not.
*/
#define IS_HELD(dev, button) ((dev->btns_held & button) == button)
/**
* @brief Check if a button is released on this event. \n\n
* This does not mean the button is not pressed, it means \n
* this button was just now released.
* @param dev Pointer to a wiimote_t or expansion structure.
* @param button The button you are interested in.
* @return 1 if the button is released, 0 if not.
*
*/
#define IS_RELEASED(dev, button) ((dev->btns_released & button) == button)
/**
* @brief Check if a button has just been pressed this event.
* @param dev Pointer to a wiimote_t or expansion structure.
* @param button The button you are interested in.
* @return 1 if the button is pressed, 0 if not.
*/
#define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button))
/**
* @brief Return the IR sensitivity level.
* @param wm Pointer to a wiimote_t structure.
* @param lvl [out] Pointer to an int that will hold the level setting.
* If no level is set 'lvl' will be set to 0.
*/
#define WIIUSE_GET_IR_SENSITIVITY(dev, lvl) \
do { \
if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \
else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \
else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \
else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \
else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \
else *lvl = 0; \
} while (0)
#define WIIUSE_USING_ACC(wm) ((wm->state & 0x020) == 0x020)
#define WIIUSE_USING_EXP(wm) ((wm->state & 0x040) == 0x040)
#define WIIUSE_USING_IR(wm) ((wm->state & 0x080) == 0x080)
#define WIIUSE_USING_SPEAKER(wm) ((wm->state & 0x100) == 0x100)
#define WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num)
/*
* Largest known payload is 21 bytes.
* Add 2 for the prefix and round up to a power of 2.
*/
#define MAX_PAYLOAD 32
/*
* This is left over from an old hack, but it may actually
* be a useful feature to keep so it wasn't removed.
*/
#ifdef WIN32
#define WIIMOTE_DEFAULT_TIMEOUT 10
#define WIIMOTE_EXP_TIMEOUT 10
#endif
typedef unsigned char byte;
typedef char sbyte;
struct wiimote_t;
struct vec3b_t;
struct orient_t;
struct gforce_t;
/**
* @brief Callback that handles a read event.
*
* @param wm Pointer to a wiimote_t structure.
* @param data Pointer to the filled data block.
* @param len Length in bytes of the data block.
*
* @see wiiuse_init()
*
* A registered function of this type is called automatically by the wiiuse
* library when the wiimote has returned the full data requested by a previous
* call to wiiuse_read_data().
*/
typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short len);
/**
* @struct read_req_t
* @brief Data read request structure.
*/
struct read_req_t {
wiiuse_read_cb cb; /**< read data callback */
byte* buf; /**< buffer where read data is written */
unsigned int addr; /**< the offset that the read started at */
unsigned short size; /**< the length of the data read */
unsigned short wait; /**< num bytes still needed to finish read */
byte dirty; /**< set to 1 if not using callback and needs to be cleaned up */
struct read_req_t* next; /**< next read request in the queue */
};
/**
* @struct vec2b_t
* @brief Unsigned x,y byte vector.
*/
typedef struct vec2b_t {
byte x, y;
} vec2b_t;
/**
* @struct vec3b_t
* @brief Unsigned x,y,z byte vector.
*/
typedef struct vec3b_t {
byte x, y, z;
} vec3b_t;
/**
* @struct vec3f_t
* @brief Signed x,y,z float struct.
*/
typedef struct vec3f_t {
float x, y, z;
} vec3f_t;
/**
* @struct orient_t
* @brief Orientation struct.
*
* Yaw, pitch, and roll range from -180 to 180 degrees.
*/
typedef struct orient_t {
float roll; /**< roll, this may be smoothed if enabled */
float pitch; /**< pitch, this may be smoothed if enabled */
float yaw;
float a_roll; /**< absolute roll, unsmoothed */
float a_pitch; /**< absolute pitch, unsmoothed */
} orient_t;
/**
* @struct gforce_t
* @brief Gravity force struct.
*/
typedef struct gforce_t {
float x, y, z;
} gforce_t;
/**
* @struct accel_t
* @brief Accelerometer struct. For any device with an accelerometer.
*/
typedef struct accel_t {
struct vec3b_t cal_zero; /**< zero calibration */
struct vec3b_t cal_g; /**< 1g difference around 0cal */
float st_roll; /**< last smoothed roll value */
float st_pitch; /**< last smoothed roll pitch */
float st_alpha; /**< alpha value for smoothing [0-1] */
} accel_t;
/**
* @struct ir_dot_t
* @brief A single IR source.
*/
typedef struct ir_dot_t {
byte visible; /**< if the IR source is visible */
unsigned int x; /**< interpolated X coordinate */
unsigned int y; /**< interpolated Y coordinate */
short rx; /**< raw X coordinate (0-1023) */
short ry; /**< raw Y coordinate (0-767) */
byte order; /**< increasing order by x-axis value */
byte size; /**< size of the IR dot (0-15) */
} ir_dot_t;
/**
* @enum aspect_t
* @brief Screen aspect ratio.
*/
typedef enum aspect_t {
WIIUSE_ASPECT_4_3,
WIIUSE_ASPECT_16_9
} aspect_t;
/**
* @struct ir_t
* @brief IR struct. Hold all data related to the IR tracking.
*/
typedef struct ir_t {
struct ir_dot_t dot[4]; /**< IR dots */
byte num_dots; /**< number of dots at this time */
enum aspect_t aspect; /**< aspect ratio of the screen */
enum ir_position_t pos; /**< IR sensor bar position */
unsigned int vres[2]; /**< IR virtual screen resolution */
int offset[2]; /**< IR XY correction offset */
int state; /**< keeps track of the IR state */
int ax; /**< absolute X coordinate */
int ay; /**< absolute Y coordinate */
int x; /**< calculated X coordinate */
int y; /**< calculated Y coordinate */
float distance; /**< pixel distance between first 2 dots*/
float z; /**< calculated distance */
} 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.
*
* The angle \a ang is relative to the positive y-axis into quadrant I
* and ranges from 0 to 360 degrees. So if the joystick is held straight
* upwards then angle is 0 degrees. If it is held to the right it is 90,
* down is 180, and left is 270.
*
* The magnitude \a mag is the distance from the center to where the
* joystick is being held. The magnitude ranges from 0 to 1.
* If the joystick is only slightly tilted from the center the magnitude
* will be low, but if it is closer to the outter edge the value will
* be higher.
*/
typedef struct joystick_t {
struct vec2b_t max; /**< maximum joystick values */
struct vec2b_t min; /**< minimum joystick values */
struct vec2b_t center; /**< center joystick values */
float ang; /**< angle the joystick is being held */
float mag; /**< magnitude of the joystick (range 0-1) */
} joystick_t;
/**
* @struct nunchuk_t
* @brief Nunchuk expansion device.
*/
typedef struct nunchuk_t {
struct accel_t accel_calib; /**< nunchuk accelerometer calibration */
struct joystick_t js; /**< joystick calibration */
int* flags; /**< options flag (points to wiimote_t.flags) */
byte btns; /**< what buttons have just been pressed */
byte btns_held; /**< what buttons are being held down */
byte btns_released; /**< what buttons were just released this */
float orient_threshold; /**< threshold for orient to generate an event */
int accel_threshold; /**< threshold for accel to generate an event */
struct vec3b_t accel; /**< current raw acceleration data */
struct orient_t orient; /**< current orientation on each axis */
struct gforce_t gforce; /**< current gravity forces on each axis */
} nunchuk_t;
/**
* @struct classic_ctrl_t
* @brief Classic controller expansion device.
*/
typedef struct classic_ctrl_t {
short btns; /**< what buttons have just been pressed */
short btns_held; /**< what buttons are being held down */
short btns_released; /**< what buttons were just released this */
float r_shoulder; /**< right shoulder button (range 0-1) */
float l_shoulder; /**< left shoulder button (range 0-1) */
struct joystick_t ljs; /**< left joystick calibration */
struct joystick_t rjs; /**< right joystick calibration */
} classic_ctrl_t;
/**
* @struct guitar_hero_3_t
* @brief Guitar Hero 3 expansion device.
*/
typedef struct guitar_hero_3_t {
short btns; /**< what buttons have just been pressed */
short btns_held; /**< what buttons are being held down */
short btns_released; /**< what buttons were just released this */
float whammy_bar; /**< whammy bar (range 0-1) */
struct joystick_t js; /**< joystick calibration */
} 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.
*/
typedef struct expansion_t {
int type; /**< type of expansion attached */
union {
struct nunchuk_t nunchuk;
struct classic_ctrl_t classic;
struct guitar_hero_3_t gh3;
struct balance_board_t bb;
};
} expansion_t;
/**
* @enum win32_bt_stack_t
* @brief Available bluetooth stacks for Windows.
*/
typedef enum win_bt_stack_t {
WIIUSE_STACK_UNKNOWN,
WIIUSE_STACK_MS,
WIIUSE_STACK_BLUESOLEIL
} win_bt_stack_t;
/**
* @struct wiimote_state_t
* @brief Significant data from the previous event.
*/
typedef struct wiimote_state_t {
/* expansion_t */
float exp_ljs_ang;
float exp_rjs_ang;
float exp_ljs_mag;
float exp_rjs_mag;
unsigned short exp_btns;
struct orient_t exp_orient;
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;
int ir_ay;
float ir_distance;
struct orient_t orient;
unsigned short btns;
struct vec3b_t accel;
} wiimote_state_t;
/**
* @enum WIIUSE_EVENT_TYPE
* @brief Events that wiiuse can generate from a poll.
*/
typedef enum WIIUSE_EVENT_TYPE {
WIIUSE_NONE = 0,
WIIUSE_EVENT,
WIIUSE_STATUS,
WIIUSE_CONNECT,
WIIUSE_DISCONNECT,
WIIUSE_UNEXPECTED_DISCONNECT,
WIIUSE_READ_DATA,
WIIUSE_NUNCHUK_INSERTED,
WIIUSE_NUNCHUK_REMOVED,
WIIUSE_CLASSIC_CTRL_INSERTED,
WIIUSE_CLASSIC_CTRL_REMOVED,
WIIUSE_GUITAR_HERO_3_CTRL_INSERTED,
WIIUSE_GUITAR_HERO_3_CTRL_REMOVED,
WIIUSE_BALANCE_BOARD_CTRL_INSERTED,
WIIUSE_BALANCE_BOARD_CTRL_REMOVED
} WIIUSE_EVENT_TYPE;
/**
* @struct wiimote_t
* @brief Wiimote structure.
*/
typedef struct wiimote_t {
WCONST int unid; /**< user specified id */
#ifndef WIN32
WCONST bdaddr_t bdaddr; /**< bt address */
WCONST char bdaddr_str[18]; /**< readable bt address */
WCONST int out_sock; /**< output socket */
WCONST int in_sock; /**< input socket */
#else
WCONST HANDLE dev_handle; /**< HID handle */
WCONST OVERLAPPED hid_overlap; /**< overlap handle */
WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */
WCONST int timeout; /**< read timeout */
WCONST byte normal_timeout; /**< normal timeout */
WCONST byte exp_timeout; /**< timeout for expansion handshake */
#endif
WCONST int state; /**< various state flags */
WCONST byte leds; /**< currently lit leds */
WCONST float battery_level; /**< battery level */
WCONST int flags; /**< options flag */
WCONST byte handshake_state; /**< the state of the connection handshake */
WCONST struct read_req_t* read_req; /**< list of data read requests */
WCONST struct accel_t accel_calib; /**< wiimote accelerometer calibration */
WCONST struct expansion_t exp; /**< wiimote expansion device */
WCONST struct vec3b_t accel; /**< current raw acceleration data */
WCONST struct orient_t orient; /**< current orientation on each axis */
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 */
WCONST unsigned short btns_released; /**< what buttons were just released this */
WCONST float orient_threshold; /**< threshold for orient to generate an event */
WCONST int accel_threshold; /**< threshold for accel to generate an event */
WCONST struct wiimote_state_t lstate; /**< last saved state */
WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occured */
WCONST byte event_buf[MAX_PAYLOAD]; /**< event buffer */
} wiimote;
/*****************************************
*
* Include API specific stuff
*
*****************************************/
#ifdef _WIN32
#define WIIUSE_EXPORT_DECL __declspec(dllexport)
#define WIIUSE_IMPORT_DECL __declspec(dllimport)
#else
#define WIIUSE_EXPORT_DECL
#define WIIUSE_IMPORT_DECL
#endif
#ifdef WIIUSE_COMPILE_LIB
#define WIIUSE_EXPORT WIIUSE_EXPORT_DECL
#else
#define WIIUSE_EXPORT WIIUSE_IMPORT_DECL
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* wiiuse.c */
WIIUSE_EXPORT extern const char* wiiuse_version();
WIIUSE_EXPORT extern struct wiimote_t** wiiuse_init(int wiimotes);
WIIUSE_EXPORT extern void wiiuse_disconnected(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes);
WIIUSE_EXPORT extern void wiiuse_rumble(struct wiimote_t* wm, int status);
WIIUSE_EXPORT extern void wiiuse_toggle_rumble(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_set_leds(struct wiimote_t* wm, int leds);
WIIUSE_EXPORT extern void wiiuse_motion_sensing(struct wiimote_t* wm, int status);
WIIUSE_EXPORT extern int wiiuse_read_data(struct wiimote_t* wm, byte* buffer, unsigned int offset, unsigned short len);
WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len);
WIIUSE_EXPORT extern void wiiuse_status(struct wiimote_t* wm);
WIIUSE_EXPORT extern struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid);
WIIUSE_EXPORT extern int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable);
WIIUSE_EXPORT extern float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha);
WIIUSE_EXPORT extern void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type);
WIIUSE_EXPORT extern void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold);
WIIUSE_EXPORT extern void wiiuse_resync(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout);
WIIUSE_EXPORT extern void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold);
/* connect.c */
WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout);
WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes);
WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm);
/* events.c */
WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes);
/* ir.c */
WIIUSE_EXPORT extern void wiiuse_set_ir(struct wiimote_t* wm, int status);
WIIUSE_EXPORT extern void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y);
WIIUSE_EXPORT extern void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos);
WIIUSE_EXPORT extern void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect);
WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level);
/* nunchuk.c */
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
}
#endif
#endif /* WIIUSE_H_INCLUDED */

View File

@@ -1,229 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief General internal wiiuse stuff.
*
* Since Wiiuse is a library, wiiuse.h is a duplicate
* of the API header.
*
* The code that would normally go in that file, but
* which is not needed by third party developers,
* is put here.
*
* So wiiuse_internal.h is included by other files
* internally, wiiuse.h is included only here.
*/
#ifndef WIIUSE_INTERNAL_H_INCLUDED
#define WIIUSE_INTERNAL_H_INCLUDED
#ifndef WIN32
#include <arpa/inet.h> /* htons() */
#include <bluetooth/bluetooth.h>
#endif
#include "definitions.h"
/* wiiuse version */
#define WIIUSE_VERSION "0.12"
/********************
*
* Wiimote internal codes
*
********************/
/* Communication channels */
#define WM_OUTPUT_CHANNEL 0x11
#define WM_INPUT_CHANNEL 0x13
#define WM_SET_REPORT 0x50
/* commands */
#define WM_CMD_LED 0x11
#define WM_CMD_REPORT_TYPE 0x12
#define WM_CMD_RUMBLE 0x13
#define WM_CMD_IR 0x13
#define WM_CMD_CTRL_STATUS 0x15
#define WM_CMD_WRITE_DATA 0x16
#define WM_CMD_READ_DATA 0x17
#define WM_CMD_IR_2 0x1A
/* input report ids */
#define WM_RPT_CTRL_STATUS 0x20
#define WM_RPT_READ 0x21
#define WM_RPT_WRITE 0x22
#define WM_RPT_BTN 0x30
#define WM_RPT_BTN_ACC 0x31
#define WM_RPT_BTN_ACC_IR 0x33
#define WM_RPT_BTN_EXP 0x34
#define WM_RPT_BTN_ACC_EXP 0x35
#define WM_RPT_BTN_IR_EXP 0x36
#define WM_RPT_BTN_ACC_IR_EXP 0x37
#define WM_RPT_BALANCE_BOARD 0x40
#define WM_BT_INPUT 0x01
#define WM_BT_OUTPUT 0x02
/* Identify the wiimote device by its class */
#define WM_DEV_CLASS_0 0x04
#define WM_DEV_CLASS_1 0x25
#define WM_DEV_CLASS_2 0x00
#define WM_VENDOR_ID 0x057E
#define WM_PRODUCT_ID 0x0306
/* controller status stuff */
#define WM_MAX_BATTERY_CODE 0xC8
/* offsets in wiimote memory */
#define WM_MEM_OFFSET_CALIBRATION 0x16
#define WM_EXP_MEM_BASE 0x04A40000
#define WM_EXP_MEM_ENABLE1 0x04A400F0
#define WM_EXP_MEM_ENABLE2 0x04A400FB
#define WM_EXP_MEM_CALIBR 0x04A40020
#define WM_REG_IR 0x04B00030
#define WM_REG_IR_BLOCK1 0x04B00000
#define WM_REG_IR_BLOCK2 0x04B0001A
#define WM_REG_IR_MODENUM 0x04B00033
/* ir block data */
#define WM_IR_BLOCK1_LEVEL1 "\x02\x00\x00\x71\x01\x00\x64\x00\xfe"
#define WM_IR_BLOCK2_LEVEL1 "\xfd\x05"
#define WM_IR_BLOCK1_LEVEL2 "\x02\x00\x00\x71\x01\x00\x96\x00\xb4"
#define WM_IR_BLOCK2_LEVEL2 "\xb3\x04"
#define WM_IR_BLOCK1_LEVEL3 "\x02\x00\x00\x71\x01\x00\xaa\x00\x64"
#define WM_IR_BLOCK2_LEVEL3 "\x63\x03"
#define WM_IR_BLOCK1_LEVEL4 "\x02\x00\x00\x71\x01\x00\xc8\x00\x36"
#define WM_IR_BLOCK2_LEVEL4 "\x35\x03"
#define WM_IR_BLOCK1_LEVEL5 "\x07\x00\x00\x71\x01\x00\x72\x00\x20"
#define WM_IR_BLOCK2_LEVEL5 "\x1f\x03"
#define WM_IR_TYPE_BASIC 0x01
#define WM_IR_TYPE_EXTENDED 0x03
/* controller status flags for the first message byte */
/* bit 1 is unknown */
#define WM_CTRL_STATUS_BYTE1_ATTACHMENT 0x02
#define WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED 0x04
#define WM_CTRL_STATUS_BYTE1_IR_ENABLED 0x08
#define WM_CTRL_STATUS_BYTE1_LED_1 0x10
#define WM_CTRL_STATUS_BYTE1_LED_2 0x20
#define WM_CTRL_STATUS_BYTE1_LED_3 0x40
#define WM_CTRL_STATUS_BYTE1_LED_4 0x80
/* aspect ratio */
#define WM_ASPECT_16_9_X 660
#define WM_ASPECT_16_9_Y 370
#define WM_ASPECT_4_3_X 560
#define WM_ASPECT_4_3_Y 420
/**
* Expansion stuff
*/
/* encrypted expansion id codes (located at 0x04A400FC) */
#define EXP_ID_CODE_NUNCHUK 0xA4200000
#define EXP_ID_CODE_CLASSIC_CONTROLLER 0xA4200101
#define EXP_ID_CODE_GUITAR 0xA4200103
#define EXP_ID_CODE_BALANCE_BOARD 0xA4200402
#define EXP_HANDSHAKE_LEN 224
/********************
*
* End Wiimote internal codes
*
********************/
/* wiimote state flags - (some duplicated in wiiuse.h)*/
#define WIIMOTE_STATE_DEV_FOUND 0x0001
#define WIIMOTE_STATE_HANDSHAKE 0x0002 /* actual connection exists but no handshake yet */
#define WIIMOTE_STATE_HANDSHAKE_COMPLETE 0x0004 /* actual connection exists but no handshake yet */
#define WIIMOTE_STATE_CONNECTED 0x0008
#define WIIMOTE_STATE_RUMBLE 0x0010
#define WIIMOTE_STATE_ACC 0x0020
#define WIIMOTE_STATE_EXP 0x0040
#define WIIMOTE_STATE_IR 0x0080
#define WIIMOTE_STATE_SPEAKER 0x0100
#define WIIMOTE_STATE_IR_SENS_LVL1 0x0200
#define WIIMOTE_STATE_IR_SENS_LVL2 0x0400
#define WIIMOTE_STATE_IR_SENS_LVL3 0x0800
#define WIIMOTE_STATE_IR_SENS_LVL4 0x1000
#define WIIMOTE_STATE_IR_SENS_LVL5 0x2000
#define WIIMOTE_INIT_STATES (WIIMOTE_STATE_IR_SENS_LVL3)
/* macro to manage states */
#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s))
#define WIIMOTE_ENABLE_STATE(wm, s) (wm->state |= (s))
#define WIIMOTE_DISABLE_STATE(wm, s) (wm->state &= ~(s))
#define WIIMOTE_TOGGLE_STATE(wm, s) ((wm->state & (s)) ? WIIMOTE_DISABLE_STATE(wm, s) : WIIMOTE_ENABLE_STATE(wm, s))
#define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s))
#define WIIMOTE_ENABLE_FLAG(wm, s) (wm->flags |= (s))
#define WIIMOTE_DISABLE_FLAG(wm, s) (wm->flags &= ~(s))
#define WIIMOTE_TOGGLE_FLAG(wm, s) ((wm->flags & (s)) ? WIIMOTE_DISABLE_FLAG(wm, s) : WIIMOTE_ENABLE_FLAG(wm, s))
#define NUNCHUK_IS_FLAG_SET(wm, s) ((*(wm->flags) & (s)) == (s))
/* misc macros */
#define WIIMOTE_ID(wm) (wm->unid)
#define WIIMOTE_IS_CONNECTED(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
/*
* Smooth tilt calculations are computed with the
* exponential moving average formula:
* St = St_last + (alpha * (tilt - St_last))
* alpha is between 0 and 1
*/
#define WIIUSE_DEFAULT_SMOOTH_ALPHA 0.07f
#define SMOOTH_ROLL 0x01
#define SMOOTH_PITCH 0x02
#include "wiiuse.h"
#ifdef __cplusplus
extern "C" {
#endif
/* not part of the api */
int wiiuse_set_report_type(struct wiimote_t* wm);
void wiiuse_send_next_pending_read_request(struct wiimote_t* wm);
int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len);
int wiiuse_read_data_cb(struct wiimote_t* wm, wiiuse_read_cb read_cb, byte* buffer, unsigned int offset, unsigned short len);
#ifdef __cplusplus
}
#endif
#endif /* WIIUSE_INTERNAL_H_INCLUDED */

View File

@@ -1,177 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.debug.1025362616">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.debug.1025362616" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<macros>
<stringMacro name="target" type="VALUE_TEXT" value="wiiusej"/>
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.7.0"/>
</macros>
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/WiiuseJ"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/WiiuseJ/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="wiiusej" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.debug.1025362616" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.so.debug" postbuildStep="./copy.bat">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.so.debug.1025362616." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.debug.1191523047" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.debug.306321031" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.debug"/>
<builder buildPath="${workspace_loc:/WiiuseJ/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.531289265" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool command="as" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug.781950854" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.676801089" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1717798063" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.721099204" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug">
<option id="gnu.cpp.compiler.mingw.so.debug.option.optimization.level.1512062314" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.so.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.so.debug.option.debugging.level.1185068058" name="Debug Level" superClass="gnu.cpp.compiler.mingw.so.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.716839450" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${jdk}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${jdk}/include/win32&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.842669563" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.1784371330" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.so.debug.option.optimization.level.2033163253" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.so.debug.option.debugging.level.478300262" name="Debug Level" superClass="gnu.c.compiler.mingw.so.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.486668115" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${jdk}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${jdk}/include/win32&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
</option>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1057877516" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.820612620" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.424942675" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug">
<option defaultValue="true" id="gnu.c.link.mingw.so.debug.option.shared.450186350" name="Shared (-shared)" superClass="gnu.c.link.mingw.so.debug.option.shared" valueType="boolean"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.748142627" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug">
<option defaultValue="true" id="gnu.cpp.link.mingw.so.debug.option.shared.507004830" name="Shared (-shared)" superClass="gnu.cpp.link.mingw.so.debug.option.shared" valueType="boolean"/>
<option id="gnu.cpp.link.option.paths.45705116" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
</option>
<option id="gnu.cpp.link.option.libs.102697521" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="wiiuse"/>
</option>
<option id="gnu.cpp.link.option.flags.2098946116" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="-Wl,-add-stdcall-alias -static-libgcc -static-libstdc++" valueType="string"/>
<option id="gnu.cpp.link.option.strip.193866268" name="Omit all symbol information (-s)" superClass="gnu.cpp.link.option.strip" value="false" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1307869739" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
<outputType id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.output.1609835672" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.output"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.release.872708280">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.release.872708280" moduleId="org.eclipse.cdt.core.settings" name="Release">
<macros>
<stringMacro name="target" type="VALUE_TEXT" value="wiiusej"/>
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.7.0"/>
</macros>
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/WiiuseJ"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/WiiuseJ/Release"/>
<entry flags="RESOLVED" kind="libraryFile" name="wiiusej" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.release.872708280" name="Release" parent="cdt.managedbuild.config.gnu.mingw.so.release" postbuildStep="./copy.bat">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.so.release.872708280." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.release.582624041" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.release.852849225" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.release"/>
<builder buildPath="${workspace_loc:/WiiuseJ/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1667515887" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool command="as" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.assembler.mingw.so.release.1955417593" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.204782274" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.2134712739" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release.1470980799" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release">
<option id="gnu.cpp.compiler.mingw.so.release.option.optimization.level.1203189311" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.so.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.so.release.option.debugging.level.1388109930" name="Debug Level" superClass="gnu.cpp.compiler.mingw.so.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.1188267253" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${jdk}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${jdk}/include/win32&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1449486447" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.1707196863" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.so.release.option.optimization.level.899996696" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.so.release.option.debugging.level.1336215997" name="Debug Level" superClass="gnu.c.compiler.mingw.so.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.13176781" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${jdk}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${jdk}/include/win32&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
</option>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.227749697" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.839631863" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release.901924366" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release">
<option defaultValue="true" id="gnu.c.link.mingw.so.release.option.shared.1261255803" name="Shared (-shared)" superClass="gnu.c.link.mingw.so.release.option.shared" valueType="boolean"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.649216061" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release">
<option defaultValue="true" id="gnu.cpp.link.mingw.so.release.option.shared.401829660" name="Shared (-shared)" superClass="gnu.cpp.link.mingw.so.release.option.shared" valueType="boolean"/>
<option id="gnu.cpp.link.option.paths.1462133636" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
</option>
<option id="gnu.cpp.link.option.libs.173366246" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="wiiuse"/>
</option>
<option id="gnu.cpp.link.option.flags.1334245987" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="-Wl,-add-stdcall-alias -static-libgcc -static-libstdc++" valueType="string"/>
<option id="gnu.cpp.link.option.strip.611886908" name="Omit all symbol information (-s)" superClass="gnu.cpp.link.option.strip" value="false" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.790138545" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
<outputType id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.output.543131979" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.output"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="WiiuseJ.cdt.managedbuild.target.gnu.mingw.so.885833889" name="Shared Library" projectType="cdt.managedbuild.target.gnu.mingw.so"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.debug.1025362616;cdt.managedbuild.config.gnu.mingw.so.debug.1025362616.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.1784371330;cdt.managedbuild.tool.gnu.c.compiler.input.820612620">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.release.872708280;cdt.managedbuild.config.gnu.mingw.so.release.872708280.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release.1470980799;cdt.managedbuild.tool.gnu.cpp.compiler.input.1449486447">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.debug.1025362616;cdt.managedbuild.config.gnu.mingw.so.debug.1025362616.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.721099204;cdt.managedbuild.tool.gnu.cpp.compiler.input.842669563">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.release.872708280;cdt.managedbuild.config.gnu.mingw.so.release.872708280.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.1707196863;cdt.managedbuild.tool.gnu.c.compiler.input.839631863">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>

View File

@@ -1,71 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cpp.wiiusej</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/WiiuseJ/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
</natures>
</projectDescription>

View File

@@ -1 +0,0 @@
copy wiiusej.dll ..\..\..\java\wiiusej\wiiusej.dll

View File

@@ -1 +0,0 @@
copy wiiusej.dll ..\..\..\java\wiiusej\wiiusej.dll

Binary file not shown.

View File

@@ -1,710 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* 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 <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
*
* @brief API header file.
*
* If this file is included from inside the wiiuse source
* and not from a third party program, then wiimote_internal.h
* is also included which extends this file.
*/
#ifndef WIIUSE_H_INCLUDED
#define WIIUSE_H_INCLUDED
#ifdef _WIN32
/* windows */
#include <windows.h>
#else
/* nix */
#include <bluetooth/bluetooth.h>
#endif
#ifdef WIIUSE_INTERNAL_H_INCLUDED
#define WCONST
#else
#define WCONST const
#endif
/* led bit masks */
#define WIIMOTE_LED_NONE 0x00
#define WIIMOTE_LED_1 0x10
#define WIIMOTE_LED_2 0x20
#define WIIMOTE_LED_3 0x40
#define WIIMOTE_LED_4 0x80
/* button codes */
#define WIIMOTE_BUTTON_TWO 0x0001
#define WIIMOTE_BUTTON_ONE 0x0002
#define WIIMOTE_BUTTON_B 0x0004
#define WIIMOTE_BUTTON_A 0x0008
#define WIIMOTE_BUTTON_MINUS 0x0010
#define WIIMOTE_BUTTON_ZACCEL_BIT6 0x0020
#define WIIMOTE_BUTTON_ZACCEL_BIT7 0x0040
#define WIIMOTE_BUTTON_HOME 0x0080
#define WIIMOTE_BUTTON_LEFT 0x0100
#define WIIMOTE_BUTTON_RIGHT 0x0200
#define WIIMOTE_BUTTON_DOWN 0x0400
#define WIIMOTE_BUTTON_UP 0x0800
#define WIIMOTE_BUTTON_PLUS 0x1000
#define WIIMOTE_BUTTON_ZACCEL_BIT4 0x2000
#define WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000
#define WIIMOTE_BUTTON_UNKNOWN 0x8000
#define WIIMOTE_BUTTON_ALL 0x1F9F
/* nunchul button codes */
#define NUNCHUK_BUTTON_Z 0x01
#define NUNCHUK_BUTTON_C 0x02
#define NUNCHUK_BUTTON_ALL 0x03
/* classic controller button codes */
#define CLASSIC_CTRL_BUTTON_UP 0x0001
#define CLASSIC_CTRL_BUTTON_LEFT 0x0002
#define CLASSIC_CTRL_BUTTON_ZR 0x0004
#define CLASSIC_CTRL_BUTTON_X 0x0008
#define CLASSIC_CTRL_BUTTON_A 0x0010
#define CLASSIC_CTRL_BUTTON_Y 0x0020
#define CLASSIC_CTRL_BUTTON_B 0x0040
#define CLASSIC_CTRL_BUTTON_ZL 0x0080
#define CLASSIC_CTRL_BUTTON_FULL_R 0x0200
#define CLASSIC_CTRL_BUTTON_PLUS 0x0400
#define CLASSIC_CTRL_BUTTON_HOME 0x0800
#define CLASSIC_CTRL_BUTTON_MINUS 0x1000
#define CLASSIC_CTRL_BUTTON_FULL_L 0x2000
#define CLASSIC_CTRL_BUTTON_DOWN 0x4000
#define CLASSIC_CTRL_BUTTON_RIGHT 0x8000
#define CLASSIC_CTRL_BUTTON_ALL 0xFEFF
/* guitar hero 3 button codes */
#define GUITAR_HERO_3_BUTTON_STRUM_UP 0x0001
#define GUITAR_HERO_3_BUTTON_YELLOW 0x0008
#define GUITAR_HERO_3_BUTTON_GREEN 0x0010
#define GUITAR_HERO_3_BUTTON_BLUE 0x0020
#define GUITAR_HERO_3_BUTTON_RED 0x0040
#define GUITAR_HERO_3_BUTTON_ORANGE 0x0080
#define GUITAR_HERO_3_BUTTON_PLUS 0x0400
#define GUITAR_HERO_3_BUTTON_MINUS 0x1000
#define GUITAR_HERO_3_BUTTON_STRUM_DOWN 0x4000
#define GUITAR_HERO_3_BUTTON_ALL 0xFEFF
/* wiimote option flags */
#define WIIUSE_SMOOTHING 0x01
#define WIIUSE_CONTINUOUS 0x02
#define WIIUSE_ORIENT_THRESH 0x04
#define WIIUSE_INIT_FLAGS (WIIUSE_SMOOTHING | WIIUSE_ORIENT_THRESH)
#define WIIUSE_ORIENT_PRECISION 100.0f
/* expansion codes */
#define EXP_NONE 0
#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 {
WIIUSE_IR_ABOVE,
WIIUSE_IR_BELOW
} ir_position_t;
/**
* @brief Check if a button is pressed.
* @param dev Pointer to a wiimote_t or expansion structure.
* @param button The button you are interested in.
* @return 1 if the button is pressed, 0 if not.
*/
#define IS_PRESSED(dev, button) ((dev->btns & button) == button)
/**
* @brief Check if a button is being held.
* @param dev Pointer to a wiimote_t or expansion structure.
* @param button The button you are interested in.
* @return 1 if the button is held, 0 if not.
*/
#define IS_HELD(dev, button) ((dev->btns_held & button) == button)
/**
* @brief Check if a button is released on this event. \n\n
* This does not mean the button is not pressed, it means \n
* this button was just now released.
* @param dev Pointer to a wiimote_t or expansion structure.
* @param button The button you are interested in.
* @return 1 if the button is released, 0 if not.
*
*/
#define IS_RELEASED(dev, button) ((dev->btns_released & button) == button)
/**
* @brief Check if a button has just been pressed this event.
* @param dev Pointer to a wiimote_t or expansion structure.
* @param button The button you are interested in.
* @return 1 if the button is pressed, 0 if not.
*/
#define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button))
/**
* @brief Return the IR sensitivity level.
* @param wm Pointer to a wiimote_t structure.
* @param lvl [out] Pointer to an int that will hold the level setting.
* If no level is set 'lvl' will be set to 0.
*/
#define WIIUSE_GET_IR_SENSITIVITY(dev, lvl) \
do { \
if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \
else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \
else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \
else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \
else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \
else *lvl = 0; \
} while (0)
#define WIIUSE_USING_ACC(wm) ((wm->state & 0x020) == 0x020)
#define WIIUSE_USING_EXP(wm) ((wm->state & 0x040) == 0x040)
#define WIIUSE_USING_IR(wm) ((wm->state & 0x080) == 0x080)
#define WIIUSE_USING_SPEAKER(wm) ((wm->state & 0x100) == 0x100)
#define WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num)
/*
* Largest known payload is 21 bytes.
* Add 2 for the prefix and round up to a power of 2.
*/
#define MAX_PAYLOAD 32
/*
* This is left over from an old hack, but it may actually
* be a useful feature to keep so it wasn't removed.
*/
#ifdef WIN32
#define WIIMOTE_DEFAULT_TIMEOUT 10
#define WIIMOTE_EXP_TIMEOUT 10
#endif
typedef unsigned char byte;
typedef char sbyte;
struct wiimote_t;
struct vec3b_t;
struct orient_t;
struct gforce_t;
/**
* @brief Callback that handles a read event.
*
* @param wm Pointer to a wiimote_t structure.
* @param data Pointer to the filled data block.
* @param len Length in bytes of the data block.
*
* @see wiiuse_init()
*
* A registered function of this type is called automatically by the wiiuse
* library when the wiimote has returned the full data requested by a previous
* call to wiiuse_read_data().
*/
typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short len);
/**
* @struct read_req_t
* @brief Data read request structure.
*/
struct read_req_t {
wiiuse_read_cb cb; /**< read data callback */
byte* buf; /**< buffer where read data is written */
unsigned int addr; /**< the offset that the read started at */
unsigned short size; /**< the length of the data read */
unsigned short wait; /**< num bytes still needed to finish read */
byte dirty; /**< set to 1 if not using callback and needs to be cleaned up */
struct read_req_t* next; /**< next read request in the queue */
};
/**
* @struct vec2b_t
* @brief Unsigned x,y byte vector.
*/
typedef struct vec2b_t {
byte x, y;
} vec2b_t;
/**
* @struct vec3b_t
* @brief Unsigned x,y,z byte vector.
*/
typedef struct vec3b_t {
byte x, y, z;
} vec3b_t;
/**
* @struct vec3f_t
* @brief Signed x,y,z float struct.
*/
typedef struct vec3f_t {
float x, y, z;
} vec3f_t;
/**
* @struct orient_t
* @brief Orientation struct.
*
* Yaw, pitch, and roll range from -180 to 180 degrees.
*/
typedef struct orient_t {
float roll; /**< roll, this may be smoothed if enabled */
float pitch; /**< pitch, this may be smoothed if enabled */
float yaw;
float a_roll; /**< absolute roll, unsmoothed */
float a_pitch; /**< absolute pitch, unsmoothed */
} orient_t;
/**
* @struct gforce_t
* @brief Gravity force struct.
*/
typedef struct gforce_t {
float x, y, z;
} gforce_t;
/**
* @struct accel_t
* @brief Accelerometer struct. For any device with an accelerometer.
*/
typedef struct accel_t {
struct vec3b_t cal_zero; /**< zero calibration */
struct vec3b_t cal_g; /**< 1g difference around 0cal */
float st_roll; /**< last smoothed roll value */
float st_pitch; /**< last smoothed roll pitch */
float st_alpha; /**< alpha value for smoothing [0-1] */
} accel_t;
/**
* @struct ir_dot_t
* @brief A single IR source.
*/
typedef struct ir_dot_t {
byte visible; /**< if the IR source is visible */
unsigned int x; /**< interpolated X coordinate */
unsigned int y; /**< interpolated Y coordinate */
short rx; /**< raw X coordinate (0-1023) */
short ry; /**< raw Y coordinate (0-767) */
byte order; /**< increasing order by x-axis value */
byte size; /**< size of the IR dot (0-15) */
} ir_dot_t;
/**
* @enum aspect_t
* @brief Screen aspect ratio.
*/
typedef enum aspect_t {
WIIUSE_ASPECT_4_3,
WIIUSE_ASPECT_16_9
} aspect_t;
/**
* @struct ir_t
* @brief IR struct. Hold all data related to the IR tracking.
*/
typedef struct ir_t {
struct ir_dot_t dot[4]; /**< IR dots */
byte num_dots; /**< number of dots at this time */
enum aspect_t aspect; /**< aspect ratio of the screen */
enum ir_position_t pos; /**< IR sensor bar position */
unsigned int vres[2]; /**< IR virtual screen resolution */
int offset[2]; /**< IR XY correction offset */
int state; /**< keeps track of the IR state */
int ax; /**< absolute X coordinate */
int ay; /**< absolute Y coordinate */
int x; /**< calculated X coordinate */
int y; /**< calculated Y coordinate */
float distance; /**< pixel distance between first 2 dots*/
float z; /**< calculated distance */
} 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.
*
* The angle \a ang is relative to the positive y-axis into quadrant I
* and ranges from 0 to 360 degrees. So if the joystick is held straight
* upwards then angle is 0 degrees. If it is held to the right it is 90,
* down is 180, and left is 270.
*
* The magnitude \a mag is the distance from the center to where the
* joystick is being held. The magnitude ranges from 0 to 1.
* If the joystick is only slightly tilted from the center the magnitude
* will be low, but if it is closer to the outter edge the value will
* be higher.
*/
typedef struct joystick_t {
struct vec2b_t max; /**< maximum joystick values */
struct vec2b_t min; /**< minimum joystick values */
struct vec2b_t center; /**< center joystick values */
float ang; /**< angle the joystick is being held */
float mag; /**< magnitude of the joystick (range 0-1) */
} joystick_t;
/**
* @struct nunchuk_t
* @brief Nunchuk expansion device.
*/
typedef struct nunchuk_t {
struct accel_t accel_calib; /**< nunchuk accelerometer calibration */
struct joystick_t js; /**< joystick calibration */
int* flags; /**< options flag (points to wiimote_t.flags) */
byte btns; /**< what buttons have just been pressed */
byte btns_held; /**< what buttons are being held down */
byte btns_released; /**< what buttons were just released this */
float orient_threshold; /**< threshold for orient to generate an event */
int accel_threshold; /**< threshold for accel to generate an event */
struct vec3b_t accel; /**< current raw acceleration data */
struct orient_t orient; /**< current orientation on each axis */
struct gforce_t gforce; /**< current gravity forces on each axis */
} nunchuk_t;
/**
* @struct classic_ctrl_t
* @brief Classic controller expansion device.
*/
typedef struct classic_ctrl_t {
short btns; /**< what buttons have just been pressed */
short btns_held; /**< what buttons are being held down */
short btns_released; /**< what buttons were just released this */
float r_shoulder; /**< right shoulder button (range 0-1) */
float l_shoulder; /**< left shoulder button (range 0-1) */
struct joystick_t ljs; /**< left joystick calibration */
struct joystick_t rjs; /**< right joystick calibration */
} classic_ctrl_t;
/**
* @struct guitar_hero_3_t
* @brief Guitar Hero 3 expansion device.
*/
typedef struct guitar_hero_3_t {
short btns; /**< what buttons have just been pressed */
short btns_held; /**< what buttons are being held down */
short btns_released; /**< what buttons were just released this */
float whammy_bar; /**< whammy bar (range 0-1) */
struct joystick_t js; /**< joystick calibration */
} 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.
*/
typedef struct expansion_t {
int type; /**< type of expansion attached */
union {
struct nunchuk_t nunchuk;
struct classic_ctrl_t classic;
struct guitar_hero_3_t gh3;
struct balance_board_t bb;
};
} expansion_t;
/**
* @enum win32_bt_stack_t
* @brief Available bluetooth stacks for Windows.
*/
typedef enum win_bt_stack_t {
WIIUSE_STACK_UNKNOWN,
WIIUSE_STACK_MS,
WIIUSE_STACK_BLUESOLEIL
} win_bt_stack_t;
/**
* @struct wiimote_state_t
* @brief Significant data from the previous event.
*/
typedef struct wiimote_state_t {
/* expansion_t */
float exp_ljs_ang;
float exp_rjs_ang;
float exp_ljs_mag;
float exp_rjs_mag;
unsigned short exp_btns;
struct orient_t exp_orient;
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;
int ir_ay;
float ir_distance;
struct orient_t orient;
unsigned short btns;
struct vec3b_t accel;
} wiimote_state_t;
/**
* @enum WIIUSE_EVENT_TYPE
* @brief Events that wiiuse can generate from a poll.
*/
typedef enum WIIUSE_EVENT_TYPE {
WIIUSE_NONE = 0,
WIIUSE_EVENT,
WIIUSE_STATUS,
WIIUSE_CONNECT,
WIIUSE_DISCONNECT,
WIIUSE_UNEXPECTED_DISCONNECT,
WIIUSE_READ_DATA,
WIIUSE_NUNCHUK_INSERTED,
WIIUSE_NUNCHUK_REMOVED,
WIIUSE_CLASSIC_CTRL_INSERTED,
WIIUSE_CLASSIC_CTRL_REMOVED,
WIIUSE_GUITAR_HERO_3_CTRL_INSERTED,
WIIUSE_GUITAR_HERO_3_CTRL_REMOVED,
WIIUSE_BALANCE_BOARD_CTRL_INSERTED,
WIIUSE_BALANCE_BOARD_CTRL_REMOVED
} WIIUSE_EVENT_TYPE;
/**
* @struct wiimote_t
* @brief Wiimote structure.
*/
typedef struct wiimote_t {
WCONST int unid; /**< user specified id */
#ifndef WIN32
WCONST bdaddr_t bdaddr; /**< bt address */
WCONST char bdaddr_str[18]; /**< readable bt address */
WCONST int out_sock; /**< output socket */
WCONST int in_sock; /**< input socket */
#else
WCONST HANDLE dev_handle; /**< HID handle */
WCONST OVERLAPPED hid_overlap; /**< overlap handle */
WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */
WCONST int timeout; /**< read timeout */
WCONST byte normal_timeout; /**< normal timeout */
WCONST byte exp_timeout; /**< timeout for expansion handshake */
#endif
WCONST int state; /**< various state flags */
WCONST byte leds; /**< currently lit leds */
WCONST float battery_level; /**< battery level */
WCONST int flags; /**< options flag */
WCONST byte handshake_state; /**< the state of the connection handshake */
WCONST struct read_req_t* read_req; /**< list of data read requests */
WCONST struct accel_t accel_calib; /**< wiimote accelerometer calibration */
WCONST struct expansion_t exp; /**< wiimote expansion device */
WCONST struct vec3b_t accel; /**< current raw acceleration data */
WCONST struct orient_t orient; /**< current orientation on each axis */
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 */
WCONST unsigned short btns_released; /**< what buttons were just released this */
WCONST float orient_threshold; /**< threshold for orient to generate an event */
WCONST int accel_threshold; /**< threshold for accel to generate an event */
WCONST struct wiimote_state_t lstate; /**< last saved state */
WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occured */
WCONST byte event_buf[MAX_PAYLOAD]; /**< event buffer */
} wiimote;
/*****************************************
*
* Include API specific stuff
*
*****************************************/
#ifdef _WIN32
#define WIIUSE_EXPORT_DECL __declspec(dllexport)
#define WIIUSE_IMPORT_DECL __declspec(dllimport)
#else
#define WIIUSE_EXPORT_DECL
#define WIIUSE_IMPORT_DECL
#endif
#ifdef WIIUSE_COMPILE_LIB
#define WIIUSE_EXPORT WIIUSE_EXPORT_DECL
#else
#define WIIUSE_EXPORT WIIUSE_IMPORT_DECL
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* wiiuse.c */
WIIUSE_EXPORT extern const char* wiiuse_version();
WIIUSE_EXPORT extern struct wiimote_t** wiiuse_init(int wiimotes);
WIIUSE_EXPORT extern void wiiuse_disconnected(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes);
WIIUSE_EXPORT extern void wiiuse_rumble(struct wiimote_t* wm, int status);
WIIUSE_EXPORT extern void wiiuse_toggle_rumble(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_set_leds(struct wiimote_t* wm, int leds);
WIIUSE_EXPORT extern void wiiuse_motion_sensing(struct wiimote_t* wm, int status);
WIIUSE_EXPORT extern int wiiuse_read_data(struct wiimote_t* wm, byte* buffer, unsigned int offset, unsigned short len);
WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len);
WIIUSE_EXPORT extern void wiiuse_status(struct wiimote_t* wm);
WIIUSE_EXPORT extern struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid);
WIIUSE_EXPORT extern int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable);
WIIUSE_EXPORT extern float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha);
WIIUSE_EXPORT extern void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type);
WIIUSE_EXPORT extern void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold);
WIIUSE_EXPORT extern void wiiuse_resync(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout);
WIIUSE_EXPORT extern void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold);
/* connect.c */
WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout);
WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes);
WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm);
/* events.c */
WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes);
/* ir.c */
WIIUSE_EXPORT extern void wiiuse_set_ir(struct wiimote_t* wm, int status);
WIIUSE_EXPORT extern void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y);
WIIUSE_EXPORT extern void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos);
WIIUSE_EXPORT extern void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect);
WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level);
/* nunchuk.c */
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
}
#endif
#endif /* WIIUSE_H_INCLUDED */

Binary file not shown.

View File

@@ -1,768 +0,0 @@
/**
* This file is part of WiiuseJ.
*
* WiiuseJ 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.
*
* WiiuseJ 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 WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WIN32
#include <unistd.h>
#endif
#include "wiiusej_WiiUseApi.h"
#include "wiiuse.h"
/*
* These are some identifiers for wiimotes
*
* See below in main() for what they are used for.
*/
#define WIIMOTE_STATE_RUMBLE 0x0010
#define WIIMOTE_STATE_CONNECTED 0x0008
#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s))
#define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s))
#define WIIUSE_GET_IR_SENSITIVITY_CORRECTED(wm, lvl) \
do { \
if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \
else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \
else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \
else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \
else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \
else *lvl = 0; \
} while (0)
/********************* VARIABLES DECLARATIONS *****************************/
/*
* Make a temp array of wiimote ids.
* Here I only anticipate connecting up to
* two wiimotes. Each wiimote connected
* will get one of these ids.
*/
static wiimote** wiimotes;
static int nbMaxWiimotes;
/****************** GENERAL FUNCTIONS DEFINITIONS *************************/
/**
* Connect to a wiimote or wiimotes once an address is known.
* @param nbWiimotes The number of wiimotes.
* @return The number of wiimotes that successfully connected.
*/
JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_connect
(JNIEnv *env, jobject obj, jint nbWiimotes) {
return wiiuse_connect(wiimotes, nbWiimotes);
}
/**
* Find a wiimote or wiimotes.
* @param nbMaxWiimotes The number of wiimotes.
* @param timeout The number of seconds before the search times out.
* @return The number of wiimotes found.
*/
JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_find
(JNIEnv *env, jobject obj, jint nbMaxWiimotes, jint timeout) {
return wiiuse_find(wiimotes, nbMaxWiimotes, timeout);
}
/**
* Initialize an array of wiimote structures (for the C side of the library).
* @param nbPossibleWiimotes size of the array.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_init
(JNIEnv *env, jobject obj, jint nbPossibleWiimotes) {
wiimotes = wiiuse_init(nbPossibleWiimotes);
nbMaxWiimotes = nbPossibleWiimotes;
}
/**
* Close connection to the wiimote with the given id.
*
* @param id the id of the wiimote to disconnect.Must be 1 or 2.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection
(JNIEnv *env, jobject obj, jint id) {
wiiuse_disconnect(wiimotes[id]);
}
/**
* Get unique id of a wiimote in the wiimotes array.
* Please make sure you call an existing index with a
* wiimote initialized at this index,
* other wise you'll get a wrong value.
* @param index index of the wiimote in the wiimotes array.
*/
JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_getUnId
(JNIEnv *env, jobject obj, jint index) {
return wiimotes[index]->unid;
}
/**
* Shutdown api.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_cleanUp
(JNIEnv *env, jobject obj) {
wiiuse_cleanup(wiimotes, nbMaxWiimotes);
}
/**
* Activate rumble for the wiimote with the given id.
* @param id the id of the wiimote.Must be 1 or 2.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble
(JNIEnv *env, jobject obj, jint id) {
wiiuse_rumble(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1);
}
/**
* Deactivate rumble for the wiimote with the given id.
* @param id the id of the wiimote.Must be 1 or 2.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble
(JNIEnv *env, jobject obj, jint id) {
wiiuse_rumble(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0);
}
/**
* Activate IR TRacking for the wiimote with the given id.
* @param id the id of the wiimote.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_ir(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1);
}
/**
* Deactivate IR TRacking for the wiimote with the given id.
* @param id the id of the wiimote.Must be 1 or 2.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_ir(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0);
}
/**
* Activate Motion Sensing for the wiimote with the given id.
* @param id the id of the wiimote.Must be 1 or 2.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing
(JNIEnv *env, jobject obj, jint id) {
wiiuse_motion_sensing(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1);
}
/**
* Deactivate Motion Sensing for the wiimote with the given id.
* @param id the id of the wiimote.Must be 1 or 2.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing
(JNIEnv *env, jobject obj, jint id) {
wiiuse_motion_sensing(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0);
}
/**
* Set wiimote leds status.
* @param id the id of the wiimote concerned
* @param led1 status of led1: True=ON, False=OFF
* @param led2 status of led2: True=ON, False=OFF
* @param led3 status of led3: True=ON, False=OFF
* @param led4 status of led4: True=ON, False=OFF
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds
(JNIEnv *env, jobject obj, jint id, jboolean led1, jboolean led2, jboolean led3, jboolean led4) {
int leds = 0;
if (led1) leds |= WIIMOTE_LED_1;
if (led2) leds |= WIIMOTE_LED_2;
if (led3) leds |= WIIMOTE_LED_3;
if (led4) leds |= WIIMOTE_LED_4;
wiiuse_set_leds(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), leds);
}
/**
* Set how many degrees an angle must change to generate an event.
* @param id id of the wiimote concerned
* @param thresh minimum angle detected by an event
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold
(JNIEnv *env, jobject obj, jint id, jfloat thresh) {
wiiuse_set_orient_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), thresh);
}
/**
* Set how much acceleration must change to generate an event.
* @param id id of the wiimote concerned
* @param val minimum value detected by an event
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold
(JNIEnv *env, jobject obj, jint id, jint val) {
wiiuse_set_accel_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val);
}
/**
* Set alpha smoothing parameter for the given id.
* @param id id of the wiimote concerned
* @param value alpha smoothing value
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing
(JNIEnv *env, jobject obj, jint id, jfloat val) {
wiiuse_set_smooth_alpha(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val);
}
/**
* Try to resync with the wiimote by starting a new handshake.
* @param id id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_reSync
(JNIEnv *env, jobject obj, jint id) {
wiiuse_resync(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
/**
* Make the the accelerometers give smoother results.
* This is set by default.
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_SMOOTHING, 0);
}
/**
* Make the the accelerometers give raw results.
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0, WIIUSE_SMOOTHING);
}
/**
* Make the wiimote generate an event each time we poll.
* Not set by default.
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_CONTINUOUS, 0);
}
/**
* Make the wiimote generate an event only when there is one.
* (default behavior)
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0, WIIUSE_CONTINUOUS);
}
/**
* Notify wiiuse that your screen has an aspect ratio of 4/3.
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_aspect_ratio(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_ASPECT_4_3);
}
/**
* Notify wiiuse that your screen has an aspect ratio of 16/9.
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_aspect_ratio(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_ASPECT_4_3);
}
/**
* Notify wiiuse that the sensor bar is above your screen.
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_ir_position(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_IR_ABOVE);
}
/**
* Notify wiiuse that the sensor bar is below your screen.
* @param id the id of the wiimote concerned
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen
(JNIEnv *env, jobject obj, jint id) {
wiiuse_set_ir_position(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_IR_BELOW);
}
/**
* Set virtual screen resolution. It is used to automatically
* compute the position of a cursor on this virtual screen
* using the sensor bar. These results come in the IREvent.
* @param id the id of the wiimote concerned
* @param x x resolution.
* @param y y resolution.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution
(JNIEnv *env, jobject obj, jint id, jint x, jint y) {
wiiuse_set_ir_vres(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), x, y);
}
/**
* Get status from the wiimotes and send it through call backs.
*
* @param id the id of the wiimote. Must be 1 or 2.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus
(JNIEnv *env, jobject obj, jint id) {
wiiuse_status(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
/**
* Set the normal and expansion handshake timeouts.
*
* @param id
* the id of the wiimote concerned.
* @param normalTimeout
* The timeout in milliseconds for a normal read.
* @param expansionTimeout
* The timeout in millisecondsd to wait for an expansion
* handshake.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setTimeout
(JNIEnv *env, jobject obj, jint id, jshort normalTimeout, jshort expansionTimeout) {
wiiuse_set_timeout(wiimotes, nbMaxWiimotes, (byte) normalTimeout, (byte) expansionTimeout);
}
/**
* Set the IR sensitivity.
*
* @param id
* the id of the wiimote concerned.
* @param level
* 1-5, same as Wii system sensitivity setting. If the level is <
* 1, then level will be set to 1. If the level is > 5, then
* level will be set to 5.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setIrSensitivity
(JNIEnv *env, jobject obj, jint id, jint level) {
wiiuse_set_ir_sensitivity(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), level);
}
/**
* Set how many degrees an angle must change to generate an event for the nunchuk.
* @param id id of the wiimote concerned
* @param thresh minimum angle detected by an event
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold
(JNIEnv *env, jobject obj, jint id, jfloat thresh) {
wiiuse_set_nunchuk_orient_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), thresh);
}
/**
* Set how much acceleration must change to generate an event for the nunchuk.
* @param id id of the wiimote concerned
* @param val minimum value detected by an event
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold
(JNIEnv *env, jobject obj, jint id, jint val) {
wiiuse_set_nunchuk_accel_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val);
}
/**
* Force the bluetooth stack type.(useful only for windows)
*
* @param bluetoothStackType
* must be WiiUseApi.WIIUSE_STACK_UNKNOWN or WiiUseApi.WIIUSE_STACK_MS or
* WiiUseApi.WIIUSE_STACK_BLUESOLEIL.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_windowsSetBluetoothStack
(JNIEnv *env, jobject obj, jint bluetoothStackType) {
if (bluetoothStackType == 0) {
wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_UNKNOWN);
} else if (bluetoothStackType == 1) {
wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_MS);
} else if (bluetoothStackType == 2) {
wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_BLUESOLEIL);
}
}
/**
* Get status and values from the wiimotes and send it through callbacks.
* @param wim the wiimote object to fill with the datas.
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
(JNIEnv *env, jobject obj, jobject gath) {
/* Variables Declarations */
int i, a;
short leds = 0;
jclass cls = (*env)->GetObjectClass(env, gath);
jmethodID mid;
//printf("avant poll, nbMaxwiimotes : %i \n",nbMaxWiimotes);
if (wiiuse_poll(wiimotes, nbMaxWiimotes)) {
/*
* This happens if something happened on any wiimote.
* So go through each one and check if anything happened.
*/
//printf("il y a des events\n");
for (i=0; i < nbMaxWiimotes; ++i) {
//printf("recupe events wiimote : %i\n",nbMaxWiimotes);
switch (wiimotes[i]->event) {
case WIIUSE_EVENT:
/* a generic event occured */
//printf("Generic event\n");
mid = (*env)->GetMethodID(env, cls, "prepareWiiMoteEvent", "(ISSS)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid, wiimotes[i]->btns,
wiimotes[i]->btns_released, wiimotes[i]->btns_held);
/*
* If IR tracking is enabled then print the coordinates
* on the virtual screen that the wiimote is pointing to.
*
* Also make sure that we see at least 1 dot.
*/
if (WIIUSE_USING_IR(wiimotes[i])) {
//printf("IR event\n");
WIIUSE_GET_IR_SENSITIVITY_CORRECTED(wiimotes[i], &a);
mid = (*env)->GetMethodID(env, cls, "prepareIRevent", "(IIFIIIIIISSSF)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid,
wiimotes[i]->ir.x, wiimotes[i]->ir.y, wiimotes[i]->ir.z,
wiimotes[i]->ir.ax, wiimotes[i]->ir.ay,
wiimotes[i]->ir.vres[0], wiimotes[i]->ir.vres[1],
wiimotes[i]->ir.offset[0], wiimotes[i]->ir.offset[1],
wiimotes[i]->ir.pos, wiimotes[i]->ir.aspect,
a , wiimotes[i]->ir.distance);
mid = (*env)->GetMethodID(env, cls, "addIRPointToPreparedWiiMoteEvent",
"(IISSS)V");
if (mid == 0) {
return;
}
/* go through each of the 4 possible IR sources */
for (a=0; a < 4; a++) {
/* check if the source is visible */
if (wiimotes[i]->ir.dot[a].visible) {
(*env)->CallVoidMethod(env, gath, mid,
wiimotes[i]->ir.dot[a].x, wiimotes[i]->ir.dot[a].y,
wiimotes[i]->ir.dot[a].rx, wiimotes[i]->ir.dot[a].ry,
wiimotes[i]->ir.dot[a].size);
}
}
}
/* Motion Sensing */
if (WIIUSE_USING_ACC(wiimotes[i])) {
//printf("acc event\n");
/* set orientation and gravity force */
mid = (*env)->GetMethodID(env, cls,
"addMotionSensingValues", "(FIZFFFFFFFFFSSS)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid,
wiimotes[i]->orient_threshold, wiimotes[i]->accel_threshold,
WIIMOTE_IS_FLAG_SET(wiimotes[i],WIIUSE_SMOOTHING), wiimotes[i]->accel_calib.st_alpha,
wiimotes[i]->orient.roll, wiimotes[i]->orient.pitch, wiimotes[i]->orient.yaw,
wiimotes[i]->orient.a_roll, wiimotes[i]->orient.a_pitch,
wiimotes[i]->gforce.x, wiimotes[i]->gforce.y, wiimotes[i]->gforce.z,
wiimotes[i]->accel.x, wiimotes[i]->accel.y, wiimotes[i]->accel.z);
}
/* Expansions support support*/
if (WIIUSE_USING_EXP(wiimotes[i])) {
/* Nunchuk support */
if (wiimotes[i]->exp.type == EXP_NUNCHUK) {
/* put nunchuk values in wiimote generic event */
mid = (*env)->GetMethodID(env, cls,
"addNunchunkEventToPreparedWiimoteEvent", "(SSSFIZFFFFFFFFFSSSFFSSSSSS)V");
if (mid == 0) {
return;
}
struct nunchuk_t* nc = (nunchuk_t*)&wiimotes[i]->exp.nunchuk;
(*env)->CallVoidMethod(env, gath, mid,
/* buttons */
nc->btns,nc->btns_released,nc->btns_held,
/* motion sensing */
nc->orient_threshold,nc->accel_threshold,
WIIMOTE_IS_FLAG_SET(wiimotes[i],WIIUSE_SMOOTHING),nc->accel_calib.st_alpha,
nc->orient.roll, nc->orient.pitch, nc->orient.yaw,
nc->orient.a_roll, nc->orient.a_pitch,
nc->gforce.x, nc->gforce.y, nc->gforce.z,
nc->accel.x, nc->accel.y, nc->accel.z,
/* joystick */
nc->js.ang,nc->js.mag,
nc->js.max.x,nc->js.max.y,
nc->js.min.x,nc->js.min.y,
nc->js.center.x,nc->js.center.y);
} else if (wiimotes[i]->exp.type == EXP_GUITAR_HERO_3) {
/* put guitar hero values in wiimote generic event */
mid = (*env)->GetMethodID(env, cls,
"addGuitarHeroEventToPreparedWiimoteEvent", "(SSSFFFSSSSSS)V");
if (mid == 0) {
return;
}
struct guitar_hero_3_t* gh = (guitar_hero_3_t*)&wiimotes[i]->exp.gh3;
(*env)->CallVoidMethod(env, gath, mid,
/* buttons */
gh->btns,gh->btns_released,gh->btns_held,
/* whammy bar */
gh->whammy_bar,
/* joystick */
gh->js.ang,gh->js.mag,
gh->js.max.x,gh->js.max.y,
gh->js.min.x,gh->js.min.y,
gh->js.center.x,gh->js.center.y);
} else if (wiimotes[i]->exp.type == EXP_CLASSIC) {
/* put classic controller values in wiimote generic event */
mid = (*env)->GetMethodID(env, cls,
"addClassicControllerEventToPreparedWiimoteEvent", "(SSSFFFFSSSSSSFFSSSSSS)V");
if (mid == 0) {
return;
}
struct classic_ctrl_t* cl = (classic_ctrl_t*)&wiimotes[i]->exp.classic;
(*env)->CallVoidMethod(env, gath, mid,
/* buttons */
cl->btns,cl->btns_released,cl->btns_held,
/* shoulder buttons */
cl->r_shoulder,cl->l_shoulder,
/* joystick left*/
cl->ljs.ang,cl->ljs.mag,
cl->ljs.max.x,cl->ljs.max.y,
cl->ljs.min.x,cl->ljs.min.y,
cl->ljs.center.x,cl->ljs.center.y,
/* joystick right */
cl->rjs.ang,cl->rjs.mag,
cl->rjs.max.x,cl->rjs.max.y,
cl->rjs.min.x,cl->rjs.min.y,
cl->rjs.center.x,cl->rjs.center.y);
} else if (wiimotes[i]->exp.type == EXP_BALANCE_BOARD) {
/* put balance board values in wiimote generic event */
mid = (*env)->GetMethodID(env, cls,
"addBalanceBoardEventToPreparedWiimoteEvent", "(FFFF)V");
if (mid == 0) {
return;
}
struct balance_board_t* bb = (balance_board_t*)&wiimotes[i]->exp.bb;
(*env)->CallVoidMethod(env, gath, mid,
/* weight */
bb->tr,
bb->br,
bb->bl,
bb->tl);
}
}
/* add generic event to java object used to gather events in c environment */
mid = (*env)->GetMethodID(env, cls, "addWiimoteEvent", "()V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid);
break;
case WIIUSE_DISCONNECT:
/* the wiimote disconnected */
mid = (*env)->GetMethodID(env, cls, "addDisconnectionEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_UNEXPECTED_DISCONNECT:
/* the wimote disconnected */
mid = (*env)->GetMethodID(env, cls, "addDisconnectionEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_NUNCHUK_INSERTED:
/* the nunchuk was just connected */
mid = (*env)->GetMethodID(env, cls, "addNunchukInsertedEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_NUNCHUK_REMOVED:
/* the nunchuk disconnected */
mid = (*env)->GetMethodID(env, cls, "addNunchukRemovedEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_GUITAR_HERO_3_CTRL_INSERTED:
/* the guitar hero was just connected */
mid = (*env)->GetMethodID(env, cls, "addGuitarHeroInsertedEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_GUITAR_HERO_3_CTRL_REMOVED:
/* the guitar hero disconnected */
mid = (*env)->GetMethodID(env, cls, "addGuitarHeroRemovedEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_CLASSIC_CTRL_INSERTED:
/* the classic controller was just connected */
mid = (*env)->GetMethodID(env, cls, "addClassicControllerInsertedEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_CLASSIC_CTRL_REMOVED:
/* the classic controller disconnected */
mid = (*env)->GetMethodID(env, cls, "addClassicControllerRemovedEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_BALANCE_BOARD_CTRL_INSERTED:
/* the balance board was just connected */
mid = (*env)->GetMethodID(env, cls, "addBalanceBoardInsertedEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_BALANCE_BOARD_CTRL_REMOVED:
/* the balance board disconnected */
mid = (*env)->GetMethodID(env, cls, "addBalanceBoardRemovedEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_STATUS:
/* a status event occured */
mid = (*env)->GetMethodID(env, cls, "addStatusEvent", "(IZFSZIZZZZ)V");
if (mid == 0) {
return;
}
/* LEDS */
if (WIIUSE_IS_LED_SET(wiimotes[i], 1)) leds += 1;
if (WIIUSE_IS_LED_SET(wiimotes[i], 2)) leds += 2;
if (WIIUSE_IS_LED_SET(wiimotes[i], 3)) leds += 4;
if (WIIUSE_IS_LED_SET(wiimotes[i], 4)) leds += 8;
(*env)->CallVoidMethod(env, gath, mid,
wiimotes[i]->unid, WIIMOTE_IS_SET(wiimotes[i], WIIMOTE_STATE_CONNECTED),
wiimotes[i]->battery_level, leds, WIIUSE_USING_SPEAKER(wiimotes[i]),
wiimotes[i]->exp.type,WIIMOTE_IS_SET(wiimotes[i], WIIMOTE_STATE_RUMBLE),
WIIMOTE_IS_FLAG_SET(wiimotes[i],WIIUSE_CONTINUOUS),
WIIUSE_USING_IR(wiimotes[i]),WIIUSE_USING_ACC(wiimotes[i]));
break;
default:
break;
}
}
}
}
/* Calibration *
JNIEXPORT jshortArray JNICALL Java_wiiusej_WiiUseApi_getCalibration
(JNIEnv *env, jobject obj, jint id) {
struct wiimote_t wm = *wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id);
jshort calibration[6] = {
wm.accel_calib.cal_zero.x,
wm.accel_calib.cal_zero.y,
wm.accel_calib.cal_zero.z,
wm.accel_calib.cal_g.x,
wm.accel_calib.cal_g.y,
wm.accel_calib.cal_g.z};
jshortArray jShorts = (*env)->NewShortArray(env, 6);
(*env)->SetShortArrayRegion(env, jShorts, 0, 6, calibration);
return jShorts;
}*/
/**
* Speaker
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_enableSpeaker(JNIEnv *env, jobject obj, jint id) {
wiiuse_speaker_enable(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_disableSpeaker(JNIEnv *env, jobject obj, jint id){
wiiuse_speaker_disable(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_muteSpeaker(JNIEnv *env, jobject obj, jint id) {
wiiuse_speaker_mute(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_unmuteSpeaker(JNIEnv *env, jobject obj, jint id) {
wiiuse_speaker_unmute(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSpeaker(JNIEnv *env, jobject obj, jint id) {
wiiuse_speaker_activate(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSpeaker(JNIEnv *env, jobject obj, jint id) {
wiiuse_speaker_deactivate(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerFormat(JNIEnv *env, jobject obj, jint id, jbyte format) {
wiiuse_speaker_format(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), format);
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerRate(JNIEnv *env, jobject obj, jint id, jbyte rate, jbyte freq) {
wiiuse_speaker_rate(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), rate, freq);
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerVolume(JNIEnv *env, jobject obj, jint id, jdouble vol) {
wiiuse_speaker_volume(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), vol);
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerConfig(JNIEnv *env, jobject obj, jint id) {
wiiuse_speaker_config(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_streamSpeakerData(JNIEnv *env, jobject obj, jint id, jbyteArray jbArray) {
jbyte *jbData = (*env)->GetByteArrayElements(env, jbArray, JNI_FALSE);
/* Todo: Check for data loss by using signed vs unsigned bytes */
int len = (int) (*env)->GetArrayLength(env, jbArray);
/*byte data[len];
int i = 0;
for (i = 0; i < len; ++i) {
data[i] = (byte) jbData[i];
}*/
wiiuse_speaker_data(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), (byte*) jbData, len);
(*env)->ReleaseByteArrayElements(env, jbArray, jbData, JNI_FALSE);
}

View File

@@ -1,364 +0,0 @@
#include <jni.h>
/* Header for class wiiusej_WiiUseApi */
#ifndef _Included_wiiusej_WiiUseApi
#define _Included_wiiusej_WiiUseApi
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: wiiusej_WiiUseApi
* Method: connect
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_connect
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: find
* Signature: (II)I
*/
JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_find
(JNIEnv *, jobject, jint, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: init
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_init
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: closeConnection
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: getUnId
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_getUnId
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: cleanUp
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_cleanUp
(JNIEnv *, jobject);
/*
* Class: wiiusej_WiiUseApi
* Method: activateRumble
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: deactivateRumble
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: activateIRTracking
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: deactivateIRTracking
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: activateMotionSensing
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: deactivateMotionSensing
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setLeds
* Signature: (IZZZZ)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds
(JNIEnv *, jobject, jint, jboolean, jboolean, jboolean, jboolean);
/*
* Class: wiiusej_WiiUseApi
* Method: setOrientThreshold
* Signature: (IF)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold
(JNIEnv *, jobject, jint, jfloat);
/*
* Class: wiiusej_WiiUseApi
* Method: setAccelThreshold
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold
(JNIEnv *, jobject, jint, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setAlphaSmoothing
* Signature: (IF)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing
(JNIEnv *, jobject, jint, jfloat);
/*
* Class: wiiusej_WiiUseApi
* Method: reSync
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_reSync
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: activateSmoothing
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: deactivateSmoothing
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: activateContinuous
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: deactivateContinuous
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setScreenRatio43
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setScreenRatio169
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setSensorBarAboveScreen
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setSensorBarBelowScreen
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setVirtualScreenResolution
* Signature: (III)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution
(JNIEnv *, jobject, jint, jint, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: getStatus
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setTimeout
* Signature: (ISS)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setTimeout
(JNIEnv *, jobject, jint, jshort, jshort);
/*
* Class: wiiusej_WiiUseApi
* Method: setIrSensitivity
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setIrSensitivity
(JNIEnv *, jobject, jint, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setNunchukOrientationThreshold
* Signature: (IF)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold
(JNIEnv *, jobject, jint, jfloat);
/*
* Class: wiiusej_WiiUseApi
* Method: setNunchukAccelerationThreshold
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold
(JNIEnv *, jobject, jint, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: windowsSetBluetoothStack
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_windowsSetBluetoothStack
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: specialPoll
* Signature: (Lwiiusej/wiiusejevents/utils/EventsGatherer;)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
(JNIEnv *, jobject, jobject);
/*
* Class: wiiusej_WiiUseApi
* Method: enableSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_enableSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: disableSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_disableSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: muteSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_muteSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: unmuteSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_unmuteSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: activateSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: deactivateSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setSpeakerFormat
* Signature: (IB)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerFormat
(JNIEnv *, jobject, jint, jbyte);
/*
* Class: wiiusej_WiiUseApi
* Method: setSpeakerRate
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerRate
(JNIEnv *, jobject, jint, jbyte, jbyte);
/*
* Class: wiiusej_WiiUseApi
* Method: setSpeakerVolume
* Signature: (ID)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerVolume
(JNIEnv *, jobject, jint, jdouble);
/*
* Class: wiiusej_WiiUseApi
* Method: setSpeakerConfig
* Signature: (IBID)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerConfig
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: streamSpeakerData
* Signature: (I[B)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_streamSpeakerData
(JNIEnv *, jobject, jint, jbyteArray);
#ifdef __cplusplus
}
#endif
#endif