Move source files to gradle project layout

This commit is contained in:
2014-11-24 22:53:55 +00:00
parent 0f697f7c4d
commit 1536be84f3
76 changed files with 7991 additions and 7942 deletions

6
.classpath Normal file
View File

@@ -0,0 +1,6 @@
<?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>

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build/

View File

@@ -0,0 +1 @@
#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 Normal file
View File

@@ -0,0 +1,18 @@
<?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>

View File

@@ -0,0 +1,10 @@
#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=;

View File

@@ -0,0 +1,4 @@
#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=

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -1,34 +1,34 @@
EXPORTS EXPORTS
Java_wiiusej_WiiUseApi_connect Java_wiiusej_WiiUseApi_connect
Java_wiiusej_WiiUseApi_find Java_wiiusej_WiiUseApi_find
Java_wiiusej_WiiUseApi_init Java_wiiusej_WiiUseApi_init
Java_wiiusej_WiiUseApi_closeConnection Java_wiiusej_WiiUseApi_closeConnection
Java_wiiusej_WiiUseApi_getUnId Java_wiiusej_WiiUseApi_getUnId
Java_wiiusej_WiiUseApi_cleanUp Java_wiiusej_WiiUseApi_cleanUp
Java_wiiusej_WiiUseApi_activateRumble Java_wiiusej_WiiUseApi_activateRumble
Java_wiiusej_WiiUseApi_deactivateRumble Java_wiiusej_WiiUseApi_deactivateRumble
Java_wiiusej_WiiUseApi_activateIRTracking Java_wiiusej_WiiUseApi_activateIRTracking
Java_wiiusej_WiiUseApi_deactivateIRTracking Java_wiiusej_WiiUseApi_deactivateIRTracking
Java_wiiusej_WiiUseApi_activateMotionSensing Java_wiiusej_WiiUseApi_activateMotionSensing
Java_wiiusej_WiiUseApi_deactivateMotionSensing Java_wiiusej_WiiUseApi_deactivateMotionSensing
Java_wiiusej_WiiUseApi_setLeds Java_wiiusej_WiiUseApi_setLeds
Java_wiiusej_WiiUseApi_setOrientThreshold Java_wiiusej_WiiUseApi_setOrientThreshold
Java_wiiusej_WiiUseApi_setAccelThreshold Java_wiiusej_WiiUseApi_setAccelThreshold
Java_wiiusej_WiiUseApi_setAlphaSmoothing Java_wiiusej_WiiUseApi_setAlphaSmoothing
Java_wiiusej_WiiUseApi_reSync Java_wiiusej_WiiUseApi_reSync
Java_wiiusej_WiiUseApi_activateSmoothing Java_wiiusej_WiiUseApi_activateSmoothing
Java_wiiusej_WiiUseApi_deactivateSmoothing Java_wiiusej_WiiUseApi_deactivateSmoothing
Java_wiiusej_WiiUseApi_activateContinuous Java_wiiusej_WiiUseApi_activateContinuous
Java_wiiusej_WiiUseApi_deactivateContinuous Java_wiiusej_WiiUseApi_deactivateContinuous
Java_wiiusej_WiiUseApi_setScreenRatio43 Java_wiiusej_WiiUseApi_setScreenRatio43
Java_wiiusej_WiiUseApi_setScreenRatio169 Java_wiiusej_WiiUseApi_setScreenRatio169
Java_wiiusej_WiiUseApi_setSensorBarAboveScreen Java_wiiusej_WiiUseApi_setSensorBarAboveScreen
Java_wiiusej_WiiUseApi_setSensorBarBelowScreen Java_wiiusej_WiiUseApi_setSensorBarBelowScreen
Java_wiiusej_WiiUseApi_setVirtualScreenResolution Java_wiiusej_WiiUseApi_setVirtualScreenResolution
Java_wiiusej_WiiUseApi_getStatus Java_wiiusej_WiiUseApi_getStatus
Java_wiiusej_WiiUseApi_setTimeout Java_wiiusej_WiiUseApi_setTimeout
Java_wiiusej_WiiUseApi_setIrSensitivity Java_wiiusej_WiiUseApi_setIrSensitivity
Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold
Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold
Java_wiiusej_WiiUseApi_windowsSetBluetoothStack Java_wiiusej_WiiUseApi_windowsSetBluetoothStack
Java_wiiusej_WiiUseApi_specialPoll Java_wiiusej_WiiUseApi_specialPoll

View File

@@ -1,277 +1,277 @@
/* DO NOT EDIT THIS FILE - it is machine generated */ /* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h> #include <jni.h>
/* Header for class wiiusej_WiiUseApi */ /* Header for class wiiusej_WiiUseApi */
#ifndef _Included_wiiusej_WiiUseApi #ifndef _Included_wiiusej_WiiUseApi
#define _Included_wiiusej_WiiUseApi #define _Included_wiiusej_WiiUseApi
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: connect * Method: connect
* Signature: (I)I * Signature: (I)I
*/ */
JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_connect JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_connect
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: find * Method: find
* Signature: (II)I * Signature: (II)I
*/ */
JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_find JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_find
(JNIEnv *, jobject, jint, jint); (JNIEnv *, jobject, jint, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: init * Method: init
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_init JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_init
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: closeConnection * Method: closeConnection
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: getUnId * Method: getUnId
* Signature: (I)I * Signature: (I)I
*/ */
JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_getUnId JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_getUnId
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: cleanUp * Method: cleanUp
* Signature: ()V * Signature: ()V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_cleanUp JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_cleanUp
(JNIEnv *, jobject); (JNIEnv *, jobject);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: activateRumble * Method: activateRumble
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: deactivateRumble * Method: deactivateRumble
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: activateIRTracking * Method: activateIRTracking
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: deactivateIRTracking * Method: deactivateIRTracking
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: activateMotionSensing * Method: activateMotionSensing
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: deactivateMotionSensing * Method: deactivateMotionSensing
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setLeds * Method: setLeds
* Signature: (IZZZZ)V * Signature: (IZZZZ)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds
(JNIEnv *, jobject, jint, jboolean, jboolean, jboolean, jboolean); (JNIEnv *, jobject, jint, jboolean, jboolean, jboolean, jboolean);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setOrientThreshold * Method: setOrientThreshold
* Signature: (IF)V * Signature: (IF)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold
(JNIEnv *, jobject, jint, jfloat); (JNIEnv *, jobject, jint, jfloat);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setAccelThreshold * Method: setAccelThreshold
* Signature: (II)V * Signature: (II)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold
(JNIEnv *, jobject, jint, jint); (JNIEnv *, jobject, jint, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setAlphaSmoothing * Method: setAlphaSmoothing
* Signature: (IF)V * Signature: (IF)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing
(JNIEnv *, jobject, jint, jfloat); (JNIEnv *, jobject, jint, jfloat);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: reSync * Method: reSync
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_reSync JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_reSync
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: activateSmoothing * Method: activateSmoothing
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: deactivateSmoothing * Method: deactivateSmoothing
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: activateContinuous * Method: activateContinuous
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: deactivateContinuous * Method: deactivateContinuous
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setScreenRatio43 * Method: setScreenRatio43
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43 JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setScreenRatio169 * Method: setScreenRatio169
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169 JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setSensorBarAboveScreen * Method: setSensorBarAboveScreen
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setSensorBarBelowScreen * Method: setSensorBarBelowScreen
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setVirtualScreenResolution * Method: setVirtualScreenResolution
* Signature: (III)V * Signature: (III)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution
(JNIEnv *, jobject, jint, jint, jint); (JNIEnv *, jobject, jint, jint, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: getStatus * Method: getStatus
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setTimeout * Method: setTimeout
* Signature: (ISS)V * Signature: (ISS)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setTimeout JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setTimeout
(JNIEnv *, jobject, jint, jshort, jshort); (JNIEnv *, jobject, jint, jshort, jshort);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setIrSensitivity * Method: setIrSensitivity
* Signature: (II)V * Signature: (II)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setIrSensitivity JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setIrSensitivity
(JNIEnv *, jobject, jint, jint); (JNIEnv *, jobject, jint, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setNunchukOrientationThreshold * Method: setNunchukOrientationThreshold
* Signature: (IF)V * Signature: (IF)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold
(JNIEnv *, jobject, jint, jfloat); (JNIEnv *, jobject, jint, jfloat);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: setNunchukAccelerationThreshold * Method: setNunchukAccelerationThreshold
* Signature: (II)V * Signature: (II)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold
(JNIEnv *, jobject, jint, jint); (JNIEnv *, jobject, jint, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: windowsSetBluetoothStack * Method: windowsSetBluetoothStack
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_windowsSetBluetoothStack JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_windowsSetBluetoothStack
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: specialPoll * Method: specialPoll
* Signature: (Lwiiusej/wiiusejevents/utils/EventsGatherer;)V * Signature: (Lwiiusej/wiiusejevents/utils/EventsGatherer;)V
*/ */
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
(JNIEnv *, jobject, jobject); (JNIEnv *, jobject, jobject);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@@ -1,351 +1,351 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej; package wiiusej;
import wiiusej.wiiusejevents.utils.EventsGatherer; import wiiusej.wiiusejevents.utils.EventsGatherer;
/** /**
* Singleton used to manipulate WiiUse Api. * Singleton used to manipulate WiiUse Api.
* *
* @author guiguito * @author guiguito
*/ */
public class WiiUseApi { public class WiiUseApi {
static { static {
System.loadLibrary("WiiuseJ"); System.loadLibrary("WiiuseJ");
} }
private static WiiUseApi instance = new WiiUseApi(); private static WiiUseApi instance = new WiiUseApi();
/** /**
* Get the only instance of WiiUseApi. * Get the only instance of WiiUseApi.
* *
* @return the only instace of WiiUseApi. * @return the only instace of WiiUseApi.
*/ */
protected static WiiUseApi getInstance() { protected static WiiUseApi getInstance() {
return instance; return instance;
} }
/** /**
* Connect to a wiimote or wiimotes once an address is known. * Connect to a wiimote or wiimotes once an address is known.
* *
* @param nbWiimotes * @param nbWiimotes
* The number of wiimotes. * The number of wiimotes.
* @return The number of wiimotes that successfully connected. * @return The number of wiimotes that successfully connected.
*/ */
synchronized native int connect(int nbWiimotes); synchronized native int connect(int nbWiimotes);
/** /**
* Find a wiimote or wiimotes. * Find a wiimote or wiimotes.
* *
* @param nbMaxWiimotes * @param nbMaxWiimotes
* The number of wiimotes. * The number of wiimotes.
* @param timeout * @param timeout
* The number of seconds before the search times out. * The number of seconds before the search times out.
* @return The number of wiimotes found. * @return The number of wiimotes found.
*/ */
synchronized native int find(int nbMaxWiimotes, int timeout); synchronized native int find(int nbMaxWiimotes, int timeout);
/** /**
* Initialize an array of wiimote structures (for the C side of the * Initialize an array of wiimote structures (for the C side of the
* library). * library).
* *
* @param nbPossibleWiimotes * @param nbPossibleWiimotes
* size of the array. * size of the array.
*/ */
synchronized native void init(int nbPossibleWiimotes); synchronized native void init(int nbPossibleWiimotes);
/** /**
* Close connection to the wiimote with the given id. * Close connection to the wiimote with the given id.
* *
*/ */
synchronized native void closeConnection(int id); synchronized native void closeConnection(int id);
/** /**
* Get unique id of a wiimote in the wiimotes array. Please make sure you * Get unique id of a wiimote in the wiimotes array. Please make sure you
* call an existing index with a wiimote initialized at this index, other * call an existing index with a wiimote initialized at this index, other
* wise you'll get a wrong value. * wise you'll get a wrong value.
* *
* @param index * @param index
* index of the wiimote in the wiimotes array. * index of the wiimote in the wiimotes array.
* @return the unid of the wiimote, or a wrong value if the index was false. * @return the unid of the wiimote, or a wrong value if the index was false.
* *
*/ */
synchronized native int getUnId(int index); synchronized native int getUnId(int index);
/** /**
* CleanUp Wiiuse API. * CleanUp Wiiuse API.
*/ */
synchronized native void cleanUp(); synchronized native void cleanUp();
/** /**
* Activate rumble on the wiimote with the given id. * Activate rumble on the wiimote with the given id.
* *
* @param id * @param id
* the id of the wiimote. * the id of the wiimote.
*/ */
synchronized native void activateRumble(int id); synchronized native void activateRumble(int id);
/** /**
* Deactivate rumble on the wiimote with the given id. * Deactivate rumble on the wiimote with the given id.
* *
* @param id * @param id
* the id of the wiimote. * the id of the wiimote.
*/ */
synchronized native void deactivateRumble(int id); synchronized native void deactivateRumble(int id);
/** /**
* Activate IR Tracking on the wiimote with the given id. * Activate IR Tracking on the wiimote with the given id.
* *
* @param id * @param id
* the id of the wiimote. * the id of the wiimote.
*/ */
synchronized native void activateIRTracking(int id); synchronized native void activateIRTracking(int id);
/** /**
* Deactivate IR Tracking on the wiimote with the given id. * Deactivate IR Tracking on the wiimote with the given id.
* *
* @param id * @param id
* the id of the wiimote. * the id of the wiimote.
*/ */
synchronized native void deactivateIRTracking(int id); synchronized native void deactivateIRTracking(int id);
/** /**
* Activate motion sensing on the wiimote with the given id. * Activate motion sensing on the wiimote with the given id.
* *
* @param id * @param id
* the id of the wiimote. * the id of the wiimote.
*/ */
synchronized native void activateMotionSensing(int id); synchronized native void activateMotionSensing(int id);
/** /**
* Deactivate motion sensing on the wiimote with the given id. * Deactivate motion sensing on the wiimote with the given id.
* *
* @param id * @param id
* the id of the wiimote. * the id of the wiimote.
*/ */
synchronized native void deactivateMotionSensing(int id); synchronized native void deactivateMotionSensing(int id);
/** /**
* Set wiimote leds status. * Set wiimote leds status.
* *
* @param id * @param id
* the id of the wiimote concerned. * the id of the wiimote concerned.
* @param led1 * @param led1
* status of led1: True=ON, False=OFF. * status of led1: True=ON, False=OFF.
* @param led2 * @param led2
* status of led2: True=ON, False=OFF. * status of led2: True=ON, False=OFF.
* @param led3 * @param led3
* status of led3: True=ON, False=OFF. * status of led3: True=ON, False=OFF.
* @param led4 * @param led4
* status of led4: True=ON, False=OFF. * status of led4: True=ON, False=OFF.
*/ */
synchronized native void setLeds(int id, boolean led1, boolean led2, synchronized native void setLeds(int id, boolean led1, boolean led2,
boolean led3, boolean led4); boolean led3, boolean led4);
/** /**
* Set how many degrees an angle must change to generate an event. * Set how many degrees an angle must change to generate an event.
* *
* @param id * @param id
* id of the wiimote concerned. * id of the wiimote concerned.
* @param angle * @param angle
* minimum angle detected by an event. * minimum angle detected by an event.
*/ */
synchronized native void setOrientThreshold(int id, float angle); synchronized native void setOrientThreshold(int id, float angle);
/** /**
* Set how much acceleration must change to generate an event. * Set how much acceleration must change to generate an event.
* *
* @param id * @param id
* id of the wiimote concerned. * id of the wiimote concerned.
* @param value * @param value
* minimum value detected by an event. * minimum value detected by an event.
*/ */
synchronized native void setAccelThreshold(int id, int value); synchronized native void setAccelThreshold(int id, int value);
/** /**
* Set alpha smoothing parameter for the given id. * Set alpha smoothing parameter for the given id.
* *
* @param id * @param id
* id of the wiimote concerned. * id of the wiimote concerned.
* @param value * @param value
* alpha smoothing value. * alpha smoothing value.
*/ */
synchronized native void setAlphaSmoothing(int id, float value); synchronized native void setAlphaSmoothing(int id, float value);
/** /**
* Try to resync with the wiimote by starting a new handshake. * Try to resync with the wiimote by starting a new handshake.
* *
* @param id * @param id
* id of the wiimote concerned. * id of the wiimote concerned.
*/ */
synchronized native void reSync(int id); synchronized native void reSync(int id);
/** /**
* Make the the accelerometers give smoother results. This is set by * Make the the accelerometers give smoother results. This is set by
* default. * default.
* *
* @param id * @param id
* the id of the wiimote concerned. * the id of the wiimote concerned.
*/ */
synchronized native void activateSmoothing(int id); synchronized native void activateSmoothing(int id);
/** /**
* Make the the accelerometers give raw results. * Make the the accelerometers give raw results.
* *
* @param id * @param id
* the id of the wiimote concerned. * the id of the wiimote concerned.
*/ */
synchronized native void deactivateSmoothing(int id); synchronized native void deactivateSmoothing(int id);
/** /**
* Make the wiimote generate an event each time we poll. Not set by default. * Make the wiimote generate an event each time we poll. Not set by default.
* *
* @param id * @param id
* the id of the wiimote concerned. * the id of the wiimote concerned.
*/ */
synchronized native void activateContinuous(int id); synchronized native void activateContinuous(int id);
/** /**
* Make the wiimote generate an event only when there is one. * Make the wiimote generate an event only when there is one.
* *
* @param id * @param id
* the id of the wiimote concerned. * the id of the wiimote concerned.
*/ */
synchronized native void deactivateContinuous(int id); synchronized native void deactivateContinuous(int id);
/** /**
* Notify wiiuse that your screen has an aspect ratio of 4/3. * Notify wiiuse that your screen has an aspect ratio of 4/3.
* *
* @param id * @param id
* the id of the wiimote of which we want the status. * the id of the wiimote of which we want the status.
*/ */
synchronized native void setScreenRatio43(int id); synchronized native void setScreenRatio43(int id);
/** /**
* Notify wiiuse that your screen has an aspect ratio of 16/9. * Notify wiiuse that your screen has an aspect ratio of 16/9.
* *
* @param id * @param id
* the id of the wiimote of which we want the status. * the id of the wiimote of which we want the status.
*/ */
synchronized native void setScreenRatio169(int id); synchronized native void setScreenRatio169(int id);
/** /**
* Notify wiiuse that the sensor bar is above your screen. * Notify wiiuse that the sensor bar is above your screen.
* *
* @param id * @param id
* the id of the wiimote of which we want the status. * the id of the wiimote of which we want the status.
*/ */
synchronized native void setSensorBarAboveScreen(int id); synchronized native void setSensorBarAboveScreen(int id);
/** /**
* Notify wiiuse that the sensor bar is below your screen. * Notify wiiuse that the sensor bar is below your screen.
* *
* @param id * @param id
* the id of the wiimote of which we want the status. * the id of the wiimote of which we want the status.
*/ */
synchronized native void setSensorBarBelowScreen(int id); synchronized native void setSensorBarBelowScreen(int id);
/** /**
* Set virtual screen resolution. It is used to automatically compute the * Set virtual screen resolution. It is used to automatically compute the
* position of a cursor on this virtual screen using the sensor bar. These * position of a cursor on this virtual screen using the sensor bar. These
* results come in the IREvent. * results come in the IREvent.
* *
* @param id * @param id
* the id of the wiimote of which we want the status. * the id of the wiimote of which we want the status.
* @param x * @param x
* x resolution. * x resolution.
* @param y * @param y
* y resolution. * y resolution.
*/ */
synchronized native void setVirtualScreenResolution(int id, int x, int y); synchronized native void setVirtualScreenResolution(int id, int x, int y);
/** /**
* Get status and values from the wiimotes and send it through callbacks. * Get status and values from the wiimotes and send it through callbacks.
* *
* @param id * @param id
* the id of the wiimote of which we want the status. * the id of the wiimote of which we want the status.
*/ */
synchronized native void getStatus(int id); synchronized native void getStatus(int id);
/** /**
* Set the normal and expansion handshake timeouts. * Set the normal and expansion handshake timeouts.
* *
* @param id * @param id
* the id of the wiimote concerned. * the id of the wiimote concerned.
* @param normalTimeout * @param normalTimeout
* The timeout in milliseconds for a normal read. * The timeout in milliseconds for a normal read.
* @param expansionTimeout * @param expansionTimeout
* The timeout in millisecondsd to wait for an expansion * The timeout in millisecondsd to wait for an expansion
* handshake. * handshake.
*/ */
synchronized native void setTimeout(int id, short normalTimeout, synchronized native void setTimeout(int id, short normalTimeout,
short expansionTimeout); short expansionTimeout);
/** /**
* Set the IR sensitivity. * Set the IR sensitivity.
* *
* @param id * @param id
* the id of the wiimote concerned. * the id of the wiimote concerned.
* @param level * @param level
* 1-5, same as Wii system sensitivity setting. If the level is < * 1-5, same as Wii system sensitivity setting. If the level is <
* 1, then level will be set to 1. If the level is > 5, then * 1, then level will be set to 1. If the level is > 5, then
* level will be set to 5. * level will be set to 5.
*/ */
synchronized native void setIrSensitivity(int id, int level); synchronized native void setIrSensitivity(int id, int level);
/** /**
* Set how many degrees an angle must change to generate an event for the * Set how many degrees an angle must change to generate an event for the
* nunchuk. * nunchuk.
* *
* @param id * @param id
* id of the wiimote concerned. * id of the wiimote concerned.
* @param angle * @param angle
* minimum angle detected by an event. * minimum angle detected by an event.
*/ */
synchronized native void setNunchukOrientationThreshold(int id, float angle); synchronized native void setNunchukOrientationThreshold(int id, float angle);
/** /**
* Set how much acceleration must change to generate an event for the * Set how much acceleration must change to generate an event for the
* nunchuk. * nunchuk.
* *
* @param id * @param id
* id of the wiimote concerned. * id of the wiimote concerned.
* @param value * @param value
* minimum value detected by an event. * minimum value detected by an event.
*/ */
synchronized native void setNunchukAccelerationThreshold(int id, int value); synchronized native void setNunchukAccelerationThreshold(int id, int value);
/** /**
* Force the bluetooth stack type.(useful only for windows) * Force the bluetooth stack type.(useful only for windows)
* *
* @param bluetoothStackType * @param bluetoothStackType
* must be WiiUseApi.WIIUSE_STACK_UNKNOWN or * must be WiiUseApi.WIIUSE_STACK_UNKNOWN or
* WiiUseApi.WIIUSE_STACK_MS or * WiiUseApi.WIIUSE_STACK_MS or
* WiiUseApi.WIIUSE_STACK_BLUESOLEIL. * WiiUseApi.WIIUSE_STACK_BLUESOLEIL.
*/ */
native void windowsSetBluetoothStack(int bluetoothStackType); native void windowsSetBluetoothStack(int bluetoothStackType);
/** /**
* Check for new Events and Get it. * Check for new Events and Get it.
* *
* @param gath * @param gath
* the object where we store all the new events. * the object where we store all the new events.
*/ */
native void specialPoll(EventsGatherer gath); native void specialPoll(EventsGatherer gath);
} }

View File

@@ -1,495 +1,495 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej; package wiiusej;
import javax.swing.event.EventListenerList; import javax.swing.event.EventListenerList;
import wiiusej.wiiusejevents.utils.WiiUseApiListener; import wiiusej.wiiusejevents.utils.WiiUseApiListener;
import wiiusej.wiiusejevents.utils.WiimoteListener; import wiiusej.wiiusejevents.utils.WiimoteListener;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent; import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent; import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent; import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent; import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent; import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
import wiiusej.wiiusejevents.wiiuseapievents.WiimoteEvent; import wiiusej.wiiusejevents.wiiuseapievents.WiimoteEvent;
/** /**
* Class that represents a wiimote. You can register as an observer of this * Class that represents a wiimote. You can register as an observer of this
* wiimote to listen events from it. You manage it. * wiimote to listen events from it. You manage it.
* *
* @author guiguito * @author guiguito
*/ */
public class Wiimote implements WiiUseApiListener { public class Wiimote implements WiiUseApiListener {
private int id = -1;// wiimote id private int id = -1;// wiimote id
private EventListenerList listeners = new EventListenerList(); private EventListenerList listeners = new EventListenerList();
private WiiUseApiManager manager; private WiiUseApiManager manager;
/** /**
* Constructor. * Constructor.
* *
* @param idd * @param idd
* id of the wiimote * id of the wiimote
* @param manager * @param manager
* manager wo built it. * manager wo built it.
*/ */
public Wiimote(int idd, WiiUseApiManager manager) { public Wiimote(int idd, WiiUseApiManager manager) {
id = idd; id = idd;
this.manager = manager; this.manager = manager;
} }
/** /**
* Get the unique id of the wiimote. * Get the unique id of the wiimote.
* *
* @return the id * @return the id
*/ */
public int getId() { public int getId() {
return id; return id;
} }
/** /**
* Disconnect this wiimote. * Disconnect this wiimote.
*/ */
public void disconnect() { public void disconnect() {
deactivateIRTRacking(); deactivateIRTRacking();
deactivateMotionSensing(); deactivateMotionSensing();
deactivateRumble(); deactivateRumble();
manager.closeConnection(id); manager.closeConnection(id);
} }
/** /**
* Activate the rumble. * Activate the rumble.
*/ */
public void activateRumble() { public void activateRumble() {
manager.activateRumble(id); manager.activateRumble(id);
} }
/** /**
* Deactivate the rumble. * Deactivate the rumble.
*/ */
public void deactivateRumble() { public void deactivateRumble() {
manager.deactivateRumble(id); manager.deactivateRumble(id);
} }
/** /**
* Activate IR Tracking. * Activate IR Tracking.
*/ */
public void activateIRTRacking() { public void activateIRTRacking() {
manager.activateIRTRacking(id); manager.activateIRTRacking(id);
} }
/** /**
* Deactivate IR Tracking. * Deactivate IR Tracking.
*/ */
public void deactivateIRTRacking() { public void deactivateIRTRacking() {
manager.deactivateIRTRacking(id); manager.deactivateIRTRacking(id);
} }
/** /**
* Activate motion sensing. * Activate motion sensing.
*/ */
public void activateMotionSensing() { public void activateMotionSensing() {
manager.activateMotionSensing(id); manager.activateMotionSensing(id);
} }
/** /**
* Deactivate motion sensing. * Deactivate motion sensing.
*/ */
public void deactivateMotionSensing() { public void deactivateMotionSensing() {
manager.deactivateMotionSensing(id); manager.deactivateMotionSensing(id);
} }
/** /**
* Activate smoothing. * Activate smoothing.
*/ */
public void activateSmoothing() { public void activateSmoothing() {
manager.activateSmoothing(id); manager.activateSmoothing(id);
} }
/** /**
* Deactivate smoothing. * Deactivate smoothing.
*/ */
public void deactivateSmoothing() { public void deactivateSmoothing() {
manager.deactivateSmoothing(id); manager.deactivateSmoothing(id);
} }
/** /**
* Activate continuous. * Activate continuous.
*/ */
public void activateContinuous() { public void activateContinuous() {
manager.activateContinuous(id); manager.activateContinuous(id);
} }
/** /**
* Deactivate continuous. * Deactivate continuous.
*/ */
public void deactivateContinuous() { public void deactivateContinuous() {
manager.deactivateContinuous(id); manager.deactivateContinuous(id);
} }
/** /**
* Set leds status. * Set leds status.
* *
* @param l1 * @param l1
* status of led1. True : ON, False : OFF * status of led1. True : ON, False : OFF
* @param l2 * @param l2
* status of led2. True : ON, False : OFF * status of led2. True : ON, False : OFF
* @param l3 * @param l3
* status of led3. True : ON, False : OFF * status of led3. True : ON, False : OFF
* @param l4 * @param l4
* status of led4. True : ON, False : OFF * status of led4. True : ON, False : OFF
*/ */
public void setLeds(boolean l1, boolean l2, boolean l3, boolean l4) { public void setLeds(boolean l1, boolean l2, boolean l3, boolean l4) {
manager.setLeds(id, l1, l2, l3, l4); manager.setLeds(id, l1, l2, l3, l4);
} }
/** /**
* Set the orientation threshold (minimum angle between two degrees with * Set the orientation threshold (minimum angle between two degrees with
* accelerometer). * accelerometer).
* *
* @param th * @param th
* threshold in degrees * threshold in degrees
*/ */
public void setOrientationThreshold(float th) { public void setOrientationThreshold(float th) {
manager.setOrientationThreshold(id, th); manager.setOrientationThreshold(id, th);
} }
/** /**
* Set the acceleration threshold(minimum angle between two degrees with * Set the acceleration threshold(minimum angle between two degrees with
* accelerometer). * accelerometer).
* *
* @param th * @param th
* threshold * threshold
*/ */
public void setAccelerationThreshold(int th) { public void setAccelerationThreshold(int th) {
manager.setAccelerationThreshold(id, th); manager.setAccelerationThreshold(id, th);
} }
/** /**
* Set the alpha smoothing value. * Set the alpha smoothing value.
* *
* @param th * @param th
* threshold * threshold
*/ */
public void setAlphaSmoothingValue(float th) { public void setAlphaSmoothingValue(float th) {
manager.setAlphaSmoothing(id, th); manager.setAlphaSmoothing(id, th);
} }
/** /**
* Set the screen aspect ratio to be considered as 4/3. * Set the screen aspect ratio to be considered as 4/3.
*/ */
public void setScreenAspectRatio43() { public void setScreenAspectRatio43() {
manager.setScreenAspectRatio43(id); manager.setScreenAspectRatio43(id);
} }
/** /**
* Set the screen aspect ratio to be considered as 16/9. * Set the screen aspect ratio to be considered as 16/9.
*/ */
public void setScreenAspectRatio169() { public void setScreenAspectRatio169() {
manager.setScreenAspectRatio169(id); manager.setScreenAspectRatio169(id);
} }
/** /**
* Set the sensor bar to be considered above the screen. * Set the sensor bar to be considered above the screen.
*/ */
public void setSensorBarAboveScreen() { public void setSensorBarAboveScreen() {
manager.setSensorBarAboveScreen(id); manager.setSensorBarAboveScreen(id);
} }
/** /**
* Set the sensor bar to be considered below the screen. * Set the sensor bar to be considered below the screen.
*/ */
public void setSensorBarBelowScreen() { public void setSensorBarBelowScreen() {
manager.setSensorBarBelowScreen(id); manager.setSensorBarBelowScreen(id);
} }
/** /**
* Set the screen resolution of the you are pointing at with your wiimote. * Set the screen resolution of the you are pointing at with your wiimote.
* *
* @param x * @param x
* x resolution. * x resolution.
* @param y * @param y
* y resolution. * y resolution.
*/ */
public void setVirtualResolution(int x, int y) { public void setVirtualResolution(int x, int y) {
manager.setVirtualResolution(id, x, y); manager.setVirtualResolution(id, x, y);
} }
/** /**
* Set the nunchuk orientation threshold for the given id. (minimum angle * Set the nunchuk orientation threshold for the given id. (minimum angle
* between two events) * between two events)
* *
* @param th * @param th
* threshold in degrees. * threshold in degrees.
*/ */
public void setNunchukOrientationThreshold(float th) { public void setNunchukOrientationThreshold(float th) {
manager.setNunchukOrientationThreshold(id, th); manager.setNunchukOrientationThreshold(id, th);
} }
/** /**
* Set the nunchuk acceleration threshold for the given id. (minimum angle * Set the nunchuk acceleration threshold for the given id. (minimum angle
* between two events) * between two events)
* *
* @param th * @param th
* threshold. * threshold.
*/ */
public void setNunchukAccelerationThreshold(int th) { public void setNunchukAccelerationThreshold(int th) {
manager.setNunchukAccelerationThreshold(id, th); manager.setNunchukAccelerationThreshold(id, th);
} }
/** /**
* Try to resync the wiimote by starting a new handshake. * Try to resync the wiimote by starting a new handshake.
*/ */
public void reSync() { public void reSync() {
manager.reSync(id); manager.reSync(id);
} }
/** /**
* Ask for the status of the wiimote. The result will be received in a * Ask for the status of the wiimote. The result will be received in a
* status event object. Implements onStatusEvent on wiimote listener to get * status event object. Implements onStatusEvent on wiimote listener to get
* it. * it.
*/ */
public void getStatus() { public void getStatus() {
manager.getStatus(id); manager.getStatus(id);
} }
/** /**
* Set the normal and expansion handshake timeouts for this wiimote. Normal * Set the normal and expansion handshake timeouts for this wiimote. Normal
* time out is for classic polling. The expansion timeout is used when an * time out is for classic polling. The expansion timeout is used when an
* expansion is detected until the expansion successfully handshakes. * expansion is detected until the expansion successfully handshakes.
* *
* @param normalTimeout * @param normalTimeout
* The timeout in milliseconds for a normal read. * The timeout in milliseconds for a normal read.
* @param expansionTimeout * @param expansionTimeout
* The timeout in millisecondsd to wait for an expansion * The timeout in millisecondsd to wait for an expansion
* handshake. * handshake.
*/ */
public void setTimeout(short normalTimeout, short expansionTimeout) { public void setTimeout(short normalTimeout, short expansionTimeout) {
manager.setTimeout(id, normalTimeout, expansionTimeout); manager.setTimeout(id, normalTimeout, expansionTimeout);
} }
/** /**
* Set the IR sensitivity. * Set the IR sensitivity.
* *
* @param level * @param level
* 1-5, same as Wii system sensitivity setting. If the level is < * 1-5, same as Wii system sensitivity setting. If the level is <
* 1, then level will be set to 1. If the level is > 5, then * 1, then level will be set to 1. If the level is > 5, then
* level will be set to 5. * level will be set to 5.
*/ */
public void setIrSensitivity(int level) { public void setIrSensitivity(int level) {
manager.setIrSensitivity(id, level); manager.setIrSensitivity(id, level);
} }
/** /**
* Method called when a WiiUseApiEvent occurs. * Method called when a WiiUseApiEvent occurs.
* *
* @param e * @param e
* the WiiUseApiEvent. * the WiiUseApiEvent.
*/ */
public void onWiiUseApiEvent(WiiUseApiEvent e) { public void onWiiUseApiEvent(WiiUseApiEvent e) {
if (e.getWiimoteId() == id) { if (e.getWiimoteId() == id) {
if (e.getEventType() == WiiUseApiEvent.GENERIC_EVENT) { if (e.getEventType() == WiiUseApiEvent.GENERIC_EVENT) {
notifyWiiMoteEventListeners((WiimoteEvent) e); notifyWiiMoteEventListeners((WiimoteEvent) e);
} else if (e.getEventType() == WiiUseApiEvent.STATUS_EVENT) { } else if (e.getEventType() == WiiUseApiEvent.STATUS_EVENT) {
notifyStatusEventListeners((StatusEvent) e); notifyStatusEventListeners((StatusEvent) e);
} else if (e.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT) { } else if (e.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT) {
notifyDisconnectionEventListeners((DisconnectionEvent) e); notifyDisconnectionEventListeners((DisconnectionEvent) e);
} else if (e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_INSERTED) { } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_INSERTED) {
notifyNunchukInsertedEventListeners((NunchukInsertedEvent) e); notifyNunchukInsertedEventListeners((NunchukInsertedEvent) e);
} else if (e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_REMOVED) { } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_REMOVED) {
notifyNunchukRemovedEventListeners((NunchukRemovedEvent) e); notifyNunchukRemovedEventListeners((NunchukRemovedEvent) e);
} else if (e.getEventType() == WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED) { } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED) {
notifyGuitarHeroInsertedEventListeners((GuitarHeroInsertedEvent) e); notifyGuitarHeroInsertedEventListeners((GuitarHeroInsertedEvent) e);
} else if (e.getEventType() == WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED) { } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED) {
notifyGuitarHeroRemovedEventListeners((GuitarHeroRemovedEvent) e); notifyGuitarHeroRemovedEventListeners((GuitarHeroRemovedEvent) e);
} else if (e.getEventType() == WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED) { } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED) {
notifyClassicControllerInsertedEventListeners((ClassicControllerInsertedEvent) e); notifyClassicControllerInsertedEventListeners((ClassicControllerInsertedEvent) e);
} else if (e.getEventType() == WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_REMOVED) { } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_REMOVED) {
notifyClassicControllerRemovedEventListeners((ClassicControllerRemovedEvent) e); notifyClassicControllerRemovedEventListeners((ClassicControllerRemovedEvent) e);
} }
/* /*
* events not managed yet || e.getEventType() == WIIUSE_READ_DATA * events not managed yet || e.getEventType() == WIIUSE_READ_DATA
* WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED || e.getEventType() == * WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED || e.getEventType() ==
* WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_REMOVED || e.getEventType() == * WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_REMOVED || e.getEventType() ==
* WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED || * WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED ||
* e.getEventType() == * e.getEventType() ==
* WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED * WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED
*/ */
} }
} }
/** /**
* Add a WiimoteListener to the listeners list. * Add a WiimoteListener to the listeners list.
* *
* @param listener * @param listener
* a WiimoteListener * a WiimoteListener
*/ */
public void addWiiMoteEventListeners(WiimoteListener listener) { public void addWiiMoteEventListeners(WiimoteListener listener) {
listeners.add(WiimoteListener.class, listener); listeners.add(WiimoteListener.class, listener);
} }
/** /**
* Remove a WiimoteListener from the listeners list. * Remove a WiimoteListener from the listeners list.
* *
* @param listener * @param listener
* a WiimoteListener * a WiimoteListener
*/ */
public void removeWiiMoteEventListeners(WiimoteListener listener) { public void removeWiiMoteEventListeners(WiimoteListener listener) {
listeners.remove(WiimoteListener.class, listener); listeners.remove(WiimoteListener.class, listener);
} }
/** /**
* Get the list of WiimoteListener. * Get the list of WiimoteListener.
* *
* @return the list of WiimoteListener. * @return the list of WiimoteListener.
*/ */
public WiimoteListener[] getWiiMoteEventListeners() { public WiimoteListener[] getWiiMoteEventListeners() {
return listeners.getListeners(WiimoteListener.class); return listeners.getListeners(WiimoteListener.class);
} }
/** /**
* Notify WiimoteListeners that an event occured. Notify in first the * Notify WiimoteListeners that an event occured. Notify in first the
* listeners for Buttons Events. In second the listeners for IR Events. In * listeners for Buttons Events. In second the listeners for IR Events. In
* third the listeners for Motion sensing events. * third the listeners for Motion sensing events.
* *
* @param evt * @param evt
* GenericEvent occured * GenericEvent occured
*/ */
private void notifyWiiMoteEventListeners(WiimoteEvent evt) { private void notifyWiiMoteEventListeners(WiimoteEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) { for (WiimoteListener listener : getWiiMoteEventListeners()) {
listener.onButtonsEvent(evt.getButtonsEvent()); listener.onButtonsEvent(evt.getButtonsEvent());
if (evt.isThereIrEvent()) { if (evt.isThereIrEvent()) {
listener.onIrEvent(evt.getIREvent()); listener.onIrEvent(evt.getIREvent());
} }
if (evt.isThereMotionSensingEvent()) { if (evt.isThereMotionSensingEvent()) {
listener.onMotionSensingEvent(evt.getMotionSensingEvent()); listener.onMotionSensingEvent(evt.getMotionSensingEvent());
} }
if (evt.isThereExpansionEvent()) { if (evt.isThereExpansionEvent()) {
listener.onExpansionEvent(evt.getExpansionEvent()); listener.onExpansionEvent(evt.getExpansionEvent());
} }
} }
} }
/** /**
* Notify WiimoteListener that a status event occured. * Notify WiimoteListener that a status event occured.
* *
* @param evt * @param evt
* status event occured * status event occured
*/ */
private void notifyStatusEventListeners(StatusEvent evt) { private void notifyStatusEventListeners(StatusEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) { for (WiimoteListener listener : getWiiMoteEventListeners()) {
listener.onStatusEvent(evt); listener.onStatusEvent(evt);
} }
} }
/** /**
* Notify WiimoteListener that a disconnection event occured. * Notify WiimoteListener that a disconnection event occured.
* *
* @param evt * @param evt
* disconnection event occured * disconnection event occured
*/ */
private void notifyDisconnectionEventListeners(DisconnectionEvent evt) { private void notifyDisconnectionEventListeners(DisconnectionEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) { for (WiimoteListener listener : getWiiMoteEventListeners()) {
listener.onDisconnectionEvent(evt); listener.onDisconnectionEvent(evt);
} }
} }
/** /**
* Notify WiimoteListener that a NunchukInserted Event occured. * Notify WiimoteListener that a NunchukInserted Event occured.
* *
* @param evt * @param evt
* NunchukInserted Event occured * NunchukInserted Event occured
*/ */
private void notifyNunchukInsertedEventListeners(NunchukInsertedEvent evt) { private void notifyNunchukInsertedEventListeners(NunchukInsertedEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) { for (WiimoteListener listener : getWiiMoteEventListeners()) {
listener.onNunchukInsertedEvent(evt); listener.onNunchukInsertedEvent(evt);
} }
} }
/** /**
* Notify WiimoteListener that a NunchukRemoved Event occured. * Notify WiimoteListener that a NunchukRemoved Event occured.
* *
* @param evt * @param evt
* NunchukRemoved Event occured * NunchukRemoved Event occured
*/ */
private void notifyNunchukRemovedEventListeners(NunchukRemovedEvent evt) { private void notifyNunchukRemovedEventListeners(NunchukRemovedEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) { for (WiimoteListener listener : getWiiMoteEventListeners()) {
listener.onNunchukRemovedEvent(evt); listener.onNunchukRemovedEvent(evt);
} }
} }
/** /**
* Notify WiimoteListener that a GuitarHeroInserted Event occured. * Notify WiimoteListener that a GuitarHeroInserted Event occured.
* *
* @param evt * @param evt
* GuitarHeroInserted Event occured * GuitarHeroInserted Event occured
*/ */
private void notifyGuitarHeroInsertedEventListeners(GuitarHeroInsertedEvent evt) { private void notifyGuitarHeroInsertedEventListeners(GuitarHeroInsertedEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) { for (WiimoteListener listener : getWiiMoteEventListeners()) {
listener.onGuitarHeroInsertedEvent(evt); listener.onGuitarHeroInsertedEvent(evt);
} }
} }
/** /**
* Notify WiimoteListener that a GuitarHeroRemoved Event occured. * Notify WiimoteListener that a GuitarHeroRemoved Event occured.
* *
* @param evt * @param evt
* GuitarHeroRemoved Event occured * GuitarHeroRemoved Event occured
*/ */
private void notifyGuitarHeroRemovedEventListeners(GuitarHeroRemovedEvent evt) { private void notifyGuitarHeroRemovedEventListeners(GuitarHeroRemovedEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) { for (WiimoteListener listener : getWiiMoteEventListeners()) {
listener.onGuitarHeroRemovedEvent(evt); listener.onGuitarHeroRemovedEvent(evt);
} }
} }
/** /**
* Notify WiimoteListener that a ClassicControllerInserted Event occured. * Notify WiimoteListener that a ClassicControllerInserted Event occured.
* *
* @param evt * @param evt
* ClassicControllerInserted Event occured * ClassicControllerInserted Event occured
*/ */
private void notifyClassicControllerInsertedEventListeners(ClassicControllerInsertedEvent evt) { private void notifyClassicControllerInsertedEventListeners(ClassicControllerInsertedEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) { for (WiimoteListener listener : getWiiMoteEventListeners()) {
listener.onClassicControllerInsertedEvent(evt); listener.onClassicControllerInsertedEvent(evt);
} }
} }
/** /**
* Notify WiimoteListener that a ClassicControllerRemoved Event occured. * Notify WiimoteListener that a ClassicControllerRemoved Event occured.
* *
* @param evt * @param evt
* ClassicControllerRemoved Event occured * ClassicControllerRemoved Event occured
*/ */
private void notifyClassicControllerRemovedEventListeners(ClassicControllerRemovedEvent evt) { private void notifyClassicControllerRemovedEventListeners(ClassicControllerRemovedEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) { for (WiimoteListener listener : getWiiMoteEventListeners()) {
listener.onClassicControllerRemovedEvent(evt); listener.onClassicControllerRemovedEvent(evt);
} }
} }
@Override @Override
public String toString() { public String toString() {
return "Wiimote with ID : " + id; return "Wiimote with ID : " + id;
} }
} }

