From 574b6cc810757915e6121af534eceaf3a7d83b9d Mon Sep 17 00:00:00 2001 From: Rik Veenboer Date: Tue, 1 Sep 2015 13:14:57 +0100 Subject: [PATCH] Replace tabs with spaces --- src/main/c/wiiusej_WiiUseApi.c | 600 ++++---- src/main/java/wiiusej/WiiUseApi.java | 576 +++---- src/main/java/wiiusej/WiiUseApiManager.java | 1134 +++++++------- src/main/java/wiiusej/Wiimote.java | 818 +++++----- .../AccelerationExpansionEventPanel.java | 16 +- .../java/wiiusej/utils/AccelerationPanel.java | 428 +++--- .../utils/AccelerationWiimoteEventPanel.java | 14 +- .../java/wiiusej/utils/ButtonsEventPanel.java | 576 +++---- src/main/java/wiiusej/utils/GForcePanel.java | 434 +++--- .../utils/GForceWiimoteEventPanel.java | 14 +- src/main/java/wiiusej/utils/IRPanel.java | 386 ++--- .../wiiusej/utils/JoystickEventPanel.java | 340 ++--- .../utils/NunchukJoystickEventPanel.java | 14 +- .../utils/OrientationExpansionEventPanel.java | 16 +- .../java/wiiusej/utils/OrientationPanel.java | 436 +++--- .../utils/OrientationWiimoteEventPanel.java | 14 +- src/main/java/wiiusej/values/GForce.java | 96 +- src/main/java/wiiusej/values/IRSource.java | 144 +- src/main/java/wiiusej/values/Orientation.java | 164 +- .../java/wiiusej/values/RawAcceleration.java | 96 +- .../wiiusej/wiiusejevents/GenericEvent.java | 68 +- .../physicalevents/ButtonsEvent.java | 174 +-- .../ClassicControllerButtonsEvent.java | 606 ++++---- .../ClassicControllerEvent.java | 282 ++-- .../physicalevents/ExpansionEvent.java | 22 +- .../GuitarHeroButtonsEvent.java | 320 ++-- .../physicalevents/GuitarHeroEvent.java | 176 +-- .../wiiusejevents/physicalevents/IREvent.java | 532 +++---- .../physicalevents/JoystickEvent.java | 198 +-- .../physicalevents/MotionSensingEvent.java | 322 ++-- .../physicalevents/NunchukButtonsEvent.java | 100 +- .../physicalevents/NunchukEvent.java | 270 ++-- .../physicalevents/WiimoteButtonsEvent.java | 364 ++--- .../wiiusejevents/utils/EventsGatherer.java | 896 +++++------ .../utils/WiiUseApiListener.java | 16 +- .../wiiusejevents/utils/WiimoteListener.java | 186 +-- .../ClassicControllerInsertedEvent.java | 34 +- .../ClassicControllerRemovedEvent.java | 34 +- .../wiiuseapievents/DisconnectionEvent.java | 34 +- .../GuitarHeroInsertedEvent.java | 34 +- .../GuitarHeroRemovedEvent.java | 34 +- .../wiiuseapievents/NunchukInsertedEvent.java | 44 +- .../wiiuseapievents/NunchukRemovedEvent.java | 44 +- .../wiiuseapievents/StatusEvent.java | 468 +++--- .../wiiuseapievents/WiiUseApiEvent.java | 76 +- .../wiiuseapievents/WiimoteEvent.java | 770 +++++----- .../wiiusej/test/CloseGuiTestCleanly.java | 42 +- src/test/java/wiiusej/test/Main.java | 30 +- .../java/wiiusej/test/NunchukGuiTest.java | 680 ++++----- src/test/java/wiiusej/test/Tests.java | 598 ++++---- .../java/wiiusej/test/WiiuseJGuiTest.java | 1326 ++++++++--------- 51 files changed, 7548 insertions(+), 7548 deletions(-) diff --git a/src/main/c/wiiusej_WiiUseApi.c b/src/main/c/wiiusej_WiiUseApi.c index b6f17fd..872b050 100644 --- a/src/main/c/wiiusej_WiiUseApi.c +++ b/src/main/c/wiiusej_WiiUseApi.c @@ -23,31 +23,31 @@ #include "wiiusej_WiiUseApi.h" #include "wiiuse.h" /* - * These are some identifiers for wiimotes + * These are some identifiers for wiimotes * - * See below in main() for what they are used for. + * See below in main() for what they are used for. */ -#define WIIMOTE_STATE_RUMBLE 0x0010 -#define WIIMOTE_STATE_CONNECTED 0x0008 -#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s)) -#define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s)) -#define WIIUSE_GET_IR_SENSITIVITY_CORRECTED(wm, lvl) \ - do { \ - if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \ - else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \ - else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \ - else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \ - else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \ - else *lvl = 0; \ - } while (0) +#define WIIMOTE_STATE_RUMBLE 0x0010 +#define WIIMOTE_STATE_CONNECTED 0x0008 +#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s)) +#define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s)) +#define WIIUSE_GET_IR_SENSITIVITY_CORRECTED(wm, lvl) \ + do { \ + if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \ + else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \ + else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \ + else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \ + else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \ + else *lvl = 0; \ + } while (0) /********************* VARIABLES DECLARATIONS *****************************/ /* - * Make a temp array of wiimote ids. - * Here I only anticipate connecting up to - * two wiimotes. Each wiimote connected - * will get one of these ids. + * Make a temp array of wiimote ids. + * Here I only anticipate connecting up to + * two wiimotes. Each wiimote connected + * will get one of these ids. */ static wiimote** wiimotes; static int nbMaxWiimotes; @@ -61,7 +61,7 @@ static int nbMaxWiimotes; */ JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_connect (JNIEnv *env, jobject obj, jint nbWiimotes) { - return wiiuse_connect(wiimotes, nbWiimotes); + return wiiuse_connect(wiimotes, nbWiimotes); } /** @@ -72,7 +72,7 @@ JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_connect */ JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_find (JNIEnv *env, jobject obj, jint nbMaxWiimotes, jint timeout) { - return wiiuse_find(wiimotes, nbMaxWiimotes, timeout); + return wiiuse_find(wiimotes, nbMaxWiimotes, timeout); } /** @@ -81,8 +81,8 @@ JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_find */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_init (JNIEnv *env, jobject obj, jint nbPossibleWiimotes) { - wiimotes = wiiuse_init(nbPossibleWiimotes); - nbMaxWiimotes = nbPossibleWiimotes; + wiimotes = wiiuse_init(nbPossibleWiimotes); + nbMaxWiimotes = nbPossibleWiimotes; } /** @@ -92,7 +92,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_init */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection (JNIEnv *env, jobject obj, jint id) { - wiiuse_disconnect(wiimotes[id]); + wiiuse_disconnect(wiimotes[id]); } /** @@ -104,7 +104,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection */ JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_getUnId (JNIEnv *env, jobject obj, jint index) { - return wiimotes[index]->unid; + return wiimotes[index]->unid; } /** @@ -112,7 +112,7 @@ JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_getUnId */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_cleanUp (JNIEnv *env, jobject obj) { - wiiuse_cleanup(wiimotes, nbMaxWiimotes); + wiiuse_cleanup(wiimotes, nbMaxWiimotes); } /** @@ -121,7 +121,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_cleanUp */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble (JNIEnv *env, jobject obj, jint id) { - wiiuse_rumble(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1); + wiiuse_rumble(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1); } /** @@ -130,7 +130,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble (JNIEnv *env, jobject obj, jint id) { - wiiuse_rumble(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0); + wiiuse_rumble(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0); } /** @@ -139,7 +139,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking (JNIEnv *env, jobject obj, jint id) { - wiiuse_set_ir(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1); + wiiuse_set_ir(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1); } /** @@ -148,7 +148,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking (JNIEnv *env, jobject obj, jint id) { - wiiuse_set_ir(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0); + wiiuse_set_ir(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0); } /** @@ -157,7 +157,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing (JNIEnv *env, jobject obj, jint id) { - wiiuse_motion_sensing(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1); + wiiuse_motion_sensing(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1); } /** @@ -166,7 +166,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing (JNIEnv *env, jobject obj, jint id) { - wiiuse_motion_sensing(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0); + wiiuse_motion_sensing(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0); } /** @@ -179,14 +179,14 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds (JNIEnv *env, jobject obj, jint id, jboolean led1, jboolean led2, jboolean led3, jboolean led4) { - int leds = 0; + int leds = 0; - if (led1) leds |= WIIMOTE_LED_1; - if (led2) leds |= WIIMOTE_LED_2; - if (led3) leds |= WIIMOTE_LED_3; - if (led4) leds |= WIIMOTE_LED_4; + if (led1) leds |= WIIMOTE_LED_1; + if (led2) leds |= WIIMOTE_LED_2; + if (led3) leds |= WIIMOTE_LED_3; + if (led4) leds |= WIIMOTE_LED_4; - wiiuse_set_leds(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), leds); + wiiuse_set_leds(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), leds); } /** @@ -196,7 +196,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold (JNIEnv *env, jobject obj, jint id, jfloat thresh) { - wiiuse_set_orient_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), thresh); + wiiuse_set_orient_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), thresh); } /** @@ -206,7 +206,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold (JNIEnv *env, jobject obj, jint id, jint val) { - wiiuse_set_accel_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val); + wiiuse_set_accel_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val); } /** @@ -216,7 +216,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing (JNIEnv *env, jobject obj, jint id, jfloat val) { - wiiuse_set_smooth_alpha(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val); + wiiuse_set_smooth_alpha(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val); } /** @@ -225,7 +225,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_reSync (JNIEnv *env, jobject obj, jint id) { - wiiuse_resync(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); + wiiuse_resync(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); } /** @@ -235,7 +235,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_reSync */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing (JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_SMOOTHING, 0); + wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_SMOOTHING, 0); } /** @@ -244,7 +244,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing (JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0, WIIUSE_SMOOTHING); + wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0, WIIUSE_SMOOTHING); } /** @@ -254,7 +254,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous (JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_CONTINUOUS, 0); + wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_CONTINUOUS, 0); } /** @@ -264,7 +264,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous (JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0, WIIUSE_CONTINUOUS); + wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0, WIIUSE_CONTINUOUS); } /** @@ -273,7 +273,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43 (JNIEnv *env, jobject obj, jint id) { - wiiuse_set_aspect_ratio(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_ASPECT_4_3); + wiiuse_set_aspect_ratio(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_ASPECT_4_3); } /** @@ -282,7 +282,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43 */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169 (JNIEnv *env, jobject obj, jint id) { - wiiuse_set_aspect_ratio(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_ASPECT_4_3); + wiiuse_set_aspect_ratio(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_ASPECT_4_3); } /** @@ -291,7 +291,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169 */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen (JNIEnv *env, jobject obj, jint id) { - wiiuse_set_ir_position(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_IR_ABOVE); + wiiuse_set_ir_position(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_IR_ABOVE); } /** @@ -300,7 +300,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen (JNIEnv *env, jobject obj, jint id) { - wiiuse_set_ir_position(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_IR_BELOW); + wiiuse_set_ir_position(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_IR_BELOW); } /** @@ -313,7 +313,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution (JNIEnv *env, jobject obj, jint id, jint x, jint y) { - wiiuse_set_ir_vres(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), x, y); + wiiuse_set_ir_vres(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), x, y); } /** @@ -323,7 +323,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus (JNIEnv *env, jobject obj, jint id) { - wiiuse_status(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); + wiiuse_status(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); } /** @@ -339,7 +339,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setTimeout (JNIEnv *env, jobject obj, jint id, jshort normalTimeout, jshort expansionTimeout) { - wiiuse_set_timeout(wiimotes, nbMaxWiimotes, normalTimeout, expansionTimeout); + wiiuse_set_timeout(wiimotes, nbMaxWiimotes, normalTimeout, expansionTimeout); } /** @@ -354,7 +354,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setTimeout */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setIrSensitivity (JNIEnv *env, jobject obj, jint id, jint level) { - wiiuse_set_ir_sensitivity(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), level); + wiiuse_set_ir_sensitivity(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), level); } /** @@ -364,7 +364,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setIrSensitivity */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold (JNIEnv *env, jobject obj, jint id, jfloat thresh) { - wiiuse_set_nunchuk_orient_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), thresh); + wiiuse_set_nunchuk_orient_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), thresh); } /** @@ -374,7 +374,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold (JNIEnv *env, jobject obj, jint id, jint val) { - wiiuse_set_nunchuk_accel_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val); + wiiuse_set_nunchuk_accel_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val); } /** @@ -386,13 +386,13 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_windowsSetBluetoothStack (JNIEnv *env, jobject obj, jint bluetoothStackType) { - if (bluetoothStackType == 0) { - wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_UNKNOWN); - } else if (bluetoothStackType == 1) { - wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_MS); - } else if (bluetoothStackType == 2) { - wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_BLUESOLEIL); - } + if (bluetoothStackType == 0) { + wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_UNKNOWN); + } else if (bluetoothStackType == 1) { + wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_MS); + } else if (bluetoothStackType == 2) { + wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_BLUESOLEIL); + } } /** @@ -402,261 +402,261 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_windowsSetBluetoothStack JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll (JNIEnv *env, jobject obj, jobject gath) { - /* Variables Declarations */ - int i; - short leds = 0; - jclass cls = (*env)->GetObjectClass(env, gath); - jmethodID mid; + /* Variables Declarations */ + int i; + short leds = 0; + jclass cls = (*env)->GetObjectClass(env, gath); + jmethodID mid; - if (wiiuse_poll(wiimotes, nbMaxWiimotes)) { - /* - * This happens if something happened on any wiimote. - * So go through each one and check if anything happened. - */ - for (i=0; i < nbMaxWiimotes; ++i) { - switch (wiimotes[i]->event) { - case WIIUSE_EVENT: - /* a generic event occured */ - mid = (*env)->GetMethodID(env, cls, "prepareWiiMoteEvent", "(ISSS)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid, wiimotes[i]->btns, - wiimotes[i]->btns_released, wiimotes[i]->btns_held); - /* - * If IR tracking is enabled then print the coordinates - * on the virtual screen that the wiimote is pointing to. - * - * Also make sure that we see at least 1 dot. - */ - if (WIIUSE_USING_IR(wiimotes[i])) { - int a; - WIIUSE_GET_IR_SENSITIVITY_CORRECTED(wiimotes[i], &a); + if (wiiuse_poll(wiimotes, nbMaxWiimotes)) { + /* + * This happens if something happened on any wiimote. + * So go through each one and check if anything happened. + */ + for (i=0; i < nbMaxWiimotes; ++i) { + switch (wiimotes[i]->event) { + case WIIUSE_EVENT: + /* a generic event occured */ + mid = (*env)->GetMethodID(env, cls, "prepareWiiMoteEvent", "(ISSS)V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid, wiimotes[i]->btns, + wiimotes[i]->btns_released, wiimotes[i]->btns_held); + /* + * If IR tracking is enabled then print the coordinates + * on the virtual screen that the wiimote is pointing to. + * + * Also make sure that we see at least 1 dot. + */ + if (WIIUSE_USING_IR(wiimotes[i])) { + int a; + WIIUSE_GET_IR_SENSITIVITY_CORRECTED(wiimotes[i], &a); - mid = (*env)->GetMethodID(env, cls, "prepareIRevent", - "(IIFIIIIIISSSF)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, - wiimotes[i]->ir.x, wiimotes[i]->ir.y, wiimotes[i]->ir.z, - wiimotes[i]->ir.ax, wiimotes[i]->ir.ay, - wiimotes[i]->ir.vres[0], wiimotes[i]->ir.vres[1], - wiimotes[i]->ir.offset[0], wiimotes[i]->ir.offset[1], - wiimotes[i]->ir.pos, wiimotes[i]->ir.aspect, - a , wiimotes[i]->ir.distance); + mid = (*env)->GetMethodID(env, cls, "prepareIRevent", + "(IIFIIIIIISSSF)V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid, + wiimotes[i]->ir.x, wiimotes[i]->ir.y, wiimotes[i]->ir.z, + wiimotes[i]->ir.ax, wiimotes[i]->ir.ay, + wiimotes[i]->ir.vres[0], wiimotes[i]->ir.vres[1], + wiimotes[i]->ir.offset[0], wiimotes[i]->ir.offset[1], + wiimotes[i]->ir.pos, wiimotes[i]->ir.aspect, + a , wiimotes[i]->ir.distance); - mid = (*env)->GetMethodID(env, cls, "addIRPointToPreparedWiiMoteEvent", - "(IISSS)V"); - if (mid == 0) { - return; - } - /* go through each of the 4 possible IR sources */ - for (a=0; a < 4; a++) { - /* check if the source is visible */ - if (wiimotes[i]->ir.dot[a].visible) { - (*env)->CallVoidMethod(env, gath, mid, - wiimotes[i]->ir.dot[a].x, wiimotes[i]->ir.dot[a].y, - wiimotes[i]->ir.dot[a].rx, wiimotes[i]->ir.dot[a].ry, - wiimotes[i]->ir.dot[a].size); - } - } - } + mid = (*env)->GetMethodID(env, cls, "addIRPointToPreparedWiiMoteEvent", + "(IISSS)V"); + if (mid == 0) { + return; + } + /* go through each of the 4 possible IR sources */ + for (a=0; a < 4; a++) { + /* check if the source is visible */ + if (wiimotes[i]->ir.dot[a].visible) { + (*env)->CallVoidMethod(env, gath, mid, + wiimotes[i]->ir.dot[a].x, wiimotes[i]->ir.dot[a].y, + wiimotes[i]->ir.dot[a].rx, wiimotes[i]->ir.dot[a].ry, + wiimotes[i]->ir.dot[a].size); + } + } + } - /* Motion Sensing */ - if (WIIUSE_USING_ACC(wiimotes[i])) { - /* set orientation and gravity force */ - mid = (*env)->GetMethodID(env, cls, - "addMotionSensingValues", "(FIZFFFFFFFFFSSS)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, - wiimotes[i]->orient_threshold, wiimotes[i]->accel_threshold, - WIIMOTE_IS_FLAG_SET(wiimotes[i],WIIUSE_SMOOTHING), wiimotes[i]->accel_calib.st_alpha, - wiimotes[i]->orient.roll, wiimotes[i]->orient.pitch, wiimotes[i]->orient.yaw, - wiimotes[i]->orient.a_roll, wiimotes[i]->orient.a_pitch, - wiimotes[i]->gforce.x, wiimotes[i]->gforce.y, wiimotes[i]->gforce.z, - wiimotes[i]->accel.x, wiimotes[i]->accel.y, wiimotes[i]->accel.z); - } + /* Motion Sensing */ + if (WIIUSE_USING_ACC(wiimotes[i])) { + /* set orientation and gravity force */ + mid = (*env)->GetMethodID(env, cls, + "addMotionSensingValues", "(FIZFFFFFFFFFSSS)V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid, + wiimotes[i]->orient_threshold, wiimotes[i]->accel_threshold, + WIIMOTE_IS_FLAG_SET(wiimotes[i],WIIUSE_SMOOTHING), wiimotes[i]->accel_calib.st_alpha, + wiimotes[i]->orient.roll, wiimotes[i]->orient.pitch, wiimotes[i]->orient.yaw, + wiimotes[i]->orient.a_roll, wiimotes[i]->orient.a_pitch, + wiimotes[i]->gforce.x, wiimotes[i]->gforce.y, wiimotes[i]->gforce.z, + wiimotes[i]->accel.x, wiimotes[i]->accel.y, wiimotes[i]->accel.z); + } - /* Expansions support support*/ - if (WIIUSE_USING_EXP(wiimotes[i])) { - /* Nunchuk support */ - if (wiimotes[i]->exp.type == EXP_NUNCHUK) { - /* put nunchuk values in wiimote generic event */ - mid = (*env)->GetMethodID(env, cls, - "addNunchunkEventToPreparedWiimoteEvent", "(SSSFIZFFFFFFFFFSSSFFSSSSSS)V"); - if (mid == 0) { - return; - } - struct nunchuk_t* nc = (nunchuk_t*)&wiimotes[i]->exp.nunchuk; + /* Expansions support support*/ + if (WIIUSE_USING_EXP(wiimotes[i])) { + /* Nunchuk support */ + if (wiimotes[i]->exp.type == EXP_NUNCHUK) { + /* put nunchuk values in wiimote generic event */ + mid = (*env)->GetMethodID(env, cls, + "addNunchunkEventToPreparedWiimoteEvent", "(SSSFIZFFFFFFFFFSSSFFSSSSSS)V"); + if (mid == 0) { + return; + } + struct nunchuk_t* nc = (nunchuk_t*)&wiimotes[i]->exp.nunchuk; - (*env)->CallVoidMethod(env, gath, mid, - /* buttons */ - nc->btns,nc->btns_released,nc->btns_held, - /* motion sensing */ - nc->orient_threshold,nc->accel_threshold, - WIIMOTE_IS_FLAG_SET(wiimotes[i],WIIUSE_SMOOTHING),nc->accel_calib.st_alpha, - nc->orient.roll, nc->orient.pitch, nc->orient.yaw, - nc->orient.a_roll, nc->orient.a_pitch, - nc->gforce.x, nc->gforce.y, nc->gforce.z, - nc->accel.x, nc->accel.y, nc->accel.z, - /* joystick */ - nc->js.ang,nc->js.mag, - nc->js.max.x,nc->js.max.y, - nc->js.min.x,nc->js.min.y, - nc->js.center.x,nc->js.center.y); - } else if (wiimotes[i]->exp.type == EXP_GUITAR_HERO_3) { - /* put guitar hero values in wiimote generic event */ - mid = (*env)->GetMethodID(env, cls, - "addGuitarHeroEventToPreparedWiimoteEvent", "(SSSFFFSSSSSS)V"); - if (mid == 0) { - return; - } - struct guitar_hero_3_t* gh = (guitar_hero_3_t*)&wiimotes[i]->exp.gh3; + (*env)->CallVoidMethod(env, gath, mid, + /* buttons */ + nc->btns,nc->btns_released,nc->btns_held, + /* motion sensing */ + nc->orient_threshold,nc->accel_threshold, + WIIMOTE_IS_FLAG_SET(wiimotes[i],WIIUSE_SMOOTHING),nc->accel_calib.st_alpha, + nc->orient.roll, nc->orient.pitch, nc->orient.yaw, + nc->orient.a_roll, nc->orient.a_pitch, + nc->gforce.x, nc->gforce.y, nc->gforce.z, + nc->accel.x, nc->accel.y, nc->accel.z, + /* joystick */ + nc->js.ang,nc->js.mag, + nc->js.max.x,nc->js.max.y, + nc->js.min.x,nc->js.min.y, + nc->js.center.x,nc->js.center.y); + } else if (wiimotes[i]->exp.type == EXP_GUITAR_HERO_3) { + /* put guitar hero values in wiimote generic event */ + mid = (*env)->GetMethodID(env, cls, + "addGuitarHeroEventToPreparedWiimoteEvent", "(SSSFFFSSSSSS)V"); + if (mid == 0) { + return; + } + struct guitar_hero_3_t* gh = (guitar_hero_3_t*)&wiimotes[i]->exp.gh3; - (*env)->CallVoidMethod(env, gath, mid, - /* buttons */ - gh->btns,gh->btns_released,gh->btns_held, - /* whammy bar */ - gh->whammy_bar, - /* joystick */ - gh->js.ang,gh->js.mag, - gh->js.max.x,gh->js.max.y, - gh->js.min.x,gh->js.min.y, - gh->js.center.x,gh->js.center.y); - }if (wiimotes[i]->exp.type == EXP_CLASSIC) { - /* put classic controller values in wiimote generic event */ - mid = (*env)->GetMethodID(env, cls, - "addClassicControllerEventToPreparedWiimoteEvent", "(SSSFFFFSSSSSSFFSSSSSS)V"); - if (mid == 0) { - return; - } - struct classic_ctrl_t* cl = (classic_ctrl_t*)&wiimotes[i]->exp.classic; + (*env)->CallVoidMethod(env, gath, mid, + /* buttons */ + gh->btns,gh->btns_released,gh->btns_held, + /* whammy bar */ + gh->whammy_bar, + /* joystick */ + gh->js.ang,gh->js.mag, + gh->js.max.x,gh->js.max.y, + gh->js.min.x,gh->js.min.y, + gh->js.center.x,gh->js.center.y); + }if (wiimotes[i]->exp.type == EXP_CLASSIC) { + /* put classic controller values in wiimote generic event */ + mid = (*env)->GetMethodID(env, cls, + "addClassicControllerEventToPreparedWiimoteEvent", "(SSSFFFFSSSSSSFFSSSSSS)V"); + if (mid == 0) { + return; + } + struct classic_ctrl_t* cl = (classic_ctrl_t*)&wiimotes[i]->exp.classic; - (*env)->CallVoidMethod(env, gath, mid, - /* buttons */ - cl->btns,cl->btns_released,cl->btns_held, - /* shoulder buttons */ - cl->r_shoulder,cl->l_shoulder, - /* joystick left*/ - cl->ljs.ang,cl->ljs.mag, - cl->ljs.max.x,cl->ljs.max.y, - cl->ljs.min.x,cl->ljs.min.y, - cl->ljs.center.x,cl->ljs.center.y, - /* joystick right */ - cl->rjs.ang,cl->rjs.mag, - cl->rjs.max.x,cl->rjs.max.y, - cl->rjs.min.x,cl->rjs.min.y, - cl->rjs.center.x,cl->rjs.center.y); - } - } + (*env)->CallVoidMethod(env, gath, mid, + /* buttons */ + cl->btns,cl->btns_released,cl->btns_held, + /* shoulder buttons */ + cl->r_shoulder,cl->l_shoulder, + /* joystick left*/ + cl->ljs.ang,cl->ljs.mag, + cl->ljs.max.x,cl->ljs.max.y, + cl->ljs.min.x,cl->ljs.min.y, + cl->ljs.center.x,cl->ljs.center.y, + /* joystick right */ + cl->rjs.ang,cl->rjs.mag, + cl->rjs.max.x,cl->rjs.max.y, + cl->rjs.min.x,cl->rjs.min.y, + cl->rjs.center.x,cl->rjs.center.y); + } + } - /* add generic event to java object used to gather events in c environment */ - mid = (*env)->GetMethodID(env, cls, "addWiimoteEvent", - "()V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid); - break; + /* add generic event to java object used to gather events in c environment */ + mid = (*env)->GetMethodID(env, cls, "addWiimoteEvent", + "()V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid); + break; - case WIIUSE_DISCONNECT: - /* the wiimote disconnected */ - mid = (*env)->GetMethodID(env, cls, "addDisconnectionEvent", "(I)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); - break; + case WIIUSE_DISCONNECT: + /* the wiimote disconnected */ + mid = (*env)->GetMethodID(env, cls, "addDisconnectionEvent", "(I)V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); + break; - case WIIUSE_UNEXPECTED_DISCONNECT: - /* the wimote disconnected */ - mid = (*env)->GetMethodID(env, cls, "addDisconnectionEvent", "(I)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); - break; + case WIIUSE_UNEXPECTED_DISCONNECT: + /* the wimote disconnected */ + mid = (*env)->GetMethodID(env, cls, "addDisconnectionEvent", "(I)V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); + break; - case WIIUSE_NUNCHUK_INSERTED: - /* the nunchuk was just connected */ - mid = (*env)->GetMethodID(env, cls, "addNunchukInsertedEvent", "(I)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); - break; + case WIIUSE_NUNCHUK_INSERTED: + /* the nunchuk was just connected */ + mid = (*env)->GetMethodID(env, cls, "addNunchukInsertedEvent", "(I)V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); + break; - case WIIUSE_NUNCHUK_REMOVED: - /* the nunchuk disconnected */ - mid = (*env)->GetMethodID(env, cls, "addNunchukRemovedEvent", "(I)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); - break; + case WIIUSE_NUNCHUK_REMOVED: + /* the nunchuk disconnected */ + mid = (*env)->GetMethodID(env, cls, "addNunchukRemovedEvent", "(I)V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); + break; - case WIIUSE_GUITAR_HERO_3_CTRL_INSERTED: - /* the guitar hero was just connected */ - mid = (*env)->GetMethodID(env, cls, "addGuitarHeroInsertedEvent", "(I)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); - break; + case WIIUSE_GUITAR_HERO_3_CTRL_INSERTED: + /* the guitar hero was just connected */ + mid = (*env)->GetMethodID(env, cls, "addGuitarHeroInsertedEvent", "(I)V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); + break; - case WIIUSE_GUITAR_HERO_3_CTRL_REMOVED: - /* the guitar hero disconnected */ - mid = (*env)->GetMethodID(env, cls, "addGuitarHeroRemovedEvent", "(I)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); - break; + case WIIUSE_GUITAR_HERO_3_CTRL_REMOVED: + /* the guitar hero disconnected */ + mid = (*env)->GetMethodID(env, cls, "addGuitarHeroRemovedEvent", "(I)V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); + break; - case WIIUSE_CLASSIC_CTRL_INSERTED: - /* the classic controller was just connected */ - mid = (*env)->GetMethodID(env, cls, "addClassicControllerInsertedEvent", "(I)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); - break; + case WIIUSE_CLASSIC_CTRL_INSERTED: + /* the classic controller was just connected */ + mid = (*env)->GetMethodID(env, cls, "addClassicControllerInsertedEvent", "(I)V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); + break; - case WIIUSE_CLASSIC_CTRL_REMOVED: - /* the classic controller disconnected */ - mid = (*env)->GetMethodID(env, cls, "addClassicControllerRemovedEvent", "(I)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); - break; + case WIIUSE_CLASSIC_CTRL_REMOVED: + /* the classic controller disconnected */ + mid = (*env)->GetMethodID(env, cls, "addClassicControllerRemovedEvent", "(I)V"); + if (mid == 0) { + return; + } + (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); + break; - case WIIUSE_STATUS: - /* a status event occured */ - mid = (*env)->GetMethodID(env, cls, "addStatusEvent", "(IZFSZIZZZZ)V"); - if (mid == 0) { - return; - } - /* LEDS */ - if (WIIUSE_IS_LED_SET(wiimotes[i], 1)) leds += 1; - if (WIIUSE_IS_LED_SET(wiimotes[i], 2)) leds += 2; - if (WIIUSE_IS_LED_SET(wiimotes[i], 3)) leds += 4; - if (WIIUSE_IS_LED_SET(wiimotes[i], 4)) leds += 8; + case WIIUSE_STATUS: + /* a status event occured */ + mid = (*env)->GetMethodID(env, cls, "addStatusEvent", "(IZFSZIZZZZ)V"); + if (mid == 0) { + return; + } + /* LEDS */ + if (WIIUSE_IS_LED_SET(wiimotes[i], 1)) leds += 1; + if (WIIUSE_IS_LED_SET(wiimotes[i], 2)) leds += 2; + if (WIIUSE_IS_LED_SET(wiimotes[i], 3)) leds += 4; + if (WIIUSE_IS_LED_SET(wiimotes[i], 4)) leds += 8; - (*env)->CallVoidMethod(env, gath, mid, - wiimotes[i]->unid, WIIMOTE_IS_SET(wiimotes[i], WIIMOTE_STATE_CONNECTED), - wiimotes[i]->battery_level, leds, WIIUSE_USING_SPEAKER(wiimotes[i]), - wiimotes[i]->exp.type,WIIMOTE_IS_SET(wiimotes[i], WIIMOTE_STATE_RUMBLE), - WIIMOTE_IS_FLAG_SET(wiimotes[i],WIIUSE_CONTINUOUS), - WIIUSE_USING_IR(wiimotes[i]),WIIUSE_USING_ACC(wiimotes[i])); - break; + (*env)->CallVoidMethod(env, gath, mid, + wiimotes[i]->unid, WIIMOTE_IS_SET(wiimotes[i], WIIMOTE_STATE_CONNECTED), + wiimotes[i]->battery_level, leds, WIIUSE_USING_SPEAKER(wiimotes[i]), + wiimotes[i]->exp.type,WIIMOTE_IS_SET(wiimotes[i], WIIMOTE_STATE_RUMBLE), + WIIMOTE_IS_FLAG_SET(wiimotes[i],WIIUSE_CONTINUOUS), + WIIUSE_USING_IR(wiimotes[i]),WIIUSE_USING_ACC(wiimotes[i])); + break; - default: - break; - } - } - } + default: + break; + } + } + } } diff --git a/src/main/java/wiiusej/WiiUseApi.java b/src/main/java/wiiusej/WiiUseApi.java index 57d3518..b999feb 100644 --- a/src/main/java/wiiusej/WiiUseApi.java +++ b/src/main/java/wiiusej/WiiUseApi.java @@ -27,328 +27,328 @@ import wiiusej.wiiusejevents.utils.EventsGatherer; */ public class WiiUseApi { - static { - Native.load("com.github.boukefalos", "libwiiuse"); - Native.load("com.github.boukefalos", "jlibwiiuse"); - } + static { + Native.load("com.github.boukefalos", "libwiiuse"); + Native.load("com.github.boukefalos", "jlibwiiuse"); + } - private static WiiUseApi instance = new WiiUseApi(); + private static WiiUseApi instance = new WiiUseApi(); - /** - * Get the only instance of WiiUseApi. - * - * @return the only instace of WiiUseApi. - */ - protected static WiiUseApi getInstance() { - return instance; - } + /** + * Get the only instance of WiiUseApi. + * + * @return the only instace of WiiUseApi. + */ + protected static WiiUseApi getInstance() { + return instance; + } - /** - * Connect to a wiimote or wiimotes once an address is known. - * - * @param nbWiimotes - * The number of wiimotes. - * @return The number of wiimotes that successfully connected. - */ - synchronized native int connect(int nbWiimotes); + /** + * Connect to a wiimote or wiimotes once an address is known. + * + * @param nbWiimotes + * The number of wiimotes. + * @return The number of wiimotes that successfully connected. + */ + synchronized native int connect(int nbWiimotes); - /** - * Find a wiimote or wiimotes. - * - * @param nbMaxWiimotes - * The number of wiimotes. - * @param timeout - * The number of seconds before the search times out. - * @return The number of wiimotes found. - */ - synchronized native int find(int nbMaxWiimotes, int timeout); + /** + * Find a wiimote or wiimotes. + * + * @param nbMaxWiimotes + * The number of wiimotes. + * @param timeout + * The number of seconds before the search times out. + * @return The number of wiimotes found. + */ + synchronized native int find(int nbMaxWiimotes, int timeout); - /** - * Initialize an array of wiimote structures (for the C side of the - * library). - * - * @param nbPossibleWiimotes - * size of the array. - */ - synchronized native void init(int nbPossibleWiimotes); + /** + * Initialize an array of wiimote structures (for the C side of the + * library). + * + * @param nbPossibleWiimotes + * size of the array. + */ + synchronized native void init(int nbPossibleWiimotes); - /** - * Close connection to the wiimote with the given id. - * - */ - synchronized native void closeConnection(int id); + /** + * Close connection to the wiimote with the given id. + * + */ + synchronized native void closeConnection(int id); - /** - * Get unique id of a wiimote in the wiimotes array. Please make sure you - * call an existing index with a wiimote initialized at this index, other - * wise you'll get a wrong value. - * - * @param index - * index of the wiimote in the wiimotes array. - * @return the unid of the wiimote, or a wrong value if the index was false. - * - */ - synchronized native int getUnId(int index); + /** + * Get unique id of a wiimote in the wiimotes array. Please make sure you + * call an existing index with a wiimote initialized at this index, other + * wise you'll get a wrong value. + * + * @param index + * index of the wiimote in the wiimotes array. + * @return the unid of the wiimote, or a wrong value if the index was false. + * + */ + synchronized native int getUnId(int index); - /** - * CleanUp Wiiuse API. - */ - synchronized native void cleanUp(); + /** + * CleanUp Wiiuse API. + */ + synchronized native void cleanUp(); - /** - * Activate rumble on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - synchronized native void activateRumble(int id); + /** + * Activate rumble on the wiimote with the given id. + * + * @param id + * the id of the wiimote. + */ + synchronized native void activateRumble(int id); - /** - * Deactivate rumble on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - synchronized native void deactivateRumble(int id); + /** + * Deactivate rumble on the wiimote with the given id. + * + * @param id + * the id of the wiimote. + */ + synchronized native void deactivateRumble(int id); - /** - * Activate IR Tracking on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - synchronized native void activateIRTracking(int id); + /** + * Activate IR Tracking on the wiimote with the given id. + * + * @param id + * the id of the wiimote. + */ + synchronized native void activateIRTracking(int id); - /** - * Deactivate IR Tracking on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - synchronized native void deactivateIRTracking(int id); + /** + * Deactivate IR Tracking on the wiimote with the given id. + * + * @param id + * the id of the wiimote. + */ + synchronized native void deactivateIRTracking(int id); - /** - * Activate motion sensing on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - synchronized native void activateMotionSensing(int id); + /** + * Activate motion sensing on the wiimote with the given id. + * + * @param id + * the id of the wiimote. + */ + synchronized native void activateMotionSensing(int id); - /** - * Deactivate motion sensing on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - synchronized native void deactivateMotionSensing(int id); + /** + * Deactivate motion sensing on the wiimote with the given id. + * + * @param id + * the id of the wiimote. + */ + synchronized native void deactivateMotionSensing(int id); - /** - * Set wiimote leds status. - * - * @param id - * the id of the wiimote concerned. - * @param led1 - * status of led1: True=ON, False=OFF. - * @param led2 - * status of led2: True=ON, False=OFF. - * @param led3 - * status of led3: True=ON, False=OFF. - * @param led4 - * status of led4: True=ON, False=OFF. - */ - synchronized native void setLeds(int id, boolean led1, boolean led2, - boolean led3, boolean led4); + /** + * Set wiimote leds status. + * + * @param id + * the id of the wiimote concerned. + * @param led1 + * status of led1: True=ON, False=OFF. + * @param led2 + * status of led2: True=ON, False=OFF. + * @param led3 + * status of led3: True=ON, False=OFF. + * @param led4 + * status of led4: True=ON, False=OFF. + */ + synchronized native void setLeds(int id, boolean led1, boolean led2, + boolean led3, boolean led4); - /** - * Set how many degrees an angle must change to generate an event. - * - * @param id - * id of the wiimote concerned. - * @param angle - * minimum angle detected by an event. - */ - synchronized native void setOrientThreshold(int id, float angle); + /** + * Set how many degrees an angle must change to generate an event. + * + * @param id + * id of the wiimote concerned. + * @param angle + * minimum angle detected by an event. + */ + synchronized native void setOrientThreshold(int id, float angle); - /** - * Set how much acceleration must change to generate an event. - * - * @param id - * id of the wiimote concerned. - * @param value - * minimum value detected by an event. - */ - synchronized native void setAccelThreshold(int id, int value); + /** + * Set how much acceleration must change to generate an event. + * + * @param id + * id of the wiimote concerned. + * @param value + * minimum value detected by an event. + */ + synchronized native void setAccelThreshold(int id, int value); - /** - * Set alpha smoothing parameter for the given id. - * - * @param id - * id of the wiimote concerned. - * @param value - * alpha smoothing value. - */ - synchronized native void setAlphaSmoothing(int id, float value); + /** + * Set alpha smoothing parameter for the given id. + * + * @param id + * id of the wiimote concerned. + * @param value + * alpha smoothing value. + */ + synchronized native void setAlphaSmoothing(int id, float value); - /** - * Try to resync with the wiimote by starting a new handshake. - * - * @param id - * id of the wiimote concerned. - */ - synchronized native void reSync(int id); + /** + * Try to resync with the wiimote by starting a new handshake. + * + * @param id + * id of the wiimote concerned. + */ + synchronized native void reSync(int id); - /** - * Make the the accelerometers give smoother results. This is set by - * default. - * - * @param id - * the id of the wiimote concerned. - */ - synchronized native void activateSmoothing(int id); + /** + * Make the the accelerometers give smoother results. This is set by + * default. + * + * @param id + * the id of the wiimote concerned. + */ + synchronized native void activateSmoothing(int id); - /** - * Make the the accelerometers give raw results. - * - * @param id - * the id of the wiimote concerned. - */ - synchronized native void deactivateSmoothing(int id); + /** + * Make the the accelerometers give raw results. + * + * @param id + * the id of the wiimote concerned. + */ + synchronized native void deactivateSmoothing(int id); - /** - * Make the wiimote generate an event each time we poll. Not set by default. - * - * @param id - * the id of the wiimote concerned. - */ - synchronized native void activateContinuous(int id); + /** + * Make the wiimote generate an event each time we poll. Not set by default. + * + * @param id + * the id of the wiimote concerned. + */ + synchronized native void activateContinuous(int id); - /** - * Make the wiimote generate an event only when there is one. - * - * @param id - * the id of the wiimote concerned. - */ - synchronized native void deactivateContinuous(int id); + /** + * Make the wiimote generate an event only when there is one. + * + * @param id + * the id of the wiimote concerned. + */ + synchronized native void deactivateContinuous(int id); - /** - * Notify wiiuse that your screen has an aspect ratio of 4/3. - * - * @param id - * the id of the wiimote of which we want the status. - */ - synchronized native void setScreenRatio43(int id); + /** + * Notify wiiuse that your screen has an aspect ratio of 4/3. + * + * @param id + * the id of the wiimote of which we want the status. + */ + synchronized native void setScreenRatio43(int id); - /** - * Notify wiiuse that your screen has an aspect ratio of 16/9. - * - * @param id - * the id of the wiimote of which we want the status. - */ - synchronized native void setScreenRatio169(int id); + /** + * Notify wiiuse that your screen has an aspect ratio of 16/9. + * + * @param id + * the id of the wiimote of which we want the status. + */ + synchronized native void setScreenRatio169(int id); - /** - * Notify wiiuse that the sensor bar is above your screen. - * - * @param id - * the id of the wiimote of which we want the status. - */ - synchronized native void setSensorBarAboveScreen(int id); + /** + * Notify wiiuse that the sensor bar is above your screen. + * + * @param id + * the id of the wiimote of which we want the status. + */ + synchronized native void setSensorBarAboveScreen(int id); - /** - * Notify wiiuse that the sensor bar is below your screen. - * - * @param id - * the id of the wiimote of which we want the status. - */ - synchronized native void setSensorBarBelowScreen(int id); + /** + * Notify wiiuse that the sensor bar is below your screen. + * + * @param id + * the id of the wiimote of which we want the status. + */ + synchronized native void setSensorBarBelowScreen(int id); - /** - * Set virtual screen resolution. It is used to automatically compute the - * position of a cursor on this virtual screen using the sensor bar. These - * results come in the IREvent. - * - * @param id - * the id of the wiimote of which we want the status. - * @param x - * x resolution. - * @param y - * y resolution. - */ - synchronized native void setVirtualScreenResolution(int id, int x, int y); + /** + * Set virtual screen resolution. It is used to automatically compute the + * position of a cursor on this virtual screen using the sensor bar. These + * results come in the IREvent. + * + * @param id + * the id of the wiimote of which we want the status. + * @param x + * x resolution. + * @param y + * y resolution. + */ + synchronized native void setVirtualScreenResolution(int id, int x, int y); - /** - * Get status and values from the wiimotes and send it through callbacks. - * - * @param id - * the id of the wiimote of which we want the status. - */ - synchronized native void getStatus(int id); + /** + * Get status and values from the wiimotes and send it through callbacks. + * + * @param id + * the id of the wiimote of which we want the status. + */ + synchronized native void getStatus(int id); - /** - * Set the normal and expansion handshake timeouts. - * - * @param id - * the id of the wiimote concerned. - * @param normalTimeout - * The timeout in milliseconds for a normal read. - * @param expansionTimeout - * The timeout in millisecondsd to wait for an expansion - * handshake. - */ - synchronized native void setTimeout(int id, short normalTimeout, - short expansionTimeout); + /** + * Set the normal and expansion handshake timeouts. + * + * @param id + * the id of the wiimote concerned. + * @param normalTimeout + * The timeout in milliseconds for a normal read. + * @param expansionTimeout + * The timeout in millisecondsd to wait for an expansion + * handshake. + */ + synchronized native void setTimeout(int id, short normalTimeout, + short expansionTimeout); - /** - * Set the IR sensitivity. - * - * @param id - * the id of the wiimote concerned. - * @param level - * 1-5, same as Wii system sensitivity setting. If the level is < - * 1, then level will be set to 1. If the level is > 5, then - * level will be set to 5. - */ - synchronized native void setIrSensitivity(int id, int level); + /** + * Set the IR sensitivity. + * + * @param id + * the id of the wiimote concerned. + * @param level + * 1-5, same as Wii system sensitivity setting. If the level is < + * 1, then level will be set to 1. If the level is > 5, then + * level will be set to 5. + */ + synchronized native void setIrSensitivity(int id, int level); - /** - * Set how many degrees an angle must change to generate an event for the - * nunchuk. - * - * @param id - * id of the wiimote concerned. - * @param angle - * minimum angle detected by an event. - */ - synchronized native void setNunchukOrientationThreshold(int id, float angle); + /** + * Set how many degrees an angle must change to generate an event for the + * nunchuk. + * + * @param id + * id of the wiimote concerned. + * @param angle + * minimum angle detected by an event. + */ + synchronized native void setNunchukOrientationThreshold(int id, float angle); - /** - * Set how much acceleration must change to generate an event for the - * nunchuk. - * - * @param id - * id of the wiimote concerned. - * @param value - * minimum value detected by an event. - */ - synchronized native void setNunchukAccelerationThreshold(int id, int value); + /** + * Set how much acceleration must change to generate an event for the + * nunchuk. + * + * @param id + * id of the wiimote concerned. + * @param value + * minimum value detected by an event. + */ + synchronized native void setNunchukAccelerationThreshold(int id, int value); - /** - * Force the bluetooth stack type.(useful only for windows) - * - * @param bluetoothStackType - * must be WiiUseApi.WIIUSE_STACK_UNKNOWN or - * WiiUseApi.WIIUSE_STACK_MS or - * WiiUseApi.WIIUSE_STACK_BLUESOLEIL. - */ - native void windowsSetBluetoothStack(int bluetoothStackType); + /** + * Force the bluetooth stack type.(useful only for windows) + * + * @param bluetoothStackType + * must be WiiUseApi.WIIUSE_STACK_UNKNOWN or + * WiiUseApi.WIIUSE_STACK_MS or + * WiiUseApi.WIIUSE_STACK_BLUESOLEIL. + */ + native void windowsSetBluetoothStack(int bluetoothStackType); - /** - * Check for new Events and Get it. - * - * @param gath - * the object where we store all the new events. - */ - native void specialPoll(EventsGatherer gath); + /** + * Check for new Events and Get it. + * + * @param gath + * the object where we store all the new events. + */ + native void specialPoll(EventsGatherer gath); } diff --git a/src/main/java/wiiusej/WiiUseApiManager.java b/src/main/java/wiiusej/WiiUseApiManager.java index 4d6d1e4..d8e102c 100644 --- a/src/main/java/wiiusej/WiiUseApiManager.java +++ b/src/main/java/wiiusej/WiiUseApiManager.java @@ -32,633 +32,633 @@ import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent; */ public class WiiUseApiManager extends Thread { - private static WiiUseApiManager instance = new WiiUseApiManager(); + private static WiiUseApiManager instance = new WiiUseApiManager(); - private final EventListenerList listeners = new EventListenerList(); + private final EventListenerList listeners = new EventListenerList(); - private Semaphore semaphore = new Semaphore(0); + private Semaphore semaphore = new Semaphore(0); - private Wiimote[] wiimotes; + private Wiimote[] wiimotes; - private WiiUseApi wiiuse = WiiUseApi.getInstance(); + private WiiUseApi wiiuse = WiiUseApi.getInstance(); - private int connected = -1; + private int connected = -1; - private AtomicBoolean running = new AtomicBoolean(false); + private AtomicBoolean running = new AtomicBoolean(false); - private boolean leave = false; + private boolean leave = false; - public static int WIIUSE_STACK_UNKNOWN = 0; - public static int WIIUSE_STACK_MS = 1; - public static int WIIUSE_STACK_BLUESOLEIL = 2; + public static int WIIUSE_STACK_UNKNOWN = 0; + public static int WIIUSE_STACK_MS = 1; + public static int WIIUSE_STACK_BLUESOLEIL = 2; - public static WiiUseApiManager getInstance() { - return instance; - } + public static WiiUseApiManager getInstance() { + return instance; + } - /** - * Get wiimotes. Load library if necessary. Connect to wiimotes if - * necessary. Start polling if necessary. Return an array with the connected - * wiimotes. - * - * @param nb - * try to connect nb wiimotes. - * @param rumble - * make the connected wiimotes rumble. - * - * @return an array with connected wiimotes or NULL. - */ - public static Wiimote[] getWiimotes(int nb, boolean rumble) { - return getWiimotesPrivate(nb, rumble, false, WIIUSE_STACK_UNKNOWN); - } + /** + * Get wiimotes. Load library if necessary. Connect to wiimotes if + * necessary. Start polling if necessary. Return an array with the connected + * wiimotes. + * + * @param nb + * try to connect nb wiimotes. + * @param rumble + * make the connected wiimotes rumble. + * + * @return an array with connected wiimotes or NULL. + */ + public static Wiimote[] getWiimotes(int nb, boolean rumble) { + return getWiimotesPrivate(nb, rumble, false, WIIUSE_STACK_UNKNOWN); + } - /** - * Get wiimotes. Load library if necessary. Connect to wiimotes if - * necessary. Start polling if necessary. Return an array with the connected - * wiimotes. - * - * @param nb - * try to connect nb wiimotes. - * @param rumble - * make the connected wiimotes rumble.* - * @param stackType - * the stack type : WiiUseApiManager.WIIUSE_STACK_UNKNOWN or - * WiiUseApiManager.WIIUSE_STACK_MS or - * WiiUseApiManager.WIIUSE_STACK_BLUESOLEIL - * - * @return an array with connected wiimotes or NULL. - */ - public static Wiimote[] getWiimotes(int nb, boolean rumble, int stackType) { - return getWiimotesPrivate(nb, rumble, true, stackType); - } + /** + * Get wiimotes. Load library if necessary. Connect to wiimotes if + * necessary. Start polling if necessary. Return an array with the connected + * wiimotes. + * + * @param nb + * try to connect nb wiimotes. + * @param rumble + * make the connected wiimotes rumble.* + * @param stackType + * the stack type : WiiUseApiManager.WIIUSE_STACK_UNKNOWN or + * WiiUseApiManager.WIIUSE_STACK_MS or + * WiiUseApiManager.WIIUSE_STACK_BLUESOLEIL + * + * @return an array with connected wiimotes or NULL. + */ + public static Wiimote[] getWiimotes(int nb, boolean rumble, int stackType) { + return getWiimotesPrivate(nb, rumble, true, stackType); + } - /** - * Get wiimotes. Load library if necessary. Connect to wiimotes if - * necessary. Start polling if necessary. Return an array with the connected - * wiimotes. - * - * @param nb - * try to connect nb wiimotes. - * @param rumble - * make the connected wiimotes rumble.* - * @param forceStackType - * true if we want to force the stack type. - * @param stackType - * the stack type : WiiUseApiManager.WIIUSE_STACK_UNKNOWN or - * WiiUseApiManager.WIIUSE_STACK_MS or - * WiiUseApiManager.WIIUSE_STACK_BLUESOLEIL - * - * @return an array with connected wiimotes or NULL. - */ - private synchronized static Wiimote[] getWiimotesPrivate(int nb, - boolean rumble, boolean forceStackType, int stackType) { - WiiUseApiManager manager = getInstance(); + /** + * Get wiimotes. Load library if necessary. Connect to wiimotes if + * necessary. Start polling if necessary. Return an array with the connected + * wiimotes. + * + * @param nb + * try to connect nb wiimotes. + * @param rumble + * make the connected wiimotes rumble.* + * @param forceStackType + * true if we want to force the stack type. + * @param stackType + * the stack type : WiiUseApiManager.WIIUSE_STACK_UNKNOWN or + * WiiUseApiManager.WIIUSE_STACK_MS or + * WiiUseApiManager.WIIUSE_STACK_BLUESOLEIL + * + * @return an array with connected wiimotes or NULL. + */ + private synchronized static Wiimote[] getWiimotesPrivate(int nb, + boolean rumble, boolean forceStackType, int stackType) { + WiiUseApiManager manager = getInstance(); - if (manager.leave) - return null;// wiiusej definitively stopped + if (manager.leave) + return null;// wiiusej definitively stopped - if (manager.connected <= 0 && !manager.running.get()) { - // connect wiimotes. - int nbWiimotes = manager.connectWiimotes(nb, rumble, - forceStackType, stackType); - manager.wiimotes = new Wiimote[nbWiimotes]; - for (int i = 0; i < nbWiimotes; i++) { - Wiimote wim = new Wiimote(WiiUseApi.getInstance().getUnId(i), - manager); - manager.wiimotes[i] = wim; - manager.addWiiUseApiListener(wim); - } - // Set leds on wiimote - for (Wiimote wiimote : manager.wiimotes) { - int id = wiimote.getId(); - if (id % 4 == 0) { - wiimote.setLeds(true, true, true, true); - } else if (id % 4 == 1) { - wiimote.setLeds(true, false, false, false); - } else if (id % 4 == 2) { - wiimote.setLeds(true, true, false, false); - } else if (id % 4 == 3) { - wiimote.setLeds(true, true, true, false); - } - } - // make the connected wiimotes rumble - if (rumble) { - for (Wiimote wiimote : manager.wiimotes) { - wiimote.activateRumble(); - } - try { - sleep(500); - } catch (InterruptedException e) { - } - for (Wiimote wiimote : manager.wiimotes) { - wiimote.deactivateRumble(); - } - } - } + if (manager.connected <= 0 && !manager.running.get()) { + // connect wiimotes. + int nbWiimotes = manager.connectWiimotes(nb, rumble, + forceStackType, stackType); + manager.wiimotes = new Wiimote[nbWiimotes]; + for (int i = 0; i < nbWiimotes; i++) { + Wiimote wim = new Wiimote(WiiUseApi.getInstance().getUnId(i), + manager); + manager.wiimotes[i] = wim; + manager.addWiiUseApiListener(wim); + } + // Set leds on wiimote + for (Wiimote wiimote : manager.wiimotes) { + int id = wiimote.getId(); + if (id % 4 == 0) { + wiimote.setLeds(true, true, true, true); + } else if (id % 4 == 1) { + wiimote.setLeds(true, false, false, false); + } else if (id % 4 == 2) { + wiimote.setLeds(true, true, false, false); + } else if (id % 4 == 3) { + wiimote.setLeds(true, true, true, false); + } + } + // make the connected wiimotes rumble + if (rumble) { + for (Wiimote wiimote : manager.wiimotes) { + wiimote.activateRumble(); + } + try { + sleep(500); + } catch (InterruptedException e) { + } + for (Wiimote wiimote : manager.wiimotes) { + wiimote.deactivateRumble(); + } + } + } - if (manager.connected == 0) {// no wiimote connected - // return empty array - return new Wiimote[0]; - } + if (manager.connected == 0) {// no wiimote connected + // return empty array + return new Wiimote[0]; + } - if (!manager.isAlive())// start wiiuseJ polling - manager.start(); + if (!manager.isAlive())// start wiiuseJ polling + manager.start(); - manager.semaphore.release(1); + manager.semaphore.release(1); - return manager.wiimotes; - } + return manager.wiimotes; + } - /** - * Connect wiimote and get the number of wiimotes connected. Supposed to be - * used once. - * - * @param nb - * try to connect nb wiimotes - * @param rumble - * make the connected wiimotes rumble - * @param forceStackType - * true if we want to force the stack type. - * @param stackType - * the stack type : WiiUseApiManager.WIIUSE_STACK_UNKNOWN or - * WiiUseApiManager.WIIUSE_STACK_MS or - * WiiUseApiManager.WIIUSE_STACK_BLUESOLEIL - * @return 0 if nothing connected or the number of wiimotes connected. - */ - private int connectWiimotes(int nb, boolean rumble, boolean forceStackType, - int stackType) { - if (connected <= 0) { - int nbWiimotesFound; - wiiuse.init(nb); - // force bluetooth stack type ? - if (forceStackType) - setBlueToothstackType(stackType); - nbWiimotesFound = wiiuse.find(nb, 3); - connected = wiiuse.connect(nbWiimotesFound); - return connected; - } else {// library not loaded, no wiimotes connected - return 0; - } - } + /** + * Connect wiimote and get the number of wiimotes connected. Supposed to be + * used once. + * + * @param nb + * try to connect nb wiimotes + * @param rumble + * make the connected wiimotes rumble + * @param forceStackType + * true if we want to force the stack type. + * @param stackType + * the stack type : WiiUseApiManager.WIIUSE_STACK_UNKNOWN or + * WiiUseApiManager.WIIUSE_STACK_MS or + * WiiUseApiManager.WIIUSE_STACK_BLUESOLEIL + * @return 0 if nothing connected or the number of wiimotes connected. + */ + private int connectWiimotes(int nb, boolean rumble, boolean forceStackType, + int stackType) { + if (connected <= 0) { + int nbWiimotesFound; + wiiuse.init(nb); + // force bluetooth stack type ? + if (forceStackType) + setBlueToothstackType(stackType); + nbWiimotesFound = wiiuse.find(nb, 3); + connected = wiiuse.connect(nbWiimotesFound); + return connected; + } else {// library not loaded, no wiimotes connected + return 0; + } + } - /** - * Ask the thread to close a connection. - * - * @param id - * id of the wiimote to disconnect. - */ - protected void closeConnection(int id) { - int index = 0; - boolean found = false; - while (index < wiimotes.length && !found) { - if (wiimotes[index]!=null && wiimotes[index].getId() == id) {// we have a wiimote with this - // id - // remove the wiimote - removeWiiUseApiListener(wiimotes[index]); - wiimotes[index] = null; - connected--; - if (connected == 0) {// stop this thread if there is - // no more wiimotes connected. - // stop thread - running.set(false); - } - /* Close connection in wiiuse */ - wiiuse.closeConnection(index); - } - index++; - } - } + /** + * Ask the thread to close a connection. + * + * @param id + * id of the wiimote to disconnect. + */ + protected void closeConnection(int id) { + int index = 0; + boolean found = false; + while (index < wiimotes.length && !found) { + if (wiimotes[index]!=null && wiimotes[index].getId() == id) {// we have a wiimote with this + // id + // remove the wiimote + removeWiiUseApiListener(wiimotes[index]); + wiimotes[index] = null; + connected--; + if (connected == 0) {// stop this thread if there is + // no more wiimotes connected. + // stop thread + running.set(false); + } + /* Close connection in wiiuse */ + wiiuse.closeConnection(index); + } + index++; + } + } - /** - * Get the number of wiimotes connected. - * - * @return the number of wiimotes connected. - */ - public static int getNbConnectedWiimotes() { - return getInstance().connected; - } + /** + * Get the number of wiimotes connected. + * + * @return the number of wiimotes connected. + */ + public static int getNbConnectedWiimotes() { + return getInstance().connected; + } - /** - * Stop thread and shutdown wiiuse Api. - */ - public static void shutdown() { - WiiUseApiManager manager = getInstance(); - int pastConnected = manager.connected; - if (manager.connected > 0) { - for (Wiimote wim : manager.wiimotes) { - if (wim != null) - wim.disconnect(); - } - } - manager.running.set(false); - if (pastConnected > 0) { - manager.wiiuse.cleanUp(); - } - } + /** + * Stop thread and shutdown wiiuse Api. + */ + public static void shutdown() { + WiiUseApiManager manager = getInstance(); + int pastConnected = manager.connected; + if (manager.connected > 0) { + for (Wiimote wim : manager.wiimotes) { + if (wim != null) + wim.disconnect(); + } + } + manager.running.set(false); + if (pastConnected > 0) { + manager.wiiuse.cleanUp(); + } + } - /** - * Stop wiiuseJ definitively for this program. It finishes Wiiusej thread - * and shutdown wiiuse API. - */ - public static void definitiveShutdown() { - getInstance().leave = true; - shutdown(); - } + /** + * Stop wiiuseJ definitively for this program. It finishes Wiiusej thread + * and shutdown wiiuse API. + */ + public static void definitiveShutdown() { + getInstance().leave = true; + shutdown(); + } - /** - * Activate the rumble for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - protected void activateRumble(int id) { - wiiuse.activateRumble(id); - } + /** + * Activate the rumble for the wiimote with the given id. + * + * @param id + * id of the wiimote. + */ + protected void activateRumble(int id) { + wiiuse.activateRumble(id); + } - /** - * Deactivate the rumble for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - protected void deactivateRumble(int id) { - wiiuse.deactivateRumble(id); - } + /** + * Deactivate the rumble for the wiimote with the given id. + * + * @param id + * id of the wiimote. + */ + protected void deactivateRumble(int id) { + wiiuse.deactivateRumble(id); + } - /** - * Activate IR Tracking for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - protected void activateIRTRacking(int id) { - wiiuse.activateIRTracking(id); - } + /** + * Activate IR Tracking for the wiimote with the given id. + * + * @param id + * id of the wiimote. + */ + protected void activateIRTRacking(int id) { + wiiuse.activateIRTracking(id); + } - /** - * Deactivate IR Tracking for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - protected void deactivateIRTRacking(int id) { - wiiuse.deactivateIRTracking(id); - } + /** + * Deactivate IR Tracking for the wiimote with the given id. + * + * @param id + * id of the wiimote. + */ + protected void deactivateIRTRacking(int id) { + wiiuse.deactivateIRTracking(id); + } - /** - * Activate motion sensing for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - protected void activateMotionSensing(int id) { - wiiuse.activateMotionSensing(id); - } + /** + * Activate motion sensing for the wiimote with the given id. + * + * @param id + * id of the wiimote. + */ + protected void activateMotionSensing(int id) { + wiiuse.activateMotionSensing(id); + } - /** - * Deactivate motion sensing for the wiimoter with the given id. - * - * @param id - * id of the wiimote. - */ - protected void deactivateMotionSensing(int id) { - wiiuse.deactivateMotionSensing(id); - } + /** + * Deactivate motion sensing for the wiimoter with the given id. + * + * @param id + * id of the wiimote. + */ + protected void deactivateMotionSensing(int id) { + wiiuse.deactivateMotionSensing(id); + } - /** - * Activate smoothing the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - protected void activateSmoothing(int id) { - wiiuse.activateSmoothing(id); - } + /** + * Activate smoothing the wiimotes with the given id. + * + * @param id + * id of the wiimote. + */ + protected void activateSmoothing(int id) { + wiiuse.activateSmoothing(id); + } - /** - * Deactivate smoothing the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - protected void deactivateSmoothing(int id) { - wiiuse.deactivateSmoothing(id); - } + /** + * Deactivate smoothing the wiimotes with the given id. + * + * @param id + * id of the wiimote. + */ + protected void deactivateSmoothing(int id) { + wiiuse.deactivateSmoothing(id); + } - /** - * Activate continuous for the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - protected void activateContinuous(int id) { - wiiuse.activateContinuous(id); - } + /** + * Activate continuous for the wiimotes with the given id. + * + * @param id + * id of the wiimote. + */ + protected void activateContinuous(int id) { + wiiuse.activateContinuous(id); + } - /** - * Deactivate continuous for the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - protected void deactivateContinuous(int id) { - wiiuse.deactivateContinuous(id); - } + /** + * Deactivate continuous for the wiimotes with the given id. + * + * @param id + * id of the wiimote. + */ + protected void deactivateContinuous(int id) { + wiiuse.deactivateContinuous(id); + } - /** - * Set leds for the wiimotes with the given id. - * - * @param id - * id of the wiimote - * @param l1 - * status of led1. True : ON, False : OFF. - * @param l2 - * status of led2. True : ON, False : OFF. - * @param l3 - * status of led3. True : ON, False : OFF. - * @param l4 - * status of led4. True : ON, False : OFF. - */ - protected void setLeds(int id, boolean l1, boolean l2, boolean l3, - boolean l4) { - wiiuse.setLeds(id, l1, l2, l3, l4); - } + /** + * Set leds for the wiimotes with the given id. + * + * @param id + * id of the wiimote + * @param l1 + * status of led1. True : ON, False : OFF. + * @param l2 + * status of led2. True : ON, False : OFF. + * @param l3 + * status of led3. True : ON, False : OFF. + * @param l4 + * status of led4. True : ON, False : OFF. + */ + protected void setLeds(int id, boolean l1, boolean l2, boolean l3, + boolean l4) { + wiiuse.setLeds(id, l1, l2, l3, l4); + } - /** - * Set the orientation threshold for the given id. (minimum angle between - * two events) - * - * @param id - * id of the wiimote. - * @param th - * threshold in degrees. - */ - protected void setOrientationThreshold(int id, float th) { - wiiuse.setOrientThreshold(id, th); - } + /** + * Set the orientation threshold for the given id. (minimum angle between + * two events) + * + * @param id + * id of the wiimote. + * @param th + * threshold in degrees. + */ + protected void setOrientationThreshold(int id, float th) { + wiiuse.setOrientThreshold(id, th); + } - /** - * Set the acceleration threshold for the given id. (minimum angle between - * two events) - * - * @param id - * id of the wiimote. - * @param th - * threshold. - */ - protected void setAccelerationThreshold(int id, int th) { - wiiuse.setAccelThreshold(id, th); - } + /** + * Set the acceleration threshold for the given id. (minimum angle between + * two events) + * + * @param id + * id of the wiimote. + * @param th + * threshold. + */ + protected void setAccelerationThreshold(int id, int th) { + wiiuse.setAccelThreshold(id, th); + } - /** - * Set alpha smoothing for the given id. - * - * @param id - * id of the wiimote. - * @param th - * threshold. - */ - protected void setAlphaSmoothing(int id, float th) { - wiiuse.setAlphaSmoothing(id, th); - } + /** + * Set alpha smoothing for the given id. + * + * @param id + * id of the wiimote. + * @param th + * threshold. + */ + protected void setAlphaSmoothing(int id, float th) { + wiiuse.setAlphaSmoothing(id, th); + } - /** - * Try to resync with the wiimote by starting a new handshake. - * - * @param id - * id of the wiimote. - */ - protected void reSync(int id) { - wiiuse.reSync(id); - } + /** + * Try to resync with the wiimote by starting a new handshake. + * + * @param id + * id of the wiimote. + */ + protected void reSync(int id) { + wiiuse.reSync(id); + } - /** - * Set screen aspect ratio to 4/3 for the given id. - * - * @param id - * id of the wiimote. - */ - protected void setScreenAspectRatio43(int id) { - wiiuse.setScreenRatio43(id); - } + /** + * Set screen aspect ratio to 4/3 for the given id. + * + * @param id + * id of the wiimote. + */ + protected void setScreenAspectRatio43(int id) { + wiiuse.setScreenRatio43(id); + } - /** - * Set screen aspect ratio to 16/9 for the given id. - * - * @param id - * id of the wiimote. - */ - protected void setScreenAspectRatio169(int id) { - wiiuse.setScreenRatio169(id); - } + /** + * Set screen aspect ratio to 16/9 for the given id. + * + * @param id + * id of the wiimote. + */ + protected void setScreenAspectRatio169(int id) { + wiiuse.setScreenRatio169(id); + } - /** - * Set the sensor bar to be above the screen. - * - * @param id - * id of the wiimote. - */ - protected void setSensorBarAboveScreen(int id) { - wiiuse.setSensorBarAboveScreen(id); - } + /** + * Set the sensor bar to be above the screen. + * + * @param id + * id of the wiimote. + */ + protected void setSensorBarAboveScreen(int id) { + wiiuse.setSensorBarAboveScreen(id); + } - /** - * Set the sensor bar to be below the screen. - * - * @param id - * id of the wiimote. - */ - protected void setSensorBarBelowScreen(int id) { - wiiuse.setSensorBarBelowScreen(id); - } + /** + * Set the sensor bar to be below the screen. + * + * @param id + * id of the wiimote. + */ + protected void setSensorBarBelowScreen(int id) { + wiiuse.setSensorBarBelowScreen(id); + } - /** - * Set virtual resolution. It is used to automatically compute the position - * of a cursor on this virtual screen using the sensor bar. These results - * come in the IREvent. - * - * @param id - * id of the wiimote. - * @param x - * x resolution. - * @param y - * y resolution. - */ - protected void setVirtualResolution(int id, int x, int y) { - wiiuse.setVirtualScreenResolution(id, x, y); - } + /** + * Set virtual resolution. It is used to automatically compute the position + * of a cursor on this virtual screen using the sensor bar. These results + * come in the IREvent. + * + * @param id + * id of the wiimote. + * @param x + * x resolution. + * @param y + * y resolution. + */ + protected void setVirtualResolution(int id, int x, int y) { + wiiuse.setVirtualScreenResolution(id, x, y); + } - /** - * Get Status for the wiimote for the given id. - * - * @param id - * id of the wiimote. - */ - protected void getStatus(int id) { - wiiuse.getStatus(id); - } + /** + * Get Status for the wiimote for the given id. + * + * @param id + * id of the wiimote. + */ + protected void getStatus(int id) { + wiiuse.getStatus(id); + } - /** - * Set the normal and expansion handshake timeouts. - * - * @param id - * the id of the wiimote concerned. - * @param normalTimeout - * The timeout in milliseconds for a normal read. - * @param expansionTimeout - * The timeout in millisecondsd to wait for an expansion - * handshake. - */ - protected void setTimeout(int id, short normalTimeout, - short expansionTimeout) { - wiiuse.setTimeout(id, normalTimeout, expansionTimeout); - } + /** + * Set the normal and expansion handshake timeouts. + * + * @param id + * the id of the wiimote concerned. + * @param normalTimeout + * The timeout in milliseconds for a normal read. + * @param expansionTimeout + * The timeout in millisecondsd to wait for an expansion + * handshake. + */ + protected void setTimeout(int id, short normalTimeout, + short expansionTimeout) { + wiiuse.setTimeout(id, normalTimeout, expansionTimeout); + } - /** - * Set the IR sensitivity. - * - * @param id - * the id of the wiimote concerned. - * @param level - * 1-5, same as Wii system sensitivity setting. If the level is < - * 1, then level will be set to 1. If the level is > 5, then - * level will be set to 5. - */ - protected void setIrSensitivity(int id, int level) { - wiiuse.setIrSensitivity(id, level); - } + /** + * Set the IR sensitivity. + * + * @param id + * the id of the wiimote concerned. + * @param level + * 1-5, same as Wii system sensitivity setting. If the level is < + * 1, then level will be set to 1. If the level is > 5, then + * level will be set to 5. + */ + protected void setIrSensitivity(int id, int level) { + wiiuse.setIrSensitivity(id, level); + } - /** - * Set the nunchuk orientation threshold for the given id. (minimum angle - * between two events) - * - * @param id - * id of the wiimote. - * @param th - * threshold in degrees. - */ - protected void setNunchukOrientationThreshold(int id, float th) { - wiiuse.setNunchukOrientationThreshold(id, th); - } + /** + * Set the nunchuk orientation threshold for the given id. (minimum angle + * between two events) + * + * @param id + * id of the wiimote. + * @param th + * threshold in degrees. + */ + protected void setNunchukOrientationThreshold(int id, float th) { + wiiuse.setNunchukOrientationThreshold(id, th); + } - /** - * Set the nunchuk acceleration threshold for the given id. (minimum angle - * between two events) - * - * @param id - * id of the wiimote. - * @param th - * threshold. - */ - protected void setNunchukAccelerationThreshold(int id, int th) { - wiiuse.setNunchukAccelerationThreshold(id, th); - } + /** + * Set the nunchuk acceleration threshold for the given id. (minimum angle + * between two events) + * + * @param id + * id of the wiimote. + * @param th + * threshold. + */ + protected void setNunchukAccelerationThreshold(int id, int th) { + wiiuse.setNunchukAccelerationThreshold(id, th); + } - /** - * Force the bluetooth stack type.(useful only for windows) - * - * @param type - * must be WIIUSE_STACK_UNKNOWN or WIIUSE_STACK_MS or - * WIIUSE_STACK_BLUESOLEIL. - */ - private void setBlueToothstackType(int type) { - wiiuse.windowsSetBluetoothStack(type); - } + /** + * Force the bluetooth stack type.(useful only for windows) + * + * @param type + * must be WIIUSE_STACK_UNKNOWN or WIIUSE_STACK_MS or + * WIIUSE_STACK_BLUESOLEIL. + */ + private void setBlueToothstackType(int type) { + wiiuse.windowsSetBluetoothStack(type); + } - @Override - public void run() { + @Override + public void run() { - while (!leave) { - try { - semaphore.acquire(); - } catch (InterruptedException e) { - e.printStackTrace(); - } + while (!leave) { + try { + semaphore.acquire(); + } catch (InterruptedException e) { + e.printStackTrace(); + } - if (connected > 0) { - running.set(true); + if (connected > 0) { + running.set(true); - EventsGatherer gather = new EventsGatherer(connected); + EventsGatherer gather = new EventsGatherer(connected); - // Start polling and tell the observers when there are Wiimote - // events - while (running.get() && connected > 0) { + // Start polling and tell the observers when there are Wiimote + // events + while (running.get() && connected > 0) { - /* Polling */ - wiiuse.specialPoll(gather); + /* Polling */ + wiiuse.specialPoll(gather); - /* deal with events gathered in Wiiuse API */ - for (WiiUseApiEvent evt : gather.getEvents()) { - if (evt.getWiimoteId() != -1) {// event filled - // there is an event notify observers - notifyWiiUseApiListener(evt); - if (evt.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT) { - // check if it was a disconnection - // in this case disconnect the wiimote - closeConnection(evt.getWiimoteId()); - } - } else { - System.out - .println("There is an event with id == -1 ??? there is a problem !!! : " - + evt); - } - } - gather.clearEvents(); - } - }/* else { - if (connected <= 0) { - System.out.println("No wiimotes connected !"); - } - }*/ - }// end while true - } + /* deal with events gathered in Wiiuse API */ + for (WiiUseApiEvent evt : gather.getEvents()) { + if (evt.getWiimoteId() != -1) {// event filled + // there is an event notify observers + notifyWiiUseApiListener(evt); + if (evt.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT) { + // check if it was a disconnection + // in this case disconnect the wiimote + closeConnection(evt.getWiimoteId()); + } + } else { + System.out + .println("There is an event with id == -1 ??? there is a problem !!! : " + + evt); + } + } + gather.clearEvents(); + } + }/* else { + if (connected <= 0) { + System.out.println("No wiimotes connected !"); + } + }*/ + }// end while true + } - /** - * Add WiiUseApiListener to the listeners list. - * - * @param listener - * a WiiUseApiListener - */ - protected void addWiiUseApiListener(WiiUseApiListener listener) { - listeners.add(WiiUseApiListener.class, listener); - } + /** + * Add WiiUseApiListener to the listeners list. + * + * @param listener + * a WiiUseApiListener + */ + protected void addWiiUseApiListener(WiiUseApiListener listener) { + listeners.add(WiiUseApiListener.class, listener); + } - /** - * Remove WiiUseApiListener from the listeners list. - * - * @param listener - * a WiiUseApiListener - */ - protected void removeWiiUseApiListener(WiiUseApiListener listener) { - listeners.remove(WiiUseApiListener.class, listener); - } + /** + * Remove WiiUseApiListener from the listeners list. + * + * @param listener + * a WiiUseApiListener + */ + protected void removeWiiUseApiListener(WiiUseApiListener listener) { + listeners.remove(WiiUseApiListener.class, listener); + } - /** - * Get the list of WiiUseApiListeners. - * - * @return the list of WiiUseApiListeners. - */ - protected WiiUseApiListener[] getWiiUseApiListeners() { - return listeners.getListeners(WiiUseApiListener.class); - } + /** + * Get the list of WiiUseApiListeners. + * + * @return the list of WiiUseApiListeners. + */ + protected WiiUseApiListener[] getWiiUseApiListeners() { + return listeners.getListeners(WiiUseApiListener.class); + } - /** - * Notify WiiUseApiListeners that an event occured. - * - * @param evt - * GenericEvent occured - */ - private void notifyWiiUseApiListener(WiiUseApiEvent evt) { - for (WiiUseApiListener listener : getWiiUseApiListeners()) { - listener.onWiiUseApiEvent(evt); - } - } + /** + * Notify WiiUseApiListeners that an event occured. + * + * @param evt + * GenericEvent occured + */ + private void notifyWiiUseApiListener(WiiUseApiEvent evt) { + for (WiiUseApiListener listener : getWiiUseApiListeners()) { + listener.onWiiUseApiEvent(evt); + } + } - /** - * Called by the garbage collector at the end. - */ - protected void finalize() throws Throwable { - shutdown(); - } + /** + * Called by the garbage collector at the end. + */ + protected void finalize() throws Throwable { + shutdown(); + } } diff --git a/src/main/java/wiiusej/Wiimote.java b/src/main/java/wiiusej/Wiimote.java index b7bca21..ea91fd0 100644 --- a/src/main/java/wiiusej/Wiimote.java +++ b/src/main/java/wiiusej/Wiimote.java @@ -39,457 +39,457 @@ import wiiusej.wiiusejevents.wiiuseapievents.WiimoteEvent; */ 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. - * - * @param idd - * id of the wiimote - * @param manager - * manager wo built it. - */ - public Wiimote(int idd, WiiUseApiManager manager) { - id = idd; - this.manager = manager; - } + /** + * Constructor. + * + * @param idd + * id of the wiimote + * @param manager + * manager wo built it. + */ + public Wiimote(int idd, WiiUseApiManager manager) { + id = idd; + this.manager = manager; + } - /** - * Get the unique id of the wiimote. - * - * @return the id - */ - public int getId() { - return id; - } + /** + * Get the unique id of the wiimote. + * + * @return the id + */ + public int getId() { + return id; + } - /** - * Disconnect this wiimote. - */ - public void disconnect() { - deactivateIRTRacking(); - deactivateMotionSensing(); - deactivateRumble(); - manager.closeConnection(id); - } + /** + * Disconnect this wiimote. + */ + public void disconnect() { + deactivateIRTRacking(); + deactivateMotionSensing(); + deactivateRumble(); + manager.closeConnection(id); + } - /** - * Activate the rumble. - */ - public void activateRumble() { - manager.activateRumble(id); - } + /** + * Activate the rumble. + */ + public void activateRumble() { + manager.activateRumble(id); + } - /** - * Deactivate the rumble. - */ - public void deactivateRumble() { - manager.deactivateRumble(id); - } + /** + * Deactivate the rumble. + */ + public void deactivateRumble() { + manager.deactivateRumble(id); + } - /** - * Activate IR Tracking. - */ - public void activateIRTRacking() { - manager.activateIRTRacking(id); - } + /** + * Activate IR Tracking. + */ + public void activateIRTRacking() { + manager.activateIRTRacking(id); + } - /** - * Deactivate IR Tracking. - */ - public void deactivateIRTRacking() { - manager.deactivateIRTRacking(id); - } + /** + * Deactivate IR Tracking. + */ + public void deactivateIRTRacking() { + manager.deactivateIRTRacking(id); + } - /** - * Activate motion sensing. - */ - public void activateMotionSensing() { - manager.activateMotionSensing(id); - } + /** + * Activate motion sensing. + */ + public void activateMotionSensing() { + manager.activateMotionSensing(id); + } - /** - * Deactivate motion sensing. - */ - public void deactivateMotionSensing() { - manager.deactivateMotionSensing(id); - } + /** + * Deactivate motion sensing. + */ + public void deactivateMotionSensing() { + manager.deactivateMotionSensing(id); + } - /** - * Activate smoothing. - */ - public void activateSmoothing() { - manager.activateSmoothing(id); - } + /** + * Activate smoothing. + */ + public void activateSmoothing() { + manager.activateSmoothing(id); + } - /** - * Deactivate smoothing. - */ - public void deactivateSmoothing() { - manager.deactivateSmoothing(id); - } + /** + * Deactivate smoothing. + */ + public void deactivateSmoothing() { + manager.deactivateSmoothing(id); + } - /** - * Activate continuous. - */ - public void activateContinuous() { - manager.activateContinuous(id); - } + /** + * Activate continuous. + */ + public void activateContinuous() { + manager.activateContinuous(id); + } - /** - * Deactivate continuous. - */ - public void deactivateContinuous() { - manager.deactivateContinuous(id); + /** + * Deactivate continuous. + */ + public void deactivateContinuous() { + manager.deactivateContinuous(id); - } + } - /** - * Set leds status. - * - * @param l1 - * status of led1. True : ON, False : OFF - * @param l2 - * status of led2. True : ON, False : OFF - * @param l3 - * status of led3. True : ON, False : OFF - * @param l4 - * status of led4. True : ON, False : OFF - */ - public void setLeds(boolean l1, boolean l2, boolean l3, boolean l4) { - manager.setLeds(id, l1, l2, l3, l4); - } + /** + * Set leds status. + * + * @param l1 + * status of led1. True : ON, False : OFF + * @param l2 + * status of led2. True : ON, False : OFF + * @param l3 + * status of led3. True : ON, False : OFF + * @param l4 + * status of led4. True : ON, False : OFF + */ + public void setLeds(boolean l1, boolean l2, boolean l3, boolean l4) { + manager.setLeds(id, l1, l2, l3, l4); + } - /** - * Set the orientation threshold (minimum angle between two degrees with - * accelerometer). - * - * @param th - * threshold in degrees - */ - public void setOrientationThreshold(float th) { - manager.setOrientationThreshold(id, th); - } + /** + * Set the orientation threshold (minimum angle between two degrees with + * accelerometer). + * + * @param th + * threshold in degrees + */ + public void setOrientationThreshold(float th) { + manager.setOrientationThreshold(id, th); + } - /** - * Set the acceleration threshold(minimum angle between two degrees with - * accelerometer). - * - * @param th - * threshold - */ - public void setAccelerationThreshold(int th) { - manager.setAccelerationThreshold(id, th); - } + /** + * Set the acceleration threshold(minimum angle between two degrees with + * accelerometer). + * + * @param th + * threshold + */ + public void setAccelerationThreshold(int th) { + manager.setAccelerationThreshold(id, th); + } - /** - * Set the alpha smoothing value. - * - * @param th - * threshold - */ - public void setAlphaSmoothingValue(float th) { - manager.setAlphaSmoothing(id, th); - } + /** + * Set the alpha smoothing value. + * + * @param th + * threshold + */ + public void setAlphaSmoothingValue(float th) { + manager.setAlphaSmoothing(id, th); + } - /** - * Set the screen aspect ratio to be considered as 4/3. - */ - public void setScreenAspectRatio43() { - manager.setScreenAspectRatio43(id); - } + /** + * Set the screen aspect ratio to be considered as 4/3. + */ + public void setScreenAspectRatio43() { + manager.setScreenAspectRatio43(id); + } - /** - * Set the screen aspect ratio to be considered as 16/9. - */ - public void setScreenAspectRatio169() { - manager.setScreenAspectRatio169(id); - } + /** + * Set the screen aspect ratio to be considered as 16/9. + */ + public void setScreenAspectRatio169() { + manager.setScreenAspectRatio169(id); + } - /** - * Set the sensor bar to be considered above the screen. - */ - public void setSensorBarAboveScreen() { - manager.setSensorBarAboveScreen(id); - } + /** + * Set the sensor bar to be considered above the screen. + */ + public void setSensorBarAboveScreen() { + manager.setSensorBarAboveScreen(id); + } - /** - * Set the sensor bar to be considered below the screen. - */ - public void setSensorBarBelowScreen() { - manager.setSensorBarBelowScreen(id); - } + /** + * Set the sensor bar to be considered below the screen. + */ + public void setSensorBarBelowScreen() { + manager.setSensorBarBelowScreen(id); + } - /** - * Set the screen resolution of the you are pointing at with your wiimote. - * - * @param x - * x resolution. - * @param y - * y resolution. - */ - public void setVirtualResolution(int x, int y) { - manager.setVirtualResolution(id, x, y); - } + /** + * Set the screen resolution of the you are pointing at with your wiimote. + * + * @param x + * x resolution. + * @param y + * y resolution. + */ + public void setVirtualResolution(int x, int y) { + manager.setVirtualResolution(id, x, y); + } - /** - * Set the nunchuk orientation threshold for the given id. (minimum angle - * between two events) - * - * @param th - * threshold in degrees. - */ - public void setNunchukOrientationThreshold(float th) { - manager.setNunchukOrientationThreshold(id, th); - } + /** + * Set the nunchuk orientation threshold for the given id. (minimum angle + * between two events) + * + * @param th + * threshold in degrees. + */ + public void setNunchukOrientationThreshold(float th) { + manager.setNunchukOrientationThreshold(id, th); + } - /** - * Set the nunchuk acceleration threshold for the given id. (minimum angle - * between two events) - * - * @param th - * threshold. - */ - public void setNunchukAccelerationThreshold(int th) { - manager.setNunchukAccelerationThreshold(id, th); - } + /** + * Set the nunchuk acceleration threshold for the given id. (minimum angle + * between two events) + * + * @param th + * threshold. + */ + public void setNunchukAccelerationThreshold(int th) { + manager.setNunchukAccelerationThreshold(id, th); + } - /** - * Try to resync the wiimote by starting a new handshake. - */ - public void reSync() { - manager.reSync(id); - } + /** + * Try to resync the wiimote by starting a new handshake. + */ + public void reSync() { + manager.reSync(id); + } - /** - * Ask for the status of the wiimote. The result will be received in a - * status event object. Implements onStatusEvent on wiimote listener to get - * it. - */ - public void getStatus() { - manager.getStatus(id); - } + /** + * Ask for the status of the wiimote. The result will be received in a + * status event object. Implements onStatusEvent on wiimote listener to get + * it. + */ + public void getStatus() { + manager.getStatus(id); + } - /** - * Set the normal and expansion handshake timeouts for this wiimote. Normal - * time out is for classic polling. The expansion timeout is used when an - * expansion is detected until the expansion successfully handshakes. - * - * @param normalTimeout - * The timeout in milliseconds for a normal read. - * @param expansionTimeout - * The timeout in millisecondsd to wait for an expansion - * handshake. - */ - public void setTimeout(short normalTimeout, short expansionTimeout) { - manager.setTimeout(id, normalTimeout, expansionTimeout); - } + /** + * Set the normal and expansion handshake timeouts for this wiimote. Normal + * time out is for classic polling. The expansion timeout is used when an + * expansion is detected until the expansion successfully handshakes. + * + * @param normalTimeout + * The timeout in milliseconds for a normal read. + * @param expansionTimeout + * The timeout in millisecondsd to wait for an expansion + * handshake. + */ + public void setTimeout(short normalTimeout, short expansionTimeout) { + manager.setTimeout(id, normalTimeout, expansionTimeout); + } - /** - * Set the IR sensitivity. - * - * @param level - * 1-5, same as Wii system sensitivity setting. If the level is < - * 1, then level will be set to 1. If the level is > 5, then - * level will be set to 5. - */ - public void setIrSensitivity(int level) { - manager.setIrSensitivity(id, level); - } + /** + * Set the IR sensitivity. + * + * @param level + * 1-5, same as Wii system sensitivity setting. If the level is < + * 1, then level will be set to 1. If the level is > 5, then + * level will be set to 5. + */ + public void setIrSensitivity(int level) { + manager.setIrSensitivity(id, level); + } - /** - * Method called when a WiiUseApiEvent occurs. - * - * @param e - * the WiiUseApiEvent. - */ - public void onWiiUseApiEvent(WiiUseApiEvent e) { - if (e.getWiimoteId() == id) { - if (e.getEventType() == WiiUseApiEvent.GENERIC_EVENT) { - notifyWiiMoteEventListeners((WiimoteEvent) e); - } else if (e.getEventType() == WiiUseApiEvent.STATUS_EVENT) { - notifyStatusEventListeners((StatusEvent) e); - } else if (e.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT) { - notifyDisconnectionEventListeners((DisconnectionEvent) e); - } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_INSERTED) { - notifyNunchukInsertedEventListeners((NunchukInsertedEvent) e); - } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_REMOVED) { - notifyNunchukRemovedEventListeners((NunchukRemovedEvent) e); - } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED) { - notifyGuitarHeroInsertedEventListeners((GuitarHeroInsertedEvent) e); - } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED) { - notifyGuitarHeroRemovedEventListeners((GuitarHeroRemovedEvent) e); - } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED) { - notifyClassicControllerInsertedEventListeners((ClassicControllerInsertedEvent) e); - } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_REMOVED) { - notifyClassicControllerRemovedEventListeners((ClassicControllerRemovedEvent) e); - } - /* - * events not managed yet || e.getEventType() == WIIUSE_READ_DATA - * WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED || e.getEventType() == - * WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_REMOVED || e.getEventType() == - * WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED || - * e.getEventType() == - * WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED - */ - } - } + /** + * Method called when a WiiUseApiEvent occurs. + * + * @param e + * the WiiUseApiEvent. + */ + public void onWiiUseApiEvent(WiiUseApiEvent e) { + if (e.getWiimoteId() == id) { + if (e.getEventType() == WiiUseApiEvent.GENERIC_EVENT) { + notifyWiiMoteEventListeners((WiimoteEvent) e); + } else if (e.getEventType() == WiiUseApiEvent.STATUS_EVENT) { + notifyStatusEventListeners((StatusEvent) e); + } else if (e.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT) { + notifyDisconnectionEventListeners((DisconnectionEvent) e); + } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_INSERTED) { + notifyNunchukInsertedEventListeners((NunchukInsertedEvent) e); + } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_REMOVED) { + notifyNunchukRemovedEventListeners((NunchukRemovedEvent) e); + } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED) { + notifyGuitarHeroInsertedEventListeners((GuitarHeroInsertedEvent) e); + } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED) { + notifyGuitarHeroRemovedEventListeners((GuitarHeroRemovedEvent) e); + } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED) { + notifyClassicControllerInsertedEventListeners((ClassicControllerInsertedEvent) e); + } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_REMOVED) { + notifyClassicControllerRemovedEventListeners((ClassicControllerRemovedEvent) e); + } + /* + * events not managed yet || e.getEventType() == WIIUSE_READ_DATA + * WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED || e.getEventType() == + * WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_REMOVED || e.getEventType() == + * WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED || + * e.getEventType() == + * WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED + */ + } + } - /** - * Add a WiimoteListener to the listeners list. - * - * @param listener - * a WiimoteListener - */ - public void addWiiMoteEventListeners(WiimoteListener listener) { - listeners.add(WiimoteListener.class, listener); - } + /** + * Add a WiimoteListener to the listeners list. + * + * @param listener + * a WiimoteListener + */ + public void addWiiMoteEventListeners(WiimoteListener listener) { + listeners.add(WiimoteListener.class, listener); + } - /** - * Remove a WiimoteListener from the listeners list. - * - * @param listener - * a WiimoteListener - */ - public void removeWiiMoteEventListeners(WiimoteListener listener) { - listeners.remove(WiimoteListener.class, listener); - } + /** + * Remove a WiimoteListener from the listeners list. + * + * @param listener + * a WiimoteListener + */ + public void removeWiiMoteEventListeners(WiimoteListener listener) { + listeners.remove(WiimoteListener.class, listener); + } - /** - * Get the list of WiimoteListener. - * - * @return the list of WiimoteListener. - */ - public WiimoteListener[] getWiiMoteEventListeners() { - return listeners.getListeners(WiimoteListener.class); - } + /** + * Get the list of WiimoteListener. + * + * @return the list of WiimoteListener. + */ + public WiimoteListener[] getWiiMoteEventListeners() { + return listeners.getListeners(WiimoteListener.class); + } - /** - * Notify WiimoteListeners that an event occured. Notify in first the - * listeners for Buttons Events. In second the listeners for IR Events. In - * third the listeners for Motion sensing events. - * - * @param evt - * GenericEvent occured - */ - private void notifyWiiMoteEventListeners(WiimoteEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onButtonsEvent(evt.getButtonsEvent()); - if (evt.isThereIrEvent()) { - listener.onIrEvent(evt.getIREvent()); - } - if (evt.isThereMotionSensingEvent()) { - listener.onMotionSensingEvent(evt.getMotionSensingEvent()); - } - if (evt.isThereExpansionEvent()) { - listener.onExpansionEvent(evt.getExpansionEvent()); - } - } - } + /** + * Notify WiimoteListeners that an event occured. Notify in first the + * listeners for Buttons Events. In second the listeners for IR Events. In + * third the listeners for Motion sensing events. + * + * @param evt + * GenericEvent occured + */ + private void notifyWiiMoteEventListeners(WiimoteEvent evt) { + for (WiimoteListener listener : getWiiMoteEventListeners()) { + listener.onButtonsEvent(evt.getButtonsEvent()); + if (evt.isThereIrEvent()) { + listener.onIrEvent(evt.getIREvent()); + } + if (evt.isThereMotionSensingEvent()) { + listener.onMotionSensingEvent(evt.getMotionSensingEvent()); + } + if (evt.isThereExpansionEvent()) { + listener.onExpansionEvent(evt.getExpansionEvent()); + } + } + } - /** - * Notify WiimoteListener that a status event occured. - * - * @param evt - * status event occured - */ - private void notifyStatusEventListeners(StatusEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onStatusEvent(evt); - } - } + /** + * Notify WiimoteListener that a status event occured. + * + * @param evt + * status event occured + */ + private void notifyStatusEventListeners(StatusEvent evt) { + for (WiimoteListener listener : getWiiMoteEventListeners()) { + listener.onStatusEvent(evt); + } + } - /** - * Notify WiimoteListener that a disconnection event occured. - * - * @param evt - * disconnection event occured - */ - private void notifyDisconnectionEventListeners(DisconnectionEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onDisconnectionEvent(evt); - } - } + /** + * Notify WiimoteListener that a disconnection event occured. + * + * @param evt + * disconnection event occured + */ + private void notifyDisconnectionEventListeners(DisconnectionEvent evt) { + for (WiimoteListener listener : getWiiMoteEventListeners()) { + listener.onDisconnectionEvent(evt); + } + } - /** - * Notify WiimoteListener that a NunchukInserted Event occured. - * - * @param evt - * NunchukInserted Event occured - */ - private void notifyNunchukInsertedEventListeners(NunchukInsertedEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onNunchukInsertedEvent(evt); - } - } + /** + * Notify WiimoteListener that a NunchukInserted Event occured. + * + * @param evt + * NunchukInserted Event occured + */ + private void notifyNunchukInsertedEventListeners(NunchukInsertedEvent evt) { + for (WiimoteListener listener : getWiiMoteEventListeners()) { + listener.onNunchukInsertedEvent(evt); + } + } - /** - * Notify WiimoteListener that a NunchukRemoved Event occured. - * - * @param evt - * NunchukRemoved Event occured - */ - private void notifyNunchukRemovedEventListeners(NunchukRemovedEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onNunchukRemovedEvent(evt); - } - } + /** + * Notify WiimoteListener that a NunchukRemoved Event occured. + * + * @param evt + * NunchukRemoved Event occured + */ + private void notifyNunchukRemovedEventListeners(NunchukRemovedEvent evt) { + for (WiimoteListener listener : getWiiMoteEventListeners()) { + listener.onNunchukRemovedEvent(evt); + } + } - /** - * Notify WiimoteListener that a GuitarHeroInserted Event occured. - * - * @param evt - * GuitarHeroInserted Event occured - */ - private void notifyGuitarHeroInsertedEventListeners(GuitarHeroInsertedEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onGuitarHeroInsertedEvent(evt); - } - } + /** + * Notify WiimoteListener that a GuitarHeroInserted Event occured. + * + * @param evt + * GuitarHeroInserted Event occured + */ + private void notifyGuitarHeroInsertedEventListeners(GuitarHeroInsertedEvent evt) { + for (WiimoteListener listener : getWiiMoteEventListeners()) { + listener.onGuitarHeroInsertedEvent(evt); + } + } - /** - * Notify WiimoteListener that a GuitarHeroRemoved Event occured. - * - * @param evt - * GuitarHeroRemoved Event occured - */ - private void notifyGuitarHeroRemovedEventListeners(GuitarHeroRemovedEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onGuitarHeroRemovedEvent(evt); - } - } - - /** - * Notify WiimoteListener that a ClassicControllerInserted Event occured. - * - * @param evt - * ClassicControllerInserted Event occured - */ - private void notifyClassicControllerInsertedEventListeners(ClassicControllerInsertedEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onClassicControllerInsertedEvent(evt); - } - } + /** + * Notify WiimoteListener that a GuitarHeroRemoved Event occured. + * + * @param evt + * GuitarHeroRemoved Event occured + */ + private void notifyGuitarHeroRemovedEventListeners(GuitarHeroRemovedEvent evt) { + for (WiimoteListener listener : getWiiMoteEventListeners()) { + listener.onGuitarHeroRemovedEvent(evt); + } + } + + /** + * Notify WiimoteListener that a ClassicControllerInserted Event occured. + * + * @param evt + * ClassicControllerInserted Event occured + */ + private void notifyClassicControllerInsertedEventListeners(ClassicControllerInsertedEvent evt) { + for (WiimoteListener listener : getWiiMoteEventListeners()) { + listener.onClassicControllerInsertedEvent(evt); + } + } - /** - * Notify WiimoteListener that a ClassicControllerRemoved Event occured. - * - * @param evt - * ClassicControllerRemoved Event occured - */ - private void notifyClassicControllerRemovedEventListeners(ClassicControllerRemovedEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onClassicControllerRemovedEvent(evt); - } - } - - @Override - public String toString() { - return "Wiimote with ID : " + id; - } + /** + * Notify WiimoteListener that a ClassicControllerRemoved Event occured. + * + * @param evt + * ClassicControllerRemoved Event occured + */ + private void notifyClassicControllerRemovedEventListeners(ClassicControllerRemovedEvent evt) { + for (WiimoteListener listener : getWiiMoteEventListeners()) { + listener.onClassicControllerRemovedEvent(evt); + } + } + + @Override + public String toString() { + return "Wiimote with ID : " + id; + } } diff --git a/src/main/java/wiiusej/utils/AccelerationExpansionEventPanel.java b/src/main/java/wiiusej/utils/AccelerationExpansionEventPanel.java index cb3021f..5fa8cee 100644 --- a/src/main/java/wiiusej/utils/AccelerationExpansionEventPanel.java +++ b/src/main/java/wiiusej/utils/AccelerationExpansionEventPanel.java @@ -27,13 +27,13 @@ import wiiusej.wiiusejevents.physicalevents.NunchukEvent; */ public class AccelerationExpansionEventPanel extends AccelerationPanel { - @Override - public RawAcceleration getRawAccelerationValue(GenericEvent e) { - if (e instanceof NunchukEvent) { - return ((NunchukEvent) e).getNunchukMotionSensingEvent() - .getRawAcceleration(); - } - return null; - } + @Override + public RawAcceleration getRawAccelerationValue(GenericEvent e) { + if (e instanceof NunchukEvent) { + return ((NunchukEvent) e).getNunchukMotionSensingEvent() + .getRawAcceleration(); + } + return null; + } } diff --git a/src/main/java/wiiusej/utils/AccelerationPanel.java b/src/main/java/wiiusej/utils/AccelerationPanel.java index 15f1551..44b2470 100644 --- a/src/main/java/wiiusej/utils/AccelerationPanel.java +++ b/src/main/java/wiiusej/utils/AccelerationPanel.java @@ -48,256 +48,256 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; * @author guiguito */ public abstract class AccelerationPanel extends javax.swing.JPanel implements - WiimoteListener { + WiimoteListener { - private Image mImage;// image for double buffering - private Color xColor = Color.RED; - private Color yColor = Color.GREEN; - private Color zColor = Color.BLUE; - private Color backgroundColor = Color.WHITE; - private Color lineColor = Color.BLACK; - private ArrayList values = new ArrayList(); + private Image mImage;// image for double buffering + private Color xColor = Color.RED; + private Color yColor = Color.GREEN; + private Color zColor = Color.BLUE; + private Color backgroundColor = Color.WHITE; + private Color lineColor = Color.BLACK; + private ArrayList values = new ArrayList(); - /** Creates new form AccelerationPanel */ - public AccelerationPanel() { - initComponents(); - } + /** Creates new form AccelerationPanel */ + public AccelerationPanel() { + initComponents(); + } - /** - * Constructor used to choose the colors used by the AccelerationPanel. - * - * @param bgColor - * background color. - * @param xColor - * x color. - * @param yColor - * y color. - * @param zColor - * z color. - * @param lColor - * line color. - */ - public AccelerationPanel(Color bgColor, Color xColor, Color yColor, - Color zColor, Color lColor) { - backgroundColor = bgColor; - this.xColor = xColor; - this.yColor = yColor; - this.zColor = zColor; - lineColor = lColor; - initComponents(); - } + /** + * Constructor used to choose the colors used by the AccelerationPanel. + * + * @param bgColor + * background color. + * @param xColor + * x color. + * @param yColor + * y color. + * @param zColor + * z color. + * @param lColor + * line color. + */ + public AccelerationPanel(Color bgColor, Color xColor, Color yColor, + Color zColor, Color lColor) { + backgroundColor = bgColor; + this.xColor = xColor; + this.yColor = yColor; + this.zColor = zColor; + lineColor = lColor; + initComponents(); + } - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Dimension d = getSize(); + checkOffScreenImage(); + Graphics offG = mImage.getGraphics(); + offG.setColor(backgroundColor); + offG.fillRect(0, 0, d.width, d.height); + Graphics2D g2 = (Graphics2D) mImage.getGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - // draw medium line - int yLine = getHeight() - 25; + // draw medium line + int yLine = getHeight() - 25; - g2.setPaint(lineColor); - g2.drawLine(0, yLine, getWidth(), yLine); + g2.setPaint(lineColor); + g2.drawLine(0, yLine, getWidth(), yLine); - RawAcceleration[] valuesArray = values.toArray(new RawAcceleration[0]); + RawAcceleration[] valuesArray = values.toArray(new RawAcceleration[0]); - double unit = yLine / 255.0; - int previousX = 0; - int previousY = 0; - int previousZ = 0; - // draw curves - for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { - RawAcceleration acceleration = valuesArray[i]; - // draw X - g2.setPaint(xColor); - int yDelta = (int) Math.round(unit * acceleration.getX()); - int y = -1 * yDelta + yLine; - g2.drawLine(i - 1, previousX, i, y); - g2.setTransform(new AffineTransform()); - previousX = y; - // draw Y - g2.setPaint(yColor); - yDelta = (int) Math.round(unit * acceleration.getY()); - y = -1 * yDelta + yLine; - g2.drawLine(i - 1, previousY, i, y); - g2.setTransform(new AffineTransform()); - previousY = y; - // draw Z - g2.setPaint(zColor); - yDelta = (int) Math.round(unit * acceleration.getZ()); - y = -1 * yDelta + yLine; - g2.drawLine(i - 1, previousZ, i, y); - g2.setTransform(new AffineTransform()); - previousZ = y; - } + double unit = yLine / 255.0; + int previousX = 0; + int previousY = 0; + int previousZ = 0; + // draw curves + for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { + RawAcceleration acceleration = valuesArray[i]; + // draw X + g2.setPaint(xColor); + int yDelta = (int) Math.round(unit * acceleration.getX()); + int y = -1 * yDelta + yLine; + g2.drawLine(i - 1, previousX, i, y); + g2.setTransform(new AffineTransform()); + previousX = y; + // draw Y + g2.setPaint(yColor); + yDelta = (int) Math.round(unit * acceleration.getY()); + y = -1 * yDelta + yLine; + g2.drawLine(i - 1, previousY, i, y); + g2.setTransform(new AffineTransform()); + previousY = y; + // draw Z + g2.setPaint(zColor); + yDelta = (int) Math.round(unit * acceleration.getZ()); + y = -1 * yDelta + yLine; + g2.drawLine(i - 1, previousZ, i, y); + g2.setTransform(new AffineTransform()); + previousZ = y; + } - // draw legend - g2.setPaint(xColor); - g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10); - g2.setPaint(yColor); - g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10); - g2.setPaint(zColor); - g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10); + // draw legend + g2.setPaint(xColor); + g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10); + g2.setPaint(yColor); + g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10); + g2.setPaint(zColor); + g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10); - g2.setPaint(lineColor); - g2.drawString("X", 30, getHeight() - 5); - g2.drawString("Y", 85, getHeight() - 5); - g2.drawString("Z", 145, getHeight() - 5); - g2.drawString("0", 2, yLine - 5); - g2.drawString("255", 2, 15); - // put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } + g2.setPaint(lineColor); + g2.drawString("X", 30, getHeight() - 5); + g2.drawString("Y", 85, getHeight() - 5); + g2.drawString("Z", 145, getHeight() - 5); + g2.drawString("0", 2, yLine - 5); + g2.drawString("255", 2, 15); + // put offscreen image on the screen + g.drawImage(mImage, 0, 0, null); + } - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } + /** + * check if the mImage variable has been initialized. If it's not the case + * it initializes it with the dimensions of the panel. mImage is for double + * buffering. + */ + private void checkOffScreenImage() { + Dimension d = getSize(); + if (mImage == null || mImage.getWidth(null) != d.width + || mImage.getHeight(null) != d.height) { + mImage = createImage(d.width, d.height); + } + } - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - // nothing - } + public void onButtonsEvent(WiimoteButtonsEvent arg0) { + // nothing + } - public void onIrEvent(IREvent arg0) { - // nothing - } + public void onIrEvent(IREvent arg0) { + // nothing + } - public void onMotionSensingEvent(MotionSensingEvent arg0) { - draw(arg0); - } + public void onMotionSensingEvent(MotionSensingEvent arg0) { + draw(arg0); + } - public void onExpansionEvent(ExpansionEvent arg0) { - draw(arg0); - } + public void onExpansionEvent(ExpansionEvent arg0) { + draw(arg0); + } - public void onStatusEvent(StatusEvent arg0) { - // nothing - } + public void onStatusEvent(StatusEvent arg0) { + // nothing + } - public void onDisconnectionEvent(DisconnectionEvent arg0) { - // Clear points. - values.clear(); - repaint(); - } + public void onDisconnectionEvent(DisconnectionEvent arg0) { + // Clear points. + values.clear(); + repaint(); + } - public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { - // nothing - } + public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { + // nothing + } - public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { - // nothing - } - - public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { - // nothing - } + public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { + // nothing + } + + public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { + // nothing + } - public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { - // nothing - } + public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { + // nothing + } - public void onClassicControllerInsertedEvent( - ClassicControllerInsertedEvent arg0) { - // nothing - } + public void onClassicControllerInsertedEvent( + ClassicControllerInsertedEvent arg0) { + // nothing + } - public void onClassicControllerRemovedEvent( - ClassicControllerRemovedEvent arg0) { - // nothing - } + public void onClassicControllerRemovedEvent( + ClassicControllerRemovedEvent arg0) { + // nothing + } - private void draw(GenericEvent arg0) { - if (values.size() >= getWidth()) { - // if there are as many values as pixels in the width - // clear points - values.clear(); - } - RawAcceleration rawAcceleration = getRawAccelerationValue(arg0); - if (rawAcceleration != null) - values.add(rawAcceleration); - repaint(); - } + private void draw(GenericEvent arg0) { + if (values.size() >= getWidth()) { + // if there are as many values as pixels in the width + // clear points + values.clear(); + } + RawAcceleration rawAcceleration = getRawAccelerationValue(arg0); + if (rawAcceleration != null) + values.add(rawAcceleration); + repaint(); + } - public abstract RawAcceleration getRawAccelerationValue(GenericEvent e); + public abstract RawAcceleration getRawAccelerationValue(GenericEvent e); - public Color getBackgroundColor() { - return backgroundColor; - } + public Color getBackgroundColor() { + return backgroundColor; + } - public Color getLineColor() { - return lineColor; - } + public Color getLineColor() { + return lineColor; + } - public Color getXColor() { - return xColor; - } + public Color getXColor() { + return xColor; + } - public Color getYColor() { - return yColor; - } + public Color getYColor() { + return yColor; + } - public Color getZColor() { - return zColor; - } + public Color getZColor() { + return zColor; + } - public void setBackgroundColor(Color backgroundColor) { - this.backgroundColor = backgroundColor; - } + public void setBackgroundColor(Color backgroundColor) { + this.backgroundColor = backgroundColor; + } - public void setLineColor(Color lineColor) { - this.lineColor = lineColor; - } + public void setLineColor(Color lineColor) { + this.lineColor = lineColor; + } - public void setXColor(Color xColor) { - this.xColor = xColor; - } + public void setXColor(Color xColor) { + this.xColor = xColor; + } - public void setYColor(Color yColor) { - this.yColor = yColor; - } + public void setYColor(Color yColor) { + this.yColor = yColor; + } - public void setZColor(Color zColor) { - this.zColor = zColor; - } + public void setZColor(Color zColor) { + this.zColor = zColor; + } - public void clearView() { - values.clear(); - repaint(); - } + public void clearView() { + values.clear(); + repaint(); + } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, - Short.MAX_VALUE)); - layout.setVerticalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, - Short.MAX_VALUE)); - }// //GEN-END:initComponents + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, + Short.MAX_VALUE)); + layout.setVerticalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, + Short.MAX_VALUE)); + }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/wiiusej/utils/AccelerationWiimoteEventPanel.java b/src/main/java/wiiusej/utils/AccelerationWiimoteEventPanel.java index 4e716de..d4166e3 100644 --- a/src/main/java/wiiusej/utils/AccelerationWiimoteEventPanel.java +++ b/src/main/java/wiiusej/utils/AccelerationWiimoteEventPanel.java @@ -26,12 +26,12 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; */ public class AccelerationWiimoteEventPanel extends AccelerationPanel { - @Override - public RawAcceleration getRawAccelerationValue(GenericEvent e) { - if (e instanceof MotionSensingEvent) { - return ((MotionSensingEvent) e).getRawAcceleration(); - } - return null; - } + @Override + public RawAcceleration getRawAccelerationValue(GenericEvent e) { + if (e instanceof MotionSensingEvent) { + return ((MotionSensingEvent) e).getRawAcceleration(); + } + return null; + } } diff --git a/src/main/java/wiiusej/utils/ButtonsEventPanel.java b/src/main/java/wiiusej/utils/ButtonsEventPanel.java index 97f9b19..7aeb016 100644 --- a/src/main/java/wiiusej/utils/ButtonsEventPanel.java +++ b/src/main/java/wiiusej/utils/ButtonsEventPanel.java @@ -47,336 +47,336 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; * @author guiguito */ public class ButtonsEventPanel extends javax.swing.JPanel implements - WiimoteListener { + WiimoteListener { - private Image mImage;// image for double buffering - private Image wiimoteImage;// image for double buffering - private WiimoteButtonsEvent buttons; - private Color pressedColor = Color.RED; - private Color heldColor = Color.ORANGE; - private Color releasedColor = Color.YELLOW; - private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13); + private Image mImage;// image for double buffering + private Image wiimoteImage;// image for double buffering + private WiimoteButtonsEvent buttons; + private Color pressedColor = Color.RED; + private Color heldColor = Color.ORANGE; + private Color releasedColor = Color.YELLOW; + private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13); - /** - * Default constructor. Red : button just pressed. Orange : button held. - * Yellow : button just released. - */ - public ButtonsEventPanel() { - Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); - java.net.URL url = ButtonsEventPanel.class - .getResource("/img/wiimote.png"); - wiimoteImage = toolkit.createImage(url); - initComponents(); - } + /** + * Default constructor. Red : button just pressed. Orange : button held. + * Yellow : button just released. + */ + public ButtonsEventPanel() { + Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); + java.net.URL url = ButtonsEventPanel.class + .getResource("/img/wiimote.png"); + wiimoteImage = toolkit.createImage(url); + initComponents(); + } - /** - * Constructor used to set colors and shape used. - * - * @param pressColor - * color of a button just pressed. - * @param hColor - * color of a button held. - * @param relColor - * color of a button just released. - * @param sh - * shape draw on the buttons. - */ - public ButtonsEventPanel(Color pressColor, Color hColor, Color relColor, - Shape sh) { - pressedColor = pressColor; - heldColor = hColor; - releasedColor = relColor; - shape = sh; - Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); - wiimoteImage = toolkit.createImage("img\\wiimote.png"); - initComponents(); - } + /** + * Constructor used to set colors and shape used. + * + * @param pressColor + * color of a button just pressed. + * @param hColor + * color of a button held. + * @param relColor + * color of a button just released. + * @param sh + * shape draw on the buttons. + */ + public ButtonsEventPanel(Color pressColor, Color hColor, Color relColor, + Shape sh) { + pressedColor = pressColor; + heldColor = hColor; + releasedColor = relColor; + shape = sh; + Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); + wiimoteImage = toolkit.createImage("img\\wiimote.png"); + initComponents(); + } - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - // offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Dimension d = getSize(); + checkOffScreenImage(); + Graphics offG = mImage.getGraphics(); + // offG.setColor(backgroundColor); + offG.fillRect(0, 0, d.width, d.height); + Graphics2D g2 = (Graphics2D) mImage.getGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - // draw buttons pushed - g2.drawImage(wiimoteImage, 0, 0, this); - g2.setTransform(new AffineTransform()); + // draw buttons pushed + g2.drawImage(wiimoteImage, 0, 0, this); + g2.setTransform(new AffineTransform()); - if (buttons != null) { - /* button ONE */ - if (buttons.isButtonOneJustPressed()) { - drawFunction(g2, pressedColor, 53, 353); - } - if (buttons.isButtonOneHeld()) { - drawFunction(g2, heldColor, 53, 353); - } - if (buttons.isButtonOneJustReleased()) { - drawFunction(g2, releasedColor, 53, 353); - } + if (buttons != null) { + /* button ONE */ + if (buttons.isButtonOneJustPressed()) { + drawFunction(g2, pressedColor, 53, 353); + } + if (buttons.isButtonOneHeld()) { + drawFunction(g2, heldColor, 53, 353); + } + if (buttons.isButtonOneJustReleased()) { + drawFunction(g2, releasedColor, 53, 353); + } - /* button TWO */ - if (buttons.isButtonTwoJustPressed()) { - drawFunction(g2, pressedColor, 53, 395); - } - if (buttons.isButtonTwoHeld()) { - drawFunction(g2, heldColor, 53, 395); - } - if (buttons.isButtonTwoJustReleased()) { - drawFunction(g2, releasedColor, 53, 395); - } + /* button TWO */ + if (buttons.isButtonTwoJustPressed()) { + drawFunction(g2, pressedColor, 53, 395); + } + if (buttons.isButtonTwoHeld()) { + drawFunction(g2, heldColor, 53, 395); + } + if (buttons.isButtonTwoJustReleased()) { + drawFunction(g2, releasedColor, 53, 395); + } - /* button A */ - if (buttons.isButtonAJustPressed()) { - drawFunction(g2, pressedColor, 53, 150); - } - if (buttons.isButtonAHeld()) { - drawFunction(g2, heldColor, 53, 150); - } - if (buttons.isButtonAJustReleased()) { - drawFunction(g2, releasedColor, 53, 150); - } + /* button A */ + if (buttons.isButtonAJustPressed()) { + drawFunction(g2, pressedColor, 53, 150); + } + if (buttons.isButtonAHeld()) { + drawFunction(g2, heldColor, 53, 150); + } + if (buttons.isButtonAJustReleased()) { + drawFunction(g2, releasedColor, 53, 150); + } - /* button B */ - if (buttons.isButtonBJustPressed()) { - drawFunction(g2, pressedColor, 16, 149); - } - if (buttons.isButtonBHeld()) { - drawFunction(g2, heldColor, 16, 149); - } - if (buttons.isButtonBJustReleased()) { - drawFunction(g2, releasedColor, 16, 149); - } + /* button B */ + if (buttons.isButtonBJustPressed()) { + drawFunction(g2, pressedColor, 16, 149); + } + if (buttons.isButtonBHeld()) { + drawFunction(g2, heldColor, 16, 149); + } + if (buttons.isButtonBJustReleased()) { + drawFunction(g2, releasedColor, 16, 149); + } - /* button LEFT */ - if (buttons.isButtonLeftJustPressed()) { - drawFunction(g2, pressedColor, 33, 77); - } - if (buttons.isButtonLeftHeld()) { - drawFunction(g2, heldColor, 33, 77); - } - if (buttons.isButtonLeftJustReleased()) { - drawFunction(g2, releasedColor, 33, 77); - } + /* button LEFT */ + if (buttons.isButtonLeftJustPressed()) { + drawFunction(g2, pressedColor, 33, 77); + } + if (buttons.isButtonLeftHeld()) { + drawFunction(g2, heldColor, 33, 77); + } + if (buttons.isButtonLeftJustReleased()) { + drawFunction(g2, releasedColor, 33, 77); + } - /* button RIGHT */ - if (buttons.isButtonRightJustPressed()) { - drawFunction(g2, pressedColor, 73, 77); - } - if (buttons.isButtonRightHeld()) { - drawFunction(g2, heldColor, 73, 77); - } - if (buttons.isButtonRightJustReleased()) { - drawFunction(g2, releasedColor, 73, 77); - } + /* button RIGHT */ + if (buttons.isButtonRightJustPressed()) { + drawFunction(g2, pressedColor, 73, 77); + } + if (buttons.isButtonRightHeld()) { + drawFunction(g2, heldColor, 73, 77); + } + if (buttons.isButtonRightJustReleased()) { + drawFunction(g2, releasedColor, 73, 77); + } - /* button UP */ - if (buttons.isButtonUpJustPressed()) { - drawFunction(g2, pressedColor, 54, 60); - } - if (buttons.isButtonUpHeld()) { - drawFunction(g2, heldColor, 54, 60); - } - if (buttons.isButtonUpJustReleased()) { - drawFunction(g2, releasedColor, 54, 60); - } + /* button UP */ + if (buttons.isButtonUpJustPressed()) { + drawFunction(g2, pressedColor, 54, 60); + } + if (buttons.isButtonUpHeld()) { + drawFunction(g2, heldColor, 54, 60); + } + if (buttons.isButtonUpJustReleased()) { + drawFunction(g2, releasedColor, 54, 60); + } - /* button DOWN */ - if (buttons.isButtonDownJustPressed()) { - drawFunction(g2, pressedColor, 54, 97); - } - if (buttons.isButtonDownHeld()) { - drawFunction(g2, heldColor, 54, 97); - } - if (buttons.isButtonDownJustReleased()) { - drawFunction(g2, releasedColor, 54, 97); - } + /* button DOWN */ + if (buttons.isButtonDownJustPressed()) { + drawFunction(g2, pressedColor, 54, 97); + } + if (buttons.isButtonDownHeld()) { + drawFunction(g2, heldColor, 54, 97); + } + if (buttons.isButtonDownJustReleased()) { + drawFunction(g2, releasedColor, 54, 97); + } - /* button MINUS */ - if (buttons.isButtonMinusJustPressed()) { - drawFunction(g2, pressedColor, 20, 230); - } - if (buttons.isButtonMinusHeld()) { - drawFunction(g2, heldColor, 20, 230); - } - if (buttons.isButtonMinusJustReleased()) { - drawFunction(g2, releasedColor, 20, 230); - } + /* button MINUS */ + if (buttons.isButtonMinusJustPressed()) { + drawFunction(g2, pressedColor, 20, 230); + } + if (buttons.isButtonMinusHeld()) { + drawFunction(g2, heldColor, 20, 230); + } + if (buttons.isButtonMinusJustReleased()) { + drawFunction(g2, releasedColor, 20, 230); + } - /* button PLUS */ - if (buttons.isButtonPlusJustPressed()) { - drawFunction(g2, pressedColor, 86, 230); - } - if (buttons.isButtonPlusHeld()) { - drawFunction(g2, heldColor, 86, 230); - } - if (buttons.isButtonPlusJustReleased()) { - drawFunction(g2, releasedColor, 86, 230); - } + /* button PLUS */ + if (buttons.isButtonPlusJustPressed()) { + drawFunction(g2, pressedColor, 86, 230); + } + if (buttons.isButtonPlusHeld()) { + drawFunction(g2, heldColor, 86, 230); + } + if (buttons.isButtonPlusJustReleased()) { + drawFunction(g2, releasedColor, 86, 230); + } - /* button HOME */ - if (buttons.isButtonHomeJustPressed()) { - drawFunction(g2, pressedColor, 53, 230); - } - if (buttons.isButtonHomeHeld()) { - drawFunction(g2, heldColor, 53, 230); - } - if (buttons.isButtonHomeJustReleased()) { - drawFunction(g2, releasedColor, 53, 230); - } + /* button HOME */ + if (buttons.isButtonHomeJustPressed()) { + drawFunction(g2, pressedColor, 53, 230); + } + if (buttons.isButtonHomeHeld()) { + drawFunction(g2, heldColor, 53, 230); + } + if (buttons.isButtonHomeJustReleased()) { + drawFunction(g2, releasedColor, 53, 230); + } - buttons = null; - } + buttons = null; + } - // put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } + // put offscreen image on the screen + g.drawImage(mImage, 0, 0, null); + } - /** - * Function used to factorize code. - * - * @param g2 - * where to draw a shape. - * @param col - * color to use. - * @param x - * x coordinates. - * @param y - * y coordinates. - */ - private void drawFunction(Graphics2D g2, Color col, int x, int y) { - g2.setPaint(col); - g2.translate(x, y); - g2.draw(shape); - g2.fill(shape); - g2.setTransform(new AffineTransform()); - } + /** + * Function used to factorize code. + * + * @param g2 + * where to draw a shape. + * @param col + * color to use. + * @param x + * x coordinates. + * @param y + * y coordinates. + */ + private void drawFunction(Graphics2D g2, Color col, int x, int y) { + g2.setPaint(col); + g2.translate(x, y); + g2.draw(shape); + g2.fill(shape); + g2.setTransform(new AffineTransform()); + } - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } + /** + * check if the mImage variable has been initialized. If it's not the case + * it initializes it with the dimensions of the panel. mImage is for double + * buffering. + */ + private void checkOffScreenImage() { + Dimension d = getSize(); + if (mImage == null || mImage.getWidth(null) != d.width + || mImage.getHeight(null) != d.height) { + mImage = createImage(d.width, d.height); + } + } - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - setSize(wiimoteImage.getWidth(this), wiimoteImage.getHeight(this)); - buttons = arg0; - repaint(); - } + public void onButtonsEvent(WiimoteButtonsEvent arg0) { + setSize(wiimoteImage.getWidth(this), wiimoteImage.getHeight(this)); + buttons = arg0; + repaint(); + } - public void onIrEvent(IREvent arg0) { - // nothing - } + public void onIrEvent(IREvent arg0) { + // nothing + } - public void onMotionSensingEvent(MotionSensingEvent arg0) { - // nothing - } + public void onMotionSensingEvent(MotionSensingEvent arg0) { + // nothing + } - public void onExpansionEvent(ExpansionEvent e) { - // nothing - } + public void onExpansionEvent(ExpansionEvent e) { + // nothing + } - public void onStatusEvent(StatusEvent arg0) { - // nothing - } + public void onStatusEvent(StatusEvent arg0) { + // nothing + } - public void onDisconnectionEvent(DisconnectionEvent arg0) { + public void onDisconnectionEvent(DisconnectionEvent arg0) { clearView(); - } + } - public void onNunchukInsertedEvent(NunchukInsertedEvent e) { - // nothing - } + public void onNunchukInsertedEvent(NunchukInsertedEvent e) { + // nothing + } - public void onNunchukRemovedEvent(NunchukRemovedEvent e) { - // nothing - } + public void onNunchukRemovedEvent(NunchukRemovedEvent e) { + // nothing + } - public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { - // nothing - } + public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { + // nothing + } - public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { - // nothing - } + public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { + // nothing + } - public void onClassicControllerInsertedEvent( - ClassicControllerInsertedEvent arg0) { - // nothing - } + public void onClassicControllerInsertedEvent( + ClassicControllerInsertedEvent arg0) { + // nothing + } - public void onClassicControllerRemovedEvent( - ClassicControllerRemovedEvent arg0) { - // nothing - } + public void onClassicControllerRemovedEvent( + ClassicControllerRemovedEvent arg0) { + // nothing + } - public Color getHeldColor() { - return heldColor; - } + public Color getHeldColor() { + return heldColor; + } - public Color getPressedColor() { - return pressedColor; - } + public Color getPressedColor() { + return pressedColor; + } - public Color getReleasedColor() { - return releasedColor; - } + public Color getReleasedColor() { + return releasedColor; + } - public Shape getShape() { - return shape; - } + public Shape getShape() { + return shape; + } - public void setHeldColor(Color heldColor) { - this.heldColor = heldColor; - } + public void setHeldColor(Color heldColor) { + this.heldColor = heldColor; + } - public void setPressedColor(Color pressedColor) { - this.pressedColor = pressedColor; - } + public void setPressedColor(Color pressedColor) { + this.pressedColor = pressedColor; + } - public void setReleasedColor(Color releasedColor) { - this.releasedColor = releasedColor; - } + public void setReleasedColor(Color releasedColor) { + this.releasedColor = releasedColor; + } - public void setShape(Shape shape) { - this.shape = shape; - } + public void setShape(Shape shape) { + this.shape = shape; + } - public void clearView() { - buttons = null; - repaint(); - } + public void clearView() { + buttons = null; + repaint(); + } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, - Short.MAX_VALUE)); - layout.setVerticalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, - Short.MAX_VALUE)); - }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, + Short.MAX_VALUE)); + layout.setVerticalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, + Short.MAX_VALUE)); + }// //GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/wiiusej/utils/GForcePanel.java b/src/main/java/wiiusej/utils/GForcePanel.java index dc57b30..d6cf570 100644 --- a/src/main/java/wiiusej/utils/GForcePanel.java +++ b/src/main/java/wiiusej/utils/GForcePanel.java @@ -47,258 +47,258 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; * @author guiguito */ public abstract class GForcePanel extends javax.swing.JPanel implements - WiimoteListener { + WiimoteListener { - private Image mImage;// image for double buffering - private Color xColor = Color.RED; - private Color yColor = Color.GREEN; - private Color zColor = Color.BLUE; - private Color backgroundColor = Color.WHITE; - private Color lineColor = Color.BLACK; - private ArrayList values = new ArrayList(); + private Image mImage;// image for double buffering + private Color xColor = Color.RED; + private Color yColor = Color.GREEN; + private Color zColor = Color.BLUE; + private Color backgroundColor = Color.WHITE; + private Color lineColor = Color.BLACK; + private ArrayList values = new ArrayList(); - /** - * Default constructor of the AccelerationPanel. - */ - public GForcePanel() { - initComponents(); - } + /** + * Default constructor of the AccelerationPanel. + */ + public GForcePanel() { + initComponents(); + } - /** - * Constructor used to choose the colors used by the AccelerationPanel. - * - * @param bgColor - * background color. - * @param xxColor - * color of the acceleration on X axis. - * @param yyColor - * color of the acceleration on Y axis. - * @param zzColor - * color of the acceleration on Z axis. - * @param lColor - * line color. - */ - public GForcePanel(Color bgColor, Color xxColor, Color yyColor, - Color zzColor, Color lColor) { - backgroundColor = bgColor; - xColor = xxColor; - yColor = yyColor; - zColor = zzColor; - lineColor = lColor; - initComponents(); - } + /** + * Constructor used to choose the colors used by the AccelerationPanel. + * + * @param bgColor + * background color. + * @param xxColor + * color of the acceleration on X axis. + * @param yyColor + * color of the acceleration on Y axis. + * @param zzColor + * color of the acceleration on Z axis. + * @param lColor + * line color. + */ + public GForcePanel(Color bgColor, Color xxColor, Color yyColor, + Color zzColor, Color lColor) { + backgroundColor = bgColor; + xColor = xxColor; + yColor = yyColor; + zColor = zzColor; + lineColor = lColor; + initComponents(); + } - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Dimension d = getSize(); + checkOffScreenImage(); + Graphics offG = mImage.getGraphics(); + offG.setColor(backgroundColor); + offG.fillRect(0, 0, d.width, d.height); + Graphics2D g2 = (Graphics2D) mImage.getGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - // draw medium line - double yMiddleFloat = getHeight() / 2.0; - int yMiddle = (int) Math.round(yMiddleFloat); + // draw medium line + double yMiddleFloat = getHeight() / 2.0; + int yMiddle = (int) Math.round(yMiddleFloat); - g2.setPaint(lineColor); - g2.drawLine(0, yMiddle, getWidth(), yMiddle); + g2.setPaint(lineColor); + g2.drawLine(0, yMiddle, getWidth(), yMiddle); - GForce[] valuesArray = values.toArray(new GForce[0]); - double unit = yMiddleFloat / 5.0; - int previousX = 0; - int previousY = 0; - int previousZ = 0; - // draw curves - for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { - GForce gforce = valuesArray[i]; - // draw X - g2.setPaint(xColor); - int yDelta = (int) Math.round(unit * gforce.getX()); - int y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousX, i, y); - g2.setTransform(new AffineTransform()); - previousX = y; - // draw Y - g2.setPaint(yColor); - yDelta = (int) Math.round(unit * gforce.getY()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousY, i, y); - g2.setTransform(new AffineTransform()); - previousY = y; - // draw Z - g2.setPaint(zColor); - yDelta = (int) Math.round(unit * gforce.getZ()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousZ, i, y); - g2.setTransform(new AffineTransform()); - previousZ = y; - } + GForce[] valuesArray = values.toArray(new GForce[0]); + double unit = yMiddleFloat / 5.0; + int previousX = 0; + int previousY = 0; + int previousZ = 0; + // draw curves + for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { + GForce gforce = valuesArray[i]; + // draw X + g2.setPaint(xColor); + int yDelta = (int) Math.round(unit * gforce.getX()); + int y = -1 * yDelta + yMiddle; + g2.drawLine(i - 1, previousX, i, y); + g2.setTransform(new AffineTransform()); + previousX = y; + // draw Y + g2.setPaint(yColor); + yDelta = (int) Math.round(unit * gforce.getY()); + y = -1 * yDelta + yMiddle; + g2.drawLine(i - 1, previousY, i, y); + g2.setTransform(new AffineTransform()); + previousY = y; + // draw Z + g2.setPaint(zColor); + yDelta = (int) Math.round(unit * gforce.getZ()); + y = -1 * yDelta + yMiddle; + g2.drawLine(i - 1, previousZ, i, y); + g2.setTransform(new AffineTransform()); + previousZ = y; + } - // draw legend - g2.setPaint(xColor); - g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10); - g2.setPaint(yColor); - g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10); - g2.setPaint(zColor); - g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10); + // draw legend + g2.setPaint(xColor); + g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10); + g2.setPaint(yColor); + g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10); + g2.setPaint(zColor); + g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10); - g2.setPaint(lineColor); - g2.drawString("X", 30, getHeight() - 5); - g2.drawString("Y", 85, getHeight() - 5); - g2.drawString("Z", 145, getHeight() - 5); - g2.drawString("0", 2, yMiddle - 5); - g2.drawString("5", 2, 10); - g2.drawString("-5", 2, getHeight() - 15); - // put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } + g2.setPaint(lineColor); + g2.drawString("X", 30, getHeight() - 5); + g2.drawString("Y", 85, getHeight() - 5); + g2.drawString("Z", 145, getHeight() - 5); + g2.drawString("0", 2, yMiddle - 5); + g2.drawString("5", 2, 10); + g2.drawString("-5", 2, getHeight() - 15); + // put offscreen image on the screen + g.drawImage(mImage, 0, 0, null); + } - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } + /** + * check if the mImage variable has been initialized. If it's not the case + * it initializes it with the dimensions of the panel. mImage is for double + * buffering. + */ + private void checkOffScreenImage() { + Dimension d = getSize(); + if (mImage == null || mImage.getWidth(null) != d.width + || mImage.getHeight(null) != d.height) { + mImage = createImage(d.width, d.height); + } + } - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - // nothing - } + public void onButtonsEvent(WiimoteButtonsEvent arg0) { + // nothing + } - public void onIrEvent(IREvent arg0) { - // nothing - } + public void onIrEvent(IREvent arg0) { + // nothing + } - public void onMotionSensingEvent(MotionSensingEvent arg0) { - draw(arg0); - } + public void onMotionSensingEvent(MotionSensingEvent arg0) { + draw(arg0); + } - public void onExpansionEvent(ExpansionEvent arg0) { - draw(arg0); - } + public void onExpansionEvent(ExpansionEvent arg0) { + draw(arg0); + } - public void onStatusEvent(StatusEvent arg0) { - // nothing - } + public void onStatusEvent(StatusEvent arg0) { + // nothing + } - public void onDisconnectionEvent(DisconnectionEvent arg0) { - // Clear points. - values.clear(); - repaint(); - } + public void onDisconnectionEvent(DisconnectionEvent arg0) { + // Clear points. + values.clear(); + repaint(); + } - public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { - // nothing - } + public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { + // nothing + } - public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { - // nothing - } + public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { + // nothing + } - public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { - // nothing - } + public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { + // nothing + } - public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { - // nothing - } + public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { + // nothing + } - public void onClassicControllerInsertedEvent( - ClassicControllerInsertedEvent arg0) { - // nothing - } + public void onClassicControllerInsertedEvent( + ClassicControllerInsertedEvent arg0) { + // nothing + } - public void onClassicControllerRemovedEvent( - ClassicControllerRemovedEvent arg0) { - // nothing - } + public void onClassicControllerRemovedEvent( + ClassicControllerRemovedEvent arg0) { + // nothing + } - private void draw(GenericEvent arg0) { - if (values.size() >= getWidth()) { - // if there are as many values as pixels in the width - // clear points - values.clear(); - } - GForce gforce = getGForceValue(arg0); - if (gforce != null) - values.add(gforce); - repaint(); - } + private void draw(GenericEvent arg0) { + if (values.size() >= getWidth()) { + // if there are as many values as pixels in the width + // clear points + values.clear(); + } + GForce gforce = getGForceValue(arg0); + if (gforce != null) + values.add(gforce); + repaint(); + } - public abstract GForce getGForceValue(GenericEvent e); + public abstract GForce getGForceValue(GenericEvent e); - public Color getBackgroundColor() { - return backgroundColor; - } + public Color getBackgroundColor() { + return backgroundColor; + } - public Color getLineColor() { - return lineColor; - } + public Color getLineColor() { + return lineColor; + } - public Color getXColor() { - return xColor; - } + public Color getXColor() { + return xColor; + } - public Color getYColor() { - return yColor; - } + public Color getYColor() { + return yColor; + } - public Color getZColor() { - return zColor; - } + public Color getZColor() { + return zColor; + } - public void setBackgroundColor(Color backgroundColor) { - this.backgroundColor = backgroundColor; - } + public void setBackgroundColor(Color backgroundColor) { + this.backgroundColor = backgroundColor; + } - public void setLineColor(Color lineColor) { - this.lineColor = lineColor; - } + public void setLineColor(Color lineColor) { + this.lineColor = lineColor; + } - public void setXColor(Color xColor) { - this.xColor = xColor; - } + public void setXColor(Color xColor) { + this.xColor = xColor; + } - public void setYColor(Color yColor) { - this.yColor = yColor; - } + public void setYColor(Color yColor) { + this.yColor = yColor; + } - public void setZColor(Color zColor) { - this.zColor = zColor; - } + public void setZColor(Color zColor) { + this.zColor = zColor; + } - public void clearView() { - values.clear(); - repaint(); - } + public void clearView() { + values.clear(); + repaint(); + } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, - Short.MAX_VALUE)); - layout.setVerticalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, - Short.MAX_VALUE)); - }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, + Short.MAX_VALUE)); + layout.setVerticalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, + Short.MAX_VALUE)); + }// //GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/wiiusej/utils/GForceWiimoteEventPanel.java b/src/main/java/wiiusej/utils/GForceWiimoteEventPanel.java index 1ae710e..0dc1e3e 100644 --- a/src/main/java/wiiusej/utils/GForceWiimoteEventPanel.java +++ b/src/main/java/wiiusej/utils/GForceWiimoteEventPanel.java @@ -27,11 +27,11 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; */ public class GForceWiimoteEventPanel extends GForcePanel { - @Override - public GForce getGForceValue(GenericEvent e) { - if (e instanceof MotionSensingEvent) { - return ((MotionSensingEvent) e).getGforce(); - } - return null; - } + @Override + public GForce getGForceValue(GenericEvent e) { + if (e instanceof MotionSensingEvent) { + return ((MotionSensingEvent) e).getGforce(); + } + return null; + } } diff --git a/src/main/java/wiiusej/utils/IRPanel.java b/src/main/java/wiiusej/utils/IRPanel.java index 9d4cf79..3465c8c 100644 --- a/src/main/java/wiiusej/utils/IRPanel.java +++ b/src/main/java/wiiusej/utils/IRPanel.java @@ -46,230 +46,230 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; */ public class IRPanel extends javax.swing.JPanel implements WiimoteListener { - private static int MAX_NB_POINTS = 4; - private Color color = Color.YELLOW; - private Color backgroundColor = Color.BLACK; - private Color borderColor = Color.BLUE; - private Shape shape; - private Image mImage;// image for double buffering - private int[] xCoordinates; - private int[] yCoordinates; - private int nbPoints = -1; + private static int MAX_NB_POINTS = 4; + private Color color = Color.YELLOW; + private Color backgroundColor = Color.BLACK; + private Color borderColor = Color.BLUE; + private Shape shape; + private Image mImage;// image for double buffering + private int[] xCoordinates; + private int[] yCoordinates; + private int nbPoints = -1; - /** - * Default constructor for IR Panel. Background color : black. IR sources - * color : yellow. Border color of IR sources : blue. Shape of the IR - * sources : circle with a diameter of 10. - */ - public IRPanel() { - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10); - initArrays(); - initComponents(); - } + /** + * Default constructor for IR Panel. Background color : black. IR sources + * color : yellow. Border color of IR sources : blue. Shape of the IR + * sources : circle with a diameter of 10. + */ + public IRPanel() { + shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10); + initArrays(); + initComponents(); + } - /** - * Constructor used to parameterize the IR panel. - * - * @param bgColor - * color. - * @param ptColor - * IR sources color. - * @param bdColor - * border color of IR sources. - * @param sh - * Shape of the IR sources. - */ - public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) { - backgroundColor = bgColor; - color = ptColor; - borderColor = bdColor; - shape = sh; - initArrays(); - initComponents(); - } + /** + * Constructor used to parameterize the IR panel. + * + * @param bgColor + * color. + * @param ptColor + * IR sources color. + * @param bdColor + * border color of IR sources. + * @param sh + * Shape of the IR sources. + */ + public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) { + backgroundColor = bgColor; + color = ptColor; + borderColor = bdColor; + shape = sh; + initArrays(); + initComponents(); + } - private void initArrays() { - xCoordinates = new int[MAX_NB_POINTS]; - yCoordinates = new int[MAX_NB_POINTS]; - for (int i = 0; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } - } + private void initArrays() { + xCoordinates = new int[MAX_NB_POINTS]; + yCoordinates = new int[MAX_NB_POINTS]; + for (int i = 0; i < MAX_NB_POINTS; i++) { + xCoordinates[i] = -1; + yCoordinates[i] = -1; + } + } - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Dimension d = getSize(); + checkOffScreenImage(); + Graphics offG = mImage.getGraphics(); + offG.setColor(backgroundColor); + offG.fillRect(0, 0, d.width, d.height); + Graphics2D g2 = (Graphics2D) mImage.getGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - // draw points - int i = 0; - while (i < nbPoints) { - double x = xCoordinates[i]; - double y = yCoordinates[i]; + // draw points + int i = 0; + while (i < nbPoints) { + double x = xCoordinates[i]; + double y = yCoordinates[i]; - long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0); - long yy = getHeight() - - Math.round((double) getHeight() * y / 768.0); - g2.translate(xx, yy); + long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0); + long yy = getHeight() + - Math.round((double) getHeight() * y / 768.0); + g2.translate(xx, yy); - g2.setPaint(borderColor); - g2.draw(shape); - g2.setPaint(color); - g2.fill(shape); + g2.setPaint(borderColor); + g2.draw(shape); + g2.setPaint(color); + g2.fill(shape); - g2.setTransform(new AffineTransform()); - i++; - } - // put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } + g2.setTransform(new AffineTransform()); + i++; + } + // put offscreen image on the screen + g.drawImage(mImage, 0, 0, null); + } - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } + /** + * check if the mImage variable has been initialized. If it's not the case + * it initializes it with the dimensions of the panel. mImage is for double + * buffering. + */ + private void checkOffScreenImage() { + Dimension d = getSize(); + if (mImage == null || mImage.getWidth(null) != d.width + || mImage.getHeight(null) != d.height) { + mImage = createImage(d.width, d.height); + } + } - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - // nothing - repaint(); - } + public void onButtonsEvent(WiimoteButtonsEvent arg0) { + // nothing + repaint(); + } - public void onIrEvent(IREvent arg0) { - // transfer points - wiiusej.values.IRSource[] points = arg0.getIRPoints(); - nbPoints = points.length; - for (int i = 0; i < points.length; i++) { - xCoordinates[i] = (int) points[i].getRx(); - yCoordinates[i] = (int) points[i].getRy(); - } - for (int i = points.length; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } + public void onIrEvent(IREvent arg0) { + // transfer points + wiiusej.values.IRSource[] points = arg0.getIRPoints(); + nbPoints = points.length; + for (int i = 0; i < points.length; i++) { + xCoordinates[i] = (int) points[i].getRx(); + yCoordinates[i] = (int) points[i].getRy(); + } + for (int i = points.length; i < MAX_NB_POINTS; i++) { + xCoordinates[i] = -1; + yCoordinates[i] = -1; + } - // redraw panel - repaint(); - } + // redraw panel + repaint(); + } - public void onMotionSensingEvent(MotionSensingEvent arg0) { - // nothing - } + public void onMotionSensingEvent(MotionSensingEvent arg0) { + // nothing + } - public void onExpansionEvent(ExpansionEvent e) { - // nothing - } + public void onExpansionEvent(ExpansionEvent e) { + // nothing + } - public void onStatusEvent(StatusEvent arg0) { - // nothing - } + public void onStatusEvent(StatusEvent arg0) { + // nothing + } - public void onDisconnectionEvent(DisconnectionEvent arg0) { - // clear previous points - for (int i = 0; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } - // redraw panel - repaint(); - } + public void onDisconnectionEvent(DisconnectionEvent arg0) { + // clear previous points + for (int i = 0; i < MAX_NB_POINTS; i++) { + xCoordinates[i] = -1; + yCoordinates[i] = -1; + } + // redraw panel + repaint(); + } - public void onNunchukInsertedEvent(NunchukInsertedEvent e) { - // nothing - } + public void onNunchukInsertedEvent(NunchukInsertedEvent e) { + // nothing + } - public void onNunchukRemovedEvent(NunchukRemovedEvent e) { - // nothing - } + public void onNunchukRemovedEvent(NunchukRemovedEvent e) { + // nothing + } - public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { - // nothing - } + public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { + // nothing + } - public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { - // nothing - } + public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { + // nothing + } - public void onClassicControllerInsertedEvent( - ClassicControllerInsertedEvent arg0) { - // nothing - } + public void onClassicControllerInsertedEvent( + ClassicControllerInsertedEvent arg0) { + // nothing + } - public void onClassicControllerRemovedEvent( - ClassicControllerRemovedEvent arg0) { - // nothing - } + public void onClassicControllerRemovedEvent( + ClassicControllerRemovedEvent arg0) { + // nothing + } - public Color getBackgroundColor() { - return backgroundColor; - } + public Color getBackgroundColor() { + return backgroundColor; + } - public Color getBorderColor() { - return borderColor; - } + public Color getBorderColor() { + return borderColor; + } - public Color getColor() { - return color; - } + public Color getColor() { + return color; + } - public Shape getShape() { - return shape; - } + public Shape getShape() { + return shape; + } - public void setBackgroundColor(Color backgroundColor) { - this.backgroundColor = backgroundColor; - } + public void setBackgroundColor(Color backgroundColor) { + this.backgroundColor = backgroundColor; + } - public void setBorderColor(Color borderColor) { - this.borderColor = borderColor; - } + public void setBorderColor(Color borderColor) { + this.borderColor = borderColor; + } - public void setColor(Color color) { - this.color = color; - } + public void setColor(Color color) { + this.color = color; + } - public void setShape(Shape shape) { - this.shape = shape; - } + public void setShape(Shape shape) { + this.shape = shape; + } - public void clearView() { - initArrays(); - repaint(); - } + public void clearView() { + initArrays(); + repaint(); + } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, - Short.MAX_VALUE)); - layout.setVerticalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, - Short.MAX_VALUE)); - }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, + Short.MAX_VALUE)); + layout.setVerticalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, + Short.MAX_VALUE)); + }// //GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/wiiusej/utils/JoystickEventPanel.java b/src/main/java/wiiusej/utils/JoystickEventPanel.java index 2883216..ead8493 100644 --- a/src/main/java/wiiusej/utils/JoystickEventPanel.java +++ b/src/main/java/wiiusej/utils/JoystickEventPanel.java @@ -45,204 +45,204 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; * @author guiguito */ public abstract class JoystickEventPanel extends javax.swing.JPanel implements - WiimoteListener { + WiimoteListener { - private Image mImage;// image for double buffering - private Color backgroundColor = Color.BLACK; - private Color borderColor = Color.RED; - private Color pointColor = Color.RED; - private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 30, 30); - private JoystickEvent lastJoystickEvent = null; + private Image mImage;// image for double buffering + private Color backgroundColor = Color.BLACK; + private Color borderColor = Color.RED; + private Color pointColor = Color.RED; + private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 30, 30); + private JoystickEvent lastJoystickEvent = null; - /** Creates new form JoystickPanel */ - public JoystickEventPanel() { - initComponents(); - } + /** Creates new form JoystickPanel */ + public JoystickEventPanel() { + initComponents(); + } - /** - * Constructor used to choose the colors used by the JoystickPanel. - * - * @param bgColor - * background color. - * @param pColor - * point color. - * @param bdColor - * border color for the shape. - * @param sh - * shape of what is drawn. - */ - public JoystickEventPanel(Color bgColor, Color pColor, Color bdColor, - Shape sh) { - backgroundColor = bgColor; - pointColor = pColor; - shape = sh; - borderColor = bdColor; - initComponents(); - } + /** + * Constructor used to choose the colors used by the JoystickPanel. + * + * @param bgColor + * background color. + * @param pColor + * point color. + * @param bdColor + * border color for the shape. + * @param sh + * shape of what is drawn. + */ + public JoystickEventPanel(Color bgColor, Color pColor, Color bdColor, + Shape sh) { + backgroundColor = bgColor; + pointColor = pColor; + shape = sh; + borderColor = bdColor; + initComponents(); + } - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - g2.setTransform(new AffineTransform()); + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Dimension d = getSize(); + checkOffScreenImage(); + Graphics offG = mImage.getGraphics(); + offG.setColor(backgroundColor); + offG.fillRect(0, 0, d.width, d.height); + Graphics2D g2 = (Graphics2D) mImage.getGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2.setTransform(new AffineTransform()); - // compute center - int xCenter = (int) Math.round(d.getWidth() / 2.0); - int yCenter = (int) Math.round(d.getHeight() / 2.0); + // compute center + int xCenter = (int) Math.round(d.getWidth() / 2.0); + int yCenter = (int) Math.round(d.getHeight() / 2.0); - // compute coordinates - if (lastJoystickEvent != null) { - double xAng = Math.sin(lastJoystickEvent.getAngle() * Math.PI - / 180.0) - * lastJoystickEvent.getMagnitude(); - double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI - / 180.0) - * lastJoystickEvent.getMagnitude(); - int halfWidth = (int) Math.round(shape.getBounds().getWidth() / 2); - int halHeight = (int) Math.round(shape.getBounds().getHeight() / 2); - int xAmplitude = (int) Math.round(xCenter - shape.getBounds().getWidth()); - int yAmplitude = (int) Math.round(xCenter - shape.getBounds().getHeight()); - int xShift = (int) Math.round(xAng * xAmplitude); - int yShift = (int) Math.round(yAng * yAmplitude); - int x = xCenter + xShift - halfWidth; - int y = yCenter - yShift - halHeight; - // shape - g2.translate(x, y); - g2.setPaint(borderColor); - g2.draw(shape); - g2.setPaint(pointColor); - g2.fill(shape); - } - // put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } + // compute coordinates + if (lastJoystickEvent != null) { + double xAng = Math.sin(lastJoystickEvent.getAngle() * Math.PI + / 180.0) + * lastJoystickEvent.getMagnitude(); + double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI + / 180.0) + * lastJoystickEvent.getMagnitude(); + int halfWidth = (int) Math.round(shape.getBounds().getWidth() / 2); + int halHeight = (int) Math.round(shape.getBounds().getHeight() / 2); + int xAmplitude = (int) Math.round(xCenter - shape.getBounds().getWidth()); + int yAmplitude = (int) Math.round(xCenter - shape.getBounds().getHeight()); + int xShift = (int) Math.round(xAng * xAmplitude); + int yShift = (int) Math.round(yAng * yAmplitude); + int x = xCenter + xShift - halfWidth; + int y = yCenter - yShift - halHeight; + // shape + g2.translate(x, y); + g2.setPaint(borderColor); + g2.draw(shape); + g2.setPaint(pointColor); + g2.fill(shape); + } + // put offscreen image on the screen + g.drawImage(mImage, 0, 0, null); + } - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } + /** + * check if the mImage variable has been initialized. If it's not the case + * it initializes it with the dimensions of the panel. mImage is for double + * buffering. + */ + private void checkOffScreenImage() { + Dimension d = getSize(); + if (mImage == null || mImage.getWidth(null) != d.width + || mImage.getHeight(null) != d.height) { + mImage = createImage(d.width, d.height); + } + } - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - // nothing - } + public void onButtonsEvent(WiimoteButtonsEvent arg0) { + // nothing + } - public void onIrEvent(IREvent arg0) { - // nothing - } + public void onIrEvent(IREvent arg0) { + // nothing + } - public void onMotionSensingEvent(MotionSensingEvent arg0) { - // nothing - } + public void onMotionSensingEvent(MotionSensingEvent arg0) { + // nothing + } - public void onExpansionEvent(ExpansionEvent arg0) { - JoystickEvent joy = getJoystickEvent(arg0); - if (joy != null) { - lastJoystickEvent = joy; - } - repaint(); - } + public void onExpansionEvent(ExpansionEvent arg0) { + JoystickEvent joy = getJoystickEvent(arg0); + if (joy != null) { + lastJoystickEvent = joy; + } + repaint(); + } - public void onStatusEvent(StatusEvent arg0) { - // nothing - } + public void onStatusEvent(StatusEvent arg0) { + // nothing + } - public void onDisconnectionEvent(DisconnectionEvent arg0) { - // nothing - } + public void onDisconnectionEvent(DisconnectionEvent arg0) { + // nothing + } - public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { - // nothing - } + public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { + // nothing + } - public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { - // nothing - } + public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { + // nothing + } - public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { - // nothing - } + public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { + // nothing + } - public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { - // nothing - } + public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { + // nothing + } - public void onClassicControllerInsertedEvent( - ClassicControllerInsertedEvent arg0) { - // nothing - } + public void onClassicControllerInsertedEvent( + ClassicControllerInsertedEvent arg0) { + // nothing + } - public void onClassicControllerRemovedEvent( - ClassicControllerRemovedEvent arg0) { - // nothing - } + public void onClassicControllerRemovedEvent( + ClassicControllerRemovedEvent arg0) { + // nothing + } - public Color getBackgroundColor() { - return backgroundColor; - } + public Color getBackgroundColor() { + return backgroundColor; + } - public Color getPointColor() { - return pointColor; - } + public Color getPointColor() { + return pointColor; + } - public Color getBorderColor() { - return borderColor; - } + public Color getBorderColor() { + return borderColor; + } - public Shape getShape() { - return shape; - } + public Shape getShape() { + return shape; + } - public void setBackgroundColor(Color backgroundColor) { - this.backgroundColor = backgroundColor; - } + public void setBackgroundColor(Color backgroundColor) { + this.backgroundColor = backgroundColor; + } - public void setPointColor(Color pointColor) { - this.pointColor = pointColor; - } + public void setPointColor(Color pointColor) { + this.pointColor = pointColor; + } - public void setBorderColor(Color borderColor) { - this.borderColor = borderColor; - } + public void setBorderColor(Color borderColor) { + this.borderColor = borderColor; + } - public void setShape(Shape shape) { - this.shape = shape; - } + public void setShape(Shape shape) { + this.shape = shape; + } - public abstract JoystickEvent getJoystickEvent(ExpansionEvent e); + public abstract JoystickEvent getJoystickEvent(ExpansionEvent e); - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, - Short.MAX_VALUE)); - layout.setVerticalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, - Short.MAX_VALUE)); - }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, + Short.MAX_VALUE)); + layout.setVerticalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, + Short.MAX_VALUE)); + }// //GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/wiiusej/utils/NunchukJoystickEventPanel.java b/src/main/java/wiiusej/utils/NunchukJoystickEventPanel.java index 9d088bc..b62d433 100644 --- a/src/main/java/wiiusej/utils/NunchukJoystickEventPanel.java +++ b/src/main/java/wiiusej/utils/NunchukJoystickEventPanel.java @@ -28,11 +28,11 @@ import wiiusej.wiiusejevents.physicalevents.NunchukEvent; */ public class NunchukJoystickEventPanel extends JoystickEventPanel { - @Override - public JoystickEvent getJoystickEvent(ExpansionEvent e) { - if (e instanceof NunchukEvent) { - return ((NunchukEvent) e).getNunchukJoystickEvent(); - } - return null; - } + @Override + public JoystickEvent getJoystickEvent(ExpansionEvent e) { + if (e instanceof NunchukEvent) { + return ((NunchukEvent) e).getNunchukJoystickEvent(); + } + return null; + } } diff --git a/src/main/java/wiiusej/utils/OrientationExpansionEventPanel.java b/src/main/java/wiiusej/utils/OrientationExpansionEventPanel.java index f5e3856..ba3a5fb 100644 --- a/src/main/java/wiiusej/utils/OrientationExpansionEventPanel.java +++ b/src/main/java/wiiusej/utils/OrientationExpansionEventPanel.java @@ -27,12 +27,12 @@ import wiiusej.wiiusejevents.physicalevents.NunchukEvent; */ public class OrientationExpansionEventPanel extends OrientationPanel { - @Override - public Orientation getOrientationValue(GenericEvent e) { - if (e instanceof NunchukEvent) { - return ((NunchukEvent) e).getNunchukMotionSensingEvent() - .getOrientation(); - } - return null; - } + @Override + public Orientation getOrientationValue(GenericEvent e) { + if (e instanceof NunchukEvent) { + return ((NunchukEvent) e).getNunchukMotionSensingEvent() + .getOrientation(); + } + return null; + } } diff --git a/src/main/java/wiiusej/utils/OrientationPanel.java b/src/main/java/wiiusej/utils/OrientationPanel.java index 839fdfd..15c36a9 100644 --- a/src/main/java/wiiusej/utils/OrientationPanel.java +++ b/src/main/java/wiiusej/utils/OrientationPanel.java @@ -47,259 +47,259 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; * @author guiguito */ public abstract class OrientationPanel extends javax.swing.JPanel implements - WiimoteListener { + WiimoteListener { - private Image mImage;// image for double buffering - private Color rollColor = Color.RED; - private Color pitchColor = Color.GREEN; - private Color yawColor = Color.BLUE; - private Color backgroundColor = Color.WHITE; - private Color lineColor = Color.BLACK; - private ArrayList values = new ArrayList(); + private Image mImage;// image for double buffering + private Color rollColor = Color.RED; + private Color pitchColor = Color.GREEN; + private Color yawColor = Color.BLUE; + private Color backgroundColor = Color.WHITE; + private Color lineColor = Color.BLACK; + private ArrayList values = new ArrayList(); - /** - * Default constructor. Background color : White. Roll color : Red. Pitch - * color : Green. Yaw color : Blue. - */ - public OrientationPanel() { - initComponents(); - } + /** + * Default constructor. Background color : White. Roll color : Red. Pitch + * color : Green. Yaw color : Blue. + */ + public OrientationPanel() { + initComponents(); + } - /** - * Constructor used to choose the colors used by the OrientationPanel. - * - * @param bgColor - * background color. - * @param rColor - * roll color. - * @param pColor - * pitch color. - * @param yColor - * yaw color. - * @param lColor - * line color. - */ - public OrientationPanel(Color bgColor, Color rColor, Color pColor, - Color yColor, Color lColor) { - backgroundColor = bgColor; - rollColor = rColor; - pitchColor = pColor; - yawColor = yColor; - lineColor = lColor; - initComponents(); - } + /** + * Constructor used to choose the colors used by the OrientationPanel. + * + * @param bgColor + * background color. + * @param rColor + * roll color. + * @param pColor + * pitch color. + * @param yColor + * yaw color. + * @param lColor + * line color. + */ + public OrientationPanel(Color bgColor, Color rColor, Color pColor, + Color yColor, Color lColor) { + backgroundColor = bgColor; + rollColor = rColor; + pitchColor = pColor; + yawColor = yColor; + lineColor = lColor; + initComponents(); + } - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Dimension d = getSize(); + checkOffScreenImage(); + Graphics offG = mImage.getGraphics(); + offG.setColor(backgroundColor); + offG.fillRect(0, 0, d.width, d.height); + Graphics2D g2 = (Graphics2D) mImage.getGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - // draw medium line - double yMiddleFloat = getHeight() / 2.0; - int yMiddle = (int) Math.round(yMiddleFloat); + // draw medium line + double yMiddleFloat = getHeight() / 2.0; + int yMiddle = (int) Math.round(yMiddleFloat); - g2.setPaint(lineColor); - g2.drawLine(0, yMiddle, getWidth(), yMiddle); + g2.setPaint(lineColor); + g2.drawLine(0, yMiddle, getWidth(), yMiddle); - Orientation[] valuesArray = values.toArray(new Orientation[0]); - double unit = yMiddleFloat / 180.0; - int previousRoll = 0; - int previousPitch = 0; - int previousYaw = 0; - // draw curves - for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { - Orientation orientation = valuesArray[i]; - // draw roll - g2.setPaint(rollColor); - int yDelta = (int) Math.round(unit * orientation.getRoll()); - int y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousRoll, i, y); - g2.setTransform(new AffineTransform()); - previousRoll = y; - // draw pitch - g2.setPaint(pitchColor); - yDelta = (int) Math.round(unit * orientation.getPitch()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousPitch, i, y); - g2.setTransform(new AffineTransform()); - previousPitch = y; - // draw yaw - g2.setPaint(yawColor); - yDelta = (int) Math.round(unit * orientation.getYaw()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousYaw, i, y); - g2.setTransform(new AffineTransform()); - previousYaw = y; - } + Orientation[] valuesArray = values.toArray(new Orientation[0]); + double unit = yMiddleFloat / 180.0; + int previousRoll = 0; + int previousPitch = 0; + int previousYaw = 0; + // draw curves + for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { + Orientation orientation = valuesArray[i]; + // draw roll + g2.setPaint(rollColor); + int yDelta = (int) Math.round(unit * orientation.getRoll()); + int y = -1 * yDelta + yMiddle; + g2.drawLine(i - 1, previousRoll, i, y); + g2.setTransform(new AffineTransform()); + previousRoll = y; + // draw pitch + g2.setPaint(pitchColor); + yDelta = (int) Math.round(unit * orientation.getPitch()); + y = -1 * yDelta + yMiddle; + g2.drawLine(i - 1, previousPitch, i, y); + g2.setTransform(new AffineTransform()); + previousPitch = y; + // draw yaw + g2.setPaint(yawColor); + yDelta = (int) Math.round(unit * orientation.getYaw()); + y = -1 * yDelta + yMiddle; + g2.drawLine(i - 1, previousYaw, i, y); + g2.setTransform(new AffineTransform()); + previousYaw = y; + } - // draw legend - g2.setPaint(rollColor); - g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10); - g2.setPaint(pitchColor); - g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10); - g2.setPaint(yawColor); - g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10); + // draw legend + g2.setPaint(rollColor); + g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10); + g2.setPaint(pitchColor); + g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10); + g2.setPaint(yawColor); + g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10); - g2.setPaint(lineColor); - g2.drawString("Roll", 30, getHeight() - 5); - g2.drawString("Pitch", 85, getHeight() - 5); - g2.drawString("Yaw", 145, getHeight() - 5); - g2.drawString("0", 2, yMiddle - 5); - g2.drawString("180", 2, 10); - g2.drawString("-180", 2, getHeight() - 15); - // put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } + g2.setPaint(lineColor); + g2.drawString("Roll", 30, getHeight() - 5); + g2.drawString("Pitch", 85, getHeight() - 5); + g2.drawString("Yaw", 145, getHeight() - 5); + g2.drawString("0", 2, yMiddle - 5); + g2.drawString("180", 2, 10); + g2.drawString("-180", 2, getHeight() - 15); + // put offscreen image on the screen + g.drawImage(mImage, 0, 0, null); + } - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } + /** + * check if the mImage variable has been initialized. If it's not the case + * it initializes it with the dimensions of the panel. mImage is for double + * buffering. + */ + private void checkOffScreenImage() { + Dimension d = getSize(); + if (mImage == null || mImage.getWidth(null) != d.width + || mImage.getHeight(null) != d.height) { + mImage = createImage(d.width, d.height); + } + } - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - // nothing - } + public void onButtonsEvent(WiimoteButtonsEvent arg0) { + // nothing + } - public void onIrEvent(IREvent arg0) { - // nothing - } + public void onIrEvent(IREvent arg0) { + // nothing + } - public void onMotionSensingEvent(MotionSensingEvent arg0) { - draw(arg0); - } + public void onMotionSensingEvent(MotionSensingEvent arg0) { + draw(arg0); + } - public void onExpansionEvent(ExpansionEvent arg0) { - draw(arg0); - } + public void onExpansionEvent(ExpansionEvent arg0) { + draw(arg0); + } - public void onStatusEvent(StatusEvent arg0) { - // nothing - } + public void onStatusEvent(StatusEvent arg0) { + // nothing + } - public void onDisconnectionEvent(DisconnectionEvent arg0) { - // Clear points. - values.clear(); - repaint(); - } + public void onDisconnectionEvent(DisconnectionEvent arg0) { + // Clear points. + values.clear(); + repaint(); + } - public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { - // nothing - } + public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { + // nothing + } - public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { - // nothing - } + public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { + // nothing + } - public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { - // nothing - } + public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { + // nothing + } - public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { - // nothing - } + public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { + // nothing + } - public void onClassicControllerInsertedEvent( - ClassicControllerInsertedEvent arg0) { - // nothing - } + public void onClassicControllerInsertedEvent( + ClassicControllerInsertedEvent arg0) { + // nothing + } - public void onClassicControllerRemovedEvent( - ClassicControllerRemovedEvent arg0) { - // nothing - } + public void onClassicControllerRemovedEvent( + ClassicControllerRemovedEvent arg0) { + // nothing + } - private void draw(GenericEvent arg0) { - if (values.size() >= getWidth()) { - // if there are as many values as pixels in the width - // clear points - values.clear(); - } - Orientation orientation = getOrientationValue(arg0); - if (orientation != null) - values.add(orientation); - repaint(); - } + private void draw(GenericEvent arg0) { + if (values.size() >= getWidth()) { + // if there are as many values as pixels in the width + // clear points + values.clear(); + } + Orientation orientation = getOrientationValue(arg0); + if (orientation != null) + values.add(orientation); + repaint(); + } - public abstract Orientation getOrientationValue(GenericEvent e); + public abstract Orientation getOrientationValue(GenericEvent e); - public Color getBackgroundColor() { - return backgroundColor; - } + public Color getBackgroundColor() { + return backgroundColor; + } - public Color getLineColor() { - return lineColor; - } + public Color getLineColor() { + return lineColor; + } - public Color getPitchColor() { - return pitchColor; - } + public Color getPitchColor() { + return pitchColor; + } - public Color getRollColor() { - return rollColor; - } + public Color getRollColor() { + return rollColor; + } - public Color getYawColor() { - return yawColor; - } + public Color getYawColor() { + return yawColor; + } - public void setBackgroundColor(Color backgroundColor) { - this.backgroundColor = backgroundColor; - } + public void setBackgroundColor(Color backgroundColor) { + this.backgroundColor = backgroundColor; + } - public void setLineColor(Color lineColor) { - this.lineColor = lineColor; - } + public void setLineColor(Color lineColor) { + this.lineColor = lineColor; + } - public void setPitchColor(Color pitchColor) { - this.pitchColor = pitchColor; - } + public void setPitchColor(Color pitchColor) { + this.pitchColor = pitchColor; + } - public void setRollColor(Color rollColor) { - this.rollColor = rollColor; - } + public void setRollColor(Color rollColor) { + this.rollColor = rollColor; + } - public void setYawColor(Color yawColor) { - this.yawColor = yawColor; - } + public void setYawColor(Color yawColor) { + this.yawColor = yawColor; + } - public void clearView() { - values.clear(); - repaint(); - } + public void clearView() { + values.clear(); + repaint(); + } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, - Short.MAX_VALUE)); - layout.setVerticalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, - Short.MAX_VALUE)); - }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, + Short.MAX_VALUE)); + layout.setVerticalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, + Short.MAX_VALUE)); + }// //GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/wiiusej/utils/OrientationWiimoteEventPanel.java b/src/main/java/wiiusej/utils/OrientationWiimoteEventPanel.java index e38f3c9..239cbc0 100644 --- a/src/main/java/wiiusej/utils/OrientationWiimoteEventPanel.java +++ b/src/main/java/wiiusej/utils/OrientationWiimoteEventPanel.java @@ -27,12 +27,12 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; */ public class OrientationWiimoteEventPanel extends OrientationPanel { - @Override - public Orientation getOrientationValue(GenericEvent e) { - if (e instanceof MotionSensingEvent) { - return ((MotionSensingEvent) e).getOrientation(); - } - return null; - } + @Override + public Orientation getOrientationValue(GenericEvent e) { + if (e instanceof MotionSensingEvent) { + return ((MotionSensingEvent) e).getOrientation(); + } + return null; + } } diff --git a/src/main/java/wiiusej/values/GForce.java b/src/main/java/wiiusej/values/GForce.java index 45be3dc..60a4390 100644 --- a/src/main/java/wiiusej/values/GForce.java +++ b/src/main/java/wiiusej/values/GForce.java @@ -23,58 +23,58 @@ package wiiusej.values; */ public class GForce { - private float x; - private float y; - private float z; + private float x; + private float y; + private float z; - /** - * Default constructor; - */ - public GForce() { - x = 0; - y = 0; - z = 0; - } + /** + * Default constructor; + */ + public GForce() { + x = 0; + y = 0; + z = 0; + } - /** - * Constructor with gravity force on each axis. - * - * @param xx - * x value - * @param yy - * x value - * @param zz - * x value - */ - public GForce(float xx, float yy, float zz) { - x = xx; - y = yy; - z = zz; - } + /** + * Constructor with gravity force on each axis. + * + * @param xx + * x value + * @param yy + * x value + * @param zz + * x value + */ + public GForce(float xx, float yy, float zz) { + x = xx; + y = yy; + z = zz; + } - /** - * @return the x - */ - public float getX() { - return x; - } + /** + * @return the x + */ + public float getX() { + return x; + } - /** - * @return the y - */ - public float getY() { - return y; - } + /** + * @return the y + */ + public float getY() { + return y; + } - /** - * @return the z - */ - public float getZ() { - return z; - } + /** + * @return the z + */ + public float getZ() { + return z; + } - @Override - public String toString() { - return "Gravity force : (" + x + ", " + y + "," + z + ")"; - } + @Override + public String toString() { + return "Gravity force : (" + x + ", " + y + "," + z + ")"; + } } diff --git a/src/main/java/wiiusej/values/IRSource.java b/src/main/java/wiiusej/values/IRSource.java index fc4790a..aabe8d7 100644 --- a/src/main/java/wiiusej/values/IRSource.java +++ b/src/main/java/wiiusej/values/IRSource.java @@ -23,84 +23,84 @@ package wiiusej.values; */ public class IRSource { - private int x; - private int y; - private short rx; - private short ry; - private short size; + private int x; + private int y; + private short rx; + private short ry; + private short size; - /** - * Build an IR source with all details. - * - * @param xx - * xx interpolated coordinates. - * @param yy - * yy interpolated coordinates. - * @param rxx - * raw X coordinate (0-1023). - * @param ryy - * raw Y coordinate (0-1023). - * @param si - * size of the IR dot (0-15). - */ - public IRSource(int xx, int yy, short rxx, short ryy, short si) { - x = xx; - y = yy; - rx = rxx; - ry = ryy; - size = si; - } + /** + * Build an IR source with all details. + * + * @param xx + * xx interpolated coordinates. + * @param yy + * yy interpolated coordinates. + * @param rxx + * raw X coordinate (0-1023). + * @param ryy + * raw Y coordinate (0-1023). + * @param si + * size of the IR dot (0-15). + */ + public IRSource(int xx, int yy, short rxx, short ryy, short si) { + x = xx; + y = yy; + rx = rxx; + ry = ryy; + size = si; + } - /** - * Return x interpolated coordinates. - * - * @return the x - */ - public int getX() { - return x; - } + /** + * Return x interpolated coordinates. + * + * @return the x + */ + public int getX() { + return x; + } - /** - * Return y interpolated coordinates. - * - * @return the y - */ - public int getY() { - return y; - } + /** + * Return y interpolated coordinates. + * + * @return the y + */ + public int getY() { + return y; + } - /** - * Return raw X coordinate (0-1023). - * - * @return the rx - */ - public short getRx() { - return rx; - } + /** + * Return raw X coordinate (0-1023). + * + * @return the rx + */ + public short getRx() { + return rx; + } - /** - * Return raw Y coordinate (0-1023). - * - * @return the ry - */ - public short getRy() { - return ry; - } + /** + * Return raw Y coordinate (0-1023). + * + * @return the ry + */ + public short getRy() { + return ry; + } - /** - * Return size of the IR dot (0-15). - * - * @return the size - */ - public short getSize() { - return size; - } + /** + * Return size of the IR dot (0-15). + * + * @return the size + */ + public short getSize() { + return size; + } - @Override - public String toString() { - return "Interpolated coordinates (" + x + "," + y - + "), Raw coordinates(" + rx + "," + ry + "), source size : " - + size + ")"; - } + @Override + public String toString() { + return "Interpolated coordinates (" + x + "," + y + + "), Raw coordinates(" + rx + "," + ry + "), source size : " + + size + ")"; + } } diff --git a/src/main/java/wiiusej/values/Orientation.java b/src/main/java/wiiusej/values/Orientation.java index 9513e30..f817b92 100644 --- a/src/main/java/wiiusej/values/Orientation.java +++ b/src/main/java/wiiusej/values/Orientation.java @@ -23,95 +23,95 @@ package wiiusej.values; */ public class Orientation { - private float roll; - private float pitch; - private float yaw; - private float a_roll; - private float a_pitch; + private float roll; + private float pitch; + private float yaw; + private float a_roll; + private float a_pitch; - /** - * Default constructor. - */ - public Orientation() { - roll = 0; - pitch = 0; - yaw = 0; - a_roll = 0; - a_pitch = 0; - } + /** + * Default constructor. + */ + public Orientation() { + roll = 0; + pitch = 0; + yaw = 0; + a_roll = 0; + a_pitch = 0; + } - /** - * Contructor with raw, pitch , yaw. - * - * @param r - * roll (can be smoothed) - * @param p - * pitch (can be smoothed) - * @param y - * yaw - * @param ar - * absolute roll - * @param ap - * absolute pitch - */ - public Orientation(float r, float p, float y, float ar, float ap) { - roll = r; - pitch = p; - yaw = y; - a_roll = ar; - a_pitch = ap; - } + /** + * Contructor with raw, pitch , yaw. + * + * @param r + * roll (can be smoothed) + * @param p + * pitch (can be smoothed) + * @param y + * yaw + * @param ar + * absolute roll + * @param ap + * absolute pitch + */ + public Orientation(float r, float p, float y, float ar, float ap) { + roll = r; + pitch = p; + yaw = y; + a_roll = ar; + a_pitch = ap; + } - /** - * Get the roll (can be smoothed). - * - * @return the roll - */ - public float getRoll() { - return roll; - } + /** + * Get the roll (can be smoothed). + * + * @return the roll + */ + public float getRoll() { + return roll; + } - /** - * Get the pitch (can be smoothed). - * - * @return the pitch - */ - public float getPitch() { - return pitch; - } + /** + * Get the pitch (can be smoothed). + * + * @return the pitch + */ + public float getPitch() { + return pitch; + } - /** - * Get the yaw. - * - * @return the yaw - */ - public float getYaw() { - return yaw; - } + /** + * Get the yaw. + * + * @return the yaw + */ + public float getYaw() { + return yaw; + } - /** - * Get absolute roll (can not be smoothed). - * - * @return the a_roll - */ - public float getARoll() { - return a_roll; - } + /** + * Get absolute roll (can not be smoothed). + * + * @return the a_roll + */ + public float getARoll() { + return a_roll; + } - /** - * Get absolute pitch (can not be smoothed). - * - * @return the a_pitch - */ - public float getAPitch() { - return a_pitch; - } + /** + * Get absolute pitch (can not be smoothed). + * + * @return the a_pitch + */ + public float getAPitch() { + return a_pitch; + } - @Override - public String toString() { - return "Orientation : (roll: " + roll + ", pitch: " + pitch + ", yaw: " - + yaw + ", absolute roll: " + a_roll + ", absolute pitch: " - + a_pitch + ")"; - } + @Override + public String toString() { + return "Orientation : (roll: " + roll + ", pitch: " + pitch + ", yaw: " + + yaw + ", absolute roll: " + a_roll + ", absolute pitch: " + + a_pitch + ")"; + } } diff --git a/src/main/java/wiiusej/values/RawAcceleration.java b/src/main/java/wiiusej/values/RawAcceleration.java index 249a097..69d965a 100644 --- a/src/main/java/wiiusej/values/RawAcceleration.java +++ b/src/main/java/wiiusej/values/RawAcceleration.java @@ -23,59 +23,59 @@ package wiiusej.values; */ public class RawAcceleration { - private short x; - private short y; - private short z; + private short x; + private short y; + private short z; - /** - * Default constructor; - */ - public RawAcceleration() { - x = 0; - y = 0; - z = 0; - } + /** + * Default constructor; + */ + public RawAcceleration() { + x = 0; + y = 0; + z = 0; + } - /** - * Constructor with raw acceleration on each axis. - * - * @param xx - * x value - * @param yy - * x value - * @param zz - * x value - */ - public RawAcceleration(short xx, short yy, short zz) { - x = xx; - y = yy; - z = zz; - } + /** + * Constructor with raw acceleration on each axis. + * + * @param xx + * x value + * @param yy + * x value + * @param zz + * x value + */ + public RawAcceleration(short xx, short yy, short zz) { + x = xx; + y = yy; + z = zz; + } - /** - * @return the x - */ - public short getX() { - return x; - } + /** + * @return the x + */ + public short getX() { + return x; + } - /** - * @return the y - */ - public short getY() { - return y; - } + /** + * @return the y + */ + public short getY() { + return y; + } - /** - * @return the z - */ - public short getZ() { - return z; - } + /** + * @return the z + */ + public short getZ() { + return z; + } - @Override - public String toString() { - return "Raw acceleration : (" + x + ", " + y + "," + z + ")"; - } + @Override + public String toString() { + return "Raw acceleration : (" + x + ", " + y + "," + z + ")"; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/GenericEvent.java b/src/main/java/wiiusej/wiiusejevents/GenericEvent.java index a44d664..c25b455 100644 --- a/src/main/java/wiiusej/wiiusejevents/GenericEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/GenericEvent.java @@ -22,38 +22,38 @@ package wiiusej.wiiusejevents; * @author guiguito */ public abstract class GenericEvent { - - /* ID */ - private int wiimoteId = -1; - - /** - * Construct the WiiUseApiEvent setting up the id. - * - * @param id - * the Wiimote id - */ - public GenericEvent(int id) { - wiimoteId = id; - } - - /** - * Get Wiimote ID - * - * @return the wiimote id. - */ - public int getWiimoteId() { - return wiimoteId; - } - - /** - * Set Wiimote ID - * - * @param wiimoteId - * id of the wiimote - */ - void setWiimoteId(int wiimoteId) { - this.wiimoteId = wiimoteId; - } - - public abstract String toString(); + + /* ID */ + private int wiimoteId = -1; + + /** + * Construct the WiiUseApiEvent setting up the id. + * + * @param id + * the Wiimote id + */ + public GenericEvent(int id) { + wiimoteId = id; + } + + /** + * Get Wiimote ID + * + * @return the wiimote id. + */ + public int getWiimoteId() { + return wiimoteId; + } + + /** + * Set Wiimote ID + * + * @param wiimoteId + * id of the wiimote + */ + void setWiimoteId(int wiimoteId) { + this.wiimoteId = wiimoteId; + } + + public abstract String toString(); } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/ButtonsEvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/ButtonsEvent.java index 2e12a22..3a547d4 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/ButtonsEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/ButtonsEvent.java @@ -25,104 +25,104 @@ import wiiusej.wiiusejevents.GenericEvent; */ public abstract class ButtonsEvent extends GenericEvent { - /* Buttons */ - private short buttonsJustPressed = 0; - private short buttonsJustReleased = 0; - private short buttonsHeld = 0; + /* Buttons */ + private short buttonsJustPressed = 0; + private short buttonsJustReleased = 0; + private short buttonsHeld = 0; - /** - * Constructor of the button Event. - * - * @param id - * id of the wiimote concerned. - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just held. - */ - public ButtonsEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld) { - super(id); - setAllButtons(buttonsJustPressed, buttonsJustReleased, buttonsHeld); - } + /** + * Constructor of the button Event. + * + * @param id + * id of the wiimote concerned. + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just held. + */ + public ButtonsEvent(int id, short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld) { + super(id); + setAllButtons(buttonsJustPressed, buttonsJustReleased, buttonsHeld); + } - /** - * Set all buttons in one method. - * - * @param buttonsJustPressed - * @param buttonsJustReleased - * @param buttonsHeld - */ - private void setAllButtons(short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld) { - this.buttonsJustPressed = buttonsJustPressed; - this.buttonsJustReleased = buttonsJustReleased; - this.buttonsHeld = buttonsHeld; - } + /** + * Set all buttons in one method. + * + * @param buttonsJustPressed + * @param buttonsJustReleased + * @param buttonsHeld + */ + private void setAllButtons(short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld) { + this.buttonsJustPressed = buttonsJustPressed; + this.buttonsJustReleased = buttonsJustReleased; + this.buttonsHeld = buttonsHeld; + } - /** - * Get the short storing the buttons just pressed - * - * @return the short storing the buttons just pressed - */ - public short getButtonsJustPressed() { - return buttonsJustPressed; - } + /** + * Get the short storing the buttons just pressed + * + * @return the short storing the buttons just pressed + */ + public short getButtonsJustPressed() { + return buttonsJustPressed; + } - /** - * Get the short storing the buttons just released - * - * @return the short storing the buttons just released - */ - public short getButtonsJustReleased() { - return buttonsJustReleased; - } + /** + * Get the short storing the buttons just released + * + * @return the short storing the buttons just released + */ + public short getButtonsJustReleased() { + return buttonsJustReleased; + } - /** - * get the short storing the buttons held - * - * @return the short storing the buttons held - */ - public short getButtonsHeld() { - return buttonsHeld; - } + /** + * get the short storing the buttons held + * + * @return the short storing the buttons held + */ + public short getButtonsHeld() { + return buttonsHeld; + } - /** **************** BUTTONS Methods ***************** */ - /* generic button functions */ + /** **************** BUTTONS Methods ***************** */ + /* generic button functions */ - protected boolean buttonTest(int buttonBitsDefinition, int buttons) { - return (buttons & buttonBitsDefinition) == buttonBitsDefinition; - } + protected boolean buttonTest(int buttonBitsDefinition, int buttons) { + return (buttons & buttonBitsDefinition) == buttonBitsDefinition; + } - protected boolean isButtonJustPressed(int buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustPressed) - && !isButtonHeld(buttonBitsDefinition); - } + protected boolean isButtonJustPressed(int buttonBitsDefinition) { + return buttonTest(buttonBitsDefinition, buttonsJustPressed) + && !isButtonHeld(buttonBitsDefinition); + } - protected boolean isButtonJustReleased(int buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustReleased); - } + protected boolean isButtonJustReleased(int buttonBitsDefinition) { + return buttonTest(buttonBitsDefinition, buttonsJustReleased); + } - protected boolean isButtonHeld(int buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsHeld); - } + protected boolean isButtonHeld(int buttonBitsDefinition) { + return buttonTest(buttonBitsDefinition, buttonsHeld); + } - protected boolean isButtonPressed(int buttonBitsDefinition) { - return isButtonHeld(buttonBitsDefinition) - || isButtonJustPressed(buttonBitsDefinition); - } + protected boolean isButtonPressed(int buttonBitsDefinition) { + return isButtonHeld(buttonBitsDefinition) + || isButtonJustPressed(buttonBitsDefinition); + } - @Override - public String toString() { - String out = ""; - /* Display buttons */ - out += "/******** Buttons ********/\n"; - out += "--- Buttons just pressed : " + buttonsJustPressed + "\n"; - out += "--- Buttons just released : " + buttonsJustReleased + "\n"; - out += "--- Buttons held : " + buttonsHeld + "\n"; - return out; - } + @Override + public String toString() { + String out = ""; + /* Display buttons */ + out += "/******** Buttons ********/\n"; + out += "--- Buttons just pressed : " + buttonsJustPressed + "\n"; + out += "--- Buttons just released : " + buttonsJustReleased + "\n"; + out += "--- Buttons held : " + buttonsHeld + "\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/ClassicControllerButtonsEvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/ClassicControllerButtonsEvent.java index 99c5bc9..132dc89 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/ClassicControllerButtonsEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/ClassicControllerButtonsEvent.java @@ -21,309 +21,309 @@ package wiiusej.wiiusejevents.physicalevents; * @author guiguito */ public class ClassicControllerButtonsEvent extends ButtonsEvent{ - - private static short CLASSIC_CTRL_BUTTON_UP = 0x0001; - private static short CLASSIC_CTRL_BUTTON_LEFT = 0x0002; - private static short CLASSIC_CTRL_BUTTON_ZR = 0x0004; - private static short CLASSIC_CTRL_BUTTON_X = 0x0008; - private static short CLASSIC_CTRL_BUTTON_A = 0x0010; - private static short CLASSIC_CTRL_BUTTON_Y = 0x0020; - private static short CLASSIC_CTRL_BUTTON_B = 0x0040; - private static short CLASSIC_CTRL_BUTTON_ZL = 0x0080; - private static short CLASSIC_CTRL_BUTTON_FULL_R = 0x0200; - private static short CLASSIC_CTRL_BUTTON_PLUS = 0x0400; - private static short CLASSIC_CTRL_BUTTON_HOME = 0x0800; - private static short CLASSIC_CTRL_BUTTON_MINUS = 0x1000; - private static short CLASSIC_CTRL_BUTTON_FULL_L = 0x2000; - private static short CLASSIC_CTRL_BUTTON_DOWN = 0x4000; - private static int CLASSIC_CTRL_BUTTON_RIGHT = 0x8000; - private static int CLASSIC_CTRL_BUTTON_ALL = 0xFEFF; - - /** - * Constructor of the classic controller buttons Event. - * - * @param id - * id of the wiimote. - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - */ - public ClassicControllerButtonsEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld) { - super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); - } - - /* Button LEFT */ - - public boolean isButtonLeftJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_LEFT); - } - - public boolean isButtonLeftJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_LEFT); - } - - public boolean isButtonLeftHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_LEFT); - } - - public boolean isButtonLeftPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_LEFT); - } - - /* Button RIGHT */ - - public boolean isButtonRightJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_RIGHT); - } - - public boolean isButtonRightJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_RIGHT); - } - - public boolean isButtonRightHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_RIGHT); - } - - public boolean isButtonRightPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_RIGHT); - } - - /* Button UP */ - - public boolean isButtonUpJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_UP); - } - - public boolean isButtonUpJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_UP); - } - - public boolean isButtonUpHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_UP); - } - - public boolean isButtonUpPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_UP); - } - - /* Button DOWN */ - - public boolean isButtonDownJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_DOWN); - } - - public boolean isButtonDownJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_DOWN); - } - - public boolean isButtonDownHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_DOWN); - } - - public boolean isButtonDownPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_DOWN); - } - - /* Button A */ - - public boolean isButtonAJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_A); - } - - public boolean isButtonAJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_A); - } - - public boolean isButtonAHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_A); - } - - public boolean isButtonAPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_A); - } - - /* Button B */ - - public boolean isButtonBJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_B); - } - - public boolean isButtonBJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_B); - } + + private static short CLASSIC_CTRL_BUTTON_UP = 0x0001; + private static short CLASSIC_CTRL_BUTTON_LEFT = 0x0002; + private static short CLASSIC_CTRL_BUTTON_ZR = 0x0004; + private static short CLASSIC_CTRL_BUTTON_X = 0x0008; + private static short CLASSIC_CTRL_BUTTON_A = 0x0010; + private static short CLASSIC_CTRL_BUTTON_Y = 0x0020; + private static short CLASSIC_CTRL_BUTTON_B = 0x0040; + private static short CLASSIC_CTRL_BUTTON_ZL = 0x0080; + private static short CLASSIC_CTRL_BUTTON_FULL_R = 0x0200; + private static short CLASSIC_CTRL_BUTTON_PLUS = 0x0400; + private static short CLASSIC_CTRL_BUTTON_HOME = 0x0800; + private static short CLASSIC_CTRL_BUTTON_MINUS = 0x1000; + private static short CLASSIC_CTRL_BUTTON_FULL_L = 0x2000; + private static short CLASSIC_CTRL_BUTTON_DOWN = 0x4000; + private static int CLASSIC_CTRL_BUTTON_RIGHT = 0x8000; + private static int CLASSIC_CTRL_BUTTON_ALL = 0xFEFF; + + /** + * Constructor of the classic controller buttons Event. + * + * @param id + * id of the wiimote. + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + */ + public ClassicControllerButtonsEvent(int id, short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld) { + super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); + } + + /* Button LEFT */ + + public boolean isButtonLeftJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_LEFT); + } + + public boolean isButtonLeftJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_LEFT); + } + + public boolean isButtonLeftHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_LEFT); + } + + public boolean isButtonLeftPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_LEFT); + } + + /* Button RIGHT */ + + public boolean isButtonRightJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_RIGHT); + } + + public boolean isButtonRightJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_RIGHT); + } + + public boolean isButtonRightHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_RIGHT); + } + + public boolean isButtonRightPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_RIGHT); + } + + /* Button UP */ + + public boolean isButtonUpJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_UP); + } + + public boolean isButtonUpJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_UP); + } + + public boolean isButtonUpHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_UP); + } + + public boolean isButtonUpPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_UP); + } + + /* Button DOWN */ + + public boolean isButtonDownJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_DOWN); + } + + public boolean isButtonDownJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_DOWN); + } + + public boolean isButtonDownHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_DOWN); + } + + public boolean isButtonDownPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_DOWN); + } + + /* Button A */ + + public boolean isButtonAJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_A); + } + + public boolean isButtonAJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_A); + } + + public boolean isButtonAHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_A); + } + + public boolean isButtonAPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_A); + } + + /* Button B */ + + public boolean isButtonBJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_B); + } + + public boolean isButtonBJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_B); + } - public boolean isButtonBHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_B); - } - - public boolean isButtonBPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_B); - } - - /* Button X */ - - public boolean isButtonXJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_X); - } - - public boolean isButtonXJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_X); - } - - public boolean isButtonXHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_X); - } - - public boolean isButtonXPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_X); - } - - /* Button Y */ - - public boolean isButtonYJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_Y); - } - - public boolean isButtonYJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_Y); - } - - public boolean isButtonYHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_Y); - } - - public boolean isButtonYPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_Y); - } - - /* Button FullLeft */ - - public boolean isButtonFullLeftJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_FULL_L); - } - - public boolean isButtonFullLeftJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_FULL_L); - } - - public boolean isButtonFullLeftHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_FULL_L); - } - - public boolean isButtonFullLeftPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_FULL_L); - } - - /* Button FullRight */ - - public boolean isButtonFullRightJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_FULL_R); - } - - public boolean isButtonFullRightJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_FULL_R); - } - - public boolean isButtonFullRightHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_FULL_R); - } - - public boolean isButtonFullRightPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_FULL_R); - } - - /* Button Home */ - - public boolean isButtonHomeJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_HOME); - } - - public boolean isButtonHomeJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_HOME); - } - - public boolean isButtonHomeHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_HOME); - } - - public boolean isButtonHomePressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_HOME); - } - - /* Button Minus */ - - public boolean isButtonMinusJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_MINUS); - } - - public boolean isButtonMinusJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_MINUS); - } - - public boolean isButtonMinusHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_MINUS); - } - - public boolean isButtonMinusPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_MINUS); - } - - /* Button Plus */ - - public boolean isButtonPlusJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_PLUS); - } - - public boolean isButtonPlusJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_PLUS); - } - - public boolean isButtonPlusHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_PLUS); - } - - public boolean isButtonPlusPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_PLUS); - } - - /* Button ZL */ - - public boolean isButtonZLJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_ZL); - } - - public boolean isButtonZLJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_ZL); - } - - public boolean isButtonZLHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_ZL); - } - - public boolean isButtonZLPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_ZL); - } - - /* Button ZR */ - - public boolean isButtonZRJustPressed() { - return isButtonJustPressed(CLASSIC_CTRL_BUTTON_ZR); - } - - public boolean isButtonZRJustReleased() { - return isButtonJustReleased(CLASSIC_CTRL_BUTTON_ZR); - } - - public boolean isButtonZRHeld() { - return isButtonHeld(CLASSIC_CTRL_BUTTON_ZR); - } - - public boolean isButtonZRPressed() { - return isButtonPressed(CLASSIC_CTRL_BUTTON_ZR); - } + public boolean isButtonBHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_B); + } + + public boolean isButtonBPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_B); + } + + /* Button X */ + + public boolean isButtonXJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_X); + } + + public boolean isButtonXJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_X); + } + + public boolean isButtonXHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_X); + } + + public boolean isButtonXPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_X); + } + + /* Button Y */ + + public boolean isButtonYJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_Y); + } + + public boolean isButtonYJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_Y); + } + + public boolean isButtonYHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_Y); + } + + public boolean isButtonYPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_Y); + } + + /* Button FullLeft */ + + public boolean isButtonFullLeftJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_FULL_L); + } + + public boolean isButtonFullLeftJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_FULL_L); + } + + public boolean isButtonFullLeftHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_FULL_L); + } + + public boolean isButtonFullLeftPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_FULL_L); + } + + /* Button FullRight */ + + public boolean isButtonFullRightJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_FULL_R); + } + + public boolean isButtonFullRightJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_FULL_R); + } + + public boolean isButtonFullRightHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_FULL_R); + } + + public boolean isButtonFullRightPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_FULL_R); + } + + /* Button Home */ + + public boolean isButtonHomeJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_HOME); + } + + public boolean isButtonHomeJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_HOME); + } + + public boolean isButtonHomeHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_HOME); + } + + public boolean isButtonHomePressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_HOME); + } + + /* Button Minus */ + + public boolean isButtonMinusJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_MINUS); + } + + public boolean isButtonMinusJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_MINUS); + } + + public boolean isButtonMinusHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_MINUS); + } + + public boolean isButtonMinusPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_MINUS); + } + + /* Button Plus */ + + public boolean isButtonPlusJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_PLUS); + } + + public boolean isButtonPlusJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_PLUS); + } + + public boolean isButtonPlusHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_PLUS); + } + + public boolean isButtonPlusPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_PLUS); + } + + /* Button ZL */ + + public boolean isButtonZLJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_ZL); + } + + public boolean isButtonZLJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_ZL); + } + + public boolean isButtonZLHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_ZL); + } + + public boolean isButtonZLPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_ZL); + } + + /* Button ZR */ + + public boolean isButtonZRJustPressed() { + return isButtonJustPressed(CLASSIC_CTRL_BUTTON_ZR); + } + + public boolean isButtonZRJustReleased() { + return isButtonJustReleased(CLASSIC_CTRL_BUTTON_ZR); + } + + public boolean isButtonZRHeld() { + return isButtonHeld(CLASSIC_CTRL_BUTTON_ZR); + } + + public boolean isButtonZRPressed() { + return isButtonPressed(CLASSIC_CTRL_BUTTON_ZR); + } } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/ClassicControllerEvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/ClassicControllerEvent.java index 214e030..6102acd 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/ClassicControllerEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/ClassicControllerEvent.java @@ -23,155 +23,155 @@ package wiiusej.wiiusejevents.physicalevents; */ public class ClassicControllerEvent extends ExpansionEvent { - private float rightShoulder; - private float leftShoulder; - private ClassicControllerButtonsEvent buttonsEvent; - private JoystickEvent classicControllerRightJoystickEvent; - private JoystickEvent classicControllerLeftJoystickEvent; + private float rightShoulder; + private float leftShoulder; + private ClassicControllerButtonsEvent buttonsEvent; + private JoystickEvent classicControllerRightJoystickEvent; + private JoystickEvent classicControllerLeftJoystickEvent; - /** - * Constructor of ClassicControllerEvent. - * - * @param id - * id of the wiimote. - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - * @param rightShoulder - * right shoulder button (range 0-1). - * @param leftShoulder - * left shoulder button (range 0-1). - * @param langle - * angle the left joystick is being held. - * @param lmagnitude - * magnitude of the left joystick (range 0-1). - * @param lmax1 - * maximum left joystick value 1. - * @param lmax2 - * maximum left joystick value 2. - * @param lmin1 - * minimum left joystick value 1. - * @param lmin2 - * minimum left joystick value 2. - * @param lcenter1 - * center left joystick value 1. - * @param lcenter2 - * center left joystick value 2. - * @param rangle - * angle the right joystick is being held. - * @param rmagnitude - * magnitude of the right joystick (range 0-1). - * @param rmax1 - * maximum right joystick value 1. - * @param rmax2 - * maximum right joystick value 2. - * @param rmin1 - * minimum right joystick value 1. - * @param rmin2 - * minimum right joystick value 2. - * @param rcenter1 - * center right joystick value 1. - * @param rcenter2 - * center right joystick value 2. - */ - public ClassicControllerEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld, float rightShoulder, - float leftShoulder, float langle, float lmagnitude, short lmax1, - short lmax2, short lmin1, short lmin2, short lcenter1, - short lcenter2, float rangle, float rmagnitude, short rmax1, - short rmax2, short rmin1, short rmin2, short rcenter1, - short rcenter2) { - super(id); - this.leftShoulder = leftShoulder; - this.rightShoulder = rightShoulder; - buttonsEvent = new ClassicControllerButtonsEvent(id, - buttonsJustPressed, buttonsJustReleased, buttonsHeld); - classicControllerLeftJoystickEvent = new JoystickEvent(id, langle, - lmagnitude, lmax1, lmax2, lmin1, lmin2, lcenter1, lcenter2); - classicControllerRightJoystickEvent = new JoystickEvent(id, rangle, - rmagnitude, rmax1, rmax2, rmin1, rmin2, rcenter1, rcenter2); - } + /** + * Constructor of ClassicControllerEvent. + * + * @param id + * id of the wiimote. + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + * @param rightShoulder + * right shoulder button (range 0-1). + * @param leftShoulder + * left shoulder button (range 0-1). + * @param langle + * angle the left joystick is being held. + * @param lmagnitude + * magnitude of the left joystick (range 0-1). + * @param lmax1 + * maximum left joystick value 1. + * @param lmax2 + * maximum left joystick value 2. + * @param lmin1 + * minimum left joystick value 1. + * @param lmin2 + * minimum left joystick value 2. + * @param lcenter1 + * center left joystick value 1. + * @param lcenter2 + * center left joystick value 2. + * @param rangle + * angle the right joystick is being held. + * @param rmagnitude + * magnitude of the right joystick (range 0-1). + * @param rmax1 + * maximum right joystick value 1. + * @param rmax2 + * maximum right joystick value 2. + * @param rmin1 + * minimum right joystick value 1. + * @param rmin2 + * minimum right joystick value 2. + * @param rcenter1 + * center right joystick value 1. + * @param rcenter2 + * center right joystick value 2. + */ + public ClassicControllerEvent(int id, short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld, float rightShoulder, + float leftShoulder, float langle, float lmagnitude, short lmax1, + short lmax2, short lmin1, short lmin2, short lcenter1, + short lcenter2, float rangle, float rmagnitude, short rmax1, + short rmax2, short rmin1, short rmin2, short rcenter1, + short rcenter2) { + super(id); + this.leftShoulder = leftShoulder; + this.rightShoulder = rightShoulder; + buttonsEvent = new ClassicControllerButtonsEvent(id, + buttonsJustPressed, buttonsJustReleased, buttonsHeld); + classicControllerLeftJoystickEvent = new JoystickEvent(id, langle, + lmagnitude, lmax1, lmax2, lmin1, lmin2, lcenter1, lcenter2); + classicControllerRightJoystickEvent = new JoystickEvent(id, rangle, + rmagnitude, rmax1, rmax2, rmin1, rmin2, rcenter1, rcenter2); + } - /** - * Tell if there is a classic controller left joystick event. - * - * @return TRUE if there is a classic controller left joystick event, false - * otherwise. - */ - public boolean isThereClassicControllerLeftJoystickEvent() { - return classicControllerLeftJoystickEvent != null; - } + /** + * Tell if there is a classic controller left joystick event. + * + * @return TRUE if there is a classic controller left joystick event, false + * otherwise. + */ + public boolean isThereClassicControllerLeftJoystickEvent() { + return classicControllerLeftJoystickEvent != null; + } - /** - * Tell if there is a classic controller right joystick event. - * - * @return TRUE if there is a classic controller right joystick event, false - * otherwise. - */ - public boolean isThereClassicControllerRightJoystickEvent() { - return classicControllerRightJoystickEvent != null; - } + /** + * Tell if there is a classic controller right joystick event. + * + * @return TRUE if there is a classic controller right joystick event, false + * otherwise. + */ + public boolean isThereClassicControllerRightJoystickEvent() { + return classicControllerRightJoystickEvent != null; + } - /** - * Get the right shoulder button(range 0-1). - * - * @return value of the rightShoulder button. - */ - public float getRightShoulder() { - return rightShoulder; - } + /** + * Get the right shoulder button(range 0-1). + * + * @return value of the rightShoulder button. + */ + public float getRightShoulder() { + return rightShoulder; + } - /** - * Get the left shoulder button(range 0-1). - * - * @return value of the leftShoulder button. - */ - public float getLeftShoulder() { - return leftShoulder; - } + /** + * Get the left shoulder button(range 0-1). + * + * @return value of the leftShoulder button. + */ + public float getLeftShoulder() { + return leftShoulder; + } - /** - * Get buttons event for the classic controller. - * - * @return the classic controller buttons event if there is one or null. - */ - public ClassicControllerButtonsEvent getButtonsEvent() { - return buttonsEvent; - } + /** + * Get buttons event for the classic controller. + * + * @return the classic controller buttons event if there is one or null. + */ + public ClassicControllerButtonsEvent getButtonsEvent() { + return buttonsEvent; + } - /** - * Get event from the right joystick of the classic controller. - * - * @return the classic controller right Joystick Event if there is one or null. - */ - public JoystickEvent getClassicControllerRightJoystickEvent() { - return classicControllerRightJoystickEvent; - } + /** + * Get event from the right joystick of the classic controller. + * + * @return the classic controller right Joystick Event if there is one or null. + */ + public JoystickEvent getClassicControllerRightJoystickEvent() { + return classicControllerRightJoystickEvent; + } - /** - * Get event from the left joystick of the classic controller. - * - * @return the classic controller left Joystick Event if there is one or null. - */ - public JoystickEvent getClassicControllerLeftJoystickEvent() { - return classicControllerLeftJoystickEvent; - } + /** + * Get event from the left joystick of the classic controller. + * + * @return the classic controller left Joystick Event if there is one or null. + */ + public JoystickEvent getClassicControllerLeftJoystickEvent() { + return classicControllerLeftJoystickEvent; + } - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** Classic Controller EVENT : WIIMOTE ID :" - + getWiimoteId() + " ********/\n"; - out += buttonsEvent; - out += "Left shoulder : " + leftShoulder + "\n"; - out += "Right shoulder : " + rightShoulder + "\n"; - out += classicControllerLeftJoystickEvent; - out += classicControllerRightJoystickEvent; - return out; - } + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** Classic Controller EVENT : WIIMOTE ID :" + + getWiimoteId() + " ********/\n"; + out += buttonsEvent; + out += "Left shoulder : " + leftShoulder + "\n"; + out += "Right shoulder : " + rightShoulder + "\n"; + out += classicControllerLeftJoystickEvent; + out += classicControllerRightJoystickEvent; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/ExpansionEvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/ExpansionEvent.java index 0b71a4c..935d3d6 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/ExpansionEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/ExpansionEvent.java @@ -25,16 +25,16 @@ import wiiusej.wiiusejevents.GenericEvent; */ public abstract class ExpansionEvent extends GenericEvent { - /** - * Constructor of an ExpansionEvent. - * - * @param id - * id of the wiimote to which the expansion is connected. - */ - public ExpansionEvent(int id) { - super(id); - } - - public abstract String toString(); + /** + * Constructor of an ExpansionEvent. + * + * @param id + * id of the wiimote to which the expansion is connected. + */ + public ExpansionEvent(int id) { + super(id); + } + + public abstract String toString(); } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/GuitarHeroButtonsEvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/GuitarHeroButtonsEvent.java index 92d139e..c993836 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/GuitarHeroButtonsEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/GuitarHeroButtonsEvent.java @@ -22,193 +22,193 @@ package wiiusej.wiiusejevents.physicalevents; */ public class GuitarHeroButtonsEvent extends ButtonsEvent { - 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_GREEN = 0x0010; - 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_ORANGE = 0x0080; - 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_STRUM_DOWN = 0x4000; - private static int GUITAR_HERO_3_BUTTON_ALL = 0xFEFF; + 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_GREEN = 0x0010; + 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_ORANGE = 0x0080; + 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_STRUM_DOWN = 0x4000; + private static int GUITAR_HERO_3_BUTTON_ALL = 0xFEFF; - /** - * Constructor of the guitar hero buttons Event. - * - * @param id - * id of the wiimote. - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - */ - public GuitarHeroButtonsEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld) { - super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); - } - - /* Button Strum Up */ + /** + * Constructor of the guitar hero buttons Event. + * + * @param id + * id of the wiimote. + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + */ + public GuitarHeroButtonsEvent(int id, short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld) { + super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); + } + + /* Button Strum Up */ - public boolean isButtonStrumUpJustPressed() { - return isButtonJustPressed(GUITAR_HERO_3_BUTTON_STRUM_UP); - } - - public boolean isButtonStrumUpJustReleased() { - return isButtonJustReleased(GUITAR_HERO_3_BUTTON_STRUM_UP); - } + public boolean isButtonStrumUpJustPressed() { + return isButtonJustPressed(GUITAR_HERO_3_BUTTON_STRUM_UP); + } + + public boolean isButtonStrumUpJustReleased() { + return isButtonJustReleased(GUITAR_HERO_3_BUTTON_STRUM_UP); + } - public boolean isButtonStrumUpeHeld() { - return isButtonHeld(GUITAR_HERO_3_BUTTON_STRUM_UP); - } + public boolean isButtonStrumUpeHeld() { + return isButtonHeld(GUITAR_HERO_3_BUTTON_STRUM_UP); + } - public boolean isButtonStrumUpPressed() { - return isButtonPressed(GUITAR_HERO_3_BUTTON_STRUM_UP); - } - - /* Button Strum Down */ + public boolean isButtonStrumUpPressed() { + return isButtonPressed(GUITAR_HERO_3_BUTTON_STRUM_UP); + } + + /* Button Strum Down */ - public boolean isButtonStrumDownJustPressed() { - return isButtonJustPressed(GUITAR_HERO_3_BUTTON_STRUM_DOWN); - } - - public boolean isButtonStrumDownJustReleased() { - return isButtonJustReleased(GUITAR_HERO_3_BUTTON_STRUM_DOWN); - } + public boolean isButtonStrumDownJustPressed() { + return isButtonJustPressed(GUITAR_HERO_3_BUTTON_STRUM_DOWN); + } + + public boolean isButtonStrumDownJustReleased() { + return isButtonJustReleased(GUITAR_HERO_3_BUTTON_STRUM_DOWN); + } - public boolean isButtonStrumDowneHeld() { - return isButtonHeld(GUITAR_HERO_3_BUTTON_STRUM_DOWN); - } + public boolean isButtonStrumDowneHeld() { + return isButtonHeld(GUITAR_HERO_3_BUTTON_STRUM_DOWN); + } - public boolean isButtonStrumDownPressed() { - return isButtonPressed(GUITAR_HERO_3_BUTTON_STRUM_DOWN); - } - - /* Button blue */ + public boolean isButtonStrumDownPressed() { + return isButtonPressed(GUITAR_HERO_3_BUTTON_STRUM_DOWN); + } + + /* Button blue */ - public boolean isButtonBlueJustPressed() { - return isButtonJustPressed(GUITAR_HERO_3_BUTTON_BLUE); - } - - public boolean isButtonBlueJustReleased() { - return isButtonJustReleased(GUITAR_HERO_3_BUTTON_BLUE); - } + public boolean isButtonBlueJustPressed() { + return isButtonJustPressed(GUITAR_HERO_3_BUTTON_BLUE); + } + + public boolean isButtonBlueJustReleased() { + return isButtonJustReleased(GUITAR_HERO_3_BUTTON_BLUE); + } - public boolean isButtonBlueHeld() { - return isButtonHeld(GUITAR_HERO_3_BUTTON_BLUE); - } + public boolean isButtonBlueHeld() { + return isButtonHeld(GUITAR_HERO_3_BUTTON_BLUE); + } - public boolean isButtonBluePressed() { - return isButtonPressed(GUITAR_HERO_3_BUTTON_BLUE); - } - - /* Button Green */ + public boolean isButtonBluePressed() { + return isButtonPressed(GUITAR_HERO_3_BUTTON_BLUE); + } + + /* Button Green */ - public boolean isButtonGreenJustPressed() { - return isButtonJustPressed(GUITAR_HERO_3_BUTTON_GREEN); - } - - public boolean isButtonGreenJustReleased() { - return isButtonJustReleased(GUITAR_HERO_3_BUTTON_GREEN); - } + public boolean isButtonGreenJustPressed() { + return isButtonJustPressed(GUITAR_HERO_3_BUTTON_GREEN); + } + + public boolean isButtonGreenJustReleased() { + return isButtonJustReleased(GUITAR_HERO_3_BUTTON_GREEN); + } - public boolean isButtonGreenHeld() { - return isButtonHeld(GUITAR_HERO_3_BUTTON_GREEN); - } + public boolean isButtonGreenHeld() { + return isButtonHeld(GUITAR_HERO_3_BUTTON_GREEN); + } - public boolean isButtonGreenPressed() { - return isButtonPressed(GUITAR_HERO_3_BUTTON_GREEN); - } + public boolean isButtonGreenPressed() { + return isButtonPressed(GUITAR_HERO_3_BUTTON_GREEN); + } - /* Button Minus */ + /* Button Minus */ - public boolean isButtonMinusJustPressed() { - return isButtonJustPressed(GUITAR_HERO_3_BUTTON_MINUS); - } - - public boolean isButtonMinusJustReleased() { - return isButtonJustReleased(GUITAR_HERO_3_BUTTON_MINUS); - } + public boolean isButtonMinusJustPressed() { + return isButtonJustPressed(GUITAR_HERO_3_BUTTON_MINUS); + } + + public boolean isButtonMinusJustReleased() { + return isButtonJustReleased(GUITAR_HERO_3_BUTTON_MINUS); + } - public boolean isButtonMinusHeld() { - return isButtonHeld(GUITAR_HERO_3_BUTTON_MINUS); - } + public boolean isButtonMinusHeld() { + return isButtonHeld(GUITAR_HERO_3_BUTTON_MINUS); + } - public boolean isButtonMinusPressed() { - return isButtonPressed(GUITAR_HERO_3_BUTTON_MINUS); - } - - /* Button Orange */ + public boolean isButtonMinusPressed() { + return isButtonPressed(GUITAR_HERO_3_BUTTON_MINUS); + } + + /* Button Orange */ - public boolean isButtonOrangeJustPressed() { - return isButtonJustPressed(GUITAR_HERO_3_BUTTON_ORANGE); - } - - public boolean isButtonOrangeJustReleased() { - return isButtonJustReleased(GUITAR_HERO_3_BUTTON_ORANGE); - } + public boolean isButtonOrangeJustPressed() { + return isButtonJustPressed(GUITAR_HERO_3_BUTTON_ORANGE); + } + + public boolean isButtonOrangeJustReleased() { + return isButtonJustReleased(GUITAR_HERO_3_BUTTON_ORANGE); + } - public boolean isButtonOrangeHeld() { - return isButtonHeld(GUITAR_HERO_3_BUTTON_ORANGE); - } + public boolean isButtonOrangeHeld() { + return isButtonHeld(GUITAR_HERO_3_BUTTON_ORANGE); + } - public boolean isButtonOrangePressed() { - return isButtonPressed(GUITAR_HERO_3_BUTTON_ORANGE); - } - - /* Button Plus */ + public boolean isButtonOrangePressed() { + return isButtonPressed(GUITAR_HERO_3_BUTTON_ORANGE); + } + + /* Button Plus */ - public boolean isButtonPlusJustPressed() { - return isButtonJustPressed(GUITAR_HERO_3_BUTTON_PLUS); - } - - public boolean isButtonPlusJustReleased() { - return isButtonJustReleased(GUITAR_HERO_3_BUTTON_PLUS); - } + public boolean isButtonPlusJustPressed() { + return isButtonJustPressed(GUITAR_HERO_3_BUTTON_PLUS); + } + + public boolean isButtonPlusJustReleased() { + return isButtonJustReleased(GUITAR_HERO_3_BUTTON_PLUS); + } - public boolean isButtonPlusHeld() { - return isButtonHeld(GUITAR_HERO_3_BUTTON_PLUS); - } + public boolean isButtonPlusHeld() { + return isButtonHeld(GUITAR_HERO_3_BUTTON_PLUS); + } - public boolean isButtonPlusPressed() { - return isButtonPressed(GUITAR_HERO_3_BUTTON_PLUS); - } - - /* Button Red */ + public boolean isButtonPlusPressed() { + return isButtonPressed(GUITAR_HERO_3_BUTTON_PLUS); + } + + /* Button Red */ - public boolean isButtonRedJustPressed() { - return isButtonJustPressed(GUITAR_HERO_3_BUTTON_RED); - } - - public boolean isButtonRedJustReleased() { - return isButtonJustReleased(GUITAR_HERO_3_BUTTON_RED); - } + public boolean isButtonRedJustPressed() { + return isButtonJustPressed(GUITAR_HERO_3_BUTTON_RED); + } + + public boolean isButtonRedJustReleased() { + return isButtonJustReleased(GUITAR_HERO_3_BUTTON_RED); + } - public boolean isButtonRedHeld() { - return isButtonHeld(GUITAR_HERO_3_BUTTON_RED); - } + public boolean isButtonRedHeld() { + return isButtonHeld(GUITAR_HERO_3_BUTTON_RED); + } - public boolean isButtonRedPressed() { - return isButtonPressed(GUITAR_HERO_3_BUTTON_RED); - } - - /* Button Yellow */ + public boolean isButtonRedPressed() { + return isButtonPressed(GUITAR_HERO_3_BUTTON_RED); + } + + /* Button Yellow */ - public boolean isButtonYellowJustPressed() { - return isButtonJustPressed(GUITAR_HERO_3_BUTTON_YELLOW); - } - - public boolean isButtonYellowJustReleased() { - return isButtonJustReleased(GUITAR_HERO_3_BUTTON_YELLOW); - } + public boolean isButtonYellowJustPressed() { + return isButtonJustPressed(GUITAR_HERO_3_BUTTON_YELLOW); + } + + public boolean isButtonYellowJustReleased() { + return isButtonJustReleased(GUITAR_HERO_3_BUTTON_YELLOW); + } - public boolean isButtonYellowHeld() { - return isButtonHeld(GUITAR_HERO_3_BUTTON_YELLOW); - } + public boolean isButtonYellowHeld() { + return isButtonHeld(GUITAR_HERO_3_BUTTON_YELLOW); + } - public boolean isButtonYellowPressed() { - return isButtonPressed(GUITAR_HERO_3_BUTTON_YELLOW); - } + public boolean isButtonYellowPressed() { + return isButtonPressed(GUITAR_HERO_3_BUTTON_YELLOW); + } } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/GuitarHeroEvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/GuitarHeroEvent.java index 6fb9e8c..346a3cf 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/GuitarHeroEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/GuitarHeroEvent.java @@ -22,98 +22,98 @@ package wiiusej.wiiusejevents.physicalevents; * @author guiguito */ public class GuitarHeroEvent extends ExpansionEvent{ - - private float whammyBar; - private GuitarHeroButtonsEvent buttonsEvent; - private JoystickEvent guitarHeroJoystickEvent; - - /** - * Constructor of GuitarHeroEvent. - * - * @param id - * id of the wiimote. - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - * @param whammyBar - * whammy bar (range 0-1). - * @param angle - * angle the joystick is being held. - * @param magnitude - * magnitude of the joystick (range 0-1). - * @param max1 - * maximum joystick value 1. - * @param max2 - * maximum joystick value 2. - * @param min1 - * minimum joystick value 1. - * @param min2 - * minimum joystick value 2. - * @param center1 - * center joystick value 1. - * @param center2 - * center joystick value 2. - */ - public GuitarHeroEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld, float whammyBar, - float angle, float magnitude, short max1, - short max2, short min1, short min2, short center1, - short center2) { - super(id); - this.whammyBar = whammyBar; - buttonsEvent = new GuitarHeroButtonsEvent(id, - buttonsJustPressed, buttonsJustReleased, buttonsHeld); - guitarHeroJoystickEvent = new JoystickEvent(id, angle, - magnitude, max1, max2, min1, min2, center1, center2); + + private float whammyBar; + private GuitarHeroButtonsEvent buttonsEvent; + private JoystickEvent guitarHeroJoystickEvent; + + /** + * Constructor of GuitarHeroEvent. + * + * @param id + * id of the wiimote. + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + * @param whammyBar + * whammy bar (range 0-1). + * @param angle + * angle the joystick is being held. + * @param magnitude + * magnitude of the joystick (range 0-1). + * @param max1 + * maximum joystick value 1. + * @param max2 + * maximum joystick value 2. + * @param min1 + * minimum joystick value 1. + * @param min2 + * minimum joystick value 2. + * @param center1 + * center joystick value 1. + * @param center2 + * center joystick value 2. + */ + public GuitarHeroEvent(int id, short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld, float whammyBar, + float angle, float magnitude, short max1, + short max2, short min1, short min2, short center1, + short center2) { + super(id); + this.whammyBar = whammyBar; + buttonsEvent = new GuitarHeroButtonsEvent(id, + buttonsJustPressed, buttonsJustReleased, buttonsHeld); + guitarHeroJoystickEvent = new JoystickEvent(id, angle, + magnitude, max1, max2, min1, min2, center1, center2); - } - - /** - * Tell if there is a Guitar Hero joystick event. - * - * @return TRUE if there is a Guitar Hero joystick event, false otherwise. - */ - public boolean isThereGuitarHeroJoystickEvent() { - return guitarHeroJoystickEvent != null; - } + } + + /** + * Tell if there is a Guitar Hero joystick event. + * + * @return TRUE if there is a Guitar Hero joystick event, false otherwise. + */ + public boolean isThereGuitarHeroJoystickEvent() { + return guitarHeroJoystickEvent != null; + } - /** - * Whammy bar (range 0-1). - * @return the whammyBar value. - */ - public float getWhammyBar() { - return whammyBar; - } + /** + * Whammy bar (range 0-1). + * @return the whammyBar value. + */ + public float getWhammyBar() { + return whammyBar; + } - /** - * Get buttons event for the guitar hero controller. - * @return the guitar hero controller buttons event if there is one or null. - */ - public GuitarHeroButtonsEvent getButtonsEvent() { - return buttonsEvent; - } + /** + * Get buttons event for the guitar hero controller. + * @return the guitar hero controller buttons event if there is one or null. + */ + public GuitarHeroButtonsEvent getButtonsEvent() { + return buttonsEvent; + } - /** - * Get event from the joystick of the guitar hero controller. - * @return the guitar hero controller joystick Event if there is one or null. - */ - public JoystickEvent getGuitarHeroJoystickEvent() { - return guitarHeroJoystickEvent; - } + /** + * Get event from the joystick of the guitar hero controller. + * @return the guitar hero controller joystick Event if there is one or null. + */ + public JoystickEvent getGuitarHeroJoystickEvent() { + return guitarHeroJoystickEvent; + } - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** Guitar Hero 3 EVENT : WIIMOTE ID :" + getWiimoteId() - + " ********/\n"; - out += buttonsEvent; - out += "Whammy Bar : "+whammyBar+"\n"; - out += guitarHeroJoystickEvent; - return out; - } + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** Guitar Hero 3 EVENT : WIIMOTE ID :" + getWiimoteId() + + " ********/\n"; + out += buttonsEvent; + out += "Whammy Bar : "+whammyBar+"\n"; + out += guitarHeroJoystickEvent; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/IREvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/IREvent.java index 74d4f2c..7dadc56 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/IREvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/IREvent.java @@ -26,294 +26,294 @@ import wiiusej.wiiusejevents.GenericEvent; */ public class IREvent extends GenericEvent { - /* IR Tracking */ - private IRSource[] IRPoints; - private short indexPoints = 0; - private int x; - private int y; - private float z;// distance from the sensor bar - private int ax; - private int ay; - private int xVRes; - private int yVRes; - private int xOffset; - private int yOffset; - private short sensorBarPostion; - private short screenAsPectRatio; - private short irSensitivity; - private float distance; + /* IR Tracking */ + private IRSource[] IRPoints; + private short indexPoints = 0; + private int x; + private int y; + private float z;// distance from the sensor bar + private int ax; + private int ay; + private int xVRes; + private int yVRes; + private int xOffset; + private int yOffset; + private short sensorBarPostion; + private short screenAsPectRatio; + private short irSensitivity; + private float distance; - static private short WIIUSE_IR_ABOVE = 0; - static private short WIIUSE_IR_BELOW = 1; - static private short WIIUSE_SCREEN_RATIO_4_3 = 0; - static private short WIIUSE_SCREEN_RATIO_16_9 = 1; + static private short WIIUSE_IR_ABOVE = 0; + static private short WIIUSE_IR_BELOW = 1; + static private short WIIUSE_SCREEN_RATIO_4_3 = 0; + 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. - * - * @param id - * d of the wiimote concerned. - * @param x - * calculated X coordinate. - * @param y - * calculated Y coordinate. - * @param z - * calculated distance. - * @param ax - * absolute X coordinate. - * @param ay - * absolute Y coordinate - * @param xVRes - * IR virtual screen x resolution. - * @param yVRes - * IR virtual screen y resolution. - * @param xOffset - * IR X correction offset. - * @param yOffset - * IR Y correction offset. - * @param sensorBarPostion - * aspect ratio of the screen. - * @param screenAsPectRatio - * IR sensor bar position. - * @param irSensitivity - * Sensitivity of the infrared camera. - * @param distance - * Pixel Distance between first two dots - */ - public IREvent(int id, int x, int y, float z, int ax, int ay, int xVRes, - int yVRes, int xOffset, int yOffset, short sensorBarPostion, - short screenAsPectRatio, short irSensitivity, float distance) { - super(id); - this.x = x; - this.y = y; - this.z = z; - this.ax = ax; - this.ay = ay; - this.xVRes = xVRes; - this.yVRes = yVRes; - this.xOffset = xOffset; - this.yOffset = yOffset; - this.sensorBarPostion = sensorBarPostion; - this.screenAsPectRatio = screenAsPectRatio; - this.irSensitivity = irSensitivity; - this.distance = distance; - IRPoints = new IRSource[NB_POINTS]; - } + /** + * Constructor of IREvent with full infos. + * + * @param id + * d of the wiimote concerned. + * @param x + * calculated X coordinate. + * @param y + * calculated Y coordinate. + * @param z + * calculated distance. + * @param ax + * absolute X coordinate. + * @param ay + * absolute Y coordinate + * @param xVRes + * IR virtual screen x resolution. + * @param yVRes + * IR virtual screen y resolution. + * @param xOffset + * IR X correction offset. + * @param yOffset + * IR Y correction offset. + * @param sensorBarPostion + * aspect ratio of the screen. + * @param screenAsPectRatio + * IR sensor bar position. + * @param irSensitivity + * Sensitivity of the infrared camera. + * @param distance + * Pixel Distance between first two dots + */ + public IREvent(int id, int x, int y, float z, int ax, int ay, int xVRes, + int yVRes, int xOffset, int yOffset, short sensorBarPostion, + short screenAsPectRatio, short irSensitivity, float distance) { + super(id); + this.x = x; + this.y = y; + this.z = z; + this.ax = ax; + this.ay = ay; + this.xVRes = xVRes; + this.yVRes = yVRes; + this.xOffset = xOffset; + this.yOffset = yOffset; + this.sensorBarPostion = sensorBarPostion; + this.screenAsPectRatio = screenAsPectRatio; + this.irSensitivity = irSensitivity; + this.distance = distance; + IRPoints = new IRSource[NB_POINTS]; + } - /** - * Get list of IR points. - * - * @return the list of 2D points - */ - public IRSource[] getIRPoints() { - IRSource[] ir = new IRSource[indexPoints]; + /** + * Get list of IR points. + * + * @return the list of 2D points + */ + public IRSource[] getIRPoints() { + IRSource[] ir = new IRSource[indexPoints]; System.arraycopy(IRPoints, 0, ir, 0, indexPoints); return ir; - } + } - /** - * Add IR Point in the list (Max 4 points) - * - * @param x - * x value - * @param y - * y value - * @param rx - * raw X coordinate (0-1023). - * @param ry - * raw Y coordinate (0-1023). - * @param size - * size of the IR dot (0-15). - */ - public void addIRpoint(int x, int y, short rx, short ry, short size) { - IRPoints[indexPoints] = new IRSource(x, y, rx, ry, size); - indexPoints++; - return; - } + /** + * Add IR Point in the list (Max 4 points) + * + * @param x + * x value + * @param y + * y value + * @param rx + * raw X coordinate (0-1023). + * @param ry + * raw Y coordinate (0-1023). + * @param size + * size of the IR dot (0-15). + */ + public void addIRpoint(int x, int y, short rx, short ry, short size) { + IRPoints[indexPoints] = new IRSource(x, y, rx, ry, size); + indexPoints++; + return; + } - /** - * Return calculated X coordinate. - * - * @return the x - */ - public int getX() { - return x; - } + /** + * Return calculated X coordinate. + * + * @return the x + */ + public int getX() { + return x; + } - /** - * Return calculated Y coordinate. - * - * @return the y - */ - public int getY() { - return y; - } + /** + * Return calculated Y coordinate. + * + * @return the y + */ + public int getY() { + return y; + } - /** - * Return calculated distance. - * - * @return the z - */ - public float getZ() { - return z; - } + /** + * Return calculated distance. + * + * @return the z + */ + public float getZ() { + return z; + } - /** - * Return absolute X coordinate. - * - * @return the ax - */ - public int getAx() { - return ax; - } + /** + * Return absolute X coordinate. + * + * @return the ax + */ + public int getAx() { + return ax; + } - /** - * Return absolute Y coordinate. - * - * @return the ay - */ - public int getAy() { - return ay; - } + /** + * Return absolute Y coordinate. + * + * @return the ay + */ + public int getAy() { + return ay; + } - /** - * Return IR virtual screen x resolution. - * - * @return the xVRes - */ - public int getXVRes() { - return xVRes; - } + /** + * Return IR virtual screen x resolution. + * + * @return the xVRes + */ + public int getXVRes() { + return xVRes; + } - /** - * Return IR virtual screen y resolution. - * - * @return the yVRes - */ - public int getYVRes() { - return yVRes; - } + /** + * Return IR virtual screen y resolution. + * + * @return the yVRes + */ + public int getYVRes() { + return yVRes; + } - /** - * Return IR X correction offset. - * - * @return the xOffset - */ - public int getXOffset() { - return xOffset; - } + /** + * Return IR X correction offset. + * + * @return the xOffset + */ + public int getXOffset() { + return xOffset; + } - /** - * Return IR Y correction offset. - * - * @return the yOffset - */ - public int getYOffset() { - return yOffset; - } + /** + * Return IR Y correction offset. + * + * @return the yOffset + */ + public int getYOffset() { + return yOffset; + } - /** - * Return true if the sensor bar is above. - * - * @return true if the sensor bar is above. - */ - public boolean isSensorBarAbove() { - return sensorBarPostion == WIIUSE_IR_ABOVE; - } + /** + * Return true if the sensor bar is above. + * + * @return true if the sensor bar is above. + */ + public boolean isSensorBarAbove() { + return sensorBarPostion == WIIUSE_IR_ABOVE; + } - /** - * Return true if the sensor bar is below. - * - * @return true if the sensor bar is below. - */ - public boolean isSensorBarBelow() { - return sensorBarPostion == WIIUSE_IR_BELOW; - } + /** + * Return true if the sensor bar is below. + * + * @return true if the sensor bar is below. + */ + public boolean isSensorBarBelow() { + 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. - */ - public boolean isScreenAspectRatio43() { - return screenAsPectRatio == WIIUSE_SCREEN_RATIO_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() { + 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. - */ - public boolean isScreenAspectRatio169() { - return screenAsPectRatio == WIIUSE_SCREEN_RATIO_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() { + return screenAsPectRatio == WIIUSE_SCREEN_RATIO_16_9; + } - /** - * Return aspect ratio of the screen. - * - * @return the screenAsPectRatio - */ - public short getScreenAsPectRatio() { - return screenAsPectRatio; - } + /** + * Return aspect ratio of the screen. + * + * @return the screenAsPectRatio + */ + public short getScreenAsPectRatio() { + return screenAsPectRatio; + } - /** - * 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 - * sensitivity to a degree between 1 (lowest) and 5 (highest). The default - * is 3. - * - * @return the irSensitivity - */ - public short getIrSensitivity() { - return irSensitivity; - } + /** + * 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 + * sensitivity to a degree between 1 (lowest) and 5 (highest). The default + * is 3. + * + * @return the irSensitivity + */ + public short getIrSensitivity() { + return irSensitivity; + } - /** - * Pixel distance between first 2 dots. - * - * @return the distance between first 2 dots. - */ - public float getDistance() { - return distance; - } + /** + * Pixel distance between first 2 dots. + * + * @return the distance between first 2 dots. + */ + public float getDistance() { + return distance; + } - @Override - public String toString() { - String out = ""; - /* Display IR Tracking */ - out += "/******** IR Tracking ********/\n"; - out += "--- Active : true\n"; - out += "--- calculated X coordinate : " + x + "\n"; - out += "--- calculated Y coordinate : " + y + "\n"; - out += "--- calculated Z coordinate : " + z + "\n"; - out += "--- calculated distance : " + distance + "\n"; - out += "--- absolute X coordinate : " + ax + "\n"; - out += "--- absolute Y coordinate : " + ay + "\n"; - out += "--- IR virtual screen x resolution : " + xVRes + "\n"; - out += "--- IR virtual screen y resolution : " + yVRes + "\n"; - out += "--- IR X correction offset : " + xOffset + "\n"; - out += "--- IR Y correction offset : " + yOffset + "\n"; - out += "--- IR Sensitivity (between 1-5) : " + irSensitivity + "\n"; - if (isScreenAspectRatio43()) { - out += "--- aspect ratio of the screen : 4/3\n"; - } else if (isScreenAspectRatio169()) { - out += "--- aspect ratio of the screen : 16/9\n"; - } - if (isSensorBarAbove()) { - out += "--- IR sensor bar position. : Above\n"; - } else if (isSensorBarBelow()) { - out += "--- IR sensor bar position. : Below\n"; - } - out += "--- Seen points\n"; - for (int i = 0; i < IRPoints.length; i++) { - if (IRPoints[i] != null) { - out += IRPoints[i].toString(); - } - } - out += "\n"; - return out; - } + @Override + public String toString() { + String out = ""; + /* Display IR Tracking */ + out += "/******** IR Tracking ********/\n"; + out += "--- Active : true\n"; + out += "--- calculated X coordinate : " + x + "\n"; + out += "--- calculated Y coordinate : " + y + "\n"; + out += "--- calculated Z coordinate : " + z + "\n"; + out += "--- calculated distance : " + distance + "\n"; + out += "--- absolute X coordinate : " + ax + "\n"; + out += "--- absolute Y coordinate : " + ay + "\n"; + out += "--- IR virtual screen x resolution : " + xVRes + "\n"; + out += "--- IR virtual screen y resolution : " + yVRes + "\n"; + out += "--- IR X correction offset : " + xOffset + "\n"; + out += "--- IR Y correction offset : " + yOffset + "\n"; + out += "--- IR Sensitivity (between 1-5) : " + irSensitivity + "\n"; + if (isScreenAspectRatio43()) { + out += "--- aspect ratio of the screen : 4/3\n"; + } else if (isScreenAspectRatio169()) { + out += "--- aspect ratio of the screen : 16/9\n"; + } + if (isSensorBarAbove()) { + out += "--- IR sensor bar position. : Above\n"; + } else if (isSensorBarBelow()) { + out += "--- IR sensor bar position. : Below\n"; + } + out += "--- Seen points\n"; + for (int i = 0; i < IRPoints.length; i++) { + if (IRPoints[i] != null) { + out += IRPoints[i].toString(); + } + } + out += "\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/JoystickEvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/JoystickEvent.java index cab6b1d..cead047 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/JoystickEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/JoystickEvent.java @@ -25,111 +25,111 @@ import wiiusej.wiiusejevents.GenericEvent; */ public class JoystickEvent extends GenericEvent { - private float angle; - private float magnitude; - private short[] max; - private short[] min; - private short[] center; + private float angle; + private float magnitude; + private short[] max; + private short[] min; + private short[] center; - /** - * Constructor of a JoystickEvent. - * - * @param id - * id of the wiimote connected. - * @param angle - * angle the joystick is being held. - * @param magnitude - * magnitude of the joystick (range 0-1). - * @param max1 - * maximum joystick value 1. - * @param max2 - * maximum joystick value 2. - * @param min1 - * minimum joystick value 1. - * @param min2 - * minimum joystick value 2. - * @param center1 - * center joystick value 1. - * @param center2 - * center joystick value 2. - */ - public JoystickEvent(int id, float angle, float magnitude, short max1, - short max2, short min1, short min2, short center1, short center2) { - super(id); - this.angle = angle; - this.magnitude = magnitude; - max = new short[2]; - max[0] = max1; - max[1] = max2; - min = new short[2]; - min[0] = min1; - min[1] = min2; - center = new short[2]; - center[0] = center1; - center[1] = center2; - } + /** + * Constructor of a JoystickEvent. + * + * @param id + * id of the wiimote connected. + * @param angle + * angle the joystick is being held. + * @param magnitude + * magnitude of the joystick (range 0-1). + * @param max1 + * maximum joystick value 1. + * @param max2 + * maximum joystick value 2. + * @param min1 + * minimum joystick value 1. + * @param min2 + * minimum joystick value 2. + * @param center1 + * center joystick value 1. + * @param center2 + * center joystick value 2. + */ + public JoystickEvent(int id, float angle, float magnitude, short max1, + short max2, short min1, short min2, short center1, short center2) { + super(id); + this.angle = angle; + this.magnitude = magnitude; + max = new short[2]; + max[0] = max1; + max[1] = max2; + min = new short[2]; + min[0] = min1; + min[1] = min2; + center = new short[2]; + center[0] = center1; + center[1] = center2; + } - /** - * Get angle the joystick is being held. - * - * @return the angle angle the joystick. - */ - public float getAngle() { - return angle; - } + /** + * Get angle the joystick is being held. + * + * @return the angle angle the joystick. + */ + public float getAngle() { + return angle; + } - /** - * Get magnitude of the joystick (range 0-1). - * - * @return the magnitude magnitude of the joystick. - */ - public float getMagnitude() { - return magnitude; - } + /** + * Get magnitude of the joystick (range 0-1). + * + * @return the magnitude magnitude of the joystick. + */ + public float getMagnitude() { + return magnitude; + } - /** - * Maximum joystick values. - * - * @return the max - */ - public short[] getMax() { - return max; - } + /** + * Maximum joystick values. + * + * @return the max + */ + public short[] getMax() { + return max; + } - /** - * Minimum joystick values. - * - * @return the min - */ - public short[] getMin() { - return min; - } + /** + * Minimum joystick values. + * + * @return the min + */ + public short[] getMin() { + return min; + } - /** - * Center joystick values. - * - * @return the center - */ - public short[] getCenter() { - return center; - } + /** + * Center joystick values. + * + * @return the center + */ + public short[] getCenter() { + return center; + } - /* - * (non-Javadoc) - * - * @see wiiusej.wiiusejevents.GenericEvent#toString() - */ - @Override - public String toString() { - String out = ""; - /* Display IR Tracking */ - out += "/******** Joystick ********/\n"; - out += "--- angle : " + angle + "\n"; - out += "--- magnitude : " + magnitude + "\n"; - out += "--- maximum values : " + max[0] + "," + max[1] + "\n"; - out += "--- minimum values : " + min[0] + "," + min[1] + "\n"; - out += "--- center values : " + center[0] + "," + center[1] + "\n"; - return out; - } + /* + * (non-Javadoc) + * + * @see wiiusej.wiiusejevents.GenericEvent#toString() + */ + @Override + public String toString() { + String out = ""; + /* Display IR Tracking */ + out += "/******** Joystick ********/\n"; + out += "--- angle : " + angle + "\n"; + out += "--- magnitude : " + magnitude + "\n"; + out += "--- maximum values : " + max[0] + "," + max[1] + "\n"; + out += "--- minimum values : " + min[0] + "," + min[1] + "\n"; + out += "--- center values : " + center[0] + "," + center[1] + "\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/MotionSensingEvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/MotionSensingEvent.java index e177fbd..998e255 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/MotionSensingEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/MotionSensingEvent.java @@ -28,176 +28,176 @@ import wiiusej.wiiusejevents.GenericEvent; */ public class MotionSensingEvent extends GenericEvent { - /* Motion Sensing */ - private Orientation orientation; - private GForce gforce; - private RawAcceleration acceleration; + /* Motion Sensing */ + private Orientation orientation; + private GForce gforce; + private RawAcceleration acceleration; - private float orientationThreshold = 0; - private int accelerationThreshold = 0; - private float alphaSmoothing = 0; - private boolean isSmoothingActive = false; + private float orientationThreshold = 0; + private int accelerationThreshold = 0; + private float alphaSmoothing = 0; + private boolean isSmoothingActive = false; - /** - * Constructor for a Motion Sensing Event. - * - * @param id - * id of the wiimote concerned. - * @param orientationThreshold - * value of the minimum angle between two events with the - * accelerometer. - * @param accelerationThreshold - * value of the value variation between two events with the - * accelerometer. - * @param smoothingState - * true if smoothing flag is activated. - * @param alphaSmooth - * value of the alpha smoothing parameter. - * @param r - * roll. - * @param p - * pitch. - * @param ya - * yaw. - * @param ar - * absolute roll. - * @param ap - * absolute pitch. - * @param x - * gravity force on x axis. - * @param y - * gravity force on y axis. - * @param z - * gravity force on z axis. - * @param xx - * raw acceleration on x axis. - * @param yy - * raw acceleration on y axis. - * @param zz - * raw acceleration on z axis. - */ - public MotionSensingEvent(int id, float orientationThreshold, - int accelerationThreshold, boolean smoothingState, - float alphaSmooth, float r, float p, float ya, float ar, float ap, - float x, float y, float z, short xx, short yy, short zz) { - super(id); - this.orientationThreshold = orientationThreshold; - this.accelerationThreshold = accelerationThreshold; - this.isSmoothingActive = smoothingState; - this.alphaSmoothing = alphaSmooth; - setOrientationAndGforce(r, p, ya, ar, ap, x, y, z, xx, yy, zz); - } + /** + * Constructor for a Motion Sensing Event. + * + * @param id + * id of the wiimote concerned. + * @param orientationThreshold + * value of the minimum angle between two events with the + * accelerometer. + * @param accelerationThreshold + * value of the value variation between two events with the + * accelerometer. + * @param smoothingState + * true if smoothing flag is activated. + * @param alphaSmooth + * value of the alpha smoothing parameter. + * @param r + * roll. + * @param p + * pitch. + * @param ya + * yaw. + * @param ar + * absolute roll. + * @param ap + * absolute pitch. + * @param x + * gravity force on x axis. + * @param y + * gravity force on y axis. + * @param z + * gravity force on z axis. + * @param xx + * raw acceleration on x axis. + * @param yy + * raw acceleration on y axis. + * @param zz + * raw acceleration on z axis. + */ + public MotionSensingEvent(int id, float orientationThreshold, + int accelerationThreshold, boolean smoothingState, + float alphaSmooth, float r, float p, float ya, float ar, float ap, + float x, float y, float z, short xx, short yy, short zz) { + super(id); + this.orientationThreshold = orientationThreshold; + this.accelerationThreshold = accelerationThreshold; + this.isSmoothingActive = smoothingState; + this.alphaSmoothing = alphaSmooth; + setOrientationAndGforce(r, p, ya, ar, ap, x, y, z, xx, yy, zz); + } - /** - * Set orientation, gravity force and raw acceleration. - * - * @param r - * roll - * @param p - * pitch - * @param ya - * yaw - * @param ar - * absolute roll - * @param ap - * absolute pitch - * @param x - * gravity force on x axis - * @param y - * gravity force on y axis - * @param z - * gravity force on z axis - * @param xx - * raw acceleration on x axis - * @param yy - * raw acceleration on y axis - * @param zz - * raw acceleration on z axis - */ - 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) { - this.orientation = new Orientation(r, p, ya, ar, ap); - this.gforce = new GForce(x, y, z); - this.acceleration = new RawAcceleration(xx, yy, zz); - } + /** + * Set orientation, gravity force and raw acceleration. + * + * @param r + * roll + * @param p + * pitch + * @param ya + * yaw + * @param ar + * absolute roll + * @param ap + * absolute pitch + * @param x + * gravity force on x axis + * @param y + * gravity force on y axis + * @param z + * gravity force on z axis + * @param xx + * raw acceleration on x axis + * @param yy + * raw acceleration on y axis + * @param zz + * raw acceleration on z axis + */ + 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) { + this.orientation = new Orientation(r, p, ya, ar, ap); + this.gforce = new GForce(x, y, z); + this.acceleration = new RawAcceleration(xx, yy, zz); + } - /** - * @return the orientation - */ - public Orientation getOrientation() { - return orientation; - } + /** + * @return the orientation + */ + public Orientation getOrientation() { + return orientation; + } - /** - * Get the gravity force. - * - * @return the gforce - */ - public GForce getGforce() { - return gforce; - } + /** + * Get the gravity force. + * + * @return the gforce + */ + public GForce getGforce() { + return gforce; + } - /** - * Get the raw acceleration. - * - * @return the raw acceleration - */ - public RawAcceleration getRawAcceleration() { - return acceleration; - } + /** + * Get the raw acceleration. + * + * @return the raw acceleration + */ + public RawAcceleration getRawAcceleration() { + return acceleration; + } - /** - * Get orientation threshold. - * - * @return the orientationThreshold - */ - public float getOrientationThreshold() { - return orientationThreshold; - } + /** + * Get orientation threshold. + * + * @return the orientationThreshold + */ + public float getOrientationThreshold() { + return orientationThreshold; + } - /** - * Get acceleration threshold. - * - * @return the accelerationThreshold - */ - public int getAccelerationThreshold() { - return accelerationThreshold; - } + /** + * Get acceleration threshold. + * + * @return the accelerationThreshold + */ + public int getAccelerationThreshold() { + return accelerationThreshold; + } - /** - * Get alpha smoothing. - * - * @return the alphaSmoothing - */ - public float getAlphaSmoothing() { - return alphaSmoothing; - } + /** + * Get alpha smoothing. + * + * @return the alphaSmoothing + */ + public float getAlphaSmoothing() { + return alphaSmoothing; + } - /** - * Tell if the option SMOOTHING is activated. - * - * @return the isSmoothingActive - */ - public boolean isSmoothingActive() { - return isSmoothingActive; - } + /** + * Tell if the option SMOOTHING is activated. + * + * @return the isSmoothingActive + */ + public boolean isSmoothingActive() { + return isSmoothingActive; + } - @Override - public String toString() { - String out = ""; - /* Motion sensing */ - out += "/******** Motion sensing ********/\n"; - out += "--- Motion sensing : true \n"; - out += "--- Orientation threshold value ? : " + orientationThreshold - + "\n"; - out += "--- Acceleration threshold value ? : " + accelerationThreshold - + "\n"; - out += "--- Alpha smoothing threshold value ? : " + alphaSmoothing - + "\n"; - out += "--- Smoothing ? : " + isSmoothingActive + "\n"; - out += "--- " + orientation + "\n"; - out += "--- " + gforce + "\n"; - out += "--- " + acceleration + "\n"; - return out; - } + @Override + public String toString() { + String out = ""; + /* Motion sensing */ + out += "/******** Motion sensing ********/\n"; + out += "--- Motion sensing : true \n"; + out += "--- Orientation threshold value ? : " + orientationThreshold + + "\n"; + out += "--- Acceleration threshold value ? : " + accelerationThreshold + + "\n"; + out += "--- Alpha smoothing threshold value ? : " + alphaSmoothing + + "\n"; + out += "--- Smoothing ? : " + isSmoothingActive + "\n"; + out += "--- " + orientation + "\n"; + out += "--- " + gforce + "\n"; + out += "--- " + acceleration + "\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/NunchukButtonsEvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/NunchukButtonsEvent.java index 4cab0ae..95cc5a2 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/NunchukButtonsEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/NunchukButtonsEvent.java @@ -23,67 +23,67 @@ package wiiusej.wiiusejevents.physicalevents; */ public class NunchukButtonsEvent extends ButtonsEvent { - private static short NUNCHUK_BUTTON_Z = 0x01; - private static short NUNCHUK_BUTTON_C = 0x02; - private static short NUNCHUK_BUTTON_ALL = 0x03; + private static short NUNCHUK_BUTTON_Z = 0x01; + private static short NUNCHUK_BUTTON_C = 0x02; + private static short NUNCHUK_BUTTON_ALL = 0x03; - /** - * Constructor of the nunchuk buttons Event. - * - * @param id - * id of the wiimote. - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - */ - public NunchukButtonsEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld) { - super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); - } + /** + * Constructor of the nunchuk buttons Event. + * + * @param id + * id of the wiimote. + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + */ + public NunchukButtonsEvent(int id, short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld) { + super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); + } - /* Button Z */ + /* Button Z */ - public boolean isButtonZJustPressed() { - return isButtonJustPressed(NUNCHUK_BUTTON_Z); - } + public boolean isButtonZJustPressed() { + return isButtonJustPressed(NUNCHUK_BUTTON_Z); + } - public boolean isButtonZJustReleased() { - return isButtonJustReleased(NUNCHUK_BUTTON_Z); - } + public boolean isButtonZJustReleased() { + return isButtonJustReleased(NUNCHUK_BUTTON_Z); + } - public boolean isButtonZeHeld() { - return isButtonHeld(NUNCHUK_BUTTON_Z); - } + public boolean isButtonZeHeld() { + return isButtonHeld(NUNCHUK_BUTTON_Z); + } - public boolean isButtonZPressed() { - return isButtonPressed(NUNCHUK_BUTTON_Z); - } + public boolean isButtonZPressed() { + return isButtonPressed(NUNCHUK_BUTTON_Z); + } - /* Button Z */ + /* Button Z */ - public boolean isButtonCJustPressed() { - return isButtonJustPressed(NUNCHUK_BUTTON_C); - } + public boolean isButtonCJustPressed() { + return isButtonJustPressed(NUNCHUK_BUTTON_C); + } - public boolean isButtonCJustReleased() { - return isButtonJustReleased(NUNCHUK_BUTTON_C); - } + public boolean isButtonCJustReleased() { + return isButtonJustReleased(NUNCHUK_BUTTON_C); + } - public boolean isButtonCHeld() { - return isButtonHeld(NUNCHUK_BUTTON_C); - } + public boolean isButtonCHeld() { + return isButtonHeld(NUNCHUK_BUTTON_C); + } - public boolean isButtonCPressed() { - return isButtonPressed(NUNCHUK_BUTTON_C); - } + public boolean isButtonCPressed() { + return isButtonPressed(NUNCHUK_BUTTON_C); + } - @Override - public String toString() { - return "/******** Buttons for Nunchuk Event ********/\n" - + super.toString(); - } + @Override + public String toString() { + return "/******** Buttons for Nunchuk Event ********/\n" + + super.toString(); + } } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/NunchukEvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/NunchukEvent.java index 12a8275..4ad341c 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/NunchukEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/NunchukEvent.java @@ -23,147 +23,147 @@ package wiiusej.wiiusejevents.physicalevents; */ public class NunchukEvent extends ExpansionEvent { - private NunchukButtonsEvent buttonsEvent; - private MotionSensingEvent nunchukMotionSensingEvent; - private JoystickEvent nunchukJoystickEvent; + private NunchukButtonsEvent buttonsEvent; + private MotionSensingEvent nunchukMotionSensingEvent; + private JoystickEvent nunchukJoystickEvent; - /** - * Constructor of NunchukEvent. - * - * @param id - * id of the wiimote. - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - * @param orientationThreshold - * value of the minimum angle between two events with the - * accelerometer. - * @param accelerationThreshold - * value of the value variation between two events with the - * accelerometer. - * @param smoothingState - * true if smoothing flag is activated. - * @param alphaSmooth - * value of the alpha smoothing parameter. - * @param r - * roll. - * @param p - * pitch. - * @param ya - * yaw. - * @param ar - * absolute roll. - * @param ap - * absolute pitch. - * @param x - * gravity force on x axis. - * @param y - * gravity force on y axis. - * @param z - * gravity force on z axis. - * @param xx - * raw acceleration on x axis. - * @param yy - * raw acceleration on y axis. - * @param zz - * raw acceleration on z axis. - * @param angle - * angle the joystick is being held. - * @param magnitude - * magnitude of the joystick (range 0-1). - * @param max1 - * maximum joystick value 1. - * @param max2 - * maximum joystick value 2. - * @param min1 - * minimum joystick value 1. - * @param min2 - * minimum joystick value 2. - * @param center1 - * center joystick value 1. - * @param center2 - * center joystick value 2. - */ - public NunchukEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld, - float orientationThreshold, int accelerationThreshold, - boolean smoothingState, 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 angle, float magnitude, short max1, - short max2, short min1, short min2, short center1, short center2) { - super(id); - buttonsEvent = new NunchukButtonsEvent(id, buttonsJustPressed, - buttonsJustReleased, buttonsHeld); - nunchukMotionSensingEvent = new MotionSensingEvent(id, - orientationThreshold, accelerationThreshold, smoothingState, - alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz); - nunchukJoystickEvent = new JoystickEvent(id, angle, magnitude, max1, - max2, min1, min2, center1, center2); - } + /** + * Constructor of NunchukEvent. + * + * @param id + * id of the wiimote. + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + * @param orientationThreshold + * value of the minimum angle between two events with the + * accelerometer. + * @param accelerationThreshold + * value of the value variation between two events with the + * accelerometer. + * @param smoothingState + * true if smoothing flag is activated. + * @param alphaSmooth + * value of the alpha smoothing parameter. + * @param r + * roll. + * @param p + * pitch. + * @param ya + * yaw. + * @param ar + * absolute roll. + * @param ap + * absolute pitch. + * @param x + * gravity force on x axis. + * @param y + * gravity force on y axis. + * @param z + * gravity force on z axis. + * @param xx + * raw acceleration on x axis. + * @param yy + * raw acceleration on y axis. + * @param zz + * raw acceleration on z axis. + * @param angle + * angle the joystick is being held. + * @param magnitude + * magnitude of the joystick (range 0-1). + * @param max1 + * maximum joystick value 1. + * @param max2 + * maximum joystick value 2. + * @param min1 + * minimum joystick value 1. + * @param min2 + * minimum joystick value 2. + * @param center1 + * center joystick value 1. + * @param center2 + * center joystick value 2. + */ + public NunchukEvent(int id, short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld, + float orientationThreshold, int accelerationThreshold, + boolean smoothingState, 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 angle, float magnitude, short max1, + short max2, short min1, short min2, short center1, short center2) { + super(id); + buttonsEvent = new NunchukButtonsEvent(id, buttonsJustPressed, + buttonsJustReleased, buttonsHeld); + nunchukMotionSensingEvent = new MotionSensingEvent(id, + orientationThreshold, accelerationThreshold, smoothingState, + alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz); + nunchukJoystickEvent = new JoystickEvent(id, angle, magnitude, max1, + max2, min1, min2, center1, center2); + } - /** - * Tell if there is a nunchuk motion sensing Event. - * - * @return TRUE if there is a nunchuk motion sensing event, false otherwise. - */ - public boolean isThereMotionSensingEvent() { - return nunchukMotionSensingEvent != null; - } + /** + * Tell if there is a nunchuk motion sensing Event. + * + * @return TRUE if there is a nunchuk motion sensing event, false otherwise. + */ + public boolean isThereMotionSensingEvent() { + return nunchukMotionSensingEvent != null; + } - /** - * Tell if there is a nunchuk joystick event. - * - * @return TRUE if there is a nunchuk joystick event, false otherwise. - */ - public boolean isThereNunchukJoystickEvent() { - return nunchukJoystickEvent != null; - } + /** + * Tell if there is a nunchuk joystick event. + * + * @return TRUE if there is a nunchuk joystick event, false otherwise. + */ + public boolean isThereNunchukJoystickEvent() { + return nunchukJoystickEvent != null; + } - /** - * Get nunchuk buttons event. - * - * @return the nunchuk buttons event if there is one or null. - */ - public NunchukButtonsEvent getButtonsEvent() { - return buttonsEvent; - } + /** + * Get nunchuk buttons event. + * + * @return the nunchuk buttons event if there is one or null. + */ + public NunchukButtonsEvent getButtonsEvent() { + return buttonsEvent; + } - /** - * Get the nunchuk motion sensing event. - * - * @return the nunchuk motion sensing event if there is one or null. - */ - public MotionSensingEvent getNunchukMotionSensingEvent() { - return nunchukMotionSensingEvent; - } + /** + * Get the nunchuk motion sensing event. + * + * @return the nunchuk motion sensing event if there is one or null. + */ + public MotionSensingEvent getNunchukMotionSensingEvent() { + return nunchukMotionSensingEvent; + } - /** - * Get the nunchuk joystick event. - * - * @return the nunchuk Joystick Event if there is one or null. - */ - public JoystickEvent getNunchukJoystickEvent() { - return nunchukJoystickEvent; - } + /** + * Get the nunchuk joystick event. + * + * @return the nunchuk Joystick Event if there is one or null. + */ + public JoystickEvent getNunchukJoystickEvent() { + return nunchukJoystickEvent; + } - /* - * (non-Javadoc) - * - * @see wiiusej.wiiusejevents.GenericEvent#toString() - */ - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** Nunchuk EVENT : WIIMOTE ID :" + getWiimoteId() - + " ********/\n"; - out += buttonsEvent; - out += nunchukJoystickEvent; - out += nunchukMotionSensingEvent; - return out; - } + /* + * (non-Javadoc) + * + * @see wiiusej.wiiusejevents.GenericEvent#toString() + */ + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** Nunchuk EVENT : WIIMOTE ID :" + getWiimoteId() + + " ********/\n"; + out += buttonsEvent; + out += nunchukJoystickEvent; + out += nunchukMotionSensingEvent; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/physicalevents/WiimoteButtonsEvent.java b/src/main/java/wiiusej/wiiusejevents/physicalevents/WiimoteButtonsEvent.java index 9af3249..d9ed056 100644 --- a/src/main/java/wiiusej/wiiusejevents/physicalevents/WiimoteButtonsEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/physicalevents/WiimoteButtonsEvent.java @@ -24,244 +24,244 @@ package wiiusej.wiiusejevents.physicalevents; */ public class WiimoteButtonsEvent extends ButtonsEvent { - /* Buttons MACRO */ - private static short WIIMOTE_BUTTON_TWO = 0x0001; - private static short WIIMOTE_BUTTON_ONE = 0x0002; - private static short WIIMOTE_BUTTON_B = 0x0004; - private static short WIIMOTE_BUTTON_A = 0x0008; - private static short WIIMOTE_BUTTON_MINUS = 0x0010; - private static short WIIMOTE_BUTTON_ZACCEL_BIT6 = 0x0020; - private static short WIIMOTE_BUTTON_ZACCEL_BIT7 = 0x0040; - private static short WIIMOTE_BUTTON_HOME = 0x0080; - private static short WIIMOTE_BUTTON_LEFT = 0x0100; - private static short WIIMOTE_BUTTON_RIGHT = 0x0200; - private static short WIIMOTE_BUTTON_DOWN = 0x0400; - private static short WIIMOTE_BUTTON_UP = 0x0800; - private static short WIIMOTE_BUTTON_PLUS = 0x1000; - private static short WIIMOTE_BUTTON_ZACCEL_BIT4 = 0x2000; - private static short WIIMOTE_BUTTON_ZACCEL_BIT5 = 0x4000; - private static int WIIMOTE_BUTTON_UNKNOWN = 0x8000; - private static short WIIMOTE_BUTTON_ALL = 0x1F9F; + /* Buttons MACRO */ + private static short WIIMOTE_BUTTON_TWO = 0x0001; + private static short WIIMOTE_BUTTON_ONE = 0x0002; + private static short WIIMOTE_BUTTON_B = 0x0004; + private static short WIIMOTE_BUTTON_A = 0x0008; + private static short WIIMOTE_BUTTON_MINUS = 0x0010; + private static short WIIMOTE_BUTTON_ZACCEL_BIT6 = 0x0020; + private static short WIIMOTE_BUTTON_ZACCEL_BIT7 = 0x0040; + private static short WIIMOTE_BUTTON_HOME = 0x0080; + private static short WIIMOTE_BUTTON_LEFT = 0x0100; + private static short WIIMOTE_BUTTON_RIGHT = 0x0200; + private static short WIIMOTE_BUTTON_DOWN = 0x0400; + private static short WIIMOTE_BUTTON_UP = 0x0800; + private static short WIIMOTE_BUTTON_PLUS = 0x1000; + private static short WIIMOTE_BUTTON_ZACCEL_BIT4 = 0x2000; + private static short WIIMOTE_BUTTON_ZACCEL_BIT5 = 0x4000; + private static int WIIMOTE_BUTTON_UNKNOWN = 0x8000; + private static short WIIMOTE_BUTTON_ALL = 0x1F9F; - /** - * Constructor of the wiimote button Event. - * - * @param id - * id of the wiimote. - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons held. - */ - public WiimoteButtonsEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld) { - super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); - } + /** + * Constructor of the wiimote button Event. + * + * @param id + * id of the wiimote. + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons held. + */ + public WiimoteButtonsEvent(int id, short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld) { + super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld); + } - /* Button ONE */ + /* Button ONE */ - public boolean isButtonOneJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_ONE); - } + public boolean isButtonOneJustPressed() { + return isButtonJustPressed(WIIMOTE_BUTTON_ONE); + } - public boolean isButtonOneJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_ONE); - } + public boolean isButtonOneJustReleased() { + return isButtonJustReleased(WIIMOTE_BUTTON_ONE); + } - public boolean isButtonOneHeld() { - return isButtonHeld(WIIMOTE_BUTTON_ONE); - } + public boolean isButtonOneHeld() { + return isButtonHeld(WIIMOTE_BUTTON_ONE); + } - public boolean isButtonOnePressed() { - return isButtonPressed(WIIMOTE_BUTTON_ONE); - } + public boolean isButtonOnePressed() { + return isButtonPressed(WIIMOTE_BUTTON_ONE); + } - /* Button TWO */ + /* Button TWO */ - public boolean isButtonTwoJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_TWO); - } + public boolean isButtonTwoJustPressed() { + return isButtonJustPressed(WIIMOTE_BUTTON_TWO); + } - public boolean isButtonTwoJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_TWO); - } + public boolean isButtonTwoJustReleased() { + return isButtonJustReleased(WIIMOTE_BUTTON_TWO); + } - public boolean isButtonTwoHeld() { - return isButtonHeld(WIIMOTE_BUTTON_TWO); - } + public boolean isButtonTwoHeld() { + return isButtonHeld(WIIMOTE_BUTTON_TWO); + } - public boolean isButtonTwoPressed() { - return isButtonPressed(WIIMOTE_BUTTON_TWO); - } + public boolean isButtonTwoPressed() { + return isButtonPressed(WIIMOTE_BUTTON_TWO); + } - /* Button A */ + /* Button A */ - public boolean isButtonAJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_A); - } + public boolean isButtonAJustPressed() { + return isButtonJustPressed(WIIMOTE_BUTTON_A); + } - public boolean isButtonAJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_A); - } + public boolean isButtonAJustReleased() { + return isButtonJustReleased(WIIMOTE_BUTTON_A); + } - public boolean isButtonAHeld() { - return isButtonHeld(WIIMOTE_BUTTON_A); - } + public boolean isButtonAHeld() { + return isButtonHeld(WIIMOTE_BUTTON_A); + } - public boolean isButtonAPressed() { - return isButtonPressed(WIIMOTE_BUTTON_A); - } + public boolean isButtonAPressed() { + return isButtonPressed(WIIMOTE_BUTTON_A); + } - /* Button B */ + /* Button B */ - public boolean isButtonBJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_B); - } + public boolean isButtonBJustPressed() { + return isButtonJustPressed(WIIMOTE_BUTTON_B); + } - public boolean isButtonBJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_B); - } + public boolean isButtonBJustReleased() { + return isButtonJustReleased(WIIMOTE_BUTTON_B); + } - public boolean isButtonBHeld() { - return isButtonHeld(WIIMOTE_BUTTON_B); - } + public boolean isButtonBHeld() { + return isButtonHeld(WIIMOTE_BUTTON_B); + } - public boolean isButtonBPressed() { - return isButtonPressed(WIIMOTE_BUTTON_B); - } + public boolean isButtonBPressed() { + return isButtonPressed(WIIMOTE_BUTTON_B); + } - /* Button LEFT */ + /* Button LEFT */ - public boolean isButtonLeftJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_LEFT); - } + public boolean isButtonLeftJustPressed() { + return isButtonJustPressed(WIIMOTE_BUTTON_LEFT); + } - public boolean isButtonLeftJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_LEFT); - } + public boolean isButtonLeftJustReleased() { + return isButtonJustReleased(WIIMOTE_BUTTON_LEFT); + } - public boolean isButtonLeftHeld() { - return isButtonHeld(WIIMOTE_BUTTON_LEFT); - } + public boolean isButtonLeftHeld() { + return isButtonHeld(WIIMOTE_BUTTON_LEFT); + } - public boolean isButtonLeftPressed() { - return isButtonPressed(WIIMOTE_BUTTON_LEFT); - } + public boolean isButtonLeftPressed() { + return isButtonPressed(WIIMOTE_BUTTON_LEFT); + } - /* Button RIGHT */ + /* Button RIGHT */ - public boolean isButtonRightJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_RIGHT); - } + public boolean isButtonRightJustPressed() { + return isButtonJustPressed(WIIMOTE_BUTTON_RIGHT); + } - public boolean isButtonRightJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_RIGHT); - } + public boolean isButtonRightJustReleased() { + return isButtonJustReleased(WIIMOTE_BUTTON_RIGHT); + } - public boolean isButtonRightHeld() { - return isButtonHeld(WIIMOTE_BUTTON_RIGHT); - } + public boolean isButtonRightHeld() { + return isButtonHeld(WIIMOTE_BUTTON_RIGHT); + } - public boolean isButtonRightPressed() { - return isButtonPressed(WIIMOTE_BUTTON_RIGHT); - } + public boolean isButtonRightPressed() { + return isButtonPressed(WIIMOTE_BUTTON_RIGHT); + } - /* Button UP */ + /* Button UP */ - public boolean isButtonUpJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_UP); - } + public boolean isButtonUpJustPressed() { + return isButtonJustPressed(WIIMOTE_BUTTON_UP); + } - public boolean isButtonUpJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_UP); - } + public boolean isButtonUpJustReleased() { + return isButtonJustReleased(WIIMOTE_BUTTON_UP); + } - public boolean isButtonUpHeld() { - return isButtonHeld(WIIMOTE_BUTTON_UP); - } + public boolean isButtonUpHeld() { + return isButtonHeld(WIIMOTE_BUTTON_UP); + } - public boolean isButtonUpPressed() { - return isButtonPressed(WIIMOTE_BUTTON_UP); - } + public boolean isButtonUpPressed() { + return isButtonPressed(WIIMOTE_BUTTON_UP); + } - /* Button DOWN */ + /* Button DOWN */ - public boolean isButtonDownJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_DOWN); - } + public boolean isButtonDownJustPressed() { + return isButtonJustPressed(WIIMOTE_BUTTON_DOWN); + } - public boolean isButtonDownJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_DOWN); - } + public boolean isButtonDownJustReleased() { + return isButtonJustReleased(WIIMOTE_BUTTON_DOWN); + } - public boolean isButtonDownHeld() { - return isButtonHeld(WIIMOTE_BUTTON_DOWN); - } + public boolean isButtonDownHeld() { + return isButtonHeld(WIIMOTE_BUTTON_DOWN); + } - public boolean isButtonDownPressed() { - return isButtonPressed(WIIMOTE_BUTTON_DOWN); - } + public boolean isButtonDownPressed() { + return isButtonPressed(WIIMOTE_BUTTON_DOWN); + } - /* Button - */ + /* Button - */ - public boolean isButtonMinusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_MINUS); - } + public boolean isButtonMinusJustPressed() { + return isButtonJustPressed(WIIMOTE_BUTTON_MINUS); + } - public boolean isButtonMinusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_MINUS); - } + public boolean isButtonMinusJustReleased() { + return isButtonJustReleased(WIIMOTE_BUTTON_MINUS); + } - public boolean isButtonMinusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_MINUS); - } + public boolean isButtonMinusHeld() { + return isButtonHeld(WIIMOTE_BUTTON_MINUS); + } - public boolean isButtonMinusPressed() { - return isButtonPressed(WIIMOTE_BUTTON_MINUS); - } + public boolean isButtonMinusPressed() { + return isButtonPressed(WIIMOTE_BUTTON_MINUS); + } - /* Button + */ + /* Button + */ - public boolean isButtonPlusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_PLUS); - } + public boolean isButtonPlusJustPressed() { + return isButtonJustPressed(WIIMOTE_BUTTON_PLUS); + } - public boolean isButtonPlusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_PLUS); - } + public boolean isButtonPlusJustReleased() { + return isButtonJustReleased(WIIMOTE_BUTTON_PLUS); + } - public boolean isButtonPlusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_PLUS); - } + public boolean isButtonPlusHeld() { + return isButtonHeld(WIIMOTE_BUTTON_PLUS); + } - public boolean isButtonPlusPressed() { - return isButtonPressed(WIIMOTE_BUTTON_PLUS); - } + public boolean isButtonPlusPressed() { + return isButtonPressed(WIIMOTE_BUTTON_PLUS); + } - /* Button HOME */ + /* Button HOME */ - public boolean isButtonHomeJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_HOME); - } + public boolean isButtonHomeJustPressed() { + return isButtonJustPressed(WIIMOTE_BUTTON_HOME); + } - public boolean isButtonHomeJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_HOME); - } + public boolean isButtonHomeJustReleased() { + return isButtonJustReleased(WIIMOTE_BUTTON_HOME); + } - public boolean isButtonHomeHeld() { - return isButtonHeld(WIIMOTE_BUTTON_HOME); - } + public boolean isButtonHomeHeld() { + return isButtonHeld(WIIMOTE_BUTTON_HOME); + } - public boolean isButtonHomePressed() { - return isButtonPressed(WIIMOTE_BUTTON_HOME); - } + public boolean isButtonHomePressed() { + return isButtonPressed(WIIMOTE_BUTTON_HOME); + } - @Override - public String toString() { - return "/******** Buttons for Wiimote generic Event ********/\n" - + super.toString(); - } + @Override + public String toString() { + return "/******** Buttons for Wiimote generic Event ********/\n" + + super.toString(); + } } diff --git a/src/main/java/wiiusej/wiiusejevents/utils/EventsGatherer.java b/src/main/java/wiiusej/wiiusejevents/utils/EventsGatherer.java index cc5382e..752a35b 100644 --- a/src/main/java/wiiusej/wiiusejevents/utils/EventsGatherer.java +++ b/src/main/java/wiiusej/wiiusejevents/utils/EventsGatherer.java @@ -34,476 +34,476 @@ import wiiusej.wiiusejevents.wiiuseapievents.WiimoteEvent; */ public class EventsGatherer { - private WiiUseApiEvent[] events; - private int index = 0; - private WiimoteEvent genericEvent = null; + private WiiUseApiEvent[] events; + private int index = 0; + private WiimoteEvent genericEvent = null; - /** - * Create EventsGatherer. - * - * @param nbWiimotes - * nb wiimotes (nb a of events possible in a call to Wiiuse API). - */ - public EventsGatherer(int nbWiimotes) { - events = new WiiUseApiEvent[nbWiimotes]; - } + /** + * Create EventsGatherer. + * + * @param nbWiimotes + * nb wiimotes (nb a of events possible in a call to Wiiuse API). + */ + public EventsGatherer(int nbWiimotes) { + events = new WiiUseApiEvent[nbWiimotes]; + } - /** - * Add an event to the array. - * - * @param e - * the event to add. - */ - private void addEvent(WiiUseApiEvent e) { - events[index] = e; - index++; - } + /** + * Add an event to the array. + * + * @param e + * the event to add. + */ + private void addEvent(WiiUseApiEvent e) { + events[index] = e; + index++; + } - /** - * Prepare a wiimote event to add. - * - * @param id - * id of the wiimote. - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons held. - */ - public void prepareWiiMoteEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld) { - genericEvent = new WiimoteEvent(id, buttonsJustPressed, - buttonsJustReleased, buttonsHeld); - } + /** + * Prepare a wiimote event to add. + * + * @param id + * id of the wiimote. + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons held. + */ + public void prepareWiiMoteEvent(int id, short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld) { + genericEvent = new WiimoteEvent(id, buttonsJustPressed, + buttonsJustReleased, buttonsHeld); + } - /** - * Prepare an IR event to populate. - * - * @param x - * calculated X coordinate. - * @param y - * calculated Y coordinate. - * @param z - * calculated distance. - * @param ax - * absolute X coordinate. - * @param ay - * absolute Y coordinate. - * @param xVRes - * IR virtual screen x resolution. - * @param yVRes - * IR virtual screen y resolution. - * @param xOffset - * IR X correction offset. - * @param yOffset - * IR Y correction offset. - * @param sensorBarPostion - * aspect ratio of the screen. - * @param screenAsPectRatio - * IR sensor bar position. - * @param irSensitivity - * Sensitivity of the infrared camera. - * @param distance - * Pixel Distance between first two dots. - */ - public void prepareIRevent(int x, int y, float z, int ax, int ay, - int xVRes, int yVRes, int xOffset, int yOffset, - short sensorBarPostion, short screenAsPectRatio, - short irSensitivity, float distance) { - genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes, yVRes, xOffset, - yOffset, sensorBarPostion, screenAsPectRatio, irSensitivity, - distance); + /** + * Prepare an IR event to populate. + * + * @param x + * calculated X coordinate. + * @param y + * calculated Y coordinate. + * @param z + * calculated distance. + * @param ax + * absolute X coordinate. + * @param ay + * absolute Y coordinate. + * @param xVRes + * IR virtual screen x resolution. + * @param yVRes + * IR virtual screen y resolution. + * @param xOffset + * IR X correction offset. + * @param yOffset + * IR Y correction offset. + * @param sensorBarPostion + * aspect ratio of the screen. + * @param screenAsPectRatio + * IR sensor bar position. + * @param irSensitivity + * Sensitivity of the infrared camera. + * @param distance + * Pixel Distance between first two dots. + */ + public void prepareIRevent(int x, int y, float z, int ax, int ay, + int xVRes, int yVRes, int xOffset, int yOffset, + short sensorBarPostion, short screenAsPectRatio, + short irSensitivity, float distance) { + genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes, yVRes, xOffset, + yOffset, sensorBarPostion, screenAsPectRatio, irSensitivity, + distance); - } + } - /** - * Add an IR point to the WiiMoteEvent prepared. - * - * @param x - * x coordinates. - * @param y - * y coordinates. - * @param rx - * raw X coordinate (0-1023). - * @param ry - * raw Y coordinate (0-1023). - * @param size - * size of the IR dot (0-15). - */ - public void addIRPointToPreparedWiiMoteEvent(int x, int y, short rx, - short ry, short size) { - if (genericEvent != null) { - genericEvent.addIRpoint(x, y, rx, ry, size); - } - } + /** + * Add an IR point to the WiiMoteEvent prepared. + * + * @param x + * x coordinates. + * @param y + * y coordinates. + * @param rx + * raw X coordinate (0-1023). + * @param ry + * raw Y coordinate (0-1023). + * @param size + * size of the IR dot (0-15). + */ + public void addIRPointToPreparedWiiMoteEvent(int x, int y, short rx, + short ry, short size) { + if (genericEvent != null) { + genericEvent.addIRpoint(x, y, rx, ry, size); + } + } - /** - * Set orientation and gravity force of the prepared event. - * - * @param orientationThreshold - * value of the minimum angle between two events with the - * accelerometer. - * @param accelerationThreshold - * value of the value variation between two events with the - * accelerometer. - * @param smoothingState - * true if smoothing flag is activated. - * @param alphaSmooth - * value of the alpha smoothing parameter. - * @param r - * roll. - * @param p - * pitch. - * @param ya - * yaw. - * @param ar - * absolute roll. - * @param ap - * absolute pitch. - * @param x - * gravity force on x axis. - * @param y - * gravity force on y axis. - * @param z - * gravity force on z axis. - * @param xx - * raw acceleration on x axis. - * @param yy - * raw acceleration on y axis. - * @param zz - * raw acceleration on z axis. - */ - public void addMotionSensingValues(float orientationThreshold, - int accelerationThreshold, boolean smoothingState, - float alphaSmooth, float r, float p, float ya, float ar, float ap, - float x, float y, float z, short xx, short yy, short zz) { - if (genericEvent != null) { - genericEvent.setMotionSensingEvent(orientationThreshold, - accelerationThreshold, smoothingState, alphaSmooth, r, p, - ya, ar, ap, x, y, z, xx, yy, zz); - } - } + /** + * Set orientation and gravity force of the prepared event. + * + * @param orientationThreshold + * value of the minimum angle between two events with the + * accelerometer. + * @param accelerationThreshold + * value of the value variation between two events with the + * accelerometer. + * @param smoothingState + * true if smoothing flag is activated. + * @param alphaSmooth + * value of the alpha smoothing parameter. + * @param r + * roll. + * @param p + * pitch. + * @param ya + * yaw. + * @param ar + * absolute roll. + * @param ap + * absolute pitch. + * @param x + * gravity force on x axis. + * @param y + * gravity force on y axis. + * @param z + * gravity force on z axis. + * @param xx + * raw acceleration on x axis. + * @param yy + * raw acceleration on y axis. + * @param zz + * raw acceleration on z axis. + */ + public void addMotionSensingValues(float orientationThreshold, + int accelerationThreshold, boolean smoothingState, + float alphaSmooth, float r, float p, float ya, float ar, float ap, + float x, float y, float z, short xx, short yy, short zz) { + if (genericEvent != null) { + genericEvent.setMotionSensingEvent(orientationThreshold, + accelerationThreshold, smoothingState, alphaSmooth, r, p, + ya, ar, ap, x, y, z, xx, yy, zz); + } + } - /** - * Set a NunchukEvent to the prepared WiimoteEvent. - * - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - * @param orientationThreshold - * value of the minimum angle between two events with the - * accelerometer. - * @param accelerationThreshold - * value of the value variation between two events with the - * accelerometer. - * @param smoothingState - * true if smoothing flag is activated. - * @param alphaSmooth - * value of the alpha smoothing parameter. - * @param r - * roll. - * @param p - * pitch. - * @param ya - * yaw. - * @param ar - * absolute roll. - * @param ap - * absolute pitch. - * @param x - * gravity force on x axis. - * @param y - * gravity force on y axis. - * @param z - * gravity force on z axis. - * @param xx - * raw acceleration on x axis. - * @param yy - * raw acceleration on y axis. - * @param zz - * raw acceleration on z axis. - * @param angle - * angle the joystick is being held. - * @param magnitude - * magnitude of the joystick (range 0-1). - * @param max1 - * maximum joystick value 1. - * @param max2 - * maximum joystick value 2. - * @param min1 - * minimum joystick value 1. - * @param min2 - * minimum joystick value 2. - * @param center1 - * center joystick value 1. - * @param center2 - * center joystick value 2. - */ - public void addNunchunkEventToPreparedWiimoteEvent( - short buttonsJustPressed, short buttonsJustReleased, - short buttonsHeld, float orientationThreshold, - int accelerationThreshold, boolean smoothingState, - 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 angle, float magnitude, short max1, short max2, short min1, - short min2, short center1, short center2) { - if (genericEvent != null) { - genericEvent.setNunchukEvent(buttonsJustPressed, - buttonsJustReleased, buttonsHeld, orientationThreshold, - accelerationThreshold, smoothingState, alphaSmooth, r, p, - ya, ar, ap, x, y, z, xx, yy, zz, angle, magnitude, max1, - max2, min1, min2, center1, center2); - } - } + /** + * Set a NunchukEvent to the prepared WiimoteEvent. + * + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + * @param orientationThreshold + * value of the minimum angle between two events with the + * accelerometer. + * @param accelerationThreshold + * value of the value variation between two events with the + * accelerometer. + * @param smoothingState + * true if smoothing flag is activated. + * @param alphaSmooth + * value of the alpha smoothing parameter. + * @param r + * roll. + * @param p + * pitch. + * @param ya + * yaw. + * @param ar + * absolute roll. + * @param ap + * absolute pitch. + * @param x + * gravity force on x axis. + * @param y + * gravity force on y axis. + * @param z + * gravity force on z axis. + * @param xx + * raw acceleration on x axis. + * @param yy + * raw acceleration on y axis. + * @param zz + * raw acceleration on z axis. + * @param angle + * angle the joystick is being held. + * @param magnitude + * magnitude of the joystick (range 0-1). + * @param max1 + * maximum joystick value 1. + * @param max2 + * maximum joystick value 2. + * @param min1 + * minimum joystick value 1. + * @param min2 + * minimum joystick value 2. + * @param center1 + * center joystick value 1. + * @param center2 + * center joystick value 2. + */ + public void addNunchunkEventToPreparedWiimoteEvent( + short buttonsJustPressed, short buttonsJustReleased, + short buttonsHeld, float orientationThreshold, + int accelerationThreshold, boolean smoothingState, + 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 angle, float magnitude, short max1, short max2, short min1, + short min2, short center1, short center2) { + if (genericEvent != null) { + genericEvent.setNunchukEvent(buttonsJustPressed, + buttonsJustReleased, buttonsHeld, orientationThreshold, + accelerationThreshold, smoothingState, alphaSmooth, r, p, + ya, ar, ap, x, y, z, xx, yy, zz, angle, magnitude, max1, + max2, min1, min2, center1, center2); + } + } - /** - * Set a GuitarHeroEvent to the prepared WiimoteEvent. - * - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - * @param whammyBar - * whammy bar (range 0-1). - * @param angle - * angle the joystick is being held. - * @param magnitude - * magnitude of the joystick (range 0-1). - * @param max1 - * maximum joystick value 1. - * @param max2 - * maximum joystick value 2. - * @param min1 - * minimum joystick value 1. - * @param min2 - * minimum joystick value 2. - * @param center1 - * center joystick value 1. - * @param center2 - * center joystick value 2. - */ - public void addGuitarHeroEventToPreparedWiimoteEvent( - short buttonsJustPressed, short buttonsJustReleased, - short buttonsHeld, float whammyBar, float angle, float magnitude, - short max1, short max2, short min1, short min2, short center1, - short center2) { - if (genericEvent != null) { - genericEvent.setGuitarHeroEvent(buttonsJustPressed, - buttonsJustReleased, buttonsHeld, whammyBar, angle, - magnitude, max1, max2, min1, min2, center1, center2); - } - } + /** + * Set a GuitarHeroEvent to the prepared WiimoteEvent. + * + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + * @param whammyBar + * whammy bar (range 0-1). + * @param angle + * angle the joystick is being held. + * @param magnitude + * magnitude of the joystick (range 0-1). + * @param max1 + * maximum joystick value 1. + * @param max2 + * maximum joystick value 2. + * @param min1 + * minimum joystick value 1. + * @param min2 + * minimum joystick value 2. + * @param center1 + * center joystick value 1. + * @param center2 + * center joystick value 2. + */ + public void addGuitarHeroEventToPreparedWiimoteEvent( + short buttonsJustPressed, short buttonsJustReleased, + short buttonsHeld, float whammyBar, float angle, float magnitude, + short max1, short max2, short min1, short min2, short center1, + short center2) { + if (genericEvent != null) { + genericEvent.setGuitarHeroEvent(buttonsJustPressed, + buttonsJustReleased, buttonsHeld, whammyBar, angle, + magnitude, max1, max2, min1, min2, center1, center2); + } + } - /** - * Set a ClassicControllerEvent to the prepared WiimoteEvent. - * - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - * @param rightShoulder - * right shoulder button (range 0-1). - * @param leftShoulder - * left shoulder button (range 0-1). - * @param langle - * angle the left joystick is being held. - * @param lmagnitude - * magnitude of the left joystick (range 0-1). - * @param lmax1 - * maximum left joystick value 1. - * @param lmax2 - * maximum left joystick value 2. - * @param lmin1 - * minimum left joystick value 1. - * @param lmin2 - * minimum left joystick value 2. - * @param lcenter1 - * center left joystick value 1. - * @param lcenter2 - * center left joystick value 2. - * @param rangle - * angle the right joystick is being held. - * @param rmagnitude - * magnitude of the right joystick (range 0-1). - * @param rmax1 - * maximum right joystick value 1. - * @param rmax2 - * maximum right joystick value 2. - * @param rmin1 - * minimum right joystick value 1. - * @param rmin2 - * minimum right joystick value 2. - * @param rcenter1 - * center right joystick value 1. - * @param rcenter2 - * center right joystick value 2. - */ - public void addClassicControllerEventToPreparedWiimoteEvent(short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld, float rightShoulder, - float leftShoulder, float langle, float lmagnitude, short lmax1, - short lmax2, short lmin1, short lmin2, short lcenter1, - short lcenter2, float rangle, float rmagnitude, short rmax1, - short rmax2, short rmin1, short rmin2, short rcenter1, - short rcenter2) { - if (genericEvent != null) { - genericEvent.setClassicControllerEvent(buttonsJustPressed, - buttonsJustReleased, buttonsHeld, rightShoulder, - leftShoulder, langle, lmagnitude, lmax1, lmax2, lmin1, - lmin2, lcenter1, lcenter2, rangle, rmagnitude, rmax1, - rmax2, rmin1, rmin2, rcenter1, rcenter2); - } - } + /** + * Set a ClassicControllerEvent to the prepared WiimoteEvent. + * + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + * @param rightShoulder + * right shoulder button (range 0-1). + * @param leftShoulder + * left shoulder button (range 0-1). + * @param langle + * angle the left joystick is being held. + * @param lmagnitude + * magnitude of the left joystick (range 0-1). + * @param lmax1 + * maximum left joystick value 1. + * @param lmax2 + * maximum left joystick value 2. + * @param lmin1 + * minimum left joystick value 1. + * @param lmin2 + * minimum left joystick value 2. + * @param lcenter1 + * center left joystick value 1. + * @param lcenter2 + * center left joystick value 2. + * @param rangle + * angle the right joystick is being held. + * @param rmagnitude + * magnitude of the right joystick (range 0-1). + * @param rmax1 + * maximum right joystick value 1. + * @param rmax2 + * maximum right joystick value 2. + * @param rmin1 + * minimum right joystick value 1. + * @param rmin2 + * minimum right joystick value 2. + * @param rcenter1 + * center right joystick value 1. + * @param rcenter2 + * center right joystick value 2. + */ + public void addClassicControllerEventToPreparedWiimoteEvent(short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld, float rightShoulder, + float leftShoulder, float langle, float lmagnitude, short lmax1, + short lmax2, short lmin1, short lmin2, short lcenter1, + short lcenter2, float rangle, float rmagnitude, short rmax1, + short rmax2, short rmin1, short rmin2, short rcenter1, + short rcenter2) { + if (genericEvent != null) { + genericEvent.setClassicControllerEvent(buttonsJustPressed, + buttonsJustReleased, buttonsHeld, rightShoulder, + leftShoulder, langle, lmagnitude, lmax1, lmax2, lmin1, + lmin2, lcenter1, lcenter2, rangle, rmagnitude, rmax1, + rmax2, rmin1, rmin2, rcenter1, rcenter2); + } + } - /** - * Add the prepared WiimoteEvent to the gatherer. - */ - public void addWiimoteEvent() { - if (genericEvent != null) { - addEvent(genericEvent); - genericEvent = null; - } - } + /** + * Add the prepared WiimoteEvent to the gatherer. + */ + public void addWiimoteEvent() { + if (genericEvent != null) { + addEvent(genericEvent); + genericEvent = null; + } + } - /** - * Add a StatusEvent to the gatherer. - * - * @param id - * id of the wiimote. - * @param connect - * true if the wiimote is connected. - * @param batt - * battery level. - * @param led - * status of leds. - * @param speak - * speakers status. - * @param attach - * attachment status. - * @param rumbleState - * true if rumble is active. - * @param continuousState - * true if continuous flag is activated. - * @param irState - * true if ir is active. - * @param motionSensingState - * true if accelerometer is active. - */ - public void addStatusEvent(int id, boolean connect, float batt, short led, - boolean speak, int attach, boolean rumbleState, - boolean continuousState, boolean irState, boolean motionSensingState) { - StatusEvent evt = new StatusEvent(id, connect, batt, led, speak, - attach, rumbleState, continuousState, irState, - motionSensingState); - addEvent(evt); - } + /** + * Add a StatusEvent to the gatherer. + * + * @param id + * id of the wiimote. + * @param connect + * true if the wiimote is connected. + * @param batt + * battery level. + * @param led + * status of leds. + * @param speak + * speakers status. + * @param attach + * attachment status. + * @param rumbleState + * true if rumble is active. + * @param continuousState + * true if continuous flag is activated. + * @param irState + * true if ir is active. + * @param motionSensingState + * true if accelerometer is active. + */ + public void addStatusEvent(int id, boolean connect, float batt, short led, + boolean speak, int attach, boolean rumbleState, + boolean continuousState, boolean irState, boolean motionSensingState) { + StatusEvent evt = new StatusEvent(id, connect, batt, led, speak, + attach, rumbleState, continuousState, irState, + motionSensingState); + addEvent(evt); + } - /** - * Add a DisconnectionEvent to the gatherer. - * - * @param id - * id of the wiimote. - */ - public void addDisconnectionEvent(int id) { - DisconnectionEvent evt = new DisconnectionEvent(id); - addEvent(evt); - } + /** + * Add a DisconnectionEvent to the gatherer. + * + * @param id + * id of the wiimote. + */ + public void addDisconnectionEvent(int id) { + DisconnectionEvent evt = new DisconnectionEvent(id); + addEvent(evt); + } - /** - * Add a NunchukInsertedEvent to the gatherer. - * - * @param id - * id of the wiimote. - */ - public void addNunchukInsertedEvent(int id) { - NunchukInsertedEvent evt = new NunchukInsertedEvent(id); - addEvent(evt); - } + /** + * Add a NunchukInsertedEvent to the gatherer. + * + * @param id + * id of the wiimote. + */ + public void addNunchukInsertedEvent(int id) { + NunchukInsertedEvent evt = new NunchukInsertedEvent(id); + addEvent(evt); + } - /** - * Add a NunchukRemovedEvent to the gatherer. - * - * @param id - * id of the wiimote. - */ - public void addNunchukRemovedEvent(int id) { - NunchukRemovedEvent evt = new NunchukRemovedEvent(id); - addEvent(evt); - } + /** + * Add a NunchukRemovedEvent to the gatherer. + * + * @param id + * id of the wiimote. + */ + public void addNunchukRemovedEvent(int id) { + NunchukRemovedEvent evt = new NunchukRemovedEvent(id); + addEvent(evt); + } - /** - * Add a GuitarHeroInsertedEvent to the gatherer. - * - * @param id - * id of the wiimote. - */ - public void addGuitarHeroInsertedEvent(int id) { - GuitarHeroInsertedEvent evt = new GuitarHeroInsertedEvent(id); - addEvent(evt); - } + /** + * Add a GuitarHeroInsertedEvent to the gatherer. + * + * @param id + * id of the wiimote. + */ + public void addGuitarHeroInsertedEvent(int id) { + GuitarHeroInsertedEvent evt = new GuitarHeroInsertedEvent(id); + addEvent(evt); + } - /** - * Add a GuitarHeroRemovedEvent to the gatherer. - * - * @param id - * id of the wiimote. - */ - public void addGuitarHeroRemovedEvent(int id) { - GuitarHeroRemovedEvent evt = new GuitarHeroRemovedEvent(id); - addEvent(evt); - } + /** + * Add a GuitarHeroRemovedEvent to the gatherer. + * + * @param id + * id of the wiimote. + */ + public void addGuitarHeroRemovedEvent(int id) { + GuitarHeroRemovedEvent evt = new GuitarHeroRemovedEvent(id); + addEvent(evt); + } - /** - * Add a ClassicControllerInsertedEvent to the gatherer. - * - * @param id - * id of the wiimote. - */ - public void addClassicControllerInsertedEvent(int id) { - ClassicControllerInsertedEvent evt = new ClassicControllerInsertedEvent( - id); - addEvent(evt); - } + /** + * Add a ClassicControllerInsertedEvent to the gatherer. + * + * @param id + * id of the wiimote. + */ + public void addClassicControllerInsertedEvent(int id) { + ClassicControllerInsertedEvent evt = new ClassicControllerInsertedEvent( + id); + addEvent(evt); + } - /** - * Add a ClassicControllerRemovedEvent to the gatherer. - * - * @param id - * id of the wiimote. - */ - public void addClassicControllerRemovedEvent(int id) { - ClassicControllerRemovedEvent evt = new ClassicControllerRemovedEvent( - id); - addEvent(evt); - } + /** + * Add a ClassicControllerRemovedEvent to the gatherer. + * + * @param id + * id of the wiimote. + */ + public void addClassicControllerRemovedEvent(int id) { + ClassicControllerRemovedEvent evt = new ClassicControllerRemovedEvent( + id); + addEvent(evt); + } - /** - * Return an array containing the events. - * - * @return events received. - */ - public WiiUseApiEvent[] getEvents() { - WiiUseApiEvent[] ev = new WiiUseApiEvent[index]; + /** + * Return an array containing the events. + * + * @return events received. + */ + public WiiUseApiEvent[] getEvents() { + WiiUseApiEvent[] ev = new WiiUseApiEvent[index]; System.arraycopy(events, 0, ev, 0, index); return ev; - } + } - /** - * Clear the gatherer and remove objects. - */ - public void clearEvents() { - for (int i = 0; i < events.length; i++) { - events[i] = null; - } - genericEvent = null; - index = 0; - } + /** + * Clear the gatherer and remove objects. + */ + public void clearEvents() { + for (int i = 0; i < events.length; i++) { + events[i] = null; + } + genericEvent = null; + index = 0; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/utils/WiiUseApiListener.java b/src/main/java/wiiusej/wiiusejevents/utils/WiiUseApiListener.java index b38f0f5..958ef08 100644 --- a/src/main/java/wiiusej/wiiusejevents/utils/WiiUseApiListener.java +++ b/src/main/java/wiiusej/wiiusejevents/utils/WiiUseApiListener.java @@ -25,13 +25,13 @@ import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent; */ public interface WiiUseApiListener extends java.util.EventListener { - /** - * Method called when a WiiUseApiEvent occurs. A WiiUseApiEvent can be : - - * WiimoteEvent (Storing ButtonsEvent and eventually IREvent and - * MotionSensingEvent) - StatusEvent - DisconnectionEvent - * - * @param e - */ - void onWiiUseApiEvent(WiiUseApiEvent e); + /** + * Method called when a WiiUseApiEvent occurs. A WiiUseApiEvent can be : - + * WiimoteEvent (Storing ButtonsEvent and eventually IREvent and + * MotionSensingEvent) - StatusEvent - DisconnectionEvent + * + * @param e + */ + void onWiiUseApiEvent(WiiUseApiEvent e); } diff --git a/src/main/java/wiiusej/wiiusejevents/utils/WiimoteListener.java b/src/main/java/wiiusej/wiiusejevents/utils/WiimoteListener.java index d97293d..af73db7 100644 --- a/src/main/java/wiiusej/wiiusejevents/utils/WiimoteListener.java +++ b/src/main/java/wiiusej/wiiusejevents/utils/WiimoteListener.java @@ -39,107 +39,107 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; */ public interface WiimoteListener extends java.util.EventListener { - /** - * Method called on a button Event. - * - * @param e - * the buttonEvent with the last informations about the buttons - * of the wiimote. - */ - void onButtonsEvent(WiimoteButtonsEvent e); + /** + * Method called on a button Event. + * + * @param e + * the buttonEvent with the last informations about the buttons + * of the wiimote. + */ + void onButtonsEvent(WiimoteButtonsEvent e); - /** - * Method called when an IR event occurs. - * - * @param e - * the IREvent with the IR points seen. - */ - void onIrEvent(IREvent e); + /** + * Method called when an IR event occurs. + * + * @param e + * the IREvent with the IR points seen. + */ + void onIrEvent(IREvent e); - /** - * Method called when a motion sensing event occurs. - * - * @param e - * the motion sensing event with orientation and acceleration. - */ - void onMotionSensingEvent(MotionSensingEvent e); + /** + * Method called when a motion sensing event occurs. + * + * @param e + * the motion sensing event with orientation and acceleration. + */ + void onMotionSensingEvent(MotionSensingEvent e); - /** - * Method called when an expansion event occurs. - * - * @param e - * the expansion event occured. - */ - void onExpansionEvent(ExpansionEvent e); + /** + * Method called when an expansion event occurs. + * + * @param e + * the expansion event occured. + */ + void onExpansionEvent(ExpansionEvent e); - /** - * Method called on a status event. A status event occurs when : - we ask it - - * an expansion controller has been plugged - an expansion controller has - * been unplugged This is where you can get the different values of the - * parameters setup on your wiimote. - * - * @param e - * the status event. - */ - void onStatusEvent(StatusEvent e); + /** + * Method called on a status event. A status event occurs when : - we ask it - + * an expansion controller has been plugged - an expansion controller has + * been unplugged This is where you can get the different values of the + * parameters setup on your wiimote. + * + * @param e + * the status event. + */ + void onStatusEvent(StatusEvent e); - /** - * This is the method called when a disconnection event occurs. A - * disconnection event happens when : - there are no battery left - the - * wiimote has just been turned off - the connection is dropped - * - * @param e - * the disconnection event. - */ - void onDisconnectionEvent(DisconnectionEvent e); + /** + * This is the method called when a disconnection event occurs. A + * disconnection event happens when : - there are no battery left - the + * wiimote has just been turned off - the connection is dropped + * + * @param e + * the disconnection event. + */ + void onDisconnectionEvent(DisconnectionEvent e); - /** - * This is the method called when a NunchukInsertedEvent occurs. - * - * @param e - * the NunchukInsertedEvent. - */ - void onNunchukInsertedEvent(NunchukInsertedEvent e); + /** + * This is the method called when a NunchukInsertedEvent occurs. + * + * @param e + * the NunchukInsertedEvent. + */ + void onNunchukInsertedEvent(NunchukInsertedEvent e); - /** - * This is the method called when a NunchukRemovedEvent occurs. - * - * @param e - * the NunchukRemovedEvent. - */ - void onNunchukRemovedEvent(NunchukRemovedEvent e); - - - /** - * This is the method called when a GuitarHeroInsertedEvent occurs. - * - * @param e - * the GuitarHeroInsertedEvent. - */ - void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e); + /** + * This is the method called when a NunchukRemovedEvent occurs. + * + * @param e + * the NunchukRemovedEvent. + */ + void onNunchukRemovedEvent(NunchukRemovedEvent e); + + + /** + * This is the method called when a GuitarHeroInsertedEvent occurs. + * + * @param e + * the GuitarHeroInsertedEvent. + */ + void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e); - /** - * This is the method called when a GuitarHeroRemovedEvent occurs. - * - * @param e - * the GuitarHeroRemovedEvent. - */ - void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e); - - /** - * This is the method called when a ClassicControllerInsertedEvent occurs. - * - * @param e - * the ClassicControllerInsertedEvent. - */ - void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent e); + /** + * This is the method called when a GuitarHeroRemovedEvent occurs. + * + * @param e + * the GuitarHeroRemovedEvent. + */ + void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e); + + /** + * This is the method called when a ClassicControllerInsertedEvent occurs. + * + * @param e + * the ClassicControllerInsertedEvent. + */ + void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent e); - /** - * This is the method called when a ClassicControllerRemovedEvent occurs. - * - * @param e - * the ClassicControllerRemovedEvent. - */ - void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e); + /** + * This is the method called when a ClassicControllerRemovedEvent occurs. + * + * @param e + * the ClassicControllerRemovedEvent. + */ + void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e); } diff --git a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/ClassicControllerInsertedEvent.java b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/ClassicControllerInsertedEvent.java index f61be56..f16a8dc 100644 --- a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/ClassicControllerInsertedEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/ClassicControllerInsertedEvent.java @@ -24,23 +24,23 @@ package wiiusej.wiiusejevents.wiiuseapievents; */ public class ClassicControllerInsertedEvent extends WiiUseApiEvent { - /** - * Construct the ClassicControllerInsertedEvent setting up the id. - * - * @param id - * id of the wiimote. - */ - public ClassicControllerInsertedEvent(int id) { - super(id, WIIUSE_CLASSIC_CTRL_INSERTED); - } + /** + * Construct the ClassicControllerInsertedEvent setting up the id. + * + * @param id + * id of the wiimote. + */ + public ClassicControllerInsertedEvent(int id) { + super(id, WIIUSE_CLASSIC_CTRL_INSERTED); + } - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** CLASSIC CONTROLLER INSERTED EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - return out; - } + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** CLASSIC CONTROLLER INSERTED EVENT : WIIMOTE ID :" + + super.getWiimoteId() + " ********/\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/ClassicControllerRemovedEvent.java b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/ClassicControllerRemovedEvent.java index d3407bc..2c603b4 100644 --- a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/ClassicControllerRemovedEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/ClassicControllerRemovedEvent.java @@ -25,23 +25,23 @@ package wiiusej.wiiusejevents.wiiuseapievents; */ public class ClassicControllerRemovedEvent extends WiiUseApiEvent { - /** - * Construct the ClassicControllerRemovedEvent setting up the id. - * - * @param id - * id of the wiimote. - */ - public ClassicControllerRemovedEvent(int id) { - super(id, WIIUSE_CLASSIC_CTRL_REMOVED); - } + /** + * Construct the ClassicControllerRemovedEvent setting up the id. + * + * @param id + * id of the wiimote. + */ + public ClassicControllerRemovedEvent(int id) { + super(id, WIIUSE_CLASSIC_CTRL_REMOVED); + } - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** CLASSIC CONTROLLER REMOVED EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - return out; - } + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** CLASSIC CONTROLLER REMOVED EVENT : WIIMOTE ID :" + + super.getWiimoteId() + " ********/\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/DisconnectionEvent.java b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/DisconnectionEvent.java index 660642f..5eaee1a 100644 --- a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/DisconnectionEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/DisconnectionEvent.java @@ -23,23 +23,23 @@ package wiiusej.wiiusejevents.wiiuseapievents; */ public class DisconnectionEvent extends WiiUseApiEvent { - /** - * Construct the DisconnectionEvent setting up the id. - * - * @param id - * the Wiimote id - */ - public DisconnectionEvent(int id) { - super(id, WiiUseApiEvent.DISCONNECTION_EVENT); - } + /** + * Construct the DisconnectionEvent setting up the id. + * + * @param id + * the Wiimote id + */ + public DisconnectionEvent(int id) { + super(id, WiiUseApiEvent.DISCONNECTION_EVENT); + } - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - return out; - } + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :" + + super.getWiimoteId() + " ********/\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/GuitarHeroInsertedEvent.java b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/GuitarHeroInsertedEvent.java index 4fb041e..fffdc52 100644 --- a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/GuitarHeroInsertedEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/GuitarHeroInsertedEvent.java @@ -25,23 +25,23 @@ package wiiusej.wiiusejevents.wiiuseapievents; */ public class GuitarHeroInsertedEvent extends WiiUseApiEvent { - /** - * Construct the GuitarHeroInsertedEvent setting up the id. - * - * @param id - * id of the wiimote. - */ - public GuitarHeroInsertedEvent(int id) { - super(id, WIIUSE_GUITAR_HERO_3_CTRL_INSERTED); - } + /** + * Construct the GuitarHeroInsertedEvent setting up the id. + * + * @param id + * id of the wiimote. + */ + public GuitarHeroInsertedEvent(int id) { + super(id, WIIUSE_GUITAR_HERO_3_CTRL_INSERTED); + } - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** GUITAR HERO INSERTED EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - return out; - } + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** GUITAR HERO INSERTED EVENT : WIIMOTE ID :" + + super.getWiimoteId() + " ********/\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/GuitarHeroRemovedEvent.java b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/GuitarHeroRemovedEvent.java index c8c6a95..dcbf93d 100644 --- a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/GuitarHeroRemovedEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/GuitarHeroRemovedEvent.java @@ -25,23 +25,23 @@ package wiiusej.wiiusejevents.wiiuseapievents; */ public class GuitarHeroRemovedEvent extends WiiUseApiEvent { - /** - * Construct the GuitarHeroRemovedEvent setting up the id. - * - * @param id - * id of the wiimote. - */ - public GuitarHeroRemovedEvent(int id) { - super(id, WIIUSE_GUITAR_HERO_3_CTRL_REMOVED); - } + /** + * Construct the GuitarHeroRemovedEvent setting up the id. + * + * @param id + * id of the wiimote. + */ + public GuitarHeroRemovedEvent(int id) { + super(id, WIIUSE_GUITAR_HERO_3_CTRL_REMOVED); + } - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** GUITAR HERO REMOVED EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - return out; - } + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** GUITAR HERO REMOVED EVENT : WIIMOTE ID :" + + super.getWiimoteId() + " ********/\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/NunchukInsertedEvent.java b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/NunchukInsertedEvent.java index a4a388b..d5ae670 100644 --- a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/NunchukInsertedEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/NunchukInsertedEvent.java @@ -24,28 +24,28 @@ package wiiusej.wiiusejevents.wiiuseapievents; */ public class NunchukInsertedEvent extends WiiUseApiEvent { - /** - * Construct the NunchukInsertedEvent setting up the id. - * - * @param id - * id of the wiimote. - */ - public NunchukInsertedEvent(int id) { - super(id, WIIUSE_NUNCHUK_INSERTED); - } + /** + * Construct the NunchukInsertedEvent setting up the id. + * + * @param id + * id of the wiimote. + */ + public NunchukInsertedEvent(int id) { + super(id, WIIUSE_NUNCHUK_INSERTED); + } - /* - * (non-Javadoc) - * - * @see wiiusej.wiiusejevents.WiiUseApiEvent#toString() - */ - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** NUNCHUK INSERTED EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - return out; - } + /* + * (non-Javadoc) + * + * @see wiiusej.wiiusejevents.WiiUseApiEvent#toString() + */ + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** NUNCHUK INSERTED EVENT : WIIMOTE ID :" + + super.getWiimoteId() + " ********/\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/NunchukRemovedEvent.java b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/NunchukRemovedEvent.java index 9173c86..02a0b9b 100644 --- a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/NunchukRemovedEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/NunchukRemovedEvent.java @@ -23,28 +23,28 @@ package wiiusej.wiiusejevents.wiiuseapievents; */ public class NunchukRemovedEvent extends WiiUseApiEvent { - /** - * Construct the NunchukInsertedEvent setting up the id. - * - * @param id - * id of the wiimote. - */ - public NunchukRemovedEvent(int id) { - super(id, WIIUSE_NUNCHUK_REMOVED); - } + /** + * Construct the NunchukInsertedEvent setting up the id. + * + * @param id + * id of the wiimote. + */ + public NunchukRemovedEvent(int id) { + super(id, WIIUSE_NUNCHUK_REMOVED); + } - /* - * (non-Javadoc) - * - * @see wiiusej.wiiusejevents.WiiUseApiEvent#toString() - */ - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** NUNCHUK REMOVED EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - return out; - } + /* + * (non-Javadoc) + * + * @see wiiusej.wiiusejevents.WiiUseApiEvent#toString() + */ + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** NUNCHUK REMOVED EVENT : WIIMOTE ID :" + + super.getWiimoteId() + " ********/\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/StatusEvent.java b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/StatusEvent.java index 4544845..bd85b58 100644 --- a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/StatusEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/StatusEvent.java @@ -24,270 +24,270 @@ package wiiusej.wiiusejevents.wiiuseapievents; */ public class StatusEvent extends WiiUseApiEvent { - protected static short WIIMOTE_LED_1 = 1; - protected static short WIIMOTE_LED_2 = 2; - protected static short WIIMOTE_LED_3 = 4; - protected static short WIIMOTE_LED_4 = 8; + protected static short WIIMOTE_LED_1 = 1; + protected static short WIIMOTE_LED_2 = 2; + protected static short WIIMOTE_LED_3 = 4; + protected static short WIIMOTE_LED_4 = 8; - /* ATTACHMENT CONSTANTS */ + /* ATTACHMENT CONSTANTS */ - private static short EXP_NONE = 0; - private static short EXP_NUNCHUK = 1; - private static short EXP_CLASSIC = 2; - private static short EXP_GUITAR_HERO_3 = 3; + private static short EXP_NONE = 0; + private static short EXP_NUNCHUK = 1; + private static short EXP_CLASSIC = 2; + private static short EXP_GUITAR_HERO_3 = 3; - /* Status variables */ - private boolean connected = false; + /* Status variables */ + 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. - * - * @param id - * the Wiimote id - */ - public StatusEvent(int id) { - super(id, WiiUseApiEvent.STATUS_EVENT); - } + /** + * Construct the StatusEvent setting up the id. + * + * @param id + * the Wiimote id + */ + public StatusEvent(int id) { + super(id, WiiUseApiEvent.STATUS_EVENT); + } - /** - * Build a StatusEvent with all fields set. - * - * @param id - * id of the wiimote - * @param connect - * true if the wiimote is connected - * @param batt - * battery level - * @param led - * status of leds - * @param speak - * speakers status - * @param attach - * attachment status - * @param rumbleState - * true if rumble is active - * @param continuousState - * true if continuous flag is activated - * @param irState - * true if ir is active - * @param motionSensingState - * true if accelerometer is active - */ - public StatusEvent(int id, boolean connect, float batt, short led, - boolean speak, int attach, boolean rumbleState, - boolean continuousState, boolean irState, boolean motionSensingState) { - super(id, WiiUseApiEvent.STATUS_EVENT); - connected = connect; - this.batteryLevel = batt; - this.leds = led; - this.isSpeakerEnabled = speak; - this.attachment = attach; - isRumbleActive = rumbleState; - isContinuousActive = continuousState; - isIrActive = irState; - isMotionSensingActive = motionSensingState; - } + /** + * Build a StatusEvent with all fields set. + * + * @param id + * id of the wiimote + * @param connect + * true if the wiimote is connected + * @param batt + * battery level + * @param led + * status of leds + * @param speak + * speakers status + * @param attach + * attachment status + * @param rumbleState + * true if rumble is active + * @param continuousState + * true if continuous flag is activated + * @param irState + * true if ir is active + * @param motionSensingState + * true if accelerometer is active + */ + public StatusEvent(int id, boolean connect, float batt, short led, + boolean speak, int attach, boolean rumbleState, + boolean continuousState, boolean irState, boolean motionSensingState) { + super(id, WiiUseApiEvent.STATUS_EVENT); + connected = connect; + this.batteryLevel = batt; + this.leds = led; + this.isSpeakerEnabled = speak; + this.attachment = attach; + isRumbleActive = rumbleState; + isContinuousActive = continuousState; + isIrActive = irState; + isMotionSensingActive = motionSensingState; + } - /** - * True if the wiimote is connected false otherwise. - * - * @return return the connected status. - */ - public boolean isConnected() { - return connected; - } + /** + * True if the wiimote is connected false otherwise. + * + * @return return the connected status. + */ + public boolean isConnected() { + return connected; + } - /** - * Get battery level. - * - * @return battery level. 1 = 100% - */ - public float getBatteryLevel() { - return batteryLevel; - } + /** + * Get battery level. + * + * @return battery level. 1 = 100% + */ + public float getBatteryLevel() { + return batteryLevel; + } - /** - * Get status of the leds . - * - * @return a short representing LEDS turned on. - */ - public short getLeds() { - return leds; - } + /** + * Get status of the leds . + * + * @return a short representing LEDS turned on. + */ + public short getLeds() { + return leds; + } - /** - * Tells if the given led is turned on according to the leds status int. - * - * @param led - * the int encoding a led. - * @return true if the led is turned on false otherwise. - */ - private boolean ledStatusCheck(short led) { - if ((leds & led) > 0) { - return true; - } else { - return false; - } - } + /** + * Tells if the given led is turned on according to the leds status int. + * + * @param led + * the int encoding a led. + * @return true if the led is turned on false otherwise. + */ + private boolean ledStatusCheck(short led) { + if ((leds & led) > 0) { + return true; + } else { + return false; + } + } - /** - * Get led1 status. - * - * @return true if the led is set. - */ - public boolean isLed1Set() { - return ledStatusCheck(WIIMOTE_LED_1); - } + /** + * Get led1 status. + * + * @return true if the led is set. + */ + public boolean isLed1Set() { + return ledStatusCheck(WIIMOTE_LED_1); + } - /** - * Get led2 status. - * - * @return true if the led is set. - */ - public boolean isLed2Set() { - return ledStatusCheck(WIIMOTE_LED_2); - } + /** + * Get led2 status. + * + * @return true if the led is set. + */ + public boolean isLed2Set() { + return ledStatusCheck(WIIMOTE_LED_2); + } - /** - * Get led3 status. - * - * @return true if the led is set. - */ - public boolean isLed3Set() { - return ledStatusCheck(WIIMOTE_LED_3); - } + /** + * Get led3 status. + * + * @return true if the led is set. + */ + public boolean isLed3Set() { + return ledStatusCheck(WIIMOTE_LED_3); + } - /** - * Get led4 status. - * - * @return true if the led is set. - */ - public boolean isLed4Set() { - return ledStatusCheck(WIIMOTE_LED_4); - } + /** + * Get led4 status. + * + * @return true if the led is set. + */ + public boolean isLed4Set() { + return ledStatusCheck(WIIMOTE_LED_4); + } - /** - * Tell if the speaker is enable for this wiimote - * - * @return TRUE if it enabled false otherwise - */ - public boolean isSpeakerEnabled() { - return isSpeakerEnabled; - } + /** + * Tell if the speaker is enable for this wiimote + * + * @return TRUE if it enabled false otherwise + */ + public boolean isSpeakerEnabled() { + return isSpeakerEnabled; + } - /** - * Get the int representing the attachment type. - * - * @return value of the Attachment Type - */ - public int getAttachment() { - return attachment; - } + /** + * Get the int representing the attachment type. + * + * @return value of the Attachment Type + */ + public int getAttachment() { + return attachment; + } - /** - * Get the status of rumble. - * - * @return true if the rumble is active false otherwise - */ - public boolean isRumbleActive() { - return isRumbleActive; - } + /** + * Get the status of rumble. + * + * @return true if the rumble is active false otherwise + */ + public boolean isRumbleActive() { + return isRumbleActive; + } - /** - * Tell if the CONTINUOUS option is activated. - * - * @return the isContinuousActive - */ - public boolean isContinuousActive() { - return isContinuousActive; - } + /** + * Tell if the CONTINUOUS option is activated. + * + * @return the isContinuousActive + */ + public boolean isContinuousActive() { + return isContinuousActive; + } - /** - * Tell if the IR Tracking is active. - * - * @return TRUE if it is active or false otherwise. - */ - public boolean isIrActive() { - return isIrActive; - } + /** + * Tell if the IR Tracking is active. + * + * @return TRUE if it is active or false otherwise. + */ + public boolean isIrActive() { + return isIrActive; + } - /** - * Get the flag indicating if the motion sensing is active. - * - * @return true if the motion sensing is active false otherwise - */ - public boolean isMotionSensingActive() { - return isMotionSensingActive; - } + /** + * Get the flag indicating if the motion sensing is active. + * + * @return true if the motion sensing is active false otherwise + */ + public boolean isMotionSensingActive() { + return isMotionSensingActive; + } - /** - * Tells if an attachment is connected. - * - * @return true if anything is connected to the wiimote false otherwise. - */ - public boolean isAttachmentConnected() { - return attachment == EXP_NONE; - } + /** + * Tells if an attachment is connected. + * + * @return true if anything is connected to the wiimote false otherwise. + */ + public boolean isAttachmentConnected() { + return attachment == EXP_NONE; + } - /** - * Tells if a nunchuk is connected. - * - * @return true if a nunchuk is connected to the wiimote false otherwise. - */ - public boolean isNunchukConnected() { - return attachment == EXP_NUNCHUK; - } + /** + * Tells if a nunchuk is connected. + * + * @return true if a nunchuk is connected to the wiimote false otherwise. + */ + public boolean isNunchukConnected() { + return attachment == EXP_NUNCHUK; + } - /** - * Tells if a classic controller is connected. - * - * @return true if a classic controller is connected to the wiimote false otherwise. - */ - public boolean isClassicControllerConnected() { - return attachment == EXP_CLASSIC; - } - - /** - * Tells if a guitar hero controller is connected. - * - * @return true if a guitar hero controllerr is connected to the wiimote false otherwise. - */ - public boolean isGuitarHeroConnected() { - return attachment == EXP_GUITAR_HERO_3; - } + /** + * Tells if a classic controller is connected. + * + * @return true if a classic controller is connected to the wiimote false otherwise. + */ + public boolean isClassicControllerConnected() { + return attachment == EXP_CLASSIC; + } + + /** + * Tells if a guitar hero controller is connected. + * + * @return true if a guitar hero controllerr is connected to the wiimote false otherwise. + */ + public boolean isGuitarHeroConnected() { + return attachment == EXP_GUITAR_HERO_3; + } - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** STATUS EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - out += "--- connected : " + connected + "\n"; - out += "--- Battery level : " + batteryLevel + "\n"; - out += "--- Leds : " + leds + "\n"; - out += "--- Speaker enabled : " + isSpeakerEnabled + "\n"; - out += "--- Attachment ? : " + attachment + "\n"; - out += "--- Rumble ? : " + isRumbleActive + "\n"; - out += "--- Continuous ? : " + isContinuousActive + "\n"; - out += "--- IR active ? : " + isIrActive + "\n"; - out += "--- Motion sensing active ? : " + isMotionSensingActive + "\n"; - return out; - } + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** STATUS EVENT : WIIMOTE ID :" + + super.getWiimoteId() + " ********/\n"; + out += "--- connected : " + connected + "\n"; + out += "--- Battery level : " + batteryLevel + "\n"; + out += "--- Leds : " + leds + "\n"; + out += "--- Speaker enabled : " + isSpeakerEnabled + "\n"; + out += "--- Attachment ? : " + attachment + "\n"; + out += "--- Rumble ? : " + isRumbleActive + "\n"; + out += "--- Continuous ? : " + isContinuousActive + "\n"; + out += "--- IR active ? : " + isIrActive + "\n"; + out += "--- Motion sensing active ? : " + isMotionSensingActive + "\n"; + return out; + } } diff --git a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/WiiUseApiEvent.java b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/WiiUseApiEvent.java index c4f001d..31b39f0 100644 --- a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/WiiUseApiEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/WiiUseApiEvent.java @@ -24,43 +24,43 @@ import wiiusej.wiiusejevents.GenericEvent; * @author guiguito */ public abstract class WiiUseApiEvent extends GenericEvent{ - - public static int NONE_EVENT = 0; - public static int GENERIC_EVENT = 1; - public static int STATUS_EVENT = 2; - public static int DISCONNECTION_EVENT = 3; - public static int WIIUSE_READ_DATA = 4; - public static int WIIUSE_NUNCHUK_INSERTED = 5; - public static int WIIUSE_NUNCHUK_REMOVED = 6; - public static int WIIUSE_CLASSIC_CTRL_INSERTED = 7; - public static int WIIUSE_CLASSIC_CTRL_REMOVED = 8; - public static int WIIUSE_GUITAR_HERO_3_CTRL_INSERTED = 9; - public static int WIIUSE_GUITAR_HERO_3_CTRL_REMOVED = 10; - - /* Event Type */ - private int eventType; - - /** - * Construct the WiiUseApiEvent setting up the id. - * - * @param id - * the Wiimote id - * @param type - * type of the event - */ - public WiiUseApiEvent(int id, int type) { - super(id); - eventType = type; - } - - /** - * Get the event type. - * @return the eventType - */ - public int getEventType() { - return eventType; - } - - public abstract String toString(); + + public static int NONE_EVENT = 0; + public static int GENERIC_EVENT = 1; + public static int STATUS_EVENT = 2; + public static int DISCONNECTION_EVENT = 3; + public static int WIIUSE_READ_DATA = 4; + public static int WIIUSE_NUNCHUK_INSERTED = 5; + public static int WIIUSE_NUNCHUK_REMOVED = 6; + public static int WIIUSE_CLASSIC_CTRL_INSERTED = 7; + public static int WIIUSE_CLASSIC_CTRL_REMOVED = 8; + public static int WIIUSE_GUITAR_HERO_3_CTRL_INSERTED = 9; + public static int WIIUSE_GUITAR_HERO_3_CTRL_REMOVED = 10; + + /* Event Type */ + private int eventType; + + /** + * Construct the WiiUseApiEvent setting up the id. + * + * @param id + * the Wiimote id + * @param type + * type of the event + */ + public WiiUseApiEvent(int id, int type) { + super(id); + eventType = type; + } + + /** + * Get the event type. + * @return the eventType + */ + public int getEventType() { + return eventType; + } + + public abstract String toString(); } diff --git a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/WiimoteEvent.java b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/WiimoteEvent.java index 582b33b..e4a6628 100644 --- a/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/WiimoteEvent.java +++ b/src/main/java/wiiusej/wiiusejevents/wiiuseapievents/WiimoteEvent.java @@ -32,410 +32,410 @@ import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; */ public class WiimoteEvent extends WiiUseApiEvent { - private WiimoteButtonsEvent buttonsEvent = null; - private IREvent infraredEvent = null; - private MotionSensingEvent motionSensingEvent = null; - private ExpansionEvent expansionEvent = null; + private WiimoteButtonsEvent buttonsEvent = null; + private IREvent infraredEvent = null; + private MotionSensingEvent motionSensingEvent = null; + private ExpansionEvent expansionEvent = null; - /** - * Construct the Wiimote setting up the id. - * - * @param id - * the Wiimote id - */ - public WiimoteEvent(int id) { - super(id, WiiUseApiEvent.GENERIC_EVENT); - } + /** + * Construct the Wiimote setting up the id. + * + * @param id + * the Wiimote id + */ + public WiimoteEvent(int id) { + super(id, WiiUseApiEvent.GENERIC_EVENT); + } - /** - * Construct the Wiimote setting up the id and the buttons. - * - * @param id - * the Wiimote id - * @param buttonsJustPressed - * buttons just pressed - * @param buttonsJustReleased - * buttons just released - * @param buttonsHeld - * buttons held - */ - public WiimoteEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld) { - super(id, WiiUseApiEvent.GENERIC_EVENT); - buttonsEvent = new WiimoteButtonsEvent(id, buttonsJustPressed, - buttonsJustReleased, buttonsHeld); - } + /** + * Construct the Wiimote setting up the id and the buttons. + * + * @param id + * the Wiimote id + * @param buttonsJustPressed + * buttons just pressed + * @param buttonsJustReleased + * buttons just released + * @param buttonsHeld + * buttons held + */ + public WiimoteEvent(int id, short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld) { + super(id, WiiUseApiEvent.GENERIC_EVENT); + buttonsEvent = new WiimoteButtonsEvent(id, buttonsJustPressed, + buttonsJustReleased, buttonsHeld); + } - /** - * Tell if there is an IR Event. - * - * @return TRUE if there is an IR event. - */ - public boolean isThereIrEvent() { - return infraredEvent != null; - } + /** + * Tell if there is an IR Event. + * + * @return TRUE if there is an IR event. + */ + public boolean isThereIrEvent() { + return infraredEvent != null; + } - /** - * Tell if there is a motion sensing Event. - * - * @return TRUE if there is a motion sensing event. - */ - public boolean isThereMotionSensingEvent() { - return motionSensingEvent != null; - } + /** + * Tell if there is a motion sensing Event. + * + * @return TRUE if there is a motion sensing event. + */ + public boolean isThereMotionSensingEvent() { + return motionSensingEvent != null; + } - /** - * Tell if there is an expansion Event. - * - * @return TRUE if there is an expansion event. - */ - public boolean isThereExpansionEvent() { - return expansionEvent != null; - } + /** + * Tell if there is an expansion Event. + * + * @return TRUE if there is an expansion event. + */ + public boolean isThereExpansionEvent() { + return expansionEvent != null; + } - /** - * Get buttons event. - * - * @return the buttons event. - */ - public WiimoteButtonsEvent getButtonsEvent() { - return buttonsEvent; - } + /** + * Get buttons event. + * + * @return the buttons event. + */ + public WiimoteButtonsEvent getButtonsEvent() { + return buttonsEvent; + } - /** - * Get the IR event. - * - * @return the IR event if there is one or null. - */ - public IREvent getIREvent() { - return infraredEvent; - } + /** + * Get the IR event. + * + * @return the IR event if there is one or null. + */ + public IREvent getIREvent() { + return infraredEvent; + } - /** - * Get the motion sensing event. - * - * @return the motion sensing event if there is one or null. - */ - public MotionSensingEvent getMotionSensingEvent() { - return motionSensingEvent; - } + /** + * Get the motion sensing event. + * + * @return the motion sensing event if there is one or null. + */ + public MotionSensingEvent getMotionSensingEvent() { + return motionSensingEvent; + } - /** - * Get the expansion event. - * - * @return the expansion event if there is one or null. - */ - public ExpansionEvent getExpansionEvent() { - return expansionEvent; - } + /** + * Get the expansion event. + * + * @return the expansion event if there is one or null. + */ + public ExpansionEvent getExpansionEvent() { + return expansionEvent; + } - /** - * Prepare an IR event to populate. - * - * @param x - * calculated X coordinate. - * @param y - * calculated Y coordinate. - * @param z - * calculated distance. - * @param ax - * absolute X coordinate. - * @param ay - * absolute Y coordinate - * @param xVRes - * IR virtual screen x resolution. - * @param yVRes - * IR virtual screen y resolution. - * @param xOffset - * IR X correction offset. - * @param yOffset - * IR Y correction offset. - * @param sensorBarPostion - * aspect ratio of the screen. - * @param screenAsPectRatio - * IR sensor bar position. - * @param irSensitivity - * Sensitivity of the infrared camera. - * @param distance - * Pixel Distance between first two dots - */ - public void prepareIRevent(int x, int y, float z, int ax, int ay, - int xVRes, int yVRes, int xOffset, int yOffset, - short sensorBarPostion, short screenAsPectRatio, - short irSensitivity, float distance) { - if (infraredEvent == null) { - infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes, - yVRes, xOffset, yOffset, sensorBarPostion, - screenAsPectRatio, irSensitivity, distance); - } - } + /** + * Prepare an IR event to populate. + * + * @param x + * calculated X coordinate. + * @param y + * calculated Y coordinate. + * @param z + * calculated distance. + * @param ax + * absolute X coordinate. + * @param ay + * absolute Y coordinate + * @param xVRes + * IR virtual screen x resolution. + * @param yVRes + * IR virtual screen y resolution. + * @param xOffset + * IR X correction offset. + * @param yOffset + * IR Y correction offset. + * @param sensorBarPostion + * aspect ratio of the screen. + * @param screenAsPectRatio + * IR sensor bar position. + * @param irSensitivity + * Sensitivity of the infrared camera. + * @param distance + * Pixel Distance between first two dots + */ + public void prepareIRevent(int x, int y, float z, int ax, int ay, + int xVRes, int yVRes, int xOffset, int yOffset, + short sensorBarPostion, short screenAsPectRatio, + short irSensitivity, float distance) { + if (infraredEvent == null) { + infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes, + yVRes, xOffset, yOffset, sensorBarPostion, + screenAsPectRatio, irSensitivity, distance); + } + } - /** - * Add an IR point to the generic event. Create an IR Event if it's not - * created yet. - * - * @param x - * x coordinates. - * @param y - * y coordinates - * @param rx - * raw X coordinate (0-1023). - * @param ry - * raw Y coordinate (0-1023). - * @param size - * size of the IR dot (0-15). - */ - public void addIRpoint(int x, int y, short rx, short ry, short size) { - if (infraredEvent != null) - infraredEvent.addIRpoint(x, y, rx, ry, size); - } + /** + * Add an IR point to the generic event. Create an IR Event if it's not + * created yet. + * + * @param x + * x coordinates. + * @param y + * y coordinates + * @param rx + * raw X coordinate (0-1023). + * @param ry + * raw Y coordinate (0-1023). + * @param size + * size of the IR dot (0-15). + */ + public void addIRpoint(int x, int y, short rx, short ry, short size) { + if (infraredEvent != null) + infraredEvent.addIRpoint(x, y, rx, ry, size); + } - /** - * Set the Motion Sensing Event. - * - * @param orientationThreshold - * value of the minimum angle between two events with the - * accelerometer. - * @param accelerationThreshold - * value of the value variation between two events with the - * accelerometer. - * @param smoothingState - * true if smoothing flag is activated. - * @param alphaSmooth - * value of the alpha smoothing parameter. - * @param r - * roll. - * @param p - * pitch. - * @param ya - * yaw. - * @param ar - * absolute roll. - * @param ap - * absolute pitch. - * @param x - * gravity force on x axis. - * @param y - * gravity force on y axis. - * @param z - * gravity force on z axis. - * @param xx - * raw acceleration on x axis. - * @param yy - * raw acceleration on y axis. - * @param zz - * raw acceleration on z axis. - */ - public void setMotionSensingEvent(float orientationThreshold, - int accelerationThreshold, boolean smoothingState, - float alphaSmooth, float r, float p, float ya, float ar, float ap, - float x, float y, float z, short xx, short yy, short zz) { - motionSensingEvent = new MotionSensingEvent(getWiimoteId(), - orientationThreshold, accelerationThreshold, smoothingState, - alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz); - } + /** + * Set the Motion Sensing Event. + * + * @param orientationThreshold + * value of the minimum angle between two events with the + * accelerometer. + * @param accelerationThreshold + * value of the value variation between two events with the + * accelerometer. + * @param smoothingState + * true if smoothing flag is activated. + * @param alphaSmooth + * value of the alpha smoothing parameter. + * @param r + * roll. + * @param p + * pitch. + * @param ya + * yaw. + * @param ar + * absolute roll. + * @param ap + * absolute pitch. + * @param x + * gravity force on x axis. + * @param y + * gravity force on y axis. + * @param z + * gravity force on z axis. + * @param xx + * raw acceleration on x axis. + * @param yy + * raw acceleration on y axis. + * @param zz + * raw acceleration on z axis. + */ + public void setMotionSensingEvent(float orientationThreshold, + int accelerationThreshold, boolean smoothingState, + float alphaSmooth, float r, float p, float ya, float ar, float ap, + float x, float y, float z, short xx, short yy, short zz) { + motionSensingEvent = new MotionSensingEvent(getWiimoteId(), + orientationThreshold, accelerationThreshold, smoothingState, + alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz); + } - /** - * Set a NunchukEvent for the expansion event. - * - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - * @param orientationThreshold - * value of the minimum angle between two events with the - * accelerometer. - * @param accelerationThreshold - * value of the value variation between two events with the - * accelerometer. - * @param smoothingState - * true if smoothing flag is activated. - * @param alphaSmooth - * value of the alpha smoothing parameter. - * @param r - * roll. - * @param p - * pitch. - * @param ya - * yaw. - * @param ar - * absolute roll. - * @param ap - * absolute pitch. - * @param x - * gravity force on x axis. - * @param y - * gravity force on y axis. - * @param z - * gravity force on z axis. - * @param xx - * raw acceleration on x axis. - * @param yy - * raw acceleration on y axis. - * @param zz - * raw acceleration on z axis. - * @param angle - * angle the joystick is being held. - * @param magnitude - * magnitude of the joystick (range 0-1). - * @param max1 - * maximum joystick value 1. - * @param max2 - * maximum joystick value 2. - * @param min1 - * minimum joystick value 1. - * @param min2 - * minimum joystick value 2. - * @param center1 - * center joystick value 1. - * @param center2 - * center joystick value 2. - */ - public void setNunchukEvent(short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld, - float orientationThreshold, int accelerationThreshold, - boolean smoothingState, 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 angle, float magnitude, short max1, - short max2, short min1, short min2, short center1, short center2) { - expansionEvent = new NunchukEvent(getWiimoteId(), buttonsJustPressed, - buttonsJustReleased, buttonsHeld, orientationThreshold, - accelerationThreshold, smoothingState, alphaSmooth, r, p, ya, - ar, ap, x, y, z, xx, yy, zz, angle, magnitude, max1, max2, - min1, min2, center1, center2); - } + /** + * Set a NunchukEvent for the expansion event. + * + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + * @param orientationThreshold + * value of the minimum angle between two events with the + * accelerometer. + * @param accelerationThreshold + * value of the value variation between two events with the + * accelerometer. + * @param smoothingState + * true if smoothing flag is activated. + * @param alphaSmooth + * value of the alpha smoothing parameter. + * @param r + * roll. + * @param p + * pitch. + * @param ya + * yaw. + * @param ar + * absolute roll. + * @param ap + * absolute pitch. + * @param x + * gravity force on x axis. + * @param y + * gravity force on y axis. + * @param z + * gravity force on z axis. + * @param xx + * raw acceleration on x axis. + * @param yy + * raw acceleration on y axis. + * @param zz + * raw acceleration on z axis. + * @param angle + * angle the joystick is being held. + * @param magnitude + * magnitude of the joystick (range 0-1). + * @param max1 + * maximum joystick value 1. + * @param max2 + * maximum joystick value 2. + * @param min1 + * minimum joystick value 1. + * @param min2 + * minimum joystick value 2. + * @param center1 + * center joystick value 1. + * @param center2 + * center joystick value 2. + */ + public void setNunchukEvent(short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld, + float orientationThreshold, int accelerationThreshold, + boolean smoothingState, 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 angle, float magnitude, short max1, + short max2, short min1, short min2, short center1, short center2) { + expansionEvent = new NunchukEvent(getWiimoteId(), buttonsJustPressed, + buttonsJustReleased, buttonsHeld, orientationThreshold, + accelerationThreshold, smoothingState, alphaSmooth, r, p, ya, + ar, ap, x, y, z, xx, yy, zz, angle, magnitude, max1, max2, + min1, min2, center1, center2); + } - /** - * Set a ClassicControllerEvent for the expansionEvent. - * - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - * @param rightShoulder - * right shoulder button (range 0-1). - * @param leftShoulder - * left shoulder button (range 0-1). - * @param langle - * angle the left joystick is being held. - * @param lmagnitude - * magnitude of the left joystick (range 0-1). - * @param lmax1 - * maximum left joystick value 1. - * @param lmax2 - * maximum left joystick value 2. - * @param lmin1 - * minimum left joystick value 1. - * @param lmin2 - * minimum left joystick value 2. - * @param lcenter1 - * center left joystick value 1. - * @param lcenter2 - * center left joystick value 2. - * @param rangle - * angle the right joystick is being held. - * @param rmagnitude - * magnitude of the right joystick (range 0-1). - * @param rmax1 - * maximum right joystick value 1. - * @param rmax2 - * maximum right joystick value 2. - * @param rmin1 - * minimum right joystick value 1. - * @param rmin2 - * minimum right joystick value 2. - * @param rcenter1 - * center right joystick value 1. - * @param rcenter2 - * center right joystick value 2. - */ - public void setClassicControllerEvent(short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld, float rightShoulder, - float leftShoulder, float langle, float lmagnitude, short lmax1, - short lmax2, short lmin1, short lmin2, short lcenter1, - short lcenter2, float rangle, float rmagnitude, short rmax1, - short rmax2, short rmin1, short rmin2, short rcenter1, - short rcenter2) { - expansionEvent = new ClassicControllerEvent(getWiimoteId(), - buttonsJustPressed, buttonsJustReleased, buttonsHeld, - rightShoulder, leftShoulder, langle, lmagnitude, lmax1, lmax2, - lmin1, lmin2, lcenter1, lcenter2, rangle, rmagnitude, rmax1, - rmax2, rmin1, rmin2, rcenter1, rcenter2); - } - - /** - * Set a GuitarHeroEvent for the expansionEvent. - * - * @param buttonsJustPressed - * buttons just pressed. - * @param buttonsJustReleased - * buttons just released. - * @param buttonsHeld - * buttons just pressed. - * @param whammyBar - * whammy bar (range 0-1). - * @param angle - * angle the joystick is being held. - * @param magnitude - * magnitude of the joystick (range 0-1). - * @param max1 - * maximum joystick value 1. - * @param max2 - * maximum joystick value 2. - * @param min1 - * minimum joystick value 1. - * @param min2 - * minimum joystick value 2. - * @param center1 - * center joystick value 1. - * @param center2 - * center joystick value 2. - */ - public void setGuitarHeroEvent(short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld, float whammyBar, - float angle, float magnitude, short max1, short max2, short min1, - short min2, short center1, short center2) { - expansionEvent = new GuitarHeroEvent(getWiimoteId(), - buttonsJustPressed, buttonsJustReleased, buttonsHeld, - whammyBar, angle, magnitude, max1, max2, min1, min2, center1, - center2); - } + /** + * Set a ClassicControllerEvent for the expansionEvent. + * + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + * @param rightShoulder + * right shoulder button (range 0-1). + * @param leftShoulder + * left shoulder button (range 0-1). + * @param langle + * angle the left joystick is being held. + * @param lmagnitude + * magnitude of the left joystick (range 0-1). + * @param lmax1 + * maximum left joystick value 1. + * @param lmax2 + * maximum left joystick value 2. + * @param lmin1 + * minimum left joystick value 1. + * @param lmin2 + * minimum left joystick value 2. + * @param lcenter1 + * center left joystick value 1. + * @param lcenter2 + * center left joystick value 2. + * @param rangle + * angle the right joystick is being held. + * @param rmagnitude + * magnitude of the right joystick (range 0-1). + * @param rmax1 + * maximum right joystick value 1. + * @param rmax2 + * maximum right joystick value 2. + * @param rmin1 + * minimum right joystick value 1. + * @param rmin2 + * minimum right joystick value 2. + * @param rcenter1 + * center right joystick value 1. + * @param rcenter2 + * center right joystick value 2. + */ + public void setClassicControllerEvent(short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld, float rightShoulder, + float leftShoulder, float langle, float lmagnitude, short lmax1, + short lmax2, short lmin1, short lmin2, short lcenter1, + short lcenter2, float rangle, float rmagnitude, short rmax1, + short rmax2, short rmin1, short rmin2, short rcenter1, + short rcenter2) { + expansionEvent = new ClassicControllerEvent(getWiimoteId(), + buttonsJustPressed, buttonsJustReleased, buttonsHeld, + rightShoulder, leftShoulder, langle, lmagnitude, lmax1, lmax2, + lmin1, lmin2, lcenter1, lcenter2, rangle, rmagnitude, rmax1, + rmax2, rmin1, rmin2, rcenter1, rcenter2); + } + + /** + * Set a GuitarHeroEvent for the expansionEvent. + * + * @param buttonsJustPressed + * buttons just pressed. + * @param buttonsJustReleased + * buttons just released. + * @param buttonsHeld + * buttons just pressed. + * @param whammyBar + * whammy bar (range 0-1). + * @param angle + * angle the joystick is being held. + * @param magnitude + * magnitude of the joystick (range 0-1). + * @param max1 + * maximum joystick value 1. + * @param max2 + * maximum joystick value 2. + * @param min1 + * minimum joystick value 1. + * @param min2 + * minimum joystick value 2. + * @param center1 + * center joystick value 1. + * @param center2 + * center joystick value 2. + */ + public void setGuitarHeroEvent(short buttonsJustPressed, + short buttonsJustReleased, short buttonsHeld, float whammyBar, + float angle, float magnitude, short max1, short max2, short min1, + short min2, short center1, short center2) { + expansionEvent = new GuitarHeroEvent(getWiimoteId(), + buttonsJustPressed, buttonsJustReleased, buttonsHeld, + whammyBar, angle, magnitude, max1, max2, min1, min2, center1, + center2); + } - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** GENERIC EVENT : WIIMOTE ID :" + getWiimoteId() - + " ********/\n"; + @Override + public String toString() { + String out = ""; + /* Status */ + out += "/*********** GENERIC EVENT : WIIMOTE ID :" + getWiimoteId() + + " ********/\n"; - out += buttonsEvent; + out += buttonsEvent; - if (infraredEvent != null) { - out += infraredEvent; - } else { - out += "/******** IR Tracking ********/\n"; - out += "--- Active : false\n"; - } + if (infraredEvent != null) { + out += infraredEvent; + } else { + out += "/******** IR Tracking ********/\n"; + out += "--- Active : false\n"; + } - if (motionSensingEvent != null) { - out += motionSensingEvent; - } else { - out += "/******** Motion sensing ********/\n"; - out += "--- Motion sensing : false \n"; - } + if (motionSensingEvent != null) { + out += motionSensingEvent; + } else { + out += "/******** Motion sensing ********/\n"; + out += "--- Motion sensing : false \n"; + } - if (expansionEvent != null) { - out += expansionEvent; - } else { - out += "/******** Expansion ********/\n"; - out += "--- No expansion connected \n"; - } + if (expansionEvent != null) { + out += expansionEvent; + } else { + out += "/******** Expansion ********/\n"; + out += "--- No expansion connected \n"; + } - return out; - } + return out; + } } diff --git a/src/test/java/wiiusej/test/CloseGuiTestCleanly.java b/src/test/java/wiiusej/test/CloseGuiTestCleanly.java index 584f2d9..6790b6f 100644 --- a/src/test/java/wiiusej/test/CloseGuiTestCleanly.java +++ b/src/test/java/wiiusej/test/CloseGuiTestCleanly.java @@ -27,32 +27,32 @@ import wiiusej.WiiUseApiManager; */ public class CloseGuiTestCleanly implements WindowListener { - public void windowOpened(WindowEvent e) { - // nothing - } + public void windowOpened(WindowEvent e) { + // nothing + } - public void windowClosing(WindowEvent e) { - WiiUseApiManager.definitiveShutdown(); - } + public void windowClosing(WindowEvent e) { + WiiUseApiManager.definitiveShutdown(); + } - public void windowClosed(WindowEvent e) { - // nothing - } + public void windowClosed(WindowEvent e) { + // nothing + } - public void windowIconified(WindowEvent e) { - // nothing - } + public void windowIconified(WindowEvent e) { + // nothing + } - public void windowDeiconified(WindowEvent e) { - // nothing - } + public void windowDeiconified(WindowEvent e) { + // nothing + } - public void windowActivated(WindowEvent e) { - // nothing - } + public void windowActivated(WindowEvent e) { + // nothing + } - public void windowDeactivated(WindowEvent e) { - // nothing - } + public void windowDeactivated(WindowEvent e) { + // nothing + } } diff --git a/src/test/java/wiiusej/test/Main.java b/src/test/java/wiiusej/test/Main.java index 67ef279..29a2c14 100644 --- a/src/test/java/wiiusej/test/Main.java +++ b/src/test/java/wiiusej/test/Main.java @@ -26,20 +26,20 @@ import wiiusej.Wiimote; */ public class Main { - /** - * @param args - * the command line arguments - */ - public static void main(String[] args) { - Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true); - WiiuseJGuiTest gui = null; - if (wiimotes.length > 0) { - gui = new WiiuseJGuiTest(wiimotes[0]); - } else { - gui = new WiiuseJGuiTest(); - } - gui.setDefaultCloseOperation(WiiuseJGuiTest.EXIT_ON_CLOSE); - gui.setVisible(true); - } + /** + * @param args + * the command line arguments + */ + public static void main(String[] args) { + Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true); + WiiuseJGuiTest gui = null; + if (wiimotes.length > 0) { + gui = new WiiuseJGuiTest(wiimotes[0]); + } else { + gui = new WiiuseJGuiTest(); + } + gui.setDefaultCloseOperation(WiiuseJGuiTest.EXIT_ON_CLOSE); + gui.setVisible(true); + } } diff --git a/src/test/java/wiiusej/test/NunchukGuiTest.java b/src/test/java/wiiusej/test/NunchukGuiTest.java index d7f284f..3d22b01 100644 --- a/src/test/java/wiiusej/test/NunchukGuiTest.java +++ b/src/test/java/wiiusej/test/NunchukGuiTest.java @@ -46,405 +46,405 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; * @author guiguito */ public class NunchukGuiTest extends javax.swing.JFrame implements - WiimoteListener { + WiimoteListener { - private Wiimote wiimote; - private boolean isThresholdsRequested = true; + private Wiimote wiimote; + private boolean isThresholdsRequested = true; - /** Creates new form NunchukGuiTest */ - public NunchukGuiTest(Wiimote wiimote) { - initComponents(); - this.wiimote = wiimote; - registerListeners(); - } + /** Creates new form NunchukGuiTest */ + public NunchukGuiTest(Wiimote wiimote) { + initComponents(); + this.wiimote = wiimote; + registerListeners(); + } - private void registerListeners() { - wiimote.addWiiMoteEventListeners(this); - wiimote.addWiiMoteEventListeners((OrientationPanel) orientationPanel); - wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel); - wiimote - .addWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel); - wiimote - .addWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel); - } + private void registerListeners() { + wiimote.addWiiMoteEventListeners(this); + wiimote.addWiiMoteEventListeners((OrientationPanel) orientationPanel); + wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel); + wiimote + .addWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel); + wiimote + .addWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel); + } - public void unRegisterListeners() { - wiimote - .removeWiiMoteEventListeners((OrientationPanel) orientationPanel); - wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel); - wiimote - .removeWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel); - wiimote - .removeWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel); - wiimote.removeWiiMoteEventListeners(this); - } + public void unRegisterListeners() { + wiimote + .removeWiiMoteEventListeners((OrientationPanel) orientationPanel); + wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel); + wiimote + .removeWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel); + wiimote + .removeWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel); + wiimote.removeWiiMoteEventListeners(this); + } - public void requestThresholdsUpdate() { - isThresholdsRequested = true; - } + public void requestThresholdsUpdate() { + isThresholdsRequested = true; + } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { - topPanels = new javax.swing.JPanel(); - joystickEventsPanel = new NunchukJoystickEventPanel(); - motionSensingEventsPanel = new javax.swing.JPanel(); - motionSensingEventsTabbedPanels = new javax.swing.JTabbedPane(); - rawAccelerationPanel = new AccelerationExpansionEventPanel(); - orientationPanel = new OrientationExpansionEventPanel(); - gForcePanel = new GForceExpansionEventPanel(); - setNunchukValuesPanel = new javax.swing.JPanel(); - nunchukButtonsEventPanel = new javax.swing.JPanel(); - cButton = new javax.swing.JButton(); - zButton = new javax.swing.JButton(); - nunchukOrientationPanel = new javax.swing.JPanel(); - nunchukOrientationTextField = new javax.swing.JTextField(); - nunchukOrientationButton = new javax.swing.JButton(); - nunchukAccelerationPanel = new javax.swing.JPanel(); - nunchukAccelerationTextField = new javax.swing.JTextField(); - nunchukAccelerationButton = new javax.swing.JButton(); - messagePanel = new javax.swing.JPanel(); - messageText = new javax.swing.JLabel(); + topPanels = new javax.swing.JPanel(); + joystickEventsPanel = new NunchukJoystickEventPanel(); + motionSensingEventsPanel = new javax.swing.JPanel(); + motionSensingEventsTabbedPanels = new javax.swing.JTabbedPane(); + rawAccelerationPanel = new AccelerationExpansionEventPanel(); + orientationPanel = new OrientationExpansionEventPanel(); + gForcePanel = new GForceExpansionEventPanel(); + setNunchukValuesPanel = new javax.swing.JPanel(); + nunchukButtonsEventPanel = new javax.swing.JPanel(); + cButton = new javax.swing.JButton(); + zButton = new javax.swing.JButton(); + nunchukOrientationPanel = new javax.swing.JPanel(); + nunchukOrientationTextField = new javax.swing.JTextField(); + nunchukOrientationButton = new javax.swing.JButton(); + nunchukAccelerationPanel = new javax.swing.JPanel(); + nunchukAccelerationTextField = new javax.swing.JTextField(); + nunchukAccelerationButton = new javax.swing.JButton(); + messagePanel = new javax.swing.JPanel(); + messageText = new javax.swing.JLabel(); - setTitle("WiiuseJ Nunchuk Test GUI"); - setMinimumSize(new java.awt.Dimension(400, 400)); - getContentPane().setLayout( - new javax.swing.BoxLayout(getContentPane(), - javax.swing.BoxLayout.Y_AXIS)); + setTitle("WiiuseJ Nunchuk Test GUI"); + setMinimumSize(new java.awt.Dimension(400, 400)); + getContentPane().setLayout( + new javax.swing.BoxLayout(getContentPane(), + javax.swing.BoxLayout.Y_AXIS)); - topPanels.setMinimumSize(new java.awt.Dimension(400, 200)); - topPanels.setPreferredSize(new java.awt.Dimension(400, 200)); - topPanels.setLayout(new javax.swing.BoxLayout(topPanels, - javax.swing.BoxLayout.LINE_AXIS)); + topPanels.setMinimumSize(new java.awt.Dimension(400, 200)); + topPanels.setPreferredSize(new java.awt.Dimension(400, 200)); + topPanels.setLayout(new javax.swing.BoxLayout(topPanels, + javax.swing.BoxLayout.LINE_AXIS)); - joystickEventsPanel.setBackground(new java.awt.Color(0, 0, 0)); - joystickEventsPanel.setBorder(javax.swing.BorderFactory - .createTitledBorder(new javax.swing.border.LineBorder( - new java.awt.Color(51, 153, 0), 2, true), - "Joystick View", - javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, - javax.swing.border.TitledBorder.DEFAULT_POSITION, - new java.awt.Font("Tahoma", 0, 11), new java.awt.Color( - 204, 102, 0))); - joystickEventsPanel.setToolTipText("JoystickEvent"); - joystickEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200)); + joystickEventsPanel.setBackground(new java.awt.Color(0, 0, 0)); + joystickEventsPanel.setBorder(javax.swing.BorderFactory + .createTitledBorder(new javax.swing.border.LineBorder( + new java.awt.Color(51, 153, 0), 2, true), + "Joystick View", + javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, + javax.swing.border.TitledBorder.DEFAULT_POSITION, + new java.awt.Font("Tahoma", 0, 11), new java.awt.Color( + 204, 102, 0))); + joystickEventsPanel.setToolTipText("JoystickEvent"); + joystickEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200)); - javax.swing.GroupLayout joystickEventsPanelLayout = new javax.swing.GroupLayout( - joystickEventsPanel); - joystickEventsPanel.setLayout(joystickEventsPanelLayout); - joystickEventsPanelLayout.setHorizontalGroup(joystickEventsPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 601, Short.MAX_VALUE)); - joystickEventsPanelLayout.setVerticalGroup(joystickEventsPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 174, Short.MAX_VALUE)); + javax.swing.GroupLayout joystickEventsPanelLayout = new javax.swing.GroupLayout( + joystickEventsPanel); + joystickEventsPanel.setLayout(joystickEventsPanelLayout); + joystickEventsPanelLayout.setHorizontalGroup(joystickEventsPanelLayout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 601, Short.MAX_VALUE)); + joystickEventsPanelLayout.setVerticalGroup(joystickEventsPanelLayout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 174, Short.MAX_VALUE)); - topPanels.add(joystickEventsPanel); - joystickEventsPanel.getAccessibleContext() - .setAccessibleName("Joystick"); + topPanels.add(joystickEventsPanel); + joystickEventsPanel.getAccessibleContext() + .setAccessibleName("Joystick"); - motionSensingEventsPanel - .setMinimumSize(new java.awt.Dimension(200, 200)); + motionSensingEventsPanel + .setMinimumSize(new java.awt.Dimension(200, 200)); - rawAccelerationPanel.setToolTipText("Nunchuk MotionSensingEvent"); + rawAccelerationPanel.setToolTipText("Nunchuk MotionSensingEvent"); - javax.swing.GroupLayout rawAccelerationPanelLayout = new javax.swing.GroupLayout( - rawAccelerationPanel); - rawAccelerationPanel.setLayout(rawAccelerationPanelLayout); - rawAccelerationPanelLayout - .setHorizontalGroup(rawAccelerationPanelLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 597, Short.MAX_VALUE)); - rawAccelerationPanelLayout.setVerticalGroup(rawAccelerationPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 175, Short.MAX_VALUE)); + javax.swing.GroupLayout rawAccelerationPanelLayout = new javax.swing.GroupLayout( + rawAccelerationPanel); + rawAccelerationPanel.setLayout(rawAccelerationPanelLayout); + rawAccelerationPanelLayout + .setHorizontalGroup(rawAccelerationPanelLayout + .createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 597, Short.MAX_VALUE)); + rawAccelerationPanelLayout.setVerticalGroup(rawAccelerationPanelLayout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 175, Short.MAX_VALUE)); - motionSensingEventsTabbedPanels.addTab("RawAcceleration", - rawAccelerationPanel); + motionSensingEventsTabbedPanels.addTab("RawAcceleration", + rawAccelerationPanel); - javax.swing.GroupLayout orientationPanelLayout = new javax.swing.GroupLayout( - orientationPanel); - orientationPanel.setLayout(orientationPanelLayout); - orientationPanelLayout.setHorizontalGroup(orientationPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 597, Short.MAX_VALUE)); - orientationPanelLayout.setVerticalGroup(orientationPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 175, Short.MAX_VALUE)); + javax.swing.GroupLayout orientationPanelLayout = new javax.swing.GroupLayout( + orientationPanel); + orientationPanel.setLayout(orientationPanelLayout); + orientationPanelLayout.setHorizontalGroup(orientationPanelLayout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 597, Short.MAX_VALUE)); + orientationPanelLayout.setVerticalGroup(orientationPanelLayout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 175, Short.MAX_VALUE)); - motionSensingEventsTabbedPanels.addTab("Orientation", orientationPanel); + motionSensingEventsTabbedPanels.addTab("Orientation", orientationPanel); - javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout( - gForcePanel); - gForcePanel.setLayout(gForcePanelLayout); - gForcePanelLayout.setHorizontalGroup(gForcePanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 597, Short.MAX_VALUE)); - gForcePanelLayout.setVerticalGroup(gForcePanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 175, Short.MAX_VALUE)); + javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout( + gForcePanel); + gForcePanel.setLayout(gForcePanelLayout); + gForcePanelLayout.setHorizontalGroup(gForcePanelLayout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 597, Short.MAX_VALUE)); + gForcePanelLayout.setVerticalGroup(gForcePanelLayout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 175, Short.MAX_VALUE)); - motionSensingEventsTabbedPanels.addTab("GForce", gForcePanel); + motionSensingEventsTabbedPanels.addTab("GForce", gForcePanel); - javax.swing.GroupLayout motionSensingEventsPanelLayout = new javax.swing.GroupLayout( - motionSensingEventsPanel); - motionSensingEventsPanel.setLayout(motionSensingEventsPanelLayout); - motionSensingEventsPanelLayout - .setHorizontalGroup(motionSensingEventsPanelLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(motionSensingEventsTabbedPanels, - javax.swing.GroupLayout.DEFAULT_SIZE, 602, - Short.MAX_VALUE)); - motionSensingEventsPanelLayout - .setVerticalGroup(motionSensingEventsPanelLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(motionSensingEventsTabbedPanels, - javax.swing.GroupLayout.DEFAULT_SIZE, 200, - Short.MAX_VALUE)); + javax.swing.GroupLayout motionSensingEventsPanelLayout = new javax.swing.GroupLayout( + motionSensingEventsPanel); + motionSensingEventsPanel.setLayout(motionSensingEventsPanelLayout); + motionSensingEventsPanelLayout + .setHorizontalGroup(motionSensingEventsPanelLayout + .createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(motionSensingEventsTabbedPanels, + javax.swing.GroupLayout.DEFAULT_SIZE, 602, + Short.MAX_VALUE)); + motionSensingEventsPanelLayout + .setVerticalGroup(motionSensingEventsPanelLayout + .createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(motionSensingEventsTabbedPanels, + javax.swing.GroupLayout.DEFAULT_SIZE, 200, + Short.MAX_VALUE)); - topPanels.add(motionSensingEventsPanel); + topPanels.add(motionSensingEventsPanel); - getContentPane().add(topPanels); + getContentPane().add(topPanels); - setNunchukValuesPanel.setMinimumSize(new java.awt.Dimension(400, 200)); - setNunchukValuesPanel - .setPreferredSize(new java.awt.Dimension(400, 200)); - setNunchukValuesPanel.setLayout(new javax.swing.BoxLayout( - setNunchukValuesPanel, javax.swing.BoxLayout.Y_AXIS)); + setNunchukValuesPanel.setMinimumSize(new java.awt.Dimension(400, 200)); + setNunchukValuesPanel + .setPreferredSize(new java.awt.Dimension(400, 200)); + setNunchukValuesPanel.setLayout(new javax.swing.BoxLayout( + setNunchukValuesPanel, javax.swing.BoxLayout.Y_AXIS)); - nunchukButtonsEventPanel.setToolTipText("Nunchuk ButtonsEvent"); - nunchukButtonsEventPanel - .setMinimumSize(new java.awt.Dimension(100, 100)); - nunchukButtonsEventPanel.setPreferredSize(new java.awt.Dimension(100, - 100)); - nunchukButtonsEventPanel.setLayout(new javax.swing.BoxLayout( - nunchukButtonsEventPanel, javax.swing.BoxLayout.LINE_AXIS)); + nunchukButtonsEventPanel.setToolTipText("Nunchuk ButtonsEvent"); + nunchukButtonsEventPanel + .setMinimumSize(new java.awt.Dimension(100, 100)); + nunchukButtonsEventPanel.setPreferredSize(new java.awt.Dimension(100, + 100)); + nunchukButtonsEventPanel.setLayout(new javax.swing.BoxLayout( + nunchukButtonsEventPanel, javax.swing.BoxLayout.LINE_AXIS)); - cButton.setText("C"); - cButton.setMaximumSize(new java.awt.Dimension(50, 50)); - cButton.setMinimumSize(new java.awt.Dimension(50, 50)); - cButton.setPreferredSize(new java.awt.Dimension(50, 50)); - nunchukButtonsEventPanel.add(cButton); + cButton.setText("C"); + cButton.setMaximumSize(new java.awt.Dimension(50, 50)); + cButton.setMinimumSize(new java.awt.Dimension(50, 50)); + cButton.setPreferredSize(new java.awt.Dimension(50, 50)); + nunchukButtonsEventPanel.add(cButton); - zButton.setText("Z"); - zButton.setMaximumSize(new java.awt.Dimension(50, 50)); - zButton.setMinimumSize(new java.awt.Dimension(50, 50)); - zButton.setPreferredSize(new java.awt.Dimension(50, 50)); - nunchukButtonsEventPanel.add(zButton); + zButton.setText("Z"); + zButton.setMaximumSize(new java.awt.Dimension(50, 50)); + zButton.setMinimumSize(new java.awt.Dimension(50, 50)); + zButton.setPreferredSize(new java.awt.Dimension(50, 50)); + nunchukButtonsEventPanel.add(zButton); - setNunchukValuesPanel.add(nunchukButtonsEventPanel); + setNunchukValuesPanel.add(nunchukButtonsEventPanel); - nunchukOrientationTextField.setPreferredSize(new java.awt.Dimension(60, - 20)); - nunchukOrientationPanel.add(nunchukOrientationTextField); + nunchukOrientationTextField.setPreferredSize(new java.awt.Dimension(60, + 20)); + nunchukOrientationPanel.add(nunchukOrientationTextField); - nunchukOrientationButton.setText("Set Orientation Threshold"); - nunchukOrientationButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - nunchukOrientationButtonMousePressed(evt); - } - }); - nunchukOrientationPanel.add(nunchukOrientationButton); + nunchukOrientationButton.setText("Set Orientation Threshold"); + nunchukOrientationButton + .addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + nunchukOrientationButtonMousePressed(evt); + } + }); + nunchukOrientationPanel.add(nunchukOrientationButton); - setNunchukValuesPanel.add(nunchukOrientationPanel); + setNunchukValuesPanel.add(nunchukOrientationPanel); - nunchukAccelerationTextField.setPreferredSize(new java.awt.Dimension( - 60, 20)); - nunchukAccelerationPanel.add(nunchukAccelerationTextField); + nunchukAccelerationTextField.setPreferredSize(new java.awt.Dimension( + 60, 20)); + nunchukAccelerationPanel.add(nunchukAccelerationTextField); - nunchukAccelerationButton.setText("Set Acceleration Threshold"); - nunchukAccelerationButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - nunchukAccelerationButtonMousePressed(evt); - } - }); - nunchukAccelerationPanel.add(nunchukAccelerationButton); + nunchukAccelerationButton.setText("Set Acceleration Threshold"); + nunchukAccelerationButton + .addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + nunchukAccelerationButtonMousePressed(evt); + } + }); + nunchukAccelerationPanel.add(nunchukAccelerationButton); - setNunchukValuesPanel.add(nunchukAccelerationPanel); + setNunchukValuesPanel.add(nunchukAccelerationPanel); - messageText.setText("Message:"); + messageText.setText("Message:"); - javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout( - messagePanel); - messagePanel.setLayout(messagePanelLayout); - messagePanelLayout - .setHorizontalGroup(messagePanelLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 1216, Short.MAX_VALUE) - .addGroup( - messagePanelLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - messagePanelLayout - .createSequentialGroup() - .addGap(0, 0, - Short.MAX_VALUE) - .addComponent( - messageText) - .addGap(0, 0, - Short.MAX_VALUE)))); - messagePanelLayout - .setVerticalGroup(messagePanelLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 34, Short.MAX_VALUE) - .addGroup( - messagePanelLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - messagePanelLayout - .createSequentialGroup() - .addGap(0, 0, - Short.MAX_VALUE) - .addComponent( - messageText) - .addGap(0, 0, - Short.MAX_VALUE)))); + javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout( + messagePanel); + messagePanel.setLayout(messagePanelLayout); + messagePanelLayout + .setHorizontalGroup(messagePanelLayout + .createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 1216, Short.MAX_VALUE) + .addGroup( + messagePanelLayout + .createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING) + .addGroup( + messagePanelLayout + .createSequentialGroup() + .addGap(0, 0, + Short.MAX_VALUE) + .addComponent( + messageText) + .addGap(0, 0, + Short.MAX_VALUE)))); + messagePanelLayout + .setVerticalGroup(messagePanelLayout + .createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 34, Short.MAX_VALUE) + .addGroup( + messagePanelLayout + .createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING) + .addGroup( + messagePanelLayout + .createSequentialGroup() + .addGap(0, 0, + Short.MAX_VALUE) + .addComponent( + messageText) + .addGap(0, 0, + Short.MAX_VALUE)))); - setNunchukValuesPanel.add(messagePanel); + setNunchukValuesPanel.add(messagePanel); - getContentPane().add(setNunchukValuesPanel); + getContentPane().add(setNunchukValuesPanel); - pack(); - }// //GEN-END:initComponents + pack(); + }// //GEN-END:initComponents - private void nunchukOrientationButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukOrientationButtonMousePressed - try { - float nb = Float.parseFloat(nunchukOrientationTextField.getText()); - wiimote.setNunchukOrientationThreshold(nb); - messageText.setText("Nunchuk orientation threshold set to " + nb); - } catch (NumberFormatException e) { - messageText - .setText("Number is not an integer, nunchuk orientation threshold not set !"); - } - }// GEN-LAST:event_nunchukOrientationButtonMousePressed + private void nunchukOrientationButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukOrientationButtonMousePressed + try { + float nb = Float.parseFloat(nunchukOrientationTextField.getText()); + wiimote.setNunchukOrientationThreshold(nb); + messageText.setText("Nunchuk orientation threshold set to " + nb); + } catch (NumberFormatException e) { + messageText + .setText("Number is not an integer, nunchuk orientation threshold not set !"); + } + }// GEN-LAST:event_nunchukOrientationButtonMousePressed - private void nunchukAccelerationButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukAccelerationButtonMousePressed - try { - int nb = Integer.parseInt(nunchukAccelerationTextField.getText()); - wiimote.setNunchukAccelerationThreshold(nb); - messageText.setText("Nunchuk acceleration threshold set to " + nb); - } catch (NumberFormatException e) { - messageText - .setText("Number is not an integer, nunchuk acceleration threshold not set !"); - } - }// GEN-LAST:event_nunchukAccelerationButtonMousePressed + private void nunchukAccelerationButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukAccelerationButtonMousePressed + try { + int nb = Integer.parseInt(nunchukAccelerationTextField.getText()); + wiimote.setNunchukAccelerationThreshold(nb); + messageText.setText("Nunchuk acceleration threshold set to " + nb); + } catch (NumberFormatException e) { + messageText + .setText("Number is not an integer, nunchuk acceleration threshold not set !"); + } + }// GEN-LAST:event_nunchukAccelerationButtonMousePressed - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - // nothing to do - } + public void onButtonsEvent(WiimoteButtonsEvent arg0) { + // nothing to do + } - public void onIrEvent(IREvent arg0) { - // nothing to do - } + public void onIrEvent(IREvent arg0) { + // nothing to do + } - public void onMotionSensingEvent(MotionSensingEvent arg0) { - // nothing to do - } + public void onMotionSensingEvent(MotionSensingEvent arg0) { + // nothing to do + } - public void onExpansionEvent(ExpansionEvent arg0) { - if (arg0 instanceof NunchukEvent) { - NunchukEvent nunchuk = (NunchukEvent) arg0; - NunchukButtonsEvent buttons = nunchuk.getButtonsEvent(); + public void onExpansionEvent(ExpansionEvent arg0) { + if (arg0 instanceof NunchukEvent) { + NunchukEvent nunchuk = (NunchukEvent) arg0; + NunchukButtonsEvent buttons = nunchuk.getButtonsEvent(); //C button - if (buttons.isButtonCJustPressed()) { - cButton.setEnabled(false); - }else if (buttons.isButtonCJustReleased()) { - cButton.setEnabled(true); - } + if (buttons.isButtonCJustPressed()) { + cButton.setEnabled(false); + }else if (buttons.isButtonCJustReleased()) { + cButton.setEnabled(true); + } //Z button if(buttons.isButtonZJustPressed()) { - zButton.setEnabled(false); - }else if (buttons.isButtonZJustReleased()) { - zButton.setEnabled(true); - } + zButton.setEnabled(false); + }else if (buttons.isButtonZJustReleased()) { + zButton.setEnabled(true); + } - if (isThresholdsRequested) { - MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent(); - nunchukAccelerationTextField.setText(evt - .getAccelerationThreshold() - + ""); - nunchukOrientationTextField.setText(evt - .getOrientationThreshold() - + ""); - isThresholdsRequested = false; - } - } - } + if (isThresholdsRequested) { + MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent(); + nunchukAccelerationTextField.setText(evt + .getAccelerationThreshold() + + ""); + nunchukOrientationTextField.setText(evt + .getOrientationThreshold() + + ""); + isThresholdsRequested = false; + } + } + } - public void onStatusEvent(StatusEvent arg0) { - // nothing to do - } + public void onStatusEvent(StatusEvent arg0) { + // nothing to do + } - public void onDisconnectionEvent(DisconnectionEvent arg0) { - // nothing - } + public void onDisconnectionEvent(DisconnectionEvent arg0) { + // nothing + } - public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { - // nothing - } + public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { + // nothing + } - public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { - // nothing - } + public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { + // nothing + } - public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { - // nothing - } + public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { + // nothing + } - public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { - // nothing - } + public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { + // nothing + } - public void onClassicControllerInsertedEvent( - ClassicControllerInsertedEvent arg0) { - // nothing - } + public void onClassicControllerInsertedEvent( + ClassicControllerInsertedEvent arg0) { + // nothing + } - public void onClassicControllerRemovedEvent( - ClassicControllerRemovedEvent arg0) { - // nothing - } + public void onClassicControllerRemovedEvent( + ClassicControllerRemovedEvent arg0) { + // nothing + } - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton cButton; - private javax.swing.JPanel gForcePanel; - private javax.swing.JPanel joystickEventsPanel; - private javax.swing.JPanel messagePanel; - private javax.swing.JLabel messageText; - private javax.swing.JPanel motionSensingEventsPanel; - private javax.swing.JTabbedPane motionSensingEventsTabbedPanels; - private javax.swing.JButton nunchukAccelerationButton; - private javax.swing.JPanel nunchukAccelerationPanel; - private javax.swing.JTextField nunchukAccelerationTextField; - private javax.swing.JPanel nunchukButtonsEventPanel; - private javax.swing.JButton nunchukOrientationButton; - private javax.swing.JPanel nunchukOrientationPanel; - private javax.swing.JTextField nunchukOrientationTextField; - private javax.swing.JPanel orientationPanel; - private javax.swing.JPanel rawAccelerationPanel; - private javax.swing.JPanel setNunchukValuesPanel; - private javax.swing.JPanel topPanels; - private javax.swing.JButton zButton; - // End of variables declaration//GEN-END:variables + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton cButton; + private javax.swing.JPanel gForcePanel; + private javax.swing.JPanel joystickEventsPanel; + private javax.swing.JPanel messagePanel; + private javax.swing.JLabel messageText; + private javax.swing.JPanel motionSensingEventsPanel; + private javax.swing.JTabbedPane motionSensingEventsTabbedPanels; + private javax.swing.JButton nunchukAccelerationButton; + private javax.swing.JPanel nunchukAccelerationPanel; + private javax.swing.JTextField nunchukAccelerationTextField; + private javax.swing.JPanel nunchukButtonsEventPanel; + private javax.swing.JButton nunchukOrientationButton; + private javax.swing.JPanel nunchukOrientationPanel; + private javax.swing.JTextField nunchukOrientationTextField; + private javax.swing.JPanel orientationPanel; + private javax.swing.JPanel rawAccelerationPanel; + private javax.swing.JPanel setNunchukValuesPanel; + private javax.swing.JPanel topPanels; + private javax.swing.JButton zButton; + // End of variables declaration//GEN-END:variables } diff --git a/src/test/java/wiiusej/test/Tests.java b/src/test/java/wiiusej/test/Tests.java index 88fe873..2256093 100644 --- a/src/test/java/wiiusej/test/Tests.java +++ b/src/test/java/wiiusej/test/Tests.java @@ -44,346 +44,346 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; */ public class Tests implements WiimoteListener { - Robot robot; + Robot robot; - private static int DISPLAY_EACH_VALUE = 1; - private static int DUMP = 2; - private static int MOVE_MOUSE = 3; - private static int TEST_LEDS = 5; + private static int DISPLAY_EACH_VALUE = 1; + private static int DUMP = 2; + private static int MOVE_MOUSE = 3; + private static int TEST_LEDS = 5; - private Wiimote wiimote; + private Wiimote wiimote; - int dump = DISPLAY_EACH_VALUE; + int dump = DISPLAY_EACH_VALUE; - public Tests(Wiimote wim) { - wiimote = wim; - wiimote.addWiiMoteEventListeners(this); - try { - robot = new Robot(); - } catch (AWTException e) { - e.printStackTrace(); - } - } + public Tests(Wiimote wim) { + wiimote = wim; + wiimote.addWiiMoteEventListeners(this); + try { + robot = new Robot(); + } catch (AWTException e) { + e.printStackTrace(); + } + } - public void onButtonsEvent(WiimoteButtonsEvent e) { - if (dump == DISPLAY_EACH_VALUE) { - // System.out.println("*********** WIIMOTE ID : "+ - // e.getWiimoteId() + " **************"); - /* button ONE */ - if (e.isButtonOneJustPressed()) { - System.out.println("button one pressed"); - } - if (e.isButtonOneHeld()) { - System.out.println("button one held"); - } - if (e.isButtonOneJustReleased()) { - System.out.println("button one released"); - } + public void onButtonsEvent(WiimoteButtonsEvent e) { + if (dump == DISPLAY_EACH_VALUE) { + // System.out.println("*********** WIIMOTE ID : "+ + // e.getWiimoteId() + " **************"); + /* button ONE */ + if (e.isButtonOneJustPressed()) { + System.out.println("button one pressed"); + } + if (e.isButtonOneHeld()) { + System.out.println("button one held"); + } + if (e.isButtonOneJustReleased()) { + System.out.println("button one released"); + } - /* button TWO */ - if (e.isButtonTwoJustPressed()) { - System.out.println("button two pressed"); - } - if (e.isButtonTwoHeld()) { - System.out.println("button two held"); - } - if (e.isButtonTwoJustReleased()) { - System.out.println("button two released"); - } + /* button TWO */ + if (e.isButtonTwoJustPressed()) { + System.out.println("button two pressed"); + } + if (e.isButtonTwoHeld()) { + System.out.println("button two held"); + } + if (e.isButtonTwoJustReleased()) { + System.out.println("button two released"); + } - /* button A */ - if (e.isButtonAJustPressed()) { - System.out.println("button A pressed"); - } - if (e.isButtonAHeld()) { - System.out.println("button A held"); - } - if (e.isButtonAJustReleased()) { - System.out.println("button A released"); - } + /* button A */ + if (e.isButtonAJustPressed()) { + System.out.println("button A pressed"); + } + if (e.isButtonAHeld()) { + System.out.println("button A held"); + } + if (e.isButtonAJustReleased()) { + System.out.println("button A released"); + } - /* button B */ - if (e.isButtonBJustPressed()) { - System.out.println("button B pressed"); - } - if (e.isButtonBHeld()) { - System.out.println("button B held"); - } - if (e.isButtonBJustReleased()) { - System.out.println("button B released"); - } + /* button B */ + if (e.isButtonBJustPressed()) { + System.out.println("button B pressed"); + } + if (e.isButtonBHeld()) { + System.out.println("button B held"); + } + if (e.isButtonBJustReleased()) { + System.out.println("button B released"); + } - /* button LEFT */ - if (e.isButtonLeftJustPressed()) { - System.out.println("button Left pressed"); - } - if (e.isButtonLeftHeld()) { - System.out.println("button Left held"); - } - if (e.isButtonLeftJustReleased()) { - System.out.println("button Left released"); - } + /* button LEFT */ + if (e.isButtonLeftJustPressed()) { + System.out.println("button Left pressed"); + } + if (e.isButtonLeftHeld()) { + System.out.println("button Left held"); + } + if (e.isButtonLeftJustReleased()) { + System.out.println("button Left released"); + } - /* button RIGHT */ - if (e.isButtonRightJustPressed()) { - System.out.println("button Right pressed"); - } - if (e.isButtonRightHeld()) { - System.out.println("button Right held"); - } - if (e.isButtonRightJustReleased()) { - System.out.println("button Right released"); - } + /* button RIGHT */ + if (e.isButtonRightJustPressed()) { + System.out.println("button Right pressed"); + } + if (e.isButtonRightHeld()) { + System.out.println("button Right held"); + } + if (e.isButtonRightJustReleased()) { + System.out.println("button Right released"); + } - /* button UP */ - if (e.isButtonUpJustPressed()) { - System.out.println("button UP pressed"); - } - if (e.isButtonUpHeld()) { - System.out.println("button UP held"); - } - if (e.isButtonUpJustReleased()) { - System.out.println("button UP released"); - } + /* button UP */ + if (e.isButtonUpJustPressed()) { + System.out.println("button UP pressed"); + } + if (e.isButtonUpHeld()) { + System.out.println("button UP held"); + } + if (e.isButtonUpJustReleased()) { + System.out.println("button UP released"); + } - /* button DOWN */ - if (e.isButtonDownJustPressed()) { - System.out.println("button DOWN pressed"); - } - if (e.isButtonDownHeld()) { - System.out.println("button DOWN held"); - } - if (e.isButtonDownJustReleased()) { - System.out.println("button DOWN released"); - } + /* button DOWN */ + if (e.isButtonDownJustPressed()) { + System.out.println("button DOWN pressed"); + } + if (e.isButtonDownHeld()) { + System.out.println("button DOWN held"); + } + if (e.isButtonDownJustReleased()) { + System.out.println("button DOWN released"); + } - /* button MINUS */ - if (e.isButtonMinusJustPressed()) { - System.out.println("button MINUS pressed"); - } - if (e.isButtonMinusHeld()) { - System.out.println("button MINUS held"); - } - if (e.isButtonMinusJustReleased()) { - System.out.println("button MINUS released"); - } + /* button MINUS */ + if (e.isButtonMinusJustPressed()) { + System.out.println("button MINUS pressed"); + } + if (e.isButtonMinusHeld()) { + System.out.println("button MINUS held"); + } + if (e.isButtonMinusJustReleased()) { + System.out.println("button MINUS released"); + } - /* button PLUS */ - if (e.isButtonPlusJustPressed()) { - System.out.println("button PLUS pressed"); - } - if (e.isButtonPlusHeld()) { - System.out.println("button PLUS held"); - } - if (e.isButtonPlusJustReleased()) { - System.out.println("button PLUS released"); - } + /* button PLUS */ + if (e.isButtonPlusJustPressed()) { + System.out.println("button PLUS pressed"); + } + if (e.isButtonPlusHeld()) { + System.out.println("button PLUS held"); + } + if (e.isButtonPlusJustReleased()) { + System.out.println("button PLUS released"); + } - /* button HOME */ - if (e.isButtonHomeJustPressed()) { - System.out.println("button HOME pressed"); - } - if (e.isButtonHomeHeld()) { - System.out.println("button HOME held"); - } - if (e.isButtonHomeJustReleased()) { - System.out.println("button HOME released"); - } + /* button HOME */ + if (e.isButtonHomeJustPressed()) { + System.out.println("button HOME pressed"); + } + if (e.isButtonHomeHeld()) { + System.out.println("button HOME held"); + } + if (e.isButtonHomeJustReleased()) { + System.out.println("button HOME released"); + } - /* get status */ - if (e.isButtonUpJustPressed()) { - wiimote.getStatus(); - } + /* get status */ + if (e.isButtonUpJustPressed()) { + wiimote.getStatus(); + } - /* Activate rumble */ - if (e.isButtonOneJustPressed()) { - System.out.println("Rumble Activated"); - wiimote.activateRumble(); - } - if (e.isButtonTwoJustPressed()) { - System.out.println("Rumble Deactivated"); - wiimote.deactivateRumble(); - } + /* Activate rumble */ + if (e.isButtonOneJustPressed()) { + System.out.println("Rumble Activated"); + wiimote.activateRumble(); + } + if (e.isButtonTwoJustPressed()) { + System.out.println("Rumble Deactivated"); + wiimote.deactivateRumble(); + } - /* Activate IR Tracking */ - if (e.isButtonAJustPressed()) { - System.out.println("IR Activated"); - wiimote.activateIRTRacking(); - } - if (e.isButtonBJustPressed()) { - System.out.println("IR Deactivated"); - wiimote.deactivateIRTRacking(); - } + /* Activate IR Tracking */ + if (e.isButtonAJustPressed()) { + System.out.println("IR Activated"); + wiimote.activateIRTRacking(); + } + if (e.isButtonBJustPressed()) { + System.out.println("IR Deactivated"); + wiimote.deactivateIRTRacking(); + } - /* Activate Motion sensing */ - if (e.isButtonPlusJustPressed()) { - System.out.println("Motion sensing Activated"); - wiimote.activateMotionSensing(); - } - if (e.isButtonMinusJustPressed()) { - System.out.println("Motion sensing Deactivated"); - wiimote.deactivateMotionSensing(); - } + /* Activate Motion sensing */ + if (e.isButtonPlusJustPressed()) { + System.out.println("Motion sensing Activated"); + wiimote.activateMotionSensing(); + } + if (e.isButtonMinusJustPressed()) { + System.out.println("Motion sensing Deactivated"); + wiimote.deactivateMotionSensing(); + } - /* leave test */ - if (e.isButtonHomeJustPressed()) { - System.out.println("LEAVING TEST"); - wiimote.disconnect(); - WiiUseApiManager.definitiveShutdown(); - } + /* leave test */ + if (e.isButtonHomeJustPressed()) { + System.out.println("LEAVING TEST"); + wiimote.disconnect(); + WiiUseApiManager.definitiveShutdown(); + } - } else if (dump == DUMP) { - System.out.println(e); - /* Activate all */ - if (e.isButtonAJustPressed()) { - System.out.println("IR, rumble and motion sensing Activated"); - wiimote.activateIRTRacking(); - wiimote.activateMotionSensing(); - wiimote.activateRumble(); - } - if (e.isButtonBJustPressed()) { - System.out.println("IR, rumble and motion sensing Deactivated"); - wiimote.deactivateIRTRacking(); - wiimote.deactivateMotionSensing(); - wiimote.deactivateRumble(); - } + } else if (dump == DUMP) { + System.out.println(e); + /* Activate all */ + if (e.isButtonAJustPressed()) { + System.out.println("IR, rumble and motion sensing Activated"); + wiimote.activateIRTRacking(); + wiimote.activateMotionSensing(); + wiimote.activateRumble(); + } + if (e.isButtonBJustPressed()) { + System.out.println("IR, rumble and motion sensing Deactivated"); + wiimote.deactivateIRTRacking(); + wiimote.deactivateMotionSensing(); + wiimote.deactivateRumble(); + } - /* leave test */ - if (e.isButtonHomeJustPressed()) { - System.out.println("LEAVING TEST"); - wiimote.disconnect(); - } - } else if (dump == MOVE_MOUSE) { - /* Activate IR Tracking */ - if (e.isButtonOneJustPressed()) { - System.out.println("IR Activated"); - wiimote.activateIRTRacking(); - } - if (e.isButtonTwoJustPressed()) { - System.out.println("IR Deactivated"); - wiimote.deactivateIRTRacking(); - } + /* leave test */ + if (e.isButtonHomeJustPressed()) { + System.out.println("LEAVING TEST"); + wiimote.disconnect(); + } + } else if (dump == MOVE_MOUSE) { + /* Activate IR Tracking */ + if (e.isButtonOneJustPressed()) { + System.out.println("IR Activated"); + wiimote.activateIRTRacking(); + } + if (e.isButtonTwoJustPressed()) { + System.out.println("IR Deactivated"); + wiimote.deactivateIRTRacking(); + } - /* button A */ - if (e.isButtonAJustPressed()) { - robot.mousePress(InputEvent.BUTTON1_MASK); - } - if (e.isButtonAJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON1_MASK); - } + /* button A */ + if (e.isButtonAJustPressed()) { + robot.mousePress(InputEvent.BUTTON1_MASK); + } + if (e.isButtonAJustReleased()) { + robot.mouseRelease(InputEvent.BUTTON1_MASK); + } - /* button B */ - if (e.isButtonBJustPressed()) { - robot.mousePress(InputEvent.BUTTON2_MASK); - } - if (e.isButtonBJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON2_MASK); - } + /* button B */ + if (e.isButtonBJustPressed()) { + robot.mousePress(InputEvent.BUTTON2_MASK); + } + if (e.isButtonBJustReleased()) { + robot.mouseRelease(InputEvent.BUTTON2_MASK); + } - /* leave test */ - if (e.isButtonHomeJustPressed()) { - System.out.println("LEAVING TEST"); - wiimote.disconnect(); - } - } else if (dump == TEST_LEDS) { - wiimote.activateMotionSensing(); - if (e.isButtonUpJustPressed()) { - wiimote.setLeds(true, false, false, false); - } - if (e.isButtonDownJustPressed()) { - wiimote.setLeds(false, true, false, false); - } - if (e.isButtonLeftJustPressed()) { - wiimote.setLeds(false, false, true, false); - } - if (e.isButtonRightJustPressed()) { - wiimote.setLeds(false, false, false, true); - } + /* leave test */ + if (e.isButtonHomeJustPressed()) { + System.out.println("LEAVING TEST"); + wiimote.disconnect(); + } + } else if (dump == TEST_LEDS) { + wiimote.activateMotionSensing(); + if (e.isButtonUpJustPressed()) { + wiimote.setLeds(true, false, false, false); + } + if (e.isButtonDownJustPressed()) { + wiimote.setLeds(false, true, false, false); + } + if (e.isButtonLeftJustPressed()) { + wiimote.setLeds(false, false, true, false); + } + if (e.isButtonRightJustPressed()) { + wiimote.setLeds(false, false, false, true); + } - /* leave test */ - if (e.isButtonHomeJustPressed()) { - System.out.println("LEAVING TEST"); - wiimote.disconnect(); - } - } + /* leave test */ + if (e.isButtonHomeJustPressed()) { + System.out.println("LEAVING TEST"); + wiimote.disconnect(); + } + } - } + } - public void onIrEvent(IREvent e) { - if (dump == MOVE_MOUSE) { - IRSource[] list = e.getIRPoints(); - if (list.length > 0) { - int x1 = (int) list[0].getX(); - int y1 = (int) list[0].getY(); + public void onIrEvent(IREvent e) { + if (dump == MOVE_MOUSE) { + IRSource[] list = e.getIRPoints(); + if (list.length > 0) { + int x1 = (int) list[0].getX(); + int y1 = (int) list[0].getY(); - int mousex = (int) Math.round(((double) x1 / 1024.0) * 1280.0); - int mousey = (int) Math.round(((double) y1 / 768.0) * 1024.0); - robot.mouseMove(mousex, mousey); - } - } else { - System.out.println(e); - } - } + int mousex = (int) Math.round(((double) x1 / 1024.0) * 1280.0); + int mousey = (int) Math.round(((double) y1 / 768.0) * 1024.0); + robot.mouseMove(mousex, mousey); + } + } else { + System.out.println(e); + } + } - public void onMotionSensingEvent(MotionSensingEvent e) { - /* display motion sensing */ - System.out.println(e); - } + public void onMotionSensingEvent(MotionSensingEvent e) { + /* display motion sensing */ + System.out.println(e); + } - public void onExpansionEvent(ExpansionEvent e) { - System.out.println(e); - } + public void onExpansionEvent(ExpansionEvent e) { + System.out.println(e); + } - public void onStatusEvent(StatusEvent e) { - // Display status variables - System.out.println(e); - } + public void onStatusEvent(StatusEvent e) { + // Display status variables + System.out.println(e); + } - public void onDisconnectionEvent(DisconnectionEvent e) { - System.out.println(" wiimote " + e.getWiimoteId() - + "has been disconnected !!"); - } + public void onDisconnectionEvent(DisconnectionEvent e) { + System.out.println(" wiimote " + e.getWiimoteId() + + "has been disconnected !!"); + } - public void onNunchukInsertedEvent(NunchukInsertedEvent e) { - System.out.println(e); - } + public void onNunchukInsertedEvent(NunchukInsertedEvent e) { + System.out.println(e); + } - public void onNunchukRemovedEvent(NunchukRemovedEvent e) { - System.out.println(e); - } + public void onNunchukRemovedEvent(NunchukRemovedEvent e) { + System.out.println(e); + } - public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e) { - System.out.println(e); - } + public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e) { + System.out.println(e); + } - public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e) { - System.out.println(e); - } + public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e) { + System.out.println(e); + } - public void onClassicControllerInsertedEvent( - ClassicControllerInsertedEvent e) { - System.out.println(e); - } + public void onClassicControllerInsertedEvent( + ClassicControllerInsertedEvent e) { + System.out.println(e); + } - public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e) { - System.out.println(e); - } + public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e) { + System.out.println(e); + } - /** - * @param args - */ - public static void main(String[] args) { - Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true); - if (wiimotes.length > 0) { - System.out.println(wiimotes[0]); - new Tests(wiimotes[0]); - } else { - System.out.println("No wiimotes found !!!"); - } + /** + * @param args + */ + public static void main(String[] args) { + Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true); + if (wiimotes.length > 0) { + System.out.println(wiimotes[0]); + new Tests(wiimotes[0]); + } else { + System.out.println("No wiimotes found !!!"); + } - // java.util.Timer timer = new java.util.Timer(); - // timer.scheduleAtFixedRate(new LedsTask(), 0, 100); + // java.util.Timer timer = new java.util.Timer(); + // timer.scheduleAtFixedRate(new LedsTask(), 0, 100); - } + } } diff --git a/src/test/java/wiiusej/test/WiiuseJGuiTest.java b/src/test/java/wiiusej/test/WiiuseJGuiTest.java index 54dc777..1fc848c 100644 --- a/src/test/java/wiiusej/test/WiiuseJGuiTest.java +++ b/src/test/java/wiiusej/test/WiiuseJGuiTest.java @@ -54,49 +54,49 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; * @author guiguito */ public class WiiuseJGuiTest extends javax.swing.JFrame implements - WiimoteListener { + WiimoteListener { - private Wiimote wiimote; - private Robot robot = null; - private boolean statusMotionRequested = false; - private boolean statusIRRequested = false; - private JFrame expansionFrame = null; - private boolean isFirstStatusGot = false; - private WindowListener buttonSetter = new WindowListener() { + private Wiimote wiimote; + private Robot robot = null; + private boolean statusMotionRequested = false; + private boolean statusIRRequested = false; + private JFrame expansionFrame = null; + private boolean isFirstStatusGot = false; + private WindowListener buttonSetter = new WindowListener() { - public void windowOpened(WindowEvent e) { - // nothing - } + public void windowOpened(WindowEvent e) { + // nothing + } - public void windowClosing(WindowEvent e) { - // nothing - } + public void windowClosing(WindowEvent e) { + // nothing + } - public void windowClosed(WindowEvent e) { - // nothing - } + public void windowClosed(WindowEvent e) { + // nothing + } - public void windowIconified(WindowEvent e) { - // nothing - } + public void windowIconified(WindowEvent e) { + // nothing + } - public void windowDeiconified(WindowEvent e) { - // nothing - } + public void windowDeiconified(WindowEvent e) { + // nothing + } - public void windowActivated(WindowEvent e) { - showExpansionWiimoteButton.setEnabled(false); + public void windowActivated(WindowEvent e) { + showExpansionWiimoteButton.setEnabled(false); if (expansionFrame instanceof NunchukGuiTest){ showExpansionWiimoteButton.setText("Hide Nunchuk"); }else if(expansionFrame instanceof GuitarHero3GuiTest){ showExpansionWiimoteButton.setText("Hide Guitar"); }else if(expansionFrame instanceof ClassicControllerGuiTest){ showExpansionWiimoteButton.setText("Hide Classic Controller"); - } - } + } + } - public void windowDeactivated(WindowEvent e) { - showExpansionWiimoteButton.setEnabled(true); + public void windowDeactivated(WindowEvent e) { + showExpansionWiimoteButton.setEnabled(true); if (expansionFrame instanceof NunchukGuiTest){ showExpansionWiimoteButton.setText("Show Nunchuk"); }else if(expansionFrame instanceof GuitarHero3GuiTest){ @@ -104,287 +104,287 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements }else if(expansionFrame instanceof ClassicControllerGuiTest){ showExpansionWiimoteButton.setText("Show Classic controller"); } - } - }; + } + }; - /** - * default constructor - */ - public WiiuseJGuiTest() { - initComponents(); - this.addWindowListener(new CloseGuiTestCleanly()); - } + /** + * default constructor + */ + public WiiuseJGuiTest() { + initComponents(); + this.addWindowListener(new CloseGuiTestCleanly()); + } - /** - * Creates new form WiiuseJGuiTest - */ - public WiiuseJGuiTest(Wiimote wiimote) { - initComponents(); - this.addWindowListener(new CloseGuiTestCleanly()); - if (wiimote != null) { - this.wiimote = wiimote; - registerListeners(); - initWiimote(); - isFirstStatusGot = false; - getStatusButtonMousePressed(null); - } - } + /** + * Creates new form WiiuseJGuiTest + */ + public WiiuseJGuiTest(Wiimote wiimote) { + initComponents(); + this.addWindowListener(new CloseGuiTestCleanly()); + if (wiimote != null) { + this.wiimote = wiimote; + registerListeners(); + initWiimote(); + isFirstStatusGot = false; + getStatusButtonMousePressed(null); + } + } - /** - * Clear all views - */ - private void clearViews() { - ((IRPanel) irViewPanel).clearView(); - ((ButtonsEventPanel) buttonsPanel).clearView(); - ((OrientationPanel) motionSensingPanel).clearView(); - ((GForcePanel) gForcePanel).clearView(); - ((AccelerationPanel) accelerationPanel).clearView(); - } + /** + * Clear all views + */ + private void clearViews() { + ((IRPanel) irViewPanel).clearView(); + ((ButtonsEventPanel) buttonsPanel).clearView(); + ((OrientationPanel) motionSensingPanel).clearView(); + ((GForcePanel) gForcePanel).clearView(); + ((AccelerationPanel) accelerationPanel).clearView(); + } - /** - * Unregister all listeners. - */ - private void unregisterListeners() { - wiimote.removeWiiMoteEventListeners((IRPanel) irViewPanel); - wiimote.removeWiiMoteEventListeners((ButtonsEventPanel) buttonsPanel); - wiimote - .removeWiiMoteEventListeners((OrientationPanel) motionSensingPanel); - wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel); - wiimote - .removeWiiMoteEventListeners((AccelerationPanel) accelerationPanel); - wiimote.removeWiiMoteEventListeners(this); - } + /** + * Unregister all listeners. + */ + private void unregisterListeners() { + wiimote.removeWiiMoteEventListeners((IRPanel) irViewPanel); + wiimote.removeWiiMoteEventListeners((ButtonsEventPanel) buttonsPanel); + wiimote + .removeWiiMoteEventListeners((OrientationPanel) motionSensingPanel); + wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel); + wiimote + .removeWiiMoteEventListeners((AccelerationPanel) accelerationPanel); + wiimote.removeWiiMoteEventListeners(this); + } - private void initWiimote() { - wiimote.deactivateContinuous(); - wiimote.deactivateSmoothing(); - wiimote.setScreenAspectRatio169(); - wiimote.setSensorBarBelowScreen(); - } + private void initWiimote() { + wiimote.deactivateContinuous(); + wiimote.deactivateSmoothing(); + wiimote.setScreenAspectRatio169(); + wiimote.setSensorBarBelowScreen(); + } - /** - * Register all listeners - */ - private void registerListeners() { - wiimote.addWiiMoteEventListeners((IRPanel) irViewPanel); - wiimote.addWiiMoteEventListeners((ButtonsEventPanel) buttonsPanel); - wiimote.addWiiMoteEventListeners((OrientationPanel) motionSensingPanel); - wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel); - wiimote.addWiiMoteEventListeners((AccelerationPanel) accelerationPanel); - wiimote.addWiiMoteEventListeners(this); + /** + * Register all listeners + */ + private void registerListeners() { + wiimote.addWiiMoteEventListeners((IRPanel) irViewPanel); + wiimote.addWiiMoteEventListeners((ButtonsEventPanel) buttonsPanel); + wiimote.addWiiMoteEventListeners((OrientationPanel) motionSensingPanel); + wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel); + wiimote.addWiiMoteEventListeners((AccelerationPanel) accelerationPanel); + wiimote.addWiiMoteEventListeners(this); - } + } - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - if (robot != null) { - if (arg0.isButtonAPressed()) { - robot.mousePress(InputEvent.BUTTON1_MASK); + public void onButtonsEvent(WiimoteButtonsEvent arg0) { + if (robot != null) { + if (arg0.isButtonAPressed()) { + robot.mousePress(InputEvent.BUTTON1_MASK); - } - if (arg0.isButtonBPressed()) { - robot.mousePress(InputEvent.BUTTON2_MASK); + } + if (arg0.isButtonBPressed()) { + robot.mousePress(InputEvent.BUTTON2_MASK); - } - if (arg0.isButtonOnePressed()) { - robot.mousePress(InputEvent.BUTTON3_MASK); + } + if (arg0.isButtonOnePressed()) { + robot.mousePress(InputEvent.BUTTON3_MASK); - } - if (arg0.isButtonAJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON1_MASK); + } + if (arg0.isButtonAJustReleased()) { + robot.mouseRelease(InputEvent.BUTTON1_MASK); - } - if (arg0.isButtonBJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON2_MASK); + } + if (arg0.isButtonBJustReleased()) { + robot.mouseRelease(InputEvent.BUTTON2_MASK); - } - if (arg0.isButtonOneJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON3_MASK); + } + if (arg0.isButtonOneJustReleased()) { + robot.mouseRelease(InputEvent.BUTTON3_MASK); - } - if (arg0.isButtonUpPressed()) {// mouse wheel up - robot.mouseWheel(-1); - } - if (arg0.isButtonDownPressed()) {// mouse wheel down - robot.mouseWheel(1); - } + } + if (arg0.isButtonUpPressed()) {// mouse wheel up + robot.mouseWheel(-1); + } + if (arg0.isButtonDownPressed()) {// mouse wheel down + robot.mouseWheel(1); + } - if (arg0.isButtonTwoPressed()) {// stop mouse control - mouseIRControlButtonMousePressed(null); - } - } - } + if (arg0.isButtonTwoPressed()) {// stop mouse control + mouseIRControlButtonMousePressed(null); + } + } + } - public void onIrEvent(IREvent arg0) { - if (robot != null) {// if mouse control activated - robot.mouseMove(arg0.getX(), arg0.getY()); - } - if (statusIRRequested) { - xResolutionTextField.setText("" + arg0.getXVRes()); - yResolutionTextField.setText("" + arg0.getYVRes()); - statusIRRequested = false; - } - } + public void onIrEvent(IREvent arg0) { + if (robot != null) {// if mouse control activated + robot.mouseMove(arg0.getX(), arg0.getY()); + } + if (statusIRRequested) { + xResolutionTextField.setText("" + arg0.getXVRes()); + yResolutionTextField.setText("" + arg0.getYVRes()); + statusIRRequested = false; + } + } - public void onMotionSensingEvent(MotionSensingEvent arg0) { - if (statusMotionRequested) {// Status requested - accelerationThresholdTextField.setText("" - + arg0.getAccelerationThreshold()); - orientationThresholdTextField.setText("" - + arg0.getOrientationThreshold()); - alphaSmoothingTextField.setText("" + arg0.getAlphaSmoothing()); - statusMotionRequested = false; - } - } + public void onMotionSensingEvent(MotionSensingEvent arg0) { + if (statusMotionRequested) {// Status requested + accelerationThresholdTextField.setText("" + + arg0.getAccelerationThreshold()); + orientationThresholdTextField.setText("" + + arg0.getOrientationThreshold()); + alphaSmoothingTextField.setText("" + arg0.getAlphaSmoothing()); + statusMotionRequested = false; + } + } - public void onExpansionEvent(ExpansionEvent e) { - // nothing yet - } + public void onExpansionEvent(ExpansionEvent e) { + // nothing yet + } - public void onStatusEvent(StatusEvent arg0) { - if (!isFirstStatusGot) { - if (arg0.isNunchukConnected()) { - showExpansionWiimoteButton.setEnabled(true); - showExpansionWiimoteButton.setText("Show Nunchuk"); - expansionFrame = new NunchukGuiTest(wiimote); - expansionFrame - .setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); - expansionFrame.addWindowListener(buttonSetter); - isFirstStatusGot = true; - }else if(arg0.isClassicControllerConnected()){ + public void onStatusEvent(StatusEvent arg0) { + if (!isFirstStatusGot) { + if (arg0.isNunchukConnected()) { + showExpansionWiimoteButton.setEnabled(true); + showExpansionWiimoteButton.setText("Show Nunchuk"); + expansionFrame = new NunchukGuiTest(wiimote); + expansionFrame + .setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + expansionFrame.addWindowListener(buttonSetter); + isFirstStatusGot = true; + }else if(arg0.isClassicControllerConnected()){ showExpansionWiimoteButton.setEnabled(true); - showExpansionWiimoteButton.setText("Show Classic Controller"); - expansionFrame = new ClassicControllerGuiTest(wiimote); - expansionFrame - .setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); - expansionFrame.addWindowListener(buttonSetter); - isFirstStatusGot = true; + showExpansionWiimoteButton.setText("Show Classic Controller"); + expansionFrame = new ClassicControllerGuiTest(wiimote); + expansionFrame + .setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + expansionFrame.addWindowListener(buttonSetter); + isFirstStatusGot = true; } else if(arg0.isGuitarHeroConnected()){ showExpansionWiimoteButton.setEnabled(true); - showExpansionWiimoteButton.setText("Show Guitar Hero 3 Controller"); - expansionFrame = new GuitarHero3GuiTest(wiimote); - expansionFrame - .setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); - expansionFrame.addWindowListener(buttonSetter); - isFirstStatusGot = true; + showExpansionWiimoteButton.setText("Show Guitar Hero 3 Controller"); + expansionFrame = new GuitarHero3GuiTest(wiimote); + expansionFrame + .setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + expansionFrame.addWindowListener(buttonSetter); + isFirstStatusGot = true; } - } - messageText.setText("Status received !"); - batteryLevelText.setText(arg0.getBatteryLevel() + " %"); - led1Button.setEnabled(arg0.isLed1Set()); - led2Button.setEnabled(arg0.isLed2Set()); - led3Button.setEnabled(arg0.isLed3Set()); - led4Button.setEnabled(arg0.isLed4Set()); - if (arg0.isNunchukConnected()) { + } + messageText.setText("Status received !"); + batteryLevelText.setText(arg0.getBatteryLevel() + " %"); + led1Button.setEnabled(arg0.isLed1Set()); + led2Button.setEnabled(arg0.isLed2Set()); + led3Button.setEnabled(arg0.isLed3Set()); + led4Button.setEnabled(arg0.isLed4Set()); + if (arg0.isNunchukConnected()) { ((NunchukGuiTest) expansionFrame).requestThresholdsUpdate(); - } - // attachments - int eventType = arg0.getEventType(); - if (eventType == StatusEvent.WIIUSE_CLASSIC_CTRL_INSERTED) { - expansionText.setText("Classic control connected."); - } else if (eventType == StatusEvent.WIIUSE_CLASSIC_CTRL_REMOVED) { - expansionText.setText("Classic control removed."); - } else if (eventType == StatusEvent.WIIUSE_NUNCHUK_INSERTED) { - expansionText.setText("Nunchuk connected."); - } else if (eventType == StatusEvent.WIIUSE_NUNCHUK_REMOVED) { - expansionText.setText("Nunchuk removed."); - } else if (eventType == StatusEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED) { - expansionText.setText("Guitar Hero 3 control connected."); - } else if (eventType == StatusEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED) { - expansionText.setText("Guitar Hero 3 control removed."); - } - } + } + // attachments + int eventType = arg0.getEventType(); + if (eventType == StatusEvent.WIIUSE_CLASSIC_CTRL_INSERTED) { + expansionText.setText("Classic control connected."); + } else if (eventType == StatusEvent.WIIUSE_CLASSIC_CTRL_REMOVED) { + expansionText.setText("Classic control removed."); + } else if (eventType == StatusEvent.WIIUSE_NUNCHUK_INSERTED) { + expansionText.setText("Nunchuk connected."); + } else if (eventType == StatusEvent.WIIUSE_NUNCHUK_REMOVED) { + expansionText.setText("Nunchuk removed."); + } else if (eventType == StatusEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED) { + expansionText.setText("Guitar Hero 3 control connected."); + } else if (eventType == StatusEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED) { + expansionText.setText("Guitar Hero 3 control removed."); + } + } - public void onDisconnectionEvent(DisconnectionEvent arg0) { - messageText.setText("Wiimote Disconnected !"); - unregisterListeners(); - clearViews(); - isFirstStatusGot = false; - } + public void onDisconnectionEvent(DisconnectionEvent arg0) { + messageText.setText("Wiimote Disconnected !"); + unregisterListeners(); + clearViews(); + isFirstStatusGot = false; + } - public void onNunchukInsertedEvent(NunchukInsertedEvent e) { - messageText.setText("Nunchuk connected !"); - expansionText.setText("Expansion connected : Nunchuk."); - showExpansionWiimoteButton.setEnabled(true); - showExpansionWiimoteButton.setText("Show nunchuk"); - expansionFrame = new NunchukGuiTest(wiimote); - expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); - expansionFrame.addWindowListener(buttonSetter); - } + public void onNunchukInsertedEvent(NunchukInsertedEvent e) { + messageText.setText("Nunchuk connected !"); + expansionText.setText("Expansion connected : Nunchuk."); + showExpansionWiimoteButton.setEnabled(true); + showExpansionWiimoteButton.setText("Show nunchuk"); + expansionFrame = new NunchukGuiTest(wiimote); + expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + expansionFrame.addWindowListener(buttonSetter); + } - public void onNunchukRemovedEvent(NunchukRemovedEvent e) { - messageText.setText("Nunchuk disconnected !"); - expansionText.setText("No expansion connected."); - showExpansionWiimoteButton.setEnabled(false); - showExpansionWiimoteButton.setText("No expansion"); - if (expansionFrame != null) { - if (expansionFrame instanceof NunchukGuiTest) { - ((NunchukGuiTest) expansionFrame).unRegisterListeners(); - } - expansionFrame.setEnabled(false); - expansionFrame.dispose(); - expansionFrame = null; - } - } + public void onNunchukRemovedEvent(NunchukRemovedEvent e) { + messageText.setText("Nunchuk disconnected !"); + expansionText.setText("No expansion connected."); + showExpansionWiimoteButton.setEnabled(false); + showExpansionWiimoteButton.setText("No expansion"); + if (expansionFrame != null) { + if (expansionFrame instanceof NunchukGuiTest) { + ((NunchukGuiTest) expansionFrame).unRegisterListeners(); + } + expansionFrame.setEnabled(false); + expansionFrame.dispose(); + expansionFrame = null; + } + } - public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { - messageText.setText("Guitar Hero 3 connected !"); - expansionText.setText("Expansion connected : Guitar Hero 3."); - showExpansionWiimoteButton.setEnabled(true); - showExpansionWiimoteButton.setText("Show Guitar Hero 3"); - expansionFrame = new GuitarHero3GuiTest(wiimote); - expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); - expansionFrame.addWindowListener(buttonSetter); - } + public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) { + messageText.setText("Guitar Hero 3 connected !"); + expansionText.setText("Expansion connected : Guitar Hero 3."); + showExpansionWiimoteButton.setEnabled(true); + showExpansionWiimoteButton.setText("Show Guitar Hero 3"); + expansionFrame = new GuitarHero3GuiTest(wiimote); + expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + expansionFrame.addWindowListener(buttonSetter); + } - public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { - messageText.setText("Guitar Hero 3 disconnected !"); - expansionText.setText("No expansion connected."); - showExpansionWiimoteButton.setEnabled(false); - showExpansionWiimoteButton.setText("No expansion"); - if (expansionFrame != null) { - if (expansionFrame instanceof GuitarHero3GuiTest) { - ((GuitarHero3GuiTest) expansionFrame).unRegisterListeners(); - } - expansionFrame.setEnabled(false); - expansionFrame.dispose(); - expansionFrame = null; - } - } + public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) { + messageText.setText("Guitar Hero 3 disconnected !"); + expansionText.setText("No expansion connected."); + showExpansionWiimoteButton.setEnabled(false); + showExpansionWiimoteButton.setText("No expansion"); + if (expansionFrame != null) { + if (expansionFrame instanceof GuitarHero3GuiTest) { + ((GuitarHero3GuiTest) expansionFrame).unRegisterListeners(); + } + expansionFrame.setEnabled(false); + expansionFrame.dispose(); + expansionFrame = null; + } + } - public void onClassicControllerInsertedEvent( - ClassicControllerInsertedEvent arg0) { + public void onClassicControllerInsertedEvent( + ClassicControllerInsertedEvent arg0) { messageText.setText("Classic controller connected !"); - expansionText.setText("Expansion connected : Classic Controller."); - showExpansionWiimoteButton.setEnabled(true); - showExpansionWiimoteButton.setText("Show Classic Controller"); - expansionFrame = new ClassicControllerGuiTest(wiimote); - expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); - expansionFrame.addWindowListener(buttonSetter); - } + expansionText.setText("Expansion connected : Classic Controller."); + showExpansionWiimoteButton.setEnabled(true); + showExpansionWiimoteButton.setText("Show Classic Controller"); + expansionFrame = new ClassicControllerGuiTest(wiimote); + expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + expansionFrame.addWindowListener(buttonSetter); + } - public void onClassicControllerRemovedEvent( - ClassicControllerRemovedEvent arg0) { - messageText.setText("Classic controller disconnected !"); - expansionText.setText("No expansion connected."); - showExpansionWiimoteButton.setEnabled(false); - showExpansionWiimoteButton.setText("No expansion"); - if (expansionFrame != null) { - if (expansionFrame instanceof ClassicControllerGuiTest) { - ((ClassicControllerGuiTest) expansionFrame).unRegisterListeners(); - } - expansionFrame.setEnabled(false); - expansionFrame.dispose(); - expansionFrame = null; - } - } + public void onClassicControllerRemovedEvent( + ClassicControllerRemovedEvent arg0) { + messageText.setText("Classic controller disconnected !"); + expansionText.setText("No expansion connected."); + showExpansionWiimoteButton.setEnabled(false); + showExpansionWiimoteButton.setText("No expansion"); + if (expansionFrame != null) { + if (expansionFrame instanceof ClassicControllerGuiTest) { + ((ClassicControllerGuiTest) expansionFrame).unRegisterListeners(); + } + expansionFrame.setEnabled(false); + expansionFrame.dispose(); + expansionFrame = null; + } + } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents private void initComponents() { @@ -872,415 +872,415 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements setBounds((screenSize.width-800)/2, (screenSize.height-600)/2, 800, 600); }// //GEN-END:initComponents - private void toggleRumbleButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleRumbleButtonMousePressed - if (toggleRumbleButton.isEnabled()) { - wiimote.activateRumble(); - toggleRumbleButton.setEnabled(false); - toggleRumbleButton.setText("Deactivate Rumble"); - messageText.setText("Rumble activated"); - } else { - wiimote.deactivateRumble(); - toggleRumbleButton.setEnabled(true); - toggleRumbleButton.setText("Activate Rumble"); - messageText.setText("Rumble deactivated"); - } - }// GEN-LAST:event_toggleRumbleButtonMousePressed + private void toggleRumbleButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleRumbleButtonMousePressed + if (toggleRumbleButton.isEnabled()) { + wiimote.activateRumble(); + toggleRumbleButton.setEnabled(false); + toggleRumbleButton.setText("Deactivate Rumble"); + messageText.setText("Rumble activated"); + } else { + wiimote.deactivateRumble(); + toggleRumbleButton.setEnabled(true); + toggleRumbleButton.setText("Activate Rumble"); + messageText.setText("Rumble deactivated"); + } + }// GEN-LAST:event_toggleRumbleButtonMousePressed - private void toggleIRTrackingButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleIRTrackingButtonMousePressed - if (toggleIRTrackingButton.isEnabled()) { - wiimote.activateIRTRacking(); - toggleIRTrackingButton.setEnabled(false); - toggleIRTrackingButton.setText("Deactivate IR Tracking"); - messageText.setText("IR Tracking activated"); - } else { - wiimote.deactivateIRTRacking(); - toggleIRTrackingButton.setEnabled(true); - toggleIRTrackingButton.setText("Activate IR Tracking"); - ((IRPanel) irViewPanel).onDisconnectionEvent(null); - messageText.setText("IR Tracking deactivated"); - } - }// GEN-LAST:event_toggleIRTrackingButtonMousePressed + private void toggleIRTrackingButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleIRTrackingButtonMousePressed + if (toggleIRTrackingButton.isEnabled()) { + wiimote.activateIRTRacking(); + toggleIRTrackingButton.setEnabled(false); + toggleIRTrackingButton.setText("Deactivate IR Tracking"); + messageText.setText("IR Tracking activated"); + } else { + wiimote.deactivateIRTRacking(); + toggleIRTrackingButton.setEnabled(true); + toggleIRTrackingButton.setText("Activate IR Tracking"); + ((IRPanel) irViewPanel).onDisconnectionEvent(null); + messageText.setText("IR Tracking deactivated"); + } + }// GEN-LAST:event_toggleIRTrackingButtonMousePressed - private void toggleMotionSensingTrackingButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleMotionSensingTrackingButtonMousePressed - if (toggleMotionSensingTrackingButton.isEnabled()) { - wiimote.activateMotionSensing(); - toggleMotionSensingTrackingButton.setEnabled(false); - toggleMotionSensingTrackingButton - .setText("Deactivate Motion Sensing"); - messageText.setText("Motion Sensing activated"); - } else { - wiimote.deactivateMotionSensing(); - toggleMotionSensingTrackingButton.setEnabled(true); - toggleMotionSensingTrackingButton - .setText("Activate Motion Sensing"); - ((OrientationPanel) motionSensingPanel).onDisconnectionEvent(null); - ((GForcePanel) gForcePanel).onDisconnectionEvent(null); - messageText.setText("Motion Sensing deactivated"); - } - }// GEN-LAST:event_toggleMotionSensingTrackingButtonMousePressed + private void toggleMotionSensingTrackingButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleMotionSensingTrackingButtonMousePressed + if (toggleMotionSensingTrackingButton.isEnabled()) { + wiimote.activateMotionSensing(); + toggleMotionSensingTrackingButton.setEnabled(false); + toggleMotionSensingTrackingButton + .setText("Deactivate Motion Sensing"); + messageText.setText("Motion Sensing activated"); + } else { + wiimote.deactivateMotionSensing(); + toggleMotionSensingTrackingButton.setEnabled(true); + toggleMotionSensingTrackingButton + .setText("Activate Motion Sensing"); + ((OrientationPanel) motionSensingPanel).onDisconnectionEvent(null); + ((GForcePanel) gForcePanel).onDisconnectionEvent(null); + messageText.setText("Motion Sensing deactivated"); + } + }// GEN-LAST:event_toggleMotionSensingTrackingButtonMousePressed - private void toggleSmoothingButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleSmoothingButtonMousePressed - if (toggleSmoothingButton.isEnabled()) { - wiimote.activateSmoothing(); - toggleSmoothingButton.setEnabled(false); - toggleSmoothingButton.setText("Deactivate Alpha Smoothing"); - messageText.setText("Alpha Smoothing activated"); - } else { - wiimote.deactivateSmoothing(); - toggleSmoothingButton.setEnabled(true); - toggleSmoothingButton.setText("Activate Alpha Smoothing"); - messageText.setText("Alpha Smoothing deactivated"); - } - }// GEN-LAST:event_toggleSmoothingButtonMousePressed + private void toggleSmoothingButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleSmoothingButtonMousePressed + if (toggleSmoothingButton.isEnabled()) { + wiimote.activateSmoothing(); + toggleSmoothingButton.setEnabled(false); + toggleSmoothingButton.setText("Deactivate Alpha Smoothing"); + messageText.setText("Alpha Smoothing activated"); + } else { + wiimote.deactivateSmoothing(); + toggleSmoothingButton.setEnabled(true); + toggleSmoothingButton.setText("Activate Alpha Smoothing"); + messageText.setText("Alpha Smoothing deactivated"); + } + }// GEN-LAST:event_toggleSmoothingButtonMousePressed - private void toggleContinuousButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleContinuousButtonMousePressed - if (toggleContinuousButton.isEnabled()) { - wiimote.activateContinuous(); - toggleContinuousButton.setEnabled(false); - toggleContinuousButton.setText("Deactivate Continuous"); - messageText.setText("Continuous activated"); - } else { - wiimote.deactivateContinuous(); - toggleContinuousButton.setEnabled(true); - toggleContinuousButton.setText("Activate Continuous"); - messageText.setText("Continuous deactivated"); - } - }// GEN-LAST:event_toggleContinuousButtonMousePressed + private void toggleContinuousButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleContinuousButtonMousePressed + if (toggleContinuousButton.isEnabled()) { + wiimote.activateContinuous(); + toggleContinuousButton.setEnabled(false); + toggleContinuousButton.setText("Deactivate Continuous"); + messageText.setText("Continuous activated"); + } else { + wiimote.deactivateContinuous(); + toggleContinuousButton.setEnabled(true); + toggleContinuousButton.setText("Activate Continuous"); + messageText.setText("Continuous deactivated"); + } + }// GEN-LAST:event_toggleContinuousButtonMousePressed - private void led1ButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_led1ButtonMousePressed - if (led1Button.isEnabled()) { - led1Button.setEnabled(false); - } else { - led1Button.setEnabled(true); - } - }// GEN-LAST:event_led1ButtonMousePressed + private void led1ButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_led1ButtonMousePressed + if (led1Button.isEnabled()) { + led1Button.setEnabled(false); + } else { + led1Button.setEnabled(true); + } + }// GEN-LAST:event_led1ButtonMousePressed - private void led2ButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_led2ButtonMousePressed - if (led2Button.isEnabled()) { - led2Button.setEnabled(false); - } else { - led2Button.setEnabled(true); - } - }// GEN-LAST:event_led2ButtonMousePressed + private void led2ButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_led2ButtonMousePressed + if (led2Button.isEnabled()) { + led2Button.setEnabled(false); + } else { + led2Button.setEnabled(true); + } + }// GEN-LAST:event_led2ButtonMousePressed - private void led3ButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_led3ButtonMousePressed - if (led3Button.isEnabled()) { - led3Button.setEnabled(false); - } else { - led3Button.setEnabled(true); - } - }// GEN-LAST:event_led3ButtonMousePressed + private void led3ButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_led3ButtonMousePressed + if (led3Button.isEnabled()) { + led3Button.setEnabled(false); + } else { + led3Button.setEnabled(true); + } + }// GEN-LAST:event_led3ButtonMousePressed - private void led4ButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_led4ButtonMousePressed - if (led4Button.isEnabled()) { - led4Button.setEnabled(false); - } else { - led4Button.setEnabled(true); - } - }// GEN-LAST:event_led4ButtonMousePressed + private void led4ButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_led4ButtonMousePressed + if (led4Button.isEnabled()) { + led4Button.setEnabled(false); + } else { + led4Button.setEnabled(true); + } + }// GEN-LAST:event_led4ButtonMousePressed - private void setLedsButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_setLedsButtonMousePressed - wiimote.setLeds(led1Button.isEnabled(), led2Button.isEnabled(), - led3Button.isEnabled(), led4Button.isEnabled()); - messageText.setText("Leds set"); - }// GEN-LAST:event_setLedsButtonMousePressed + private void setLedsButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_setLedsButtonMousePressed + wiimote.setLeds(led1Button.isEnabled(), led2Button.isEnabled(), + led3Button.isEnabled(), led4Button.isEnabled()); + messageText.setText("Leds set"); + }// GEN-LAST:event_setLedsButtonMousePressed - private void alphaSmoothingButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_alphaSmoothingButtonMousePressed - try { - float nb = Float.parseFloat(alphaSmoothingTextField.getText()); - wiimote.setAlphaSmoothingValue(nb); - messageText.setText("Alpha smoothing set to " + nb); - } catch (NumberFormatException e) { - messageText - .setText("Number is not a float, alpha smoothing not set !"); - } - }// GEN-LAST:event_alphaSmoothingButtonMousePressed + private void alphaSmoothingButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_alphaSmoothingButtonMousePressed + try { + float nb = Float.parseFloat(alphaSmoothingTextField.getText()); + wiimote.setAlphaSmoothingValue(nb); + messageText.setText("Alpha smoothing set to " + nb); + } catch (NumberFormatException e) { + messageText + .setText("Number is not a float, alpha smoothing not set !"); + } + }// GEN-LAST:event_alphaSmoothingButtonMousePressed - private void orientationThresholdButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_orientationThresholdButtonMousePressed - try { - float nb = Float - .parseFloat(orientationThresholdTextField.getText()); - wiimote.setOrientationThreshold(nb); - messageText.setText("Orientation threshold set to " + nb); - } catch (NumberFormatException e) { - messageText - .setText("Number is not a float, orientation threshold not set !"); - } - }// GEN-LAST:event_orientationThresholdButtonMousePressed + private void orientationThresholdButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_orientationThresholdButtonMousePressed + try { + float nb = Float + .parseFloat(orientationThresholdTextField.getText()); + wiimote.setOrientationThreshold(nb); + messageText.setText("Orientation threshold set to " + nb); + } catch (NumberFormatException e) { + messageText + .setText("Number is not a float, orientation threshold not set !"); + } + }// GEN-LAST:event_orientationThresholdButtonMousePressed - private void accelerationThresholdButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_accelerationThresholdButtonMousePressed - try { - int nb = Integer.parseInt(accelerationThresholdTextField.getText()); - wiimote.setAccelerationThreshold(nb); - messageText.setText("Acceleration threshold set to " + nb); - } catch (NumberFormatException e) { - messageText - .setText("Number is not an integer, acceleration threshold not set !"); - } - }// GEN-LAST:event_accelerationThresholdButtonMousePressed + private void accelerationThresholdButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_accelerationThresholdButtonMousePressed + try { + int nb = Integer.parseInt(accelerationThresholdTextField.getText()); + wiimote.setAccelerationThreshold(nb); + messageText.setText("Acceleration threshold set to " + nb); + } catch (NumberFormatException e) { + messageText + .setText("Number is not an integer, acceleration threshold not set !"); + } + }// GEN-LAST:event_accelerationThresholdButtonMousePressed - private void getStatusButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_getStatusButtonMousePressed - wiimote.getStatus(); - statusMotionRequested = true; - statusIRRequested = true; - if (expansionFrame instanceof NunchukGuiTest) { - ((NunchukGuiTest) expansionFrame).requestThresholdsUpdate(); - } - }// GEN-LAST:event_getStatusButtonMousePressed + private void getStatusButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_getStatusButtonMousePressed + wiimote.getStatus(); + statusMotionRequested = true; + statusIRRequested = true; + if (expansionFrame instanceof NunchukGuiTest) { + ((NunchukGuiTest) expansionFrame).requestThresholdsUpdate(); + } + }// GEN-LAST:event_getStatusButtonMousePressed - private void toggleSensorBarPositionButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleSensorBarPositionButtonMousePressed - if (toggleSensorBarPositionButton.isEnabled()) { - wiimote.setSensorBarBelowScreen(); - toggleSensorBarPositionButton.setEnabled(false); - toggleSensorBarPositionButton.setText("Set sensor bar below"); - messageText.setText("Sensor bar set above"); - } else { - wiimote.setSensorBarAboveScreen(); - toggleSensorBarPositionButton.setEnabled(true); - toggleSensorBarPositionButton.setText("Set sensor bar above"); - messageText.setText("Sensor bar set below"); - } - }// GEN-LAST:event_toggleSensorBarPositionButtonMousePressed + private void toggleSensorBarPositionButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleSensorBarPositionButtonMousePressed + if (toggleSensorBarPositionButton.isEnabled()) { + wiimote.setSensorBarBelowScreen(); + toggleSensorBarPositionButton.setEnabled(false); + toggleSensorBarPositionButton.setText("Set sensor bar below"); + messageText.setText("Sensor bar set above"); + } else { + wiimote.setSensorBarAboveScreen(); + toggleSensorBarPositionButton.setEnabled(true); + toggleSensorBarPositionButton.setText("Set sensor bar above"); + messageText.setText("Sensor bar set below"); + } + }// GEN-LAST:event_toggleSensorBarPositionButtonMousePressed - private void toggleScreenAspectRatioButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleScreenAspectRatioButtonMousePressed - if (toggleScreenAspectRatioButton.isEnabled()) { - wiimote.setScreenAspectRatio43(); - toggleScreenAspectRatioButton.setEnabled(false); - toggleScreenAspectRatioButton - .setText("Set screen aspect ratio 16/9"); - messageText.setText("creen aspect ratio to 4/3"); - } else { - wiimote.setScreenAspectRatio169(); - toggleScreenAspectRatioButton.setEnabled(true); - toggleScreenAspectRatioButton - .setText("Set screen aspect ratio 4/3"); - messageText.setText("Screen aspect ratio to 16/9"); - } - }// GEN-LAST:event_toggleScreenAspectRatioButtonMousePressed + private void toggleScreenAspectRatioButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleScreenAspectRatioButtonMousePressed + if (toggleScreenAspectRatioButton.isEnabled()) { + wiimote.setScreenAspectRatio43(); + toggleScreenAspectRatioButton.setEnabled(false); + toggleScreenAspectRatioButton + .setText("Set screen aspect ratio 16/9"); + messageText.setText("creen aspect ratio to 4/3"); + } else { + wiimote.setScreenAspectRatio169(); + toggleScreenAspectRatioButton.setEnabled(true); + toggleScreenAspectRatioButton + .setText("Set screen aspect ratio 4/3"); + messageText.setText("Screen aspect ratio to 16/9"); + } + }// GEN-LAST:event_toggleScreenAspectRatioButtonMousePressed - private void setVirtualResolutionButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_setVirtualResolutionButtonMousePressed - try { - int xres = Integer.parseInt(xResolutionTextField.getText()); - int yres = Integer.parseInt(yResolutionTextField.getText()); - wiimote.setVirtualResolution(xres, yres); - messageText.setText("Virtual resolution set to " + xres + "X" - + yres); - } catch (NumberFormatException e) { - messageText - .setText("A number in the virtual resolution is not an integer. Virtual resolution not set!"); - } - }// GEN-LAST:event_setVirtualResolutionButtonMousePressed + private void setVirtualResolutionButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_setVirtualResolutionButtonMousePressed + try { + int xres = Integer.parseInt(xResolutionTextField.getText()); + int yres = Integer.parseInt(yResolutionTextField.getText()); + wiimote.setVirtualResolution(xres, yres); + messageText.setText("Virtual resolution set to " + xres + "X" + + yres); + } catch (NumberFormatException e) { + messageText + .setText("A number in the virtual resolution is not an integer. Virtual resolution not set!"); + } + }// GEN-LAST:event_setVirtualResolutionButtonMousePressed - private void mouseIRControlButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_mouseIRControlButtonMousePressed - if (mouseIRControlButton.isEnabled()) { - try { - mouseIRControlButton.setEnabled(false); - mouseIRControlButton.setText("Stop infrared mouse control"); - robot = new Robot(); - messageText.setText("Infrared mouse control started"); - } catch (AWTException ex) { - Logger.getLogger(WiiuseJGuiTest.class.getName()).log( - Level.SEVERE, null, ex); - } - } else { - mouseIRControlButton.setEnabled(true); - mouseIRControlButton.setText("Start infrared mouse control"); - robot = null; - messageText.setText("Infrared mouse control stopped"); - } - }// GEN-LAST:event_mouseIRControlButtonMousePressed + private void mouseIRControlButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_mouseIRControlButtonMousePressed + if (mouseIRControlButton.isEnabled()) { + try { + mouseIRControlButton.setEnabled(false); + mouseIRControlButton.setText("Stop infrared mouse control"); + robot = new Robot(); + messageText.setText("Infrared mouse control started"); + } catch (AWTException ex) { + Logger.getLogger(WiiuseJGuiTest.class.getName()).log( + Level.SEVERE, null, ex); + } + } else { + mouseIRControlButton.setEnabled(true); + mouseIRControlButton.setText("Start infrared mouse control"); + robot = null; + messageText.setText("Infrared mouse control stopped"); + } + }// GEN-LAST:event_mouseIRControlButtonMousePressed - private void normalTimeoutSpinnerStateChanged( - javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_normalTimeoutSpinnerStateChanged - String value = normalTimeoutSpinner.getValue().toString(); - boolean isInt = true; - int valueInt = 0; - try { - valueInt = Integer.parseInt(value); - } catch (NumberFormatException e) { - isInt = false; - messageText.setText("Wrong value for normal timeout."); - } - if (isInt) { - if (valueInt > 1000) { - normalTimeoutSpinner.setValue("1000"); - } else if (valueInt < 0) { - normalTimeoutSpinner.setValue("0"); - } - } - }// GEN-LAST:event_normalTimeoutSpinnerStateChanged + private void normalTimeoutSpinnerStateChanged( + javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_normalTimeoutSpinnerStateChanged + String value = normalTimeoutSpinner.getValue().toString(); + boolean isInt = true; + int valueInt = 0; + try { + valueInt = Integer.parseInt(value); + } catch (NumberFormatException e) { + isInt = false; + messageText.setText("Wrong value for normal timeout."); + } + if (isInt) { + if (valueInt > 1000) { + normalTimeoutSpinner.setValue("1000"); + } else if (valueInt < 0) { + normalTimeoutSpinner.setValue("0"); + } + } + }// GEN-LAST:event_normalTimeoutSpinnerStateChanged - private void expansionHandshakeTimeoutSpinnerStateChanged( - javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_expansionHandshakeTimeoutSpinnerStateChanged - String value = expansionHandshakeTimeoutSpinner.getValue().toString(); - boolean isInt = true; - int valueInt = 0; - try { - valueInt = Integer.parseInt(value); - } catch (NumberFormatException e) { - isInt = false; - messageText.setText("Wrong value for expansion handshake timeout."); - } - if (isInt) { - if (valueInt > 1000) { - expansionHandshakeTimeoutSpinner.setValue("1000"); - } else if (valueInt < 0) { - expansionHandshakeTimeoutSpinner.setValue("0"); - } - } - }// GEN-LAST:event_expansionHandshakeTimeoutSpinnerStateChanged + private void expansionHandshakeTimeoutSpinnerStateChanged( + javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_expansionHandshakeTimeoutSpinnerStateChanged + String value = expansionHandshakeTimeoutSpinner.getValue().toString(); + boolean isInt = true; + int valueInt = 0; + try { + valueInt = Integer.parseInt(value); + } catch (NumberFormatException e) { + isInt = false; + messageText.setText("Wrong value for expansion handshake timeout."); + } + if (isInt) { + if (valueInt > 1000) { + expansionHandshakeTimeoutSpinner.setValue("1000"); + } else if (valueInt < 0) { + expansionHandshakeTimeoutSpinner.setValue("0"); + } + } + }// GEN-LAST:event_expansionHandshakeTimeoutSpinnerStateChanged - private void setIrSensitivySpinnerStateChanged( - javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_setIrSensitivySpinnerStateChanged - String value = setIrSensitivySpinner.getValue().toString(); - boolean isInt = true; - int valueInt = 0; - try { - valueInt = Integer.parseInt(value); - } catch (NumberFormatException e) { - isInt = false; - messageText.setText("Wrong value for IR senstivity."); - } - if (isInt) { - if (valueInt > 5) { - setIrSensitivySpinner.setValue("1000"); - } else if (valueInt < 0) { - setIrSensitivySpinner.setValue("0"); - } - } - }// GEN-LAST:event_setIrSensitivySpinnerStateChanged + private void setIrSensitivySpinnerStateChanged( + javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_setIrSensitivySpinnerStateChanged + String value = setIrSensitivySpinner.getValue().toString(); + boolean isInt = true; + int valueInt = 0; + try { + valueInt = Integer.parseInt(value); + } catch (NumberFormatException e) { + isInt = false; + messageText.setText("Wrong value for IR senstivity."); + } + if (isInt) { + if (valueInt > 5) { + setIrSensitivySpinner.setValue("1000"); + } else if (valueInt < 0) { + setIrSensitivySpinner.setValue("0"); + } + } + }// GEN-LAST:event_setIrSensitivySpinnerStateChanged - private void setIrSensitivyButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_setIrSensitivyButtonMousePressed - String value = setIrSensitivySpinner.getValue().toString(); - boolean isInt = true; - int valueInt = 0; - try { - valueInt = Integer.parseInt(value); - } catch (NumberFormatException e) { - isInt = false; - messageText - .setText("Wrong value for IR sensitivity. It must be an int !"); - } - if (isInt) { - if (valueInt >= 1 && valueInt <= 5) { - wiimote.setIrSensitivity(valueInt); - messageText.setText("IR senstivity set to: " + valueInt + "."); - } else { - messageText - .setText("Wrong value for IR senstivity. It muset be between 1 and 5 !"); - } - } - }// GEN-LAST:event_setIrSensitivyButtonMousePressed + private void setIrSensitivyButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_setIrSensitivyButtonMousePressed + String value = setIrSensitivySpinner.getValue().toString(); + boolean isInt = true; + int valueInt = 0; + try { + valueInt = Integer.parseInt(value); + } catch (NumberFormatException e) { + isInt = false; + messageText + .setText("Wrong value for IR sensitivity. It must be an int !"); + } + if (isInt) { + if (valueInt >= 1 && valueInt <= 5) { + wiimote.setIrSensitivity(valueInt); + messageText.setText("IR senstivity set to: " + valueInt + "."); + } else { + messageText + .setText("Wrong value for IR senstivity. It muset be between 1 and 5 !"); + } + } + }// GEN-LAST:event_setIrSensitivyButtonMousePressed - private void setTimeoutButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_setTimeoutButtonMousePressed - // get normal timeout - String value = normalTimeoutSpinner.getValue().toString(); - boolean isInt = true; - short valueInt = 0; - try { - valueInt = Short.parseShort(value); - } catch (NumberFormatException e) { - isInt = false; - messageText - .setText("Wrong value for normal timeout. It must be an int !"); - } - // get expansion handshake timeout - String value2 = expansionHandshakeTimeoutSpinner.getValue().toString(); - boolean isInt2 = true; - short valueInt2 = 0; - try { - valueInt2 = Short.parseShort(value2); - } catch (NumberFormatException e) { - isInt2 = false; - messageText - .setText("Wrong value for expansion handshake timeout. It must be an int !"); - } - if (isInt && isInt2) { - if (valueInt > 0 && valueInt2 > 0) { - wiimote.setTimeout(valueInt, valueInt2); - messageText.setText("Normal timeout set to: " + valueInt - + " and expansion handshake timeout set to: " - + valueInt2 + "!"); - } else { - messageText - .setText("Wrong value for one of the timeout value. It must be an integer > 0 !"); - } - } - }// GEN-LAST:event_setTimeoutButtonMousePressed + private void setTimeoutButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_setTimeoutButtonMousePressed + // get normal timeout + String value = normalTimeoutSpinner.getValue().toString(); + boolean isInt = true; + short valueInt = 0; + try { + valueInt = Short.parseShort(value); + } catch (NumberFormatException e) { + isInt = false; + messageText + .setText("Wrong value for normal timeout. It must be an int !"); + } + // get expansion handshake timeout + String value2 = expansionHandshakeTimeoutSpinner.getValue().toString(); + boolean isInt2 = true; + short valueInt2 = 0; + try { + valueInt2 = Short.parseShort(value2); + } catch (NumberFormatException e) { + isInt2 = false; + messageText + .setText("Wrong value for expansion handshake timeout. It must be an int !"); + } + if (isInt && isInt2) { + if (valueInt > 0 && valueInt2 > 0) { + wiimote.setTimeout(valueInt, valueInt2); + messageText.setText("Normal timeout set to: " + valueInt + + " and expansion handshake timeout set to: " + + valueInt2 + "!"); + } else { + messageText + .setText("Wrong value for one of the timeout value. It must be an integer > 0 !"); + } + } + }// GEN-LAST:event_setTimeoutButtonMousePressed - private void reconnectWiimotesButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_reconnectWiimotesButtonMousePressed - // stop manager - WiiUseApiManager.shutdown(); + private void reconnectWiimotesButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_reconnectWiimotesButtonMousePressed + // stop manager + WiiUseApiManager.shutdown(); - // unregister previous wiimote - if (wiimote != null) { - onDisconnectionEvent(null); - } + // unregister previous wiimote + if (wiimote != null) { + onDisconnectionEvent(null); + } - // Reset Gui - // remove frame for expansion - if (expansionFrame != null) { - if (expansionFrame instanceof NunchukGuiTest) { - ((NunchukGuiTest) expansionFrame).unRegisterListeners(); - }else if (expansionFrame instanceof ClassicControllerGuiTest) { - ((ClassicControllerGuiTest) expansionFrame).unRegisterListeners(); - } - expansionFrame.setEnabled(false); - expansionFrame.dispose(); - expansionFrame = null; - } + // Reset Gui + // remove frame for expansion + if (expansionFrame != null) { + if (expansionFrame instanceof NunchukGuiTest) { + ((NunchukGuiTest) expansionFrame).unRegisterListeners(); + }else if (expansionFrame instanceof ClassicControllerGuiTest) { + ((ClassicControllerGuiTest) expansionFrame).unRegisterListeners(); + } + expansionFrame.setEnabled(false); + expansionFrame.dispose(); + expansionFrame = null; + } - // setup buttons In first state - toggleRumbleButton.setText("Activate Rumble"); - toggleRumbleButton.setEnabled(true); - toggleMotionSensingTrackingButton - .setText("Activate motion sensing Tracking"); - toggleMotionSensingTrackingButton.setEnabled(true); - toggleIRTrackingButton.setText("Activate IR Tracking"); - toggleIRTrackingButton.setEnabled(true); - toggleContinuousButton.setText("Activate Continuous"); - toggleContinuousButton.setEnabled(true); - toggleScreenAspectRatioButton.setText("Set screen aspect ratio 4/3"); - toggleScreenAspectRatioButton.setEnabled(true); - toggleSensorBarPositionButton.setText("Set sensor bar above"); - toggleSensorBarPositionButton.setEnabled(true); - toggleSmoothingButton.setText("Activate Smoothing"); - toggleSmoothingButton.setEnabled(true); - mouseIRControlButton.setText("Start infrared mouse control"); - mouseIRControlButton.setEnabled(true); + // setup buttons In first state + toggleRumbleButton.setText("Activate Rumble"); + toggleRumbleButton.setEnabled(true); + toggleMotionSensingTrackingButton + .setText("Activate motion sensing Tracking"); + toggleMotionSensingTrackingButton.setEnabled(true); + toggleIRTrackingButton.setText("Activate IR Tracking"); + toggleIRTrackingButton.setEnabled(true); + toggleContinuousButton.setText("Activate Continuous"); + toggleContinuousButton.setEnabled(true); + toggleScreenAspectRatioButton.setText("Set screen aspect ratio 4/3"); + toggleScreenAspectRatioButton.setEnabled(true); + toggleSensorBarPositionButton.setText("Set sensor bar above"); + toggleSensorBarPositionButton.setEnabled(true); + toggleSmoothingButton.setText("Activate Smoothing"); + toggleSmoothingButton.setEnabled(true); + mouseIRControlButton.setText("Start infrared mouse control"); + mouseIRControlButton.setEnabled(true); - // get wiimote - Wiimote[] listWiimote = WiiUseApiManager.getWiimotes(1, true); - if (listWiimote != null && listWiimote.length > 0) { - wiimote = listWiimote[0]; + // get wiimote + Wiimote[] listWiimote = WiiUseApiManager.getWiimotes(1, true); + if (listWiimote != null && listWiimote.length > 0) { + wiimote = listWiimote[0]; - // registers listeners - registerListeners(); - initWiimote(); + // registers listeners + registerListeners(); + initWiimote(); - isFirstStatusGot = false; - getStatusButtonMousePressed(null); - } - }// GEN-LAST:event_reconnectWiimotesButtonMousePressed + isFirstStatusGot = false; + getStatusButtonMousePressed(null); + } + }// GEN-LAST:event_reconnectWiimotesButtonMousePressed - private void showExpansionWiimoteButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_showExpansionWiimoteButtonMousePressed - if (expansionFrame != null) { - if (showExpansionWiimoteButton.isEnabled()) {// expansion frame - // not shown - // show it - expansionFrame.setEnabled(true); - expansionFrame.setVisible(true); - showExpansionWiimoteButton.setEnabled(false); + private void showExpansionWiimoteButtonMousePressed( + java.awt.event.MouseEvent evt) {// GEN-FIRST:event_showExpansionWiimoteButtonMousePressed + if (expansionFrame != null) { + if (showExpansionWiimoteButton.isEnabled()) {// expansion frame + // not shown + // show it + expansionFrame.setEnabled(true); + expansionFrame.setVisible(true); + showExpansionWiimoteButton.setEnabled(false); if (expansionFrame instanceof NunchukGuiTest){ showExpansionWiimoteButton.setText("Hide Nunchuk"); messageText.setText("Nunchuk displayed !"); @@ -1291,10 +1291,10 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements showExpansionWiimoteButton.setText("Hide Classic controller"); messageText.setText("Classic controller displayed !"); } - } else {// already being shown - expansionFrame.setEnabled(false); - expansionFrame.setVisible(false); - showExpansionWiimoteButton.setEnabled(true); + } else {// already being shown + expansionFrame.setEnabled(false); + expansionFrame.setVisible(false); + showExpansionWiimoteButton.setEnabled(true); if (expansionFrame instanceof NunchukGuiTest){ showExpansionWiimoteButton.setText("Show Nunchuk"); messageText.setText("Nunchuk hidden !"); @@ -1304,10 +1304,10 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements }else if(expansionFrame instanceof ClassicControllerGuiTest){ showExpansionWiimoteButton.setText("Show Classic controller"); messageText.setText("Classic controller hidden !"); - } - } - } - }// GEN-LAST:event_showExpansionWiimoteButtonMousePressed + } + } + } + }// GEN-LAST:event_showExpansionWiimoteButtonMousePressed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel accelerationPanel;