Ant buildfile aan Mimis toegevoegd om uitvoerbare jar te maken. Begonnen aan implementatie van Wii Balance Board in WiiuseJ.

This commit is contained in:
2011-10-22 09:15:01 +00:00
parent 80f639474b
commit 8e485256b2
39 changed files with 385 additions and 186 deletions

Binary file not shown.

View File

@@ -1,4 +1,4 @@
#Wed Jul 20 23:54:48 CEST 2011 #Wed Oct 19 11:47:57 CEST 2011
eclipse.preferences.version=1 eclipse.preferences.version=1
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/CPATH/delimiter=; environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/CPATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/CPATH/operation=remove environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/CPATH/operation=remove
@@ -6,6 +6,12 @@ environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/C_INCLUDE_PATH/operation=remove environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/C_INCLUDE_PATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/append=true environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/append=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/appendContributed=true environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/appendContributed=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/CPATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/CPATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/C_INCLUDE_PATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/C_INCLUDE_PATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/append=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339.10143143/appendContributed=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/CPATH/delimiter=; environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/CPATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/CPATH/operation=remove environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/CPATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/C_INCLUDE_PATH/delimiter=; environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.release.1074641339/C_INCLUDE_PATH/delimiter=;

View File

@@ -50,6 +50,7 @@
<listOptionValue builtIn="false" value="&quot;${jdk}/include/win32&quot;"/> <listOptionValue builtIn="false" value="&quot;${jdk}/include/win32&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
</option> </option>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1057877516" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.820612620" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.820612620" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.424942675" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug"> <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.424942675" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug">
@@ -103,7 +104,7 @@
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.release.582624041" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.release"> <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.release.582624041" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.release.852849225" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.release"/> <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.release.852849225" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.release"/>
<builder buildPath="${workspace_loc:/WiiuseJ/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1667515887" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/> <builder buildPath="${workspace_loc:/WiiuseJ/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1667515887" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.so.release.1955417593" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.release"> <tool command="as" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.assembler.mingw.so.release.1955417593" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.204782274" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> <inputType id="cdt.managedbuild.tool.gnu.assembler.input.204782274" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.2134712739" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/> <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.2134712739" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
@@ -124,6 +125,7 @@
<listOptionValue builtIn="false" value="&quot;${jdk}/include/win32&quot;"/> <listOptionValue builtIn="false" value="&quot;${jdk}/include/win32&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
</option> </option>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.227749697" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.839631863" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.839631863" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release.901924366" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release"> <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release.901924366" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release">
@@ -143,6 +145,7 @@
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType> </inputType>
<outputType id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.output.543131979" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.output"/>
</tool> </tool>
</toolChain> </toolChain>
</folderInfo> </folderInfo>

Binary file not shown.

Binary file not shown.

View File