View File

@@ -1,80 +1,80 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.values; package wiiusej.values;
/** /**
* Represents gravity force on each axis. * Represents gravity force on each axis.
* *
* @author guiguito * @author guiguito
*/ */
public class GForce { public class GForce {
private float x; private float x;
private float y; private float y;
private float z; private float z;
/** /**
* Default constructor; * Default constructor;
*/ */
public GForce() { public GForce() {
x = 0; x = 0;
y = 0; y = 0;
z = 0; z = 0;
} }
/** /**
* Constructor with gravity force on each axis. * Constructor with gravity force on each axis.
* *
* @param xx * @param xx
* x value * x value
* @param yy * @param yy
* x value * x value
* @param zz * @param zz
* x value * x value
*/ */
public GForce(float xx, float yy, float zz) { public GForce(float xx, float yy, float zz) {
x = xx; x = xx;
y = yy; y = yy;
z = zz; z = zz;
} }
/** /**
* @return the x * @return the x
*/ */
public float getX() { public float getX() {
return x; return x;
} }
/** /**
* @return the y * @return the y
*/ */
public float getY() { public float getY() {
return y; return y;
} }
/** /**
* @return the z * @return the z
*/ */
public float getZ() { public float getZ() {
return z; return z;
} }
@Override @Override
public String toString() { public String toString() {
return "Gravity force : (" + x + ", " + y + "," + z + ")"; return "Gravity force : (" + x + ", " + y + "," + z + ")";
} }
} }

View File

@@ -1,106 +1,106 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.values; package wiiusej.values;
/** /**
* Class used for IR sources. * Class used for IR sources.
* *
* @author guiguito * @author guiguito
*/ */
public class IRSource { public class IRSource {
private int x; private int x;
private int y; private int y;
private short rx; private short rx;
private short ry; private short ry;
private short size; private short size;
/** /**
* Build an IR source with all details. * Build an IR source with all details.
* *
* @param xx * @param xx
* xx interpolated coordinates. * xx interpolated coordinates.
* @param yy * @param yy
* yy interpolated coordinates. * yy interpolated coordinates.
* @param rxx * @param rxx
* raw X coordinate (0-1023). * raw X coordinate (0-1023).
* @param ryy * @param ryy
* raw Y coordinate (0-1023). * raw Y coordinate (0-1023).
* @param si * @param si
* size of the IR dot (0-15). * size of the IR dot (0-15).
*/ */
public IRSource(int xx, int yy, short rxx, short ryy, short si) { public IRSource(int xx, int yy, short rxx, short ryy, short si) {
x = xx; x = xx;
y = yy; y = yy;
rx = rxx; rx = rxx;
ry = ryy; ry = ryy;
size = si; size = si;
} }
/** /**
* Return x interpolated coordinates. * Return x interpolated coordinates.
* *
* @return the x * @return the x
*/ */
public int getX() { public int getX() {
return x; return x;
} }
/** /**
* Return y interpolated coordinates. * Return y interpolated coordinates.
* *
* @return the y * @return the y
*/ */
public int getY() { public int getY() {
return y; return y;
} }
/** /**
* Return raw X coordinate (0-1023). * Return raw X coordinate (0-1023).
* *
* @return the rx * @return the rx
*/ */
public short getRx() { public short getRx() {
return rx; return rx;
} }
/** /**
* Return raw Y coordinate (0-1023). * Return raw Y coordinate (0-1023).
* *
* @return the ry * @return the ry
*/ */
public short getRy() { public short getRy() {
return ry; return ry;
} }
/** /**
* Return size of the IR dot (0-15). * Return size of the IR dot (0-15).
* *
* @return the size * @return the size
*/ */
public short getSize() { public short getSize() {
return size; return size;
} }
@Override @Override
public String toString() { public String toString() {
return "Interpolated coordinates (" + x + "," + y return "Interpolated coordinates (" + x + "," + y
+ "), Raw coordinates(" + rx + "," + ry + "), source size : " + "), Raw coordinates(" + rx + "," + ry + "), source size : "
+ size + ")"; + size + ")";
} }
} }

View File

@@ -1,117 +1,117 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.values; package wiiusej.values;
/** /**
* Class that represents the orientation of the wiimote. * Class that represents the orientation of the wiimote.
* *
* @author guiguito * @author guiguito
*/ */
public class Orientation { public class Orientation {
private float roll; private float roll;
private float pitch; private float pitch;
private float yaw; private float yaw;
private float a_roll; private float a_roll;
private float a_pitch; private float a_pitch;
/** /**
* Default constructor. * Default constructor.
*/ */
public Orientation() { public Orientation() {
roll = 0; roll = 0;
pitch = 0; pitch = 0;
yaw = 0; yaw = 0;
a_roll = 0; a_roll = 0;
a_pitch = 0; a_pitch = 0;
} }
/** /**
* Contructor with raw, pitch , yaw. * Contructor with raw, pitch , yaw.
* *
* @param r * @param r
* roll (can be smoothed) * roll (can be smoothed)
* @param p * @param p
* pitch (can be smoothed) * pitch (can be smoothed)
* @param y * @param y
* yaw * yaw
* @param ar * @param ar
* absolute roll * absolute roll
* @param ap * @param ap
* absolute pitch * absolute pitch
*/ */
public Orientation(float r, float p, float y, float ar, float ap) { public Orientation(float r, float p, float y, float ar, float ap) {
roll = r; roll = r;
pitch = p; pitch = p;
yaw = y; yaw = y;
a_roll = ar; a_roll = ar;
a_pitch = ap; a_pitch = ap;
} }
/** /**
* Get the roll (can be smoothed). * Get the roll (can be smoothed).
* *
* @return the roll * @return the roll
*/ */
public float getRoll() { public float getRoll() {
return roll; return roll;
} }
/** /**
* Get the pitch (can be smoothed). * Get the pitch (can be smoothed).
* *
* @return the pitch * @return the pitch
*/ */
public float getPitch() { public float getPitch() {
return pitch; return pitch;
} }
/** /**
* Get the yaw. * Get the yaw.
* *
* @return the yaw * @return the yaw
*/ */
public float getYaw() { public float getYaw() {
return yaw; return yaw;
} }
/** /**
* Get absolute roll (can not be smoothed). * Get absolute roll (can not be smoothed).
* *
* @return the a_roll * @return the a_roll
*/ */
public float getARoll() { public float getARoll() {
return a_roll; return a_roll;
} }
/** /**
* Get absolute pitch (can not be smoothed). * Get absolute pitch (can not be smoothed).
* *
* @return the a_pitch * @return the a_pitch
*/ */
public float getAPitch() { public float getAPitch() {
return a_pitch; return a_pitch;
} }
@Override @Override
public String toString() { public String toString() {
return "Orientation : (roll: " + roll + ", pitch: " + pitch + ", yaw: " return "Orientation : (roll: " + roll + ", pitch: " + pitch + ", yaw: "
+ yaw + ", absolute roll: " + a_roll + ", absolute pitch: " + yaw + ", absolute roll: " + a_roll + ", absolute pitch: "
+ a_pitch + ")"; + a_pitch + ")";
} }
} }

View File

@@ -1,81 +1,81 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.values; package wiiusej.values;
/** /**
* Represents raw acceleration on each axis. * Represents raw acceleration on each axis.
* *
* @author guiguito * @author guiguito
*/ */
public class RawAcceleration { public class RawAcceleration {
private short x; private short x;
private short y; private short y;
private short z; private short z;
/** /**
* Default constructor; * Default constructor;
*/ */
public RawAcceleration() { public RawAcceleration() {
x = 0; x = 0;
y = 0; y = 0;
z = 0; z = 0;
} }
/** /**
* Constructor with raw acceleration on each axis. * Constructor with raw acceleration on each axis.
* *
* @param xx * @param xx
* x value * x value
* @param yy * @param yy
* x value * x value
* @param zz * @param zz
* x value * x value
*/ */
public RawAcceleration(short xx, short yy, short zz) { public RawAcceleration(short xx, short yy, short zz) {
x = xx; x = xx;
y = yy; y = yy;
z = zz; z = zz;
} }
/** /**
* @return the x * @return the x
*/ */
public short getX() { public short getX() {
return x; return x;
} }
/** /**
* @return the y * @return the y
*/ */
public short getY() { public short getY() {
return y; return y;
} }
/** /**
* @return the z * @return the z
*/ */
public short getZ() { public short getZ() {
return z; return z;
} }
@Override @Override
public String toString() { public String toString() {
return "Raw acceleration : (" + x + ", " + y + "," + z + ")"; return "Raw acceleration : (" + x + ", " + y + "," + z + ")";
} }
} }

