Compare commits
53 Commits
dec8fca40e
...
1a547c3cee
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a547c3cee | |||
| fe2a454875 | |||
| 1895e4c4b8 | |||
| f02cfb3abd | |||
| 574b6cc810 | |||
| c402945c72 | |||
| 37c8f7bfb6 | |||
| 5cbcb09c80 | |||
| 750f60caff | |||
| 6f1b40d5fe | |||
| d52769a978 | |||
| 7f1df69ae5 | |||
| bb00df8f73 | |||
| 51cc3d050f | |||
| eb3a67f4e1 | |||
| b6c6f72ff6 | |||
| c616c8c1da | |||
| d1fe78b27b | |||
| ec47d87158 | |||
| cda9ae0b3d | |||
| d901c6fde9 | |||
| d802642d8e | |||
| 90cd632b1c | |||
| 830db5ea9a | |||
| 6b083b2a51 | |||
| 151016817f | |||
| 9ec2109909 | |||
| 2e943a951c | |||
| 6b5697cf21 | |||
| 24d55272b8 | |||
| 0edf579829 | |||
| a92edba5b8 | |||
| 0f7ae40ad0 | |||
| 4b71810e1b | |||
| 385868a4bb | |||
| 72339c6bc7 | |||
| 47bf943762 | |||
| 0ce1264917 | |||
| ac6ce59de7 | |||
| 9e80fd373e | |||
| 51833179bc | |||
| b3d6e71569 | |||
| cd78034c53 | |||
| 02e77f6cc6 | |||
| 79bc4464e9 | |||
| 819f75fd41 | |||
| e4b39cc850 | |||
| 3e8adaeb8a | |||
| 29a329af78 | |||
| fcfafc0ac3 | |||
| 66e02d0479 | |||
| c6ddcec049 | |||
| db4c7934ec |
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry exported="true" kind="con" path="org.springsource.ide.eclipse.gradle.classpathcontainer"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1 +1,9 @@
|
||||
/build/
|
||||
build
|
||||
bin
|
||||
.gradle
|
||||
.settings
|
||||
.project
|
||||
.classpath
|
||||
.maven
|
||||
.gradle
|
||||
.classpath
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#Mon Nov 24 22:53:03 GMT 2014
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18
.project
18
.project
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>jlibwiiuse</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.springsource.ide.eclipse.gradle.core.nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,10 +0,0 @@
|
||||
#org.springsource.ide.eclipse.gradle.core.preferences.GradleImportPreferences
|
||||
#Mon Nov 24 22:50:21 GMT 2014
|
||||
addResourceFilters=true
|
||||
afterTasks=afterEclipseImport;
|
||||
beforeTasks=cleanEclipse;eclipse;
|
||||
enableAfterTasks=true
|
||||
enableBeforeTasks=true
|
||||
enableDSLD=false
|
||||
enableDependendencyManagement=true
|
||||
projects=;
|
||||
@@ -1,4 +0,0 @@
|
||||
#org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences
|
||||
#Mon Nov 24 22:50:22 GMT 2014
|
||||
org.springsource.ide.eclipse.gradle.linkedresources=
|
||||
org.springsource.ide.eclipse.gradle.rootprojectloc=
|
||||
@@ -1,9 +0,0 @@
|
||||
#org.springsource.ide.eclipse.gradle.core.actions.GradleRefreshPreferences
|
||||
#Mon Nov 24 22:50:21 GMT 2014
|
||||
addResourceFilters=true
|
||||
afterTasks=afterEclipseImport;
|
||||
beforeTasks=cleanEclipse;eclipse;
|
||||
enableAfterTasks=true
|
||||
enableBeforeTasks=true
|
||||
enableDSLD=false
|
||||
useHierarchicalNames=false
|
||||
60
LICENSE
60
LICENSE
@@ -1,4 +1,4 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
@@ -616,60 +616,4 @@ above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
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/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
||||
copy of the Program in return for a fee.
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>WiiUseJava</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
File diff suppressed because one or more lines are too long
@@ -1,64 +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/>.
|
||||
*/
|
||||
|
||||
|
||||
WiiuseJ is a java API to use wiimotes on your computer. This API is built on top of an excellent API call Wiiuse using JNI.
|
||||
|
||||
WiiuseJ intent to be a very simple, easy to use and lightweight java API for wiimotes.
|
||||
|
||||
Some of the great aspects of this API are :
|
||||
|
||||
* The compatibility which is as large as Wiiuse's API compatibility
|
||||
|
||||
* Cross-platform : Windows and linux (like Wiiuse)
|
||||
|
||||
* Easy to use
|
||||
|
||||
|
||||
WiiuseJ is made by Guilhem Duch<63> : guiguito1@hotmail.com.
|
||||
You can contact me if you need more information.
|
||||
|
||||
Go to : http://wiiusej.googlecode.com/ for further documentations.
|
||||
|
||||
|
||||
|
||||
CHANGELOG :
|
||||
|
||||
wiiusej 0.12b :
|
||||
- make wiiusej compatible with java 1.5.
|
||||
- fixed a bug that made Null pointer exception happen when disconnecting several wiimotes.
|
||||
|
||||
wiiusej 0.12a :
|
||||
- added guitar hero controller support.
|
||||
- added classic controller support.
|
||||
|
||||
wiiusej 0.12 :
|
||||
- added nunchuk support.
|
||||
- all new stuffs from wiiuse 0.12.
|
||||
- added timeout method.
|
||||
- added IR sensitivity.
|
||||
- updated to be able to reconnect wiimotes.
|
||||
- new architecture behind the scene.
|
||||
- cleaning of the project.
|
||||
|
||||
wiiusej 0.11 :
|
||||
- updated with new stuffs from wiiuse 0.11.
|
||||
- Linux version.
|
||||
- selectionnable rumble on wiimotes connection.
|
||||
|
||||
wiiusej 0.1 :
|
||||
- first version on wiiuse 0.1.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,338 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.debug.1407578899">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.debug.1407578899" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/WiiUseJavaC"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="Debug"/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<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"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="dll" artifactName="WiiUseJ" 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.1407578899" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.so.debug" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep="">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.mingw.so.debug.1407578899." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.debug.639519980" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.debug">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.debug.2023348116" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.debug"/>
|
||||
<builder buildPath="${workspace_loc:/WiiUseJavaC/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.966254532" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug.331257125" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.267124359" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1666952590" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.2043576290" 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.669116307" 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.392854088" name="Debug Level" superClass="gnu.cpp.compiler.mingw.so.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.294368114" 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.251496456" 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.205159879" name="Debug Level" superClass="gnu.c.compiler.mingw.so.debug.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.172563153" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""D:\programmation\win\WINDDK\inc\ddk\wdm\wxp""/>
|
||||
<listOptionValue builtIn="false" value=""C:\Program Files\Java\jdk1.6.0_04\include\win32""/>
|
||||
<listOptionValue builtIn="false" value=""C:\Program Files\Java\jdk1.6.0_04\include""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1396012383" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.786156675" 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.1996273709" name="Shared (-shared)" superClass="gnu.c.link.mingw.so.debug.option.shared" valueType="boolean"/>
|
||||
<option id="gnu.c.link.option.userobjs.704698117" name="Other objects" superClass="gnu.c.link.option.userobjs" valueType="userObjs">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/WiiUseJavaC/wiiusej_WiiUseApi.def}""/>
|
||||
</option>
|
||||
<option id="gnu.c.link.option.paths.1987293490" name="Library search path (-L)" superClass="gnu.c.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/WiiUseJavaC/lib}""/>
|
||||
</option>
|
||||
<option id="gnu.c.link.option.libs.2064083849" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="wiiuse"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.86691693" 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.1574816302" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.output"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.863168128" 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.503834207" name="Shared (-shared)" superClass="gnu.cpp.link.mingw.so.debug.option.shared" valueType="boolean"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.release.809597794;cdt.managedbuild.config.gnu.mingw.so.release.809597794.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.1355331192;cdt.managedbuild.tool.gnu.c.compiler.input.1954844994">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.debug.1407578899;cdt.managedbuild.config.gnu.mingw.so.debug.1407578899.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.294368114;cdt.managedbuild.tool.gnu.c.compiler.input.1396012383">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
||||
<buildTargets>
|
||||
<target name="wiiusej_WiiUseApi" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>wiiusej_WiiUseApi.c</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
</buildTargets>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
|
||||
</cconfiguration>
|
||||
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="WiiUseJavaC.cdt.managedbuild.target.gnu.mingw.so.408524953" name="Shared Library" projectType="cdt.managedbuild.target.gnu.mingw.so"/>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>WiiUseJavaC</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<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.buildLocation</key>
|
||||
<value>${workspace_loc:/WiiUseJavaC/Debug}</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</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.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</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>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
Binary file not shown.
42
build.gradle
42
build.gradle
@@ -1,5 +1,5 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'cpp'
|
||||
apply plugin: 'c'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
@@ -7,10 +7,13 @@ repositories {
|
||||
maven {
|
||||
url 'https://github.com/Boukefalos/jlibloader/raw/mvn-repo/'
|
||||
}
|
||||
maven {
|
||||
url 'https://github.com/Boukefalos/libwiiuse/raw/mvn-repo/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.github.boukefalos:jlibloader:0.1'
|
||||
compile 'com.github.boukefalos:libwiiuse:0.15'
|
||||
}
|
||||
|
||||
group = 'com.github.boukefalos'
|
||||
@@ -49,10 +52,19 @@ model {
|
||||
})
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
libs(PrebuiltLibraries) {
|
||||
wiiuse { lib ->
|
||||
binaries.withType(StaticLibraryBinary) {
|
||||
staticLibraryFile = file("lib/${targetPlatform.name}/lib${lib.name}.lib")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def jniHeadersDir = file("$buildDir/headers")
|
||||
|
||||
/*
|
||||
task jniHeaders(dependsOn: compileJava) {
|
||||
def outputFile = file("$jniHeadersDir/wiiusej_WiiUseApi.h")
|
||||
inputs.files sourceSets.main.output
|
||||
@@ -65,20 +77,21 @@ task jniHeaders(dependsOn: compileJava) {
|
||||
args 'wiiusej.WiiUseApi'
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
libraries {
|
||||
main {
|
||||
baseName project.archivesBaseName
|
||||
}
|
||||
all {
|
||||
binaries.all {
|
||||
cppCompiler.args '-I' + jniHeadersDir
|
||||
cppCompiler.args "-I${org.gradle.internal.jvm.Jvm.current().javaHome}/include"
|
||||
cppCompiler.args "-I${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"
|
||||
cCompiler.args '-I' + jniHeadersDir
|
||||
cCompiler.args "-I${org.gradle.internal.jvm.Jvm.current().javaHome}/include"
|
||||
cCompiler.args "-I${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"
|
||||
linker.args '-Wl,--kill-at', '-static-libgcc', '-static-libstdc++'
|
||||
tasks.withType(CppCompile) { task ->
|
||||
/*tasks.withType(CCompile) { task ->
|
||||
task.dependsOn jniHeaders
|
||||
}
|
||||
}*/
|
||||
lib library: 'wiiuse', linkage: 'static'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +133,8 @@ binaries.withType(SharedLibraryBinary) { binary ->
|
||||
jniPom.scopeMappings.mappings.clear()
|
||||
}
|
||||
def builderTask = binary.tasks.builder
|
||||
nativeJar.into(project.group.replace('.', '/') + '/' + variantName) { from builderTask.outputFile }
|
||||
def libraryDirectory = project.group.replace('.', '/') + "/${project.archivesBaseName}/${variantName}"
|
||||
nativeJar.into(libraryDirectory) { from builderTask.outputFile }
|
||||
nativeJar.dependsOn builderTask
|
||||
}
|
||||
|
||||
@@ -140,6 +154,10 @@ mainPom.withXml { provider ->
|
||||
}
|
||||
def dep = deps.appendNode('dependency')
|
||||
dep.appendNode('groupId', 'com.github.boukefalos')
|
||||
dep.appendNode('artifactId', 'jlibloader')
|
||||
dep.appendNode('version', '0.1')
|
||||
dep.appendNode('artifactId', 'libwiiuse')
|
||||
dep.appendNode('version', '0.15')
|
||||
}
|
||||
|
||||
jar {
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#Mon Nov 24 22:53:03 GMT 2014
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-bin.zip
|
||||
164
gradlew
vendored
Normal file
164
gradlew
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
90
gradlew.bat
vendored
Normal file
90
gradlew.bat
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
Binary file not shown.
Binary file not shown.
@@ -16,8 +16,6 @@
|
||||
*/
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
#include "wiiusej_WiiUseApi.h"
|
||||
@@ -31,14 +29,14 @@
|
||||
#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) \
|
||||
#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; \
|
||||
else *lvl = 0; \
|
||||
} while (0)
|
||||
|
||||
/********************* VARIABLES DECLARATIONS *****************************/
|
||||
@@ -87,7 +85,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_init
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -97,10 +95,10 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection
|
||||
|
||||
/**
|
||||
* Get unique id of a wiimote in the wiimotes array.
|
||||
* Please make sure you call an existing index with a
|
||||
* 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.
|
||||
* @param index index of the wiimote in the wiimotes array.
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_getUnId
|
||||
(JNIEnv *env, jobject obj, jint index) {
|
||||
@@ -304,7 +302,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen
|
||||
}
|
||||
|
||||
/**
|
||||
* Set virtual screen resolution. It is used to automatically
|
||||
* 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
|
||||
@@ -318,7 +316,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -328,7 +326,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus
|
||||
|
||||
/**
|
||||
* Set the normal and expansion handshake timeouts.
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* the id of the wiimote concerned.
|
||||
* @param normalTimeout
|
||||
@@ -339,12 +337,12 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setTimeout
|
||||
(JNIEnv *env, jobject obj, jint id, jshort normalTimeout, jshort expansionTimeout) {
|
||||
wiiuse_set_timeout(wiimotes, nbMaxWiimotes, normalTimeout, expansionTimeout);
|
||||
wiiuse_set_timeout(wiimotes, nbMaxWiimotes, (byte) normalTimeout, (byte) expansionTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IR sensitivity.
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* the id of the wiimote concerned.
|
||||
* @param level
|
||||
@@ -379,7 +377,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -401,22 +399,26 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_windowsSetBluetoothStack
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
|
||||
(JNIEnv *env, jobject obj, jobject gath) {
|
||||
|
||||
/* Variables Declarations */
|
||||
int i;
|
||||
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;
|
||||
@@ -430,11 +432,11 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
|
||||
* Also make sure that we see at least 1 dot.
|
||||
*/
|
||||
if (WIIUSE_USING_IR(wiimotes[i])) {
|
||||
int a;
|
||||
//printf("IR event\n");
|
||||
|
||||
WIIUSE_GET_IR_SENSITIVITY_CORRECTED(wiimotes[i], &a);
|
||||
|
||||
mid = (*env)->GetMethodID(env, cls, "prepareIRevent",
|
||||
"(IIFIIIIIISSSF)V");
|
||||
mid = (*env)->GetMethodID(env, cls, "prepareIRevent", "(IIFIIIIIISSSF)V");
|
||||
if (mid == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -465,6 +467,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
|
||||
|
||||
/* 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");
|
||||
@@ -526,7 +529,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
|
||||
gh->js.max.x,gh->js.max.y,
|
||||
gh->js.min.x,gh->js.min.y,
|
||||
gh->js.center.x,gh->js.center.y);
|
||||
}if (wiimotes[i]->exp.type == EXP_CLASSIC) {
|
||||
} else if (wiimotes[i]->exp.type == EXP_CLASSIC) {
|
||||
/* put classic controller values in wiimote generic event */
|
||||
mid = (*env)->GetMethodID(env, cls,
|
||||
"addClassicControllerEventToPreparedWiimoteEvent", "(SSSFFFFSSSSSSFFSSSSSS)V");
|
||||
@@ -550,12 +553,25 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
|
||||
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_WII_BOARD) {
|
||||
/* put balance board values in wiimote generic event */
|
||||
mid = (*env)->GetMethodID(env, cls,
|
||||
"addBalanceBoardEventToPreparedWiimoteEvent", "(FFFF)V");
|
||||
if (mid == 0) {
|
||||
return;
|
||||
}
|
||||
struct wii_board_t* bb = (wii_board_t*)&wiimotes[i]->exp.wb;
|
||||
(*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");
|
||||
mid = (*env)->GetMethodID(env, cls, "addWiimoteEvent", "()V");
|
||||
if (mid == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -634,6 +650,24 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
|
||||
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
|
||||
break;
|
||||
|
||||
case WIIUSE_WII_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_WII_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");
|
||||
@@ -660,3 +694,75 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
@@ -7,6 +7,12 @@
|
||||
*
|
||||
* Copyright 2006-2007
|
||||
*
|
||||
* Mac fields based on wiic_structs.h from WiiC, written By:
|
||||
* Gabriele Randelli
|
||||
* Email: < randelli (--AT--) dis [--DOT--] uniroma1 [--DOT--] it >
|
||||
*
|
||||
* Copyright 2010
|
||||
*
|
||||
* This file is part of wiiuse.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -36,31 +42,126 @@
|
||||
* is also included which extends this file.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @mainpage
|
||||
*
|
||||
* @section intro Introduction
|
||||
*
|
||||
* WiiUse is a cross-platform C library for accessing the Nintendo Wii
|
||||
* Remote and its related expansions and variations.
|
||||
*
|
||||
* @section project Project
|
||||
*
|
||||
* This is a friendly fork of the original WiiUse project, which seems
|
||||
* to have gone defunct. This updated version incorporates improvements
|
||||
* from a number of internal forks found across the Internet, and is
|
||||
* intended to be the new "upstream" of the project. The new homepage is
|
||||
* on GitHub, where the source is maintained:
|
||||
*
|
||||
* - http://github.com/rpavlik/wiiuse
|
||||
*
|
||||
* Contributions (under the GPL 3+) are welcome and encouraged!
|
||||
*
|
||||
* @section publicapisec Public API
|
||||
*
|
||||
* - @ref publicapi "Public API" - entirely within @ref wiiuse.h
|
||||
* - @ref wiimote "Wiimote device structure"
|
||||
*
|
||||
*/
|
||||
#ifndef WIIUSE_H_INCLUDED
|
||||
#define WIIUSE_H_INCLUDED
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIIUSE_MAJOR 0
|
||||
#define WIIUSE_MINOR 14
|
||||
#define WIIUSE_MICRO 2
|
||||
|
||||
#define WIIUSE_VERSION_TRANSFORM(MAJ, MIN, MICRO) (MAJ * 1000000 + MIN * 1000 + MICRO)
|
||||
#define WIIUSE_HAS_VERSION(MAJ, MIN, MICRO) ( WIIUSE_VERSION_TRANSFORM(MAJ, MIN, MICRO) <= WIIUSE_VERSION_TRANSFORM(WIIUSE_MAJOR, WIIUSE_MINOR, WIIUSE_MICRO) )
|
||||
|
||||
#ifndef WIIUSE_PLATFORM
|
||||
#if defined(_WIN32)
|
||||
#define WIIUSE_PLATFORM
|
||||
#define WIIUSE_WIN32
|
||||
#elif defined(__linux)
|
||||
#define WIIUSE_PLATFORM
|
||||
#define WIIUSE_BLUEZ
|
||||
#elif defined(__APPLE__)
|
||||
#define WIIUSE_PLATFORM
|
||||
#define WIIUSE_MAC
|
||||
#else
|
||||
#error "Platform not yet supported!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WIIUSE_WIN32
|
||||
/* windows */
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#else
|
||||
#endif
|
||||
#ifdef WIIUSE_BLUEZ
|
||||
/* nix */
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIIUSE_INTERNAL_H_INCLUDED
|
||||
#define WCONST
|
||||
#else
|
||||
#ifndef WCONST
|
||||
#define WCONST const
|
||||
#endif
|
||||
|
||||
/* led bit masks */
|
||||
#if defined(_MSC_VER)
|
||||
/* MS compilers of pre-VC2010 versions don't have stdint.h
|
||||
* and I can't get VC2010's stdint.h to compile nicely in
|
||||
* WiiUse
|
||||
*/
|
||||
#include "wiiuse_msvcstdint.h"
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h> /* for FILE */
|
||||
|
||||
/** @defgroup publicapi External API */
|
||||
/** @{ */
|
||||
|
||||
/** @name Wiimote state flags and macros */
|
||||
/** @{ */
|
||||
#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_STATE_EXP_HANDSHAKE 0x10000 /* actual M+ connection exists but no handshake yet */
|
||||
#define WIIMOTE_STATE_EXP_EXTERN 0x20000 /* actual M+ connection exists but handshake failed */
|
||||
#define WIIMOTE_STATE_EXP_FAILED 0x40000 /* actual M+ connection exists but handshake failed */
|
||||
#define WIIMOTE_STATE_MPLUS_PRESENT 0x80000 /* Motion+ is connected */
|
||||
|
||||
#define WIIMOTE_ID(wm) (wm->unid)
|
||||
|
||||
#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s))
|
||||
#define WIIMOTE_IS_CONNECTED(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
|
||||
/** @} */
|
||||
|
||||
/** @name 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 */
|
||||
/** @name Button codes */
|
||||
/** @{ */
|
||||
#define WIIMOTE_BUTTON_TWO 0x0001
|
||||
#define WIIMOTE_BUTTON_ONE 0x0002
|
||||
#define WIIMOTE_BUTTON_B 0x0004
|
||||
@@ -78,13 +179,17 @@
|
||||
#define WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000
|
||||
#define WIIMOTE_BUTTON_UNKNOWN 0x8000
|
||||
#define WIIMOTE_BUTTON_ALL 0x1F9F
|
||||
/** @} */
|
||||
|
||||
/* nunchul button codes */
|
||||
/** @name Nunchuk button codes */
|
||||
/** @{ */
|
||||
#define NUNCHUK_BUTTON_Z 0x01
|
||||
#define NUNCHUK_BUTTON_C 0x02
|
||||
#define NUNCHUK_BUTTON_ALL 0x03
|
||||
/** @} */
|
||||
|
||||
/* classic controller button codes */
|
||||
/** @name Classic controller button codes */
|
||||
/** @{ */
|
||||
#define CLASSIC_CTRL_BUTTON_UP 0x0001
|
||||
#define CLASSIC_CTRL_BUTTON_LEFT 0x0002
|
||||
#define CLASSIC_CTRL_BUTTON_ZR 0x0004
|
||||
@@ -101,8 +206,10 @@
|
||||
#define CLASSIC_CTRL_BUTTON_DOWN 0x4000
|
||||
#define CLASSIC_CTRL_BUTTON_RIGHT 0x8000
|
||||
#define CLASSIC_CTRL_BUTTON_ALL 0xFEFF
|
||||
/** @} */
|
||||
|
||||
/* guitar hero 3 button codes */
|
||||
/** @name 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
|
||||
@@ -113,28 +220,39 @@
|
||||
#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 */
|
||||
/** @name 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 */
|
||||
/** @name Expansion codes */
|
||||
/** @{ */
|
||||
#define EXP_NONE 0
|
||||
#define EXP_NUNCHUK 1
|
||||
#define EXP_CLASSIC 2
|
||||
#define EXP_GUITAR_HERO_3 3
|
||||
#define EXP_WII_BOARD 4
|
||||
#define EXP_MOTION_PLUS 5
|
||||
#define EXP_MOTION_PLUS_NUNCHUK 6 /* Motion+ in nunchuk pass-through mode */
|
||||
#define EXP_MOTION_PLUS_CLASSIC 7 /* Motion+ in classic ctr. pass-through mode */
|
||||
/** @} */
|
||||
|
||||
/* IR correction types */
|
||||
/** @brief IR correction types */
|
||||
typedef enum ir_position_t {
|
||||
WIIUSE_IR_ABOVE,
|
||||
WIIUSE_IR_BELOW
|
||||
} ir_position_t;
|
||||
|
||||
|
||||
/** @name Device Inquiry Macros */
|
||||
/** @{ */
|
||||
/**
|
||||
* @brief Check if a button is pressed.
|
||||
* @param dev Pointer to a wiimote_t or expansion structure.
|
||||
@@ -176,7 +294,7 @@ typedef enum ir_position_t {
|
||||
* @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) \
|
||||
#define WIIUSE_GET_IR_SENSITIVITY(wm, lvl) \
|
||||
do { \
|
||||
if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \
|
||||
else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \
|
||||
@@ -192,22 +310,20 @@ typedef enum ir_position_t {
|
||||
#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
|
||||
#ifdef WIIUSE_WIN32
|
||||
#define WIIMOTE_DEFAULT_TIMEOUT 10
|
||||
#define WIIMOTE_EXP_TIMEOUT 10
|
||||
#endif
|
||||
|
||||
#define WIIUSE_SYNC_HANDSHAKE
|
||||
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef char sbyte;
|
||||
|
||||
@@ -230,27 +346,40 @@ struct gforce_t;
|
||||
* 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);
|
||||
typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, uint16_t 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 */
|
||||
uint32_t addr; /**< the offset that the read started at */
|
||||
uint16_t size; /**< the length of the data read */
|
||||
uint16_t 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 ang3s_t
|
||||
* @brief Roll/Pitch/Yaw short angles.
|
||||
*/
|
||||
typedef struct ang3s_t {
|
||||
int16_t roll, pitch, yaw;
|
||||
} ang3s_t;
|
||||
|
||||
/**
|
||||
* @struct ang3f_t
|
||||
* @brief Roll/Pitch/Yaw float angles.
|
||||
*/
|
||||
typedef struct ang3f_t {
|
||||
float roll, pitch, yaw;
|
||||
} ang3f_t;
|
||||
|
||||
/**
|
||||
* @struct vec2b_t
|
||||
* @brief Unsigned x,y byte vector.
|
||||
*/
|
||||
typedef struct vec2b_t {
|
||||
@@ -259,7 +388,6 @@ typedef struct vec2b_t {
|
||||
|
||||
|
||||
/**
|
||||
* @struct vec3b_t
|
||||
* @brief Unsigned x,y,z byte vector.
|
||||
*/
|
||||
typedef struct vec3b_t {
|
||||
@@ -268,7 +396,6 @@ typedef struct vec3b_t {
|
||||
|
||||
|
||||
/**
|
||||
* @struct vec3f_t
|
||||
* @brief Signed x,y,z float struct.
|
||||
*/
|
||||
typedef struct vec3f_t {
|
||||
@@ -277,7 +404,6 @@ typedef struct vec3f_t {
|
||||
|
||||
|
||||
/**
|
||||
* @struct orient_t
|
||||
* @brief Orientation struct.
|
||||
*
|
||||
* Yaw, pitch, and roll range from -180 to 180 degrees.
|
||||
@@ -293,7 +419,6 @@ typedef struct orient_t {
|
||||
|
||||
|
||||
/**
|
||||
* @struct gforce_t
|
||||
* @brief Gravity force struct.
|
||||
*/
|
||||
typedef struct gforce_t {
|
||||
@@ -302,7 +427,6 @@ typedef struct gforce_t {
|
||||
|
||||
|
||||
/**
|
||||
* @struct accel_t
|
||||
* @brief Accelerometer struct. For any device with an accelerometer.
|
||||
*/
|
||||
typedef struct accel_t {
|
||||
@@ -316,7 +440,6 @@ typedef struct accel_t {
|
||||
|
||||
|
||||
/**
|
||||
* @struct ir_dot_t
|
||||
* @brief A single IR source.
|
||||
*/
|
||||
typedef struct ir_dot_t {
|
||||
@@ -325,8 +448,8 @@ typedef struct ir_dot_t {
|
||||
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) */
|
||||
int16_t rx; /**< raw X coordinate (0-1023) */
|
||||
int16_t ry; /**< raw Y coordinate (0-767) */
|
||||
|
||||
byte order; /**< increasing order by x-axis value */
|
||||
|
||||
@@ -335,7 +458,6 @@ typedef struct ir_dot_t {
|
||||
|
||||
|
||||
/**
|
||||
* @enum aspect_t
|
||||
* @brief Screen aspect ratio.
|
||||
*/
|
||||
typedef enum aspect_t {
|
||||
@@ -345,7 +467,6 @@ typedef enum aspect_t {
|
||||
|
||||
|
||||
/**
|
||||
* @struct ir_t
|
||||
* @brief IR struct. Hold all data related to the IR tracking.
|
||||
*/
|
||||
typedef struct ir_t {
|
||||
@@ -370,9 +491,17 @@ typedef struct ir_t {
|
||||
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
|
||||
@@ -393,11 +522,12 @@ typedef struct joystick_t {
|
||||
|
||||
float ang; /**< angle the joystick is being held */
|
||||
float mag; /**< magnitude of the joystick (range 0-1) */
|
||||
float x; /**< horizontal position of the joystick (range [-1, 1] */
|
||||
float y; /**< vertical position of the joystick (range [-1, 1] */
|
||||
} joystick_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct nunchuk_t
|
||||
* @brief Nunchuk expansion device.
|
||||
*/
|
||||
typedef struct nunchuk_t {
|
||||
@@ -420,13 +550,12 @@ typedef struct 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 */
|
||||
int16_t btns; /**< what buttons have just been pressed */
|
||||
int16_t btns_held; /**< what buttons are being held down */
|
||||
int16_t 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) */
|
||||
@@ -437,13 +566,12 @@ typedef struct 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 */
|
||||
int16_t btns; /**< what buttons have just been pressed */
|
||||
int16_t btns_held; /**< what buttons are being held down */
|
||||
int16_t btns_released; /**< what buttons were just released this */
|
||||
|
||||
float whammy_bar; /**< whammy bar (range 0-1) */
|
||||
|
||||
@@ -452,22 +580,80 @@ typedef struct guitar_hero_3_t {
|
||||
|
||||
|
||||
/**
|
||||
* @struct expansion_t
|
||||
* @brief Motion Plus expansion device
|
||||
*/
|
||||
typedef struct motion_plus_t {
|
||||
byte ext; /**< is there a device on the pass-through port? */
|
||||
|
||||
struct ang3s_t raw_gyro; /**< current raw gyroscope data */
|
||||
struct ang3s_t cal_gyro; /**< calibration raw gyroscope data */
|
||||
struct ang3f_t angle_rate_gyro; /**< current gyro angle rate */
|
||||
struct orient_t orient; /**< current orientation on each axis using Motion Plus gyroscopes */
|
||||
byte acc_mode; /**< Fast/slow rotation mode for roll, pitch and yaw (0 if rotating fast, 1 if slow or still) */
|
||||
int raw_gyro_threshold; /**< threshold for gyroscopes to generate an event */
|
||||
|
||||
struct nunchuk_t *nc; /**< pointers to nunchuk & classic in pass-through-mode */
|
||||
struct classic_ctrl_t *classic;
|
||||
} motion_plus_t;
|
||||
|
||||
/**
|
||||
* @brief Wii Balance Board "expansion" device.
|
||||
*
|
||||
* A Balance Board presents itself as a Wiimote with a permanently-attached
|
||||
* Balance Board expansion device.
|
||||
*/
|
||||
typedef struct wii_board_t {
|
||||
/** @name Interpolated weight per sensor (kg)
|
||||
*
|
||||
* These are the values you're most likely to use.
|
||||
*
|
||||
* See example.c for how to compute total weight and center of gravity
|
||||
* from these values.
|
||||
*/
|
||||
/** @{ */
|
||||
float tl;
|
||||
float tr;
|
||||
float bl;
|
||||
float br;
|
||||
/** @} */
|
||||
|
||||
/** @name Raw sensor values */
|
||||
/** @{ */
|
||||
uint16_t rtl;
|
||||
uint16_t rtr;
|
||||
uint16_t rbl;
|
||||
uint16_t rbr;
|
||||
/** @} */
|
||||
|
||||
/** @name Sensor calibration values */
|
||||
/** @{ */
|
||||
uint16_t ctl[3]; /* Calibration */
|
||||
uint16_t ctr[3];
|
||||
uint16_t cbl[3];
|
||||
uint16_t cbr[3]; /* /Calibration */
|
||||
/** @} */
|
||||
uint8_t update_calib;
|
||||
} wii_board_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generic expansion device plugged into wiimote.
|
||||
*/
|
||||
typedef struct expansion_t {
|
||||
int type; /**< type of expansion attached */
|
||||
|
||||
struct motion_plus_t mp;
|
||||
|
||||
union {
|
||||
struct nunchuk_t nunchuk;
|
||||
struct classic_ctrl_t classic;
|
||||
struct guitar_hero_3_t gh3;
|
||||
struct wii_board_t wb;
|
||||
};
|
||||
} expansion_t;
|
||||
|
||||
|
||||
/**
|
||||
* @enum win32_bt_stack_t
|
||||
* @brief Available bluetooth stacks for Windows.
|
||||
*/
|
||||
typedef enum win_bt_stack_t {
|
||||
@@ -478,7 +664,6 @@ typedef enum win_bt_stack_t {
|
||||
|
||||
|
||||
/**
|
||||
* @struct wiimote_state_t
|
||||
* @brief Significant data from the previous event.
|
||||
*/
|
||||
typedef struct wiimote_state_t {
|
||||
@@ -487,26 +672,36 @@ typedef struct wiimote_state_t {
|
||||
float exp_rjs_ang;
|
||||
float exp_ljs_mag;
|
||||
float exp_rjs_mag;
|
||||
unsigned short exp_btns;
|
||||
uint16_t exp_btns;
|
||||
struct orient_t exp_orient;
|
||||
struct vec3b_t exp_accel;
|
||||
float exp_r_shoulder;
|
||||
float exp_l_shoulder;
|
||||
|
||||
/* motion plus */
|
||||
short drx;
|
||||
short dry;
|
||||
short drz;
|
||||
|
||||
/* wiiboard */
|
||||
uint16_t exp_wb_rtr;
|
||||
uint16_t exp_wb_rtl;
|
||||
uint16_t exp_wb_rbr;
|
||||
uint16_t exp_wb_rbl;
|
||||
|
||||
/* ir_t */
|
||||
int ir_ax;
|
||||
int ir_ay;
|
||||
float ir_distance;
|
||||
|
||||
struct orient_t orient;
|
||||
unsigned short btns;
|
||||
uint16_t 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 {
|
||||
@@ -517,34 +712,55 @@ typedef enum WIIUSE_EVENT_TYPE {
|
||||
WIIUSE_DISCONNECT,
|
||||
WIIUSE_UNEXPECTED_DISCONNECT,
|
||||
WIIUSE_READ_DATA,
|
||||
WIIUSE_WRITE_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_GUITAR_HERO_3_CTRL_REMOVED,
|
||||
WIIUSE_WII_BOARD_CTRL_INSERTED,
|
||||
WIIUSE_WII_BOARD_CTRL_REMOVED,
|
||||
WIIUSE_MOTION_PLUS_ACTIVATED,
|
||||
WIIUSE_MOTION_PLUS_REMOVED
|
||||
} WIIUSE_EVENT_TYPE;
|
||||
|
||||
/**
|
||||
* @struct wiimote_t
|
||||
* @brief Wiimote structure.
|
||||
* @brief Main Wiimote device structure.
|
||||
*
|
||||
* You need one of these to do pretty much anything with this library.
|
||||
*/
|
||||
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
|
||||
#ifdef WIIUSE_BLUEZ
|
||||
/** @name Linux-specific (BlueZ) members */
|
||||
/** @{ */
|
||||
WCONST char bdaddr_str[18]; /**< readable bt address */
|
||||
WCONST bdaddr_t bdaddr; /**< bt address */
|
||||
WCONST int out_sock; /**< output socket */
|
||||
WCONST int in_sock; /**< input socket */
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
#ifdef WIIUSE_WIN32
|
||||
/** @name Windows-specific members */
|
||||
/** @{ */
|
||||
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
|
||||
|
||||
#ifdef WIIUSE_MAC
|
||||
/** @name Mac OS X-specific members */
|
||||
/** @{ */
|
||||
WCONST void* objc_wm; /** WiiuseWiimote* as opaque pointer */
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
WCONST int state; /**< various state flags */
|
||||
WCONST byte leds; /**< currently lit leds */
|
||||
@@ -552,7 +768,11 @@ typedef struct wiimote_t {
|
||||
|
||||
WCONST int flags; /**< options flag */
|
||||
|
||||
#ifndef WIIUSE_SYNC_HANDSHAKE
|
||||
WCONST byte handshake_state; /**< the state of the connection handshake */
|
||||
#endif
|
||||
WCONST byte expansion_state; /**< the state of the expansion handshake */
|
||||
WCONST struct data_req_t* data_req; /**< list of data read requests */
|
||||
|
||||
WCONST struct read_req_t* read_req; /**< list of data read requests */
|
||||
WCONST struct accel_t accel_calib; /**< wiimote accelerometer calibration */
|
||||
@@ -563,20 +783,85 @@ typedef struct wiimote_t {
|
||||
WCONST struct gforce_t gforce; /**< current gravity forces on each axis */
|
||||
|
||||
WCONST struct ir_t ir; /**< IR data */
|
||||
WCONST struct speaker_t speaker; /**< speaker */
|
||||
|
||||
WCONST unsigned short btns; /**< what buttons have just been pressed */
|
||||
WCONST unsigned short btns_held; /**< what buttons are being held down */
|
||||
WCONST unsigned short btns_released; /**< what buttons were just released this */
|
||||
WCONST uint16_t btns; /**< what buttons have just been pressed */
|
||||
WCONST uint16_t btns_held; /**< what buttons are being held down */
|
||||
WCONST uint16_t 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 int32_t 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 */
|
||||
WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occurred */
|
||||
WCONST byte motion_plus_id[6];
|
||||
} wiimote;
|
||||
|
||||
/** @brief Data passed to a callback during wiiuse_update() */
|
||||
typedef struct wiimote_callback_data_t {
|
||||
WCONST int uid;
|
||||
WCONST byte leds;
|
||||
WCONST float battery_level;
|
||||
WCONST struct vec3b_t accel;
|
||||
WCONST struct orient_t orient;
|
||||
WCONST struct gforce_t gforce;
|
||||
WCONST struct ir_t ir;
|
||||
WCONST uint16_t buttons;
|
||||
WCONST uint16_t buttons_held;
|
||||
WCONST uint16_t buttons_released;
|
||||
WCONST WIIUSE_EVENT_TYPE event;
|
||||
WCONST int state;
|
||||
WCONST struct expansion_t expansion;
|
||||
} wiimote_callback_data_t;
|
||||
|
||||
/** @brief Callback type */
|
||||
typedef void (*wiiuse_update_cb)(struct wiimote_callback_data_t* wm);
|
||||
|
||||
/**
|
||||
* @brief Callback that handles a write event.
|
||||
*
|
||||
* @param wm Pointer to a wiimote_t structure.
|
||||
* @param data Pointer to the sent 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_write_data().
|
||||
*/
|
||||
typedef void (*wiiuse_write_cb)(struct wiimote_t* wm, unsigned char* data, unsigned short len);
|
||||
|
||||
typedef enum data_req_s {
|
||||
REQ_READY = 0,
|
||||
REQ_SENT,
|
||||
REQ_DONE
|
||||
} data_req_s;
|
||||
|
||||
/**
|
||||
* @struct data_req_t
|
||||
* @brief Data write request structure.
|
||||
*/
|
||||
struct data_req_t {
|
||||
|
||||
byte data[21]; /**< buffer where read data is written */
|
||||
byte len;
|
||||
unsigned int addr;
|
||||
data_req_s state; /**< set to 1 if not using callback and needs to be cleaned up */
|
||||
wiiuse_write_cb cb; /**< read data callback */
|
||||
struct data_req_t *next;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Loglevels supported by wiiuse.
|
||||
*/
|
||||
typedef enum wiiuse_loglevel {
|
||||
LOGLEVEL_ERROR = 0,
|
||||
LOGLEVEL_WARNING = 1,
|
||||
LOGLEVEL_INFO = 2,
|
||||
LOGLEVEL_DEBUG = 3
|
||||
} wiiuse_loglevel;
|
||||
|
||||
/*****************************************
|
||||
*
|
||||
@@ -584,9 +869,14 @@ typedef struct wiimote_t {
|
||||
*
|
||||
*****************************************/
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIIUSE_EXPORT_DECL __declspec(dllexport)
|
||||
#define WIIUSE_IMPORT_DECL __declspec(dllimport)
|
||||
#ifdef WIIUSE_WIN32
|
||||
#ifdef WIIUSE_STATIC
|
||||
#define WIIUSE_EXPORT_DECL
|
||||
#define WIIUSE_IMPORT_DECL
|
||||
#else
|
||||
#define WIIUSE_EXPORT_DECL __declspec(dllexport)
|
||||
#define WIIUSE_IMPORT_DECL __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define WIIUSE_EXPORT_DECL
|
||||
#define WIIUSE_IMPORT_DECL
|
||||
@@ -602,52 +892,88 @@ typedef struct wiimote_t {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* wiiuse.c */
|
||||
WIIUSE_EXPORT extern const char* wiiuse_version();
|
||||
/* 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);
|
||||
/** @brief Define indicating the presence of the feature allowing you to
|
||||
* redirect output for one or more logging levels within the library.
|
||||
*/
|
||||
#define WIIUSE_HAS_OUTPUT_REDIRECTION
|
||||
WIIUSE_EXPORT extern void wiiuse_set_output(enum wiiuse_loglevel loglevel, FILE *logtarget);
|
||||
|
||||
/* 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);
|
||||
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, uint16_t len);
|
||||
WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, const 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);
|
||||
|
||||
/* events.c */
|
||||
WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes);
|
||||
/* io.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);
|
||||
|
||||
/* 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);
|
||||
/* events.c */
|
||||
WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes);
|
||||
|
||||
/* 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);
|
||||
/**
|
||||
* @brief Poll Wiimotes, and call the provided callback with information
|
||||
* on each Wiimote that had an event.
|
||||
*
|
||||
* Alternative to calling wiiuse_poll yourself, and provides the same
|
||||
* information struct on all platforms.
|
||||
*
|
||||
* @return Number of wiimotes that had an event.
|
||||
*/
|
||||
WIIUSE_EXPORT extern int wiiuse_update(struct wiimote_t** wm, int wiimotes, wiiuse_update_cb callback);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* wiiboard.c */
|
||||
/* this function not currently implemented... */
|
||||
WIIUSE_EXPORT extern void wiiuse_set_wii_board_calib(struct wiimote_t *wm);
|
||||
|
||||
WIIUSE_EXPORT extern void wiiuse_set_motion_plus(struct wiimote_t *wm, int status);
|
||||
|
||||
/* 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 */
|
||||
|
||||
|
||||
364
src/main/headers/wiiusej_WiiUseApi.h
Normal file
364
src/main/headers/wiiusej_WiiUseApi.h
Normal file
@@ -0,0 +1,364 @@
|
||||
#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
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package wiiusej;
|
||||
|
||||
import com.github.boukefalos.jlibloader.Native;
|
||||
|
||||
import wiiusej.wiiusejevents.utils.EventsGatherer;
|
||||
|
||||
/**
|
||||
@@ -24,9 +26,9 @@ import wiiusej.wiiusejevents.utils.EventsGatherer;
|
||||
* @author guiguito
|
||||
*/
|
||||
public class WiiUseApi {
|
||||
|
||||
static {
|
||||
System.loadLibrary("WiiuseJ");
|
||||
Native.load("com.github.boukefalos", "libwiiuse");
|
||||
Native.load("com.github.boukefalos", "jlibwiiuse");
|
||||
}
|
||||
|
||||
private static WiiUseApi instance = new WiiUseApi();
|
||||
@@ -348,4 +350,18 @@ public class WiiUseApi {
|
||||
*/
|
||||
native void specialPoll(EventsGatherer gath);
|
||||
|
||||
/**
|
||||
* Speaker
|
||||
*/
|
||||
native void enableSpeaker(int id);
|
||||
native void disableSpeaker(int id);
|
||||
native void muteSpeaker(int id);
|
||||
native void unmuteSpeaker(int id);
|
||||
native void activateSpeaker(int id);
|
||||
native void deactivateSpeaker(int id);
|
||||
native void setSpeakerFormat(int id, byte format);
|
||||
native void setSpeakerRate(int id, byte rate, byte freq);
|
||||
native void setSpeakerVolume(int id, double volume);
|
||||
native void setSpeakerConfig(int id);
|
||||
native void streamSpeakerData(int id, byte[] block);
|
||||
}
|
||||
|
||||
@@ -661,4 +661,51 @@ public class WiiUseApiManager extends Thread {
|
||||
shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Speaker
|
||||
*/
|
||||
public void enableSpeaker(int id) {
|
||||
wiiuse.enableSpeaker(id);
|
||||
}
|
||||
|
||||
public void disableSpeaker(int id) {
|
||||
wiiuse.disableSpeaker(id);
|
||||
}
|
||||
|
||||
public void muteSpeaker(int id) {
|
||||
wiiuse.muteSpeaker(id);
|
||||
}
|
||||
|
||||
public void unmuteSpeaker(int id) {
|
||||
wiiuse.unmuteSpeaker(id);
|
||||
}
|
||||
|
||||
public void activateSpeaker(int id) {
|
||||
wiiuse.activateSpeaker(id);
|
||||
}
|
||||
|
||||
public void deactivateSpeaker(int id) {
|
||||
wiiuse.deactivateSpeaker(id);
|
||||
}
|
||||
|
||||
public void setSpeakerFormat(int id, byte format) {
|
||||
wiiuse.setSpeakerFormat(id, format);
|
||||
}
|
||||
|
||||
public void setSpeakerRate(int id, byte rate, byte freq) {
|
||||
wiiuse.setSpeakerRate(id, rate, freq);
|
||||
}
|
||||
|
||||
public void setSpeakerVolume(int id, double volume) {
|
||||
wiiuse.setSpeakerVolume(id, volume);
|
||||
}
|
||||
|
||||
public void setSpeakerConfig(int id) {
|
||||
wiiuse.setSpeakerConfig(id);
|
||||
}
|
||||
|
||||
public void streamSpeakerData(int id, byte[] block) {
|
||||
wiiuse.streamSpeakerData(id, block);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import javax.swing.event.EventListenerList;
|
||||
|
||||
import wiiusej.wiiusejevents.utils.WiiUseApiListener;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -327,7 +329,11 @@ public class Wiimote implements WiiUseApiListener {
|
||||
notifyClassicControllerInsertedEventListeners((ClassicControllerInsertedEvent) e);
|
||||
} else if (e.getEventType() == WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_REMOVED) {
|
||||
notifyClassicControllerRemovedEventListeners((ClassicControllerRemovedEvent) e);
|
||||
}
|
||||
} else if (e.getEventType() == WiiUseApiEvent.WIIUSE_BALANCE_BOARD_CTRL_INSERTED) {
|
||||
notifyBalanceBoardInsertedEventListeners((BalanceBoardInsertedEvent) e);
|
||||
} else if (e.getEventType() == WiiUseApiEvent.WIIUSE_BALANCE_BOARD_CTRL_REMOVED) {
|
||||
notifyBalanceBoardRemovedEventListeners((BalanceBoardRemovedEvent) e);
|
||||
}
|
||||
/*
|
||||
* events not managed yet || e.getEventType() == WIIUSE_READ_DATA
|
||||
* WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED || e.getEventType() ==
|
||||
@@ -486,10 +492,78 @@ public class Wiimote implements WiiUseApiListener {
|
||||
listener.onClassicControllerRemovedEvent(evt);
|
||||
}
|
||||
}
|
||||
|
||||
protected void notifyBalanceBoardInsertedEventListeners(BalanceBoardInsertedEvent evt) {
|
||||
for (WiimoteListener listener : getWiiMoteEventListeners()) {
|
||||
listener.onBalanceBoardInsertedEvent(evt);
|
||||
}
|
||||
}
|
||||
|
||||
protected void notifyBalanceBoardRemovedEventListeners(BalanceBoardRemovedEvent evt) {
|
||||
for (WiimoteListener listener : getWiiMoteEventListeners()) {
|
||||
listener.onBalanceBoardRemovedEvent(evt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Wiimote with ID : " + id;
|
||||
}
|
||||
|
||||
public void rumble(int milliseconds) {
|
||||
activateRumble();
|
||||
try {
|
||||
Thread.sleep(milliseconds);
|
||||
} catch (InterruptedException e) {
|
||||
} finally {
|
||||
deactivateRumble();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Speaker
|
||||
*/
|
||||
public void enableSpeaker() {
|
||||
manager.enableSpeaker(id);
|
||||
}
|
||||
|
||||
public void disableSpeaker() {
|
||||
manager.disableSpeaker(id);
|
||||
}
|
||||
|
||||
public void muteSpeaker() {
|
||||
manager.muteSpeaker(id);
|
||||
}
|
||||
|
||||
public void unmuteSpeaker() {
|
||||
manager.unmuteSpeaker(id);
|
||||
}
|
||||
|
||||
public void activateSpeaker() {
|
||||
manager.activateSpeaker(id);
|
||||
}
|
||||
|
||||
public void deactivateSpeaker() {
|
||||
manager.deactivateSpeaker(id);
|
||||
}
|
||||
|
||||
public void setSpeakerFormat(byte format) {
|
||||
manager.setSpeakerFormat(id, format);
|
||||
}
|
||||
|
||||
public void setSpeakerRate(byte rate, byte freq) {
|
||||
manager.setSpeakerRate(id, rate, freq);
|
||||
}
|
||||
|
||||
public void setSpeakerVolume(double volume) {
|
||||
manager.setSpeakerVolume(id, volume);
|
||||
}
|
||||
|
||||
public void setSpeakerConfig() {
|
||||
manager.setSpeakerConfig(id);
|
||||
}
|
||||
|
||||
public void streamSpeakerData(byte[] block) {
|
||||
manager.streamSpeakerData(id, block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package wiiusej.utils;
|
||||
import wiiusej.values.RawAcceleration;
|
||||
import wiiusej.wiiusejevents.GenericEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
|
||||
/**
|
||||
* Panel to display Acceleration in a MotionSensingEvent from an expansion.
|
||||
@@ -27,13 +29,25 @@ import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
||||
*/
|
||||
public class AccelerationExpansionEventPanel extends AccelerationPanel {
|
||||
|
||||
@Override
|
||||
public RawAcceleration getRawAccelerationValue(GenericEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukMotionSensingEvent()
|
||||
.getRawAcceleration();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RawAcceleration getRawAccelerationValue(GenericEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukMotionSensingEvent()
|
||||
.getRawAcceleration();
|
||||
}
|
||||
return null;
|
||||
public void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,256 +48,256 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class AccelerationPanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Color xColor = Color.RED;
|
||||
private Color yColor = Color.GREEN;
|
||||
private Color zColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<RawAcceleration> values = new ArrayList<RawAcceleration>();
|
||||
private Image mImage;// image for double buffering
|
||||
private Color xColor = Color.RED;
|
||||
private Color yColor = Color.GREEN;
|
||||
private Color zColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<RawAcceleration> values = new ArrayList<RawAcceleration>();
|
||||
|
||||
/** Creates new form AccelerationPanel */
|
||||
public AccelerationPanel() {
|
||||
initComponents();
|
||||
}
|
||||
/** Creates new form AccelerationPanel */
|
||||
public AccelerationPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the AccelerationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param xColor
|
||||
* x color.
|
||||
* @param yColor
|
||||
* y color.
|
||||
* @param zColor
|
||||
* z color.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public AccelerationPanel(Color bgColor, Color xColor, Color yColor,
|
||||
Color zColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
this.xColor = xColor;
|
||||
this.yColor = yColor;
|
||||
this.zColor = zColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Constructor used to choose the colors used by the AccelerationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param xColor
|
||||
* x color.
|
||||
* @param yColor
|
||||
* y color.
|
||||
* @param zColor
|
||||
* z color.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public AccelerationPanel(Color bgColor, Color xColor, Color yColor,
|
||||
Color zColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
this.xColor = xColor;
|
||||
this.yColor = yColor;
|
||||
this.zColor = zColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw medium line
|
||||
int yLine = getHeight() - 25;
|
||||
// draw medium line
|
||||
int yLine = getHeight() - 25;
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yLine, getWidth(), yLine);
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yLine, getWidth(), yLine);
|
||||
|
||||
RawAcceleration[] valuesArray = values.toArray(new RawAcceleration[0]);
|
||||
RawAcceleration[] valuesArray = values.toArray(new RawAcceleration[0]);
|
||||
|
||||
double unit = yLine / 255.0;
|
||||
int previousX = 0;
|
||||
int previousY = 0;
|
||||
int previousZ = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
RawAcceleration acceleration = valuesArray[i];
|
||||
// draw X
|
||||
g2.setPaint(xColor);
|
||||
int yDelta = (int) Math.round(unit * acceleration.getX());
|
||||
int y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousX, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousX = y;
|
||||
// draw Y
|
||||
g2.setPaint(yColor);
|
||||
yDelta = (int) Math.round(unit * acceleration.getY());
|
||||
y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousY, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousY = y;
|
||||
// draw Z
|
||||
g2.setPaint(zColor);
|
||||
yDelta = (int) Math.round(unit * acceleration.getZ());
|
||||
y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousZ, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousZ = y;
|
||||
}
|
||||
double unit = yLine / 255.0;
|
||||
int previousX = 0;
|
||||
int previousY = 0;
|
||||
int previousZ = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
RawAcceleration acceleration = valuesArray[i];
|
||||
// draw X
|
||||
g2.setPaint(xColor);
|
||||
int yDelta = (int) Math.round(unit * acceleration.getX());
|
||||
int y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousX, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousX = y;
|
||||
// draw Y
|
||||
g2.setPaint(yColor);
|
||||
yDelta = (int) Math.round(unit * acceleration.getY());
|
||||
y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousY, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousY = y;
|
||||
// draw Z
|
||||
g2.setPaint(zColor);
|
||||
yDelta = (int) Math.round(unit * acceleration.getZ());
|
||||
y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousZ, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousZ = y;
|
||||
}
|
||||
|
||||
// draw legend
|
||||
g2.setPaint(xColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(yColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(zColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
// draw legend
|
||||
g2.setPaint(xColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(yColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(zColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("X", 30, getHeight() - 5);
|
||||
g2.drawString("Y", 85, getHeight() - 5);
|
||||
g2.drawString("Z", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yLine - 5);
|
||||
g2.drawString("255", 2, 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("X", 30, getHeight() - 5);
|
||||
g2.drawString("Y", 85, getHeight() - 5);
|
||||
g2.drawString("Z", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yLine - 5);
|
||||
g2.drawString("255", 2, 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
RawAcceleration rawAcceleration = getRawAccelerationValue(arg0);
|
||||
if (rawAcceleration != null)
|
||||
values.add(rawAcceleration);
|
||||
repaint();
|
||||
}
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
RawAcceleration rawAcceleration = getRawAccelerationValue(arg0);
|
||||
if (rawAcceleration != null)
|
||||
values.add(rawAcceleration);
|
||||
repaint();
|
||||
}
|
||||
|
||||
public abstract RawAcceleration getRawAccelerationValue(GenericEvent e);
|
||||
public abstract RawAcceleration getRawAccelerationValue(GenericEvent e);
|
||||
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
|
||||
public Color getXColor() {
|
||||
return xColor;
|
||||
}
|
||||
public Color getXColor() {
|
||||
return xColor;
|
||||
}
|
||||
|
||||
public Color getYColor() {
|
||||
return yColor;
|
||||
}
|
||||
public Color getYColor() {
|
||||
return yColor;
|
||||
}
|
||||
|
||||
public Color getZColor() {
|
||||
return zColor;
|
||||
}
|
||||
public Color getZColor() {
|
||||
return zColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
|
||||
public void setXColor(Color xColor) {
|
||||
this.xColor = xColor;
|
||||
}
|
||||
public void setXColor(Color xColor) {
|
||||
this.xColor = xColor;
|
||||
}
|
||||
|
||||
public void setYColor(Color yColor) {
|
||||
this.yColor = yColor;
|
||||
}
|
||||
public void setYColor(Color yColor) {
|
||||
this.yColor = yColor;
|
||||
}
|
||||
|
||||
public void setZColor(Color zColor) {
|
||||
this.zColor = zColor;
|
||||
}
|
||||
public void setZColor(Color zColor) {
|
||||
this.zColor = zColor;
|
||||
}
|
||||
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package wiiusej.utils;
|
||||
import wiiusej.values.RawAcceleration;
|
||||
import wiiusej.wiiusejevents.GenericEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
|
||||
/**
|
||||
* Panel to display Acceleration in a MotionSensingEvent from a wiimote.
|
||||
@@ -26,12 +28,24 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
*/
|
||||
public class AccelerationWiimoteEventPanel extends AccelerationPanel {
|
||||
|
||||
@Override
|
||||
public RawAcceleration getRawAccelerationValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getRawAcceleration();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RawAcceleration getRawAccelerationValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getRawAcceleration();
|
||||
}
|
||||
return null;
|
||||
public void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -47,336 +49,348 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public class ButtonsEventPanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Image wiimoteImage;// image for double buffering
|
||||
private WiimoteButtonsEvent buttons;
|
||||
private Color pressedColor = Color.RED;
|
||||
private Color heldColor = Color.ORANGE;
|
||||
private Color releasedColor = Color.YELLOW;
|
||||
private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
|
||||
private Image mImage;// image for double buffering
|
||||
private Image wiimoteImage;// image for double buffering
|
||||
private WiimoteButtonsEvent buttons;
|
||||
private Color pressedColor = Color.RED;
|
||||
private Color heldColor = Color.ORANGE;
|
||||
private Color releasedColor = Color.YELLOW;
|
||||
private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
|
||||
|
||||
/**
|
||||
* Default constructor. Red : button just pressed. Orange : button held.
|
||||
* Yellow : button just released.
|
||||
*/
|
||||
public ButtonsEventPanel() {
|
||||
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
|
||||
java.net.URL url = ButtonsEventPanel.class
|
||||
.getResource("/img/wiimote.png");
|
||||
wiimoteImage = toolkit.createImage(url);
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Default constructor. Red : button just pressed. Orange : button held.
|
||||
* Yellow : button just released.
|
||||
*/
|
||||
public ButtonsEventPanel() {
|
||||
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
|
||||
java.net.URL url = ButtonsEventPanel.class
|
||||
.getResource("/img/wiimote.png");
|
||||
wiimoteImage = toolkit.createImage(url);
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to set colors and shape used.
|
||||
*
|
||||
* @param pressColor
|
||||
* color of a button just pressed.
|
||||
* @param hColor
|
||||
* color of a button held.
|
||||
* @param relColor
|
||||
* color of a button just released.
|
||||
* @param sh
|
||||
* shape draw on the buttons.
|
||||
*/
|
||||
public ButtonsEventPanel(Color pressColor, Color hColor, Color relColor,
|
||||
Shape sh) {
|
||||
pressedColor = pressColor;
|
||||
heldColor = hColor;
|
||||
releasedColor = relColor;
|
||||
shape = sh;
|
||||
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
|
||||
wiimoteImage = toolkit.createImage("img\\wiimote.png");
|
||||
initComponents();
|
||||
/**
|
||||
* Constructor used to set colors and shape used.
|
||||
*
|
||||
* @param pressColor
|
||||
* color of a button just pressed.
|
||||
* @param hColor
|
||||
* color of a button held.
|
||||
* @param relColor
|
||||
* color of a button just released.
|
||||
* @param sh
|
||||
* shape draw on the buttons.
|
||||
*/
|
||||
public ButtonsEventPanel(Color pressColor, Color hColor, Color relColor,
|
||||
Shape sh) {
|
||||
pressedColor = pressColor;
|
||||
heldColor = hColor;
|
||||
releasedColor = relColor;
|
||||
shape = sh;
|
||||
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
|
||||
wiimoteImage = toolkit.createImage("img\\wiimote.png");
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
// offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw buttons pushed
|
||||
g2.drawImage(wiimoteImage, 0, 0, this);
|
||||
g2.setTransform(new AffineTransform());
|
||||
|
||||
if (buttons != null) {
|
||||
/* button ONE */
|
||||
if (buttons.isButtonOneJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 353);
|
||||
}
|
||||
if (buttons.isButtonOneHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 353);
|
||||
}
|
||||
if (buttons.isButtonOneJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 353);
|
||||
}
|
||||
|
||||
/* button TWO */
|
||||
if (buttons.isButtonTwoJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 395);
|
||||
}
|
||||
if (buttons.isButtonTwoHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 395);
|
||||
}
|
||||
if (buttons.isButtonTwoJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 395);
|
||||
}
|
||||
|
||||
/* button A */
|
||||
if (buttons.isButtonAJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 150);
|
||||
}
|
||||
if (buttons.isButtonAHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 150);
|
||||
}
|
||||
if (buttons.isButtonAJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 150);
|
||||
}
|
||||
|
||||
/* button B */
|
||||
if (buttons.isButtonBJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 16, 149);
|
||||
}
|
||||
if (buttons.isButtonBHeld()) {
|
||||
drawFunction(g2, heldColor, 16, 149);
|
||||
}
|
||||
if (buttons.isButtonBJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 16, 149);
|
||||
}
|
||||
|
||||
/* button LEFT */
|
||||
if (buttons.isButtonLeftJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 33, 77);
|
||||
}
|
||||
if (buttons.isButtonLeftHeld()) {
|
||||
drawFunction(g2, heldColor, 33, 77);
|
||||
}
|
||||
if (buttons.isButtonLeftJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 33, 77);
|
||||
}
|
||||
|
||||
/* button RIGHT */
|
||||
if (buttons.isButtonRightJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 73, 77);
|
||||
}
|
||||
if (buttons.isButtonRightHeld()) {
|
||||
drawFunction(g2, heldColor, 73, 77);
|
||||
}
|
||||
if (buttons.isButtonRightJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 73, 77);
|
||||
}
|
||||
|
||||
/* button UP */
|
||||
if (buttons.isButtonUpJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 54, 60);
|
||||
}
|
||||
if (buttons.isButtonUpHeld()) {
|
||||
drawFunction(g2, heldColor, 54, 60);
|
||||
}
|
||||
if (buttons.isButtonUpJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 54, 60);
|
||||
}
|
||||
|
||||
/* button DOWN */
|
||||
if (buttons.isButtonDownJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 54, 97);
|
||||
}
|
||||
if (buttons.isButtonDownHeld()) {
|
||||
drawFunction(g2, heldColor, 54, 97);
|
||||
}
|
||||
if (buttons.isButtonDownJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 54, 97);
|
||||
}
|
||||
|
||||
/* button MINUS */
|
||||
if (buttons.isButtonMinusJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 20, 230);
|
||||
}
|
||||
if (buttons.isButtonMinusHeld()) {
|
||||
drawFunction(g2, heldColor, 20, 230);
|
||||
}
|
||||
if (buttons.isButtonMinusJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 20, 230);
|
||||
}
|
||||
|
||||
/* button PLUS */
|
||||
if (buttons.isButtonPlusJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 86, 230);
|
||||
}
|
||||
if (buttons.isButtonPlusHeld()) {
|
||||
drawFunction(g2, heldColor, 86, 230);
|
||||
}
|
||||
if (buttons.isButtonPlusJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 86, 230);
|
||||
}
|
||||
|
||||
/* button HOME */
|
||||
if (buttons.isButtonHomeJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 230);
|
||||
}
|
||||
if (buttons.isButtonHomeHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 230);
|
||||
}
|
||||
if (buttons.isButtonHomeJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 230);
|
||||
}
|
||||
|
||||
buttons = null;
|
||||
}
|
||||
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to factorize code.
|
||||
*
|
||||
* @param g2
|
||||
* where to draw a shape.
|
||||
* @param col
|
||||
* color to use.
|
||||
* @param x
|
||||
* x coordinates.
|
||||
* @param y
|
||||
* y coordinates.
|
||||
*/
|
||||
private void drawFunction(Graphics2D g2, Color col, int x, int y) {
|
||||
g2.setPaint(col);
|
||||
g2.translate(x, y);
|
||||
g2.draw(shape);
|
||||
g2.fill(shape);
|
||||
g2.setTransform(new AffineTransform());
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
setSize(wiimoteImage.getWidth(this), wiimoteImage.getHeight(this));
|
||||
buttons = arg0;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
clearView();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public Color getHeldColor() {
|
||||
return heldColor;
|
||||
}
|
||||
|
||||
public Color getPressedColor() {
|
||||
return pressedColor;
|
||||
}
|
||||
|
||||
public Color getReleasedColor() {
|
||||
return releasedColor;
|
||||
}
|
||||
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
public void setHeldColor(Color heldColor) {
|
||||
this.heldColor = heldColor;
|
||||
}
|
||||
|
||||
public void setPressedColor(Color pressedColor) {
|
||||
this.pressedColor = pressedColor;
|
||||
}
|
||||
|
||||
public void setReleasedColor(Color releasedColor) {
|
||||
this.releasedColor = releasedColor;
|
||||
}
|
||||
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
public void clearView() {
|
||||
buttons = null;
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
public void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
// offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw buttons pushed
|
||||
g2.drawImage(wiimoteImage, 0, 0, this);
|
||||
g2.setTransform(new AffineTransform());
|
||||
|
||||
if (buttons != null) {
|
||||
/* button ONE */
|
||||
if (buttons.isButtonOneJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 353);
|
||||
}
|
||||
if (buttons.isButtonOneHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 353);
|
||||
}
|
||||
if (buttons.isButtonOneJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 353);
|
||||
}
|
||||
|
||||
/* button TWO */
|
||||
if (buttons.isButtonTwoJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 395);
|
||||
}
|
||||
if (buttons.isButtonTwoHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 395);
|
||||
}
|
||||
if (buttons.isButtonTwoJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 395);
|
||||
}
|
||||
|
||||
/* button A */
|
||||
if (buttons.isButtonAJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 150);
|
||||
}
|
||||
if (buttons.isButtonAHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 150);
|
||||
}
|
||||
if (buttons.isButtonAJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 150);
|
||||
}
|
||||
|
||||
/* button B */
|
||||
if (buttons.isButtonBJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 16, 149);
|
||||
}
|
||||
if (buttons.isButtonBHeld()) {
|
||||
drawFunction(g2, heldColor, 16, 149);
|
||||
}
|
||||
if (buttons.isButtonBJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 16, 149);
|
||||
}
|
||||
|
||||
/* button LEFT */
|
||||
if (buttons.isButtonLeftJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 33, 77);
|
||||
}
|
||||
if (buttons.isButtonLeftHeld()) {
|
||||
drawFunction(g2, heldColor, 33, 77);
|
||||
}
|
||||
if (buttons.isButtonLeftJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 33, 77);
|
||||
}
|
||||
|
||||
/* button RIGHT */
|
||||
if (buttons.isButtonRightJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 73, 77);
|
||||
}
|
||||
if (buttons.isButtonRightHeld()) {
|
||||
drawFunction(g2, heldColor, 73, 77);
|
||||
}
|
||||
if (buttons.isButtonRightJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 73, 77);
|
||||
}
|
||||
|
||||
/* button UP */
|
||||
if (buttons.isButtonUpJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 54, 60);
|
||||
}
|
||||
if (buttons.isButtonUpHeld()) {
|
||||
drawFunction(g2, heldColor, 54, 60);
|
||||
}
|
||||
if (buttons.isButtonUpJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 54, 60);
|
||||
}
|
||||
|
||||
/* button DOWN */
|
||||
if (buttons.isButtonDownJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 54, 97);
|
||||
}
|
||||
if (buttons.isButtonDownHeld()) {
|
||||
drawFunction(g2, heldColor, 54, 97);
|
||||
}
|
||||
if (buttons.isButtonDownJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 54, 97);
|
||||
}
|
||||
|
||||
/* button MINUS */
|
||||
if (buttons.isButtonMinusJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 20, 230);
|
||||
}
|
||||
if (buttons.isButtonMinusHeld()) {
|
||||
drawFunction(g2, heldColor, 20, 230);
|
||||
}
|
||||
if (buttons.isButtonMinusJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 20, 230);
|
||||
}
|
||||
|
||||
/* button PLUS */
|
||||
if (buttons.isButtonPlusJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 86, 230);
|
||||
}
|
||||
if (buttons.isButtonPlusHeld()) {
|
||||
drawFunction(g2, heldColor, 86, 230);
|
||||
}
|
||||
if (buttons.isButtonPlusJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 86, 230);
|
||||
}
|
||||
|
||||
/* button HOME */
|
||||
if (buttons.isButtonHomeJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 230);
|
||||
}
|
||||
if (buttons.isButtonHomeHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 230);
|
||||
}
|
||||
if (buttons.isButtonHomeJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 230);
|
||||
}
|
||||
|
||||
buttons = null;
|
||||
}
|
||||
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
public void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to factorize code.
|
||||
*
|
||||
* @param g2
|
||||
* where to draw a shape.
|
||||
* @param col
|
||||
* color to use.
|
||||
* @param x
|
||||
* x coordinates.
|
||||
* @param y
|
||||
* y coordinates.
|
||||
*/
|
||||
private void drawFunction(Graphics2D g2, Color col, int x, int y) {
|
||||
g2.setPaint(col);
|
||||
g2.translate(x, y);
|
||||
g2.draw(shape);
|
||||
g2.fill(shape);
|
||||
g2.setTransform(new AffineTransform());
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
setSize(wiimoteImage.getWidth(this), wiimoteImage.getHeight(this));
|
||||
buttons = arg0;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
clearView();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public Color getHeldColor() {
|
||||
return heldColor;
|
||||
}
|
||||
|
||||
public Color getPressedColor() {
|
||||
return pressedColor;
|
||||
}
|
||||
|
||||
public Color getReleasedColor() {
|
||||
return releasedColor;
|
||||
}
|
||||
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
public void setHeldColor(Color heldColor) {
|
||||
this.heldColor = heldColor;
|
||||
}
|
||||
|
||||
public void setPressedColor(Color pressedColor) {
|
||||
this.pressedColor = pressedColor;
|
||||
}
|
||||
|
||||
public void setReleasedColor(Color releasedColor) {
|
||||
this.releasedColor = releasedColor;
|
||||
}
|
||||
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
public void clearView() {
|
||||
buttons = null;
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ import wiiusej.wiiusejevents.physicalevents.JoystickEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -435,6 +437,14 @@ public class ClassicControllerButtonsEventPanel extends javax.swing.JPanel imple
|
||||
clearView();
|
||||
}
|
||||
|
||||
public void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent arg0) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
public void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent arg0) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
public Color getHeldColor() {
|
||||
return heldColor;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package wiiusej.utils;
|
||||
import wiiusej.values.GForce;
|
||||
import wiiusej.wiiusejevents.GenericEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
|
||||
/**
|
||||
* Panel to display GForce in a MotionSensingEvent from an expansion.
|
||||
@@ -34,5 +36,4 @@ public class GForceExpansionEventPanel extends GForcePanel{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -47,258 +49,268 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class GForcePanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Color xColor = Color.RED;
|
||||
private Color yColor = Color.GREEN;
|
||||
private Color zColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<GForce> values = new ArrayList<GForce>();
|
||||
private Image mImage;// image for double buffering
|
||||
private Color xColor = Color.RED;
|
||||
private Color yColor = Color.GREEN;
|
||||
private Color zColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<GForce> values = new ArrayList<GForce>();
|
||||
|
||||
/**
|
||||
* Default constructor of the AccelerationPanel.
|
||||
*/
|
||||
public GForcePanel() {
|
||||
initComponents();
|
||||
/**
|
||||
* Default constructor of the AccelerationPanel.
|
||||
*/
|
||||
public GForcePanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the AccelerationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param xxColor
|
||||
* color of the acceleration on X axis.
|
||||
* @param yyColor
|
||||
* color of the acceleration on Y axis.
|
||||
* @param zzColor
|
||||
* color of the acceleration on Z axis.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public GForcePanel(Color bgColor, Color xxColor, Color yyColor,
|
||||
Color zzColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
xColor = xxColor;
|
||||
yColor = yyColor;
|
||||
zColor = zzColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw medium line
|
||||
double yMiddleFloat = getHeight() / 2.0;
|
||||
int yMiddle = (int) Math.round(yMiddleFloat);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yMiddle, getWidth(), yMiddle);
|
||||
|
||||
GForce[] valuesArray = values.toArray(new GForce[0]);
|
||||
double unit = yMiddleFloat / 5.0;
|
||||
int previousX = 0;
|
||||
int previousY = 0;
|
||||
int previousZ = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
GForce gforce = valuesArray[i];
|
||||
// draw X
|
||||
g2.setPaint(xColor);
|
||||
int yDelta = (int) Math.round(unit * gforce.getX());
|
||||
int y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousX, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousX = y;
|
||||
// draw Y
|
||||
g2.setPaint(yColor);
|
||||
yDelta = (int) Math.round(unit * gforce.getY());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousY, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousY = y;
|
||||
// draw Z
|
||||
g2.setPaint(zColor);
|
||||
yDelta = (int) Math.round(unit * gforce.getZ());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousZ, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousZ = y;
|
||||
}
|
||||
|
||||
// draw legend
|
||||
g2.setPaint(xColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(yColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(zColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("X", 30, getHeight() - 5);
|
||||
g2.drawString("Y", 85, getHeight() - 5);
|
||||
g2.drawString("Z", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yMiddle - 5);
|
||||
g2.drawString("5", 2, 10);
|
||||
g2.drawString("-5", 2, getHeight() - 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onBalanceBoardInsertedEvent(
|
||||
BalanceBoardInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the AccelerationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param xxColor
|
||||
* color of the acceleration on X axis.
|
||||
* @param yyColor
|
||||
* color of the acceleration on Y axis.
|
||||
* @param zzColor
|
||||
* color of the acceleration on Z axis.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public GForcePanel(Color bgColor, Color xxColor, Color yyColor,
|
||||
Color zzColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
xColor = xxColor;
|
||||
yColor = yyColor;
|
||||
zColor = zzColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
public void onBalanceBoardRemovedEvent(
|
||||
BalanceBoardRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
GForce gforce = getGForceValue(arg0);
|
||||
if (gforce != null)
|
||||
values.add(gforce);
|
||||
repaint();
|
||||
}
|
||||
|
||||
// draw medium line
|
||||
double yMiddleFloat = getHeight() / 2.0;
|
||||
int yMiddle = (int) Math.round(yMiddleFloat);
|
||||
public abstract GForce getGForceValue(GenericEvent e);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yMiddle, getWidth(), yMiddle);
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
GForce[] valuesArray = values.toArray(new GForce[0]);
|
||||
double unit = yMiddleFloat / 5.0;
|
||||
int previousX = 0;
|
||||
int previousY = 0;
|
||||
int previousZ = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
GForce gforce = valuesArray[i];
|
||||
// draw X
|
||||
g2.setPaint(xColor);
|
||||
int yDelta = (int) Math.round(unit * gforce.getX());
|
||||
int y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousX, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousX = y;
|
||||
// draw Y
|
||||
g2.setPaint(yColor);
|
||||
yDelta = (int) Math.round(unit * gforce.getY());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousY, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousY = y;
|
||||
// draw Z
|
||||
g2.setPaint(zColor);
|
||||
yDelta = (int) Math.round(unit * gforce.getZ());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousZ, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousZ = y;
|
||||
}
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
|
||||
// draw legend
|
||||
g2.setPaint(xColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(yColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(zColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
public Color getXColor() {
|
||||
return xColor;
|
||||
}
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("X", 30, getHeight() - 5);
|
||||
g2.drawString("Y", 85, getHeight() - 5);
|
||||
g2.drawString("Z", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yMiddle - 5);
|
||||
g2.drawString("5", 2, 10);
|
||||
g2.drawString("-5", 2, getHeight() - 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
public Color getYColor() {
|
||||
return yColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
public Color getZColor() {
|
||||
return zColor;
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void setXColor(Color xColor) {
|
||||
this.xColor = xColor;
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void setYColor(Color yColor) {
|
||||
this.yColor = yColor;
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void setZColor(Color zColor) {
|
||||
this.zColor = zColor;
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
GForce gforce = getGForceValue(arg0);
|
||||
if (gforce != null)
|
||||
values.add(gforce);
|
||||
repaint();
|
||||
}
|
||||
|
||||
public abstract GForce getGForceValue(GenericEvent e);
|
||||
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
|
||||
public Color getXColor() {
|
||||
return xColor;
|
||||
}
|
||||
|
||||
public Color getYColor() {
|
||||
return yColor;
|
||||
}
|
||||
|
||||
public Color getZColor() {
|
||||
return zColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
|
||||
public void setXColor(Color xColor) {
|
||||
this.xColor = xColor;
|
||||
}
|
||||
|
||||
public void setYColor(Color yColor) {
|
||||
this.yColor = yColor;
|
||||
}
|
||||
|
||||
public void setZColor(Color zColor) {
|
||||
this.zColor = zColor;
|
||||
}
|
||||
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -26,12 +26,10 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public class GForceWiimoteEventPanel extends GForcePanel {
|
||||
|
||||
@Override
|
||||
public GForce getGForceValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getGforce();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public GForce getGForceValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getGforce();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -256,6 +258,15 @@ public class GuitarHero3ButtonsEventPanel extends javax.swing.JPanel implements
|
||||
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
public void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent arg0) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
public void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent arg0) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel RightPanel;
|
||||
private javax.swing.JToggleButton blueButton;
|
||||
|
||||
@@ -26,7 +26,7 @@ import wiiusej.wiiusejevents.physicalevents.JoystickEvent;
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class GuitarHeroJoystickEventPanel extends JoystickEventPanel{
|
||||
public class GuitarHeroJoystickEventPanel extends JoystickEventPanel {
|
||||
|
||||
@Override
|
||||
public JoystickEvent getJoystickEvent(ExpansionEvent e) {
|
||||
|
||||
@@ -30,6 +30,8 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -46,230 +48,240 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
*/
|
||||
public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
|
||||
private static int MAX_NB_POINTS = 4;
|
||||
private Color color = Color.YELLOW;
|
||||
private Color backgroundColor = Color.BLACK;
|
||||
private Color borderColor = Color.BLUE;
|
||||
private Shape shape;
|
||||
private Image mImage;// image for double buffering
|
||||
private int[] xCoordinates;
|
||||
private int[] yCoordinates;
|
||||
private int nbPoints = -1;
|
||||
private static int MAX_NB_POINTS = 4;
|
||||
private Color color = Color.YELLOW;
|
||||
private Color backgroundColor = Color.BLACK;
|
||||
private Color borderColor = Color.BLUE;
|
||||
private Shape shape;
|
||||
private Image mImage;// image for double buffering
|
||||
private int[] xCoordinates;
|
||||
private int[] yCoordinates;
|
||||
private int nbPoints = -1;
|
||||
|
||||
/**
|
||||
* Default constructor for IR Panel. Background color : black. IR sources
|
||||
* color : yellow. Border color of IR sources : blue. Shape of the IR
|
||||
* sources : circle with a diameter of 10.
|
||||
*/
|
||||
public IRPanel() {
|
||||
shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10);
|
||||
initArrays();
|
||||
initComponents();
|
||||
/**
|
||||
* Default constructor for IR Panel. Background color : black. IR sources
|
||||
* color : yellow. Border color of IR sources : blue. Shape of the IR
|
||||
* sources : circle with a diameter of 10.
|
||||
*/
|
||||
public IRPanel() {
|
||||
shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10);
|
||||
initArrays();
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to parameterize the IR panel.
|
||||
*
|
||||
* @param bgColor
|
||||
* color.
|
||||
* @param ptColor
|
||||
* IR sources color.
|
||||
* @param bdColor
|
||||
* border color of IR sources.
|
||||
* @param sh
|
||||
* Shape of the IR sources.
|
||||
*/
|
||||
public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) {
|
||||
backgroundColor = bgColor;
|
||||
color = ptColor;
|
||||
borderColor = bdColor;
|
||||
shape = sh;
|
||||
initArrays();
|
||||
initComponents();
|
||||
}
|
||||
|
||||
private void initArrays() {
|
||||
xCoordinates = new int[MAX_NB_POINTS];
|
||||
yCoordinates = new int[MAX_NB_POINTS];
|
||||
for (int i = 0; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw points
|
||||
int i = 0;
|
||||
while (i < nbPoints) {
|
||||
double x = xCoordinates[i];
|
||||
double y = yCoordinates[i];
|
||||
|
||||
long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0);
|
||||
long yy = getHeight()
|
||||
- Math.round((double) getHeight() * y / 768.0);
|
||||
g2.translate(xx, yy);
|
||||
|
||||
g2.setPaint(borderColor);
|
||||
g2.draw(shape);
|
||||
g2.setPaint(color);
|
||||
g2.fill(shape);
|
||||
|
||||
g2.setTransform(new AffineTransform());
|
||||
i++;
|
||||
}
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// transfer points
|
||||
wiiusej.values.IRSource[] points = arg0.getIRPoints();
|
||||
nbPoints = points.length;
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
xCoordinates[i] = (int) points[i].getRx();
|
||||
yCoordinates[i] = (int) points[i].getRy();
|
||||
}
|
||||
for (int i = points.length; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
|
||||
// redraw panel
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// clear previous points
|
||||
for (int i = 0; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
// redraw panel
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onBalanceBoardInsertedEvent(
|
||||
BalanceBoardInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to parameterize the IR panel.
|
||||
*
|
||||
* @param bgColor
|
||||
* color.
|
||||
* @param ptColor
|
||||
* IR sources color.
|
||||
* @param bdColor
|
||||
* border color of IR sources.
|
||||
* @param sh
|
||||
* Shape of the IR sources.
|
||||
*/
|
||||
public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) {
|
||||
backgroundColor = bgColor;
|
||||
color = ptColor;
|
||||
borderColor = bdColor;
|
||||
shape = sh;
|
||||
initArrays();
|
||||
initComponents();
|
||||
public void onBalanceBoardRemovedEvent(
|
||||
BalanceBoardRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
private void initArrays() {
|
||||
xCoordinates = new int[MAX_NB_POINTS];
|
||||
yCoordinates = new int[MAX_NB_POINTS];
|
||||
for (int i = 0; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
}
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
// draw points
|
||||
int i = 0;
|
||||
while (i < nbPoints) {
|
||||
double x = xCoordinates[i];
|
||||
double y = yCoordinates[i];
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0);
|
||||
long yy = getHeight()
|
||||
- Math.round((double) getHeight() * y / 768.0);
|
||||
g2.translate(xx, yy);
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
g2.setPaint(borderColor);
|
||||
g2.draw(shape);
|
||||
g2.setPaint(color);
|
||||
g2.fill(shape);
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
g2.setTransform(new AffineTransform());
|
||||
i++;
|
||||
}
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
repaint();
|
||||
}
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// transfer points
|
||||
wiiusej.values.IRSource[] points = arg0.getIRPoints();
|
||||
nbPoints = points.length;
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
xCoordinates[i] = (int) points[i].getRx();
|
||||
yCoordinates[i] = (int) points[i].getRy();
|
||||
}
|
||||
for (int i = points.length; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
public void clearView() {
|
||||
initArrays();
|
||||
repaint();
|
||||
}
|
||||
|
||||
// redraw panel
|
||||
repaint();
|
||||
}
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// clear previous points
|
||||
for (int i = 0; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
// redraw panel
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
public void clearView() {
|
||||
initArrays();
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ import wiiusej.wiiusejevents.physicalevents.JoystickEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -45,204 +47,214 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class JoystickEventPanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Color backgroundColor = Color.BLACK;
|
||||
private Color borderColor = Color.RED;
|
||||
private Color pointColor = Color.RED;
|
||||
private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 30, 30);
|
||||
private JoystickEvent lastJoystickEvent = null;
|
||||
private Image mImage;// image for double buffering
|
||||
private Color backgroundColor = Color.BLACK;
|
||||
private Color borderColor = Color.RED;
|
||||
private Color pointColor = Color.RED;
|
||||
private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 30, 30);
|
||||
private JoystickEvent lastJoystickEvent = null;
|
||||
|
||||
/** Creates new form JoystickPanel */
|
||||
public JoystickEventPanel() {
|
||||
initComponents();
|
||||
/** Creates new form JoystickPanel */
|
||||
public JoystickEventPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the JoystickPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param pColor
|
||||
* point color.
|
||||
* @param bdColor
|
||||
* border color for the shape.
|
||||
* @param sh
|
||||
* shape of what is drawn.
|
||||
*/
|
||||
public JoystickEventPanel(Color bgColor, Color pColor, Color bdColor,
|
||||
Shape sh) {
|
||||
backgroundColor = bgColor;
|
||||
pointColor = pColor;
|
||||
shape = sh;
|
||||
borderColor = bdColor;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setTransform(new AffineTransform());
|
||||
|
||||
// compute center
|
||||
int xCenter = (int) Math.round(d.getWidth() / 2.0);
|
||||
int yCenter = (int) Math.round(d.getHeight() / 2.0);
|
||||
|
||||
// compute coordinates
|
||||
if (lastJoystickEvent != null) {
|
||||
double xAng = Math.sin(lastJoystickEvent.getAngle() * Math.PI
|
||||
/ 180.0)
|
||||
* lastJoystickEvent.getMagnitude();
|
||||
double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI
|
||||
/ 180.0)
|
||||
* lastJoystickEvent.getMagnitude();
|
||||
int halfWidth = (int) Math.round(shape.getBounds().getWidth() / 2);
|
||||
int halHeight = (int) Math.round(shape.getBounds().getHeight() / 2);
|
||||
int xAmplitude = (int) Math.round(xCenter - shape.getBounds().getWidth());
|
||||
int yAmplitude = (int) Math.round(xCenter - shape.getBounds().getHeight());
|
||||
int xShift = (int) Math.round(xAng * xAmplitude);
|
||||
int yShift = (int) Math.round(yAng * yAmplitude);
|
||||
int x = xCenter + xShift - halfWidth;
|
||||
int y = yCenter - yShift - halHeight;
|
||||
// shape
|
||||
g2.translate(x, y);
|
||||
g2.setPaint(borderColor);
|
||||
g2.draw(shape);
|
||||
g2.setPaint(pointColor);
|
||||
g2.fill(shape);
|
||||
}
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
JoystickEvent joy = getJoystickEvent(arg0);
|
||||
if (joy != null) {
|
||||
lastJoystickEvent = joy;
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onBalanceBoardInsertedEvent(
|
||||
BalanceBoardInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the JoystickPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param pColor
|
||||
* point color.
|
||||
* @param bdColor
|
||||
* border color for the shape.
|
||||
* @param sh
|
||||
* shape of what is drawn.
|
||||
*/
|
||||
public JoystickEventPanel(Color bgColor, Color pColor, Color bdColor,
|
||||
Shape sh) {
|
||||
backgroundColor = bgColor;
|
||||
pointColor = pColor;
|
||||
shape = sh;
|
||||
borderColor = bdColor;
|
||||
initComponents();
|
||||
public void onBalanceBoardRemovedEvent(
|
||||
BalanceBoardRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setTransform(new AffineTransform());
|
||||
public Color getPointColor() {
|
||||
return pointColor;
|
||||
}
|
||||
|
||||
// compute center
|
||||
int xCenter = (int) Math.round(d.getWidth() / 2.0);
|
||||
int yCenter = (int) Math.round(d.getHeight() / 2.0);
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
// compute coordinates
|
||||
if (lastJoystickEvent != null) {
|
||||
double xAng = Math.sin(lastJoystickEvent.getAngle() * Math.PI
|
||||
/ 180.0)
|
||||
* lastJoystickEvent.getMagnitude();
|
||||
double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI
|
||||
/ 180.0)
|
||||
* lastJoystickEvent.getMagnitude();
|
||||
int halfWidth = (int) Math.round(shape.getBounds().getWidth() / 2);
|
||||
int halHeight = (int) Math.round(shape.getBounds().getHeight() / 2);
|
||||
int xAmplitude = (int) Math.round(xCenter - shape.getBounds().getWidth());
|
||||
int yAmplitude = (int) Math.round(xCenter - shape.getBounds().getHeight());
|
||||
int xShift = (int) Math.round(xAng * xAmplitude);
|
||||
int yShift = (int) Math.round(yAng * yAmplitude);
|
||||
int x = xCenter + xShift - halfWidth;
|
||||
int y = yCenter - yShift - halHeight;
|
||||
// shape
|
||||
g2.translate(x, y);
|
||||
g2.setPaint(borderColor);
|
||||
g2.draw(shape);
|
||||
g2.setPaint(pointColor);
|
||||
g2.fill(shape);
|
||||
}
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void setPointColor(Color pointColor) {
|
||||
this.pointColor = pointColor;
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
JoystickEvent joy = getJoystickEvent(arg0);
|
||||
if (joy != null) {
|
||||
lastJoystickEvent = joy;
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
public abstract JoystickEvent getJoystickEvent(ExpansionEvent e);
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public Color getPointColor() {
|
||||
return pointColor;
|
||||
}
|
||||
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void setPointColor(Color pointColor) {
|
||||
this.pointColor = pointColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
public abstract JoystickEvent getJoystickEvent(ExpansionEvent e);
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
||||
*/
|
||||
public class NunchukJoystickEventPanel extends JoystickEventPanel {
|
||||
|
||||
@Override
|
||||
public JoystickEvent getJoystickEvent(ExpansionEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukJoystickEvent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public JoystickEvent getJoystickEvent(ExpansionEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukJoystickEvent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
||||
*/
|
||||
public class OrientationExpansionEventPanel extends OrientationPanel {
|
||||
|
||||
@Override
|
||||
public Orientation getOrientationValue(GenericEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukMotionSensingEvent()
|
||||
.getOrientation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Orientation getOrientationValue(GenericEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukMotionSensingEvent()
|
||||
.getOrientation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -47,259 +49,269 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class OrientationPanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Color rollColor = Color.RED;
|
||||
private Color pitchColor = Color.GREEN;
|
||||
private Color yawColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<Orientation> values = new ArrayList<Orientation>();
|
||||
private Image mImage;// image for double buffering
|
||||
private Color rollColor = Color.RED;
|
||||
private Color pitchColor = Color.GREEN;
|
||||
private Color yawColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<Orientation> values = new ArrayList<Orientation>();
|
||||
|
||||
/**
|
||||
* Default constructor. Background color : White. Roll color : Red. Pitch
|
||||
* color : Green. Yaw color : Blue.
|
||||
*/
|
||||
public OrientationPanel() {
|
||||
initComponents();
|
||||
/**
|
||||
* Default constructor. Background color : White. Roll color : Red. Pitch
|
||||
* color : Green. Yaw color : Blue.
|
||||
*/
|
||||
public OrientationPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the OrientationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param rColor
|
||||
* roll color.
|
||||
* @param pColor
|
||||
* pitch color.
|
||||
* @param yColor
|
||||
* yaw color.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public OrientationPanel(Color bgColor, Color rColor, Color pColor,
|
||||
Color yColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
rollColor = rColor;
|
||||
pitchColor = pColor;
|
||||
yawColor = yColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw medium line
|
||||
double yMiddleFloat = getHeight() / 2.0;
|
||||
int yMiddle = (int) Math.round(yMiddleFloat);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yMiddle, getWidth(), yMiddle);
|
||||
|
||||
Orientation[] valuesArray = values.toArray(new Orientation[0]);
|
||||
double unit = yMiddleFloat / 180.0;
|
||||
int previousRoll = 0;
|
||||
int previousPitch = 0;
|
||||
int previousYaw = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
Orientation orientation = valuesArray[i];
|
||||
// draw roll
|
||||
g2.setPaint(rollColor);
|
||||
int yDelta = (int) Math.round(unit * orientation.getRoll());
|
||||
int y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousRoll, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousRoll = y;
|
||||
// draw pitch
|
||||
g2.setPaint(pitchColor);
|
||||
yDelta = (int) Math.round(unit * orientation.getPitch());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousPitch, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousPitch = y;
|
||||
// draw yaw
|
||||
g2.setPaint(yawColor);
|
||||
yDelta = (int) Math.round(unit * orientation.getYaw());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousYaw, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousYaw = y;
|
||||
}
|
||||
|
||||
// draw legend
|
||||
g2.setPaint(rollColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(pitchColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(yawColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("Roll", 30, getHeight() - 5);
|
||||
g2.drawString("Pitch", 85, getHeight() - 5);
|
||||
g2.drawString("Yaw", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yMiddle - 5);
|
||||
g2.drawString("180", 2, 10);
|
||||
g2.drawString("-180", 2, getHeight() - 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onBalanceBoardInsertedEvent(
|
||||
BalanceBoardInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the OrientationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param rColor
|
||||
* roll color.
|
||||
* @param pColor
|
||||
* pitch color.
|
||||
* @param yColor
|
||||
* yaw color.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public OrientationPanel(Color bgColor, Color rColor, Color pColor,
|
||||
Color yColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
rollColor = rColor;
|
||||
pitchColor = pColor;
|
||||
yawColor = yColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
public void onBalanceBoardRemovedEvent(
|
||||
BalanceBoardRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
Orientation orientation = getOrientationValue(arg0);
|
||||
if (orientation != null)
|
||||
values.add(orientation);
|
||||
repaint();
|
||||
}
|
||||
|
||||
// draw medium line
|
||||
double yMiddleFloat = getHeight() / 2.0;
|
||||
int yMiddle = (int) Math.round(yMiddleFloat);
|
||||
public abstract Orientation getOrientationValue(GenericEvent e);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yMiddle, getWidth(), yMiddle);
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
Orientation[] valuesArray = values.toArray(new Orientation[0]);
|
||||
double unit = yMiddleFloat / 180.0;
|
||||
int previousRoll = 0;
|
||||
int previousPitch = 0;
|
||||
int previousYaw = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
Orientation orientation = valuesArray[i];
|
||||
// draw roll
|
||||
g2.setPaint(rollColor);
|
||||
int yDelta = (int) Math.round(unit * orientation.getRoll());
|
||||
int y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousRoll, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousRoll = y;
|
||||
// draw pitch
|
||||
g2.setPaint(pitchColor);
|
||||
yDelta = (int) Math.round(unit * orientation.getPitch());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousPitch, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousPitch = y;
|
||||
// draw yaw
|
||||
g2.setPaint(yawColor);
|
||||
yDelta = (int) Math.round(unit * orientation.getYaw());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousYaw, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousYaw = y;
|
||||
}
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
|
||||
// draw legend
|
||||
g2.setPaint(rollColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(pitchColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(yawColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
public Color getPitchColor() {
|
||||
return pitchColor;
|
||||
}
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("Roll", 30, getHeight() - 5);
|
||||
g2.drawString("Pitch", 85, getHeight() - 5);
|
||||
g2.drawString("Yaw", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yMiddle - 5);
|
||||
g2.drawString("180", 2, 10);
|
||||
g2.drawString("-180", 2, getHeight() - 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
public Color getRollColor() {
|
||||
return rollColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
public Color getYawColor() {
|
||||
return yawColor;
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void setPitchColor(Color pitchColor) {
|
||||
this.pitchColor = pitchColor;
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void setRollColor(Color rollColor) {
|
||||
this.rollColor = rollColor;
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void setYawColor(Color yawColor) {
|
||||
this.yawColor = yawColor;
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
Orientation orientation = getOrientationValue(arg0);
|
||||
if (orientation != null)
|
||||
values.add(orientation);
|
||||
repaint();
|
||||
}
|
||||
|
||||
public abstract Orientation getOrientationValue(GenericEvent e);
|
||||
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
|
||||
public Color getPitchColor() {
|
||||
return pitchColor;
|
||||
}
|
||||
|
||||
public Color getRollColor() {
|
||||
return rollColor;
|
||||
}
|
||||
|
||||
public Color getYawColor() {
|
||||
return yawColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
|
||||
public void setPitchColor(Color pitchColor) {
|
||||
this.pitchColor = pitchColor;
|
||||
}
|
||||
|
||||
public void setRollColor(Color rollColor) {
|
||||
this.rollColor = rollColor;
|
||||
}
|
||||
|
||||
public void setYawColor(Color yawColor) {
|
||||
this.yawColor = yawColor;
|
||||
}
|
||||
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
*/
|
||||
public class OrientationWiimoteEventPanel extends OrientationPanel {
|
||||
|
||||
@Override
|
||||
public Orientation getOrientationValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getOrientation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Orientation getOrientationValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getOrientation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
33
src/main/java/wiiusej/values/Acceleration.java
Normal file
33
src/main/java/wiiusej/values/Acceleration.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package wiiusej.values;
|
||||
|
||||
public class Acceleration {
|
||||
protected double x;
|
||||
protected double y;
|
||||
protected double z;
|
||||
|
||||
public Acceleration(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double[] toArray() {
|
||||
return new double[] {getX(), getY(), getZ()};
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Acceleration : (" + x + ", " + y + ", " + z + ")";
|
||||
}
|
||||
}
|
||||
31
src/main/java/wiiusej/values/Calibration.java
Normal file
31
src/main/java/wiiusej/values/Calibration.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package wiiusej.values;
|
||||
|
||||
public class Calibration {
|
||||
protected RawAcceleration zeroAcceleration;
|
||||
protected RawAcceleration gAcceleration;
|
||||
protected RawAcceleration differenceAcceleration;
|
||||
|
||||
public Calibration(RawAcceleration zeroAcceleration, RawAcceleration gAcceleration) {
|
||||
this.zeroAcceleration = zeroAcceleration;
|
||||
this.gAcceleration = gAcceleration;
|
||||
differenceAcceleration = new RawAcceleration(
|
||||
(short) (gAcceleration.getX() - zeroAcceleration.getX()),
|
||||
(short) (gAcceleration.getY() - zeroAcceleration.getY()),
|
||||
(short) (gAcceleration.getZ() - zeroAcceleration.getZ()));
|
||||
}
|
||||
|
||||
public RawAcceleration getZeroAcceleration() {
|
||||
return zeroAcceleration;
|
||||
}
|
||||
|
||||
public RawAcceleration getGAcceleration() {
|
||||
return gAcceleration;
|
||||
}
|
||||
|
||||
public Acceleration getAcceleration(RawAcceleration rawAcceleration) {
|
||||
return new Acceleration(
|
||||
(rawAcceleration.getX() - zeroAcceleration.getX()) / (double) differenceAcceleration.getX(),
|
||||
(rawAcceleration.getY() - zeroAcceleration.getY()) / (double) differenceAcceleration.getY(),
|
||||
(rawAcceleration.getZ() - zeroAcceleration.getZ()) / (double) differenceAcceleration.getZ());
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,15 @@
|
||||
*/
|
||||
package wiiusej.values;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents gravity force on each axis.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class GForce {
|
||||
public class GForce implements Serializable {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
private float x;
|
||||
private float y;
|
||||
|
||||
@@ -16,12 +16,15 @@
|
||||
*/
|
||||
package wiiusej.values;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Class that represents the orientation of the wiimote.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class Orientation {
|
||||
public class Orientation implements Serializable {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
private float roll;
|
||||
private float pitch;
|
||||
|
||||
@@ -16,12 +16,15 @@
|
||||
*/
|
||||
package wiiusej.values;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents raw acceleration on each axis.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class RawAcceleration {
|
||||
public class RawAcceleration implements Serializable {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
private short x;
|
||||
private short y;
|
||||
@@ -75,7 +78,7 @@ public class RawAcceleration {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Raw acceleration : (" + x + ", " + y + "," + z + ")";
|
||||
return "Raw acceleration : (" + x + ", " + y + ", " + z + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,12 +16,15 @@
|
||||
*/
|
||||
package wiiusej.wiiusejevents;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Abstract mother class representing an event with a wiimote id.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class GenericEvent {
|
||||
public abstract class GenericEvent implements Serializable {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
/* ID */
|
||||
private int wiimoteId = -1;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
public class BalanceBoardButtonsEvent extends ButtonsEvent {
|
||||
protected static short BALANCE_BOARD_BUTTON = 0x0001;
|
||||
|
||||
public BalanceBoardButtonsEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld) {
|
||||
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
public class BalanceBoardEvent extends ExpansionEvent {
|
||||
protected JoystickEvent balanceBoardJoystickEvent;
|
||||
|
||||
public BalanceBoardEvent(int id, float topRight, float bottomRight,
|
||||
float bottomLeft, float topLeft) {
|
||||
super(id);
|
||||
System.out.println(String.format("%f %f %f %f", topRight, bottomRight, bottomLeft, topLeft));
|
||||
/*balanceBoardJoystickEvent = new JoystickEvent(id, angle,
|
||||
magnitude, max1, max2, min1, min2, center1, center2);*/
|
||||
}
|
||||
|
||||
public boolean isThereBalanceBoardJoystickEvent() {
|
||||
return balanceBoardJoystickEvent != null;
|
||||
}
|
||||
|
||||
public JoystickEvent getBalanceBoardJoystickEvent() {
|
||||
return balanceBoardJoystickEvent;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** Balance Board EVENT : WIIMOTE ID :" + getWiimoteId()
|
||||
+ " ********/\n";
|
||||
out += balanceBoardJoystickEvent;
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,8 +27,9 @@ import wiiusej.wiiusejevents.GenericEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public class MotionSensingEvent extends GenericEvent {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
/* Motion Sensing */
|
||||
/* Motion Sensing */
|
||||
private Orientation orientation;
|
||||
private GForce gforce;
|
||||
private RawAcceleration acceleration;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package wiiusej.wiiusejevents.utils;
|
||||
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -362,6 +364,14 @@ public class EventsGatherer {
|
||||
}
|
||||
}
|
||||
|
||||
public void addBalanceBoardEventToPreparedWiimoteEvent(float topRight,
|
||||
float bottomRight, float bottomLeft, float topLeft) {
|
||||
if (genericEvent != null) {
|
||||
genericEvent.setBalanceBoardEvent(topRight, bottomRight,
|
||||
bottomLeft, topLeft);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the prepared WiimoteEvent to the gatherer.
|
||||
*/
|
||||
@@ -484,6 +494,16 @@ public class EventsGatherer {
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
public void addBalanceBoardInsertedEvent(int id) {
|
||||
BalanceBoardInsertedEvent evt = new BalanceBoardInsertedEvent(id);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
public void addBalanceBoardRemovedEvent(int id) {
|
||||
BalanceBoardRemovedEvent evt = new BalanceBoardRemovedEvent(id);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array containing the events.
|
||||
*
|
||||
|
||||
@@ -20,6 +20,8 @@ import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -142,4 +144,19 @@ public interface WiimoteListener extends java.util.EventListener {
|
||||
*/
|
||||
void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e);
|
||||
|
||||
/**
|
||||
* This is the method called when a BalanceBoardInsertedEvent occurs.
|
||||
*
|
||||
* @param e
|
||||
* the BalanceBoardInsertedEvent.
|
||||
*/
|
||||
void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent e);
|
||||
|
||||
/**
|
||||
* This is the method called when a BalanceBoardRemovedEvent occurs.
|
||||
*
|
||||
* @param e
|
||||
* the BalanceBoardRemovedEvent.
|
||||
*/
|
||||
void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
public class BalanceBoardInsertedEvent extends WiiUseApiEvent {
|
||||
public BalanceBoardInsertedEvent(int id) {
|
||||
super(id, WIIUSE_BALANCE_BOARD_CTRL_INSERTED);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** BALANCE BOARD INSERTED EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
|
||||
|
||||
public class BalanceBoardRemovedEvent extends WiiUseApiEvent {
|
||||
public BalanceBoardRemovedEvent(int id) {
|
||||
super(id, WIIUSE_BALANCE_BOARD_CTRL_REMOVED);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** BALANCE BOARD INSERTED EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import wiiusej.wiiusejevents.GenericEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class WiiUseApiEvent extends GenericEvent{
|
||||
|
||||
public static int NONE_EVENT = 0;
|
||||
public static int GENERIC_EVENT = 1;
|
||||
public static int STATUS_EVENT = 2;
|
||||
@@ -36,7 +35,9 @@ public abstract class WiiUseApiEvent extends GenericEvent{
|
||||
public static int WIIUSE_CLASSIC_CTRL_REMOVED = 8;
|
||||
public static int WIIUSE_GUITAR_HERO_3_CTRL_INSERTED = 9;
|
||||
public static int WIIUSE_GUITAR_HERO_3_CTRL_REMOVED = 10;
|
||||
|
||||
public static int WIIUSE_BALANCE_BOARD_CTRL_INSERTED = 11;
|
||||
public static int WIIUSE_BALANCE_BOARD_CTRL_REMOVED = 12;
|
||||
|
||||
/* Event Type */
|
||||
private int eventType;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
import wiiusej.wiiusejevents.physicalevents.BalanceBoardEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.ClassicControllerEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
|
||||
@@ -405,6 +406,12 @@ public class WiimoteEvent extends WiiUseApiEvent {
|
||||
center2);
|
||||
}
|
||||
|
||||
public void setBalanceBoardEvent(float topRight, float bottomRight,
|
||||
float bottomLeft, float topLeft) {
|
||||
expansionEvent = new BalanceBoardEvent(getWiimoteId(), topRight,
|
||||
bottomRight, bottomLeft, topLeft);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
@@ -437,5 +444,4 @@ public class WiimoteEvent extends WiiUseApiEvent {
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -161,6 +163,14 @@ public class ClassicControllerGuiTest extends javax.swing.JFrame implements Wiim
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
|
||||
ClassicControllerGuiTest gui = null;
|
||||
|
||||
@@ -27,32 +27,32 @@ import wiiusej.WiiUseApiManager;
|
||||
*/
|
||||
public class CloseGuiTestCleanly implements WindowListener {
|
||||
|
||||
public void windowOpened(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void windowOpened(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void windowClosing(WindowEvent e) {
|
||||
WiiUseApiManager.definitiveShutdown();
|
||||
}
|
||||
public void windowClosing(WindowEvent e) {
|
||||
WiiUseApiManager.definitiveShutdown();
|
||||
}
|
||||
|
||||
public void windowClosed(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void windowClosed(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void windowIconified(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void windowIconified(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void windowActivated(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void windowActivated(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -158,6 +160,15 @@ public class GuitarHero3GuiTest extends javax.swing.JFrame implements WiimoteLis
|
||||
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel bottomPanel;
|
||||
private javax.swing.JPanel buttonsEventPanel;
|
||||
|
||||
@@ -26,20 +26,20 @@ import wiiusej.Wiimote;
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
|
||||
WiiuseJGuiTest gui = null;
|
||||
if (wiimotes.length > 0) {
|
||||
gui = new WiiuseJGuiTest(wiimotes[0]);
|
||||
} else {
|
||||
gui = new WiiuseJGuiTest();
|
||||
}
|
||||
gui.setDefaultCloseOperation(WiiuseJGuiTest.EXIT_ON_CLOSE);
|
||||
gui.setVisible(true);
|
||||
}
|
||||
/**
|
||||
* @param args
|
||||
* the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
|
||||
WiiuseJGuiTest gui = null;
|
||||
if (wiimotes.length > 0) {
|
||||
gui = new WiiuseJGuiTest(wiimotes[0]);
|
||||
} else {
|
||||
gui = new WiiuseJGuiTest();
|
||||
}
|
||||
gui.setDefaultCloseOperation(WiiuseJGuiTest.EXIT_ON_CLOSE);
|
||||
gui.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ import wiiusej.wiiusejevents.physicalevents.NunchukButtonsEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -46,405 +48,415 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public class NunchukGuiTest extends javax.swing.JFrame implements
|
||||
WiimoteListener {
|
||||
WiimoteListener {
|
||||
|
||||
private Wiimote wiimote;
|
||||
private boolean isThresholdsRequested = true;
|
||||
private Wiimote wiimote;
|
||||
private boolean isThresholdsRequested = true;
|
||||
|
||||
/** Creates new form NunchukGuiTest */
|
||||
public NunchukGuiTest(Wiimote wiimote) {
|
||||
initComponents();
|
||||
this.wiimote = wiimote;
|
||||
registerListeners();
|
||||
}
|
||||
/** Creates new form NunchukGuiTest */
|
||||
public NunchukGuiTest(Wiimote wiimote) {
|
||||
initComponents();
|
||||
this.wiimote = wiimote;
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
wiimote.addWiiMoteEventListeners(this);
|
||||
wiimote.addWiiMoteEventListeners((OrientationPanel) orientationPanel);
|
||||
wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel);
|
||||
wiimote
|
||||
.addWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
|
||||
wiimote
|
||||
.addWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
|
||||
}
|
||||
private void registerListeners() {
|
||||
wiimote.addWiiMoteEventListeners(this);
|
||||
wiimote.addWiiMoteEventListeners((OrientationPanel) orientationPanel);
|
||||
wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel);
|
||||
wiimote
|
||||
.addWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
|
||||
wiimote
|
||||
.addWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
|
||||
}
|
||||
|
||||
public void unRegisterListeners() {
|
||||
wiimote
|
||||
.removeWiiMoteEventListeners((OrientationPanel) orientationPanel);
|
||||
wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel);
|
||||
wiimote
|
||||
.removeWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
|
||||
wiimote
|
||||
.removeWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
|
||||
wiimote.removeWiiMoteEventListeners(this);
|
||||
}
|
||||
public void unRegisterListeners() {
|
||||
wiimote
|
||||
.removeWiiMoteEventListeners((OrientationPanel) orientationPanel);
|
||||
wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel);
|
||||
wiimote
|
||||
.removeWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
|
||||
wiimote
|
||||
.removeWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
|
||||
wiimote.removeWiiMoteEventListeners(this);
|
||||
}
|
||||
|
||||
public void requestThresholdsUpdate() {
|
||||
isThresholdsRequested = true;
|
||||
}
|
||||
public void requestThresholdsUpdate() {
|
||||
isThresholdsRequested = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
topPanels = new javax.swing.JPanel();
|
||||
joystickEventsPanel = new NunchukJoystickEventPanel();
|
||||
motionSensingEventsPanel = new javax.swing.JPanel();
|
||||
motionSensingEventsTabbedPanels = new javax.swing.JTabbedPane();
|
||||
rawAccelerationPanel = new AccelerationExpansionEventPanel();
|
||||
orientationPanel = new OrientationExpansionEventPanel();
|
||||
gForcePanel = new GForceExpansionEventPanel();
|
||||
setNunchukValuesPanel = new javax.swing.JPanel();
|
||||
nunchukButtonsEventPanel = new javax.swing.JPanel();
|
||||
cButton = new javax.swing.JButton();
|
||||
zButton = new javax.swing.JButton();
|
||||
nunchukOrientationPanel = new javax.swing.JPanel();
|
||||
nunchukOrientationTextField = new javax.swing.JTextField();
|
||||
nunchukOrientationButton = new javax.swing.JButton();
|
||||
nunchukAccelerationPanel = new javax.swing.JPanel();
|
||||
nunchukAccelerationTextField = new javax.swing.JTextField();
|
||||
nunchukAccelerationButton = new javax.swing.JButton();
|
||||
messagePanel = new javax.swing.JPanel();
|
||||
messageText = new javax.swing.JLabel();
|
||||
topPanels = new javax.swing.JPanel();
|
||||
joystickEventsPanel = new NunchukJoystickEventPanel();
|
||||
motionSensingEventsPanel = new javax.swing.JPanel();
|
||||
motionSensingEventsTabbedPanels = new javax.swing.JTabbedPane();
|
||||
rawAccelerationPanel = new AccelerationExpansionEventPanel();
|
||||
orientationPanel = new OrientationExpansionEventPanel();
|
||||
gForcePanel = new GForceExpansionEventPanel();
|
||||
setNunchukValuesPanel = new javax.swing.JPanel();
|
||||
nunchukButtonsEventPanel = new javax.swing.JPanel();
|
||||
cButton = new javax.swing.JButton();
|
||||
zButton = new javax.swing.JButton();
|
||||
nunchukOrientationPanel = new javax.swing.JPanel();
|
||||
nunchukOrientationTextField = new javax.swing.JTextField();
|
||||
nunchukOrientationButton = new javax.swing.JButton();
|
||||
nunchukAccelerationPanel = new javax.swing.JPanel();
|
||||
nunchukAccelerationTextField = new javax.swing.JTextField();
|
||||
nunchukAccelerationButton = new javax.swing.JButton();
|
||||
messagePanel = new javax.swing.JPanel();
|
||||
messageText = new javax.swing.JLabel();
|
||||
|
||||
setTitle("WiiuseJ Nunchuk Test GUI");
|
||||
setMinimumSize(new java.awt.Dimension(400, 400));
|
||||
getContentPane().setLayout(
|
||||
new javax.swing.BoxLayout(getContentPane(),
|
||||
javax.swing.BoxLayout.Y_AXIS));
|
||||
setTitle("WiiuseJ Nunchuk Test GUI");
|
||||
setMinimumSize(new java.awt.Dimension(400, 400));
|
||||
getContentPane().setLayout(
|
||||
new javax.swing.BoxLayout(getContentPane(),
|
||||
javax.swing.BoxLayout.Y_AXIS));
|
||||
|
||||
topPanels.setMinimumSize(new java.awt.Dimension(400, 200));
|
||||
topPanels.setPreferredSize(new java.awt.Dimension(400, 200));
|
||||
topPanels.setLayout(new javax.swing.BoxLayout(topPanels,
|
||||
javax.swing.BoxLayout.LINE_AXIS));
|
||||
topPanels.setMinimumSize(new java.awt.Dimension(400, 200));
|
||||
topPanels.setPreferredSize(new java.awt.Dimension(400, 200));
|
||||
topPanels.setLayout(new javax.swing.BoxLayout(topPanels,
|
||||
javax.swing.BoxLayout.LINE_AXIS));
|
||||
|
||||
joystickEventsPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||
joystickEventsPanel.setBorder(javax.swing.BorderFactory
|
||||
.createTitledBorder(new javax.swing.border.LineBorder(
|
||||
new java.awt.Color(51, 153, 0), 2, true),
|
||||
"Joystick View",
|
||||
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
javax.swing.border.TitledBorder.DEFAULT_POSITION,
|
||||
new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(
|
||||
204, 102, 0)));
|
||||
joystickEventsPanel.setToolTipText("JoystickEvent");
|
||||
joystickEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200));
|
||||
joystickEventsPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||
joystickEventsPanel.setBorder(javax.swing.BorderFactory
|
||||
.createTitledBorder(new javax.swing.border.LineBorder(
|
||||
new java.awt.Color(51, 153, 0), 2, true),
|
||||
"Joystick View",
|
||||
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
javax.swing.border.TitledBorder.DEFAULT_POSITION,
|
||||
new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(
|
||||
204, 102, 0)));
|
||||
joystickEventsPanel.setToolTipText("JoystickEvent");
|
||||
joystickEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200));
|
||||
|
||||
javax.swing.GroupLayout joystickEventsPanelLayout = new javax.swing.GroupLayout(
|
||||
joystickEventsPanel);
|
||||
joystickEventsPanel.setLayout(joystickEventsPanelLayout);
|
||||
joystickEventsPanelLayout.setHorizontalGroup(joystickEventsPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 601, Short.MAX_VALUE));
|
||||
joystickEventsPanelLayout.setVerticalGroup(joystickEventsPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 174, Short.MAX_VALUE));
|
||||
javax.swing.GroupLayout joystickEventsPanelLayout = new javax.swing.GroupLayout(
|
||||
joystickEventsPanel);
|
||||
joystickEventsPanel.setLayout(joystickEventsPanelLayout);
|
||||
joystickEventsPanelLayout.setHorizontalGroup(joystickEventsPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 601, Short.MAX_VALUE));
|
||||
joystickEventsPanelLayout.setVerticalGroup(joystickEventsPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 174, Short.MAX_VALUE));
|
||||
|
||||
topPanels.add(joystickEventsPanel);
|
||||
joystickEventsPanel.getAccessibleContext()
|
||||
.setAccessibleName("Joystick");
|
||||
topPanels.add(joystickEventsPanel);
|
||||
joystickEventsPanel.getAccessibleContext()
|
||||
.setAccessibleName("Joystick");
|
||||
|
||||
motionSensingEventsPanel
|
||||
.setMinimumSize(new java.awt.Dimension(200, 200));
|
||||
motionSensingEventsPanel
|
||||
.setMinimumSize(new java.awt.Dimension(200, 200));
|
||||
|
||||
rawAccelerationPanel.setToolTipText("Nunchuk MotionSensingEvent");
|
||||
rawAccelerationPanel.setToolTipText("Nunchuk MotionSensingEvent");
|
||||
|
||||
javax.swing.GroupLayout rawAccelerationPanelLayout = new javax.swing.GroupLayout(
|
||||
rawAccelerationPanel);
|
||||
rawAccelerationPanel.setLayout(rawAccelerationPanelLayout);
|
||||
rawAccelerationPanelLayout
|
||||
.setHorizontalGroup(rawAccelerationPanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE));
|
||||
rawAccelerationPanelLayout.setVerticalGroup(rawAccelerationPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE));
|
||||
javax.swing.GroupLayout rawAccelerationPanelLayout = new javax.swing.GroupLayout(
|
||||
rawAccelerationPanel);
|
||||
rawAccelerationPanel.setLayout(rawAccelerationPanelLayout);
|
||||
rawAccelerationPanelLayout
|
||||
.setHorizontalGroup(rawAccelerationPanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE));
|
||||
rawAccelerationPanelLayout.setVerticalGroup(rawAccelerationPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE));
|
||||
|
||||
motionSensingEventsTabbedPanels.addTab("RawAcceleration",
|
||||
rawAccelerationPanel);
|
||||
motionSensingEventsTabbedPanels.addTab("RawAcceleration",
|
||||
rawAccelerationPanel);
|
||||
|
||||
javax.swing.GroupLayout orientationPanelLayout = new javax.swing.GroupLayout(
|
||||
orientationPanel);
|
||||
orientationPanel.setLayout(orientationPanelLayout);
|
||||
orientationPanelLayout.setHorizontalGroup(orientationPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE));
|
||||
orientationPanelLayout.setVerticalGroup(orientationPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE));
|
||||
javax.swing.GroupLayout orientationPanelLayout = new javax.swing.GroupLayout(
|
||||
orientationPanel);
|
||||
orientationPanel.setLayout(orientationPanelLayout);
|
||||
orientationPanelLayout.setHorizontalGroup(orientationPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE));
|
||||
orientationPanelLayout.setVerticalGroup(orientationPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE));
|
||||
|
||||
motionSensingEventsTabbedPanels.addTab("Orientation", orientationPanel);
|
||||
motionSensingEventsTabbedPanels.addTab("Orientation", orientationPanel);
|
||||
|
||||
javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(
|
||||
gForcePanel);
|
||||
gForcePanel.setLayout(gForcePanelLayout);
|
||||
gForcePanelLayout.setHorizontalGroup(gForcePanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE));
|
||||
gForcePanelLayout.setVerticalGroup(gForcePanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE));
|
||||
javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(
|
||||
gForcePanel);
|
||||
gForcePanel.setLayout(gForcePanelLayout);
|
||||
gForcePanelLayout.setHorizontalGroup(gForcePanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 597, Short.MAX_VALUE));
|
||||
gForcePanelLayout.setVerticalGroup(gForcePanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 175, Short.MAX_VALUE));
|
||||
|
||||
motionSensingEventsTabbedPanels.addTab("GForce", gForcePanel);
|
||||
motionSensingEventsTabbedPanels.addTab("GForce", gForcePanel);
|
||||
|
||||
javax.swing.GroupLayout motionSensingEventsPanelLayout = new javax.swing.GroupLayout(
|
||||
motionSensingEventsPanel);
|
||||
motionSensingEventsPanel.setLayout(motionSensingEventsPanelLayout);
|
||||
motionSensingEventsPanelLayout
|
||||
.setHorizontalGroup(motionSensingEventsPanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(motionSensingEventsTabbedPanels,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE, 602,
|
||||
Short.MAX_VALUE));
|
||||
motionSensingEventsPanelLayout
|
||||
.setVerticalGroup(motionSensingEventsPanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(motionSensingEventsTabbedPanels,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE, 200,
|
||||
Short.MAX_VALUE));
|
||||
javax.swing.GroupLayout motionSensingEventsPanelLayout = new javax.swing.GroupLayout(
|
||||
motionSensingEventsPanel);
|
||||
motionSensingEventsPanel.setLayout(motionSensingEventsPanelLayout);
|
||||
motionSensingEventsPanelLayout
|
||||
.setHorizontalGroup(motionSensingEventsPanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(motionSensingEventsTabbedPanels,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE, 602,
|
||||
Short.MAX_VALUE));
|
||||
motionSensingEventsPanelLayout
|
||||
.setVerticalGroup(motionSensingEventsPanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(motionSensingEventsTabbedPanels,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE, 200,
|
||||
Short.MAX_VALUE));
|
||||
|
||||
topPanels.add(motionSensingEventsPanel);
|
||||
topPanels.add(motionSensingEventsPanel);
|
||||
|
||||
getContentPane().add(topPanels);
|
||||
getContentPane().add(topPanels);
|
||||
|
||||
setNunchukValuesPanel.setMinimumSize(new java.awt.Dimension(400, 200));
|
||||
setNunchukValuesPanel
|
||||
.setPreferredSize(new java.awt.Dimension(400, 200));
|
||||
setNunchukValuesPanel.setLayout(new javax.swing.BoxLayout(
|
||||
setNunchukValuesPanel, javax.swing.BoxLayout.Y_AXIS));
|
||||
setNunchukValuesPanel.setMinimumSize(new java.awt.Dimension(400, 200));
|
||||
setNunchukValuesPanel
|
||||
.setPreferredSize(new java.awt.Dimension(400, 200));
|
||||
setNunchukValuesPanel.setLayout(new javax.swing.BoxLayout(
|
||||
setNunchukValuesPanel, javax.swing.BoxLayout.Y_AXIS));
|
||||
|
||||
nunchukButtonsEventPanel.setToolTipText("Nunchuk ButtonsEvent");
|
||||
nunchukButtonsEventPanel
|
||||
.setMinimumSize(new java.awt.Dimension(100, 100));
|
||||
nunchukButtonsEventPanel.setPreferredSize(new java.awt.Dimension(100,
|
||||
100));
|
||||
nunchukButtonsEventPanel.setLayout(new javax.swing.BoxLayout(
|
||||
nunchukButtonsEventPanel, javax.swing.BoxLayout.LINE_AXIS));
|
||||
nunchukButtonsEventPanel.setToolTipText("Nunchuk ButtonsEvent");
|
||||
nunchukButtonsEventPanel
|
||||
.setMinimumSize(new java.awt.Dimension(100, 100));
|
||||
nunchukButtonsEventPanel.setPreferredSize(new java.awt.Dimension(100,
|
||||
100));
|
||||
nunchukButtonsEventPanel.setLayout(new javax.swing.BoxLayout(
|
||||
nunchukButtonsEventPanel, javax.swing.BoxLayout.LINE_AXIS));
|
||||
|
||||
cButton.setText("C");
|
||||
cButton.setMaximumSize(new java.awt.Dimension(50, 50));
|
||||
cButton.setMinimumSize(new java.awt.Dimension(50, 50));
|
||||
cButton.setPreferredSize(new java.awt.Dimension(50, 50));
|
||||
nunchukButtonsEventPanel.add(cButton);
|
||||
cButton.setText("C");
|
||||
cButton.setMaximumSize(new java.awt.Dimension(50, 50));
|
||||
cButton.setMinimumSize(new java.awt.Dimension(50, 50));
|
||||
cButton.setPreferredSize(new java.awt.Dimension(50, 50));
|
||||
nunchukButtonsEventPanel.add(cButton);
|
||||
|
||||
zButton.setText("Z");
|
||||
zButton.setMaximumSize(new java.awt.Dimension(50, 50));
|
||||
zButton.setMinimumSize(new java.awt.Dimension(50, 50));
|
||||
zButton.setPreferredSize(new java.awt.Dimension(50, 50));
|
||||
nunchukButtonsEventPanel.add(zButton);
|
||||
zButton.setText("Z");
|
||||
zButton.setMaximumSize(new java.awt.Dimension(50, 50));
|
||||
zButton.setMinimumSize(new java.awt.Dimension(50, 50));
|
||||
zButton.setPreferredSize(new java.awt.Dimension(50, 50));
|
||||
nunchukButtonsEventPanel.add(zButton);
|
||||
|
||||
setNunchukValuesPanel.add(nunchukButtonsEventPanel);
|
||||
setNunchukValuesPanel.add(nunchukButtonsEventPanel);
|
||||
|
||||
nunchukOrientationTextField.setPreferredSize(new java.awt.Dimension(60,
|
||||
20));
|
||||
nunchukOrientationPanel.add(nunchukOrientationTextField);
|
||||
nunchukOrientationTextField.setPreferredSize(new java.awt.Dimension(60,
|
||||
20));
|
||||
nunchukOrientationPanel.add(nunchukOrientationTextField);
|
||||
|
||||
nunchukOrientationButton.setText("Set Orientation Threshold");
|
||||
nunchukOrientationButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
nunchukOrientationButtonMousePressed(evt);
|
||||
}
|
||||
});
|
||||
nunchukOrientationPanel.add(nunchukOrientationButton);
|
||||
nunchukOrientationButton.setText("Set Orientation Threshold");
|
||||
nunchukOrientationButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
nunchukOrientationButtonMousePressed(evt);
|
||||
}
|
||||
});
|
||||
nunchukOrientationPanel.add(nunchukOrientationButton);
|
||||
|
||||
setNunchukValuesPanel.add(nunchukOrientationPanel);
|
||||
setNunchukValuesPanel.add(nunchukOrientationPanel);
|
||||
|
||||
nunchukAccelerationTextField.setPreferredSize(new java.awt.Dimension(
|
||||
60, 20));
|
||||
nunchukAccelerationPanel.add(nunchukAccelerationTextField);
|
||||
nunchukAccelerationTextField.setPreferredSize(new java.awt.Dimension(
|
||||
60, 20));
|
||||
nunchukAccelerationPanel.add(nunchukAccelerationTextField);
|
||||
|
||||
nunchukAccelerationButton.setText("Set Acceleration Threshold");
|
||||
nunchukAccelerationButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
nunchukAccelerationButtonMousePressed(evt);
|
||||
}
|
||||
});
|
||||
nunchukAccelerationPanel.add(nunchukAccelerationButton);
|
||||
nunchukAccelerationButton.setText("Set Acceleration Threshold");
|
||||
nunchukAccelerationButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
nunchukAccelerationButtonMousePressed(evt);
|
||||
}
|
||||
});
|
||||
nunchukAccelerationPanel.add(nunchukAccelerationButton);
|
||||
|
||||
setNunchukValuesPanel.add(nunchukAccelerationPanel);
|
||||
setNunchukValuesPanel.add(nunchukAccelerationPanel);
|
||||
|
||||
messageText.setText("Message:");
|
||||
messageText.setText("Message:");
|
||||
|
||||
javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout(
|
||||
messagePanel);
|
||||
messagePanel.setLayout(messagePanelLayout);
|
||||
messagePanelLayout
|
||||
.setHorizontalGroup(messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 1216, Short.MAX_VALUE)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createSequentialGroup()
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE)
|
||||
.addComponent(
|
||||
messageText)
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE))));
|
||||
messagePanelLayout
|
||||
.setVerticalGroup(messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 34, Short.MAX_VALUE)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createSequentialGroup()
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE)
|
||||
.addComponent(
|
||||
messageText)
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE))));
|
||||
javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout(
|
||||
messagePanel);
|
||||
messagePanel.setLayout(messagePanelLayout);
|
||||
messagePanelLayout
|
||||
.setHorizontalGroup(messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 1216, Short.MAX_VALUE)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createSequentialGroup()
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE)
|
||||
.addComponent(
|
||||
messageText)
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE))));
|
||||
messagePanelLayout
|
||||
.setVerticalGroup(messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 34, Short.MAX_VALUE)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(
|
||||
messagePanelLayout
|
||||
.createSequentialGroup()
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE)
|
||||
.addComponent(
|
||||
messageText)
|
||||
.addGap(0, 0,
|
||||
Short.MAX_VALUE))));
|
||||
|
||||
setNunchukValuesPanel.add(messagePanel);
|
||||
setNunchukValuesPanel.add(messagePanel);
|
||||
|
||||
getContentPane().add(setNunchukValuesPanel);
|
||||
getContentPane().add(setNunchukValuesPanel);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void nunchukOrientationButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukOrientationButtonMousePressed
|
||||
try {
|
||||
float nb = Float.parseFloat(nunchukOrientationTextField.getText());
|
||||
wiimote.setNunchukOrientationThreshold(nb);
|
||||
messageText.setText("Nunchuk orientation threshold set to " + nb);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText
|
||||
.setText("Number is not an integer, nunchuk orientation threshold not set !");
|
||||
}
|
||||
}// GEN-LAST:event_nunchukOrientationButtonMousePressed
|
||||
private void nunchukOrientationButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukOrientationButtonMousePressed
|
||||
try {
|
||||
float nb = Float.parseFloat(nunchukOrientationTextField.getText());
|
||||
wiimote.setNunchukOrientationThreshold(nb);
|
||||
messageText.setText("Nunchuk orientation threshold set to " + nb);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText
|
||||
.setText("Number is not an integer, nunchuk orientation threshold not set !");
|
||||
}
|
||||
}// GEN-LAST:event_nunchukOrientationButtonMousePressed
|
||||
|
||||
private void nunchukAccelerationButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukAccelerationButtonMousePressed
|
||||
try {
|
||||
int nb = Integer.parseInt(nunchukAccelerationTextField.getText());
|
||||
wiimote.setNunchukAccelerationThreshold(nb);
|
||||
messageText.setText("Nunchuk acceleration threshold set to " + nb);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText
|
||||
.setText("Number is not an integer, nunchuk acceleration threshold not set !");
|
||||
}
|
||||
}// GEN-LAST:event_nunchukAccelerationButtonMousePressed
|
||||
private void nunchukAccelerationButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukAccelerationButtonMousePressed
|
||||
try {
|
||||
int nb = Integer.parseInt(nunchukAccelerationTextField.getText());
|
||||
wiimote.setNunchukAccelerationThreshold(nb);
|
||||
messageText.setText("Nunchuk acceleration threshold set to " + nb);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText
|
||||
.setText("Number is not an integer, nunchuk acceleration threshold not set !");
|
||||
}
|
||||
}// GEN-LAST:event_nunchukAccelerationButtonMousePressed
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
if (arg0 instanceof NunchukEvent) {
|
||||
NunchukEvent nunchuk = (NunchukEvent) arg0;
|
||||
NunchukButtonsEvent buttons = nunchuk.getButtonsEvent();
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
if (arg0 instanceof NunchukEvent) {
|
||||
NunchukEvent nunchuk = (NunchukEvent) arg0;
|
||||
NunchukButtonsEvent buttons = nunchuk.getButtonsEvent();
|
||||
|
||||
//C button
|
||||
if (buttons.isButtonCJustPressed()) {
|
||||
cButton.setEnabled(false);
|
||||
}else if (buttons.isButtonCJustReleased()) {
|
||||
cButton.setEnabled(true);
|
||||
}
|
||||
if (buttons.isButtonCJustPressed()) {
|
||||
cButton.setEnabled(false);
|
||||
}else if (buttons.isButtonCJustReleased()) {
|
||||
cButton.setEnabled(true);
|
||||
}
|
||||
|
||||
//Z button
|
||||
if(buttons.isButtonZJustPressed()) {
|
||||
zButton.setEnabled(false);
|
||||
}else if (buttons.isButtonZJustReleased()) {
|
||||
zButton.setEnabled(true);
|
||||
}
|
||||
zButton.setEnabled(false);
|
||||
}else if (buttons.isButtonZJustReleased()) {
|
||||
zButton.setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
if (isThresholdsRequested) {
|
||||
MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent();
|
||||
nunchukAccelerationTextField.setText(evt
|
||||
.getAccelerationThreshold()
|
||||
+ "");
|
||||
nunchukOrientationTextField.setText(evt
|
||||
.getOrientationThreshold()
|
||||
+ "");
|
||||
isThresholdsRequested = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isThresholdsRequested) {
|
||||
MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent();
|
||||
nunchukAccelerationTextField.setText(evt
|
||||
.getAccelerationThreshold()
|
||||
+ "");
|
||||
nunchukOrientationTextField.setText(evt
|
||||
.getOrientationThreshold()
|
||||
+ "");
|
||||
isThresholdsRequested = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onBalanceBoardInsertedEvent(
|
||||
BalanceBoardInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
public void onBalanceBoardRemovedEvent(
|
||||
BalanceBoardRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton cButton;
|
||||
private javax.swing.JPanel gForcePanel;
|
||||
private javax.swing.JPanel joystickEventsPanel;
|
||||
private javax.swing.JPanel messagePanel;
|
||||
private javax.swing.JLabel messageText;
|
||||
private javax.swing.JPanel motionSensingEventsPanel;
|
||||
private javax.swing.JTabbedPane motionSensingEventsTabbedPanels;
|
||||
private javax.swing.JButton nunchukAccelerationButton;
|
||||
private javax.swing.JPanel nunchukAccelerationPanel;
|
||||
private javax.swing.JTextField nunchukAccelerationTextField;
|
||||
private javax.swing.JPanel nunchukButtonsEventPanel;
|
||||
private javax.swing.JButton nunchukOrientationButton;
|
||||
private javax.swing.JPanel nunchukOrientationPanel;
|
||||
private javax.swing.JTextField nunchukOrientationTextField;
|
||||
private javax.swing.JPanel orientationPanel;
|
||||
private javax.swing.JPanel rawAccelerationPanel;
|
||||
private javax.swing.JPanel setNunchukValuesPanel;
|
||||
private javax.swing.JPanel topPanels;
|
||||
private javax.swing.JButton zButton;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton cButton;
|
||||
private javax.swing.JPanel gForcePanel;
|
||||
private javax.swing.JPanel joystickEventsPanel;
|
||||
private javax.swing.JPanel messagePanel;
|
||||
private javax.swing.JLabel messageText;
|
||||
private javax.swing.JPanel motionSensingEventsPanel;
|
||||
private javax.swing.JTabbedPane motionSensingEventsTabbedPanels;
|
||||
private javax.swing.JButton nunchukAccelerationButton;
|
||||
private javax.swing.JPanel nunchukAccelerationPanel;
|
||||
private javax.swing.JTextField nunchukAccelerationTextField;
|
||||
private javax.swing.JPanel nunchukButtonsEventPanel;
|
||||
private javax.swing.JButton nunchukOrientationButton;
|
||||
private javax.swing.JPanel nunchukOrientationPanel;
|
||||
private javax.swing.JTextField nunchukOrientationTextField;
|
||||
private javax.swing.JPanel orientationPanel;
|
||||
private javax.swing.JPanel rawAccelerationPanel;
|
||||
private javax.swing.JPanel setNunchukValuesPanel;
|
||||
private javax.swing.JPanel topPanels;
|
||||
private javax.swing.JButton zButton;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
@@ -44,346 +46,354 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
*/
|
||||
public class Tests implements WiimoteListener {
|
||||
|
||||
Robot robot;
|
||||
Robot robot;
|
||||
|
||||
private static int DISPLAY_EACH_VALUE = 1;
|
||||
private static int DUMP = 2;
|
||||
private static int MOVE_MOUSE = 3;
|
||||
private static int TEST_LEDS = 5;
|
||||
private static int DISPLAY_EACH_VALUE = 1;
|
||||
private static int DUMP = 2;
|
||||
private static int MOVE_MOUSE = 3;
|
||||
private static int TEST_LEDS = 5;
|
||||
|
||||
private Wiimote wiimote;
|
||||
private Wiimote wiimote;
|
||||
|
||||
int dump = DISPLAY_EACH_VALUE;
|
||||
int dump = DISPLAY_EACH_VALUE;
|
||||
|
||||
public Tests(Wiimote wim) {
|
||||
wiimote = wim;
|
||||
wiimote.addWiiMoteEventListeners(this);
|
||||
try {
|
||||
robot = new Robot();
|
||||
} catch (AWTException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public Tests(Wiimote wim) {
|
||||
wiimote = wim;
|
||||
wiimote.addWiiMoteEventListeners(this);
|
||||
try {
|
||||
robot = new Robot();
|
||||
} catch (AWTException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent e) {
|
||||
if (dump == DISPLAY_EACH_VALUE) {
|
||||
// System.out.println("*********** WIIMOTE ID : "+
|
||||
// e.getWiimoteId() + " **************");
|
||||
/* button ONE */
|
||||
if (e.isButtonOneJustPressed()) {
|
||||
System.out.println("button one pressed");
|
||||
}
|
||||
if (e.isButtonOneHeld()) {
|
||||
System.out.println("button one held");
|
||||
}
|
||||
if (e.isButtonOneJustReleased()) {
|
||||
System.out.println("button one released");
|
||||
}
|
||||
public void onButtonsEvent(WiimoteButtonsEvent e) {
|
||||
if (dump == DISPLAY_EACH_VALUE) {
|
||||
// System.out.println("*********** WIIMOTE ID : "+
|
||||
// e.getWiimoteId() + " **************");
|
||||
/* button ONE */
|
||||
if (e.isButtonOneJustPressed()) {
|
||||
System.out.println("button one pressed");
|
||||
}
|
||||
if (e.isButtonOneHeld()) {
|
||||
System.out.println("button one held");
|
||||
}
|
||||
if (e.isButtonOneJustReleased()) {
|
||||
System.out.println("button one released");
|
||||
}
|
||||
|
||||
/* button TWO */
|
||||
if (e.isButtonTwoJustPressed()) {
|
||||
System.out.println("button two pressed");
|
||||
}
|
||||
if (e.isButtonTwoHeld()) {
|
||||
System.out.println("button two held");
|
||||
}
|
||||
if (e.isButtonTwoJustReleased()) {
|
||||
System.out.println("button two released");
|
||||
}
|
||||
/* button TWO */
|
||||
if (e.isButtonTwoJustPressed()) {
|
||||
System.out.println("button two pressed");
|
||||
}
|
||||
if (e.isButtonTwoHeld()) {
|
||||
System.out.println("button two held");
|
||||
}
|
||||
if (e.isButtonTwoJustReleased()) {
|
||||
System.out.println("button two released");
|
||||
}
|
||||
|
||||
/* button A */
|
||||
if (e.isButtonAJustPressed()) {
|
||||
System.out.println("button A pressed");
|
||||
}
|
||||
if (e.isButtonAHeld()) {
|
||||
System.out.println("button A held");
|
||||
}
|
||||
if (e.isButtonAJustReleased()) {
|
||||
System.out.println("button A released");
|
||||
}
|
||||
/* button A */
|
||||
if (e.isButtonAJustPressed()) {
|
||||
System.out.println("button A pressed");
|
||||
}
|
||||
if (e.isButtonAHeld()) {
|
||||
System.out.println("button A held");
|
||||
}
|
||||
if (e.isButtonAJustReleased()) {
|
||||
System.out.println("button A released");
|
||||
}
|
||||
|
||||
/* button B */
|
||||
if (e.isButtonBJustPressed()) {
|
||||
System.out.println("button B pressed");
|
||||
}
|
||||
if (e.isButtonBHeld()) {
|
||||
System.out.println("button B held");
|
||||
}
|
||||
if (e.isButtonBJustReleased()) {
|
||||
System.out.println("button B released");
|
||||
}
|
||||
/* button B */
|
||||
if (e.isButtonBJustPressed()) {
|
||||
System.out.println("button B pressed");
|
||||
}
|
||||
if (e.isButtonBHeld()) {
|
||||
System.out.println("button B held");
|
||||
}
|
||||
if (e.isButtonBJustReleased()) {
|
||||
System.out.println("button B released");
|
||||
}
|
||||
|
||||
/* button LEFT */
|
||||
if (e.isButtonLeftJustPressed()) {
|
||||
System.out.println("button Left pressed");
|
||||
}
|
||||
if (e.isButtonLeftHeld()) {
|
||||
System.out.println("button Left held");
|
||||
}
|
||||
if (e.isButtonLeftJustReleased()) {
|
||||
System.out.println("button Left released");
|
||||
}
|
||||
/* button LEFT */
|
||||
if (e.isButtonLeftJustPressed()) {
|
||||
System.out.println("button Left pressed");
|
||||
}
|
||||
if (e.isButtonLeftHeld()) {
|
||||
System.out.println("button Left held");
|
||||
}
|
||||
if (e.isButtonLeftJustReleased()) {
|
||||
System.out.println("button Left released");
|
||||
}
|
||||
|
||||
/* button RIGHT */
|
||||
if (e.isButtonRightJustPressed()) {
|
||||
System.out.println("button Right pressed");
|
||||
}
|
||||
if (e.isButtonRightHeld()) {
|
||||
System.out.println("button Right held");
|
||||
}
|
||||
if (e.isButtonRightJustReleased()) {
|
||||
System.out.println("button Right released");
|
||||
}
|
||||
/* button RIGHT */
|
||||
if (e.isButtonRightJustPressed()) {
|
||||
System.out.println("button Right pressed");
|
||||
}
|
||||
if (e.isButtonRightHeld()) {
|
||||
System.out.println("button Right held");
|
||||
}
|
||||
if (e.isButtonRightJustReleased()) {
|
||||
System.out.println("button Right released");
|
||||
}
|
||||
|
||||
/* button UP */
|
||||
if (e.isButtonUpJustPressed()) {
|
||||
System.out.println("button UP pressed");
|
||||
}
|
||||
if (e.isButtonUpHeld()) {
|
||||
System.out.println("button UP held");
|
||||
}
|
||||
if (e.isButtonUpJustReleased()) {
|
||||
System.out.println("button UP released");
|
||||
}
|
||||
/* button UP */
|
||||
if (e.isButtonUpJustPressed()) {
|
||||
System.out.println("button UP pressed");
|
||||
}
|
||||
if (e.isButtonUpHeld()) {
|
||||
System.out.println("button UP held");
|
||||
}
|
||||
if (e.isButtonUpJustReleased()) {
|
||||
System.out.println("button UP released");
|
||||
}
|
||||
|
||||
/* button DOWN */
|
||||
if (e.isButtonDownJustPressed()) {
|
||||
System.out.println("button DOWN pressed");
|
||||
}
|
||||
if (e.isButtonDownHeld()) {
|
||||
System.out.println("button DOWN held");
|
||||
}
|
||||
if (e.isButtonDownJustReleased()) {
|
||||
System.out.println("button DOWN released");
|
||||
}
|
||||
/* button DOWN */
|
||||
if (e.isButtonDownJustPressed()) {
|
||||
System.out.println("button DOWN pressed");
|
||||
}
|
||||
if (e.isButtonDownHeld()) {
|
||||
System.out.println("button DOWN held");
|
||||
}
|
||||
if (e.isButtonDownJustReleased()) {
|
||||
System.out.println("button DOWN released");
|
||||
}
|
||||
|
||||
/* button MINUS */
|
||||
if (e.isButtonMinusJustPressed()) {
|
||||
System.out.println("button MINUS pressed");
|
||||
}
|
||||
if (e.isButtonMinusHeld()) {
|
||||
System.out.println("button MINUS held");
|
||||
}
|
||||
if (e.isButtonMinusJustReleased()) {
|
||||
System.out.println("button MINUS released");
|
||||
}
|
||||
/* button MINUS */
|
||||
if (e.isButtonMinusJustPressed()) {
|
||||
System.out.println("button MINUS pressed");
|
||||
}
|
||||
if (e.isButtonMinusHeld()) {
|
||||
System.out.println("button MINUS held");
|
||||
}
|
||||
if (e.isButtonMinusJustReleased()) {
|
||||
System.out.println("button MINUS released");
|
||||
}
|
||||
|
||||
/* button PLUS */
|
||||
if (e.isButtonPlusJustPressed()) {
|
||||
System.out.println("button PLUS pressed");
|
||||
}
|
||||
if (e.isButtonPlusHeld()) {
|
||||
System.out.println("button PLUS held");
|
||||
}
|
||||
if (e.isButtonPlusJustReleased()) {
|
||||
System.out.println("button PLUS released");
|
||||
}
|
||||
/* button PLUS */
|
||||
if (e.isButtonPlusJustPressed()) {
|
||||
System.out.println("button PLUS pressed");
|
||||
}
|
||||
if (e.isButtonPlusHeld()) {
|
||||
System.out.println("button PLUS held");
|
||||
}
|
||||
if (e.isButtonPlusJustReleased()) {
|
||||
System.out.println("button PLUS released");
|
||||
}
|
||||
|
||||
/* button HOME */
|
||||
if (e.isButtonHomeJustPressed()) {
|
||||
System.out.println("button HOME pressed");
|
||||
}
|
||||
if (e.isButtonHomeHeld()) {
|
||||
System.out.println("button HOME held");
|
||||
}
|
||||
if (e.isButtonHomeJustReleased()) {
|
||||
System.out.println("button HOME released");
|
||||
}
|
||||
/* button HOME */
|
||||
if (e.isButtonHomeJustPressed()) {
|
||||
System.out.println("button HOME pressed");
|
||||
}
|
||||
if (e.isButtonHomeHeld()) {
|
||||
System.out.println("button HOME held");
|
||||
}
|
||||
if (e.isButtonHomeJustReleased()) {
|
||||
System.out.println("button HOME released");
|
||||
}
|
||||
|
||||
/* get status */
|
||||
if (e.isButtonUpJustPressed()) {
|
||||
wiimote.getStatus();
|
||||
}
|
||||
/* get status */
|
||||
if (e.isButtonUpJustPressed()) {
|
||||
wiimote.getStatus();
|
||||
}
|
||||
|
||||
/* Activate rumble */
|
||||
if (e.isButtonOneJustPressed()) {
|
||||
System.out.println("Rumble Activated");
|
||||
wiimote.activateRumble();
|
||||
}
|
||||
if (e.isButtonTwoJustPressed()) {
|
||||
System.out.println("Rumble Deactivated");
|
||||
wiimote.deactivateRumble();
|
||||
}
|
||||
/* Activate rumble */
|
||||
if (e.isButtonOneJustPressed()) {
|
||||
System.out.println("Rumble Activated");
|
||||
wiimote.activateRumble();
|
||||
}
|
||||
if (e.isButtonTwoJustPressed()) {
|
||||
System.out.println("Rumble Deactivated");
|
||||
wiimote.deactivateRumble();
|
||||
}
|
||||
|
||||
/* Activate IR Tracking */
|
||||
if (e.isButtonAJustPressed()) {
|
||||
System.out.println("IR Activated");
|
||||
wiimote.activateIRTRacking();
|
||||
}
|
||||
if (e.isButtonBJustPressed()) {
|
||||
System.out.println("IR Deactivated");
|
||||
wiimote.deactivateIRTRacking();
|
||||
}
|
||||
/* Activate IR Tracking */
|
||||
if (e.isButtonAJustPressed()) {
|
||||
System.out.println("IR Activated");
|
||||
wiimote.activateIRTRacking();
|
||||
}
|
||||
if (e.isButtonBJustPressed()) {
|
||||
System.out.println("IR Deactivated");
|
||||
wiimote.deactivateIRTRacking();
|
||||
}
|
||||
|
||||
/* Activate Motion sensing */
|
||||
if (e.isButtonPlusJustPressed()) {
|
||||
System.out.println("Motion sensing Activated");
|
||||
wiimote.activateMotionSensing();
|
||||
}
|
||||
if (e.isButtonMinusJustPressed()) {
|
||||
System.out.println("Motion sensing Deactivated");
|
||||
wiimote.deactivateMotionSensing();
|
||||
}
|
||||
/* Activate Motion sensing */
|
||||
if (e.isButtonPlusJustPressed()) {
|
||||
System.out.println("Motion sensing Activated");
|
||||
wiimote.activateMotionSensing();
|
||||
}
|
||||
if (e.isButtonMinusJustPressed()) {
|
||||
System.out.println("Motion sensing Deactivated");
|
||||
wiimote.deactivateMotionSensing();
|
||||
}
|
||||
|
||||
/* leave test */
|
||||
if (e.isButtonHomeJustPressed()) {
|
||||
System.out.println("LEAVING TEST");
|
||||
wiimote.disconnect();
|
||||
WiiUseApiManager.definitiveShutdown();
|
||||
}
|
||||
/* leave test */
|
||||
if (e.isButtonHomeJustPressed()) {
|
||||
System.out.println("LEAVING TEST");
|
||||
wiimote.disconnect();
|
||||
WiiUseApiManager.definitiveShutdown();
|
||||
}
|
||||
|
||||
} else if (dump == DUMP) {
|
||||
System.out.println(e);
|
||||
/* Activate all */
|
||||
if (e.isButtonAJustPressed()) {
|
||||
System.out.println("IR, rumble and motion sensing Activated");
|
||||
wiimote.activateIRTRacking();
|
||||
wiimote.activateMotionSensing();
|
||||
wiimote.activateRumble();
|
||||
}
|
||||
if (e.isButtonBJustPressed()) {
|
||||
System.out.println("IR, rumble and motion sensing Deactivated");
|
||||
wiimote.deactivateIRTRacking();
|
||||
wiimote.deactivateMotionSensing();
|
||||
wiimote.deactivateRumble();
|
||||
}
|
||||
} else if (dump == DUMP) {
|
||||
System.out.println(e);
|
||||
/* Activate all */
|
||||
if (e.isButtonAJustPressed()) {
|
||||
System.out.println("IR, rumble and motion sensing Activated");
|
||||
wiimote.activateIRTRacking();
|
||||
wiimote.activateMotionSensing();
|
||||
wiimote.activateRumble();
|
||||
}
|
||||
if (e.isButtonBJustPressed()) {
|
||||
System.out.println("IR, rumble and motion sensing Deactivated");
|
||||
wiimote.deactivateIRTRacking();
|
||||
wiimote.deactivateMotionSensing();
|
||||
wiimote.deactivateRumble();
|
||||
}
|
||||
|
||||
/* leave test */
|
||||
if (e.isButtonHomeJustPressed()) {
|
||||
System.out.println("LEAVING TEST");
|
||||
wiimote.disconnect();
|
||||
}
|
||||
} else if (dump == MOVE_MOUSE) {
|
||||
/* Activate IR Tracking */
|
||||
if (e.isButtonOneJustPressed()) {
|
||||
System.out.println("IR Activated");
|
||||
wiimote.activateIRTRacking();
|
||||
}
|
||||
if (e.isButtonTwoJustPressed()) {
|
||||
System.out.println("IR Deactivated");
|
||||
wiimote.deactivateIRTRacking();
|
||||
}
|
||||
/* leave test */
|
||||
if (e.isButtonHomeJustPressed()) {
|
||||
System.out.println("LEAVING TEST");
|
||||
wiimote.disconnect();
|
||||
}
|
||||
} else if (dump == MOVE_MOUSE) {
|
||||
/* Activate IR Tracking */
|
||||
if (e.isButtonOneJustPressed()) {
|
||||
System.out.println("IR Activated");
|
||||
wiimote.activateIRTRacking();
|
||||
}
|
||||
if (e.isButtonTwoJustPressed()) {
|
||||
System.out.println("IR Deactivated");
|
||||
wiimote.deactivateIRTRacking();
|
||||
}
|
||||
|
||||
/* button A */
|
||||
if (e.isButtonAJustPressed()) {
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
if (e.isButtonAJustReleased()) {
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
/* button A */
|
||||
if (e.isButtonAJustPressed()) {
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
if (e.isButtonAJustReleased()) {
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
|
||||
/* button B */
|
||||
if (e.isButtonBJustPressed()) {
|
||||
robot.mousePress(InputEvent.BUTTON2_MASK);
|
||||
}
|
||||
if (e.isButtonBJustReleased()) {
|
||||
robot.mouseRelease(InputEvent.BUTTON2_MASK);
|
||||
}
|
||||
/* button B */
|
||||
if (e.isButtonBJustPressed()) {
|
||||
robot.mousePress(InputEvent.BUTTON2_MASK);
|
||||
}
|
||||
if (e.isButtonBJustReleased()) {
|
||||
robot.mouseRelease(InputEvent.BUTTON2_MASK);
|
||||
}
|
||||
|
||||
/* leave test */
|
||||
if (e.isButtonHomeJustPressed()) {
|
||||
System.out.println("LEAVING TEST");
|
||||
wiimote.disconnect();
|
||||
}
|
||||
} else if (dump == TEST_LEDS) {
|
||||
wiimote.activateMotionSensing();
|
||||
if (e.isButtonUpJustPressed()) {
|
||||
wiimote.setLeds(true, false, false, false);
|
||||
}
|
||||
if (e.isButtonDownJustPressed()) {
|
||||
wiimote.setLeds(false, true, false, false);
|
||||
}
|
||||
if (e.isButtonLeftJustPressed()) {
|
||||
wiimote.setLeds(false, false, true, false);
|
||||
}
|
||||
if (e.isButtonRightJustPressed()) {
|
||||
wiimote.setLeds(false, false, false, true);
|
||||
}
|
||||
/* leave test */
|
||||
if (e.isButtonHomeJustPressed()) {
|
||||
System.out.println("LEAVING TEST");
|
||||
wiimote.disconnect();
|
||||
}
|
||||
} else if (dump == TEST_LEDS) {
|
||||
wiimote.activateMotionSensing();
|
||||
if (e.isButtonUpJustPressed()) {
|
||||
wiimote.setLeds(true, false, false, false);
|
||||
}
|
||||
if (e.isButtonDownJustPressed()) {
|
||||
wiimote.setLeds(false, true, false, false);
|
||||
}
|
||||
if (e.isButtonLeftJustPressed()) {
|
||||
wiimote.setLeds(false, false, true, false);
|
||||
}
|
||||
if (e.isButtonRightJustPressed()) {
|
||||
wiimote.setLeds(false, false, false, true);
|
||||
}
|
||||
|
||||
/* leave test */
|
||||
if (e.isButtonHomeJustPressed()) {
|
||||
System.out.println("LEAVING TEST");
|
||||
wiimote.disconnect();
|
||||
}
|
||||
}
|
||||
/* leave test */
|
||||
if (e.isButtonHomeJustPressed()) {
|
||||
System.out.println("LEAVING TEST");
|
||||
wiimote.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent e) {
|
||||
if (dump == MOVE_MOUSE) {
|
||||
IRSource[] list = e.getIRPoints();
|
||||
if (list.length > 0) {
|
||||
int x1 = (int) list[0].getX();
|
||||
int y1 = (int) list[0].getY();
|
||||
public void onIrEvent(IREvent e) {
|
||||
if (dump == MOVE_MOUSE) {
|
||||
IRSource[] list = e.getIRPoints();
|
||||
if (list.length > 0) {
|
||||
int x1 = (int) list[0].getX();
|
||||
int y1 = (int) list[0].getY();
|
||||
|
||||
int mousex = (int) Math.round(((double) x1 / 1024.0) * 1280.0);
|
||||
int mousey = (int) Math.round(((double) y1 / 768.0) * 1024.0);
|
||||
robot.mouseMove(mousex, mousey);
|
||||
}
|
||||
} else {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
int mousex = (int) Math.round(((double) x1 / 1024.0) * 1280.0);
|
||||
int mousey = (int) Math.round(((double) y1 / 768.0) * 1024.0);
|
||||
robot.mouseMove(mousex, mousey);
|
||||
}
|
||||
} else {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent e) {
|
||||
/* display motion sensing */
|
||||
public void onMotionSensingEvent(MotionSensingEvent e) {
|
||||
/* display motion sensing */
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent e) {
|
||||
// Display status variables
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent e) {
|
||||
System.out.println(" wiimote " + e.getWiimoteId()
|
||||
+ "has been disconnected !!");
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
public void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent e) {
|
||||
// Display status variables
|
||||
System.out.println(e);
|
||||
}
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
|
||||
if (wiimotes.length > 0) {
|
||||
System.out.println(wiimotes[0]);
|
||||
new Tests(wiimotes[0]);
|
||||
} else {
|
||||
System.out.println("No wiimotes found !!!");
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent e) {
|
||||
System.out.println(" wiimote " + e.getWiimoteId()
|
||||
+ "has been disconnected !!");
|
||||
}
|
||||
// java.util.Timer timer = new java.util.Timer();
|
||||
// timer.scheduleAtFixedRate(new LedsTask(), 0, 100);
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
|
||||
if (wiimotes.length > 0) {
|
||||
System.out.println(wiimotes[0]);
|
||||
new Tests(wiimotes[0]);
|
||||
} else {
|
||||
System.out.println("No wiimotes found !!!");
|
||||
}
|
||||
|
||||
// java.util.Timer timer = new java.util.Timer();
|
||||
// timer.scheduleAtFixedRate(new LedsTask(), 0, 100);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user