@@ -20,7 +20,6 @@
#include "wiiusej_WiiUseApi.h" #include "wiiusej_WiiUseApi.h"
#include "wiiuse.h" #include "wiiuse.h"
#include <jni.h>
/* /*
* These are some identifiers for wiimotes * These are some identifiers for wiimotes
* *
@@ -511,8 +510,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
nc->js.max.x,nc->js.max.y, nc->js.max.x,nc->js.max.y,
nc->js.min.x,nc->js.min.y, nc->js.min.x,nc->js.min.y,
nc->js.center.x,nc->js.center.y); nc->js.center.x,nc->js.center.y);
} } else if (wiimotes[i]->exp.type == EXP_GUITAR_HERO_3) {
else if (wiimotes[i]->exp.type == EXP_GUITAR_HERO_3) {
/* put guitar hero values in wiimote generic event */ /* put guitar hero values in wiimote generic event */
mid = (*env)->GetMethodID(env, cls, mid = (*env)->GetMethodID(env, cls,
"addGuitarHeroEventToPreparedWiimoteEvent", "(SSSFFFSSSSSS)V"); "addGuitarHeroEventToPreparedWiimoteEvent", "(SSSFFFSSSSSS)V");
@@ -531,7 +529,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
gh->js.max.x,gh->js.max.y, gh->js.max.x,gh->js.max.y,
gh->js.min.x,gh->js.min.y, gh->js.min.x,gh->js.min.y,
gh->js.center.x,gh->js.center.y); gh->js.center.x,gh->js.center.y);
}if (wiimotes[i]->exp.type == EXP_CLASSIC) { } else if (wiimotes[i]->exp.type == EXP_CLASSIC) {
/* put classic controller values in wiimote generic event */ /* put classic controller values in wiimote generic event */
mid = (*env)->GetMethodID(env, cls, mid = (*env)->GetMethodID(env, cls,
"addClassicControllerEventToPreparedWiimoteEvent", "(SSSFFFFSSSSSSFFSSSSSS)V"); "addClassicControllerEventToPreparedWiimoteEvent", "(SSSFFFFSSSSSSFFSSSSSS)V");
@@ -555,12 +553,25 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
cl->rjs.max.x,cl->rjs.max.y, cl->rjs.max.x,cl->rjs.max.y,
cl->rjs.min.x,cl->rjs.min.y, cl->rjs.min.x,cl->rjs.min.y,
cl->rjs.center.x,cl->rjs.center.y); cl->rjs.center.x,cl->rjs.center.y);
} else if (wiimotes[i]->exp.type == EXP_BALANCE_BOARD) {
/* put balance board values in wiimote generic event */
mid = (*env)->GetMethodID(env, cls,
"addBalanceBoardEventToPreparedWiimoteEvent", "(FFFF)V");
if (mid == 0) {
return;
}
struct balance_board_t* bb = (balance_board_t*)&wiimotes[i]->exp.bb;
(*env)->CallVoidMethod(env, gath, mid,
/* weight */
bb->tr,
bb->br,
bb->bl,
bb->tl);
} }
} }
/* add generic event to java object used to gather events in c environment */ /* add generic event to java object used to gather events in c environment */
mid = (*env)->GetMethodID(env, cls, "addWiimoteEvent", mid = (*env)->GetMethodID(env, cls, "addWiimoteEvent", "()V");
"()V");
if (mid == 0) { if (mid == 0) {
return; return;
} }
@@ -639,6 +650,24 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break; break;
case WIIUSE_BALANCE_BOARD_CTRL_INSERTED:
/* the balance board was just connected */
mid = (*env)->GetMethodID(env, cls, "addBalanceBoardInsertedEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_BALANCE_BOARD_CTRL_REMOVED:
/* the balance board disconnected */
mid = (*env)->GetMethodID(env, cls, "addBalanceBoardRemovedEvent", "(I)V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid);
break;
case WIIUSE_STATUS: case WIIUSE_STATUS:
/* a status event occured */ /* a status event occured */
mid = (*env)->GetMethodID(env, cls, "addStatusEvent", "(IZFSZIZZZZ)V"); mid = (*env)->GetMethodID(env, cls, "addStatusEvent", "(IZFSZIZZZZ)V");
@@ -736,5 +765,4 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_streamSpeakerData(JNIEnv *env, job
}*/ }*/
wiiuse_speaker_data(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), (byte*) jbData, len); wiiuse_speaker_data(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), (byte*) jbData, len);
(*env)->ReleaseByteArrayElements(env, jbArray, jbData, JNI_FALSE); (*env)->ReleaseByteArrayElements(env, jbArray, jbData, JNI_FALSE);
} }

View File