View File

@@ -1,59 +1,59 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents; package wiiusej.wiiusejevents;
/** /**
* Abstract mother class representing an event with a wiimote id. * Abstract mother class representing an event with a wiimote id.
* *
* @author guiguito * @author guiguito
*/ */
public abstract class GenericEvent { public abstract class GenericEvent {
/* ID */ /* ID */
private int wiimoteId = -1; private int wiimoteId = -1;
/** /**
* Construct the WiiUseApiEvent setting up the id. * Construct the WiiUseApiEvent setting up the id.
* *
* @param id * @param id
* the Wiimote id * the Wiimote id
*/ */
public GenericEvent(int id) { public GenericEvent(int id) {
wiimoteId = id; wiimoteId = id;
} }
/** /**
* Get Wiimote ID * Get Wiimote ID
* *
* @return the wiimote id. * @return the wiimote id.
*/ */
public int getWiimoteId() { public int getWiimoteId() {
return wiimoteId; return wiimoteId;
} }
/** /**
* Set Wiimote ID * Set Wiimote ID
* *
* @param wiimoteId * @param wiimoteId
* id of the wiimote * id of the wiimote
*/ */
void setWiimoteId(int wiimoteId) { void setWiimoteId(int wiimoteId) {
this.wiimoteId = wiimoteId; this.wiimoteId = wiimoteId;
} }
public abstract String toString(); public abstract String toString();
} }

View File

@@ -1,128 +1,128 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
import wiiusej.wiiusejevents.GenericEvent; import wiiusej.wiiusejevents.GenericEvent;
/** /**
* Class which represents a buttons event. * Class which represents a buttons event.
* *
* @author guiguito * @author guiguito
*/ */
public abstract class ButtonsEvent extends GenericEvent { public abstract class ButtonsEvent extends GenericEvent {
/* Buttons */ /* Buttons */
private short buttonsJustPressed = 0; private short buttonsJustPressed = 0;
private short buttonsJustReleased = 0; private short buttonsJustReleased = 0;
private short buttonsHeld = 0; private short buttonsHeld = 0;
/** /**
* Constructor of the button Event. * Constructor of the button Event.
* *
* @param id * @param id
* id of the wiimote concerned. * id of the wiimote concerned.
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed. * buttons just pressed.
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released. * buttons just released.
* @param buttonsHeld * @param buttonsHeld
* buttons just held. * buttons just held.
*/ */
public ButtonsEvent(int id, short buttonsJustPressed, public ButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) { short buttonsJustReleased, short buttonsHeld) {
super(id); super(id);
setAllButtons(buttonsJustPressed, buttonsJustReleased, buttonsHeld); setAllButtons(buttonsJustPressed, buttonsJustReleased, buttonsHeld);
} }
/** /**
* Set all buttons in one method. * Set all buttons in one method.
* *
* @param buttonsJustPressed * @param buttonsJustPressed
* @param buttonsJustReleased * @param buttonsJustReleased
* @param buttonsHeld * @param buttonsHeld
*/ */
private void setAllButtons(short buttonsJustPressed, private void setAllButtons(short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) { short buttonsJustReleased, short buttonsHeld) {
this.buttonsJustPressed = buttonsJustPressed; this.buttonsJustPressed = buttonsJustPressed;
this.buttonsJustReleased = buttonsJustReleased; this.buttonsJustReleased = buttonsJustReleased;
this.buttonsHeld = buttonsHeld; this.buttonsHeld = buttonsHeld;
} }
/** /**
* Get the short storing the buttons just pressed * Get the short storing the buttons just pressed
* *
* @return the short storing the buttons just pressed * @return the short storing the buttons just pressed
*/ */
public short getButtonsJustPressed() { public short getButtonsJustPressed() {
return buttonsJustPressed; return buttonsJustPressed;
} }
/** /**
* Get the short storing the buttons just released * Get the short storing the buttons just released
* *
* @return the short storing the buttons just released * @return the short storing the buttons just released
*/ */
public short getButtonsJustReleased() { public short getButtonsJustReleased() {
return buttonsJustReleased; return buttonsJustReleased;
} }
/** /**
* get the short storing the buttons held * get the short storing the buttons held
* *
* @return the short storing the buttons held * @return the short storing the buttons held
*/ */
public short getButtonsHeld() { public short getButtonsHeld() {
return buttonsHeld; return buttonsHeld;
} }
/** **************** BUTTONS Methods ***************** */ /** **************** BUTTONS Methods ***************** */
/* generic button functions */ /* generic button functions */
protected boolean buttonTest(int buttonBitsDefinition, int buttons) { protected boolean buttonTest(int buttonBitsDefinition, int buttons) {
return (buttons & buttonBitsDefinition) == buttonBitsDefinition; return (buttons & buttonBitsDefinition) == buttonBitsDefinition;
} }
protected boolean isButtonJustPressed(int buttonBitsDefinition) { protected boolean isButtonJustPressed(int buttonBitsDefinition) {
return buttonTest(buttonBitsDefinition, buttonsJustPressed) return buttonTest(buttonBitsDefinition, buttonsJustPressed)
&& !isButtonHeld(buttonBitsDefinition); && !isButtonHeld(buttonBitsDefinition);
} }
protected boolean isButtonJustReleased(int buttonBitsDefinition) { protected boolean isButtonJustReleased(int buttonBitsDefinition) {
return buttonTest(buttonBitsDefinition, buttonsJustReleased); return buttonTest(buttonBitsDefinition, buttonsJustReleased);
} }
protected boolean isButtonHeld(int buttonBitsDefinition) { protected boolean isButtonHeld(int buttonBitsDefinition) {
return buttonTest(buttonBitsDefinition, buttonsHeld); return buttonTest(buttonBitsDefinition, buttonsHeld);
} }
protected boolean isButtonPressed(int buttonBitsDefinition) { protected boolean isButtonPressed(int buttonBitsDefinition) {
return isButtonHeld(buttonBitsDefinition) return isButtonHeld(buttonBitsDefinition)
|| isButtonJustPressed(buttonBitsDefinition); || isButtonJustPressed(buttonBitsDefinition);
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Display buttons */ /* Display buttons */
out += "/******** Buttons ********/\n"; out += "/******** Buttons ********/\n";
out += "--- Buttons just pressed : " + buttonsJustPressed + "\n"; out += "--- Buttons just pressed : " + buttonsJustPressed + "\n";
out += "--- Buttons just released : " + buttonsJustReleased + "\n"; out += "--- Buttons just released : " + buttonsJustReleased + "\n";
out += "--- Buttons held : " + buttonsHeld + "\n"; out += "--- Buttons held : " + buttonsHeld + "\n";
return out; return out;
} }
} }

View File

@@ -1,329 +1,329 @@
/* This file is part of WiiuseJ. /* This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
/** /**
* Class which represents a buttons event from a Classic controller. * Class which represents a buttons event from a Classic controller.
* *
* @author guiguito * @author guiguito
*/ */
public class ClassicControllerButtonsEvent extends ButtonsEvent{ public class ClassicControllerButtonsEvent extends ButtonsEvent{
private static short CLASSIC_CTRL_BUTTON_UP = 0x0001; private static short CLASSIC_CTRL_BUTTON_UP = 0x0001;
private static short CLASSIC_CTRL_BUTTON_LEFT = 0x0002; private static short CLASSIC_CTRL_BUTTON_LEFT = 0x0002;
private static short CLASSIC_CTRL_BUTTON_ZR = 0x0004; private static short CLASSIC_CTRL_BUTTON_ZR = 0x0004;
private static short CLASSIC_CTRL_BUTTON_X = 0x0008; private static short CLASSIC_CTRL_BUTTON_X = 0x0008;
private static short CLASSIC_CTRL_BUTTON_A = 0x0010; private static short CLASSIC_CTRL_BUTTON_A = 0x0010;
private static short CLASSIC_CTRL_BUTTON_Y = 0x0020; private static short CLASSIC_CTRL_BUTTON_Y = 0x0020;
private static short CLASSIC_CTRL_BUTTON_B = 0x0040; private static short CLASSIC_CTRL_BUTTON_B = 0x0040;
private static short CLASSIC_CTRL_BUTTON_ZL = 0x0080; private static short CLASSIC_CTRL_BUTTON_ZL = 0x0080;
private static short CLASSIC_CTRL_BUTTON_FULL_R = 0x0200; private static short CLASSIC_CTRL_BUTTON_FULL_R = 0x0200;
private static short CLASSIC_CTRL_BUTTON_PLUS = 0x0400; private static short CLASSIC_CTRL_BUTTON_PLUS = 0x0400;
private static short CLASSIC_CTRL_BUTTON_HOME = 0x0800; private static short CLASSIC_CTRL_BUTTON_HOME = 0x0800;
private static short CLASSIC_CTRL_BUTTON_MINUS = 0x1000; private static short CLASSIC_CTRL_BUTTON_MINUS = 0x1000;
private static short CLASSIC_CTRL_BUTTON_FULL_L = 0x2000; private static short CLASSIC_CTRL_BUTTON_FULL_L = 0x2000;
private static short CLASSIC_CTRL_BUTTON_DOWN = 0x4000; private static short CLASSIC_CTRL_BUTTON_DOWN = 0x4000;
private static int CLASSIC_CTRL_BUTTON_RIGHT = 0x8000; private static int CLASSIC_CTRL_BUTTON_RIGHT = 0x8000;
private static int CLASSIC_CTRL_BUTTON_ALL = 0xFEFF; private static int CLASSIC_CTRL_BUTTON_ALL = 0xFEFF;
/** /**
* Constructor of the classic controller buttons Event. * Constructor of the classic controller buttons Event.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed. * buttons just pressed.
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released. * buttons just released.
* @param buttonsHeld * @param buttonsHeld
* buttons just pressed. * buttons just pressed.
*/ */
public ClassicControllerButtonsEvent(int id, short buttonsJustPressed, public ClassicControllerButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) { short buttonsJustReleased, short buttonsHeld) {
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
} }
/* Button LEFT */ /* Button LEFT */
public boolean isButtonLeftJustPressed() { public boolean isButtonLeftJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_LEFT); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_LEFT);
} }
public boolean isButtonLeftJustReleased() { public boolean isButtonLeftJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_LEFT); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_LEFT);
} }
public boolean isButtonLeftHeld() { public boolean isButtonLeftHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_LEFT); return isButtonHeld(CLASSIC_CTRL_BUTTON_LEFT);
} }
public boolean isButtonLeftPressed() { public boolean isButtonLeftPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_LEFT); return isButtonPressed(CLASSIC_CTRL_BUTTON_LEFT);
} }
/* Button RIGHT */ /* Button RIGHT */
public boolean isButtonRightJustPressed() { public boolean isButtonRightJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_RIGHT); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_RIGHT);
} }
public boolean isButtonRightJustReleased() { public boolean isButtonRightJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_RIGHT); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_RIGHT);
} }
public boolean isButtonRightHeld() { public boolean isButtonRightHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_RIGHT); return isButtonHeld(CLASSIC_CTRL_BUTTON_RIGHT);
} }
public boolean isButtonRightPressed() { public boolean isButtonRightPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_RIGHT); return isButtonPressed(CLASSIC_CTRL_BUTTON_RIGHT);
} }
/* Button UP */ /* Button UP */
public boolean isButtonUpJustPressed() { public boolean isButtonUpJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_UP); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_UP);
} }
public boolean isButtonUpJustReleased() { public boolean isButtonUpJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_UP); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_UP);
} }
public boolean isButtonUpHeld() { public boolean isButtonUpHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_UP); return isButtonHeld(CLASSIC_CTRL_BUTTON_UP);
} }
public boolean isButtonUpPressed() { public boolean isButtonUpPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_UP); return isButtonPressed(CLASSIC_CTRL_BUTTON_UP);
} }
/* Button DOWN */ /* Button DOWN */
public boolean isButtonDownJustPressed() { public boolean isButtonDownJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_DOWN); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_DOWN);
} }
public boolean isButtonDownJustReleased() { public boolean isButtonDownJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_DOWN); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_DOWN);
} }
public boolean isButtonDownHeld() { public boolean isButtonDownHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_DOWN); return isButtonHeld(CLASSIC_CTRL_BUTTON_DOWN);
} }
public boolean isButtonDownPressed() { public boolean isButtonDownPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_DOWN); return isButtonPressed(CLASSIC_CTRL_BUTTON_DOWN);
} }
/* Button A */ /* Button A */
public boolean isButtonAJustPressed() { public boolean isButtonAJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_A); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_A);
} }
public boolean isButtonAJustReleased() { public boolean isButtonAJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_A); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_A);
} }
public boolean isButtonAHeld() { public boolean isButtonAHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_A); return isButtonHeld(CLASSIC_CTRL_BUTTON_A);
} }
public boolean isButtonAPressed() { public boolean isButtonAPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_A); return isButtonPressed(CLASSIC_CTRL_BUTTON_A);
} }
/* Button B */ /* Button B */
public boolean isButtonBJustPressed() { public boolean isButtonBJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_B); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_B);
} }
public boolean isButtonBJustReleased() { public boolean isButtonBJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_B); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_B);
} }
public boolean isButtonBHeld() { public boolean isButtonBHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_B); return isButtonHeld(CLASSIC_CTRL_BUTTON_B);
} }
public boolean isButtonBPressed() { public boolean isButtonBPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_B); return isButtonPressed(CLASSIC_CTRL_BUTTON_B);
} }
/* Button X */ /* Button X */
public boolean isButtonXJustPressed() { public boolean isButtonXJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_X); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_X);
} }
public boolean isButtonXJustReleased() { public boolean isButtonXJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_X); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_X);
} }
public boolean isButtonXHeld() { public boolean isButtonXHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_X); return isButtonHeld(CLASSIC_CTRL_BUTTON_X);
} }
public boolean isButtonXPressed() { public boolean isButtonXPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_X); return isButtonPressed(CLASSIC_CTRL_BUTTON_X);
} }
/* Button Y */ /* Button Y */
public boolean isButtonYJustPressed() { public boolean isButtonYJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_Y); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_Y);
} }
public boolean isButtonYJustReleased() { public boolean isButtonYJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_Y); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_Y);
} }
public boolean isButtonYHeld() { public boolean isButtonYHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_Y); return isButtonHeld(CLASSIC_CTRL_BUTTON_Y);
} }
public boolean isButtonYPressed() { public boolean isButtonYPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_Y); return isButtonPressed(CLASSIC_CTRL_BUTTON_Y);
} }
/* Button FullLeft */ /* Button FullLeft */
public boolean isButtonFullLeftJustPressed() { public boolean isButtonFullLeftJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_FULL_L); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_FULL_L);
} }
public boolean isButtonFullLeftJustReleased() { public boolean isButtonFullLeftJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_FULL_L); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_FULL_L);
} }
public boolean isButtonFullLeftHeld() { public boolean isButtonFullLeftHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_FULL_L); return isButtonHeld(CLASSIC_CTRL_BUTTON_FULL_L);
} }
public boolean isButtonFullLeftPressed() { public boolean isButtonFullLeftPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_FULL_L); return isButtonPressed(CLASSIC_CTRL_BUTTON_FULL_L);
} }
/* Button FullRight */ /* Button FullRight */
public boolean isButtonFullRightJustPressed() { public boolean isButtonFullRightJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_FULL_R); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_FULL_R);
} }
public boolean isButtonFullRightJustReleased() { public boolean isButtonFullRightJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_FULL_R); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_FULL_R);
} }
public boolean isButtonFullRightHeld() { public boolean isButtonFullRightHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_FULL_R); return isButtonHeld(CLASSIC_CTRL_BUTTON_FULL_R);
} }
public boolean isButtonFullRightPressed() { public boolean isButtonFullRightPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_FULL_R); return isButtonPressed(CLASSIC_CTRL_BUTTON_FULL_R);
} }
/* Button Home */ /* Button Home */
public boolean isButtonHomeJustPressed() { public boolean isButtonHomeJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_HOME); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_HOME);
} }
public boolean isButtonHomeJustReleased() { public boolean isButtonHomeJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_HOME); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_HOME);
} }
public boolean isButtonHomeHeld() { public boolean isButtonHomeHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_HOME); return isButtonHeld(CLASSIC_CTRL_BUTTON_HOME);
} }
public boolean isButtonHomePressed() { public boolean isButtonHomePressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_HOME); return isButtonPressed(CLASSIC_CTRL_BUTTON_HOME);
} }
/* Button Minus */ /* Button Minus */
public boolean isButtonMinusJustPressed() { public boolean isButtonMinusJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_MINUS); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_MINUS);
} }
public boolean isButtonMinusJustReleased() { public boolean isButtonMinusJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_MINUS); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_MINUS);
} }
public boolean isButtonMinusHeld() { public boolean isButtonMinusHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_MINUS); return isButtonHeld(CLASSIC_CTRL_BUTTON_MINUS);
} }
public boolean isButtonMinusPressed() { public boolean isButtonMinusPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_MINUS); return isButtonPressed(CLASSIC_CTRL_BUTTON_MINUS);
} }
/* Button Plus */ /* Button Plus */
public boolean isButtonPlusJustPressed() { public boolean isButtonPlusJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_PLUS); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_PLUS);
} }
public boolean isButtonPlusJustReleased() { public boolean isButtonPlusJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_PLUS); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_PLUS);
} }
public boolean isButtonPlusHeld() { public boolean isButtonPlusHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_PLUS); return isButtonHeld(CLASSIC_CTRL_BUTTON_PLUS);
} }
public boolean isButtonPlusPressed() { public boolean isButtonPlusPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_PLUS); return isButtonPressed(CLASSIC_CTRL_BUTTON_PLUS);
} }
/* Button ZL */ /* Button ZL */
public boolean isButtonZLJustPressed() { public boolean isButtonZLJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_ZL); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_ZL);
} }
public boolean isButtonZLJustReleased() { public boolean isButtonZLJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_ZL); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_ZL);
} }
public boolean isButtonZLHeld() { public boolean isButtonZLHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_ZL); return isButtonHeld(CLASSIC_CTRL_BUTTON_ZL);
} }
public boolean isButtonZLPressed() { public boolean isButtonZLPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_ZL); return isButtonPressed(CLASSIC_CTRL_BUTTON_ZL);
} }
/* Button ZR */ /* Button ZR */
public boolean isButtonZRJustPressed() { public boolean isButtonZRJustPressed() {
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_ZR); return isButtonJustPressed(CLASSIC_CTRL_BUTTON_ZR);
} }
public boolean isButtonZRJustReleased() { public boolean isButtonZRJustReleased() {
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_ZR); return isButtonJustReleased(CLASSIC_CTRL_BUTTON_ZR);
} }
public boolean isButtonZRHeld() { public boolean isButtonZRHeld() {
return isButtonHeld(CLASSIC_CTRL_BUTTON_ZR); return isButtonHeld(CLASSIC_CTRL_BUTTON_ZR);
} }
public boolean isButtonZRPressed() { public boolean isButtonZRPressed() {
return isButtonPressed(CLASSIC_CTRL_BUTTON_ZR); return isButtonPressed(CLASSIC_CTRL_BUTTON_ZR);
} }
} }

View File

@@ -1,177 +1,177 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
/** /**
* This class represents the values from the classic controller and its events. * This class represents the values from the classic controller and its events.
* *
* @author guiguito * @author guiguito
*/ */
public class ClassicControllerEvent extends ExpansionEvent { public class ClassicControllerEvent extends ExpansionEvent {
private float rightShoulder; private float rightShoulder;
private float leftShoulder; private float leftShoulder;
private ClassicControllerButtonsEvent buttonsEvent; private ClassicControllerButtonsEvent buttonsEvent;
private JoystickEvent classicControllerRightJoystickEvent; private JoystickEvent classicControllerRightJoystickEvent;
private JoystickEvent classicControllerLeftJoystickEvent; private JoystickEvent classicControllerLeftJoystickEvent;
/** /**
* Constructor of ClassicControllerEvent. * Constructor of ClassicControllerEvent.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed. * buttons just pressed.
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released. * buttons just released.
* @param buttonsHeld * @param buttonsHeld
* buttons just pressed. * buttons just pressed.
* @param rightShoulder * @param rightShoulder
* right shoulder button (range 0-1). * right shoulder button (range 0-1).
* @param leftShoulder * @param leftShoulder
* left shoulder button (range 0-1). * left shoulder button (range 0-1).
* @param langle * @param langle
* angle the left joystick is being held. * angle the left joystick is being held.
* @param lmagnitude * @param lmagnitude
* magnitude of the left joystick (range 0-1). * magnitude of the left joystick (range 0-1).
* @param lmax1 * @param lmax1
* maximum left joystick value 1. * maximum left joystick value 1.
* @param lmax2 * @param lmax2
* maximum left joystick value 2. * maximum left joystick value 2.
* @param lmin1 * @param lmin1
* minimum left joystick value 1. * minimum left joystick value 1.
* @param lmin2 * @param lmin2
* minimum left joystick value 2. * minimum left joystick value 2.
* @param lcenter1 * @param lcenter1
* center left joystick value 1. * center left joystick value 1.
* @param lcenter2 * @param lcenter2
* center left joystick value 2. * center left joystick value 2.
* @param rangle * @param rangle
* angle the right joystick is being held. * angle the right joystick is being held.
* @param rmagnitude * @param rmagnitude
* magnitude of the right joystick (range 0-1). * magnitude of the right joystick (range 0-1).
* @param rmax1 * @param rmax1
* maximum right joystick value 1. * maximum right joystick value 1.
* @param rmax2 * @param rmax2
* maximum right joystick value 2. * maximum right joystick value 2.
* @param rmin1 * @param rmin1
* minimum right joystick value 1. * minimum right joystick value 1.
* @param rmin2 * @param rmin2
* minimum right joystick value 2. * minimum right joystick value 2.
* @param rcenter1 * @param rcenter1
* center right joystick value 1. * center right joystick value 1.
* @param rcenter2 * @param rcenter2
* center right joystick value 2. * center right joystick value 2.
*/ */
public ClassicControllerEvent(int id, short buttonsJustPressed, public ClassicControllerEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld, float rightShoulder, short buttonsJustReleased, short buttonsHeld, float rightShoulder,
float leftShoulder, float langle, float lmagnitude, short lmax1, float leftShoulder, float langle, float lmagnitude, short lmax1,
short lmax2, short lmin1, short lmin2, short lcenter1, short lmax2, short lmin1, short lmin2, short lcenter1,
short lcenter2, float rangle, float rmagnitude, short rmax1, short lcenter2, float rangle, float rmagnitude, short rmax1,
short rmax2, short rmin1, short rmin2, short rcenter1, short rmax2, short rmin1, short rmin2, short rcenter1,
short rcenter2) { short rcenter2) {
super(id); super(id);
this.leftShoulder = leftShoulder; this.leftShoulder = leftShoulder;
this.rightShoulder = rightShoulder; this.rightShoulder = rightShoulder;
buttonsEvent = new ClassicControllerButtonsEvent(id, buttonsEvent = new ClassicControllerButtonsEvent(id,
buttonsJustPressed, buttonsJustReleased, buttonsHeld); buttonsJustPressed, buttonsJustReleased, buttonsHeld);
classicControllerLeftJoystickEvent = new JoystickEvent(id, langle, classicControllerLeftJoystickEvent = new JoystickEvent(id, langle,
lmagnitude, lmax1, lmax2, lmin1, lmin2, lcenter1, lcenter2); lmagnitude, lmax1, lmax2, lmin1, lmin2, lcenter1, lcenter2);
classicControllerRightJoystickEvent = new JoystickEvent(id, rangle, classicControllerRightJoystickEvent = new JoystickEvent(id, rangle,
rmagnitude, rmax1, rmax2, rmin1, rmin2, rcenter1, rcenter2); rmagnitude, rmax1, rmax2, rmin1, rmin2, rcenter1, rcenter2);
} }
/** /**
* Tell if there is a classic controller left joystick event. * Tell if there is a classic controller left joystick event.
* *
* @return TRUE if there is a classic controller left joystick event, false * @return TRUE if there is a classic controller left joystick event, false
* otherwise. * otherwise.
*/ */
public boolean isThereClassicControllerLeftJoystickEvent() { public boolean isThereClassicControllerLeftJoystickEvent() {
return classicControllerLeftJoystickEvent != null; return classicControllerLeftJoystickEvent != null;
} }
/** /**
* Tell if there is a classic controller right joystick event. * Tell if there is a classic controller right joystick event.
* *
* @return TRUE if there is a classic controller right joystick event, false * @return TRUE if there is a classic controller right joystick event, false
* otherwise. * otherwise.
*/ */
public boolean isThereClassicControllerRightJoystickEvent() { public boolean isThereClassicControllerRightJoystickEvent() {
return classicControllerRightJoystickEvent != null; return classicControllerRightJoystickEvent != null;
} }
/** /**
* Get the right shoulder button(range 0-1). * Get the right shoulder button(range 0-1).
* *
* @return value of the rightShoulder button. * @return value of the rightShoulder button.
*/ */
public float getRightShoulder() { public float getRightShoulder() {
return rightShoulder; return rightShoulder;
} }
/** /**
* Get the left shoulder button(range 0-1). * Get the left shoulder button(range 0-1).
* *
* @return value of the leftShoulder button. * @return value of the leftShoulder button.
*/ */
public float getLeftShoulder() { public float getLeftShoulder() {
return leftShoulder; return leftShoulder;
} }
/** /**
* Get buttons event for the classic controller. * Get buttons event for the classic controller.
* *
* @return the classic controller buttons event if there is one or null. * @return the classic controller buttons event if there is one or null.
*/ */
public ClassicControllerButtonsEvent getButtonsEvent() { public ClassicControllerButtonsEvent getButtonsEvent() {
return buttonsEvent; return buttonsEvent;
} }
/** /**
* Get event from the right joystick of the classic controller. * Get event from the right joystick of the classic controller.
* *
* @return the classic controller right Joystick Event if there is one or null. * @return the classic controller right Joystick Event if there is one or null.
*/ */
public JoystickEvent getClassicControllerRightJoystickEvent() { public JoystickEvent getClassicControllerRightJoystickEvent() {
return classicControllerRightJoystickEvent; return classicControllerRightJoystickEvent;
} }
/** /**
* Get event from the left joystick of the classic controller. * Get event from the left joystick of the classic controller.
* *
* @return the classic controller left Joystick Event if there is one or null. * @return the classic controller left Joystick Event if there is one or null.
*/ */
public JoystickEvent getClassicControllerLeftJoystickEvent() { public JoystickEvent getClassicControllerLeftJoystickEvent() {
return classicControllerLeftJoystickEvent; return classicControllerLeftJoystickEvent;
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** Classic Controller EVENT : WIIMOTE ID :" out += "/*********** Classic Controller EVENT : WIIMOTE ID :"
+ getWiimoteId() + " ********/\n"; + getWiimoteId() + " ********/\n";
out += buttonsEvent; out += buttonsEvent;
out += "Left shoulder : " + leftShoulder + "\n"; out += "Left shoulder : " + leftShoulder + "\n";
out += "Right shoulder : " + rightShoulder + "\n"; out += "Right shoulder : " + rightShoulder + "\n";
out += classicControllerLeftJoystickEvent; out += classicControllerLeftJoystickEvent;
out += classicControllerRightJoystickEvent; out += classicControllerRightJoystickEvent;
return out; return out;
} }
} }

View File

@@ -1,40 +1,40 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
import wiiusej.wiiusejevents.GenericEvent; import wiiusej.wiiusejevents.GenericEvent;
/** /**
* Mother Class of all expansions event. * Mother Class of all expansions event.
* *
* @author guiguito * @author guiguito
*/ */
public abstract class ExpansionEvent extends GenericEvent { public abstract class ExpansionEvent extends GenericEvent {
/** /**
* Constructor of an ExpansionEvent. * Constructor of an ExpansionEvent.
* *
* @param id * @param id
* id of the wiimote to which the expansion is connected. * id of the wiimote to which the expansion is connected.
*/ */
public ExpansionEvent(int id) { public ExpansionEvent(int id) {
super(id); super(id);
} }
public abstract String toString(); public abstract String toString();
} }

View File

@@ -1,214 +1,214 @@
/* This file is part of WiiuseJ. /* This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
/** /**
* Class which represents a buttons event from a Guitar Hero controller. * Class which represents a buttons event from a Guitar Hero controller.
* *
* @author guiguito * @author guiguito
*/ */
public class GuitarHeroButtonsEvent extends ButtonsEvent { public class GuitarHeroButtonsEvent extends ButtonsEvent {
private static short GUITAR_HERO_3_BUTTON_STRUM_UP = 0x0001; private static short GUITAR_HERO_3_BUTTON_STRUM_UP = 0x0001;
private static short GUITAR_HERO_3_BUTTON_YELLOW = 0x0008; private static short GUITAR_HERO_3_BUTTON_YELLOW = 0x0008;
private static short GUITAR_HERO_3_BUTTON_GREEN = 0x0010; private static short GUITAR_HERO_3_BUTTON_GREEN = 0x0010;
private static short GUITAR_HERO_3_BUTTON_BLUE = 0x0020; private static short GUITAR_HERO_3_BUTTON_BLUE = 0x0020;
private static short GUITAR_HERO_3_BUTTON_RED = 0x0040; private static short GUITAR_HERO_3_BUTTON_RED = 0x0040;
private static short GUITAR_HERO_3_BUTTON_ORANGE = 0x0080; private static short GUITAR_HERO_3_BUTTON_ORANGE = 0x0080;
private static short GUITAR_HERO_3_BUTTON_PLUS = 0x0400; private static short GUITAR_HERO_3_BUTTON_PLUS = 0x0400;
private static short GUITAR_HERO_3_BUTTON_MINUS = 0x1000; private static short GUITAR_HERO_3_BUTTON_MINUS = 0x1000;
private static short GUITAR_HERO_3_BUTTON_STRUM_DOWN = 0x4000; private static short GUITAR_HERO_3_BUTTON_STRUM_DOWN = 0x4000;
private static int GUITAR_HERO_3_BUTTON_ALL = 0xFEFF; private static int GUITAR_HERO_3_BUTTON_ALL = 0xFEFF;
/** /**
* Constructor of the guitar hero buttons Event. * Constructor of the guitar hero buttons Event.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed. * buttons just pressed.
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released. * buttons just released.
* @param buttonsHeld * @param buttonsHeld
* buttons just pressed. * buttons just pressed.
*/ */
public GuitarHeroButtonsEvent(int id, short buttonsJustPressed, public GuitarHeroButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) { short buttonsJustReleased, short buttonsHeld) {
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
} }
/* Button Strum Up */ /* Button Strum Up */
public boolean isButtonStrumUpJustPressed() { public boolean isButtonStrumUpJustPressed() {
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_STRUM_UP); return isButtonJustPressed(GUITAR_HERO_3_BUTTON_STRUM_UP);
} }
public boolean isButtonStrumUpJustReleased() { public boolean isButtonStrumUpJustReleased() {
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_STRUM_UP); return isButtonJustReleased(GUITAR_HERO_3_BUTTON_STRUM_UP);
} }
public boolean isButtonStrumUpeHeld() { public boolean isButtonStrumUpeHeld() {
return isButtonHeld(GUITAR_HERO_3_BUTTON_STRUM_UP); return isButtonHeld(GUITAR_HERO_3_BUTTON_STRUM_UP);
} }
public boolean isButtonStrumUpPressed() { public boolean isButtonStrumUpPressed() {
return isButtonPressed(GUITAR_HERO_3_BUTTON_STRUM_UP); return isButtonPressed(GUITAR_HERO_3_BUTTON_STRUM_UP);
} }
/* Button Strum Down */ /* Button Strum Down */
public boolean isButtonStrumDownJustPressed() { public boolean isButtonStrumDownJustPressed() {
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_STRUM_DOWN); return isButtonJustPressed(GUITAR_HERO_3_BUTTON_STRUM_DOWN);
} }
public boolean isButtonStrumDownJustReleased() { public boolean isButtonStrumDownJustReleased() {
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_STRUM_DOWN); return isButtonJustReleased(GUITAR_HERO_3_BUTTON_STRUM_DOWN);
} }
public boolean isButtonStrumDowneHeld() { public boolean isButtonStrumDowneHeld() {
return isButtonHeld(GUITAR_HERO_3_BUTTON_STRUM_DOWN); return isButtonHeld(GUITAR_HERO_3_BUTTON_STRUM_DOWN);
} }
public boolean isButtonStrumDownPressed() { public boolean isButtonStrumDownPressed() {
return isButtonPressed(GUITAR_HERO_3_BUTTON_STRUM_DOWN); return isButtonPressed(GUITAR_HERO_3_BUTTON_STRUM_DOWN);
} }
/* Button blue */ /* Button blue */
public boolean isButtonBlueJustPressed() { public boolean isButtonBlueJustPressed() {
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_BLUE); return isButtonJustPressed(GUITAR_HERO_3_BUTTON_BLUE);
} }
public boolean isButtonBlueJustReleased() { public boolean isButtonBlueJustReleased() {
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_BLUE); return isButtonJustReleased(GUITAR_HERO_3_BUTTON_BLUE);
} }
public boolean isButtonBlueHeld() { public boolean isButtonBlueHeld() {
return isButtonHeld(GUITAR_HERO_3_BUTTON_BLUE); return isButtonHeld(GUITAR_HERO_3_BUTTON_BLUE);
} }
public boolean isButtonBluePressed() { public boolean isButtonBluePressed() {
return isButtonPressed(GUITAR_HERO_3_BUTTON_BLUE); return isButtonPressed(GUITAR_HERO_3_BUTTON_BLUE);
} }
/* Button Green */ /* Button Green */
public boolean isButtonGreenJustPressed() { public boolean isButtonGreenJustPressed() {
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_GREEN); return isButtonJustPressed(GUITAR_HERO_3_BUTTON_GREEN);
} }
public boolean isButtonGreenJustReleased() { public boolean isButtonGreenJustReleased() {
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_GREEN); return isButtonJustReleased(GUITAR_HERO_3_BUTTON_GREEN);
} }
public boolean isButtonGreenHeld() { public boolean isButtonGreenHeld() {
return isButtonHeld(GUITAR_HERO_3_BUTTON_GREEN); return isButtonHeld(GUITAR_HERO_3_BUTTON_GREEN);
} }
public boolean isButtonGreenPressed() { public boolean isButtonGreenPressed() {
return isButtonPressed(GUITAR_HERO_3_BUTTON_GREEN); return isButtonPressed(GUITAR_HERO_3_BUTTON_GREEN);
} }
/* Button Minus */ /* Button Minus */
public boolean isButtonMinusJustPressed() { public boolean isButtonMinusJustPressed() {
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_MINUS); return isButtonJustPressed(GUITAR_HERO_3_BUTTON_MINUS);
} }
public boolean isButtonMinusJustReleased() { public boolean isButtonMinusJustReleased() {
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_MINUS); return isButtonJustReleased(GUITAR_HERO_3_BUTTON_MINUS);
} }
public boolean isButtonMinusHeld() { public boolean isButtonMinusHeld() {
return isButtonHeld(GUITAR_HERO_3_BUTTON_MINUS); return isButtonHeld(GUITAR_HERO_3_BUTTON_MINUS);
} }
public boolean isButtonMinusPressed() { public boolean isButtonMinusPressed() {
return isButtonPressed(GUITAR_HERO_3_BUTTON_MINUS); return isButtonPressed(GUITAR_HERO_3_BUTTON_MINUS);
} }
/* Button Orange */ /* Button Orange */
public boolean isButtonOrangeJustPressed() { public boolean isButtonOrangeJustPressed() {
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_ORANGE); return isButtonJustPressed(GUITAR_HERO_3_BUTTON_ORANGE);
} }
public boolean isButtonOrangeJustReleased() { public boolean isButtonOrangeJustReleased() {
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_ORANGE); return isButtonJustReleased(GUITAR_HERO_3_BUTTON_ORANGE);
} }
public boolean isButtonOrangeHeld() { public boolean isButtonOrangeHeld() {
return isButtonHeld(GUITAR_HERO_3_BUTTON_ORANGE); return isButtonHeld(GUITAR_HERO_3_BUTTON_ORANGE);
} }
public boolean isButtonOrangePressed() { public boolean isButtonOrangePressed() {
return isButtonPressed(GUITAR_HERO_3_BUTTON_ORANGE); return isButtonPressed(GUITAR_HERO_3_BUTTON_ORANGE);
} }
/* Button Plus */ /* Button Plus */
public boolean isButtonPlusJustPressed() { public boolean isButtonPlusJustPressed() {
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_PLUS); return isButtonJustPressed(GUITAR_HERO_3_BUTTON_PLUS);
} }
public boolean isButtonPlusJustReleased() { public boolean isButtonPlusJustReleased() {
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_PLUS); return isButtonJustReleased(GUITAR_HERO_3_BUTTON_PLUS);
} }
public boolean isButtonPlusHeld() { public boolean isButtonPlusHeld() {
return isButtonHeld(GUITAR_HERO_3_BUTTON_PLUS); return isButtonHeld(GUITAR_HERO_3_BUTTON_PLUS);
} }
public boolean isButtonPlusPressed() { public boolean isButtonPlusPressed() {
return isButtonPressed(GUITAR_HERO_3_BUTTON_PLUS); return isButtonPressed(GUITAR_HERO_3_BUTTON_PLUS);
} }
/* Button Red */ /* Button Red */
public boolean isButtonRedJustPressed() { public boolean isButtonRedJustPressed() {
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_RED); return isButtonJustPressed(GUITAR_HERO_3_BUTTON_RED);
} }
public boolean isButtonRedJustReleased() { public boolean isButtonRedJustReleased() {
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_RED); return isButtonJustReleased(GUITAR_HERO_3_BUTTON_RED);
} }
public boolean isButtonRedHeld() { public boolean isButtonRedHeld() {
return isButtonHeld(GUITAR_HERO_3_BUTTON_RED); return isButtonHeld(GUITAR_HERO_3_BUTTON_RED);
} }
public boolean isButtonRedPressed() { public boolean isButtonRedPressed() {
return isButtonPressed(GUITAR_HERO_3_BUTTON_RED); return isButtonPressed(GUITAR_HERO_3_BUTTON_RED);
} }
/* Button Yellow */ /* Button Yellow */
public boolean isButtonYellowJustPressed() { public boolean isButtonYellowJustPressed() {
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_YELLOW); return isButtonJustPressed(GUITAR_HERO_3_BUTTON_YELLOW);
} }
public boolean isButtonYellowJustReleased() { public boolean isButtonYellowJustReleased() {
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_YELLOW); return isButtonJustReleased(GUITAR_HERO_3_BUTTON_YELLOW);
} }
public boolean isButtonYellowHeld() { public boolean isButtonYellowHeld() {
return isButtonHeld(GUITAR_HERO_3_BUTTON_YELLOW); return isButtonHeld(GUITAR_HERO_3_BUTTON_YELLOW);
} }
public boolean isButtonYellowPressed() { public boolean isButtonYellowPressed() {
return isButtonPressed(GUITAR_HERO_3_BUTTON_YELLOW); return isButtonPressed(GUITAR_HERO_3_BUTTON_YELLOW);
} }
} }

View File

@@ -1,119 +1,119 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
/** /**
* This class represents the values from the GuitarHero and its events. * This class represents the values from the GuitarHero and its events.
* *
* @author guiguito * @author guiguito
*/ */
public class GuitarHeroEvent extends ExpansionEvent{ public class GuitarHeroEvent extends ExpansionEvent{
private float whammyBar; private float whammyBar;
private GuitarHeroButtonsEvent buttonsEvent; private GuitarHeroButtonsEvent buttonsEvent;
private JoystickEvent guitarHeroJoystickEvent; private JoystickEvent guitarHeroJoystickEvent;
/** /**
* Constructor of GuitarHeroEvent. * Constructor of GuitarHeroEvent.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed. * buttons just pressed.
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released. * buttons just released.
* @param buttonsHeld * @param buttonsHeld
* buttons just pressed. * buttons just pressed.
* @param whammyBar * @param whammyBar
* whammy bar (range 0-1). * whammy bar (range 0-1).
* @param angle * @param angle
* angle the joystick is being held. * angle the joystick is being held.
* @param magnitude * @param magnitude
* magnitude of the joystick (range 0-1). * magnitude of the joystick (range 0-1).
* @param max1 * @param max1
* maximum joystick value 1. * maximum joystick value 1.
* @param max2 * @param max2
* maximum joystick value 2. * maximum joystick value 2.
* @param min1 * @param min1
* minimum joystick value 1. * minimum joystick value 1.
* @param min2 * @param min2
* minimum joystick value 2. * minimum joystick value 2.
* @param center1 * @param center1
* center joystick value 1. * center joystick value 1.
* @param center2 * @param center2
* center joystick value 2. * center joystick value 2.
*/ */
public GuitarHeroEvent(int id, short buttonsJustPressed, public GuitarHeroEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld, float whammyBar, short buttonsJustReleased, short buttonsHeld, float whammyBar,
float angle, float magnitude, short max1, float angle, float magnitude, short max1,
short max2, short min1, short min2, short center1, short max2, short min1, short min2, short center1,
short center2) { short center2) {
super(id); super(id);
this.whammyBar = whammyBar; this.whammyBar = whammyBar;
buttonsEvent = new GuitarHeroButtonsEvent(id, buttonsEvent = new GuitarHeroButtonsEvent(id,
buttonsJustPressed, buttonsJustReleased, buttonsHeld); buttonsJustPressed, buttonsJustReleased, buttonsHeld);
guitarHeroJoystickEvent = new JoystickEvent(id, angle, guitarHeroJoystickEvent = new JoystickEvent(id, angle,
magnitude, max1, max2, min1, min2, center1, center2); magnitude, max1, max2, min1, min2, center1, center2);
} }
/** /**
* Tell if there is a Guitar Hero joystick event. * Tell if there is a Guitar Hero joystick event.
* *
* @return TRUE if there is a Guitar Hero joystick event, false otherwise. * @return TRUE if there is a Guitar Hero joystick event, false otherwise.
*/ */
public boolean isThereGuitarHeroJoystickEvent() { public boolean isThereGuitarHeroJoystickEvent() {
return guitarHeroJoystickEvent != null; return guitarHeroJoystickEvent != null;
} }
/** /**
* Whammy bar (range 0-1). * Whammy bar (range 0-1).
* @return the whammyBar value. * @return the whammyBar value.
*/ */
public float getWhammyBar() { public float getWhammyBar() {
return whammyBar; return whammyBar;
} }
/** /**
* Get buttons event for the guitar hero controller. * Get buttons event for the guitar hero controller.
* @return the guitar hero controller buttons event if there is one or null. * @return the guitar hero controller buttons event if there is one or null.
*/ */
public GuitarHeroButtonsEvent getButtonsEvent() { public GuitarHeroButtonsEvent getButtonsEvent() {
return buttonsEvent; return buttonsEvent;
} }
/** /**
* Get event from the joystick of the guitar hero controller. * Get event from the joystick of the guitar hero controller.
* @return the guitar hero controller joystick Event if there is one or null. * @return the guitar hero controller joystick Event if there is one or null.
*/ */
public JoystickEvent getGuitarHeroJoystickEvent() { public JoystickEvent getGuitarHeroJoystickEvent() {
return guitarHeroJoystickEvent; return guitarHeroJoystickEvent;
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** Guitar Hero 3 EVENT : WIIMOTE ID :" + getWiimoteId() out += "/*********** Guitar Hero 3 EVENT : WIIMOTE ID :" + getWiimoteId()
+ " ********/\n"; + " ********/\n";
out += buttonsEvent; out += buttonsEvent;
out += "Whammy Bar : "+whammyBar+"\n"; out += "Whammy Bar : "+whammyBar+"\n";
out += guitarHeroJoystickEvent; out += guitarHeroJoystickEvent;
return out; return out;
} }
} }

View File

@@ -1,319 +1,319 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
import wiiusej.values.IRSource; import wiiusej.values.IRSource;
import wiiusej.wiiusejevents.GenericEvent; import wiiusej.wiiusejevents.GenericEvent;
/** /**
* Class which represents an IR event. * Class which represents an IR event.
* *
* @author guiguito * @author guiguito
*/ */
public class IREvent extends GenericEvent { public class IREvent extends GenericEvent {
/* IR Tracking */ /* IR Tracking */
private IRSource[] IRPoints; private IRSource[] IRPoints;
private short indexPoints = 0; private short indexPoints = 0;
private int x; private int x;
private int y; private int y;
private float z;// distance from the sensor bar private float z;// distance from the sensor bar
private int ax; private int ax;
private int ay; private int ay;
private int xVRes; private int xVRes;
private int yVRes; private int yVRes;
private int xOffset; private int xOffset;
private int yOffset; private int yOffset;
private short sensorBarPostion; private short sensorBarPostion;
private short screenAsPectRatio; private short screenAsPectRatio;
private short irSensitivity; private short irSensitivity;
private float distance; private float distance;
static private short WIIUSE_IR_ABOVE = 0; static private short WIIUSE_IR_ABOVE = 0;
static private short WIIUSE_IR_BELOW = 1; static private short WIIUSE_IR_BELOW = 1;
static private short WIIUSE_SCREEN_RATIO_4_3 = 0; static private short WIIUSE_SCREEN_RATIO_4_3 = 0;
static private short WIIUSE_SCREEN_RATIO_16_9 = 1; static private short WIIUSE_SCREEN_RATIO_16_9 = 1;
private static short NB_POINTS = 4;// number of points IR can track private static short NB_POINTS = 4;// number of points IR can track
/** /**
* Constructor of IREvent with full infos. * Constructor of IREvent with full infos.
* *
* @param id * @param id
* d of the wiimote concerned. * d of the wiimote concerned.
* @param x * @param x
* calculated X coordinate. * calculated X coordinate.
* @param y * @param y
* calculated Y coordinate. * calculated Y coordinate.
* @param z * @param z
* calculated distance. * calculated distance.
* @param ax * @param ax
* absolute X coordinate. * absolute X coordinate.
* @param ay * @param ay
* absolute Y coordinate * absolute Y coordinate
* @param xVRes * @param xVRes
* IR virtual screen x resolution. * IR virtual screen x resolution.
* @param yVRes * @param yVRes
* IR virtual screen y resolution. * IR virtual screen y resolution.
* @param xOffset * @param xOffset
* IR X correction offset. * IR X correction offset.
* @param yOffset * @param yOffset
* IR Y correction offset. * IR Y correction offset.
* @param sensorBarPostion * @param sensorBarPostion
* aspect ratio of the screen. * aspect ratio of the screen.
* @param screenAsPectRatio * @param screenAsPectRatio
* IR sensor bar position. * IR sensor bar position.
* @param irSensitivity * @param irSensitivity
* Sensitivity of the infrared camera. * Sensitivity of the infrared camera.
* @param distance * @param distance
* Pixel Distance between first two dots * Pixel Distance between first two dots
*/ */
public IREvent(int id, int x, int y, float z, int ax, int ay, int xVRes, public IREvent(int id, int x, int y, float z, int ax, int ay, int xVRes,
int yVRes, int xOffset, int yOffset, short sensorBarPostion, int yVRes, int xOffset, int yOffset, short sensorBarPostion,
short screenAsPectRatio, short irSensitivity, float distance) { short screenAsPectRatio, short irSensitivity, float distance) {
super(id); super(id);
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
this.ax = ax; this.ax = ax;
this.ay = ay; this.ay = ay;
this.xVRes = xVRes; this.xVRes = xVRes;
this.yVRes = yVRes; this.yVRes = yVRes;
this.xOffset = xOffset; this.xOffset = xOffset;
this.yOffset = yOffset; this.yOffset = yOffset;
this.sensorBarPostion = sensorBarPostion; this.sensorBarPostion = sensorBarPostion;
this.screenAsPectRatio = screenAsPectRatio; this.screenAsPectRatio = screenAsPectRatio;
this.irSensitivity = irSensitivity; this.irSensitivity = irSensitivity;
this.distance = distance; this.distance = distance;
IRPoints = new IRSource[NB_POINTS]; IRPoints = new IRSource[NB_POINTS];
} }
/** /**
* Get list of IR points. * Get list of IR points.
* *
* @return the list of 2D points * @return the list of 2D points
*/ */
public IRSource[] getIRPoints() { public IRSource[] getIRPoints() {
IRSource[] ir = new IRSource[indexPoints]; IRSource[] ir = new IRSource[indexPoints];
System.arraycopy(IRPoints, 0, ir, 0, indexPoints); System.arraycopy(IRPoints, 0, ir, 0, indexPoints);
return ir; return ir;
} }
/** /**
* Add IR Point in the list (Max 4 points) * Add IR Point in the list (Max 4 points)
* *
* @param x * @param x
* x value * x value
* @param y * @param y
* y value * y value
* @param rx * @param rx
* raw X coordinate (0-1023). * raw X coordinate (0-1023).
* @param ry * @param ry
* raw Y coordinate (0-1023). * raw Y coordinate (0-1023).
* @param size * @param size
* size of the IR dot (0-15). * size of the IR dot (0-15).
*/ */
public void addIRpoint(int x, int y, short rx, short ry, short size) { public void addIRpoint(int x, int y, short rx, short ry, short size) {
IRPoints[indexPoints] = new IRSource(x, y, rx, ry, size); IRPoints[indexPoints] = new IRSource(x, y, rx, ry, size);
indexPoints++; indexPoints++;
return; return;
} }
/** /**
* Return calculated X coordinate. * Return calculated X coordinate.
* *
* @return the x * @return the x
*/ */
public int getX() { public int getX() {
return x; return x;
} }
/** /**
* Return calculated Y coordinate. * Return calculated Y coordinate.
* *
* @return the y * @return the y
*/ */
public int getY() { public int getY() {
return y; return y;
} }
/** /**
* Return calculated distance. * Return calculated distance.
* *
* @return the z * @return the z
*/ */
public float getZ() { public float getZ() {
return z; return z;
} }
/** /**
* Return absolute X coordinate. * Return absolute X coordinate.
* *
* @return the ax * @return the ax
*/ */
public int getAx() { public int getAx() {
return ax; return ax;
} }
/** /**
* Return absolute Y coordinate. * Return absolute Y coordinate.
* *
* @return the ay * @return the ay
*/ */
public int getAy() { public int getAy() {
return ay; return ay;
} }
/** /**
* Return IR virtual screen x resolution. * Return IR virtual screen x resolution.
* *
* @return the xVRes * @return the xVRes
*/ */
public int getXVRes() { public int getXVRes() {
return xVRes; return xVRes;
} }
/** /**
* Return IR virtual screen y resolution. * Return IR virtual screen y resolution.
* *
* @return the yVRes * @return the yVRes
*/ */
public int getYVRes() { public int getYVRes() {
return yVRes; return yVRes;
} }
/** /**
* Return IR X correction offset. * Return IR X correction offset.
* *
* @return the xOffset * @return the xOffset
*/ */
public int getXOffset() { public int getXOffset() {
return xOffset; return xOffset;
} }
/** /**
* Return IR Y correction offset. * Return IR Y correction offset.
* *
* @return the yOffset * @return the yOffset
*/ */
public int getYOffset() { public int getYOffset() {
return yOffset; return yOffset;
} }
/** /**
* Return true if the sensor bar is above. * Return true if the sensor bar is above.
* *
* @return true if the sensor bar is above. * @return true if the sensor bar is above.
*/ */
public boolean isSensorBarAbove() { public boolean isSensorBarAbove() {
return sensorBarPostion == WIIUSE_IR_ABOVE; return sensorBarPostion == WIIUSE_IR_ABOVE;
} }
/** /**
* Return true if the sensor bar is below. * Return true if the sensor bar is below.
* *
* @return true if the sensor bar is below. * @return true if the sensor bar is below.
*/ */
public boolean isSensorBarBelow() { public boolean isSensorBarBelow() {
return sensorBarPostion == WIIUSE_IR_BELOW; return sensorBarPostion == WIIUSE_IR_BELOW;
} }
/** /**
* Return true if screen aspect ratio set is 4/3. * Return true if screen aspect ratio set is 4/3.
* *
* @return true if screen aspect ratio set is 4/3. * @return true if screen aspect ratio set is 4/3.
*/ */
public boolean isScreenAspectRatio43() { public boolean isScreenAspectRatio43() {
return screenAsPectRatio == WIIUSE_SCREEN_RATIO_4_3; return screenAsPectRatio == WIIUSE_SCREEN_RATIO_4_3;
} }
/** /**
* Return true if screen aspect ratio set is 16/9. * Return true if screen aspect ratio set is 16/9.
* *
* @return true if screen aspect ratio set is 16/9. * @return true if screen aspect ratio set is 16/9.
*/ */
public boolean isScreenAspectRatio169() { public boolean isScreenAspectRatio169() {
return screenAsPectRatio == WIIUSE_SCREEN_RATIO_16_9; return screenAsPectRatio == WIIUSE_SCREEN_RATIO_16_9;
} }
/** /**
* Return aspect ratio of the screen. * Return aspect ratio of the screen.
* *
* @return the screenAsPectRatio * @return the screenAsPectRatio
*/ */
public short getScreenAsPectRatio() { public short getScreenAsPectRatio() {
return screenAsPectRatio; return screenAsPectRatio;
} }
/** /**
* The sensitivity of the IR camera can be turned up or down depending on * The sensitivity of the IR camera can be turned up or down depending on
* your needs. Like the Wii, wiiusej and wiiuse can set the camera * your needs. Like the Wii, wiiusej and wiiuse can set the camera
* sensitivity to a degree between 1 (lowest) and 5 (highest). The default * sensitivity to a degree between 1 (lowest) and 5 (highest). The default
* is 3. * is 3.
* *
* @return the irSensitivity * @return the irSensitivity
*/ */
public short getIrSensitivity() { public short getIrSensitivity() {
return irSensitivity; return irSensitivity;
} }
/** /**
* Pixel distance between first 2 dots. * Pixel distance between first 2 dots.
* *
* @return the distance between first 2 dots. * @return the distance between first 2 dots.
*/ */
public float getDistance() { public float getDistance() {
return distance; return distance;
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Display IR Tracking */ /* Display IR Tracking */
out += "/******** IR Tracking ********/\n"; out += "/******** IR Tracking ********/\n";
out += "--- Active : true\n"; out += "--- Active : true\n";
out += "--- calculated X coordinate : " + x + "\n"; out += "--- calculated X coordinate : " + x + "\n";
out += "--- calculated Y coordinate : " + y + "\n"; out += "--- calculated Y coordinate : " + y + "\n";
out += "--- calculated Z coordinate : " + z + "\n"; out += "--- calculated Z coordinate : " + z + "\n";
out += "--- calculated distance : " + distance + "\n"; out += "--- calculated distance : " + distance + "\n";
out += "--- absolute X coordinate : " + ax + "\n"; out += "--- absolute X coordinate : " + ax + "\n";
out += "--- absolute Y coordinate : " + ay + "\n"; out += "--- absolute Y coordinate : " + ay + "\n";
out += "--- IR virtual screen x resolution : " + xVRes + "\n"; out += "--- IR virtual screen x resolution : " + xVRes + "\n";
out += "--- IR virtual screen y resolution : " + yVRes + "\n"; out += "--- IR virtual screen y resolution : " + yVRes + "\n";
out += "--- IR X correction offset : " + xOffset + "\n"; out += "--- IR X correction offset : " + xOffset + "\n";
out += "--- IR Y correction offset : " + yOffset + "\n"; out += "--- IR Y correction offset : " + yOffset + "\n";
out += "--- IR Sensitivity (between 1-5) : " + irSensitivity + "\n"; out += "--- IR Sensitivity (between 1-5) : " + irSensitivity + "\n";
if (isScreenAspectRatio43()) { if (isScreenAspectRatio43()) {
out += "--- aspect ratio of the screen : 4/3\n"; out += "--- aspect ratio of the screen : 4/3\n";
} else if (isScreenAspectRatio169()) { } else if (isScreenAspectRatio169()) {
out += "--- aspect ratio of the screen : 16/9\n"; out += "--- aspect ratio of the screen : 16/9\n";
} }
if (isSensorBarAbove()) { if (isSensorBarAbove()) {
out += "--- IR sensor bar position. : Above\n"; out += "--- IR sensor bar position. : Above\n";
} else if (isSensorBarBelow()) { } else if (isSensorBarBelow()) {
out += "--- IR sensor bar position. : Below\n"; out += "--- IR sensor bar position. : Below\n";
} }
out += "--- Seen points\n"; out += "--- Seen points\n";
for (int i = 0; i < IRPoints.length; i++) { for (int i = 0; i < IRPoints.length; i++) {
if (IRPoints[i] != null) { if (IRPoints[i] != null) {
out += IRPoints[i].toString(); out += IRPoints[i].toString();
} }
} }
out += "\n"; out += "\n";
return out; return out;
} }
} }