@@ -1,7 +1,6 @@
/* 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

41
java/build.xml Normal file
View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="jar" name="Build file for Project Mimis">
<target name="javadoc">
<javadoc access="private" author="true" classpath="cfg;resource;lib/log4j-1.2.16.jar;lib/jxinput.jar;lib/commons-logging-1.1.1.jar;lib/jacob-1.15-M3.jar" destdir="doc" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" packagenames="mimis.exception.macro,mimis.device.network,wiiusej,mimis.application.itunes,mimis.exception.util,mimis.device.javainput,wiiusej.wiiusejevents,wiiusej.wiiusejevents.utils,mimis.util.swing,mimis.exception.worker,mimis.application.lirc,mimis.application.cmd.windows.winamp,wiiusej.values,mimis.exception.event,mimis.device.lirc.remote,mimis.device.panel,mimis.exception.device,mimis.exception.button,mimis.application.robot,mimis.application.lirc.ipod,mimis.exception.task.action,mimis.exception.application,wiiusej.wiiusejevents.wiiuseapievents,mimis.application.cmd.windows.gomplayer,mimis.application.mpc,org.wiigee.logic,mimis.device.lirc,mimis.sequence,mimis.manager,org.wiigee.util,mimis.event,mimis.application.cmd.windows.wmp,mimis.value,mimis.device.javainput.extreme3d,mimis.event.router,mimis.application.cmd,mimis.worker,org.wiigee.event,mimis.device.wiimote,mimis.device.wiimote.gesture.event,wiiusej.wiiusejevents.physicalevents,mimis.util.multiplexer,mimis,org.wiigee.control,mimis.exception.device.javainput,mimis.util,mimis.application.cmd.windows,com.dt.iTunesController,org.wiigee.device,mimis.application.vlc,mimis.device.wiimote.gesture,mimis.device.jintellitype,mimis.event.feedback,mimis.device,org.wiigee.filter,mimis.exception.application.windows,mimis.application,mimis.sequence.state,mimis.device.javainput.rumblepad,com.melloware.jintellitype,mimis.exception.event.router,mimis.exception.task,mimis.exception" source="1.6" sourcepath="src" splitindex="true" use="true" version="true"/>
</target>
<property name="dir" value="."/>
<target name="jar">
<jar destfile="${dir}/main.jar" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="mimis.Main" />
<attribute name="Class-Path" value="." />
</manifest>
<fileset dir="bin" />
<fileset dir="resource" />
<zipfileset excludes="META-INF/*.SF" src="lib/commons-logging-1.1.1.jar" />
<zipfileset excludes="META-INF/*.SF" src="lib/log4j-1.2.16.jar" />
<zipfileset excludes="META-INF/*.SF" src="lib/jacob-1.15-M3.jar" />
<zipfileset excludes="META-INF/*.SF" src="lib/jxinput.jar" />
<fileset dir="cfg" />
</jar>
<jar destfile="${dir}/client.jar" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="mimis.Client" />
<attribute name="Class-Path" value="." />
</manifest>
<fileset dir="bin" />
<fileset dir="resource" />
<zipfileset excludes="META-INF/*.SF" src="lib/commons-logging-1.1.1.jar" />
<zipfileset excludes="META-INF/*.SF" src="lib/log4j-1.2.16.jar" />
<zipfileset excludes="META-INF/*.SF" src="lib/jacob-1.15-M3.jar" />
<zipfileset excludes="META-INF/*.SF" src="lib/jxinput.jar" />
<fileset dir="cfg" />
</jar>
<!--copy todir="${dir}">
<fileset dir=".">
<include name="*.dll" />
<include name="*.exe" />
</fileset>
</copy-->
</target>
</project>

View File

@@ -1,4 +0,0 @@
@echo off
set path="C:\Program Files (x86)\Java\jdk1.6.0_24\bin";%path%;native
java -cp bin;cfg;resource;lib/commons-logging-1.1.1.jar;lib/jacob-1.15-M3.jar;lib/TableLayout.jar;lib/nativecall-0.4.1.jar;lib/nativeloader-200505172341.jar mimis.Client
pause

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +0,0 @@
@echo off
set path="C:\Program Files (x86)\Java\jdk1.6.0_24\bin";%path%;native
java -cp bin;cfg;resource;lib/commons-logging-1.1.1.jar;lib/jacob-1.15-M3.jar;lib/TableLayout.jar;lib/nativecall-0.4.1.jar;lib/nativeloader-200505172341.jar mimis.Main
pause

View File

@@ -77,7 +77,6 @@ public class WiimoteDevice extends Device implements GestureListener {
} }
if (!connected) { if (!connected) {
try { try {
log.debug("!");
connect(); connect();
} catch (DeviceNotFoundException e) { } catch (DeviceNotFoundException e) {
disconnect = true; disconnect = true;
@@ -98,7 +97,6 @@ public class WiimoteDevice extends Device implements GestureListener {
} }
wiimoteDiscovery.disconnect(); wiimoteDiscovery.disconnect();
disconnect = false; disconnect = false;
//start();
} }
} }
@@ -168,11 +166,12 @@ public class WiimoteDevice extends Device implements GestureListener {
} }
/* Connectivity */ /* Connectivity */
public void connect() throws DeviceNotFoundException { public synchronized void connect() throws DeviceNotFoundException {
wiimote = wiimoteService.getDevice(this); wiimote = wiimoteService.getDevice(this);
log.debug("Connected"); //wiimote.activateContinuous();
wiimoteDiscovery.stop(); wiimoteDiscovery.stop();
ledWorker.start(); //ledWorker.start();
sleep(10000);
} }
/* Listeners */ /* Listeners */

View File