View File

@@ -1,135 +1,135 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
import wiiusej.wiiusejevents.GenericEvent; import wiiusej.wiiusejevents.GenericEvent;
/** /**
* Class that stores values on a joystick Event. * Class that stores values on a joystick Event.
* *
* @author guiguito * @author guiguito
*/ */
public class JoystickEvent extends GenericEvent { public class JoystickEvent extends GenericEvent {
private float angle; private float angle;
private float magnitude; private float magnitude;
private short[] max; private short[] max;
private short[] min; private short[] min;
private short[] center; private short[] center;
/** /**
* Constructor of a JoystickEvent. * Constructor of a JoystickEvent.
* *
* @param id * @param id
* id of the wiimote connected. * id of the wiimote connected.
* @param angle * @param angle
* angle the joystick is being held. * angle the joystick is being held.
* @param magnitude * @param magnitude
* magnitude of the joystick (range 0-1). * magnitude of the joystick (range 0-1).
* @param max1 * @param max1
* maximum joystick value 1. * maximum joystick value 1.
* @param max2 * @param max2
* maximum joystick value 2. * maximum joystick value 2.
* @param min1 * @param min1
* minimum joystick value 1. * minimum joystick value 1.
* @param min2 * @param min2
* minimum joystick value 2. * minimum joystick value 2.
* @param center1 * @param center1
* center joystick value 1. * center joystick value 1.
* @param center2 * @param center2
* center joystick value 2. * center joystick value 2.
*/ */
public JoystickEvent(int id, float angle, float magnitude, short max1, public JoystickEvent(int id, float angle, float magnitude, short max1,
short max2, short min1, short min2, short center1, short center2) { short max2, short min1, short min2, short center1, short center2) {
super(id); super(id);
this.angle = angle; this.angle = angle;
this.magnitude = magnitude; this.magnitude = magnitude;
max = new short[2]; max = new short[2];
max[0] = max1; max[0] = max1;
max[1] = max2; max[1] = max2;
min = new short[2]; min = new short[2];
min[0] = min1; min[0] = min1;
min[1] = min2; min[1] = min2;
center = new short[2]; center = new short[2];
center[0] = center1; center[0] = center1;
center[1] = center2; center[1] = center2;
} }
/** /**
* Get angle the joystick is being held. * Get angle the joystick is being held.
* *
* @return the angle angle the joystick. * @return the angle angle the joystick.
*/ */
public float getAngle() { public float getAngle() {
return angle; return angle;
} }
/** /**
* Get magnitude of the joystick (range 0-1). * Get magnitude of the joystick (range 0-1).
* *
* @return the magnitude magnitude of the joystick. * @return the magnitude magnitude of the joystick.
*/ */
public float getMagnitude() { public float getMagnitude() {
return magnitude; return magnitude;
} }
/** /**
* Maximum joystick values. * Maximum joystick values.
* *
* @return the max * @return the max
*/ */
public short[] getMax() { public short[] getMax() {
return max; return max;
} }
/** /**
* Minimum joystick values. * Minimum joystick values.
* *
* @return the min * @return the min
*/ */
public short[] getMin() { public short[] getMin() {
return min; return min;
} }
/** /**
* Center joystick values. * Center joystick values.
* *
* @return the center * @return the center
*/ */
public short[] getCenter() { public short[] getCenter() {
return center; return center;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see wiiusej.wiiusejevents.GenericEvent#toString() * @see wiiusej.wiiusejevents.GenericEvent#toString()
*/ */
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Display IR Tracking */ /* Display IR Tracking */
out += "/******** Joystick ********/\n"; out += "/******** Joystick ********/\n";
out += "--- angle : " + angle + "\n"; out += "--- angle : " + angle + "\n";
out += "--- magnitude : " + magnitude + "\n"; out += "--- magnitude : " + magnitude + "\n";
out += "--- maximum values : " + max[0] + "," + max[1] + "\n"; out += "--- maximum values : " + max[0] + "," + max[1] + "\n";
out += "--- minimum values : " + min[0] + "," + min[1] + "\n"; out += "--- minimum values : " + min[0] + "," + min[1] + "\n";
out += "--- center values : " + center[0] + "," + center[1] + "\n"; out += "--- center values : " + center[0] + "," + center[1] + "\n";
return out; return out;
} }
} }

View File

@@ -1,203 +1,203 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
import wiiusej.values.GForce; import wiiusej.values.GForce;
import wiiusej.values.Orientation; import wiiusej.values.Orientation;
import wiiusej.values.RawAcceleration; import wiiusej.values.RawAcceleration;
import wiiusej.wiiusejevents.GenericEvent; import wiiusej.wiiusejevents.GenericEvent;
/** /**
* Class which represents a motion sensing event. * Class which represents a motion sensing event.
* *
* @author guiguito * @author guiguito
*/ */
public class MotionSensingEvent extends GenericEvent { public class MotionSensingEvent extends GenericEvent {
/* Motion Sensing */ /* Motion Sensing */
private Orientation orientation; private Orientation orientation;
private GForce gforce; private GForce gforce;
private RawAcceleration acceleration; private RawAcceleration acceleration;
private float orientationThreshold = 0; private float orientationThreshold = 0;
private int accelerationThreshold = 0; private int accelerationThreshold = 0;
private float alphaSmoothing = 0; private float alphaSmoothing = 0;
private boolean isSmoothingActive = false; private boolean isSmoothingActive = false;
/** /**
* Constructor for a Motion Sensing Event. * Constructor for a Motion Sensing Event.
* *
* @param id * @param id
* id of the wiimote concerned. * id of the wiimote concerned.
* @param orientationThreshold * @param orientationThreshold
* value of the minimum angle between two events with the * value of the minimum angle between two events with the
* accelerometer. * accelerometer.
* @param accelerationThreshold * @param accelerationThreshold
* value of the value variation between two events with the * value of the value variation between two events with the
* accelerometer. * accelerometer.
* @param smoothingState * @param smoothingState
* true if smoothing flag is activated. * true if smoothing flag is activated.
* @param alphaSmooth * @param alphaSmooth
* value of the alpha smoothing parameter. * value of the alpha smoothing parameter.
* @param r * @param r
* roll. * roll.
* @param p * @param p
* pitch. * pitch.
* @param ya * @param ya
* yaw. * yaw.
* @param ar * @param ar
* absolute roll. * absolute roll.
* @param ap * @param ap
* absolute pitch. * absolute pitch.
* @param x * @param x
* gravity force on x axis. * gravity force on x axis.
* @param y * @param y
* gravity force on y axis. * gravity force on y axis.
* @param z * @param z
* gravity force on z axis. * gravity force on z axis.
* @param xx * @param xx
* raw acceleration on x axis. * raw acceleration on x axis.
* @param yy * @param yy
* raw acceleration on y axis. * raw acceleration on y axis.
* @param zz * @param zz
* raw acceleration on z axis. * raw acceleration on z axis.
*/ */
public MotionSensingEvent(int id, float orientationThreshold, public MotionSensingEvent(int id, float orientationThreshold,
int accelerationThreshold, boolean smoothingState, int accelerationThreshold, boolean smoothingState,
float alphaSmooth, float r, float p, float ya, float ar, float ap, float alphaSmooth, float r, float p, float ya, float ar, float ap,
float x, float y, float z, short xx, short yy, short zz) { float x, float y, float z, short xx, short yy, short zz) {
super(id); super(id);
this.orientationThreshold = orientationThreshold; this.orientationThreshold = orientationThreshold;
this.accelerationThreshold = accelerationThreshold; this.accelerationThreshold = accelerationThreshold;
this.isSmoothingActive = smoothingState; this.isSmoothingActive = smoothingState;
this.alphaSmoothing = alphaSmooth; this.alphaSmoothing = alphaSmooth;
setOrientationAndGforce(r, p, ya, ar, ap, x, y, z, xx, yy, zz); setOrientationAndGforce(r, p, ya, ar, ap, x, y, z, xx, yy, zz);
} }
/** /**
* Set orientation, gravity force and raw acceleration. * Set orientation, gravity force and raw acceleration.
* *
* @param r * @param r
* roll * roll
* @param p * @param p
* pitch * pitch
* @param ya * @param ya
* yaw * yaw
* @param ar * @param ar
* absolute roll * absolute roll
* @param ap * @param ap
* absolute pitch * absolute pitch
* @param x * @param x
* gravity force on x axis * gravity force on x axis
* @param y * @param y
* gravity force on y axis * gravity force on y axis
* @param z * @param z
* gravity force on z axis * gravity force on z axis
* @param xx * @param xx
* raw acceleration on x axis * raw acceleration on x axis
* @param yy * @param yy
* raw acceleration on y axis * raw acceleration on y axis
* @param zz * @param zz
* raw acceleration on z axis * raw acceleration on z axis
*/ */
private void setOrientationAndGforce(float r, float p, float ya, float ar, private void setOrientationAndGforce(float r, float p, float ya, float ar,
float ap, float x, float y, float z, short xx, short yy, short zz) { float ap, float x, float y, float z, short xx, short yy, short zz) {
this.orientation = new Orientation(r, p, ya, ar, ap); this.orientation = new Orientation(r, p, ya, ar, ap);
this.gforce = new GForce(x, y, z); this.gforce = new GForce(x, y, z);
this.acceleration = new RawAcceleration(xx, yy, zz); this.acceleration = new RawAcceleration(xx, yy, zz);
} }
/** /**
* @return the orientation * @return the orientation
*/ */
public Orientation getOrientation() { public Orientation getOrientation() {
return orientation; return orientation;
} }
/** /**
* Get the gravity force. * Get the gravity force.
* *
* @return the gforce * @return the gforce
*/ */
public GForce getGforce() { public GForce getGforce() {
return gforce; return gforce;
} }
/** /**
* Get the raw acceleration. * Get the raw acceleration.
* *
* @return the raw acceleration * @return the raw acceleration
*/ */
public RawAcceleration getRawAcceleration() { public RawAcceleration getRawAcceleration() {
return acceleration; return acceleration;
} }
/** /**
* Get orientation threshold. * Get orientation threshold.
* *
* @return the orientationThreshold * @return the orientationThreshold
*/ */
public float getOrientationThreshold() { public float getOrientationThreshold() {
return orientationThreshold; return orientationThreshold;
} }
/** /**
* Get acceleration threshold. * Get acceleration threshold.
* *
* @return the accelerationThreshold * @return the accelerationThreshold
*/ */
public int getAccelerationThreshold() { public int getAccelerationThreshold() {
return accelerationThreshold; return accelerationThreshold;
} }
/** /**
* Get alpha smoothing. * Get alpha smoothing.
* *
* @return the alphaSmoothing * @return the alphaSmoothing
*/ */
public float getAlphaSmoothing() { public float getAlphaSmoothing() {
return alphaSmoothing; return alphaSmoothing;
} }
/** /**
* Tell if the option SMOOTHING is activated. * Tell if the option SMOOTHING is activated.
* *
* @return the isSmoothingActive * @return the isSmoothingActive
*/ */
public boolean isSmoothingActive() { public boolean isSmoothingActive() {
return isSmoothingActive; return isSmoothingActive;
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Motion sensing */ /* Motion sensing */
out += "/******** Motion sensing ********/\n"; out += "/******** Motion sensing ********/\n";
out += "--- Motion sensing : true \n"; out += "--- Motion sensing : true \n";
out += "--- Orientation threshold value ? : " + orientationThreshold out += "--- Orientation threshold value ? : " + orientationThreshold
+ "\n"; + "\n";
out += "--- Acceleration threshold value ? : " + accelerationThreshold out += "--- Acceleration threshold value ? : " + accelerationThreshold
+ "\n"; + "\n";
out += "--- Alpha smoothing threshold value ? : " + alphaSmoothing out += "--- Alpha smoothing threshold value ? : " + alphaSmoothing
+ "\n"; + "\n";
out += "--- Smoothing ? : " + isSmoothingActive + "\n"; out += "--- Smoothing ? : " + isSmoothingActive + "\n";
out += "--- " + orientation + "\n"; out += "--- " + orientation + "\n";
out += "--- " + gforce + "\n"; out += "--- " + gforce + "\n";
out += "--- " + acceleration + "\n"; out += "--- " + acceleration + "\n";
return out; return out;
} }
} }

View File

@@ -1,89 +1,89 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
/** /**
* Class which represents a buttons event from a Nunchuk. * Class which represents a buttons event from a Nunchuk.
* *
* @author guiguito * @author guiguito
*/ */
public class NunchukButtonsEvent extends ButtonsEvent { public class NunchukButtonsEvent extends ButtonsEvent {
private static short NUNCHUK_BUTTON_Z = 0x01; private static short NUNCHUK_BUTTON_Z = 0x01;
private static short NUNCHUK_BUTTON_C = 0x02; private static short NUNCHUK_BUTTON_C = 0x02;
private static short NUNCHUK_BUTTON_ALL = 0x03; private static short NUNCHUK_BUTTON_ALL = 0x03;
/** /**
* Constructor of the nunchuk buttons Event. * Constructor of the nunchuk buttons Event.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed. * buttons just pressed.
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released. * buttons just released.
* @param buttonsHeld * @param buttonsHeld
* buttons just pressed. * buttons just pressed.
*/ */
public NunchukButtonsEvent(int id, short buttonsJustPressed, public NunchukButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) { short buttonsJustReleased, short buttonsHeld) {
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
} }
/* Button Z */ /* Button Z */
public boolean isButtonZJustPressed() { public boolean isButtonZJustPressed() {
return isButtonJustPressed(NUNCHUK_BUTTON_Z); return isButtonJustPressed(NUNCHUK_BUTTON_Z);
} }
public boolean isButtonZJustReleased() { public boolean isButtonZJustReleased() {
return isButtonJustReleased(NUNCHUK_BUTTON_Z); return isButtonJustReleased(NUNCHUK_BUTTON_Z);
} }
public boolean isButtonZeHeld() { public boolean isButtonZeHeld() {
return isButtonHeld(NUNCHUK_BUTTON_Z); return isButtonHeld(NUNCHUK_BUTTON_Z);
} }
public boolean isButtonZPressed() { public boolean isButtonZPressed() {
return isButtonPressed(NUNCHUK_BUTTON_Z); return isButtonPressed(NUNCHUK_BUTTON_Z);
} }
/* Button Z */ /* Button Z */
public boolean isButtonCJustPressed() { public boolean isButtonCJustPressed() {
return isButtonJustPressed(NUNCHUK_BUTTON_C); return isButtonJustPressed(NUNCHUK_BUTTON_C);
} }
public boolean isButtonCJustReleased() { public boolean isButtonCJustReleased() {
return isButtonJustReleased(NUNCHUK_BUTTON_C); return isButtonJustReleased(NUNCHUK_BUTTON_C);
} }
public boolean isButtonCHeld() { public boolean isButtonCHeld() {
return isButtonHeld(NUNCHUK_BUTTON_C); return isButtonHeld(NUNCHUK_BUTTON_C);
} }
public boolean isButtonCPressed() { public boolean isButtonCPressed() {
return isButtonPressed(NUNCHUK_BUTTON_C); return isButtonPressed(NUNCHUK_BUTTON_C);
} }
@Override @Override
public String toString() { public String toString() {
return "/******** Buttons for Nunchuk Event ********/\n" return "/******** Buttons for Nunchuk Event ********/\n"
+ super.toString(); + super.toString();
} }
} }

View File

@@ -1,169 +1,169 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
/** /**
* This class represents the values from the joystick and its events. * This class represents the values from the joystick and its events.
* *
* @author guiguito * @author guiguito
*/ */
public class NunchukEvent extends ExpansionEvent { public class NunchukEvent extends ExpansionEvent {
private NunchukButtonsEvent buttonsEvent; private NunchukButtonsEvent buttonsEvent;
private MotionSensingEvent nunchukMotionSensingEvent; private MotionSensingEvent nunchukMotionSensingEvent;
private JoystickEvent nunchukJoystickEvent; private JoystickEvent nunchukJoystickEvent;
/** /**
* Constructor of NunchukEvent. * Constructor of NunchukEvent.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed. * buttons just pressed.
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released. * buttons just released.
* @param buttonsHeld * @param buttonsHeld
* buttons just pressed. * buttons just pressed.
* @param orientationThreshold * @param orientationThreshold
* value of the minimum angle between two events with the * value of the minimum angle between two events with the
* accelerometer. * accelerometer.
* @param accelerationThreshold * @param accelerationThreshold
* value of the value variation between two events with the * value of the value variation between two events with the
* accelerometer. * accelerometer.
* @param smoothingState * @param smoothingState
* true if smoothing flag is activated. * true if smoothing flag is activated.
* @param alphaSmooth * @param alphaSmooth
* value of the alpha smoothing parameter. * value of the alpha smoothing parameter.
* @param r * @param r
* roll. * roll.
* @param p * @param p
* pitch. * pitch.
* @param ya * @param ya
* yaw. * yaw.
* @param ar * @param ar
* absolute roll. * absolute roll.
* @param ap * @param ap
* absolute pitch. * absolute pitch.
* @param x * @param x
* gravity force on x axis. * gravity force on x axis.
* @param y * @param y
* gravity force on y axis. * gravity force on y axis.
* @param z * @param z
* gravity force on z axis. * gravity force on z axis.
* @param xx * @param xx
* raw acceleration on x axis. * raw acceleration on x axis.
* @param yy * @param yy
* raw acceleration on y axis. * raw acceleration on y axis.
* @param zz * @param zz
* raw acceleration on z axis. * raw acceleration on z axis.
* @param angle * @param angle
* angle the joystick is being held. * angle the joystick is being held.
* @param magnitude * @param magnitude
* magnitude of the joystick (range 0-1). * magnitude of the joystick (range 0-1).
* @param max1 * @param max1
* maximum joystick value 1. * maximum joystick value 1.
* @param max2 * @param max2
* maximum joystick value 2. * maximum joystick value 2.
* @param min1 * @param min1
* minimum joystick value 1. * minimum joystick value 1.
* @param min2 * @param min2
* minimum joystick value 2. * minimum joystick value 2.
* @param center1 * @param center1
* center joystick value 1. * center joystick value 1.
* @param center2 * @param center2
* center joystick value 2. * center joystick value 2.
*/ */
public NunchukEvent(int id, short buttonsJustPressed, public NunchukEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld, short buttonsJustReleased, short buttonsHeld,
float orientationThreshold, int accelerationThreshold, float orientationThreshold, int accelerationThreshold,
boolean smoothingState, float alphaSmooth, float r, float p, boolean smoothingState, float alphaSmooth, float r, float p,
float ya, float ar, float ap, float x, float y, float z, short xx, float ya, float ar, float ap, float x, float y, float z, short xx,
short yy, short zz, float angle, float magnitude, short max1, short yy, short zz, float angle, float magnitude, short max1,
short max2, short min1, short min2, short center1, short center2) { short max2, short min1, short min2, short center1, short center2) {
super(id); super(id);
buttonsEvent = new NunchukButtonsEvent(id, buttonsJustPressed, buttonsEvent = new NunchukButtonsEvent(id, buttonsJustPressed,
buttonsJustReleased, buttonsHeld); buttonsJustReleased, buttonsHeld);
nunchukMotionSensingEvent = new MotionSensingEvent(id, nunchukMotionSensingEvent = new MotionSensingEvent(id,
orientationThreshold, accelerationThreshold, smoothingState, orientationThreshold, accelerationThreshold, smoothingState,
alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz); alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz);
nunchukJoystickEvent = new JoystickEvent(id, angle, magnitude, max1, nunchukJoystickEvent = new JoystickEvent(id, angle, magnitude, max1,
max2, min1, min2, center1, center2); max2, min1, min2, center1, center2);
} }
/** /**
* Tell if there is a nunchuk motion sensing Event. * Tell if there is a nunchuk motion sensing Event.
* *
* @return TRUE if there is a nunchuk motion sensing event, false otherwise. * @return TRUE if there is a nunchuk motion sensing event, false otherwise.
*/ */
public boolean isThereMotionSensingEvent() { public boolean isThereMotionSensingEvent() {
return nunchukMotionSensingEvent != null; return nunchukMotionSensingEvent != null;
} }
/** /**
* Tell if there is a nunchuk joystick event. * Tell if there is a nunchuk joystick event.
* *
* @return TRUE if there is a nunchuk joystick event, false otherwise. * @return TRUE if there is a nunchuk joystick event, false otherwise.
*/ */
public boolean isThereNunchukJoystickEvent() { public boolean isThereNunchukJoystickEvent() {
return nunchukJoystickEvent != null; return nunchukJoystickEvent != null;
} }
/** /**
* Get nunchuk buttons event. * Get nunchuk buttons event.
* *
* @return the nunchuk buttons event if there is one or null. * @return the nunchuk buttons event if there is one or null.
*/ */
public NunchukButtonsEvent getButtonsEvent() { public NunchukButtonsEvent getButtonsEvent() {
return buttonsEvent; return buttonsEvent;
} }
/** /**
* Get the nunchuk motion sensing event. * Get the nunchuk motion sensing event.
* *
* @return the nunchuk motion sensing event if there is one or null. * @return the nunchuk motion sensing event if there is one or null.
*/ */
public MotionSensingEvent getNunchukMotionSensingEvent() { public MotionSensingEvent getNunchukMotionSensingEvent() {
return nunchukMotionSensingEvent; return nunchukMotionSensingEvent;
} }
/** /**
* Get the nunchuk joystick event. * Get the nunchuk joystick event.
* *
* @return the nunchuk Joystick Event if there is one or null. * @return the nunchuk Joystick Event if there is one or null.
*/ */
public JoystickEvent getNunchukJoystickEvent() { public JoystickEvent getNunchukJoystickEvent() {
return nunchukJoystickEvent; return nunchukJoystickEvent;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see wiiusej.wiiusejevents.GenericEvent#toString() * @see wiiusej.wiiusejevents.GenericEvent#toString()
*/ */
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** Nunchuk EVENT : WIIMOTE ID :" + getWiimoteId() out += "/*********** Nunchuk EVENT : WIIMOTE ID :" + getWiimoteId()
+ " ********/\n"; + " ********/\n";
out += buttonsEvent; out += buttonsEvent;
out += nunchukJoystickEvent; out += nunchukJoystickEvent;
out += nunchukMotionSensingEvent; out += nunchukMotionSensingEvent;
return out; return out;
} }
} }