@@ -9,6 +9,7 @@ import mimis.exception.worker.ActivateException;
import mimis.exception.worker.DeactivateException; import mimis.exception.worker.DeactivateException;
public class WiimoteDiscovery extends Worker { public class WiimoteDiscovery extends Worker {
protected static final String WIISCAN = "wiiscan-bb.exe";
protected static final int TIMEOUT = 1000; protected static final int TIMEOUT = 1000;
protected WiimoteDevice wiimoteDevice; protected WiimoteDevice wiimoteDevice;
protected Process process; protected Process process;
@@ -29,7 +30,7 @@ public class WiimoteDiscovery extends Worker {
} }
public boolean execute(String parameters) { public boolean execute(String parameters) {
String command = "wiiscan.exe -l none " + parameters; String command = WIISCAN + " -l none " + parameters;
try { try {
process = Runtime.getRuntime().exec(command); process = Runtime.getRuntime().exec(command);
Scanner scanner = new Scanner(process.getInputStream()); Scanner scanner = new Scanner(process.getInputStream());

View File

@@ -16,6 +16,8 @@ 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.BalanceBoardInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
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;
@@ -30,8 +32,7 @@ public class WiimoteService extends WiiUseApiManager implements WiimoteListener
public static void main(String[] args) { public static void main(String[] args) {
Log log = LogFactory.getLog(WiimoteService.class); Log log = LogFactory.getLog(WiimoteService.class);
WiimoteService wiimoteService = new WiimoteService(); for (Wiimote wm : WiiUseApiManager.getWiimotes(1, false)) {
for (Wiimote wm : wiimoteService.getWiimotes(1, false)) {
log.debug(wm); log.debug(wm);
} }
} }
@@ -88,6 +89,7 @@ public class WiimoteService extends WiiUseApiManager implements WiimoteListener
} }
public void onStatusEvent(StatusEvent event) { public void onStatusEvent(StatusEvent event) {
log.debug(event);
if (event.isConnected()) { if (event.isConnected()) {
WiimoteDevice wiimoteDevice = getWiimoteDevice(event); WiimoteDevice wiimoteDevice = getWiimoteDevice(event);
wiimoteDevice.connected = true; wiimoteDevice.connected = true;
@@ -106,4 +108,12 @@ public class WiimoteService extends WiiUseApiManager implements WiimoteListener
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent event) {} public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent event) {}
public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent event) {} public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent event) {}
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent event) {} public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent event) {}
public void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent e) {
log.debug(e);
}
public void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent e) {
}
} }

View File

@@ -20,6 +20,8 @@ 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.BalanceBoardInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
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;
@@ -327,7 +329,11 @@ public class Wiimote implements WiiUseApiListener {
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);
} } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_BALANCE_BOARD_CTRL_INSERTED) {
notifyBalanceBoardInsertedEventListeners((BalanceBoardInsertedEvent) e);
} else if (e.getEventType() == WiiUseApiEvent.WIIUSE_BALANCE_BOARD_CTRL_REMOVED) {
notifyBalanceBoardRemovedEventListeners((BalanceBoardRemovedEvent) e);
}
/* /*
* events not managed yet || e.getEventType() == WIIUSE_READ_DATA * events not managed yet || e.getEventType() == WIIUSE_READ_DATA
* WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED || e.getEventType() == * WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED || e.getEventType() ==
@@ -487,6 +493,18 @@ public class Wiimote implements WiiUseApiListener {
} }
} }
protected void notifyBalanceBoardInsertedEventListeners(BalanceBoardInsertedEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) {
listener.onBalanceBoardInsertedEvent(evt);
}
}
protected void notifyBalanceBoardRemovedEventListeners(BalanceBoardRemovedEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) {
listener.onBalanceBoardRemovedEvent(evt);
}
}
@Override @Override
public String toString() { public String toString() {
return "Wiimote with ID : " + id; return "Wiimote with ID : " + id;

View File

@@ -12,11 +12,6 @@ public class Calibration {
(short) (gAcceleration.getX() - zeroAcceleration.getX()), (short) (gAcceleration.getX() - zeroAcceleration.getX()),
(short) (gAcceleration.getY() - zeroAcceleration.getY()), (short) (gAcceleration.getY() - zeroAcceleration.getY()),
(short) (gAcceleration.getZ() - zeroAcceleration.getZ())); (short) (gAcceleration.getZ() - zeroAcceleration.getZ()));
System.out.println(zeroAcceleration);
System.out.println(gAcceleration);
System.out.println(differenceAcceleration);
System.out.println("<");
//System.exit(0);
} }
public RawAcceleration getZeroAcceleration() { public RawAcceleration getZeroAcceleration() {

View File

@@ -0,0 +1,11 @@
package wiiusej.wiiusejevents.physicalevents;
public class BalanceBoardButtonsEvent extends ButtonsEvent {
protected static short BALANCE_BOARD_BUTTON = 0x0001;
public BalanceBoardButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) {
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
}
}

View File

@@ -0,0 +1,33 @@
package wiiusej.wiiusejevents.physicalevents;
public class BalanceBoardEvent extends ExpansionEvent {
protected BalanceBoardButtonsEvent buttonsEvent;
protected JoystickEvent balanceBoardJoystickEvent;
public BalanceBoardEvent(int id, float topRight, float bottomRight,
float bottomLeft, float topLeft) {
super(id);
System.out.println(String.format("%f %f %f %f", topRight, bottomRight, bottomLeft, topLeft));
/*balanceBoardJoystickEvent = new JoystickEvent(id, angle,
magnitude, max1, max2, min1, min2, center1, center2);*/
}
public boolean isThereBalanceBoardJoystickEvent() {
return balanceBoardJoystickEvent != null;
}
public JoystickEvent getBalanceBoardJoystickEvent() {
return balanceBoardJoystickEvent;
}
public String toString() {
String out = "";
/* Status */
out += "/*********** Balance Board EVENT : WIIMOTE ID :" + getWiimoteId()
+ " ********/\n";
out += balanceBoardJoystickEvent;
return out;
}
}