View File

@@ -1,267 +1,267 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.physicalevents; package wiiusej.wiiusejevents.physicalevents;
/** /**
* Class which represents a buttons event for a generic event. It means buttons * Class which represents a buttons event for a generic event. It means buttons
* from a wiimote. * from a wiimote.
* *
* @author guiguito * @author guiguito
*/ */
public class WiimoteButtonsEvent extends ButtonsEvent { public class WiimoteButtonsEvent extends ButtonsEvent {
/* Buttons MACRO */ /* Buttons MACRO */
private static short WIIMOTE_BUTTON_TWO = 0x0001; private static short WIIMOTE_BUTTON_TWO = 0x0001;
private static short WIIMOTE_BUTTON_ONE = 0x0002; private static short WIIMOTE_BUTTON_ONE = 0x0002;
private static short WIIMOTE_BUTTON_B = 0x0004; private static short WIIMOTE_BUTTON_B = 0x0004;
private static short WIIMOTE_BUTTON_A = 0x0008; private static short WIIMOTE_BUTTON_A = 0x0008;
private static short WIIMOTE_BUTTON_MINUS = 0x0010; private static short WIIMOTE_BUTTON_MINUS = 0x0010;
private static short WIIMOTE_BUTTON_ZACCEL_BIT6 = 0x0020; private static short WIIMOTE_BUTTON_ZACCEL_BIT6 = 0x0020;
private static short WIIMOTE_BUTTON_ZACCEL_BIT7 = 0x0040; private static short WIIMOTE_BUTTON_ZACCEL_BIT7 = 0x0040;
private static short WIIMOTE_BUTTON_HOME = 0x0080; private static short WIIMOTE_BUTTON_HOME = 0x0080;
private static short WIIMOTE_BUTTON_LEFT = 0x0100; private static short WIIMOTE_BUTTON_LEFT = 0x0100;
private static short WIIMOTE_BUTTON_RIGHT = 0x0200; private static short WIIMOTE_BUTTON_RIGHT = 0x0200;
private static short WIIMOTE_BUTTON_DOWN = 0x0400; private static short WIIMOTE_BUTTON_DOWN = 0x0400;
private static short WIIMOTE_BUTTON_UP = 0x0800; private static short WIIMOTE_BUTTON_UP = 0x0800;
private static short WIIMOTE_BUTTON_PLUS = 0x1000; private static short WIIMOTE_BUTTON_PLUS = 0x1000;
private static short WIIMOTE_BUTTON_ZACCEL_BIT4 = 0x2000; private static short WIIMOTE_BUTTON_ZACCEL_BIT4 = 0x2000;
private static short WIIMOTE_BUTTON_ZACCEL_BIT5 = 0x4000; private static short WIIMOTE_BUTTON_ZACCEL_BIT5 = 0x4000;
private static int WIIMOTE_BUTTON_UNKNOWN = 0x8000; private static int WIIMOTE_BUTTON_UNKNOWN = 0x8000;
private static short WIIMOTE_BUTTON_ALL = 0x1F9F; private static short WIIMOTE_BUTTON_ALL = 0x1F9F;
/** /**
* Constructor of the wiimote button Event. * Constructor of the wiimote button Event.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed. * buttons just pressed.
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released. * buttons just released.
* @param buttonsHeld * @param buttonsHeld
* buttons held. * buttons held.
*/ */
public WiimoteButtonsEvent(int id, short buttonsJustPressed, public WiimoteButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) { short buttonsJustReleased, short buttonsHeld) {
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
} }
/* Button ONE */ /* Button ONE */
public boolean isButtonOneJustPressed() { public boolean isButtonOneJustPressed() {
return isButtonJustPressed(WIIMOTE_BUTTON_ONE); return isButtonJustPressed(WIIMOTE_BUTTON_ONE);
} }
public boolean isButtonOneJustReleased() { public boolean isButtonOneJustReleased() {
return isButtonJustReleased(WIIMOTE_BUTTON_ONE); return isButtonJustReleased(WIIMOTE_BUTTON_ONE);
} }
public boolean isButtonOneHeld() { public boolean isButtonOneHeld() {
return isButtonHeld(WIIMOTE_BUTTON_ONE); return isButtonHeld(WIIMOTE_BUTTON_ONE);
} }
public boolean isButtonOnePressed() { public boolean isButtonOnePressed() {
return isButtonPressed(WIIMOTE_BUTTON_ONE); return isButtonPressed(WIIMOTE_BUTTON_ONE);
} }
/* Button TWO */ /* Button TWO */
public boolean isButtonTwoJustPressed() { public boolean isButtonTwoJustPressed() {
return isButtonJustPressed(WIIMOTE_BUTTON_TWO); return isButtonJustPressed(WIIMOTE_BUTTON_TWO);
} }
public boolean isButtonTwoJustReleased() { public boolean isButtonTwoJustReleased() {
return isButtonJustReleased(WIIMOTE_BUTTON_TWO); return isButtonJustReleased(WIIMOTE_BUTTON_TWO);
} }
public boolean isButtonTwoHeld() { public boolean isButtonTwoHeld() {
return isButtonHeld(WIIMOTE_BUTTON_TWO); return isButtonHeld(WIIMOTE_BUTTON_TWO);
} }
public boolean isButtonTwoPressed() { public boolean isButtonTwoPressed() {
return isButtonPressed(WIIMOTE_BUTTON_TWO); return isButtonPressed(WIIMOTE_BUTTON_TWO);
} }
/* Button A */ /* Button A */
public boolean isButtonAJustPressed() { public boolean isButtonAJustPressed() {
return isButtonJustPressed(WIIMOTE_BUTTON_A); return isButtonJustPressed(WIIMOTE_BUTTON_A);
} }
public boolean isButtonAJustReleased() { public boolean isButtonAJustReleased() {
return isButtonJustReleased(WIIMOTE_BUTTON_A); return isButtonJustReleased(WIIMOTE_BUTTON_A);
} }
public boolean isButtonAHeld() { public boolean isButtonAHeld() {
return isButtonHeld(WIIMOTE_BUTTON_A); return isButtonHeld(WIIMOTE_BUTTON_A);
} }
public boolean isButtonAPressed() { public boolean isButtonAPressed() {
return isButtonPressed(WIIMOTE_BUTTON_A); return isButtonPressed(WIIMOTE_BUTTON_A);
} }
/* Button B */ /* Button B */
public boolean isButtonBJustPressed() { public boolean isButtonBJustPressed() {
return isButtonJustPressed(WIIMOTE_BUTTON_B); return isButtonJustPressed(WIIMOTE_BUTTON_B);
} }
public boolean isButtonBJustReleased() { public boolean isButtonBJustReleased() {
return isButtonJustReleased(WIIMOTE_BUTTON_B); return isButtonJustReleased(WIIMOTE_BUTTON_B);
} }
public boolean isButtonBHeld() { public boolean isButtonBHeld() {
return isButtonHeld(WIIMOTE_BUTTON_B); return isButtonHeld(WIIMOTE_BUTTON_B);
} }
public boolean isButtonBPressed() { public boolean isButtonBPressed() {
return isButtonPressed(WIIMOTE_BUTTON_B); return isButtonPressed(WIIMOTE_BUTTON_B);
} }
/* Button LEFT */ /* Button LEFT */
public boolean isButtonLeftJustPressed() { public boolean isButtonLeftJustPressed() {
return isButtonJustPressed(WIIMOTE_BUTTON_LEFT); return isButtonJustPressed(WIIMOTE_BUTTON_LEFT);
} }
public boolean isButtonLeftJustReleased() { public boolean isButtonLeftJustReleased() {
return isButtonJustReleased(WIIMOTE_BUTTON_LEFT); return isButtonJustReleased(WIIMOTE_BUTTON_LEFT);
} }
public boolean isButtonLeftHeld() { public boolean isButtonLeftHeld() {
return isButtonHeld(WIIMOTE_BUTTON_LEFT); return isButtonHeld(WIIMOTE_BUTTON_LEFT);
} }
public boolean isButtonLeftPressed() { public boolean isButtonLeftPressed() {
return isButtonPressed(WIIMOTE_BUTTON_LEFT); return isButtonPressed(WIIMOTE_BUTTON_LEFT);
} }
/* Button RIGHT */ /* Button RIGHT */
public boolean isButtonRightJustPressed() { public boolean isButtonRightJustPressed() {
return isButtonJustPressed(WIIMOTE_BUTTON_RIGHT); return isButtonJustPressed(WIIMOTE_BUTTON_RIGHT);
} }
public boolean isButtonRightJustReleased() { public boolean isButtonRightJustReleased() {
return isButtonJustReleased(WIIMOTE_BUTTON_RIGHT); return isButtonJustReleased(WIIMOTE_BUTTON_RIGHT);
} }
public boolean isButtonRightHeld() { public boolean isButtonRightHeld() {
return isButtonHeld(WIIMOTE_BUTTON_RIGHT); return isButtonHeld(WIIMOTE_BUTTON_RIGHT);
} }
public boolean isButtonRightPressed() { public boolean isButtonRightPressed() {
return isButtonPressed(WIIMOTE_BUTTON_RIGHT); return isButtonPressed(WIIMOTE_BUTTON_RIGHT);
} }
/* Button UP */ /* Button UP */
public boolean isButtonUpJustPressed() { public boolean isButtonUpJustPressed() {
return isButtonJustPressed(WIIMOTE_BUTTON_UP); return isButtonJustPressed(WIIMOTE_BUTTON_UP);
} }
public boolean isButtonUpJustReleased() { public boolean isButtonUpJustReleased() {
return isButtonJustReleased(WIIMOTE_BUTTON_UP); return isButtonJustReleased(WIIMOTE_BUTTON_UP);
} }
public boolean isButtonUpHeld() { public boolean isButtonUpHeld() {
return isButtonHeld(WIIMOTE_BUTTON_UP); return isButtonHeld(WIIMOTE_BUTTON_UP);
} }
public boolean isButtonUpPressed() { public boolean isButtonUpPressed() {
return isButtonPressed(WIIMOTE_BUTTON_UP); return isButtonPressed(WIIMOTE_BUTTON_UP);
} }
/* Button DOWN */ /* Button DOWN */
public boolean isButtonDownJustPressed() { public boolean isButtonDownJustPressed() {
return isButtonJustPressed(WIIMOTE_BUTTON_DOWN); return isButtonJustPressed(WIIMOTE_BUTTON_DOWN);
} }
public boolean isButtonDownJustReleased() { public boolean isButtonDownJustReleased() {
return isButtonJustReleased(WIIMOTE_BUTTON_DOWN); return isButtonJustReleased(WIIMOTE_BUTTON_DOWN);
} }
public boolean isButtonDownHeld() { public boolean isButtonDownHeld() {
return isButtonHeld(WIIMOTE_BUTTON_DOWN); return isButtonHeld(WIIMOTE_BUTTON_DOWN);
} }
public boolean isButtonDownPressed() { public boolean isButtonDownPressed() {
return isButtonPressed(WIIMOTE_BUTTON_DOWN); return isButtonPressed(WIIMOTE_BUTTON_DOWN);
} }
/* Button - */ /* Button - */
public boolean isButtonMinusJustPressed() { public boolean isButtonMinusJustPressed() {
return isButtonJustPressed(WIIMOTE_BUTTON_MINUS); return isButtonJustPressed(WIIMOTE_BUTTON_MINUS);
} }
public boolean isButtonMinusJustReleased() { public boolean isButtonMinusJustReleased() {
return isButtonJustReleased(WIIMOTE_BUTTON_MINUS); return isButtonJustReleased(WIIMOTE_BUTTON_MINUS);
} }
public boolean isButtonMinusHeld() { public boolean isButtonMinusHeld() {
return isButtonHeld(WIIMOTE_BUTTON_MINUS); return isButtonHeld(WIIMOTE_BUTTON_MINUS);
} }
public boolean isButtonMinusPressed() { public boolean isButtonMinusPressed() {
return isButtonPressed(WIIMOTE_BUTTON_MINUS); return isButtonPressed(WIIMOTE_BUTTON_MINUS);
} }
/* Button + */ /* Button + */
public boolean isButtonPlusJustPressed() { public boolean isButtonPlusJustPressed() {
return isButtonJustPressed(WIIMOTE_BUTTON_PLUS); return isButtonJustPressed(WIIMOTE_BUTTON_PLUS);
} }
public boolean isButtonPlusJustReleased() { public boolean isButtonPlusJustReleased() {
return isButtonJustReleased(WIIMOTE_BUTTON_PLUS); return isButtonJustReleased(WIIMOTE_BUTTON_PLUS);
} }
public boolean isButtonPlusHeld() { public boolean isButtonPlusHeld() {
return isButtonHeld(WIIMOTE_BUTTON_PLUS); return isButtonHeld(WIIMOTE_BUTTON_PLUS);
} }
public boolean isButtonPlusPressed() { public boolean isButtonPlusPressed() {
return isButtonPressed(WIIMOTE_BUTTON_PLUS); return isButtonPressed(WIIMOTE_BUTTON_PLUS);
} }
/* Button HOME */ /* Button HOME */
public boolean isButtonHomeJustPressed() { public boolean isButtonHomeJustPressed() {
return isButtonJustPressed(WIIMOTE_BUTTON_HOME); return isButtonJustPressed(WIIMOTE_BUTTON_HOME);
} }
public boolean isButtonHomeJustReleased() { public boolean isButtonHomeJustReleased() {
return isButtonJustReleased(WIIMOTE_BUTTON_HOME); return isButtonJustReleased(WIIMOTE_BUTTON_HOME);
} }
public boolean isButtonHomeHeld() { public boolean isButtonHomeHeld() {
return isButtonHeld(WIIMOTE_BUTTON_HOME); return isButtonHeld(WIIMOTE_BUTTON_HOME);
} }
public boolean isButtonHomePressed() { public boolean isButtonHomePressed() {
return isButtonPressed(WIIMOTE_BUTTON_HOME); return isButtonPressed(WIIMOTE_BUTTON_HOME);
} }
@Override @Override
public String toString() { public String toString() {
return "/******** Buttons for Wiimote generic Event ********/\n" return "/******** Buttons for Wiimote generic Event ********/\n"
+ super.toString(); + super.toString();
} }
} }

View File

@@ -1,37 +1,37 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.utils; package wiiusej.wiiusejevents.utils;
import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent; import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
/** /**
* This is the interface to implement to listen to events from the wiiuse API. * This is the interface to implement to listen to events from the wiiuse API.
* *
* @author guiguito * @author guiguito
*/ */
public interface WiiUseApiListener extends java.util.EventListener { public interface WiiUseApiListener extends java.util.EventListener {
/** /**
* Method called when a WiiUseApiEvent occurs. A WiiUseApiEvent can be : - * Method called when a WiiUseApiEvent occurs. A WiiUseApiEvent can be : -
* WiimoteEvent (Storing ButtonsEvent and eventually IREvent and * WiimoteEvent (Storing ButtonsEvent and eventually IREvent and
* MotionSensingEvent) - StatusEvent - DisconnectionEvent * MotionSensingEvent) - StatusEvent - DisconnectionEvent
* *
* @param e * @param e
*/ */
void onWiiUseApiEvent(WiiUseApiEvent e); void onWiiUseApiEvent(WiiUseApiEvent e);
} }

View File

@@ -1,145 +1,145 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.utils; package wiiusej.wiiusejevents.utils;
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
import wiiusej.wiiusejevents.physicalevents.IREvent; import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent; import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent; import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent; import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent; import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/** /**
* This is the interface to implement to listen to events from wiimotes. The * This is the interface to implement to listen to events from wiimotes. The
* differents methods are called in this order : onButtonsEvent, onIrEvent, * differents methods are called in this order : onButtonsEvent, onIrEvent,
* onMotionSensingEvent, onExpansionEvent, onStatusEvent, onDisconnectionEvent * onMotionSensingEvent, onExpansionEvent, onStatusEvent, onDisconnectionEvent
* onNunchukInsertedEvent, onNunchukRemovedEvent. * onNunchukInsertedEvent, onNunchukRemovedEvent.
* *
* @author guiguito * @author guiguito
*/ */
public interface WiimoteListener extends java.util.EventListener { public interface WiimoteListener extends java.util.EventListener {
/** /**
* Method called on a button Event. * Method called on a button Event.
* *
* @param e * @param e
* the buttonEvent with the last informations about the buttons * the buttonEvent with the last informations about the buttons
* of the wiimote. * of the wiimote.
*/ */
void onButtonsEvent(WiimoteButtonsEvent e); void onButtonsEvent(WiimoteButtonsEvent e);
/** /**
* Method called when an IR event occurs. * Method called when an IR event occurs.
* *
* @param e * @param e
* the IREvent with the IR points seen. * the IREvent with the IR points seen.
*/ */
void onIrEvent(IREvent e); void onIrEvent(IREvent e);
/** /**
* Method called when a motion sensing event occurs. * Method called when a motion sensing event occurs.
* *
* @param e * @param e
* the motion sensing event with orientation and acceleration. * the motion sensing event with orientation and acceleration.
*/ */
void onMotionSensingEvent(MotionSensingEvent e); void onMotionSensingEvent(MotionSensingEvent e);
/** /**
* Method called when an expansion event occurs. * Method called when an expansion event occurs.
* *
* @param e * @param e
* the expansion event occured. * the expansion event occured.
*/ */
void onExpansionEvent(ExpansionEvent e); void onExpansionEvent(ExpansionEvent e);
/** /**
* Method called on a status event. A status event occurs when : - we ask it - * Method called on a status event. A status event occurs when : - we ask it -
* an expansion controller has been plugged - an expansion controller has * an expansion controller has been plugged - an expansion controller has
* been unplugged This is where you can get the different values of the * been unplugged This is where you can get the different values of the
* parameters setup on your wiimote. * parameters setup on your wiimote.
* *
* @param e * @param e
* the status event. * the status event.
*/ */
void onStatusEvent(StatusEvent e); void onStatusEvent(StatusEvent e);
/** /**
* This is the method called when a disconnection event occurs. A * This is the method called when a disconnection event occurs. A
* disconnection event happens when : - there are no battery left - the * disconnection event happens when : - there are no battery left - the
* wiimote has just been turned off - the connection is dropped * wiimote has just been turned off - the connection is dropped
* *
* @param e * @param e
* the disconnection event. * the disconnection event.
*/ */
void onDisconnectionEvent(DisconnectionEvent e); void onDisconnectionEvent(DisconnectionEvent e);
/** /**
* This is the method called when a NunchukInsertedEvent occurs. * This is the method called when a NunchukInsertedEvent occurs.
* *
* @param e * @param e
* the NunchukInsertedEvent. * the NunchukInsertedEvent.
*/ */
void onNunchukInsertedEvent(NunchukInsertedEvent e); void onNunchukInsertedEvent(NunchukInsertedEvent e);
/** /**
* This is the method called when a NunchukRemovedEvent occurs. * This is the method called when a NunchukRemovedEvent occurs.
* *
* @param e * @param e
* the NunchukRemovedEvent. * the NunchukRemovedEvent.
*/ */
void onNunchukRemovedEvent(NunchukRemovedEvent e); void onNunchukRemovedEvent(NunchukRemovedEvent e);
/** /**
* This is the method called when a GuitarHeroInsertedEvent occurs. * This is the method called when a GuitarHeroInsertedEvent occurs.
* *
* @param e * @param e
* the GuitarHeroInsertedEvent. * the GuitarHeroInsertedEvent.
*/ */
void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e); void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e);
/** /**
* This is the method called when a GuitarHeroRemovedEvent occurs. * This is the method called when a GuitarHeroRemovedEvent occurs.
* *
* @param e * @param e
* the GuitarHeroRemovedEvent. * the GuitarHeroRemovedEvent.
*/ */
void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e); void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e);
/** /**
* This is the method called when a ClassicControllerInsertedEvent occurs. * This is the method called when a ClassicControllerInsertedEvent occurs.
* *
* @param e * @param e
* the ClassicControllerInsertedEvent. * the ClassicControllerInsertedEvent.
*/ */
void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent e); void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent e);
/** /**
* This is the method called when a ClassicControllerRemovedEvent occurs. * This is the method called when a ClassicControllerRemovedEvent occurs.
* *
* @param e * @param e
* the ClassicControllerRemovedEvent. * the ClassicControllerRemovedEvent.
*/ */
void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e); void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e);
} }

View File

@@ -1,46 +1,46 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
/** /**
* Event that represents the connection of a classic controller to a wiimote. * Event that represents the connection of a classic controller to a wiimote.
* *
* @author guiguito * @author guiguito
* *
*/ */
public class ClassicControllerInsertedEvent extends WiiUseApiEvent { public class ClassicControllerInsertedEvent extends WiiUseApiEvent {
/** /**
* Construct the ClassicControllerInsertedEvent setting up the id. * Construct the ClassicControllerInsertedEvent setting up the id.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public ClassicControllerInsertedEvent(int id) { public ClassicControllerInsertedEvent(int id) {
super(id, WIIUSE_CLASSIC_CTRL_INSERTED); super(id, WIIUSE_CLASSIC_CTRL_INSERTED);
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** CLASSIC CONTROLLER INSERTED EVENT : WIIMOTE ID :" out += "/*********** CLASSIC CONTROLLER INSERTED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n"; + super.getWiimoteId() + " ********/\n";
return out; return out;
} }
} }

View File

@@ -1,47 +1,47 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
/** /**
* Event that represents the disconnection of a classic controller from a * Event that represents the disconnection of a classic controller from a
* wiimote. * wiimote.
* *
* @author guiguito * @author guiguito
* *
*/ */
public class ClassicControllerRemovedEvent extends WiiUseApiEvent { public class ClassicControllerRemovedEvent extends WiiUseApiEvent {
/** /**
* Construct the ClassicControllerRemovedEvent setting up the id. * Construct the ClassicControllerRemovedEvent setting up the id.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public ClassicControllerRemovedEvent(int id) { public ClassicControllerRemovedEvent(int id) {
super(id, WIIUSE_CLASSIC_CTRL_REMOVED); super(id, WIIUSE_CLASSIC_CTRL_REMOVED);
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** CLASSIC CONTROLLER REMOVED EVENT : WIIMOTE ID :" out += "/*********** CLASSIC CONTROLLER REMOVED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n"; + super.getWiimoteId() + " ********/\n";
return out; return out;
} }
} }

View File

@@ -1,45 +1,45 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
/** /**
* Class representing a disconnection event. * Class representing a disconnection event.
* *
* @author guiguito * @author guiguito
*/ */
public class DisconnectionEvent extends WiiUseApiEvent { public class DisconnectionEvent extends WiiUseApiEvent {
/** /**
* Construct the DisconnectionEvent setting up the id. * Construct the DisconnectionEvent setting up the id.
* *
* @param id * @param id
* the Wiimote id * the Wiimote id
*/ */
public DisconnectionEvent(int id) { public DisconnectionEvent(int id) {
super(id, WiiUseApiEvent.DISCONNECTION_EVENT); super(id, WiiUseApiEvent.DISCONNECTION_EVENT);
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :" out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n"; + super.getWiimoteId() + " ********/\n";
return out; return out;
} }
} }

View File

@@ -1,47 +1,47 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
/** /**
* Event that represents the connection of a Guitar hero controller to a * Event that represents the connection of a Guitar hero controller to a
* wiimote. * wiimote.
* *
* @author guiguito * @author guiguito
* *
*/ */
public class GuitarHeroInsertedEvent extends WiiUseApiEvent { public class GuitarHeroInsertedEvent extends WiiUseApiEvent {
/** /**
* Construct the GuitarHeroInsertedEvent setting up the id. * Construct the GuitarHeroInsertedEvent setting up the id.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public GuitarHeroInsertedEvent(int id) { public GuitarHeroInsertedEvent(int id) {
super(id, WIIUSE_GUITAR_HERO_3_CTRL_INSERTED); super(id, WIIUSE_GUITAR_HERO_3_CTRL_INSERTED);
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** GUITAR HERO INSERTED EVENT : WIIMOTE ID :" out += "/*********** GUITAR HERO INSERTED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n"; + super.getWiimoteId() + " ********/\n";
return out; return out;
} }
} }

View File

@@ -1,47 +1,47 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
/** /**
* Event that represents the disconnection of a guitar hero controller from a * Event that represents the disconnection of a guitar hero controller from a
* wiimote. * wiimote.
* *
* @author guiguito * @author guiguito
* *
*/ */
public class GuitarHeroRemovedEvent extends WiiUseApiEvent { public class GuitarHeroRemovedEvent extends WiiUseApiEvent {
/** /**
* Construct the GuitarHeroRemovedEvent setting up the id. * Construct the GuitarHeroRemovedEvent setting up the id.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public GuitarHeroRemovedEvent(int id) { public GuitarHeroRemovedEvent(int id) {
super(id, WIIUSE_GUITAR_HERO_3_CTRL_REMOVED); super(id, WIIUSE_GUITAR_HERO_3_CTRL_REMOVED);
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** GUITAR HERO REMOVED EVENT : WIIMOTE ID :" out += "/*********** GUITAR HERO REMOVED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n"; + super.getWiimoteId() + " ********/\n";
return out; return out;
} }
} }

View File

@@ -1,51 +1,51 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
/** /**
* Event that represents the connection of a nunchuk to a wiimote. * Event that represents the connection of a nunchuk to a wiimote.
* *
* @author guiguito * @author guiguito
* *
*/ */
public class NunchukInsertedEvent extends WiiUseApiEvent { public class NunchukInsertedEvent extends WiiUseApiEvent {
/** /**
* Construct the NunchukInsertedEvent setting up the id. * Construct the NunchukInsertedEvent setting up the id.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public NunchukInsertedEvent(int id) { public NunchukInsertedEvent(int id) {
super(id, WIIUSE_NUNCHUK_INSERTED); super(id, WIIUSE_NUNCHUK_INSERTED);
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see wiiusej.wiiusejevents.WiiUseApiEvent#toString() * @see wiiusej.wiiusejevents.WiiUseApiEvent#toString()
*/ */
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** NUNCHUK INSERTED EVENT : WIIMOTE ID :" out += "/*********** NUNCHUK INSERTED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n"; + super.getWiimoteId() + " ********/\n";
return out; return out;
} }
} }

View File

@@ -1,50 +1,50 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
/** /**
* Event that represents the disconnection of a nunchuk from a wiimote. * Event that represents the disconnection of a nunchuk from a wiimote.
* *
* @author guiguito * @author guiguito
*/ */
public class NunchukRemovedEvent extends WiiUseApiEvent { public class NunchukRemovedEvent extends WiiUseApiEvent {
/** /**
* Construct the NunchukInsertedEvent setting up the id. * Construct the NunchukInsertedEvent setting up the id.
* *
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public NunchukRemovedEvent(int id) { public NunchukRemovedEvent(int id) {
super(id, WIIUSE_NUNCHUK_REMOVED); super(id, WIIUSE_NUNCHUK_REMOVED);
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see wiiusej.wiiusejevents.WiiUseApiEvent#toString() * @see wiiusej.wiiusejevents.WiiUseApiEvent#toString()
*/ */
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** NUNCHUK REMOVED EVENT : WIIMOTE ID :" out += "/*********** NUNCHUK REMOVED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n"; + super.getWiimoteId() + " ********/\n";
return out; return out;
} }
} }

View File