View File

@@ -16,6 +16,8 @@
*/ */
package wiiusej.wiiusejevents.utils; package wiiusej.wiiusejevents.utils;
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
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;
@@ -362,6 +364,14 @@ public class EventsGatherer {
} }
} }
public void addBalanceBoardEventToPreparedWiimoteEvent(float topRight,
float bottomRight, float bottomLeft, float topLeft) {
if (genericEvent != null) {
genericEvent.setBalanceBoardEvent(topRight, bottomRight,
bottomLeft, topLeft);
}
}
/** /**
* Add the prepared WiimoteEvent to the gatherer. * Add the prepared WiimoteEvent to the gatherer.
*/ */
@@ -484,6 +494,16 @@ public class EventsGatherer {
addEvent(evt); addEvent(evt);
} }
public void addBalanceBoardInsertedEvent(int id) {
BalanceBoardInsertedEvent evt = new BalanceBoardInsertedEvent(id);
addEvent(evt);
}
public void addBalanceBoardRemovedEvent(int id) {
BalanceBoardRemovedEvent evt = new BalanceBoardRemovedEvent(id);
addEvent(evt);
}
/** /**
* Return an array containing the events. * Return an array containing the events.
* *

View File

@@ -20,6 +20,8 @@ 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.BalanceBoardInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
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;
@@ -142,4 +144,6 @@ public interface WiimoteListener extends java.util.EventListener {
*/ */
void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e); void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e);
void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent e);
void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent e);
} }

View File

@@ -0,0 +1,15 @@
package wiiusej.wiiusejevents.wiiuseapievents;
public class BalanceBoardInsertedEvent extends WiiUseApiEvent {
public BalanceBoardInsertedEvent(int id) {
super(id, WIIUSE_BALANCE_BOARD_CTRL_INSERTED);
}
public String toString() {
String out = "";
/* Status */
out += "/*********** BALANCE BOARD INSERTED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n";
return out;
}
}

View File

@@ -0,0 +1,17 @@
package wiiusej.wiiusejevents.wiiuseapievents;
import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
public class BalanceBoardRemovedEvent extends WiiUseApiEvent {
public BalanceBoardRemovedEvent(int id) {
super(id, WIIUSE_BALANCE_BOARD_CTRL_REMOVED);
}
public String toString() {
String out = "";
/* Status */
out += "/*********** BALANCE BOARD INSERTED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n";
return out;
}
}

View File

@@ -24,7 +24,6 @@ import wiiusej.wiiusejevents.GenericEvent;
* @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;
@@ -36,6 +35,8 @@ public abstract class WiiUseApiEvent extends GenericEvent{
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;
public static int WIIUSE_BALANCE_BOARD_CTRL_INSERTED = 11;
public static int WIIUSE_BALANCE_BOARD_CTRL_REMOVED = 12;
/* Event Type */ /* Event Type */
private int eventType; private int eventType;

View File

@@ -16,6 +16,7 @@
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
import wiiusej.wiiusejevents.physicalevents.BalanceBoardEvent;
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;
@@ -405,6 +406,12 @@ public class WiimoteEvent extends WiiUseApiEvent {
center2); center2);
} }
public void setBalanceBoardEvent(float topRight, float bottomRight,
float bottomLeft, float topLeft) {
expansionEvent = new BalanceBoardEvent(getWiimoteId(), topRight,
bottomRight, bottomLeft, topLeft);
}
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
@@ -437,5 +444,4 @@ public class WiimoteEvent extends WiiUseApiEvent {
return out; return out;
} }
} }

Binary file not shown.

Binary file not shown.