@@ -1,293 +1,293 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
/** /**
* Class used to represent a status event. This class is used to know what are * Class used to represent a status event. This class is used to know what are
* the settings of the wiimote. * the settings of the wiimote.
* *
* @author guiguito * @author guiguito
*/ */
public class StatusEvent extends WiiUseApiEvent { public class StatusEvent extends WiiUseApiEvent {
protected static short WIIMOTE_LED_1 = 1; protected static short WIIMOTE_LED_1 = 1;
protected static short WIIMOTE_LED_2 = 2; protected static short WIIMOTE_LED_2 = 2;
protected static short WIIMOTE_LED_3 = 4; protected static short WIIMOTE_LED_3 = 4;
protected static short WIIMOTE_LED_4 = 8; protected static short WIIMOTE_LED_4 = 8;
/* ATTACHMENT CONSTANTS */ /* ATTACHMENT CONSTANTS */
private static short EXP_NONE = 0; private static short EXP_NONE = 0;
private static short EXP_NUNCHUK = 1; private static short EXP_NUNCHUK = 1;
private static short EXP_CLASSIC = 2; private static short EXP_CLASSIC = 2;
private static short EXP_GUITAR_HERO_3 = 3; private static short EXP_GUITAR_HERO_3 = 3;
/* Status variables */ /* Status variables */
private boolean connected = false; private boolean connected = false;
private float batteryLevel = -1; private float batteryLevel = -1;
private short leds = 0; private short leds = 0;
private boolean isSpeakerEnabled = false; private boolean isSpeakerEnabled = false;
private int attachment = 0; private int attachment = 0;
private boolean isRumbleActive = false; private boolean isRumbleActive = false;
private boolean isContinuousActive = false; private boolean isContinuousActive = false;
private boolean isIrActive = false; private boolean isIrActive = false;
private boolean isMotionSensingActive = false; private boolean isMotionSensingActive = false;
/** /**
* Construct the StatusEvent setting up the id. * Construct the StatusEvent setting up the id.
* *
* @param id * @param id
* the Wiimote id * the Wiimote id
*/ */
public StatusEvent(int id) { public StatusEvent(int id) {
super(id, WiiUseApiEvent.STATUS_EVENT); super(id, WiiUseApiEvent.STATUS_EVENT);
} }
/** /**
* Build a StatusEvent with all fields set. * Build a StatusEvent with all fields set.
* *
* @param id * @param id
* id of the wiimote * id of the wiimote
* @param connect * @param connect
* true if the wiimote is connected * true if the wiimote is connected
* @param batt * @param batt
* battery level * battery level
* @param led * @param led
* status of leds * status of leds
* @param speak * @param speak
* speakers status * speakers status
* @param attach * @param attach
* attachment status * attachment status
* @param rumbleState * @param rumbleState
* true if rumble is active * true if rumble is active
* @param continuousState * @param continuousState
* true if continuous flag is activated * true if continuous flag is activated
* @param irState * @param irState
* true if ir is active * true if ir is active
* @param motionSensingState * @param motionSensingState
* true if accelerometer is active * true if accelerometer is active
*/ */
public StatusEvent(int id, boolean connect, float batt, short led, public StatusEvent(int id, boolean connect, float batt, short led,
boolean speak, int attach, boolean rumbleState, boolean speak, int attach, boolean rumbleState,
boolean continuousState, boolean irState, boolean motionSensingState) { boolean continuousState, boolean irState, boolean motionSensingState) {
super(id, WiiUseApiEvent.STATUS_EVENT); super(id, WiiUseApiEvent.STATUS_EVENT);
connected = connect; connected = connect;
this.batteryLevel = batt; this.batteryLevel = batt;
this.leds = led; this.leds = led;
this.isSpeakerEnabled = speak; this.isSpeakerEnabled = speak;
this.attachment = attach; this.attachment = attach;
isRumbleActive = rumbleState; isRumbleActive = rumbleState;
isContinuousActive = continuousState; isContinuousActive = continuousState;
isIrActive = irState; isIrActive = irState;
isMotionSensingActive = motionSensingState; isMotionSensingActive = motionSensingState;
} }
/** /**
* True if the wiimote is connected false otherwise. * True if the wiimote is connected false otherwise.
* *
* @return return the connected status. * @return return the connected status.
*/ */
public boolean isConnected() { public boolean isConnected() {
return connected; return connected;
} }
/** /**
* Get battery level. * Get battery level.
* *
* @return battery level. 1 = 100% * @return battery level. 1 = 100%
*/ */
public float getBatteryLevel() { public float getBatteryLevel() {
return batteryLevel; return batteryLevel;
} }
/** /**
* Get status of the leds . * Get status of the leds .
* *
* @return a short representing LEDS turned on. * @return a short representing LEDS turned on.
*/ */
public short getLeds() { public short getLeds() {
return leds; return leds;
} }
/** /**
* Tells if the given led is turned on according to the leds status int. * Tells if the given led is turned on according to the leds status int.
* *
* @param led * @param led
* the int encoding a led. * the int encoding a led.
* @return true if the led is turned on false otherwise. * @return true if the led is turned on false otherwise.
*/ */
private boolean ledStatusCheck(short led) { private boolean ledStatusCheck(short led) {
if ((leds & led) > 0) { if ((leds & led) > 0) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
/** /**
* Get led1 status. * Get led1 status.
* *
* @return true if the led is set. * @return true if the led is set.
*/ */
public boolean isLed1Set() { public boolean isLed1Set() {
return ledStatusCheck(WIIMOTE_LED_1); return ledStatusCheck(WIIMOTE_LED_1);
} }
/** /**
* Get led2 status. * Get led2 status.
* *
* @return true if the led is set. * @return true if the led is set.
*/ */
public boolean isLed2Set() { public boolean isLed2Set() {
return ledStatusCheck(WIIMOTE_LED_2); return ledStatusCheck(WIIMOTE_LED_2);
} }
/** /**
* Get led3 status. * Get led3 status.
* *
* @return true if the led is set. * @return true if the led is set.
*/ */
public boolean isLed3Set() { public boolean isLed3Set() {
return ledStatusCheck(WIIMOTE_LED_3); return ledStatusCheck(WIIMOTE_LED_3);
} }
/** /**
* Get led4 status. * Get led4 status.
* *
* @return true if the led is set. * @return true if the led is set.
*/ */
public boolean isLed4Set() { public boolean isLed4Set() {
return ledStatusCheck(WIIMOTE_LED_4); return ledStatusCheck(WIIMOTE_LED_4);
} }
/** /**
* Tell if the speaker is enable for this wiimote * Tell if the speaker is enable for this wiimote
* *
* @return TRUE if it enabled false otherwise * @return TRUE if it enabled false otherwise
*/ */
public boolean isSpeakerEnabled() { public boolean isSpeakerEnabled() {
return isSpeakerEnabled; return isSpeakerEnabled;
} }
/** /**
* Get the int representing the attachment type. * Get the int representing the attachment type.
* *
* @return value of the Attachment Type * @return value of the Attachment Type
*/ */
public int getAttachment() { public int getAttachment() {
return attachment; return attachment;
} }
/** /**
* Get the status of rumble. * Get the status of rumble.
* *
* @return true if the rumble is active false otherwise * @return true if the rumble is active false otherwise
*/ */
public boolean isRumbleActive() { public boolean isRumbleActive() {
return isRumbleActive; return isRumbleActive;
} }
/** /**
* Tell if the CONTINUOUS option is activated. * Tell if the CONTINUOUS option is activated.
* *
* @return the isContinuousActive * @return the isContinuousActive
*/ */
public boolean isContinuousActive() { public boolean isContinuousActive() {
return isContinuousActive; return isContinuousActive;
} }
/** /**
* Tell if the IR Tracking is active. * Tell if the IR Tracking is active.
* *
* @return TRUE if it is active or false otherwise. * @return TRUE if it is active or false otherwise.
*/ */
public boolean isIrActive() { public boolean isIrActive() {
return isIrActive; return isIrActive;
} }
/** /**
* Get the flag indicating if the motion sensing is active. * Get the flag indicating if the motion sensing is active.
* *
* @return true if the motion sensing is active false otherwise * @return true if the motion sensing is active false otherwise
*/ */
public boolean isMotionSensingActive() { public boolean isMotionSensingActive() {
return isMotionSensingActive; return isMotionSensingActive;
} }
/** /**
* Tells if an attachment is connected. * Tells if an attachment is connected.
* *
* @return true if anything is connected to the wiimote false otherwise. * @return true if anything is connected to the wiimote false otherwise.
*/ */
public boolean isAttachmentConnected() { public boolean isAttachmentConnected() {
return attachment == EXP_NONE; return attachment == EXP_NONE;
} }
/** /**
* Tells if a nunchuk is connected. * Tells if a nunchuk is connected.
* *
* @return true if a nunchuk is connected to the wiimote false otherwise. * @return true if a nunchuk is connected to the wiimote false otherwise.
*/ */
public boolean isNunchukConnected() { public boolean isNunchukConnected() {
return attachment == EXP_NUNCHUK; return attachment == EXP_NUNCHUK;
} }
/** /**
* Tells if a classic controller is connected. * Tells if a classic controller is connected.
* *
* @return true if a classic controller is connected to the wiimote false otherwise. * @return true if a classic controller is connected to the wiimote false otherwise.
*/ */
public boolean isClassicControllerConnected() { public boolean isClassicControllerConnected() {
return attachment == EXP_CLASSIC; return attachment == EXP_CLASSIC;
} }
/** /**
* Tells if a guitar hero controller is connected. * Tells if a guitar hero controller is connected.
* *
* @return true if a guitar hero controllerr is connected to the wiimote false otherwise. * @return true if a guitar hero controllerr is connected to the wiimote false otherwise.
*/ */
public boolean isGuitarHeroConnected() { public boolean isGuitarHeroConnected() {
return attachment == EXP_GUITAR_HERO_3; return attachment == EXP_GUITAR_HERO_3;
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** STATUS EVENT : WIIMOTE ID :" out += "/*********** STATUS EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n"; + super.getWiimoteId() + " ********/\n";
out += "--- connected : " + connected + "\n"; out += "--- connected : " + connected + "\n";
out += "--- Battery level : " + batteryLevel + "\n"; out += "--- Battery level : " + batteryLevel + "\n";
out += "--- Leds : " + leds + "\n"; out += "--- Leds : " + leds + "\n";
out += "--- Speaker enabled : " + isSpeakerEnabled + "\n"; out += "--- Speaker enabled : " + isSpeakerEnabled + "\n";
out += "--- Attachment ? : " + attachment + "\n"; out += "--- Attachment ? : " + attachment + "\n";
out += "--- Rumble ? : " + isRumbleActive + "\n"; out += "--- Rumble ? : " + isRumbleActive + "\n";
out += "--- Continuous ? : " + isContinuousActive + "\n"; out += "--- Continuous ? : " + isContinuousActive + "\n";
out += "--- IR active ? : " + isIrActive + "\n"; out += "--- IR active ? : " + isIrActive + "\n";
out += "--- Motion sensing active ? : " + isMotionSensingActive + "\n"; out += "--- Motion sensing active ? : " + isMotionSensingActive + "\n";
return out; return out;
} }
} }

View File

@@ -1,66 +1,66 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
import wiiusej.wiiusejevents.GenericEvent; import wiiusej.wiiusejevents.GenericEvent;
/** /**
* This class describes the structure of an event from the WiiUse API event. * This class describes the structure of an event from the WiiUse API event.
* *
* @author guiguito * @author guiguito
*/ */
public abstract class WiiUseApiEvent extends GenericEvent{ public abstract class WiiUseApiEvent extends GenericEvent{
public static int NONE_EVENT = 0; public static int NONE_EVENT = 0;
public static int GENERIC_EVENT = 1; public static int GENERIC_EVENT = 1;
public static int STATUS_EVENT = 2; public static int STATUS_EVENT = 2;
public static int DISCONNECTION_EVENT = 3; public static int DISCONNECTION_EVENT = 3;
public static int WIIUSE_READ_DATA = 4; public static int WIIUSE_READ_DATA = 4;
public static int WIIUSE_NUNCHUK_INSERTED = 5; public static int WIIUSE_NUNCHUK_INSERTED = 5;
public static int WIIUSE_NUNCHUK_REMOVED = 6; public static int WIIUSE_NUNCHUK_REMOVED = 6;
public static int WIIUSE_CLASSIC_CTRL_INSERTED = 7; public static int WIIUSE_CLASSIC_CTRL_INSERTED = 7;
public static int WIIUSE_CLASSIC_CTRL_REMOVED = 8; 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_INSERTED = 9;
public static int WIIUSE_GUITAR_HERO_3_CTRL_REMOVED = 10; public static int WIIUSE_GUITAR_HERO_3_CTRL_REMOVED = 10;
/* Event Type */ /* Event Type */
private int eventType; private int eventType;
/** /**
* Construct the WiiUseApiEvent setting up the id. * Construct the WiiUseApiEvent setting up the id.
* *
* @param id * @param id
* the Wiimote id * the Wiimote id
* @param type * @param type
* type of the event * type of the event
*/ */
public WiiUseApiEvent(int id, int type) { public WiiUseApiEvent(int id, int type) {
super(id); super(id);
eventType = type; eventType = type;
} }
/** /**
* Get the event type. * Get the event type.
* @return the eventType * @return the eventType
*/ */
public int getEventType() { public int getEventType() {
return eventType; return eventType;
} }
public abstract String toString(); public abstract String toString();
} }

View File

@@ -1,441 +1,441 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
import wiiusej.wiiusejevents.physicalevents.ClassicControllerEvent; import wiiusej.wiiusejevents.physicalevents.ClassicControllerEvent;
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent; import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
import wiiusej.wiiusejevents.physicalevents.IREvent; import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.NunchukEvent; import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
/** /**
* Class that is a bean to be filled by the wiiuse API on an event that occurs * Class that is a bean to be filled by the wiiuse API on an event that occurs
* on a wiimote. * on a wiimote.
* *
* @author guiguito * @author guiguito
*/ */
public class WiimoteEvent extends WiiUseApiEvent { public class WiimoteEvent extends WiiUseApiEvent {
private WiimoteButtonsEvent buttonsEvent = null; private WiimoteButtonsEvent buttonsEvent = null;
private IREvent infraredEvent = null; private IREvent infraredEvent = null;
private MotionSensingEvent motionSensingEvent = null; private MotionSensingEvent motionSensingEvent = null;
private ExpansionEvent expansionEvent = null; private ExpansionEvent expansionEvent = null;
/** /**
* Construct the Wiimote setting up the id. * Construct the Wiimote setting up the id.
* *
* @param id * @param id
* the Wiimote id * the Wiimote id
*/ */
public WiimoteEvent(int id) { public WiimoteEvent(int id) {
super(id, WiiUseApiEvent.GENERIC_EVENT); super(id, WiiUseApiEvent.GENERIC_EVENT);
} }
/** /**
* Construct the Wiimote setting up the id and the buttons. * Construct the Wiimote setting up the id and the buttons.
* *
* @param id * @param id
* the Wiimote id * the Wiimote id
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed * buttons just pressed
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released * buttons just released
* @param buttonsHeld * @param buttonsHeld
* buttons held * buttons held
*/ */
public WiimoteEvent(int id, short buttonsJustPressed, public WiimoteEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) { short buttonsJustReleased, short buttonsHeld) {
super(id, WiiUseApiEvent.GENERIC_EVENT); super(id, WiiUseApiEvent.GENERIC_EVENT);
buttonsEvent = new WiimoteButtonsEvent(id, buttonsJustPressed, buttonsEvent = new WiimoteButtonsEvent(id, buttonsJustPressed,
buttonsJustReleased, buttonsHeld); buttonsJustReleased, buttonsHeld);
} }
/** /**
* Tell if there is an IR Event. * Tell if there is an IR Event.
* *
* @return TRUE if there is an IR event. * @return TRUE if there is an IR event.
*/ */
public boolean isThereIrEvent() { public boolean isThereIrEvent() {
return infraredEvent != null; return infraredEvent != null;
} }
/** /**
* Tell if there is a motion sensing Event. * Tell if there is a motion sensing Event.
* *
* @return TRUE if there is a motion sensing event. * @return TRUE if there is a motion sensing event.
*/ */
public boolean isThereMotionSensingEvent() { public boolean isThereMotionSensingEvent() {
return motionSensingEvent != null; return motionSensingEvent != null;
} }
/** /**
* Tell if there is an expansion Event. * Tell if there is an expansion Event.
* *
* @return TRUE if there is an expansion event. * @return TRUE if there is an expansion event.
*/ */
public boolean isThereExpansionEvent() { public boolean isThereExpansionEvent() {
return expansionEvent != null; return expansionEvent != null;
} }
/** /**
* Get buttons event. * Get buttons event.
* *
* @return the buttons event. * @return the buttons event.
*/ */
public WiimoteButtonsEvent getButtonsEvent() { public WiimoteButtonsEvent getButtonsEvent() {
return buttonsEvent; return buttonsEvent;
} }
/** /**
* Get the IR event. * Get the IR event.
* *
* @return the IR event if there is one or null. * @return the IR event if there is one or null.
*/ */
public IREvent getIREvent() { public IREvent getIREvent() {
return infraredEvent; return infraredEvent;
} }
/** /**
* Get the motion sensing event. * Get the motion sensing event.
* *
* @return the motion sensing event if there is one or null. * @return the motion sensing event if there is one or null.
*/ */
public MotionSensingEvent getMotionSensingEvent() { public MotionSensingEvent getMotionSensingEvent() {
return motionSensingEvent; return motionSensingEvent;
} }
/** /**
* Get the expansion event. * Get the expansion event.
* *
* @return the expansion event if there is one or null. * @return the expansion event if there is one or null.
*/ */
public ExpansionEvent getExpansionEvent() { public ExpansionEvent getExpansionEvent() {
return expansionEvent; return expansionEvent;
} }
/** /**
* Prepare an IR event to populate. * Prepare an IR event to populate.
* *
* @param x * @param x
* calculated X coordinate. * calculated X coordinate.
* @param y * @param y
* calculated Y coordinate. * calculated Y coordinate.
* @param z * @param z
* calculated distance. * calculated distance.
* @param ax * @param ax
* absolute X coordinate. * absolute X coordinate.
* @param ay * @param ay
* absolute Y coordinate * absolute Y coordinate
* @param xVRes * @param xVRes
* IR virtual screen x resolution. * IR virtual screen x resolution.
* @param yVRes * @param yVRes
* IR virtual screen y resolution. * IR virtual screen y resolution.
* @param xOffset * @param xOffset
* IR X correction offset. * IR X correction offset.
* @param yOffset * @param yOffset
* IR Y correction offset. * IR Y correction offset.
* @param sensorBarPostion * @param sensorBarPostion
* aspect ratio of the screen. * aspect ratio of the screen.
* @param screenAsPectRatio * @param screenAsPectRatio
* IR sensor bar position. * IR sensor bar position.
* @param irSensitivity * @param irSensitivity
* Sensitivity of the infrared camera. * Sensitivity of the infrared camera.
* @param distance * @param distance
* Pixel Distance between first two dots * Pixel Distance between first two dots
*/ */
public void prepareIRevent(int x, int y, float z, int ax, int ay, public void prepareIRevent(int x, int y, float z, int ax, int ay,
int xVRes, int yVRes, int xOffset, int yOffset, int xVRes, int yVRes, int xOffset, int yOffset,
short sensorBarPostion, short screenAsPectRatio, short sensorBarPostion, short screenAsPectRatio,
short irSensitivity, float distance) { short irSensitivity, float distance) {
if (infraredEvent == null) { if (infraredEvent == null) {
infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes, infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes,
yVRes, xOffset, yOffset, sensorBarPostion, yVRes, xOffset, yOffset, sensorBarPostion,
screenAsPectRatio, irSensitivity, distance); screenAsPectRatio, irSensitivity, distance);
} }
} }
/** /**
* Add an IR point to the generic event. Create an IR Event if it's not * Add an IR point to the generic event. Create an IR Event if it's not
* created yet. * created yet.
* *
* @param x * @param x
* x coordinates. * x coordinates.
* @param y * @param y
* y coordinates * y coordinates
* @param rx * @param rx
* raw X coordinate (0-1023). * raw X coordinate (0-1023).
* @param ry * @param ry
* raw Y coordinate (0-1023). * raw Y coordinate (0-1023).
* @param size * @param size
* size of the IR dot (0-15). * size of the IR dot (0-15).
*/ */
public void addIRpoint(int x, int y, short rx, short ry, short size) { public void addIRpoint(int x, int y, short rx, short ry, short size) {
if (infraredEvent != null) if (infraredEvent != null)
infraredEvent.addIRpoint(x, y, rx, ry, size); infraredEvent.addIRpoint(x, y, rx, ry, size);
} }
/** /**
* Set the Motion Sensing Event. * Set the Motion Sensing Event.
* *
* @param orientationThreshold * @param orientationThreshold
* value of the minimum angle between two events with the * value of the minimum angle between two events with the
* accelerometer. * accelerometer.
* @param accelerationThreshold * @param accelerationThreshold
* value of the value variation between two events with the * value of the value variation between two events with the
* accelerometer. * accelerometer.
* @param smoothingState * @param smoothingState
* true if smoothing flag is activated. * true if smoothing flag is activated.
* @param alphaSmooth * @param alphaSmooth
* value of the alpha smoothing parameter. * value of the alpha smoothing parameter.
* @param r * @param r
* roll. * roll.
* @param p * @param p
* pitch. * pitch.
* @param ya * @param ya
* yaw. * yaw.
* @param ar * @param ar
* absolute roll. * absolute roll.
* @param ap * @param ap
* absolute pitch. * absolute pitch.
* @param x * @param x
* gravity force on x axis. * gravity force on x axis.
* @param y * @param y
* gravity force on y axis. * gravity force on y axis.
* @param z * @param z
* gravity force on z axis. * gravity force on z axis.
* @param xx * @param xx
* raw acceleration on x axis. * raw acceleration on x axis.
* @param yy * @param yy
* raw acceleration on y axis. * raw acceleration on y axis.
* @param zz * @param zz
* raw acceleration on z axis. * raw acceleration on z axis.
*/ */
public void setMotionSensingEvent(float orientationThreshold, public void setMotionSensingEvent(float orientationThreshold,
int accelerationThreshold, boolean smoothingState, int accelerationThreshold, boolean smoothingState,
float alphaSmooth, float r, float p, float ya, float ar, float ap, float alphaSmooth, float r, float p, float ya, float ar, float ap,
float x, float y, float z, short xx, short yy, short zz) { float x, float y, float z, short xx, short yy, short zz) {
motionSensingEvent = new MotionSensingEvent(getWiimoteId(), motionSensingEvent = new MotionSensingEvent(getWiimoteId(),
orientationThreshold, accelerationThreshold, smoothingState, orientationThreshold, accelerationThreshold, smoothingState,
alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz); alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz);
} }
/** /**
* Set a NunchukEvent for the expansion event. * Set a NunchukEvent for the expansion event.
* *
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed. * buttons just pressed.
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released. * buttons just released.
* @param buttonsHeld * @param buttonsHeld
* buttons just pressed. * buttons just pressed.
* @param orientationThreshold * @param orientationThreshold
* value of the minimum angle between two events with the * value of the minimum angle between two events with the
* accelerometer. * accelerometer.
* @param accelerationThreshold * @param accelerationThreshold
* value of the value variation between two events with the * value of the value variation between two events with the
* accelerometer. * accelerometer.
* @param smoothingState * @param smoothingState
* true if smoothing flag is activated. * true if smoothing flag is activated.
* @param alphaSmooth * @param alphaSmooth
* value of the alpha smoothing parameter. * value of the alpha smoothing parameter.
* @param r * @param r
* roll. * roll.
* @param p * @param p
* pitch. * pitch.
* @param ya * @param ya
* yaw. * yaw.
* @param ar * @param ar
* absolute roll. * absolute roll.
* @param ap * @param ap
* absolute pitch. * absolute pitch.
* @param x * @param x
* gravity force on x axis. * gravity force on x axis.
* @param y * @param y
* gravity force on y axis. * gravity force on y axis.
* @param z * @param z
* gravity force on z axis. * gravity force on z axis.
* @param xx * @param xx
* raw acceleration on x axis. * raw acceleration on x axis.
* @param yy * @param yy
* raw acceleration on y axis. * raw acceleration on y axis.
* @param zz * @param zz
* raw acceleration on z axis. * raw acceleration on z axis.
* @param angle * @param angle
* angle the joystick is being held. * angle the joystick is being held.
* @param magnitude * @param magnitude
* magnitude of the joystick (range 0-1). * magnitude of the joystick (range 0-1).
* @param max1 * @param max1
* maximum joystick value 1. * maximum joystick value 1.
* @param max2 * @param max2
* maximum joystick value 2. * maximum joystick value 2.
* @param min1 * @param min1
* minimum joystick value 1. * minimum joystick value 1.
* @param min2 * @param min2
* minimum joystick value 2. * minimum joystick value 2.
* @param center1 * @param center1
* center joystick value 1. * center joystick value 1.
* @param center2 * @param center2
* center joystick value 2. * center joystick value 2.
*/ */
public void setNunchukEvent(short buttonsJustPressed, public void setNunchukEvent(short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld, short buttonsJustReleased, short buttonsHeld,
float orientationThreshold, int accelerationThreshold, float orientationThreshold, int accelerationThreshold,
boolean smoothingState, float alphaSmooth, float r, float p, boolean smoothingState, float alphaSmooth, float r, float p,
float ya, float ar, float ap, float x, float y, float z, short xx, float ya, float ar, float ap, float x, float y, float z, short xx,
short yy, short zz, float angle, float magnitude, short max1, short yy, short zz, float angle, float magnitude, short max1,
short max2, short min1, short min2, short center1, short center2) { short max2, short min1, short min2, short center1, short center2) {
expansionEvent = new NunchukEvent(getWiimoteId(), buttonsJustPressed, expansionEvent = new NunchukEvent(getWiimoteId(), buttonsJustPressed,
buttonsJustReleased, buttonsHeld, orientationThreshold, buttonsJustReleased, buttonsHeld, orientationThreshold,
accelerationThreshold, smoothingState, alphaSmooth, r, p, ya, accelerationThreshold, smoothingState, alphaSmooth, r, p, ya,
ar, ap, x, y, z, xx, yy, zz, angle, magnitude, max1, max2, ar, ap, x, y, z, xx, yy, zz, angle, magnitude, max1, max2,
min1, min2, center1, center2); min1, min2, center1, center2);
} }
/** /**
* Set a ClassicControllerEvent for the expansionEvent. * Set a ClassicControllerEvent for the expansionEvent.
* *
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed. * buttons just pressed.
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released. * buttons just released.
* @param buttonsHeld * @param buttonsHeld
* buttons just pressed. * buttons just pressed.
* @param rightShoulder * @param rightShoulder
* right shoulder button (range 0-1). * right shoulder button (range 0-1).
* @param leftShoulder * @param leftShoulder
* left shoulder button (range 0-1). * left shoulder button (range 0-1).
* @param langle * @param langle
* angle the left joystick is being held. * angle the left joystick is being held.
* @param lmagnitude * @param lmagnitude
* magnitude of the left joystick (range 0-1). * magnitude of the left joystick (range 0-1).
* @param lmax1 * @param lmax1
* maximum left joystick value 1. * maximum left joystick value 1.
* @param lmax2 * @param lmax2
* maximum left joystick value 2. * maximum left joystick value 2.
* @param lmin1 * @param lmin1
* minimum left joystick value 1. * minimum left joystick value 1.
* @param lmin2 * @param lmin2
* minimum left joystick value 2. * minimum left joystick value 2.
* @param lcenter1 * @param lcenter1
* center left joystick value 1. * center left joystick value 1.
* @param lcenter2 * @param lcenter2
* center left joystick value 2. * center left joystick value 2.
* @param rangle * @param rangle
* angle the right joystick is being held. * angle the right joystick is being held.
* @param rmagnitude * @param rmagnitude
* magnitude of the right joystick (range 0-1). * magnitude of the right joystick (range 0-1).
* @param rmax1 * @param rmax1
* maximum right joystick value 1. * maximum right joystick value 1.
* @param rmax2 * @param rmax2
* maximum right joystick value 2. * maximum right joystick value 2.
* @param rmin1 * @param rmin1
* minimum right joystick value 1. * minimum right joystick value 1.
* @param rmin2 * @param rmin2
* minimum right joystick value 2. * minimum right joystick value 2.
* @param rcenter1 * @param rcenter1
* center right joystick value 1. * center right joystick value 1.
* @param rcenter2 * @param rcenter2
* center right joystick value 2. * center right joystick value 2.
*/ */
public void setClassicControllerEvent(short buttonsJustPressed, public void setClassicControllerEvent(short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld, float rightShoulder, short buttonsJustReleased, short buttonsHeld, float rightShoulder,
float leftShoulder, float langle, float lmagnitude, short lmax1, float leftShoulder, float langle, float lmagnitude, short lmax1,
short lmax2, short lmin1, short lmin2, short lcenter1, short lmax2, short lmin1, short lmin2, short lcenter1,
short lcenter2, float rangle, float rmagnitude, short rmax1, short lcenter2, float rangle, float rmagnitude, short rmax1,
short rmax2, short rmin1, short rmin2, short rcenter1, short rmax2, short rmin1, short rmin2, short rcenter1,
short rcenter2) { short rcenter2) {
expansionEvent = new ClassicControllerEvent(getWiimoteId(), expansionEvent = new ClassicControllerEvent(getWiimoteId(),
buttonsJustPressed, buttonsJustReleased, buttonsHeld, buttonsJustPressed, buttonsJustReleased, buttonsHeld,
rightShoulder, leftShoulder, langle, lmagnitude, lmax1, lmax2, rightShoulder, leftShoulder, langle, lmagnitude, lmax1, lmax2,
lmin1, lmin2, lcenter1, lcenter2, rangle, rmagnitude, rmax1, lmin1, lmin2, lcenter1, lcenter2, rangle, rmagnitude, rmax1,
rmax2, rmin1, rmin2, rcenter1, rcenter2); rmax2, rmin1, rmin2, rcenter1, rcenter2);
} }
/** /**
* Set a GuitarHeroEvent for the expansionEvent. * Set a GuitarHeroEvent for the expansionEvent.
* *
* @param buttonsJustPressed * @param buttonsJustPressed
* buttons just pressed. * buttons just pressed.
* @param buttonsJustReleased * @param buttonsJustReleased
* buttons just released. * buttons just released.
* @param buttonsHeld * @param buttonsHeld
* buttons just pressed. * buttons just pressed.
* @param whammyBar * @param whammyBar
* whammy bar (range 0-1). * whammy bar (range 0-1).
* @param angle * @param angle
* angle the joystick is being held. * angle the joystick is being held.
* @param magnitude * @param magnitude
* magnitude of the joystick (range 0-1). * magnitude of the joystick (range 0-1).
* @param max1 * @param max1
* maximum joystick value 1. * maximum joystick value 1.
* @param max2 * @param max2
* maximum joystick value 2. * maximum joystick value 2.
* @param min1 * @param min1
* minimum joystick value 1. * minimum joystick value 1.
* @param min2 * @param min2
* minimum joystick value 2. * minimum joystick value 2.
* @param center1 * @param center1
* center joystick value 1. * center joystick value 1.
* @param center2 * @param center2
* center joystick value 2. * center joystick value 2.
*/ */
public void setGuitarHeroEvent(short buttonsJustPressed, public void setGuitarHeroEvent(short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld, float whammyBar, short buttonsJustReleased, short buttonsHeld, float whammyBar,
float angle, float magnitude, short max1, short max2, short min1, float angle, float magnitude, short max1, short max2, short min1,
short min2, short center1, short center2) { short min2, short center1, short center2) {
expansionEvent = new GuitarHeroEvent(getWiimoteId(), expansionEvent = new GuitarHeroEvent(getWiimoteId(),
buttonsJustPressed, buttonsJustReleased, buttonsHeld, buttonsJustPressed, buttonsJustReleased, buttonsHeld,
whammyBar, angle, magnitude, max1, max2, min1, min2, center1, whammyBar, angle, magnitude, max1, max2, min1, min2, center1,
center2); center2);
} }
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** GENERIC EVENT : WIIMOTE ID :" + getWiimoteId() out += "/*********** GENERIC EVENT : WIIMOTE ID :" + getWiimoteId()
+ " ********/\n"; + " ********/\n";
out += buttonsEvent; out += buttonsEvent;
if (infraredEvent != null) { if (infraredEvent != null) {
out += infraredEvent; out += infraredEvent;
} else { } else {
out += "/******** IR Tracking ********/\n"; out += "/******** IR Tracking ********/\n";
out += "--- Active : false\n"; out += "--- Active : false\n";
} }
if (motionSensingEvent != null) { if (motionSensingEvent != null) {
out += motionSensingEvent; out += motionSensingEvent;
} else { } else {
out += "/******** Motion sensing ********/\n"; out += "/******** Motion sensing ********/\n";
out += "--- Motion sensing : false \n"; out += "--- Motion sensing : false \n";
} }
if (expansionEvent != null) { if (expansionEvent != null) {
out += expansionEvent; out += expansionEvent;
} else { } else {
out += "/******** Expansion ********/\n"; out += "/******** Expansion ********/\n";
out += "--- No expansion connected \n"; out += "--- No expansion connected \n";
} }
return out; return out;
} }
} }

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -1,389 +1,389 @@
/** /**
* This file is part of WiiuseJ. * This file is part of WiiuseJ.
* *
* WiiuseJ is free software: you can redistribute it and/or modify * WiiuseJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* WiiuseJ is distributed in the hope that it will be useful, * WiiuseJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>. * along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
*/ */
package wiiusej.test; package wiiusej.test;
import java.awt.AWTException; import java.awt.AWTException;
import java.awt.Robot; import java.awt.Robot;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import wiiusej.WiiUseApiManager; import wiiusej.WiiUseApiManager;
import wiiusej.Wiimote; import wiiusej.Wiimote;
import wiiusej.values.IRSource; import wiiusej.values.IRSource;
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
import wiiusej.wiiusejevents.physicalevents.IREvent; import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteListener; import wiiusej.wiiusejevents.utils.WiimoteListener;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent; import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent; import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent; import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent; import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/** /**
* This class used to test WiiuseJ in text mode. * This class used to test WiiuseJ in text mode.
* *
* @author guiguito * @author guiguito
*/ */
public class Tests implements WiimoteListener { public class Tests implements WiimoteListener {
Robot robot; Robot robot;
private static int DISPLAY_EACH_VALUE = 1; private static int DISPLAY_EACH_VALUE = 1;
private static int DUMP = 2; private static int DUMP = 2;
private static int MOVE_MOUSE = 3; private static int MOVE_MOUSE = 3;
private static int TEST_LEDS = 5; 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) { public Tests(Wiimote wim) {
wiimote = wim; wiimote = wim;
wiimote.addWiiMoteEventListeners(this); wiimote.addWiiMoteEventListeners(this);
try { try {
robot = new Robot(); robot = new Robot();
} catch (AWTException e) { } catch (AWTException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public void onButtonsEvent(WiimoteButtonsEvent e) { public void onButtonsEvent(WiimoteButtonsEvent e) {
if (dump == DISPLAY_EACH_VALUE) { if (dump == DISPLAY_EACH_VALUE) {
// System.out.println("*********** WIIMOTE ID : "+ // System.out.println("*********** WIIMOTE ID : "+
// e.getWiimoteId() + " **************"); // e.getWiimoteId() + " **************");
/* button ONE */ /* button ONE */
if (e.isButtonOneJustPressed()) { if (e.isButtonOneJustPressed()) {
System.out.println("button one pressed"); System.out.println("button one pressed");
} }
if (e.isButtonOneHeld()) { if (e.isButtonOneHeld()) {
System.out.println("button one held"); System.out.println("button one held");
} }
if (e.isButtonOneJustReleased()) { if (e.isButtonOneJustReleased()) {
System.out.println("button one released"); System.out.println("button one released");
} }
/* button TWO */ /* button TWO */
if (e.isButtonTwoJustPressed()) { if (e.isButtonTwoJustPressed()) {
System.out.println("button two pressed"); System.out.println("button two pressed");
} }
if (e.isButtonTwoHeld()) { if (e.isButtonTwoHeld()) {
System.out.println("button two held"); System.out.println("button two held");
} }
if (e.isButtonTwoJustReleased()) { if (e.isButtonTwoJustReleased()) {
System.out.println("button two released"); System.out.println("button two released");
} }
/* button A */ /* button A */
if (e.isButtonAJustPressed()) { if (e.isButtonAJustPressed()) {
System.out.println("button A pressed"); System.out.println("button A pressed");
} }
if (e.isButtonAHeld()) { if (e.isButtonAHeld()) {
System.out.println("button A held"); System.out.println("button A held");
} }
if (e.isButtonAJustReleased()) { if (e.isButtonAJustReleased()) {
System.out.println("button A released"); System.out.println("button A released");
} }
/* button B */ /* button B */
if (e.isButtonBJustPressed()) { if (e.isButtonBJustPressed()) {
System.out.println("button B pressed"); System.out.println("button B pressed");
} }
if (e.isButtonBHeld()) { if (e.isButtonBHeld()) {
System.out.println("button B held"); System.out.println("button B held");
} }
if (e.isButtonBJustReleased()) { if (e.isButtonBJustReleased()) {
System.out.println("button B released"); System.out.println("button B released");
} }
/* button LEFT */ /* button LEFT */
if (e.isButtonLeftJustPressed()) { if (e.isButtonLeftJustPressed()) {
System.out.println("button Left pressed"); System.out.println("button Left pressed");
} }
if (e.isButtonLeftHeld()) { if (e.isButtonLeftHeld()) {
System.out.println("button Left held"); System.out.println("button Left held");
} }
if (e.isButtonLeftJustReleased()) { if (e.isButtonLeftJustReleased()) {
System.out.println("button Left released"); System.out.println("button Left released");
} }
/* button RIGHT */ /* button RIGHT */
if (e.isButtonRightJustPressed()) { if (e.isButtonRightJustPressed()) {
System.out.println("button Right pressed"); System.out.println("button Right pressed");
} }
if (e.isButtonRightHeld()) { if (e.isButtonRightHeld()) {
System.out.println("button Right held"); System.out.println("button Right held");
} }
if (e.isButtonRightJustReleased()) { if (e.isButtonRightJustReleased()) {
System.out.println("button Right released"); System.out.println("button Right released");
} }
/* button UP */ /* button UP */
if (e.isButtonUpJustPressed()) { if (e.isButtonUpJustPressed()) {
System.out.println("button UP pressed"); System.out.println("button UP pressed");
} }
if (e.isButtonUpHeld()) { if (e.isButtonUpHeld()) {
System.out.println("button UP held"); System.out.println("button UP held");
} }
if (e.isButtonUpJustReleased()) { if (e.isButtonUpJustReleased()) {
System.out.println("button UP released"); System.out.println("button UP released");
} }
/* button DOWN */ /* button DOWN */
if (e.isButtonDownJustPressed()) { if (e.isButtonDownJustPressed()) {
System.out.println("button DOWN pressed"); System.out.println("button DOWN pressed");
} }
if (e.isButtonDownHeld()) { if (e.isButtonDownHeld()) {
System.out.println("button DOWN held"); System.out.println("button DOWN held");
} }
if (e.isButtonDownJustReleased()) { if (e.isButtonDownJustReleased()) {
System.out.println("button DOWN released"); System.out.println("button DOWN released");
} }
/* button MINUS */ /* button MINUS */
if (e.isButtonMinusJustPressed()) { if (e.isButtonMinusJustPressed()) {
System.out.println("button MINUS pressed"); System.out.println("button MINUS pressed");
} }
if (e.isButtonMinusHeld()) { if (e.isButtonMinusHeld()) {
System.out.println("button MINUS held"); System.out.println("button MINUS held");
} }
if (e.isButtonMinusJustReleased()) { if (e.isButtonMinusJustReleased()) {
System.out.println("button MINUS released"); System.out.println("button MINUS released");
} }
/* button PLUS */ /* button PLUS */
if (e.isButtonPlusJustPressed()) { if (e.isButtonPlusJustPressed()) {
System.out.println("button PLUS pressed"); System.out.println("button PLUS pressed");
} }
if (e.isButtonPlusHeld()) { if (e.isButtonPlusHeld()) {
System.out.println("button PLUS held"); System.out.println("button PLUS held");
} }
if (e.isButtonPlusJustReleased()) { if (e.isButtonPlusJustReleased()) {
System.out.println("button PLUS released"); System.out.println("button PLUS released");
} }
/* button HOME */ /* button HOME */
if (e.isButtonHomeJustPressed()) { if (e.isButtonHomeJustPressed()) {
System.out.println("button HOME pressed"); System.out.println("button HOME pressed");
} }
if (e.isButtonHomeHeld()) { if (e.isButtonHomeHeld()) {
System.out.println("button HOME held"); System.out.println("button HOME held");
} }
if (e.isButtonHomeJustReleased()) { if (e.isButtonHomeJustReleased()) {
System.out.println("button HOME released"); System.out.println("button HOME released");
} }
/* get status */ /* get status */
if (e.isButtonUpJustPressed()) { if (e.isButtonUpJustPressed()) {
wiimote.getStatus(); wiimote.getStatus();
} }
/* Activate rumble */ /* Activate rumble */
if (e.isButtonOneJustPressed()) { if (e.isButtonOneJustPressed()) {
System.out.println("Rumble Activated"); System.out.println("Rumble Activated");
wiimote.activateRumble(); wiimote.activateRumble();
} }
if (e.isButtonTwoJustPressed()) { if (e.isButtonTwoJustPressed()) {
System.out.println("Rumble Deactivated"); System.out.println("Rumble Deactivated");
wiimote.deactivateRumble(); wiimote.deactivateRumble();
} }
/* Activate IR Tracking */ /* Activate IR Tracking */
if (e.isButtonAJustPressed()) { if (e.isButtonAJustPressed()) {
System.out.println("IR Activated"); System.out.println("IR Activated");
wiimote.activateIRTRacking(); wiimote.activateIRTRacking();
} }
if (e.isButtonBJustPressed()) { if (e.isButtonBJustPressed()) {
System.out.println("IR Deactivated"); System.out.println("IR Deactivated");
wiimote.deactivateIRTRacking(); wiimote.deactivateIRTRacking();
} }
/* Activate Motion sensing */ /* Activate Motion sensing */
if (e.isButtonPlusJustPressed()) { if (e.isButtonPlusJustPressed()) {
System.out.println("Motion sensing Activated"); System.out.println("Motion sensing Activated");
wiimote.activateMotionSensing(); wiimote.activateMotionSensing();
} }
if (e.isButtonMinusJustPressed()) { if (e.isButtonMinusJustPressed()) {
System.out.println("Motion sensing Deactivated"); System.out.println("Motion sensing Deactivated");
wiimote.deactivateMotionSensing(); wiimote.deactivateMotionSensing();
} }
/* leave test */ /* leave test */
if (e.isButtonHomeJustPressed()) { if (e.isButtonHomeJustPressed()) {
System.out.println("LEAVING TEST"); System.out.println("LEAVING TEST");
wiimote.disconnect(); wiimote.disconnect();
WiiUseApiManager.definitiveShutdown(); WiiUseApiManager.definitiveShutdown();
} }
} else if (dump == DUMP) { } else if (dump == DUMP) {
System.out.println(e); System.out.println(e);
/* Activate all */ /* Activate all */
if (e.isButtonAJustPressed()) { if (e.isButtonAJustPressed()) {
System.out.println("IR, rumble and motion sensing Activated"); System.out.println("IR, rumble and motion sensing Activated");
wiimote.activateIRTRacking(); wiimote.activateIRTRacking();
wiimote.activateMotionSensing(); wiimote.activateMotionSensing();
wiimote.activateRumble(); wiimote.activateRumble();
} }
if (e.isButtonBJustPressed()) { if (e.isButtonBJustPressed()) {
System.out.println("IR, rumble and motion sensing Deactivated"); System.out.println("IR, rumble and motion sensing Deactivated");
wiimote.deactivateIRTRacking(); wiimote.deactivateIRTRacking();
wiimote.deactivateMotionSensing(); wiimote.deactivateMotionSensing();
wiimote.deactivateRumble(); wiimote.deactivateRumble();
} }
/* leave test */ /* leave test */
if (e.isButtonHomeJustPressed()) { if (e.isButtonHomeJustPressed()) {
System.out.println("LEAVING TEST"); System.out.println("LEAVING TEST");
wiimote.disconnect(); wiimote.disconnect();
} }
} else if (dump == MOVE_MOUSE) { } else if (dump == MOVE_MOUSE) {
/* Activate IR Tracking */ /* Activate IR Tracking */
if (e.isButtonOneJustPressed()) { if (e.isButtonOneJustPressed()) {
System.out.println("IR Activated"); System.out.println("IR Activated");
wiimote.activateIRTRacking(); wiimote.activateIRTRacking();
} }
if (e.isButtonTwoJustPressed()) { if (e.isButtonTwoJustPressed()) {
System.out.println("IR Deactivated"); System.out.println("IR Deactivated");
wiimote.deactivateIRTRacking(); wiimote.deactivateIRTRacking();
} }
/* button A */ /* button A */
if (e.isButtonAJustPressed()) { if (e.isButtonAJustPressed()) {
robot.mousePress(InputEvent.BUTTON1_MASK); robot.mousePress(InputEvent.BUTTON1_MASK);
} }
if (e.isButtonAJustReleased()) { if (e.isButtonAJustReleased()) {
robot.mouseRelease(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK);
} }
/* button B */ /* button B */
if (e.isButtonBJustPressed()) { if (e.isButtonBJustPressed()) {
robot.mousePress(InputEvent.BUTTON2_MASK); robot.mousePress(InputEvent.BUTTON2_MASK);
} }
if (e.isButtonBJustReleased()) { if (e.isButtonBJustReleased()) {
robot.mouseRelease(InputEvent.BUTTON2_MASK); robot.mouseRelease(InputEvent.BUTTON2_MASK);
} }
/* leave test */ /* leave test */
if (e.isButtonHomeJustPressed()) { if (e.isButtonHomeJustPressed()) {
System.out.println("LEAVING TEST"); System.out.println("LEAVING TEST");
wiimote.disconnect(); wiimote.disconnect();
} }
} else if (dump == TEST_LEDS) { } else if (dump == TEST_LEDS) {
wiimote.activateMotionSensing(); wiimote.activateMotionSensing();
if (e.isButtonUpJustPressed()) { if (e.isButtonUpJustPressed()) {
wiimote.setLeds(true, false, false, false); wiimote.setLeds(true, false, false, false);
} }
if (e.isButtonDownJustPressed()) { if (e.isButtonDownJustPressed()) {
wiimote.setLeds(false, true, false, false); wiimote.setLeds(false, true, false, false);
} }
if (e.isButtonLeftJustPressed()) { if (e.isButtonLeftJustPressed()) {
wiimote.setLeds(false, false, true, false); wiimote.setLeds(false, false, true, false);
} }
if (e.isButtonRightJustPressed()) { if (e.isButtonRightJustPressed()) {
wiimote.setLeds(false, false, false, true); wiimote.setLeds(false, false, false, true);
} }
/* leave test */ /* leave test */
if (e.isButtonHomeJustPressed()) { if (e.isButtonHomeJustPressed()) {
System.out.println("LEAVING TEST"); System.out.println("LEAVING TEST");
wiimote.disconnect(); wiimote.disconnect();
} }
} }
} }
public void onIrEvent(IREvent e) { public void onIrEvent(IREvent e) {
if (dump == MOVE_MOUSE) { if (dump == MOVE_MOUSE) {
IRSource[] list = e.getIRPoints(); IRSource[] list = e.getIRPoints();
if (list.length > 0) { if (list.length > 0) {
int x1 = (int) list[0].getX(); int x1 = (int) list[0].getX();
int y1 = (int) list[0].getY(); int y1 = (int) list[0].getY();
int mousex = (int) Math.round(((double) x1 / 1024.0) * 1280.0); int mousex = (int) Math.round(((double) x1 / 1024.0) * 1280.0);
int mousey = (int) Math.round(((double) y1 / 768.0) * 1024.0); int mousey = (int) Math.round(((double) y1 / 768.0) * 1024.0);
robot.mouseMove(mousex, mousey); robot.mouseMove(mousex, mousey);
} }
} else { } else {
System.out.println(e); System.out.println(e);
} }
} }
public void onMotionSensingEvent(MotionSensingEvent e) { public void onMotionSensingEvent(MotionSensingEvent e) {
/* display motion sensing */ /* display motion sensing */
System.out.println(e); System.out.println(e);
} }
public void onExpansionEvent(ExpansionEvent e) { public void onExpansionEvent(ExpansionEvent e) {
System.out.println(e); System.out.println(e);
} }
public void onStatusEvent(StatusEvent e) { public void onStatusEvent(StatusEvent e) {
// Display status variables // Display status variables
System.out.println(e); System.out.println(e);
} }
public void onDisconnectionEvent(DisconnectionEvent e) { public void onDisconnectionEvent(DisconnectionEvent e) {
System.out.println(" wiimote " + e.getWiimoteId() System.out.println(" wiimote " + e.getWiimoteId()
+ "has been disconnected !!"); + "has been disconnected !!");
} }
public void onNunchukInsertedEvent(NunchukInsertedEvent e) { public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
System.out.println(e); System.out.println(e);
} }
public void onNunchukRemovedEvent(NunchukRemovedEvent e) { public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
System.out.println(e); System.out.println(e);
} }
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e) { public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e) {
System.out.println(e); System.out.println(e);
} }
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e) { public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e) {
System.out.println(e); System.out.println(e);
} }
public void onClassicControllerInsertedEvent( public void onClassicControllerInsertedEvent(
ClassicControllerInsertedEvent e) { ClassicControllerInsertedEvent e) {
System.out.println(e); System.out.println(e);
} }
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e) { public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e) {
System.out.println(e); System.out.println(e);
} }
/** /**
* @param args * @param args
*/ */
public static void main(String[] args) { public static void main(String[] args) {
Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true); Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
if (wiimotes.length > 0) { if (wiimotes.length > 0) {
System.out.println(wiimotes[0]); System.out.println(wiimotes[0]);
new Tests(wiimotes[0]); new Tests(wiimotes[0]);
} else { } else {
System.out.println("No wiimotes found !!!"); System.out.println("No wiimotes found !!!");
} }
// java.util.Timer timer = new java.util.Timer(); // java.util.Timer timer = new java.util.Timer();
// timer.scheduleAtFixedRate(new LedsTask(), 0, 100); // timer.scheduleAtFixedRate(new LedsTask(), 0, 100);
} }
} }